1 /****************************************************************************
2 **
3 ** This file is part of the LibreCAD project, a 2D CAD program
4 **
5 ** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
6 ** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
7 **
8 **
9 ** This file may be distributed and/or modified under the terms of the
10 ** GNU General Public License version 2 as published by the Free Software
11 ** Foundation and appearing in the file gpl-2.0.txt included in the
12 ** packaging of this file.
13 **
14 ** This program is distributed in the hope that it will be useful,
15 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 ** GNU General Public License for more details.
18 **
19 ** You should have received a copy of the GNU General Public License
20 ** along with this program; if not, write to the Free Software
21 ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
22 **
23 ** This copyright notice MUST APPEAR in all copies of the script!
24 **
25 **********************************************************************/
26 #include "qg_widgetpen.h"
27 
28 #include <QVariant>
29 #include "qg_colorbox.h"
30 #include "qg_widthbox.h"
31 #include "qg_linetypebox.h"
32 
33 /*
34  *  Constructs a QG_WidgetPen as a child of 'parent', with the
35  *  name 'name' and widget flags set to 'f'.
36  */
QG_WidgetPen(QWidget * parent,Qt::WindowFlags fl)37 QG_WidgetPen::QG_WidgetPen(QWidget* parent, Qt::WindowFlags fl)
38     : QWidget(parent, fl)
39 {
40     setupUi(this);
41 
42 }
43 
setPen(RS_Pen pen,bool showByLayer,bool showUnchanged,const QString & title)44 void QG_WidgetPen::setPen(RS_Pen pen, bool showByLayer,
45                           bool showUnchanged, const QString& title) {
46     cbColor->init(showByLayer, showUnchanged);
47     cbWidth->init(showByLayer, showUnchanged);
48     cbLineType->init(showByLayer, showUnchanged);
49     if (!showUnchanged) {
50        cbColor->setColor(pen.getColor());
51        cbWidth->setWidth(pen.getWidth());
52        cbLineType->setLineType(pen.getLineType());
53     }
54 
55     if (!title.isEmpty()) {
56         bgPen->setTitle(title);
57     }
58 }
59 
getPen()60 RS_Pen QG_WidgetPen::getPen() {
61     RS_Pen pen;
62 
63     pen.setColor(cbColor->getColor());
64     pen.setWidth(cbWidth->getWidth());
65     pen.setLineType(cbLineType->getLineType());
66 
67     return pen;
68 }
69 
isColorUnchanged()70 bool QG_WidgetPen::isColorUnchanged() {
71     return cbColor->isUnchanged();
72 }
73 
isLineTypeUnchanged()74 bool QG_WidgetPen::isLineTypeUnchanged() {
75     return cbLineType->isUnchanged();
76 }
77 
isWidthUnchanged()78 bool QG_WidgetPen::isWidthUnchanged() {
79     return cbWidth->isUnchanged();
80 }
81 /*
82  *  Destroys the object and frees any allocated resources
83  */
~QG_WidgetPen()84 QG_WidgetPen::~QG_WidgetPen()
85 {
86     // no need to delete child widgets, Qt does it all for us
87 }
88 
89 /*
90  *  Sets the strings of the subwidgets using the current
91  *  language.
92  */
languageChange()93 void QG_WidgetPen::languageChange()
94 {
95     retranslateUi(this);
96 }
97 
98