VR-Forces 5.0.1 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
toolButtonWrapperWidget.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2015 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
8 
10 
11 #pragma once
12 
15 
16 #include <QtWidgets/QWidget>
17 #include <QtGui/QPixmap>
18 #include <boost/signals2.hpp>
19 
20 class QAction;
21 class QHBoxLayout;
22 class QAbstractButton;
23 class QSpacerItem;
24 
25 namespace makVrf
26 {
33  {
34  Q_OBJECT
35 
36  public:
37  struct Layout
38  {
39  QHBoxLayout* layout;
40  std::vector<QAbstractButton*> buttons;
42  QSpacerItem* spacerItem;
43  };
44 
45  public:
46  DtToolButtonWrapperWidget(makVrv::DtDe& de, QWidget* parent, const Qt::WindowFlags& flags = 0);
47 
48  //DTOR
49  virtual ~DtToolButtonWrapperWidget();
50 
51  template <typename T> T* createPrototype()
52  {
53  T* b = new T(this);
54 
55  b->setFocusPolicy( Qt::NoFocus );
56  b->setIconSize(myIconSize);
57  b->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
58 
59  return b;
60  }
61 
62  template <typename T> T* createButton()
63  {
64  T* b = createPrototype<T>();
65 
66  this->myButtons.push_back(b);
67 
68  return b;
69  }
70 
72  template <typename T> T* addAction(const QString& action, bool resetLayout = true)
73  {
74  T* b = createButton<T>();
75  b->setText(action);
76 
77  if (resetLayout)
78  {
79  this->addToLayout(b);
80  }
81 
82  return b;
83  }
84 
86  template <typename T> T* addActionWithIcon(const std::string& icon, bool resetLayout = true)
87  {
88  T* b = createButton<T>();
89 
91 
92  if (resetLayout)
93  {
94  this->addToLayout(b);
95  }
96 
97  return b;
98  }
99 
101  template <typename T> T* addAction(const QIcon& icon, bool resetLayout = true)
102  {
103  T* b = createButton<T>();
104 
105  b->setIcon(icon);
106 
107  if (resetLayout)
108  {
109  this->addToLayout(b);
110  }
111 
112  return b;
113  }
114 
116  template <typename T> T* addAction(QAction* act, bool resetLayout = true)
117  {
118  T* b = createButton<T>();
119  b->setAutoRaise(true);
120  b->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
121  b->setDefaultAction(act);
122 
123  if (resetLayout)
124  {
125  this->addToLayout(b);
126  }
127 
128  return b;
129  }
130 
132  virtual int rightMarginForLine(int) const;
133 
136  virtual void setRightMarginForLine(int margin, int line = -1);
137 
139  virtual void removeRightMarginForLine(int line = -1);
140 
142  virtual void removeButton(QAbstractButton*, bool resetLayout = true);
143 
145  virtual void layoutButtons(bool force = false);
146 
149  virtual void setButtons(const std::vector<QAbstractButton*>& buttons, bool deleteCurrentButtons = false);
150 
152  virtual void setLeftToRightLayout(bool);
153  bool leftToRightLayout() const
154  {
155  return myLeftToRightLayout;
156  }
157 
158  bool needsLayout() const
159  {
160  return myNeedsLayout;
161  }
162 
165  virtual void setSizeToFit(bool);
166  bool sizeToFit() const
167  {
168  return mySizeToFit;
169  }
170 
171  int buttonsShown() const
172  {
173  return myButtonsShown;
174  }
175 
176  const std::vector<QAbstractButton*>& buttons() const
177  {
178  return myButtons;
179  }
180 
181  std::vector<QAbstractButton*>& buttons()
182  {
183  return myButtons;
184  }
185 
186  virtual bool hasButton(QAbstractButton*) const;
187 
189  virtual void setIconSize(const QSize&);
190  const QSize& iconSize() const
191  {
192  return myIconSize;
193  }
194 
196  virtual void setIconSpacing(int);
197  int iconSpacing() const
198  {
199  return myIconSpacing;
200  }
201 
203  virtual void clear();
204 
206  virtual void setUseFixedWidth(bool);
207  bool useFixedWidth() const
208  {
209  return myUseFixedWidth;
210  }
211 
212  virtual void fixWidth();
213 
215  virtual void setFixedButtonWidth(int);
216  int fixedButtonWidth() const
217  {
218  return myFixedButtonWidth;
219  }
220 
223  virtual void setFixedButtonHeight(int);
224  int fixedButtonHeight() const
225  {
226  return myFixedButtonHeight;
227  }
228 
230  virtual void setShowMaximum(int);
231  int showMaximum() const
232  {
233  return myShowMaximum;
234  }
235 
237  virtual void setMaximumLines(int);
238  int maximumLines() const
239  {
240  return myMaximumLines;
241  }
242 
243  bool reachedMaximum() const
244  {
245  return myReachedMaximum;
246  }
247 
248  virtual bool buttonsLeftToDisplay() const;
249 
250  int numRows() const
251  {
252  return myLayouts.size();
253  }
254 
255  const std::vector<Layout>& layouts() const
256  {
257  return myLayouts;
258  }
259 
260  std::vector<Layout>& layouts()
261  {
262  return myLayouts;
263  }
264 
266  virtual void setBlockResizeLayout(bool);
267  bool blockResizeLayout() const
268  {
269  return myBlockResizeLayout;
270  }
271 
273  virtual void setSignalResizeLayout(bool);
274  bool signalResizeLayout() const
275  {
276  return mySignalResizeLayout;
277  }
278 
280  virtual void setCreateDefaultIcon(bool b);
281  bool createDefaultIcon() const
282  {
283  return myCreateDefaultIcon;
284  }
285 
287  virtual void setSetToolTipToText(bool);
288  bool setToolTipToText() const
289  {
290  return mySetToolTipToText;
291  }
292 
293  boost::signals2::signal<void ()> signal_resizeLayout;
294  boost::signals2::signal<void (bool)> signal_maximumReached;
295 
296  public:
297  boost::signals2::signal<void ()> signal_buttonsLayedOut;
298  boost::signals2::signal<void (Layout&, QAbstractButton*)> signal_buttonLayedOut;
299 
300  protected slots:
301  virtual void layoutFromTimer();
302 
303  protected:
304  virtual QPixmap createDefaultIcon(const QString&) const;
305  virtual void resizeEvent(QResizeEvent*);
306  virtual void showEvent(QShowEvent*);
307  virtual void addToLayout(QAbstractButton*, bool forceLayout = false);
308 
309  protected:
310  std::vector<Layout> myLayouts;
311  std::vector<QAbstractButton*> myButtons;
312  std::map<int, int> myRightMarginForLine;
313 
314  QSize myIconSize;
332 
334  };
335 }
const std::vector< Layout > & layouts() const
Definition: toolButtonWrapperWidget.h:255
bool setToolTipToText() const
Definition: toolButtonWrapperWidget.h:288
bool signalResizeLayout() const
Definition: toolButtonWrapperWidget.h:274
int myShowMaximum
Definition: toolButtonWrapperWidget.h:323
bool mySetTimer
Definition: toolButtonWrapperWidget.h:326
T * addAction(const QIcon &icon, bool resetLayout=true)
Adds a new button with an icon.
Definition: toolButtonWrapperWidget.h:101
const std::vector< QAbstractButton * > & buttons() const
Definition: toolButtonWrapperWidget.h:176
int numRows() const
Definition: toolButtonWrapperWidget.h:250
int myIconSpacing
Definition: toolButtonWrapperWidget.h:315
This class will try and space out items such that they will wrap to multiple rows if buttons (or text...
Definition: toolButtonWrapperWidget.h:32
int myButtonsShown
Definition: toolButtonWrapperWidget.h:324
std::vector< Layout > myLayouts
Definition: toolButtonWrapperWidget.h:310
int maximumLines() const
Definition: toolButtonWrapperWidget.h:238
bool sizeToFit() const
Definition: toolButtonWrapperWidget.h:166
int iconSpacing() const
Definition: toolButtonWrapperWidget.h:197
makVrv::DtDe & myDe
Definition: toolButtonWrapperWidget.h:333
const QSize & iconSize() const
Definition: toolButtonWrapperWidget.h:190
Definition: toolButtonWrapperWidget.h:37
std::vector< QAbstractButton * > & buttons()
Definition: toolButtonWrapperWidget.h:181
Contains makVrv::DtWidgetIconStyleManager class declaration.
bool myLeftToRightLayout
Definition: toolButtonWrapperWidget.h:322
T * addAction(const QString &action, bool resetLayout=true)
Adds a new button with text. Up to caller to determine what to do with the returned tool button...
Definition: toolButtonWrapperWidget.h:72
bool myUseFixedWidth
Definition: toolButtonWrapperWidget.h:329
bool leftToRightLayout() const
Definition: toolButtonWrapperWidget.h:153
QSpacerItem * spacerItem
Definition: toolButtonWrapperWidget.h:42
std::vector< Layout > & layouts()
Definition: toolButtonWrapperWidget.h:260
static DtWidgetIconStyleManager & instance(DtDe &de)
Returns a reference to the DtWidgetIconStyleManager instance This function will register the manager ...
bool myInResize
Definition: toolButtonWrapperWidget.h:325
bool needsLayout() const
Definition: toolButtonWrapperWidget.h:158
int myFixedButtonHeight
Definition: toolButtonWrapperWidget.h:320
bool myBlockResizeLayout
Definition: toolButtonWrapperWidget.h:327
bool mySignalResizeLayout
Definition: toolButtonWrapperWidget.h:328
bool myNeedsLayout
Definition: toolButtonWrapperWidget.h:317
bool useFixedWidth() const
Definition: toolButtonWrapperWidget.h:207
boost::signals2::signal< void(Layout &, QAbstractButton *)> signal_buttonLayedOut
Definition: toolButtonWrapperWidget.h:298
int fixedButtonHeight() const
Definition: toolButtonWrapperWidget.h:224
bool mySetToolTipToText
Definition: toolButtonWrapperWidget.h:331
QHBoxLayout * layout
Definition: toolButtonWrapperWidget.h:39
T * createPrototype()
Definition: toolButtonWrapperWidget.h:51
int buttonsShown() const
Definition: toolButtonWrapperWidget.h:171
virtual void manageWidget(QObject *widgetToManage, const std::string &iconFileNameOrPath)
Add a new widget to the manager. The manager will now manage the icon style for the widget...
#define DT_DLL_VRFGUICOMMONQT
Definition: vrfGuiCommonQt.h:20
boost::signals2::signal< void(bool)> signal_maximumReached
Definition: toolButtonWrapperWidget.h:294
std::map< int, int > myRightMarginForLine
Definition: toolButtonWrapperWidget.h:312
boost::signals2::signal< void()> signal_buttonsLayedOut
Definition: toolButtonWrapperWidget.h:297
bool reachedMaximum() const
Definition: toolButtonWrapperWidget.h:243
T * addActionWithIcon(const std::string &icon, bool resetLayout=true)
Adds a new button with a managed icon.
Definition: toolButtonWrapperWidget.h:86
bool blockResizeLayout() const
Definition: toolButtonWrapperWidget.h:267
int showMaximum() const
Definition: toolButtonWrapperWidget.h:231
std::vector< QAbstractButton * > buttons
Definition: toolButtonWrapperWidget.h:40
bool myCreateDefaultIcon
Definition: toolButtonWrapperWidget.h:330
boost::signals2::signal< void()> signal_resizeLayout
Definition: toolButtonWrapperWidget.h:293
bool myReachedMaximum
Definition: toolButtonWrapperWidget.h:318
The DtDe is the core component of any VR-Vantage application. It owns a DtRenderer, DtDeCommunicator, as well as a DtDisplay and other things.
Definition: DtDe.h:70
int myFixedButtonWidth
Definition: toolButtonWrapperWidget.h:319
int currentWidth
Definition: toolButtonWrapperWidget.h:41
bool mySizeToFit
Definition: toolButtonWrapperWidget.h:321
T * addAction(QAction *act, bool resetLayout=true)
Adds a new action into the dialog for sizing.
Definition: toolButtonWrapperWidget.h:116
QSize myIconSize
Definition: toolButtonWrapperWidget.h:314
int fixedButtonWidth() const
Definition: toolButtonWrapperWidget.h:216
std::vector< QAbstractButton * > myButtons
Definition: toolButtonWrapperWidget.h:311
T * createButton()
Definition: toolButtonWrapperWidget.h:62
bool createDefaultIcon() const
Definition: toolButtonWrapperWidget.h:281
int myMaximumLines
Definition: toolButtonWrapperWidget.h:316

Document ID: Generated on Mon Jun 20 00:38:30 EDT 2022 from SVN revision 244029
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)