Qucs-GUI
0.0.19
|
00001 /*************************************************************************** 00002 arrowdialog.cpp 00003 ----------------- 00004 begin : Fri Nov 28 2003 00005 copyright : (C) 2003 by Michael Margraf 00006 email : michael.margraf@alumni.tu-berlin.de 00007 ***************************************************************************/ 00008 00009 /*************************************************************************** 00010 * * 00011 * This program is free software; you can redistribute it and/or modify * 00012 * it under the terms of the GNU General Public License as published by * 00013 * the Free Software Foundation; either version 2 of the License, or * 00014 * (at your option) any later version. * 00015 * * 00016 ***************************************************************************/ 00017 00018 #include "arrowdialog.h" 00019 00020 #include <QLabel> 00021 #include <QValidator> 00022 #include <QColorDialog> 00023 #include <QLineEdit> 00024 #include <QPushButton> 00025 #include <QComboBox> 00026 #include <QWidget> 00027 #include <QHBoxLayout> 00028 00029 00030 ArrowDialog::ArrowDialog(QWidget *parent, const char *name) 00031 : QDialog(parent, name) 00032 { 00033 setWindowTitle(tr("Edit Arrow Properties")); 00034 val100 = new QIntValidator(0, 100, this); 00035 00036 all = new QGridLayout(this, 5,4,3,3); 00037 all->setMargin(3); 00038 00039 00040 00041 all->addWidget(new QLabel(tr("Head Length: "), this), 0,0); 00042 HeadLength = new QLineEdit(this); 00043 HeadLength->setValidator(val100); 00044 HeadLength->setMaximumWidth(35); 00045 HeadLength->setText("10"); 00046 all->addWidget(HeadLength, 0,1); 00047 00048 all->addWidget(new QLabel(tr(" Head Width: "), this), 0,2); 00049 HeadWidth = new QLineEdit(this); 00050 HeadWidth->setValidator(val100); 00051 HeadWidth->setMaximumWidth(35); 00052 HeadWidth->setText("10"); 00053 all->addWidget(HeadWidth, 0,3); 00054 00055 00056 all->addWidget(new QLabel(tr("Line color: "), this), 1,0); 00057 ColorButt = new QPushButton(" ",this); 00058 ColorButt->setPaletteBackgroundColor(QColor(0,0,0)); 00059 connect(ColorButt, SIGNAL(clicked()), SLOT(slotSetColor())); 00060 all->addWidget(ColorButt, 1,1); 00061 00062 all->addWidget(new QLabel(tr(" Line Width: "), this), 1,2); 00063 LineWidth = new QLineEdit(this); 00064 LineWidth->setValidator(val100); 00065 LineWidth->setMaximumWidth(35); 00066 LineWidth->setText("0"); 00067 all->addWidget(LineWidth, 1,3); 00068 00069 00070 all->addWidget(new QLabel(tr("Line style: "), this), 2,0); 00071 StyleBox = new QComboBox(this); 00072 StyleBox->insertItem(tr("solid line")); 00073 StyleBox->insertItem(tr("dash line")); 00074 StyleBox->insertItem(tr("dot line")); 00075 StyleBox->insertItem(tr("dash dot line")); 00076 StyleBox->insertItem(tr("dash dot dot line")); 00077 connect(StyleBox, SIGNAL(activated(int)), SLOT(slotSetStyle(int))); 00078 LineStyle = Qt::SolidLine; 00079 all->addMultiCellWidget(StyleBox, 2,2,1,2); 00080 00081 all->addWidget(new QLabel(tr("Arrow head: "), this), 3,0); 00082 ArrowStyleBox = new QComboBox(this); 00083 ArrowStyleBox->insertItem(tr("two lines")); 00084 ArrowStyleBox->insertItem(tr("filled")); 00085 all->addMultiCellWidget(ArrowStyleBox, 3,3,1,2); 00086 00087 00088 QWidget *h1 = new QWidget(this); 00089 QHBoxLayout *h1Layout = new QHBoxLayout(); 00090 00091 00092 QPushButton *ButtOK = new QPushButton(tr("OK")); 00093 h1Layout->addWidget(ButtOK); 00094 connect(ButtOK, SIGNAL(clicked()), SLOT(accept())); 00095 QPushButton *ButtCancel = new QPushButton(tr("Cancel")); 00096 h1Layout->addWidget(ButtCancel); 00097 connect(ButtCancel, SIGNAL(clicked()), SLOT(reject())); 00098 00099 h1->setLayout(h1Layout); 00100 all->addMultiCellWidget(h1, 4,4,0,3); 00101 00102 ButtOK->setFocus(); 00103 } 00104 00105 ArrowDialog::~ArrowDialog() 00106 { 00107 delete all; 00108 delete val100; 00109 } 00110 00111 // -------------------------------------------------------------------------- 00112 void ArrowDialog::slotSetColor() 00113 { 00114 QColor c = QColorDialog::getColor(ColorButt->paletteBackgroundColor(),this); 00115 if(c.isValid()) ColorButt->setPaletteBackgroundColor(c); 00116 } 00117 00118 // -------------------------------------------------------------------------- 00119 void ArrowDialog::slotSetStyle(int index) 00120 { 00121 switch(index) { 00122 case 0 : LineStyle = Qt::SolidLine; 00123 break; 00124 case 1 : LineStyle = Qt::DashLine; 00125 break; 00126 case 2 : LineStyle = Qt::DotLine; 00127 break; 00128 case 3 : LineStyle = Qt::DashDotLine; 00129 break; 00130 case 4 : LineStyle = Qt::DashDotDotLine; 00131 break; 00132 default: ; 00133 } 00134 } 00135 00136 // -------------------------------------------------------------------------- 00137 void ArrowDialog::SetComboBox(Qt::PenStyle _Style) 00138 { 00139 LineStyle = _Style; 00140 switch(_Style) { 00141 case Qt::SolidLine : StyleBox->setCurrentItem(0); 00142 break; 00143 case Qt::DashLine : StyleBox->setCurrentItem(1); 00144 break; 00145 case Qt::DotLine : StyleBox->setCurrentItem(2); 00146 break; 00147 case Qt::DashDotLine : StyleBox->setCurrentItem(3); 00148 break; 00149 case Qt::DashDotDotLine : StyleBox->setCurrentItem(4); 00150 break; 00151 default: ; 00152 } 00153 }