OpendTect-6_4  6.4
uibutton.h
Go to the documentation of this file.
1 #ifndef uibutton_h
2 #define uibutton_h
3 
4 /*+
5 ________________________________________________________________________
6 
7  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
8  Author: A.H. Lammertink
9  Date: 21/01/2000
10  RCS: $Id$
11 ________________________________________________________________________
12 
13 -*/
14 
15 #include "uibasemod.h"
16 #include "uiobj.h"
17 #include "uistring.h"
18 #include "odiconfile.h"
19 
20 class uiButtonBody;
21 class uiCheckBoxBody;
22 class uiPushButtonBody;
23 class uiRadioButtonBody;
24 mFDQtclass(QAbstractButton)
25 
26 class uiMenu;
27 class uiPixmap;
28 mFDQtclass(QEvent)
29 mFDQtclass(QMenu)
30 
31 
33 
34 mExpClass(uiBase) uiButton : public uiObject
35 {
36 public:
37  uiButton(uiParent*,const uiString&,const CallBack*,
38  uiObjectBody&);
39  virtual ~uiButton() {}
40 
41  virtual void setText(const uiString&);
42  const uiString& text() const { return text_; }
43  void setIcon(const char* icon_identifier);
44  void setPixmap( const uiPixmap& pm ) { setPM(pm); }
45  void setIconScale(float val);
46  virtual void updateIconSize() {}
47 
48  virtual void click() = 0;
49 
50  Notifier<uiButton> activated;
51 
53  mQtclass(QAbstractButton*) qButton();
54  const mQtclass(QAbstractButton*) qButton() const;
55 
56  static uiButton* getStd(uiParent*,OD::StdActionType,const CallBack&,
57  bool immediate);
58  static uiButton* getStd(uiParent*,OD::StdActionType,const CallBack&,
59  bool immediate,const uiString& nonstd_text);
61 
62  static bool haveCommonPBIcons() { return havecommonpbics_; }
63  static void setHaveCommonPBIcons( bool yn=true )
64  { havecommonpbics_ = yn; }
65 
66 protected:
67 
68  uiString text_;
69  float iconscale_;
70  static bool havecommonpbics_;
71 
72  virtual void translateText();
73  virtual void setPM(const uiPixmap&);
74 
75 };
76 
77 
83 mExpClass(uiBase) uiPushButton : public uiButton
84 {
85 public:
86  uiPushButton(uiParent*,const uiString& txt,
87  bool immediate);
88  uiPushButton(uiParent*,const uiString& txt,
89  const CallBack&,bool immediate);
90  uiPushButton(uiParent*,const uiString& txt,
91  const uiPixmap&,bool immediate);
92  uiPushButton(uiParent*,const uiString& txt,
93  const uiPixmap&,const CallBack&,
94  bool immediate);
95 
96  void setDefault(bool yn=true);
97  void click();
98  void setMenu(uiMenu*);
99  void setFlat(bool);
100  bool isFlat() const;
101 
102 private:
103 
104  void translateText();
105  void updateText();
106  void updateIconSize();
107 
109  uiPushButtonBody* pbbody_;
110  uiPushButtonBody& mkbody(uiParent*,const uiString&);
111 };
112 
113 
114 mExpClass(uiBase) uiRadioButton : public uiButton
115 {
116 public:
119  const CallBack&);
120 
121  bool isChecked() const;
122  virtual void setChecked(bool yn=true);
123 
124  void click();
125 
126 private:
127 
128  uiRadioButtonBody* rbbody_;
129  uiRadioButtonBody& mkbody(uiParent*,const uiString&);
130 
131 };
132 
133 
134 mExpClass(uiBase) uiCheckBox: public uiButton
135 {
136 public:
137 
138  uiCheckBox(uiParent*,const uiString&);
139  uiCheckBox(uiParent*,const uiString&,
140  const CallBack&);
141 
142  bool isChecked() const;
143  void setChecked(bool yn=true);
144  void setTriState(bool yn=true);
145  void setCheckState(OD::CheckState);
146  OD::CheckState getCheckState() const;
147 
148  void click();
149 
150 private:
151 
152  uiCheckBoxBody* cbbody_;
153  uiCheckBoxBody& mkbody(uiParent*,const uiString&);
154 
155 };
156 
157 
159 
161 {
162  friend class i_ButMessenger;
163 
164 public:
165 
167  virtual ~uiButtonMessenger() {}
168 
171 
172 protected:
173 
175  virtual void notifyHandler(notifyTp) = 0;
176 
177 };
178 
179 #endif
uiPushButtonBody * pbbody_
Definition: uibutton.h:109
#define mExpClass(module)
Definition: commondefs.h:160
#define mQtclass(cls)
Definition: commondefs.h:229
is the base class for all buttons.
Definition: uibutton.h:83
uiCheckBoxBody * cbbody_
Definition: uibutton.h:152
uiRadioButtonBody * rbbody_
Definition: uibutton.h:128
mFDQtclass(QAbstractButton) class uiMenu
The base class for most UI elements.
Definition: uiobj.h:38
Definition: uistring.h:89
Definition: uiparent.h:26
Definition: i_qbutton.h:26
Definition: callback.h:254
CheckState
State of check objects.
Definition: oduicommon.h:53
void pressed()
Definition: i_qbutton.h:56
StdActionType
Definition: oduicommon.h:61
Definition: uimenu.h:65
uiButtonMessenger()
Definition: uibutton.h:166
Off-screen pixel-based paint device.
Definition: uipixmap.h:34
Definition: uibutton.h:114
Button Abstract Base class.
Definition: uibutton.h:160
void toggled(bool)
Definition: i_qbutton.h:54
void clicked()
Definition: i_qbutton.h:55
bool immediate_
Definition: uibutton.h:108
OpendTect.
Definition: commontypes.h:29
CallBacks object-oriented (object + method).
Definition: callback.h:57
Definition: uibutton.h:134
notifyTp
Button signals emitted by Qt.
Definition: uibutton.h:170
void released()
Definition: i_qbutton.h:57
virtual ~uiButtonMessenger()
Definition: uibutton.h:167

Generated at for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B. V. 2019