void Graphics::drawText(const char_t* text, ulong_t length, const Point& topLeft, bool inverted) { FontEffects fx = font_.effects(); PalmUnderlineSetter setUnderline(convertUnderlineMode(fx.underline())); ScalingSetter setScaling(*this); uint_t height = fontHeight(); uint_t top=topLeft.y; if (fx.subscript()) top+=(height/3); if (inverted) WinDrawInvertedChars(text, length, topLeft.x, top); else WinDrawChars(text, length, topLeft.x, top); if (fx.strikeOut()) { uint_t baseline = fontBaseline(); top=topLeft.y + (baseline*2)/3; uint_t width = FntCharsWidth(text, length); Color_t color=setTextColor(0); setTextColor(color); // Quite strange method of querying current text color... color=setForegroundColor(color); WinDrawOperation old; if (inverted) old=WinSetDrawMode(winInvert); drawLine(topLeft.x, top, topLeft.x+width, top); if (inverted) WinSetDrawMode(old); setForegroundColor(color); } }
void URLLabel::enterEvent(QEvent* e) { QLabel::enterEvent(e); if(!d->AltPixmap.isNull() && pixmap()) { d->RealPixmap = *pixmap(); setPixmap(d->AltPixmap); } if(d->Glow || d->Float) { d->Timer->stop(); setLinkColor(d->HighlightedLinkColor); d->RealUnderline = d->Underline; if(d->Float) setUnderline(true); } emit enteredURL(); emit enteredURL(d->URL); }
KateAttribute& KateAttribute::operator+=(const KateAttribute& a) { if (a.itemSet(Weight)) setWeight(a.weight()); if (a.itemSet(Italic)) setItalic(a.italic()); if (a.itemSet(Underline)) setUnderline(a.underline()); if (a.itemSet(Overline)) setOverline(a.overline()); if (a.itemSet(StrikeOut)) setStrikeOut(a.strikeOut()); if (a.itemSet(Outline)) setOutline(a.outline()); if (a.itemSet(TextColor)) setTextColor(a.textColor()); if (a.itemSet(SelectedTextColor)) setSelectedTextColor(a.selectedTextColor()); if (a.itemSet(BGColor)) setBGColor(a.bgColor()); if (a.itemSet(SelectedBGColor)) setSelectedBGColor(a.selectedBGColor()); return *this; }
void RzxTextEdit::setFormat(const Format& format) { setFont(format.family); setSize(format.size); setBold(format.bold); setItalic(format.italic); setUnderline(format.underlined); setColor(format.color); }
JFont::JFont(int face, int style, int size) : QFont(), metrics(*this) { int qfont_size; QString qfont_family; switch (size) { case SIZE_SMALL: qfont_size = QFONT_SIZE_SMALL; break; default: case SIZE_MEDIUM: qfont_size = QFONT_SIZE_MEDIUM; break; case SIZE_LARGE: qfont_size = QFONT_SIZE_LARGE; break; } setPointSize(qfont_size); switch (face) { case FACE_SYSTEM: qfont_family = QFONT_FAMILY_SYSTEM; break; default: case FACE_PROPORTIONAL: qfont_family = QFONT_FAMILY_PROPORTIONAL; break; case FACE_MONOSPACE: qfont_family = QFONT_FAMILY_MONOSPACE; break; } setFamily(qfont_family); if (style & STYLE_BOLD) setBold(true); if (style & STYLE_ITALIC) setItalic(true); if (style & STYLE_UNDERLINED) setUnderline(true); metrics = QFontMetrics(*this, JApplication::desktop()->screen()); id = attrs2id(face, style, size); cache[id] = this; }
void URLLabel::leaveEvent(QEvent* e) { QLabel::leaveEvent(e); if(!d->AltPixmap.isNull() && pixmap()) setPixmap(d->RealPixmap); if((d->Glow || d->Float) && !d->Timer->isActive()) setLinkColor(d->LinkColor); setUnderline(d->RealUnderline); emit leftURL(); emit leftURL(d->URL.toString()); }
void KUrlLabel::leaveEvent( QEvent* event ) { QLabel::leaveEvent( event ); if ( !d->alternatePixmap.isNull() && pixmap() ) setPixmap( d->realPixmap ); if ( (d->glowEnabled || d->floatEnabled) && !d->timer->isActive() ) d->setLinkColor( d->linkColor ); setUnderline( d->realUnderlined ); emit leftUrl(); emit leftUrl( d->url ); }
void Connection::InitGui() { if (mTarget.GetModule()->GetSocket(mSocket) == nullptr) { // no connection if (mConnectable) { ui.BtnAction->setText(tr("Connect")); } else { // no connection and we cant connect source ui.BtnAction->setText(tr("...")); ui.BtnAction->setEnabled(false); } } else { // connection ui.BtnAction->setText(tr("Disconnect")); ui.LineConnected->setText(mTarget.GetModule()->GetSocket(mSocket)->GetId().c_str()); } // socket name ui.LabelName->setText(mTarget.GetModule()->GetInputSockets()[mSocket]->GetName().c_str()); // slots & signals connect(ui.BtnInterface, SIGNAL(clicked()), this, SLOT(slInterface())); connect(ui.BtnAction, SIGNAL(clicked()), this, SLOT(slAction())); // description std::string desc = mTarget.GetModule()->GetInputSockets()[mSocket]->GetDescription(); if (desc.empty()) { // no description } else { // has description auto font = ui.LabelName->font(); font.setUnderline(true); ui.LabelName->setFont(font); ui.LabelName->setToolTip(desc.c_str()); } }
void KUrlLabel::enterEvent( QEvent* event ) { QLabel::enterEvent( event ); if ( !d->alternatePixmap.isNull() && pixmap() ) { d->realPixmap = *pixmap(); setPixmap( d->alternatePixmap ); } if ( d->glowEnabled || d->floatEnabled ) { d->timer->stop(); d->setLinkColor( d->highlightedLinkColor ); d->realUnderlined = d->textUnderlined; if ( d->floatEnabled ) setUnderline( true ); } emit enteredUrl(); emit enteredUrl( d->url ); }
void *TextEdit::processEvent(Event *e) { if (m_param == NULL) return NULL; if (e->type() == EventCheckState){ CommandDef *cmd = (CommandDef*)(e->param()); if (cmd->param != m_param) return NULL; switch (cmd->id){ case CmdBgColor: case CmdFgColor: case CmdBold: case CmdItalic: case CmdUnderline: case CmdFont: if ((textFormat() == RichText) && !isReadOnly()){ cmd->flags &= ~BTN_HIDE; }else{ cmd->flags |= BTN_HIDE; } return e->param(); default: return NULL; } } if (e->type() == EventCommandExec){ CommandDef *cmd = (CommandDef*)(e->param()); if (cmd->param != m_param) return NULL; switch (cmd->id){ case CmdBgColor:{ Event eWidget(EventCommandWidget, cmd); CToolButton *btnBg = (CToolButton*)(eWidget.process()); if (btnBg){ ColorPopup *popup = new ColorPopup(this, background()); popup->move(CToolButton::popupPos(btnBg, popup)); connect(popup, SIGNAL(colorChanged(QColor)), this, SLOT(bgColorChanged(QColor))); popup->show(); } return e->param(); } case CmdFgColor:{ Event eWidget(EventCommandWidget, cmd); CToolButton *btnFg = (CToolButton*)(eWidget.process()); if (btnFg){ ColorPopup *popup = new ColorPopup(this, foreground()); popup->move(CToolButton::popupPos(btnFg, popup)); connect(popup, SIGNAL(colorChanged(QColor)), this, SLOT(fgColorChanged(QColor))); popup->show(); } return e->param(); } case CmdBold: m_bSelected = true; setBold((cmd->flags & COMMAND_CHECKED) != 0); return e->param(); case CmdItalic: m_bSelected = true; setItalic((cmd->flags & COMMAND_CHECKED) != 0); return e->param(); case CmdUnderline: m_bSelected = true; setUnderline((cmd->flags & COMMAND_CHECKED) != 0); return e->param(); case CmdFont:{ #ifdef USE_KDE QFont f = font(); if (KFontDialog::getFont(f, false, topLevelWidget()) != KFontDialog::Accepted) break; #else bool ok = false; QFont f = QFontDialog::getFont(&ok, font(), topLevelWidget()); if (!ok) break; #endif m_bSelected = true; setCurrentFont(f); break; } default: return NULL; } } return NULL; }
void RichEdit::addHtml(const wchar_t* html) { size_t i = 0, j, len = wcslen(html); FastStrBuff tmp; bool insideTag = false; while(i < len) { switch(html[i]) { case L'\r': case L'\n': break; case L'<': if(tmp.size() > 0) { addText(tmp.c_str()); tmp.clear(); } insideTag = true; break; case L'>': insideTag = false; if(tmp.equalIC(L"b")) setBold(true); else if(tmp.equalIC(L"/b")) setBold(false); else if(tmp.equalIC(L"i")) setItalic(true); else if(tmp.equalIC(L"/i")) setItalic(false); else if(tmp.equalIC(L"u")) setUnderline(true); else if(tmp.equalIC(L"/u")) setUnderline(false); else if(tmp.equalIC(L"br") || tmp.equalIC(L"br/") || tmp.equalIC(L"br /")) { addText(L"\r\n"); setFontColor(_defaultCf.crTextColor); } else if(tmp.size() > 4) { std::wstring tag = tmp.firstChars(3); if(tag == L"img" || tag == L"IMG") handleImg(tmp.c_str()); } tmp.clear(); break; case L'&': if(insideTag) { tmp.push_back(html[i]); // it's tag, don't care break; } if(len > i + 3) { // < if(html[i+1] == L'l' && html[i+2] == L't' && html[i+3] == L';') { addText(tmp.c_str()); tmp.clear(); addText(L"<"); i += 3; break; } // > else if(html[i+1] == L'g' && html[i+2] == L't' && html[i+3] == L';') { addText(tmp.c_str()); tmp.clear(); addText(L">"); i += 3; break; } } if(len > i + 4) { // & if(html[i+1] == L'a' && html[i+2] == L'm' && html[i+3] == L'p' && html[i+4] == L';') { addText(tmp.c_str()); tmp.clear(); addText(L"&"); i += 4; break; } } if(len > i + 5) { // " if(html[i+1] == L'q' && html[i+2] == L'u' && html[i+3] == L'o' && html[i+4] == L't' && html[i+5] == L';') { addText(tmp.c_str()); tmp.clear(); addText(L"\""); i += 5; break; } // else if(html[i+1] == L'n' && html[i+2] == L'b' && html[i+3] == L's' && html[i+4] == L'p' && html[i+5] == L';') { addText(tmp.c_str()); tmp.clear(); addText(L" "); i += 5; break; } // ' else if(html[i+1] == L'a' && html[i+2] == L'p' && html[i+3] == L'o' && html[i+4] == L's' && html[i+5] == L';') { addText(tmp.c_str()); tmp.clear(); addText(L"'"); i += 5; break; } } // &#xxxx; if(len > i + 6 && html[i+1] == L'#' && html[i+6] == L';') { wchar_t hex[4]; bool valid = true; for(j=0; j<4; j++) { hex[j] = html[i+j+2]; if(hex[j] < L'0' || hex[j] > L'9') { valid = false; break; } hex[j] -= 0x30; } addText(tmp.c_str()); tmp.clear(); if(valid) { wchar_t letter[2] = {0,0}; letter[0] = hex[0]*1000 + hex[1]*100 + hex[2]*10 + hex[3]; addText(letter); } i += 6; break; } tmp.push_back(html[i]); // if & not for special char break; default: tmp.push_back(html[i]); } i++; } if(tmp.size() > 0) addText(tmp.c_str()); }
NotepadWin::NotepadWin(Notepad *notepad, SaveFunctionPointer sv, QWidget *parent) : QWidget(parent) { pad = notepad; saveText = sv; layout = new QVBoxLayout(this); layout->setContentsMargins(0, 0, 0, 0); setLayout(layout); edit = new QTextEdit(); layout->addWidget(edit); connect(edit, SIGNAL(textChanged()), this, SLOT(textChanged())); panel = new QWidget(); panel->setFixedHeight(25); layout->addWidget(edit); /*QFile file("/home/nay/.razor/desktop/notepad.qss"); file.open(QFile::ReadOnly); QString styleSheet = QLatin1String(file.readAll()); setStyleSheet(styleSheet); file.close();*/ panelLayout = new QHBoxLayout(); layout->addLayout(panelLayout); bold = new QToolButton(); bold->setText(QString("B")); bold->setIcon(XdgIcon::fromTheme("format-text-bold")); italic = new QToolButton(); italic->setText(QString("I")); italic->setIcon(XdgIcon::fromTheme("format-text-italic")); underline = new QToolButton(); underline->setText(QString("U")); underline->setIcon(XdgIcon::fromTheme("format-text-underline")); strikethrough = new QToolButton(); strikethrough->setText(QString("S")); strikethrough->setIcon(XdgIcon::fromTheme("format-text-strikethrough")); leftSided = new QToolButton(); leftSided->setText(QString("L")); leftSided->setIcon(XdgIcon::fromTheme("format-justify-left")); centered = new QToolButton(); centered->setText(QString("C")); centered->setIcon(XdgIcon::fromTheme("format-justify-center")); rightSided = new QToolButton(); rightSided->setText(QString("R")); rightSided->setIcon(XdgIcon::fromTheme("format-justify-right")); justified = new QToolButton(); justified->setText(QString("J")); justified->setIcon(XdgIcon::fromTheme("format-justify-fill")); int btnWidth = 21; bold->setCheckable(true); italic->setCheckable(true); underline->setCheckable(true); strikethrough->setCheckable(true); leftSided->setCheckable(true); centered->setCheckable(true); rightSided->setCheckable(true); justified->setCheckable(true); bold->setFixedWidth(btnWidth); italic->setFixedWidth(btnWidth); underline->setFixedWidth(btnWidth); strikethrough->setFixedWidth(btnWidth); leftSided->setFixedWidth(btnWidth); centered->setFixedWidth(btnWidth); rightSided->setFixedWidth(btnWidth); justified->setFixedWidth(btnWidth); bold->setObjectName(QString("boldButton")); italic->setObjectName(QString("italicButton")); underline->setObjectName(QString("underlineButton")); strikethrough->setObjectName(QString("strikethroughButton")); leftSided->setObjectName(QString("leftSided")); centered->setObjectName(QString("centered")); rightSided->setObjectName(QString("rightSided")); justified->setObjectName(QString("justified")); panelLayout->addWidget(bold); panelLayout->addWidget(italic); panelLayout->addWidget(underline); panelLayout->addWidget(strikethrough); panelLayout->setSpacing(0); panelLayout->addWidget(leftSided); panelLayout->addWidget(centered); panelLayout->addWidget(rightSided); panelLayout->addWidget(justified); layout->setAlignment(panelLayout, Qt::AlignLeft); connect(bold, SIGNAL(clicked()), this, SLOT(setBold())); connect(italic, SIGNAL(clicked()), this, SLOT(setItalic())); connect(underline, SIGNAL(clicked()), this, SLOT(setUnderline())); connect(strikethrough, SIGNAL(clicked()), this, SLOT(setStrike())); connect(leftSided, SIGNAL(clicked()), this, SLOT(setLeftSided())); connect(centered, SIGNAL(clicked()), this, SLOT(setCentered())); connect(rightSided, SIGNAL(clicked()), this, SLOT(setRightSided())); connect(justified, SIGNAL(clicked()), this, SLOT(setJustified())); connect(edit, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged())); connect(edit, SIGNAL(cursorPositionChanged()), this, SLOT(onSelectionChanged())); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); // QString s = QString::number(colors[1][0]); // ui->textEdit->append(s); // colors = new int*[12]; // for(int i = 0; i < 12; ++i){ // colors[i] = new int[3]; // } connect(ui->italic,SIGNAL(clicked()),this,SLOT(setItalic())); connect(ui->underline,SIGNAL(clicked()),this,SLOT(setUnderline())); connect(ui->bold,SIGNAL(clicked()),this,SLOT(setBold())); connect(ui->sizebox,SIGNAL(currentIndexChanged(int)),this,SLOT(setSize(int))); connect(ui->alignLeft,SIGNAL(clicked()),this,SLOT(setAlignLeft())); connect(ui->alignCenter,SIGNAL(clicked()),this,SLOT(setAlignCenter())); connect(ui->alignRight,SIGNAL(clicked()),this,SLOT(setAlignRight())); connect(ui->justify,SIGNAL(clicked()),this,SLOT(setJustify())); // connect(ui->foregroundCombo,SIGNAL(clicked()),this,SLOT(colorHandle())); //connect(ui->backColorChooser,SIGNAL(clicked()),this,SLOT(backColorHandle())); connect(ui->fontComboBox,SIGNAL(currentFontChanged(QFont)),this,SLOT(setFont(QFont))); connect(ui->menuEdit,SIGNAL(triggered()),this,SLOT(enablePasteee())); connect(ui->menuEdit,SIGNAL(clicked()),this,SLOT(enablePasteee())); connect(ui->menuEdit,SIGNAL(hovered()),this,SLOT(enablePasteee())); connect(ui->actionUndo,SIGNAL(triggered()),this,SLOT(undo())); connect(ui->actionREdo,SIGNAL(triggered()),this,SLOT(redo())); connect(ui->actionCopy,SIGNAL(triggered()),this,SLOT(copy())); connect(ui->actionCut,SIGNAL(triggered()),this,SLOT(cut())); connect(ui->actionPaste_2,SIGNAL(triggered()),this,SLOT(paste())); connect(ui->actionLoad,SIGNAL(triggered()),this,SLOT(load())); connect(ui->actionSave,SIGNAL(triggered()),this,SLOT(save())); connect(ui->actionSelectAll,SIGNAL(triggered()),this,SLOT(selectAll())); connect(ui->actionExit,SIGNAL(triggered()),this,SLOT(exit())); QIcon *i0 = new QIcon(":/new/colors/0.png"); QIcon *i1 = new QIcon(":/new/colors/1.png"); QIcon *i2 = new QIcon(":/new/colors/2.png"); QIcon *i3 = new QIcon(":/new/colors/3.png"); QIcon *i4 = new QIcon(":/new/colors/4.png"); QIcon *i5 = new QIcon(":/new/colors/5.png"); QIcon *i6 = new QIcon(":/new/colors/6.png"); QIcon *i7 = new QIcon(":/new/colors/7.png"); QIcon *i8 = new QIcon(":/new/colors/8.png"); QIcon *i9 = new QIcon(":/new/colors/9.png"); QIcon *i10 = new QIcon(":/new/colors/10.png"); QIcon *i11 = new QIcon(":/new/colors/11.png"); QIcon *i12 = new QIcon(":/new/colors/12.png"); QIcon *i13 = new QIcon(":/new/colors/13.png"); QIcon *i14 = new QIcon(":/new/colors/14.png"); QIcon *i15 = new QIcon(":/new/colors/15.png"); QIcon *i16 = new QIcon(":/new/colors/16.png"); ui->foregroundCombo->setItemIcon(0,*i0); ui->foregroundCombo->setItemIcon(1,*i1); ui->foregroundCombo->setItemIcon(2,*i2); ui->foregroundCombo->setItemIcon(3,*i3); ui->foregroundCombo->setItemIcon(4,*i4); ui->foregroundCombo->setItemIcon(5,*i5); ui->foregroundCombo->setItemIcon(6,*i6); ui->foregroundCombo->setItemIcon(7,*i7); ui->foregroundCombo->setItemIcon(8,*i8); ui->foregroundCombo->setItemIcon(9,*i9); ui->foregroundCombo->setItemIcon(10,*i10); ui->foregroundCombo->setItemIcon(11,*i11); ui->foregroundCombo->setItemIcon(12,*i12); ui->foregroundCombo->setItemIcon(13,*i13); ui->foregroundCombo->setItemIcon(14,*i14); ui->foregroundCombo->setItemIcon(15,*i15); ui->foregroundCombo->setItemIcon(16,*i16); //---------------------------------------------------- ui->backgroundCombo->setItemIcon(0,*i16); ui->backgroundCombo->setItemIcon(1,*i0); ui->backgroundCombo->setItemIcon(2,*i1); ui->backgroundCombo->setItemIcon(3,*i2); ui->backgroundCombo->setItemIcon(4,*i3); ui->backgroundCombo->setItemIcon(5,*i4); ui->backgroundCombo->setItemIcon(6,*i5); ui->backgroundCombo->setItemIcon(7,*i6); ui->backgroundCombo->setItemIcon(8,*i7); ui->backgroundCombo->setItemIcon(9,*i8); ui->backgroundCombo->setItemIcon(10,*i9); ui->backgroundCombo->setItemIcon(11,*i10); ui->backgroundCombo->setItemIcon(12,*i11); ui->backgroundCombo->setItemIcon(13,*i12); ui->backgroundCombo->setItemIcon(14,*i13); ui->backgroundCombo->setItemIcon(15,*i14); ui->backgroundCombo->setItemIcon(16,*i15); // QPixmap pixmap3(":/Editing-Align-Left-icon.png"); // QIcon leftIcon(pixmap3); // ui->alignLeft->setIcon(leftIcon); // ui->alignLeft->setIconSize(QSize(25,25)); saved = false; foregroundColor=Qt::black; backgroundColor=Qt::white; QIcon *if0 = new QIcon(":/new/colors/0f.png"); QIcon *ib0 = new QIcon(":/new/colors/16b.png"); ui->forecolor->setIcon(*if0); ui->backcolor->setIcon(*ib0); fileName =""; }
// ------------------------------------------------------------------------------- void Editor::keyPressEvent( QKeyEvent* pKeyEv ) // ------------------------------------------------------------------------------- { if ( !pKeyEv ) return; //std::cout<<"key = "<<pKeyEv->key(); // If // CTRL + S (save) or // ALT + left cursor (history one back / previous entry) or // ALT + right cursor (history one forward / next entry) // CTRL + F (shortcut for "Searching") // is called, then ignore it. if( ( (pKeyEv->state() == Qt::ControlButton) && (pKeyEv->key() == Qt::Key_S) ) || ( (pKeyEv->state() == Qt::AltButton) && (pKeyEv->key() == Qt::Key_Left) ) || ( (pKeyEv->state() == Qt::AltButton) && (pKeyEv->key() == Qt::Key_Right) ) || ( (pKeyEv->state() == Qt::ControlButton) && (pKeyEv->key() == Qt::Key_F) ) ) { //std::cout<<" -> ignore"<<std::endl; pKeyEv->ignore(); } /* // if the shift button is down while pressing return or enter, insert a new paragraph else if ( ( (pKeyEv->state() == Qt::ShiftButton ) || (pKeyEv->state() == Qt::ControlButton ) ) && ( (Qt::Key_Return == pKeyEv->key()) || (Qt::Key_Enter == pKeyEv->key()) ) ) { if ( LINEBREAK_MODERN == meLinebreakMode ) { //std::cout<<" -> shift/ctrl + enter/return"<<std::endl; Q3TextEdit::keyPressEvent( new QKeyEvent( pKeyEv->type(), Qt::Key_Return, pKeyEv->ascii(), 0 ) ); } else { Q3TextEdit::keyPressEvent( pKeyEv ); } } */ // Workaround Q3TextEdit's default Enter key behavior of adding a paragraph // Add control key pressed to it else if ( (Qt::Key_Return == pKeyEv->key()) || (Qt::Key_Enter == pKeyEv->key()) ) { Q3TextEdit::keyPressEvent( new QKeyEvent( pKeyEv->type(), Qt::Key_Return, pKeyEv->ascii(), Qt::ControlButton ) ); } // CTRL + A -> select all else if ( (Qt::ControlButton == pKeyEv->state()) && (Qt::Key_A == pKeyEv->key()) ) { selectAll(); } // CTRL + B -> bold else if ( (Qt::ControlButton == pKeyEv->state()) && (Qt::Key_B == pKeyEv->key()) ) { if ( Qt::RichText == textFormat() ) setBold( !bold() ); } // CTRL + I -> italic else if ( (Qt::ControlButton == pKeyEv->state()) && (Qt::Key_I == pKeyEv->key()) ) { if ( Qt::RichText == textFormat() ) setItalic( !italic() ); } // CTRL + U -> underline else if ( (Qt::ControlButton == pKeyEv->state()) && (Qt::Key_U == pKeyEv->key()) ) { if ( Qt::RichText == textFormat() ) setUnderline( !underline() ); } else { // otherwise call the super-method //std::cout<<std::endl; Q3TextEdit::keyPressEvent( pKeyEv ); } }