3 // Part of the Architektonas Project
4 // Originally part of QCad Community Edition by Andrew Mustun
5 // Extensively rewritten and refactored by James L. Hammons
6 // Portions copyright (C) 2001-2003 RibbonSoft
7 // Copyright (C) 2010 Underground Software
8 // See the README and GPLv2 files for licensing and warranty information
10 // JLH = James L. Hammons <jlhamm@acm.org>
13 // --- ---------- -----------------------------------------------------------
14 // JLH 05/11/2010 Added this text. :-)
15 // JLH 05/22/2010 Fixed constructor to actually add widgets to the toolbar,
16 // delete created objects in destructor to prevent memory leak
19 #include "qg_pentoolbar.h"
21 #include "qg_colorbox.h"
22 #include "qg_widthbox.h"
23 #include "qg_linetypebox.h"
28 QG_PenToolBar::QG_PenToolBar(QMainWindow * parent/*= NULL*/, const char * name/*= NULL*/):
30 colorBox(new QG_ColorBox(true, false, this, "colorbox")),
31 widthBox(new QG_WidthBox(true, false, this, "widthbox")),
32 lineTypeBox(new QG_LineTypeBox(true, false, this, "lineTypebox"))
36 colorBox->setMinimumWidth(80);
37 widthBox->setMinimumWidth(80);
38 lineTypeBox->setMinimumWidth(80);
40 connect(colorBox, SIGNAL(colorChanged(const RS_Color &)), this,
41 SLOT(slotColorChanged(const RS_Color &)));
42 connect(widthBox, SIGNAL(widthChanged(RS2::LineWidth)), this,
43 SLOT(slotWidthChanged(RS2::LineWidth)));
44 connect(lineTypeBox, SIGNAL(lineTypeChanged(RS2::LineType)), this,
45 SLOT(slotLineTypeChanged(RS2::LineType)));
47 currentPen.setColor(colorBox->getColor());
48 currentPen.setWidth(widthBox->getWidth());
49 currentPen.setLineType(lineTypeBox->getLineType());
53 addWidget(lineTypeBox);
59 QG_PenToolBar::~QG_PenToolBar()
66 RS_Pen QG_PenToolBar::getPen()
72 * Called by the layer list if this object was added as a listener
75 void QG_PenToolBar::layerActivated(RS_Layer * l)
77 //printf("QG_PenToolBar::layerActivated\n");
82 //colorBox->setColor(l->getPen().getColor());
83 //widthBox->setWidth(l->getPen().getWidth());
85 colorBox->setLayerColor(l->getPen().getColor());
86 widthBox->setLayerWidth(l->getPen().getWidth());
87 lineTypeBox->setLayerLineType(l->getPen().getLineType());
89 //if (colorBox->getColor().getFlag(C_BY_LAYER)) {
90 //printf(" Color by layer\n");
91 //colorBox->setColor(l->getPen().getColor());
96 * Called by the layer list (if this object was previously
97 * added as a listener to a layer list).
99 void QG_PenToolBar::layerEdited(RS_Layer *)
104 * Called when the color was changed by the user.
106 void QG_PenToolBar::slotColorChanged(const RS_Color & color)
108 currentPen.setColor(color);
109 //printf(" color changed\n");
111 emit penChanged(currentPen);
115 * Called when the width was changed by the user.
117 void QG_PenToolBar::slotWidthChanged(RS2::LineWidth w)
119 currentPen.setWidth(w);
120 //printf(" width changed\n");
122 emit penChanged(currentPen);
126 * Called when the linetype was changed by the user.
128 void QG_PenToolBar::slotLineTypeChanged(RS2::LineType w)
130 currentPen.setLineType(w);
131 //printf(" line type changed\n");
133 emit penChanged(currentPen);