Qucs-GUI
0.0.19
|
00001 /*************************************************************************** 00002 graphictextdialog.cpp 00003 ----------------------- 00004 begin : Wed Nov 26 2003 00005 copyright : (C) 2003 by Michael Margraf 00006 email : michael.margraf@alumni.tu-berlin.de 00007 ***************************************************************************/ 00008 00009 /*************************************************************************** 00010 * * 00011 * This program is free software; you can redistribute it and/or modify * 00012 * it under the terms of the GNU General Public License as published by * 00013 * the Free Software Foundation; either version 2 of the License, or * 00014 * (at your option) any later version. * 00015 * * 00016 ***************************************************************************/ 00017 00018 #include "graphictextdialog.h" 00019 00020 #include "qucs.h" 00021 00022 #include <QLabel> 00023 #include <QLineEdit> 00024 #include <QTextEdit> 00025 #include <QValidator> 00026 #include <QPushButton> 00027 #include <QMessageBox> 00028 #include <QColorDialog> 00029 #include <QVBoxLayout> 00030 #include <QHBoxLayout> 00031 00032 00033 GraphicTextDialog::GraphicTextDialog(QWidget *parent, const char *name) 00034 : QDialog(parent, name) 00035 { 00036 setWindowTitle(tr("Edit Text Properties")); 00037 00038 vert = new QVBoxLayout(this); 00039 vert->setMargin(3); 00040 vert->setSpacing(3); 00041 00042 vert->addWidget( 00043 new QLabel(tr("Use LaTeX style for special characters, e.g. \\tau")+ 00044 "\n"+ 00045 tr("Use _{..} and ^{..} for sub- and super-positions."), 00046 this)); 00047 00048 text = new QTextEdit(this); 00049 text->setTextFormat(Qt::PlainText); 00050 text->setWordWrapMode(QTextOption::NoWrap); 00051 text->setMinimumSize(350,150); 00052 vert->addWidget(text); 00053 00054 QWidget *h1 = new QWidget(this); 00055 QHBoxLayout *h1Layout = new QHBoxLayout(); 00056 h1Layout->setSpacing(5); 00057 h1->setLayout(h1Layout); 00058 vert->addWidget(h1); 00059 00060 QWidget *h3 = new QWidget(this); 00061 QHBoxLayout *h3Layout = new QHBoxLayout(); 00062 h3Layout->setSpacing(5); 00063 h3->setLayout(h3Layout); 00064 vert->addWidget(h3); 00065 00066 // first => activated by pressing RETURN 00067 QPushButton *ButtOK = new QPushButton(tr("&OK")); 00068 h3Layout->addWidget(ButtOK); 00069 connect(ButtOK, SIGNAL(clicked()), SLOT(slotOkButton())); 00070 QPushButton *ButtCancel = new QPushButton(tr("&Cancel")); 00071 h3Layout->addWidget(ButtCancel); 00072 connect(ButtCancel, SIGNAL(clicked()), SLOT(reject())); 00073 00074 QLabel *tc = new QLabel(tr("Text color: ")); 00075 ColorButt = new QPushButton(" "); 00076 h1Layout->addWidget(tc); 00077 h1Layout->addWidget(ColorButt); 00078 ColorButt->setPaletteBackgroundColor(QColor(0,0,0)); 00079 connect(ColorButt, SIGNAL(clicked()), SLOT(slotSetColor())); 00080 00081 QWidget *place1 = new QWidget(h1); // stretchable placeholder 00082 h1Layout->setStretchFactor(place1,5); 00083 00084 val50 = new QIntValidator(1, 50, this); 00085 QLabel *ts = new QLabel(tr(" Text size: ")); 00086 h1Layout->addWidget(ts); 00087 TextSize = new QLineEdit(this); 00088 TextSize->setValidator(val50); 00089 TextSize->setMaximumWidth(35); 00090 TextSize->setText("12"); 00091 h1Layout->addWidget(TextSize); 00092 00093 val360 = new QIntValidator(0, 359, this); 00094 QLabel *ra = new QLabel(tr(" Rotation angle: ")); 00095 h1Layout->addWidget(ra); 00096 Angle = new QLineEdit(this); 00097 Angle->setValidator(val360); 00098 Angle->setMaximumWidth(35); 00099 Angle->setText("0"); 00100 h1Layout->addWidget(Angle); 00101 00102 text->setFocus(); 00103 } 00104 00105 GraphicTextDialog::~GraphicTextDialog() 00106 { 00107 delete vert; 00108 delete val50; 00109 delete val360; 00110 } 00111 00112 // -------------------------------------------------------------------------- 00113 void GraphicTextDialog::slotSetColor() 00114 { 00115 QColor c = QColorDialog::getColor(ColorButt->paletteBackgroundColor(),this); 00116 if(c.isValid()) ColorButt->setPaletteBackgroundColor(c); 00117 } 00118 00119 // -------------------------------------------------------------------------- 00120 void GraphicTextDialog::slotOkButton() 00121 { 00122 if(text->toPlainText().size() < 1) { 00123 QMessageBox::critical(this, tr("Error"), tr("The text must not be empty!")); 00124 return; 00125 } 00126 00127 accept(); 00128 }