Exemplo n.º 1
0
void FlatLabel::setRichText(const QString &text) {
	textstyleSet(&_tst);
	_text.setRichText(_st.font, text, _labelOptions);
	refreshSize();
	textstyleRestore();
	setMouseTracking(_selectable || _text.hasLinks());
}
Exemplo n.º 2
0
void FlatLabel::setMarkedText(const TextWithEntities &textWithEntities) {
	textstyleSet(&_tst);
	_text.setMarkedText(_st.font, textWithEntities, _labelMarkedOptions);
	refreshSize();
	textstyleRestore();
	setMouseTracking(_selectable || _text.hasLinks());
}
void CompressedPixmap::addRangeRegions(const std::vector<RangeRegionDescriptor>& regions)
{
    for (const RangeRegionDescriptor& region : regions)
        m_rangeRegions.push_back(region);

    refreshSize();
}
Exemplo n.º 4
0
bool EditText::handleInput(unsigned int key)
{
  if( ( key == GLFW_KEY_ENTER) || (key == GLFW_KEY_KP_ENTER ) )
  {
    m_input_mode = false;
    Engine::unsetGUIMovementLock();
    refreshSize();
    return true;
  }
  else
  {
    if( key == GLFW_KEY_BACKSPACE)
    {
      if(m_text.size() >0)
        m_text.pop_back();
    }
    else
    {
      char k = (char)key; 
      if(  ( key >= 65 ) && ( key <91 )  ) // differentiate captitol and lower case
      {
        if( ! IOSubsystem::isKeyPressed(GLFW_KEY_LEFT_SHIFT))
        {
          k = (char) (key+32);
        }
        std::cout << k <<std::endl;
        std::stringstream ss;
        ss << m_text << k;
        m_text = ss.str();
      }
      else
      {
        if( ( key >= 320 ) && ( key <329 ) )  // numpad numbers
        {
           k = (char) (key-272);
        }
        if(key == GLFW_KEY_KP_DECIMAL )
          k = '.';
        if(key == GLFW_KEY_KP_ADD )
          k = '+';
        if(key == GLFW_KEY_KP_SUBTRACT )
          k = '-';
        if(key == GLFW_KEY_KP_DIVIDE )
          k = '/';
        if(key == GLFW_KEY_KP_MULTIPLY )
          k = '*';
        //std::cout << k <<std::endl;
        std::stringstream ss;
        ss << m_text << k;
        m_text = ss.str();
      }
    }
  }
  return false;
}
void AsemanNativeNotificationItem::resizeEvent(QResizeEvent *e)
{
    refreshSize();
    QWidget::resizeEvent(e);
}
AsemanNativeNotificationItem::AsemanNativeNotificationItem(QWidget *parent) :
    QWidget(parent)
{
    p = new AsemanNativeNotificationItemPrivate;
    p->shadow_color = QColor( SHADOW_COLOR );

    p->back = new DialogBack(this);
    p->back->setColor( p->shadow_color );

    p->scene = new DialogScene( this );

    p->title_lbl = new QLabel();
    p->title_lbl->setAlignment(Qt::AlignCenter);
    p->title_lbl->setFixedHeight(26);

    p->close_btn = new QToolButton();
    p->close_btn->setText("X");
    p->close_btn->setFixedSize(26, 26);
    p->close_btn->setAutoRaise(true);

    p->ttle_layout = new QHBoxLayout();
    p->ttle_layout->addWidget(p->title_lbl);
    p->ttle_layout->addWidget(p->close_btn);
    p->ttle_layout->setContentsMargins(0,0,0,0);
    p->ttle_layout->setSpacing(1);

    p->icon_lbl = new QLabel();
    p->icon_lbl->setFixedSize(64, 64);
    p->icon_lbl->setScaledContents(true);

    p->body_lbl = new QLabel();
    p->body_lbl->setWordWrap(true);

    p->btns_layout = new QVBoxLayout();
    p->btns_layout->setContentsMargins(0,0,0,0);
    p->btns_layout->setSpacing(1);

    p->body_layout = new QHBoxLayout();
    p->body_layout->addWidget(p->icon_lbl);
    p->body_layout->addWidget(p->body_lbl, 10000);
    p->body_layout->addLayout(p->btns_layout);
    p->body_layout->setContentsMargins(0,0,0,0);
    p->body_layout->setSpacing(8);

    p->layout = new QVBoxLayout(this);
    p->layout->addLayout(p->ttle_layout);
    p->layout->addLayout(p->body_layout);
    p->layout->setContentsMargins(SHADOW_SIZE+10,SHADOW_SIZE+8,SHADOW_SIZE+10,SHADOW_SIZE+8);
    p->layout->setSpacing(1);

    setWindowFlags( Qt::Window | Qt::FramelessWindowHint | Qt::ToolTip );
    setAttribute(Qt::WA_TranslucentBackground);
    setAttribute(Qt::WA_NoSystemBackground);
    setAttribute(Qt::WA_DeleteOnClose);
    setMouseTracking( true );
    setWindowOpacity(0.9);

    refreshSize();

    connect(p->close_btn, SIGNAL(clicked()), SLOT(close()) );
}
void CompressedPixmap::loadFromStream(std::istream& inputStream)
{
    PixmapHeader header;

    inputStream.read((char*)&header, sizeof(PixmapHeader));

    int bitAccessor = 1;

    for (int i = 0; i < header.domainRegionCount; ++i)
    {
        unsigned long packed;
        inputStream.read((char*)&packed, 4);

        std::bitset<32> bitset(packed);
        DomainRegionDescriptor domainRegion = { 0, 0, 0 };

        for (int j = 0; j < 13; ++j)
        {
            if (bitset[j])
                domainRegion.x += bitAccessor;

            bitAccessor <<= 1;
        }

        bitAccessor = 1;
        for (int j = 0; j < 13; ++j)
        {
            if (bitset[13 + j])
                domainRegion.y += bitAccessor;

            bitAccessor <<= 1;
        }

        bitAccessor = 1;
        for (int j = 0; j < 6; ++j)
        {
            if (bitset[26 + j])
                domainRegion.size += bitAccessor;

            bitAccessor <<= 1;
        }

        m_domainRegions.push_back(domainRegion);

        bitAccessor = 1;
    }

    for (int i = 0; i < header.rangeRegionCount; ++i)
    {
        unsigned long long packed;
        inputStream.read((char*)&packed, 7);

        std::bitset<58> bitset(packed);
        RangeRegionDescriptor rangeRegion = { 0, 0, 0, 0, 0, 0 };

        for (int j = 0; j < 13; ++j)
        {
            if (bitset[j])
                rangeRegion.x += bitAccessor;

            bitAccessor <<= 1;
        }

        bitAccessor = 1;
        for (int j = 0; j < 13; ++j)
        {
            if (bitset[13 + j])
                rangeRegion.y += bitAccessor;

            bitAccessor <<= 1;
        }

        bitAccessor = 1;
        for (int j = 0; j < 4; ++j)
        {
            if (bitset[26 + j])
                rangeRegion.size += bitAccessor;

            bitAccessor <<= 1;
        }

        bitAccessor = 1;
        for (int j = 0; j < 14; ++j)
        {
            if (bitset[30 + j])
                rangeRegion.domainRegionIndex += bitAccessor;

            bitAccessor <<= 1;
        }

        bitAccessor = 1;
        for (int j = 0; j < 4; ++j)
        {
            if (bitset[44 + j])
                rangeRegion.transformation += bitAccessor;

            bitAccessor <<= 1;
        }

        bitAccessor = 1;
        for (int j = 0; j < 8; ++j)
        {
            if (bitset[48 + j])
                rangeRegion.firstPixelValue += bitAccessor;

            bitAccessor <<= 1;
        }

        m_rangeRegions.push_back(rangeRegion);

        bitAccessor = 1;
    }

    refreshSize();
}