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 // (C) 2010 Underground Software
8 // JLH = James L. Hammons <jlhamm@acm.org>
11 // --- ---------- -----------------------------------------------------------
12 // JLH 05/11/2010 Added this text. :-)
13 // JLH 05/22/2010 Fixed constructor to actually add widgets to the toolbar,
14 // delete created objects in destructor to prevent memory leak
17 #include "qg_pentoolbar.h"
19 #include "qg_colorbox.h"
20 #include "qg_widthbox.h"
21 #include "qg_linetypebox.h"
26 QG_PenToolBar::QG_PenToolBar(QMainWindow * parent/*= NULL*/, const char * name/*= NULL*/):
28 colorBox(new QG_ColorBox(true, false, this, "colorbox")),
29 widthBox(new QG_WidthBox(true, false, this, "widthbox")),
30 lineTypeBox(new QG_LineTypeBox(true, false, this, "lineTypebox"))
34 colorBox->setMinimumWidth(80);
35 widthBox->setMinimumWidth(80);
36 lineTypeBox->setMinimumWidth(80);
38 connect(colorBox, SIGNAL(colorChanged(const RS_Color &)), this,
39 SLOT(slotColorChanged(const RS_Color &)));
40 connect(widthBox, SIGNAL(widthChanged(RS2::LineWidth)), this,
41 SLOT(slotWidthChanged(RS2::LineWidth)));
42 connect(lineTypeBox, SIGNAL(lineTypeChanged(RS2::LineType)), this,
43 SLOT(slotLineTypeChanged(RS2::LineType)));
45 currentPen.setColor(colorBox->getColor());
46 currentPen.setWidth(widthBox->getWidth());
47 currentPen.setLineType(lineTypeBox->getLineType());
51 addWidget(lineTypeBox);
57 QG_PenToolBar::~QG_PenToolBar()
64 RS_Pen QG_PenToolBar::getPen()
70 * Called by the layer list if this object was added as a listener
73 void QG_PenToolBar::layerActivated(RS_Layer * l)
75 //printf("QG_PenToolBar::layerActivated\n");
80 //colorBox->setColor(l->getPen().getColor());
81 //widthBox->setWidth(l->getPen().getWidth());
83 colorBox->setLayerColor(l->getPen().getColor());
84 widthBox->setLayerWidth(l->getPen().getWidth());
85 lineTypeBox->setLayerLineType(l->getPen().getLineType());
87 //if (colorBox->getColor().getFlag(C_BY_LAYER)) {
88 //printf(" Color by layer\n");
89 //colorBox->setColor(l->getPen().getColor());
94 * Called by the layer list (if this object was previously
95 * added as a listener to a layer list).
97 void QG_PenToolBar::layerEdited(RS_Layer *)
102 * Called when the color was changed by the user.
104 void QG_PenToolBar::slotColorChanged(const RS_Color & color)
106 currentPen.setColor(color);
107 //printf(" color changed\n");
109 emit penChanged(currentPen);
113 * Called when the width was changed by the user.
115 void QG_PenToolBar::slotWidthChanged(RS2::LineWidth w)
117 currentPen.setWidth(w);
118 //printf(" width changed\n");
120 emit penChanged(currentPen);
124 * Called when the linetype was changed by the user.
126 void QG_PenToolBar::slotLineTypeChanged(RS2::LineType w)
128 currentPen.setLineType(w);
129 //printf(" line type changed\n");
131 emit penChanged(currentPen);