Qucs-GUI  0.0.18
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
filldialog.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  filldialog.cpp - description
3  -------------------
4  begin : Thu May 20 2004
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 "filldialog.h"
19 
20 #include <QLabel>
21 #include <QValidator>
22 #include <QColorDialog>
23 #include <QTabWidget>
24 #include <QLineEdit>
25 #include <QPushButton>
26 #include <QComboBox>
27 #include <QCheckBox>
28 #include <QGridLayout>
29 #include <QVBoxLayout>
30 #include <QHBoxLayout>
31 #include <QWidget>
32 
33 FillDialog::FillDialog(const QString& _Caption, bool show, QWidget *parent)
34  : QDialog(parent)
35 {
36  setCaption(_Caption);
37 
38  all = new QVBoxLayout(this); // to provide the neccessary size
39  QTabWidget *t = new QTabWidget(this);
40  all->addWidget(t);
41 
42  // ...........................................................
43  QWidget *Tab1 = new QWidget(t);
44  QGridLayout *gp1 = new QGridLayout(Tab1,3,2,5,5);
45 
46  gp1->addWidget(new QLabel(tr("Line Width: "), Tab1), 0,0);
47  val100 = new QIntValidator(0,100, this);
48  LineWidth = new QLineEdit(Tab1);
49  LineWidth->setValidator(val100);
50  LineWidth->setMaximumWidth(35);
51  LineWidth->setText("0");
52  gp1->addWidget(LineWidth, 0,1);
53 
54  gp1->addWidget(new QLabel(tr("Line Color: "), Tab1), 1,0);
55  ColorButt = new QPushButton(" ",Tab1);
56  ColorButt->setPaletteBackgroundColor(QColor(0,0,0));
57  connect(ColorButt, SIGNAL(clicked()), SLOT(slotSetColor()));
58  gp1->addWidget(ColorButt, 1,1);
59 
60  gp1->addWidget(new QLabel(tr("Line Style: "), Tab1), 2,0);
61  StyleBox = new QComboBox(Tab1);
62  StyleBox->insertItem(tr("solid line"));
63  StyleBox->insertItem(tr("dash line"));
64  StyleBox->insertItem(tr("dot line"));
65  StyleBox->insertItem(tr("dash dot line"));
66  StyleBox->insertItem(tr("dash dot dot line"));
67  gp1->addWidget(StyleBox, 2,1);
68 
69 
70  t->addTab(Tab1, tr("Line Style"));
71 
72  // ...........................................................
73 if(show) {
74  QWidget *Tab2 = new QWidget(t);
75  QGridLayout *gp2 = new QGridLayout(Tab2,3,2,5,5);
76 
77  CheckFilled = new QCheckBox(tr("enable filling"),Tab2);
78  connect(CheckFilled, SIGNAL(toggled(bool)), SLOT(slotCheckFilled(bool)));
79  gp2->addMultiCellWidget(CheckFilled, 0,0,0,1);
80 
81 
82  FillLabel1 = new QLabel(tr("Fill Color: "), Tab2);
83  gp2->addWidget(FillLabel1, 1,0);
84  FillColorButt = new QPushButton(" ", Tab2);
85  FillColorButt->setPaletteBackgroundColor(QColor(0,0,0));
86  connect(FillColorButt, SIGNAL(clicked()), SLOT(slotSetFillColor()));
87  gp2->addWidget(FillColorButt, 1,1);
88 
89  FillLabel2 = new QLabel(tr("Fill Style: "), Tab2);
90  gp2->addWidget(FillLabel2, 2,0);
91  FillStyleBox = new QComboBox(Tab2);
92  FillStyleBox->insertItem(tr("no filling"));
93  FillStyleBox->insertItem(tr("solid"));
94  FillStyleBox->insertItem(tr("dense 1 (densest)"));
95  FillStyleBox->insertItem(tr("dense 2"));
96  FillStyleBox->insertItem(tr("dense 3"));
97  FillStyleBox->insertItem(tr("dense 4"));
98  FillStyleBox->insertItem(tr("dense 5"));
99  FillStyleBox->insertItem(tr("dense 6"));
100  FillStyleBox->insertItem(tr("dense 7 (least dense)"));
101  FillStyleBox->insertItem(tr("horizontal line"));
102  FillStyleBox->insertItem(tr("vertical line"));
103  FillStyleBox->insertItem(tr("crossed lines"));
104  FillStyleBox->insertItem(tr("hatched backwards"));
105  FillStyleBox->insertItem(tr("hatched forwards"));
106  FillStyleBox->insertItem(tr("diagonal crossed"));
107  gp2->addWidget(FillStyleBox, 2,1);
108 
109 
110  t->addTab(Tab2, tr("Filling Style"));
111 }
112  // ...........................................................
113  QWidget *Butts = new QWidget(this);
114  QHBoxLayout *ButtsLayout = new QHBoxLayout();
115 
116  ButtsLayout->setSpacing(5);
117  ButtsLayout->setMargin(5);
118 
119  QPushButton *ButtOK = new QPushButton(tr("OK"));
120  ButtsLayout->addWidget(ButtOK);
121  connect(ButtOK, SIGNAL(clicked()), SLOT(accept()));
122  QPushButton *ButtCancel = new QPushButton(tr("Cancel"),Butts);
123  ButtsLayout->addWidget(ButtCancel);
124  connect(ButtCancel, SIGNAL(clicked()), SLOT(reject()));
125 
126  Butts->setLayout(ButtsLayout);
127  all->addWidget(Butts);
128 
129 
130  ButtOK->setDefault(true);
131 // ButtOK->setFocus();
132 }
133 
135 {
136  delete all;
137  delete val100;
138 }
139 
140 // --------------------------------------------------------------------------
142 {
143  QColor c = QColorDialog::getColor(ColorButt->paletteBackgroundColor(),this);
144  if(c.isValid()) ColorButt->setPaletteBackgroundColor(c);
145 }
146 
147 // --------------------------------------------------------------------------
149 {
150  QColor c =
151  QColorDialog::getColor(FillColorButt->paletteBackgroundColor(), this);
152  FillColorButt->setPaletteBackgroundColor(c);
153 }
154 
155 // --------------------------------------------------------------------------
157 {
158  if(on) {
159  FillLabel1->setEnabled(true);
160  FillColorButt->setEnabled(true);
161  FillLabel2->setEnabled(true);
162  FillStyleBox->setEnabled(true);
163  }
164  else {
165  FillLabel1->setEnabled(false);
166  FillColorButt->setEnabled(false);
167  FillLabel2->setEnabled(false);
168  FillStyleBox->setEnabled(false);
169  }
170 }
QIntValidator * val100
Definition: filldialog.h:58
QVBoxLayout * all
Definition: filldialog.h:57
QCheckBox * CheckFilled
Definition: filldialog.h:52
FillDialog(const QString &_Caption, bool show=true, QWidget *parent=0)
Definition: filldialog.cpp:33
QLineEdit * LineWidth
Definition: filldialog.h:53
void slotCheckFilled(bool on)
Definition: filldialog.cpp:156
QLabel * FillLabel1
Definition: filldialog.h:51
QPushButton * FillColorButt
Definition: filldialog.h:54
QPushButton * ColorButt
Definition: filldialog.h:54
QLabel * FillLabel2
Definition: filldialog.h:51
QComboBox * StyleBox
Definition: filldialog.h:55
void slotSetFillColor()
Definition: filldialog.cpp:148
void slotSetColor()
Definition: filldialog.cpp:141
QComboBox * FillStyleBox
Definition: filldialog.h:55