TextDialog::TextDialog(TextType type, QWidget* parent, const char* name, bool modal, WFlags fl ) : QDialog( parent, name, modal, fl ) { if ( !name ) setName( "TextDialog" ); setCaption( tr( "QtiPlot - Text options" ) ); setSizeGripEnabled( true ); text_type = type; GroupBox1 = new QButtonGroup(3,QGroupBox::Horizontal, QString::null, this); new QLabel(tr( "Color" ), GroupBox1); colorBox = new ColorButton(GroupBox1); buttonOk = new QPushButton( GroupBox1); buttonOk->setText( tr( "&OK" ) ); buttonOk->setAutoDefault( TRUE ); buttonOk->setDefault( TRUE ); new QLabel(tr( "Font" ),GroupBox1); buttonFont = new QPushButton( GroupBox1, "buttonFont" ); buttonFont->setText( tr( "&Font" ) ); buttonApply = new QPushButton( GroupBox1, "buttonApply" ); buttonApply->setText( tr( "&Apply" ) ); buttonApply->setDefault( TRUE ); if (text_type) { new QLabel(tr( "Alignement" ),GroupBox1, "TextLabel1_22",0); alignementBox = new QComboBox( FALSE, GroupBox1, "alignementBox" ); alignementBox->insertItem( tr( "Center" ) ); alignementBox->insertItem( tr( "Left" ) ); alignementBox->insertItem( tr( "Right" ) ); } else { new QLabel(tr( "Frame" ), GroupBox1, "TextLabel1",0 ); backgroundBox = new QComboBox( FALSE, GroupBox1, "backgroundBox" ); backgroundBox->insertItem( tr( "None" ) ); backgroundBox->insertItem( tr( "Rectangle" ) ); backgroundBox->insertItem( tr( "Shadow" ) ); } buttonCancel = new QPushButton( GroupBox1, "buttonCancel" ); buttonCancel->setText( tr( "&Cancel" ) ); if (text_type == TextMarker) { new QLabel(tr("Background"), GroupBox1, "TextLabel2",0 ); backgroundBtn = new ColorButton(GroupBox1); connect(backgroundBtn, SIGNAL(clicked()), this, SLOT(pickBackgroundColor())); buttonDefault = new QPushButton( GroupBox1); buttonDefault->setText( tr( "Set &Default" ) ); connect(buttonDefault, SIGNAL(clicked()), this, SLOT(setDefaultValues())); } QLabel* rotate=new QLabel(tr( "Rotate (deg.)" ),GroupBox1, "TextLabel1_2",0); rotate->hide(); rotateBox = new QComboBox( FALSE, GroupBox1, "rotateBox" ); rotateBox->insertItem( tr( "0" ) ); rotateBox->insertItem( tr( "45" ) ); rotateBox->insertItem( tr( "90" ) ); rotateBox->insertItem( tr( "135" ) ); rotateBox->insertItem( tr( "180" ) ); rotateBox->insertItem( tr( "225" ) ); rotateBox->insertItem( tr( "270" ) ); rotateBox->insertItem( tr( "315" ) ); rotateBox->setEditable (TRUE); rotateBox->setCurrentItem(0); rotateBox->hide(); GroupBox2= new QButtonGroup(8, QGroupBox::Horizontal, QString::null,this, "GroupBox2" ); if (text_type == TextMarker) { buttonCurve = new QPushButton( GroupBox2, "buttonCurve" ); buttonCurve->setPixmap (QPixmap(lineSymbol_xpm)); connect( buttonCurve, SIGNAL( clicked() ), this, SLOT(addCurve() ) ); } buttonIndice = new QPushButton( GroupBox2, "buttonIndice" ); buttonIndice->setPixmap (QPixmap(index_xpm)); buttonExp = new QPushButton( GroupBox2, "buttonExp" ); buttonExp->setPixmap (QPixmap(exp_xpm)); buttonMinGreek = new QPushButton(QChar(0x3B1), GroupBox2, "buttonMinGreek" ); buttonMinGreek->setMaximumWidth(40); buttonMajGreek = new QPushButton(QChar(0x393), GroupBox2, "buttonMajGreek" ); buttonMajGreek->setMaximumWidth(40); QFont font = this->font(); font.setBold(true); buttonB = new QPushButton(tr("B"), GroupBox2, "buttonB" ); buttonB->setFont(font); buttonB->setMaximumWidth(40); font = this->font(); font.setItalic(true); buttonI = new QPushButton(tr("It"), GroupBox2, "buttonI" ); buttonI->setFont(font); buttonI->setMaximumWidth(40); font = this->font(); font.setUnderline(true); buttonU = new QPushButton(tr("U"), GroupBox2, "buttonU" ); buttonU->setFont(font); buttonU->setMaximumWidth(40); textEditBox = new QTextEdit( this); textEditBox->setTextFormat(QTextEdit::PlainText); setFocusPolicy(QWidget::StrongFocus); setFocusProxy(textEditBox); QVBoxLayout* vlayout = new QVBoxLayout(this,5,5, "vlayout"); vlayout->addWidget(GroupBox1); vlayout->addWidget(GroupBox2); vlayout->addWidget(textEditBox); // signals and slots connections connect( colorBox, SIGNAL( clicked() ), this, SLOT( pickTextColor() ) ); connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) ); connect( buttonApply, SIGNAL( clicked() ), this, SLOT( apply() ) ); connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); connect( buttonFont, SIGNAL( clicked() ), this, SLOT(customFont() ) ); connect( buttonExp, SIGNAL( clicked() ), this, SLOT(addExp() ) ); connect( buttonIndice, SIGNAL( clicked() ), this, SLOT(addIndex() ) ); connect( buttonU, SIGNAL( clicked() ), this, SLOT(addUnderline() ) ); connect( buttonI, SIGNAL( clicked() ), this, SLOT(addItalic() ) ); connect( buttonB, SIGNAL( clicked() ), this, SLOT(addBold() ) ); connect( buttonMinGreek, SIGNAL(clicked()), this, SLOT(showMinGreek())); connect( buttonMajGreek, SIGNAL(clicked()), this, SLOT(showMajGreek())); }
TextFormatButtons::TextFormatButtons(QTextEdit * textEdit, Buttons buttons, QWidget * parent) : QWidget(parent), connectedTextEdit(textEdit), d_buttons(buttons) { QHBoxLayout * layout = new QHBoxLayout(this); layout->setMargin(0); layout->setSpacing(0); QFont font = this->font(); font.setPointSize(14); if (buttons == Legend){ buttonCurve = new QPushButton( QPixmap(lineSymbol_xpm), QString()); buttonCurve->setMaximumWidth(40); buttonCurve->setMinimumHeight(35); buttonCurve->setFont(font); layout->addWidget(buttonCurve); connect( buttonCurve, SIGNAL(clicked()), this, SLOT(addCurve()) ); } buttonSubscript = new QPushButton(QPixmap(index_xpm), QString()); buttonSubscript->setMaximumWidth(40); buttonSubscript->setMinimumHeight(35); buttonSubscript->setFont(font); layout->addWidget(buttonSubscript); connect( buttonSubscript, SIGNAL(clicked()), this, SLOT(addSubscript()) ); buttonSuperscript = new QPushButton(QPixmap(exp_xpm), QString()); buttonSuperscript->setMaximumWidth(40); buttonSuperscript->setMinimumHeight(35); buttonSuperscript->setFont(font); layout->addWidget(buttonSuperscript); connect( buttonSuperscript, SIGNAL(clicked()), this, SLOT(addSuperscript())); if (buttons != Equation){ buttonLowerGreek = new QPushButton(QString(QChar(0x3B1))); buttonLowerGreek->setFont(font); buttonLowerGreek->setMaximumWidth(40); layout->addWidget(buttonLowerGreek); connect( buttonLowerGreek, SIGNAL(clicked()), this, SLOT(showLowerGreek())); buttonUpperGreek = new QPushButton(QString(QChar(0x393))); buttonUpperGreek->setFont(font); buttonUpperGreek->setMaximumWidth(40); layout->addWidget(buttonUpperGreek); connect( buttonUpperGreek, SIGNAL(clicked()), this, SLOT(showUpperGreek())); buttonMathSymbols = new QPushButton(QString(QChar(0x222B))); buttonMathSymbols->setFont(font); buttonMathSymbols->setMaximumWidth(40); layout->addWidget(buttonMathSymbols); connect( buttonMathSymbols, SIGNAL(clicked()), this, SLOT(showMathSymbols())); buttonArrowSymbols = new QPushButton(QString(QChar(0x2192))); buttonArrowSymbols->setFont(font); buttonArrowSymbols->setMaximumWidth(40); layout->addWidget(buttonArrowSymbols); connect( buttonArrowSymbols, SIGNAL(clicked()), this, SLOT(showArrowSymbols())); } if (buttons != Plot3D && buttons != Equation){ font = this->font(); font.setBold(true); font.setPointSize(14); buttonBold = new QPushButton(tr("B","Button bold")); buttonBold->setFont(font); buttonBold->setMaximumWidth(40); layout->addWidget(buttonBold); connect( buttonBold, SIGNAL(clicked()), this, SLOT(addBold())); font = this->font(); font.setItalic(true); font.setPointSize(14); buttonItalics = new QPushButton(tr("It","Button italics")); buttonItalics->setFont(font); buttonItalics->setMaximumWidth(40); layout->addWidget(buttonItalics); connect( buttonItalics, SIGNAL(clicked()), this, SLOT(addItalics())); font = this->font(); font.setUnderline(true); font.setPointSize(14); buttonUnderline = new QPushButton(tr("U","Button underline")); buttonUnderline->setFont(font); buttonUnderline->setMaximumWidth(40); layout->addWidget(buttonUnderline); layout->addStretch(); connect( buttonUnderline, SIGNAL(clicked()), this, SLOT(addUnderline())); } if (buttons == Equation){ buttonFraction = new QPushButton(QPixmap(fraction_xpm), QString()); buttonFraction->setMaximumWidth(40); buttonFraction->setMinimumHeight(35); buttonFraction->setFont(font); layout->addWidget(buttonFraction); connect(buttonFraction, SIGNAL(clicked()), this, SLOT(addFraction())); buttonSquareRoot = new QPushButton(QPixmap(square_root_xpm), QString()); buttonSquareRoot->setMaximumWidth(40); buttonSquareRoot->setMinimumHeight(35); buttonSquareRoot->setFont(font); layout->addWidget(buttonSquareRoot); connect(buttonSquareRoot, SIGNAL(clicked()), this, SLOT(addSquareRoot())); layout->addStretch(); } }
void TextFormatButtons::init(Buttons buttons) { QHBoxLayout *layout = (QHBoxLayout*)this->layout(); QLayoutItem *child; while ((child = layout->takeAt(0)) != 0){ if (child->widget()) delete child->widget(); } QFont font = QFont(); int btnSize = 32; #ifdef Q_OS_MAC btnSize = 38; #endif if (buttons == Legend || buttons == TexLegend){ QPushButton *buttonCurve = new QPushButton( QPixmap(":/lineSymbol.png"), QString()); buttonCurve->setFixedWidth(btnSize); buttonCurve->setFixedHeight(btnSize); buttonCurve->setFont(font); layout->addWidget(buttonCurve); connect( buttonCurve, SIGNAL(clicked()), this, SLOT(addCurve()) ); } QPushButton *buttonSubscript = new QPushButton(QPixmap(":/index.png"), QString()); buttonSubscript->setFixedWidth(btnSize); buttonSubscript->setFixedHeight(btnSize); buttonSubscript->setFont(font); layout->addWidget(buttonSubscript); connect( buttonSubscript, SIGNAL(clicked()), this, SLOT(addSubscript()) ); QPushButton *buttonSuperscript = new QPushButton(QPixmap(":/exp.png"), QString()); buttonSuperscript->setFixedWidth(btnSize); buttonSuperscript->setFixedHeight(btnSize); buttonSuperscript->setFont(font); layout->addWidget(buttonSuperscript); connect( buttonSuperscript, SIGNAL(clicked()), this, SLOT(addSuperscript())); if (buttons == Equation || buttons == TexLegend){ QPushButton *buttonFraction = new QPushButton(QPixmap(":/fraction.png"), QString()); buttonFraction->setFixedWidth(btnSize); buttonFraction->setFixedHeight(btnSize); buttonFraction->setFont(font); layout->addWidget(buttonFraction); connect(buttonFraction, SIGNAL(clicked()), this, SLOT(addFraction())); QPushButton *buttonSquareRoot = new QPushButton(QPixmap(":/square_root.png"), QString()); buttonSquareRoot->setFixedWidth(btnSize); buttonSquareRoot->setFixedHeight(btnSize); buttonSquareRoot->setFont(font); layout->addWidget(buttonSquareRoot); connect(buttonSquareRoot, SIGNAL(clicked()), this, SLOT(addSquareRoot())); } QPushButton *buttonLowerGreek = new QPushButton(QString(QChar(0x3B1))); buttonLowerGreek->setFont(font); buttonLowerGreek->setFixedWidth(btnSize); buttonLowerGreek->setFixedHeight(btnSize); layout->addWidget(buttonLowerGreek); connect( buttonLowerGreek, SIGNAL(clicked()), this, SLOT(showLowerGreek())); QPushButton *buttonUpperGreek = new QPushButton(QString(QChar(0x393))); buttonUpperGreek->setFont(font); buttonUpperGreek->setFixedWidth(btnSize); buttonUpperGreek->setFixedHeight(btnSize); layout->addWidget(buttonUpperGreek); connect( buttonUpperGreek, SIGNAL(clicked()), this, SLOT(showUpperGreek())); QPushButton *buttonArrowSymbols = new QPushButton(QString(QChar(0x2192))); buttonArrowSymbols->setFont(font); buttonArrowSymbols->setFixedWidth(btnSize); buttonArrowSymbols->setFixedHeight(btnSize); layout->addWidget(buttonArrowSymbols); connect( buttonArrowSymbols, SIGNAL(clicked()), this, SLOT(showArrowSymbols())); QPushButton *buttonMathSymbols = new QPushButton(QString(QChar(0x222B))); buttonMathSymbols->setFont(font); buttonMathSymbols->setFixedWidth(btnSize); buttonMathSymbols->setFixedHeight(btnSize); layout->addWidget(buttonMathSymbols); connect( buttonMathSymbols, SIGNAL(clicked()), this, SLOT(showMathSymbols())); if (buttons != Plot3D && buttons != Equation && buttons != TexLegend){ font = this->font(); font.setBold(true); QPushButton *buttonBold = new QPushButton(tr("B","Button bold")); buttonBold->setFont(font); buttonBold->setFixedWidth(btnSize); buttonBold->setFixedHeight(btnSize); layout->addWidget(buttonBold); connect( buttonBold, SIGNAL(clicked()), this, SLOT(addBold())); font = this->font(); font.setItalic(true); QPushButton *buttonItalics = new QPushButton(tr("It","Button italics")); buttonItalics->setFont(font); buttonItalics->setFixedWidth(btnSize); buttonItalics->setFixedHeight(btnSize); layout->addWidget(buttonItalics); connect( buttonItalics, SIGNAL(clicked()), this, SLOT(addItalics())); font = this->font(); font.setUnderline(true); QPushButton *buttonUnderline = new QPushButton(tr("U","Button underline")); buttonUnderline->setFont(font); buttonUnderline->setFixedWidth(btnSize); buttonUnderline->setFixedHeight(btnSize); layout->addWidget(buttonUnderline); layout->addStretch(); connect( buttonUnderline, SIGNAL(clicked()), this, SLOT(addUnderline())); } else layout->addStretch(); }