Fraxinus  17.12-rc3
An IGT application
cxBaseWidget.h
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) 2008-2014, SINTEF Department of Medical Technology
5 All rights reserved.
6 
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9 
10 1. Redistributions of source code must retain the above copyright notice,
11  this list of conditions and the following disclaimer.
12 
13 2. Redistributions in binary form must reproduce the above copyright notice,
14  this list of conditions and the following disclaimer in the documentation
15  and/or other materials provided with the distribution.
16 
17 3. Neither the name of the copyright holder nor the names of its contributors
18  may be used to endorse or promote products derived from this software
19  without specific prior written permission.
20 
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 =========================================================================*/
32 
33 #ifndef CXBASEWIDGET_H_
34 #define CXBASEWIDGET_H_
35 
36 #include "cxResourceWidgetsExport.h"
37 #include <QFrame>
38 #include <QToolButton>
39 #include <QAction>
40 #include <QLayout>
41 #include <iostream>
42 #include <boost/shared_ptr.hpp>
44 #include "boost/function.hpp"
45 
46 class QWidget;
47 class QGroupBox;
48 class QCheckBox;
49 class QLabel;
50 
62 class cxResourceWidgets_EXPORT CXFrame : public QFrame
63 {
64  Q_OBJECT
65 public:
66  CXFrame(QWidget* parent) : QFrame(parent) {}
67  virtual ~CXFrame() {}
68 };
69 
75 class cxResourceWidgets_EXPORT CXToolButton : public QToolButton
76 {
77  Q_OBJECT
78 public:
79  CXToolButton(QWidget* parent=0) : QToolButton(parent) {}
80 };
81 
87 class cxResourceWidgets_EXPORT CXSmallToolButton : public CXToolButton
88 {
89  Q_OBJECT
90 public:
91  CXSmallToolButton(QWidget* parent=0) : CXToolButton(parent) {}
92 };
93 
94 
95 namespace cx
96 {
97 typedef boost::shared_ptr<class PatientModelService> PatientModelServicePtr;
98 typedef boost::shared_ptr<class ViewService> ViewServicePtr;
99 typedef boost::shared_ptr<class TrackingService> TrackingServicePtr;
109 class cxResourceWidgets_EXPORT BaseWidget: public OptimizedUpdateWidget
110 {
111  Q_OBJECT
112 
113 public:
114  BaseWidget(QWidget* parent, QString objectName, QString windowTitle);
115  virtual ~BaseWidget() {}
116 
117  QWidget* createMethodWidget(QWidget* inputWidget, QWidget* outputWidget, QString methodname,
118  bool inputChecked = false, bool outputVisible = true);
119 
120  QGroupBox* createGroupbox(QWidget* widget, QString boxname);
121  static QFrame* createHorizontalLine();
122  QGroupBox* wrapInGroupBox(QWidget* base, QString name);
123  CXFrame* wrapInFrame(QWidget* base);
124 
129  QAction* createAction2(QObject* parent, QIcon iconName, QString text, QString tip, QLayout* layout=NULL, QToolButton* button = new QToolButton())
130  {
131  if (tip.isEmpty())
132  tip = text;
133  QAction* action = new QAction(iconName, text, parent);
134  action->setStatusTip(tip);
135  action->setWhatsThis(tip);
136  action->setToolTip(tip);
137  if (layout)
138  {
139  button->setDefaultAction(action);
140  layout->addWidget(button);
141  }
142  return action;
143  }
144 
149  template<class T>
150  QAction* createAction(QObject* parent, QIcon iconName, QString text, QString tip, T slot, QLayout* layout=NULL, QToolButton* button = new QToolButton())
151  {
152  QAction* action = createAction2(parent, iconName, text, tip, layout, button);
153  connect(action, SIGNAL(triggered()), this, slot);
154  return action;
155  }
156 
157 
158 public slots:
159  void adjustSizeSlot();
160 
161 protected:
162  virtual void showEvent(QShowEvent* event);
163 
164 private:
165  QString mObjectName;
166  QString mWindowTitle;
167 };
168 
169 }
170 
175 #endif /* CXBASEWIDGET_H_ */
CXFrame(QWidget *parent)
Definition: cxBaseWidget.h:66
boost::shared_ptr< class TrackingService > TrackingServicePtr
boost::shared_ptr< class ViewService > ViewServicePtr
virtual ~CXFrame()
Definition: cxBaseWidget.h:67
CXSmallToolButton(QWidget *parent=0)
Definition: cxBaseWidget.h:91
QAction * createAction(QObject *parent, QIcon iconName, QString text, QString tip, T slot, QLayout *layout=NULL, QToolButton *button=new QToolButton())
Definition: cxBaseWidget.h:150
virtual ~BaseWidget()
Definition: cxBaseWidget.h:115
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
Interface for QWidget which handles widgets uniformly for the system.
Definition: cxBaseWidget.h:109
Interface for all classes following the modified/prepaint paradigm.
CXToolButton(QWidget *parent=0)
Definition: cxBaseWidget.h:79
QAction * createAction2(QObject *parent, QIcon iconName, QString text, QString tip, QLayout *layout=NULL, QToolButton *button=new QToolButton())
Definition: cxBaseWidget.h:129
Namespace for all CustusX production code.