My Project  0.0.16
QUCS Mapping
 All Classes Namespaces 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.h>
21 #include <qlabel.h>
22 #include <qhbox.h>
23 #include <qvalidator.h>
24 #include <qcolordialog.h>
25 #include <qlineedit.h>
26 #include <qpushbutton.h>
27 #include <qcombobox.h>
28 
29 
30 ArrowDialog::ArrowDialog(QWidget *parent, const char *name)
31  : QDialog(parent, name)
32 {
33  setCaption(tr("Edit Arrow Properties"));
34  val100 = new QIntValidator(0, 100, this);
35 
36  all = new QGridLayout(this, 5,4,3,3);
37  all->setMargin(3);
38 
39  all->addWidget(new QLabel(tr("Head Length: "), this), 0,0);
40  HeadLength = new QLineEdit(this);
41  HeadLength->setValidator(val100);
42  HeadLength->setMaximumWidth(35);
43  HeadLength->setText("10");
44  all->addWidget(HeadLength, 0,1);
45 
46  all->addWidget(new QLabel(tr(" Head Width: "), this), 0,2);
47  HeadWidth = new QLineEdit(this);
48  HeadWidth->setValidator(val100);
49  HeadWidth->setMaximumWidth(35);
50  HeadWidth->setText("10");
51  all->addWidget(HeadWidth, 0,3);
52 
53 
54  all->addWidget(new QLabel(tr("Line color: "), this), 1,0);
55  ColorButt = new QPushButton(" ",this);
56  ColorButt->setPaletteBackgroundColor(QColor(0,0,0));
57  connect(ColorButt, SIGNAL(clicked()), SLOT(slotSetColor()));
58  all->addWidget(ColorButt, 1,1);
59 
60  all->addWidget(new QLabel(tr(" Line Width: "), this), 1,2);
61  LineWidth = new QLineEdit(this);
62  LineWidth->setValidator(val100);
63  LineWidth->setMaximumWidth(35);
64  LineWidth->setText("0");
65  all->addWidget(LineWidth, 1,3);
66 
67 
68  all->addWidget(new QLabel(tr("Line style: "), this), 2,0);
69  StyleBox = new QComboBox(this);
70  StyleBox->insertItem(tr("solid line"));
71  StyleBox->insertItem(tr("dash line"));
72  StyleBox->insertItem(tr("dot line"));
73  StyleBox->insertItem(tr("dash dot line"));
74  StyleBox->insertItem(tr("dash dot dot line"));
75  connect(StyleBox, SIGNAL(activated(int)), SLOT(slotSetStyle(int)));
76  LineStyle = Qt::SolidLine;
77  all->addMultiCellWidget(StyleBox, 2,2,1,2);
78 
79  all->addWidget(new QLabel(tr("Arrow head: "), this), 3,0);
80  ArrowStyleBox = new QComboBox(this);
81  ArrowStyleBox->insertItem(tr("two lines"));
82  ArrowStyleBox->insertItem(tr("filled"));
83  all->addMultiCellWidget(ArrowStyleBox, 3,3,1,2);
84 
85 
86  QHBox *h1 = new QHBox(this);
87  all->addMultiCellWidget(h1, 4,4,0,3);
88  QPushButton *ButtOK = new QPushButton(tr("OK"), h1);
89  connect(ButtOK, SIGNAL(clicked()), SLOT(accept()));
90  QPushButton *ButtCancel = new QPushButton(tr("Cancel"), h1);
91  connect(ButtCancel, SIGNAL(clicked()), SLOT(reject()));
92 
93  ButtOK->setFocus();
94 }
95 
97 {
98  delete all;
99  delete val100;
100 }
101 
102 // --------------------------------------------------------------------------
103 void ArrowDialog::slotSetColor()
104 {
105  QColor c = QColorDialog::getColor(ColorButt->paletteBackgroundColor(),this);
106  if(c.isValid()) ColorButt->setPaletteBackgroundColor(c);
107 }
108 
109 // --------------------------------------------------------------------------
110 void ArrowDialog::slotSetStyle(int index)
111 {
112  switch(index) {
113  case 0 : LineStyle = Qt::SolidLine;
114  break;
115  case 1 : LineStyle = Qt::DashLine;
116  break;
117  case 2 : LineStyle = Qt::DotLine;
118  break;
119  case 3 : LineStyle = Qt::DashDotLine;
120  break;
121  case 4 : LineStyle = Qt::DashDotDotLine;
122  break;
123  default: ;
124  }
125 }
126 
127 // --------------------------------------------------------------------------
128 void ArrowDialog::SetComboBox(Qt::PenStyle _Style)
129 {
130  LineStyle = _Style;
131  switch(_Style) {
132  case Qt::SolidLine : StyleBox->setCurrentItem(0);
133  break;
134  case Qt::DashLine : StyleBox->setCurrentItem(1);
135  break;
136  case Qt::DotLine : StyleBox->setCurrentItem(2);
137  break;
138  case Qt::DashDotLine : StyleBox->setCurrentItem(3);
139  break;
140  case Qt::DashDotDotLine : StyleBox->setCurrentItem(4);
141  break;
142  default: ;
143  }
144 }