My Project  0.0.16
QUCS Mapping
 All Classes Namespaces 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 <qhbox.h>
23 #include <qlabel.h>
24 #include <qlayout.h>
25 #include <qlineedit.h>
26 #include <qtextedit.h>
27 #include <qvalidator.h>
28 #include <qpushbutton.h>
29 #include <qmessagebox.h>
30 #include <qcolordialog.h>
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->setWordWrap(QTextEdit::NoWrap);
51  text->setMinimumSize(350,150);
52  vert->addWidget(text);
53 
54  QHBox *h1 = new QHBox(this);
55  h1->setSpacing(5);
56  vert->addWidget(h1);
57 
58 
59  QHBox *h2 = new QHBox(this);
60  h2->setSpacing(5);
61  vert->addWidget(h2);
62 
63  QHBox *h3 = new QHBox(this);
64  h2->setSpacing(5);
65  vert->addWidget(h3);
66 
67  // first => activated by pressing RETURN
68  QPushButton *ButtOK = new QPushButton(tr("&OK"),h3);
69  connect(ButtOK, SIGNAL(clicked()), SLOT(slotOkButton()));
70  QPushButton *ButtCancel = new QPushButton(tr("&Cancel"),h3);
71  connect(ButtCancel, SIGNAL(clicked()), SLOT(reject()));
72 
73  new QLabel(tr("Text color: "), h1);
74  ColorButt = new QPushButton(" ",h1);
75  ColorButt->setPaletteBackgroundColor(QColor(0,0,0));
76  connect(ColorButt, SIGNAL(clicked()), SLOT(slotSetColor()));
77 
78  QWidget *place1 = new QWidget(h1); // stretchable placeholder
79  h1->setStretchFactor(place1,5);
80 
81  val50 = new QIntValidator(1, 50, this);
82  new QLabel(tr("Text size: "), h1);
83  TextSize = new QLineEdit(h1);
84  TextSize->setValidator(val50);
85  TextSize->setMaximumWidth(35);
86  TextSize->setText("12");
87 
88  QWidget *place2 = new QWidget(h2); // stretchable placeholder
89  h2->setStretchFactor(place2,5);
90 
91  val360 = new QIntValidator(0, 359, this);
92  new QLabel(tr("Rotation angle: "), h2);
93  Angle = new QLineEdit(h2);
94  Angle->setValidator(val360);
95  Angle->setMaximumWidth(35);
96  Angle->setText("0");
97 
98  text->setFocus();
99 }
100 
102 {
103  delete vert;
104  delete val50;
105  delete val360;
106 }
107 
108 // --------------------------------------------------------------------------
109 void GraphicTextDialog::slotSetColor()
110 {
111  QColor c = QColorDialog::getColor(ColorButt->paletteBackgroundColor(),this);
112  if(c.isValid()) ColorButt->setPaletteBackgroundColor(c);
113 }
114 
115 // --------------------------------------------------------------------------
116 void GraphicTextDialog::slotOkButton()
117 {
118  if(text->length() < 1) {
119  QMessageBox::critical(this, tr("Error"), tr("The text must not be empty!"));
120  return;
121  }
122 
123  accept();
124 }