Qucs-GUI  0.0.18
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
graphictextdialog.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  graphictextdialog.cpp
3  -----------------------
4  begin : Wed Nov 26 2003
5  copyright : (C) 2003 by Michael Margraf
6  email : michael.margraf@alumni.tu-berlin.de
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #include "graphictextdialog.h"
19 
20 #include "qucs.h"
21 
22 #include <QLabel>
23 #include <QLineEdit>
24 #include <QTextEdit>
25 #include <QValidator>
26 #include <QPushButton>
27 #include <QMessageBox>
28 #include <QColorDialog>
29 #include <QVBoxLayout>
30 #include <QHBoxLayout>
31 
32 
33 GraphicTextDialog::GraphicTextDialog(QWidget *parent, const char *name)
34  : QDialog(parent, name)
35 {
36  setCaption(tr("Edit Text Properties"));
37 
38  vert = new QVBoxLayout(this);
39  vert->setMargin(3);
40  vert->setSpacing(3);
41 
42  vert->addWidget(
43  new QLabel(tr("Use LaTeX style for special characters, e.g. \\tau")+
44  "\n"+
45  tr("Use _{..} and ^{..} for sub- and super-positions."),
46  this));
47 
48  text = new QTextEdit(this);
49  text->setTextFormat(Qt::PlainText);
50  text->setWordWrapMode(QTextOption::NoWrap);
51  text->setMinimumSize(350,150);
52  vert->addWidget(text);
53 
54  QWidget *h1 = new QWidget(this);
55  QHBoxLayout *h1Layout = new QHBoxLayout();
56  h1Layout->setSpacing(5);
57  h1->setLayout(h1Layout);
58  vert->addWidget(h1);
59 
60  QWidget *h3 = new QWidget(this);
61  QHBoxLayout *h3Layout = new QHBoxLayout();
62  h3Layout->setSpacing(5);
63  h3->setLayout(h3Layout);
64  vert->addWidget(h3);
65 
66  // first => activated by pressing RETURN
67  QPushButton *ButtOK = new QPushButton(tr("&OK"));
68  h3Layout->addWidget(ButtOK);
69  connect(ButtOK, SIGNAL(clicked()), SLOT(slotOkButton()));
70  QPushButton *ButtCancel = new QPushButton(tr("&Cancel"));
71  h3Layout->addWidget(ButtCancel);
72  connect(ButtCancel, SIGNAL(clicked()), SLOT(reject()));
73 
74  QLabel *tc = new QLabel(tr("Text color: "));
75  ColorButt = new QPushButton(" ");
76  h1Layout->addWidget(tc);
77  h1Layout->addWidget(ColorButt);
78  ColorButt->setPaletteBackgroundColor(QColor(0,0,0));
79  connect(ColorButt, SIGNAL(clicked()), SLOT(slotSetColor()));
80 
81  QWidget *place1 = new QWidget(h1); // stretchable placeholder
82  h1Layout->setStretchFactor(place1,5);
83 
84  val50 = new QIntValidator(1, 50, this);
85  QLabel *ts = new QLabel(tr(" Text size: "));
86  h1Layout->addWidget(ts);
87  TextSize = new QLineEdit(this);
88  TextSize->setValidator(val50);
89  TextSize->setMaximumWidth(35);
90  TextSize->setText("12");
91  h1Layout->addWidget(TextSize);
92 
93  val360 = new QIntValidator(0, 359, this);
94  QLabel *ra = new QLabel(tr(" Rotation angle: "));
95  h1Layout->addWidget(ra);
96  Angle = new QLineEdit(this);
97  Angle->setValidator(val360);
98  Angle->setMaximumWidth(35);
99  Angle->setText("0");
100  h1Layout->addWidget(Angle);
101 
102  text->setFocus();
103 }
104 
106 {
107  delete vert;
108  delete val50;
109  delete val360;
110 }
111 
112 // --------------------------------------------------------------------------
114 {
115  QColor c = QColorDialog::getColor(ColorButt->paletteBackgroundColor(),this);
116  if(c.isValid()) ColorButt->setPaletteBackgroundColor(c);
117 }
118 
119 // --------------------------------------------------------------------------
121 {
122  if(text->toPlainText().size() < 1) {
123  QMessageBox::critical(this, tr("Error"), tr("The text must not be empty!"));
124  return;
125  }
126 
127  accept();
128 }
GraphicTextDialog(QWidget *parent=0, const char *name=0)
QIntValidator * val50
QIntValidator * val360
QPushButton * ColorButt
QVBoxLayout * vert