Qucs-GUI  0.0.18
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
arrowdialog.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  arrowdialog.cpp
3  -----------------
4  begin : Fri Nov 28 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 "arrowdialog.h"
19 
20 //#include <QLayout>
21 #include <QLabel>
22 #include <QValidator>
23 #include <QColorDialog>
24 #include <QLineEdit>
25 #include <QPushButton>
26 #include <QComboBox>
27 #include <QWidget>
28 #include <QHBoxLayout>
29 
30 
31 ArrowDialog::ArrowDialog(QWidget *parent, const char *name)
32  : QDialog(parent, name)
33 {
34  setCaption(tr("Edit Arrow Properties"));
35  val100 = new QIntValidator(0, 100, this);
36 
37  all = new QGridLayout(this, 5,4,3,3);
38  all->setMargin(3);
39 
40 
41 
42  all->addWidget(new QLabel(tr("Head Length: "), this), 0,0);
43  HeadLength = new QLineEdit(this);
44  HeadLength->setValidator(val100);
45  HeadLength->setMaximumWidth(35);
46  HeadLength->setText("10");
47  all->addWidget(HeadLength, 0,1);
48 
49  all->addWidget(new QLabel(tr(" Head Width: "), this), 0,2);
50  HeadWidth = new QLineEdit(this);
51  HeadWidth->setValidator(val100);
52  HeadWidth->setMaximumWidth(35);
53  HeadWidth->setText("10");
54  all->addWidget(HeadWidth, 0,3);
55 
56 
57  all->addWidget(new QLabel(tr("Line color: "), this), 1,0);
58  ColorButt = new QPushButton(" ",this);
59  ColorButt->setPaletteBackgroundColor(QColor(0,0,0));
60  connect(ColorButt, SIGNAL(clicked()), SLOT(slotSetColor()));
61  all->addWidget(ColorButt, 1,1);
62 
63  all->addWidget(new QLabel(tr(" Line Width: "), this), 1,2);
64  LineWidth = new QLineEdit(this);
65  LineWidth->setValidator(val100);
66  LineWidth->setMaximumWidth(35);
67  LineWidth->setText("0");
68  all->addWidget(LineWidth, 1,3);
69 
70 
71  all->addWidget(new QLabel(tr("Line style: "), this), 2,0);
72  StyleBox = new QComboBox(this);
73  StyleBox->insertItem(tr("solid line"));
74  StyleBox->insertItem(tr("dash line"));
75  StyleBox->insertItem(tr("dot line"));
76  StyleBox->insertItem(tr("dash dot line"));
77  StyleBox->insertItem(tr("dash dot dot line"));
78  connect(StyleBox, SIGNAL(activated(int)), SLOT(slotSetStyle(int)));
79  LineStyle = Qt::SolidLine;
80  all->addMultiCellWidget(StyleBox, 2,2,1,2);
81 
82  all->addWidget(new QLabel(tr("Arrow head: "), this), 3,0);
83  ArrowStyleBox = new QComboBox(this);
84  ArrowStyleBox->insertItem(tr("two lines"));
85  ArrowStyleBox->insertItem(tr("filled"));
86  all->addMultiCellWidget(ArrowStyleBox, 3,3,1,2);
87 
88 
89  QWidget *h1 = new QWidget(this);
90  QHBoxLayout *h1Layout = new QHBoxLayout();
91 
92 
93  QPushButton *ButtOK = new QPushButton(tr("OK"));
94  h1Layout->addWidget(ButtOK);
95  connect(ButtOK, SIGNAL(clicked()), SLOT(accept()));
96  QPushButton *ButtCancel = new QPushButton(tr("Cancel"));
97  h1Layout->addWidget(ButtCancel);
98  connect(ButtCancel, SIGNAL(clicked()), SLOT(reject()));
99 
100  h1->setLayout(h1Layout);
101  all->addMultiCellWidget(h1, 4,4,0,3);
102 
103  ButtOK->setFocus();
104 }
105 
107 {
108  delete all;
109  delete val100;
110 }
111 
112 // --------------------------------------------------------------------------
114 {
115  QColor c = QColorDialog::getColor(ColorButt->paletteBackgroundColor(),this);
116  if(c.isValid()) ColorButt->setPaletteBackgroundColor(c);
117 }
118 
119 // --------------------------------------------------------------------------
121 {
122  switch(index) {
123  case 0 : LineStyle = Qt::SolidLine;
124  break;
125  case 1 : LineStyle = Qt::DashLine;
126  break;
127  case 2 : LineStyle = Qt::DotLine;
128  break;
129  case 3 : LineStyle = Qt::DashDotLine;
130  break;
131  case 4 : LineStyle = Qt::DashDotDotLine;
132  break;
133  default: ;
134  }
135 }
136 
137 // --------------------------------------------------------------------------
138 void ArrowDialog::SetComboBox(Qt::PenStyle _Style)
139 {
140  LineStyle = _Style;
141  switch(_Style) {
142  case Qt::SolidLine : StyleBox->setCurrentItem(0);
143  break;
144  case Qt::DashLine : StyleBox->setCurrentItem(1);
145  break;
146  case Qt::DotLine : StyleBox->setCurrentItem(2);
147  break;
148  case Qt::DashDotLine : StyleBox->setCurrentItem(3);
149  break;
150  case Qt::DashDotDotLine : StyleBox->setCurrentItem(4);
151  break;
152  default: ;
153  }
154 }
QLineEdit * HeadLength
Definition: arrowdialog.h:45
QLineEdit * HeadWidth
Definition: arrowdialog.h:45
void slotSetColor()
Qt::PenStyle LineStyle
Definition: arrowdialog.h:48
void slotSetStyle(int)
QLineEdit * LineWidth
Definition: arrowdialog.h:45
QIntValidator * val100
Definition: arrowdialog.h:51
QComboBox * ArrowStyleBox
Definition: arrowdialog.h:47
QPushButton * ColorButt
Definition: arrowdialog.h:46
QComboBox * StyleBox
Definition: arrowdialog.h:47
ArrowDialog(QWidget *parent=0, const char *name=0)
Definition: arrowdialog.cpp:31
void SetComboBox(Qt::PenStyle)
QGridLayout * all
Definition: arrowdialog.h:50