Fraxinus  16.5.0-fx-rc1
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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;
108 class cxResourceWidgets_EXPORT BaseWidget: public OptimizedUpdateWidget
109 {
110  Q_OBJECT
111 
112 public:
113  BaseWidget(QWidget* parent, QString objectName, QString windowTitle);
114  virtual ~BaseWidget() {}
115 
116  QWidget* createMethodWidget(QWidget* inputWidget, QWidget* outputWidget, QString methodname,
117  bool inputChecked = false, bool outputVisible = true);
118 
119  QGroupBox* createGroupbox(QWidget* widget, QString boxname);
120  static QFrame* createHorizontalLine();
121  QGroupBox* wrapInGroupBox(QWidget* base, QString name);
122  CXFrame* wrapInFrame(QWidget* base);
123 
128  QAction* createAction2(QObject* parent, QIcon iconName, QString text, QString tip, QLayout* layout=NULL, QToolButton* button = new QToolButton())
129  {
130  if (tip.isEmpty())
131  tip = text;
132  QAction* action = new QAction(iconName, text, parent);
133  action->setStatusTip(tip);
134  action->setWhatsThis(tip);
135  action->setToolTip(tip);
136  if (layout)
137  {
138  button->setDefaultAction(action);
139  layout->addWidget(button);
140  }
141  return action;
142  }
143 
148  template<class T>
149  QAction* createAction(QObject* parent, QIcon iconName, QString text, QString tip, T slot, QLayout* layout=NULL, QToolButton* button = new QToolButton())
150  {
151  QAction* action = createAction2(parent, iconName, text, tip, layout, button);
152  connect(action, SIGNAL(triggered()), this, slot);
153  return action;
154  }
155 
156 
157 public slots:
158  void adjustSizeSlot();
159 
160 protected:
161  virtual void showEvent(QShowEvent* event);
162 
163 private:
164  QString mObjectName;
165  QString mWindowTitle;
166 };
167 
168 }
169 
174 #endif /* CXBASEWIDGET_H_ */
CXFrame(QWidget *parent)
Definition: cxBaseWidget.h:66
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:149
virtual ~BaseWidget()
Definition: cxBaseWidget.h:114
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
Interface for QWidget which handles widgets uniformly for the system.
Definition: cxBaseWidget.h:108
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:128