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