Qucs-GUI  0.0.19
/home/travis/build/Qucs/qucs/qucs/qucs/paintings/filldialog.cpp
Go to the documentation of this file.
00001 /***************************************************************************
00002                           filldialog.cpp  -  description
00003                              -------------------
00004     begin                : Thu May 20 2004
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 "filldialog.h"
00019 
00020 #include <QLabel>
00021 #include <QValidator>
00022 #include <QColorDialog>
00023 #include <QTabWidget>
00024 #include <QLineEdit>
00025 #include <QPushButton>
00026 #include <QComboBox>
00027 #include <QCheckBox>
00028 #include <QGridLayout>
00029 #include <QVBoxLayout>
00030 #include <QHBoxLayout>
00031 #include <QWidget>
00032 
00033 FillDialog::FillDialog(const QString& _Caption, bool show, QWidget *parent)
00034       : QDialog(parent)
00035 {
00036   setWindowTitle(_Caption);
00037 
00038   all = new QVBoxLayout(this); // to provide the neccessary size
00039   QTabWidget *t = new QTabWidget(this);
00040   all->addWidget(t);
00041 
00042   // ...........................................................
00043   QWidget *Tab1 = new QWidget(t);
00044   QGridLayout *gp1 = new QGridLayout(Tab1,3,2,5,5);
00045 
00046   gp1->addWidget(new QLabel(tr("Line Width: "), Tab1), 0,0);
00047   val100 = new QIntValidator(0,100, this);
00048   LineWidth = new QLineEdit(Tab1);
00049   LineWidth->setValidator(val100);
00050   LineWidth->setMaximumWidth(35);
00051   LineWidth->setText("0");
00052   gp1->addWidget(LineWidth, 0,1);
00053 
00054   gp1->addWidget(new QLabel(tr("Line Color: "), Tab1), 1,0);
00055   ColorButt = new QPushButton("        ",Tab1);
00056   ColorButt->setPaletteBackgroundColor(QColor(0,0,0));
00057   connect(ColorButt, SIGNAL(clicked()), SLOT(slotSetColor()));
00058   gp1->addWidget(ColorButt, 1,1);
00059 
00060   gp1->addWidget(new QLabel(tr("Line Style: "), Tab1), 2,0);
00061   StyleBox = new QComboBox(Tab1);
00062   StyleBox->insertItem(tr("solid line"));
00063   StyleBox->insertItem(tr("dash line"));
00064   StyleBox->insertItem(tr("dot line"));
00065   StyleBox->insertItem(tr("dash dot line"));
00066   StyleBox->insertItem(tr("dash dot dot line"));
00067   gp1->addWidget(StyleBox, 2,1);
00068 
00069 
00070   t->addTab(Tab1, tr("Line Style"));
00071 
00072   // ...........................................................
00073 if(show) {
00074   QWidget *Tab2 = new QWidget(t);
00075   QGridLayout *gp2 = new QGridLayout(Tab2,3,2,5,5);
00076 
00077   CheckFilled = new QCheckBox(tr("enable filling"),Tab2);
00078   connect(CheckFilled, SIGNAL(toggled(bool)), SLOT(slotCheckFilled(bool)));
00079   gp2->addMultiCellWidget(CheckFilled, 0,0,0,1);
00080 
00081 
00082   FillLabel1 = new QLabel(tr("Fill Color: "), Tab2);
00083   gp2->addWidget(FillLabel1, 1,0);
00084   FillColorButt = new QPushButton("        ", Tab2);
00085   FillColorButt->setPaletteBackgroundColor(QColor(0,0,0));
00086   connect(FillColorButt, SIGNAL(clicked()), SLOT(slotSetFillColor()));
00087   gp2->addWidget(FillColorButt, 1,1);
00088 
00089   FillLabel2 = new QLabel(tr("Fill Style: "), Tab2);
00090   gp2->addWidget(FillLabel2, 2,0);
00091   FillStyleBox = new QComboBox(Tab2);
00092   FillStyleBox->insertItem(tr("no filling"));
00093   FillStyleBox->insertItem(tr("solid"));
00094   FillStyleBox->insertItem(tr("dense 1 (densest)"));
00095   FillStyleBox->insertItem(tr("dense 2"));
00096   FillStyleBox->insertItem(tr("dense 3"));
00097   FillStyleBox->insertItem(tr("dense 4"));
00098   FillStyleBox->insertItem(tr("dense 5"));
00099   FillStyleBox->insertItem(tr("dense 6"));
00100   FillStyleBox->insertItem(tr("dense 7 (least dense)"));
00101   FillStyleBox->insertItem(tr("horizontal line"));
00102   FillStyleBox->insertItem(tr("vertical line"));
00103   FillStyleBox->insertItem(tr("crossed lines"));
00104   FillStyleBox->insertItem(tr("hatched backwards"));
00105   FillStyleBox->insertItem(tr("hatched forwards"));
00106   FillStyleBox->insertItem(tr("diagonal crossed"));
00107   gp2->addWidget(FillStyleBox, 2,1);
00108 
00109 
00110   t->addTab(Tab2, tr("Filling Style"));
00111 }
00112   // ...........................................................
00113   QWidget *Butts = new QWidget(this);
00114   QHBoxLayout *ButtsLayout = new QHBoxLayout();
00115 
00116   ButtsLayout->setSpacing(5);
00117   ButtsLayout->setMargin(5);
00118 
00119   QPushButton *ButtOK = new QPushButton(tr("OK"));
00120   ButtsLayout->addWidget(ButtOK);
00121   connect(ButtOK, SIGNAL(clicked()), SLOT(accept()));
00122   QPushButton *ButtCancel = new QPushButton(tr("Cancel"),Butts);
00123   ButtsLayout->addWidget(ButtCancel);
00124   connect(ButtCancel, SIGNAL(clicked()), SLOT(reject()));
00125 
00126   Butts->setLayout(ButtsLayout);
00127   all->addWidget(Butts);
00128 
00129 
00130   ButtOK->setDefault(true);
00131 //  ButtOK->setFocus();
00132 }
00133 
00134 FillDialog::~FillDialog()
00135 {
00136   delete all;
00137   delete val100;
00138 }
00139 
00140 // --------------------------------------------------------------------------
00141 void FillDialog::slotSetColor()
00142 {
00143   QColor c = QColorDialog::getColor(ColorButt->paletteBackgroundColor(),this);
00144   if(c.isValid()) ColorButt->setPaletteBackgroundColor(c);
00145 }
00146 
00147 // --------------------------------------------------------------------------
00148 void FillDialog::slotSetFillColor()
00149 {
00150   QColor c =
00151     QColorDialog::getColor(FillColorButt->paletteBackgroundColor(), this);
00152   FillColorButt->setPaletteBackgroundColor(c);
00153 }
00154 
00155 // --------------------------------------------------------------------------
00156 void FillDialog::slotCheckFilled(bool on)
00157 {
00158   if(on) {
00159     FillLabel1->setEnabled(true);
00160     FillColorButt->setEnabled(true);
00161     FillLabel2->setEnabled(true);
00162     FillStyleBox->setEnabled(true);
00163   }
00164   else {
00165     FillLabel1->setEnabled(false);
00166     FillColorButt->setEnabled(false);
00167     FillLabel2->setEnabled(false);
00168     FillStyleBox->setEnabled(false);
00169   }
00170 }
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines