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/10/2010 Created this file. :-)
15 #include "cadtoolbar.h"
17 #include "cadtoolbararcs.h"
18 #include "cadtoolbarcircles.h"
19 #include "cadtoolbardim.h"
20 #include "cadtoolbarellipses.h"
21 #include "cadtoolbarinfo.h"
22 #include "cadtoolbarlines.h"
23 #include "cadtoolbarmain.h"
24 #include "cadtoolbarmodify.h"
25 #include "cadtoolbarpoints.h"
26 #include "cadtoolbarpolylines.h"
27 #include "cadtoolbarselect.h"
28 #include "cadtoolbarsnap.h"
29 #include "cadtoolbarsplines.h"
32 CadToolBar::CadToolBar(QWidget * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
33 QWidget(parent, flags), actionHandler(NULL), currentTb(NULL), tbSplines(NULL),
34 tbInfo(NULL),tbMain(NULL), tbDim(NULL), tbLines(NULL), tbPoints(NULL),
35 tbEllipses(NULL), tbArcs(NULL), tbModify(NULL), tbCircles(NULL), tbSnap(NULL),
36 tbSelect(NULL), tbPolylines(NULL)
41 // QSizePolicy policy(QSizePolicy::Fixed, QSizePolicy::MinimumExpanding);
42 // policy.setHorizontalStretch(0);
43 // policy.setVerticalStretch(0);
44 // policy.setHeightForWidth(sizePolicy().hasHeightForWidth());
45 // setSizePolicy(policy);
46 setMinimumSize(QSize(56, 336));
48 //hm. here maybe? Yesh!
50 ((QToolBar *)parent)->addWidget(this);
53 CadToolBar::~CadToolBar()
58 * @return Pointer to action handler or NULL.
60 QG_ActionHandler * CadToolBar::getActionHandler()
66 * Called from the sub toolbar
68 void CadToolBar::back()
74 * Called from the application.
76 void CadToolBar::forceNext()
78 if (currentTb && currentTb == tbSelect)
79 tbSelect->runNextAction();
82 void CadToolBar::mouseReleaseEvent(QMouseEvent * e)
84 if (e->button() == Qt::RightButton)
91 void CadToolBar::contextMenuEvent(QContextMenuEvent * e)
97 * Creates all tool bars and shows the main toolbar.
99 * @param ah Pointer to action handler which will deal with the actions in this tool bar.
101 void CadToolBar::createSubToolBars(QG_ActionHandler * ah)
104 tbMain = new CadToolBarMain(this);
105 tbMain->setCadToolBar(this);
108 tbPoints = new CadToolBarPoints(this);
111 tbLines = new CadToolBarLines(this);
114 tbArcs = new CadToolBarArcs(this);
117 tbCircles = new CadToolBarCircles(this);
120 tbEllipses = new CadToolBarEllipses(this);
123 tbSplines = new CadToolBarSplines(this);
126 tbPolylines = new CadToolBarPolylines(this);
129 tbDim = new CadToolBarDim(this);
132 tbInfo = new CadToolBarInfo(this);
135 tbModify = new CadToolBarModify(this);
138 tbSnap = new CadToolBarSnap(this);
141 tbSelect = new CadToolBarSelect(this);
145 void CadToolBar::showToolBar(int id)
147 QWidget * newTb = NULL;
152 case RS2::ToolBarMain:
155 case RS2::ToolBarPoints:
158 case RS2::ToolBarLines:
161 case RS2::ToolBarArcs:
164 case RS2::ToolBarEllipses:
167 case RS2::ToolBarSplines:
170 case RS2::ToolBarPolylines:
173 case RS2::ToolBarCircles:
176 case RS2::ToolBarInfo:
179 case RS2::ToolBarModify:
182 case RS2::ToolBarDim:
185 case RS2::ToolBarSnap:
188 case RS2::ToolBarSelect:
193 if (currentTb == newTb)
205 void CadToolBar::showToolBarMain()
207 showToolBar(RS2::ToolBarMain);
210 void CadToolBar::showToolBarPoints()
212 showToolBar(RS2::ToolBarPoints);
215 void CadToolBar::showToolBarLines()
217 showToolBar(RS2::ToolBarLines);
220 void CadToolBar::showToolBarArcs()
222 showToolBar(RS2::ToolBarArcs);
225 void CadToolBar::showToolBarEllipses()
227 showToolBar(RS2::ToolBarEllipses);
230 void CadToolBar::showToolBarSplines()
232 showToolBar(RS2::ToolBarSplines);
235 void CadToolBar::showToolBarPolylines()
238 showToolBar(RS2::ToolBarPolylines);
242 void CadToolBar::showToolBarCircles()
244 showToolBar(RS2::ToolBarCircles);
247 void CadToolBar::showToolBarInfo()
249 showToolBar(RS2::ToolBarInfo);
252 void CadToolBar::showToolBarModify()
254 showToolBar(RS2::ToolBarModify);
257 void CadToolBar::showToolBarSnap()
259 showToolBar(RS2::ToolBarSnap);
262 void CadToolBar::showToolBarDim()
264 showToolBar(RS2::ToolBarDim);
267 void CadToolBar::showToolBarSelect()
269 showToolBarSelect(NULL, -1);
272 void CadToolBar::showToolBarSelect(RS_ActionInterface * selectAction, int nextAction)
274 tbSelect->setNextAction(nextAction);
275 tbSelect->setSelectAction(selectAction);
276 showToolBar(RS2::ToolBarSelect);