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 "pentoolbar.h"
23 #include "linetypebox.h"
29 PenToolBar::PenToolBar(QMainWindow * parent/*= NULL*/, const char * name/*= NULL*/):
31 colorBox(new ColorBox(true, false, this, "colorbox")),
32 widthBox(new WidthBox(true, false, this, "widthbox")),
33 lineTypeBox(new LineTypeBox(true, false, this, "lineTypebox"))
37 colorBox->setMinimumWidth(80);
38 widthBox->setMinimumWidth(80);
39 lineTypeBox->setMinimumWidth(80);
41 connect(colorBox, SIGNAL(colorChanged(const Color &)), this,
42 SLOT(slotColorChanged(const Color &)));
43 connect(widthBox, SIGNAL(widthChanged(RS2::LineWidth)), this,
44 SLOT(slotWidthChanged(RS2::LineWidth)));
45 connect(lineTypeBox, SIGNAL(lineTypeChanged(RS2::LineType)), this,
46 SLOT(slotLineTypeChanged(RS2::LineType)));
48 currentPen.setColor(colorBox->getColor());
49 currentPen.setWidth(widthBox->getWidth());
50 currentPen.setLineType(lineTypeBox->getLineType());
54 addWidget(lineTypeBox);
60 PenToolBar::~PenToolBar()
67 Pen PenToolBar::getPen()
73 * Called by the layer list if this object was added as a listener
76 void PenToolBar::layerActivated(Layer * l)
78 //printf("PenToolBar::layerActivated\n");
83 //colorBox->setColor(l->getPen().getColor());
84 //widthBox->setWidth(l->getPen().getWidth());
86 colorBox->setLayerColor(l->getPen().getColor());
87 widthBox->setLayerWidth(l->getPen().getWidth());
88 lineTypeBox->setLayerLineType(l->getPen().getLineType());
90 //if (colorBox->getColor().getFlag(C_BY_LAYER)) {
91 //printf(" Color by layer\n");
92 //colorBox->setColor(l->getPen().getColor());
97 * Called by the layer list (if this object was previously
98 * added as a listener to a layer list).
100 void PenToolBar::layerEdited(Layer *)
105 * Called when the color was changed by the user.
107 void PenToolBar::slotColorChanged(const Color & color)
109 currentPen.setColor(color);
110 //printf(" color changed\n");
112 emit penChanged(currentPen);
116 * Called when the width was changed by the user.
118 void PenToolBar::slotWidthChanged(RS2::LineWidth w)
120 currentPen.setWidth(w);
121 //printf(" width changed\n");
123 emit penChanged(currentPen);
127 * Called when the linetype was changed by the user.
129 void PenToolBar::slotLineTypeChanged(RS2::LineType w)
131 currentPen.setLineType(w);
132 //printf(" line type changed\n");
134 emit penChanged(currentPen);