OpendTect-6_4  6.4
uiobjbody.h
Go to the documentation of this file.
1 #ifndef uiobjbody_h
2 #define uiobjbody_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/06/2001
10  RCS: $Id$
11 ________________________________________________________________________
12 
13 -*/
14 
15 
16 #include "uibasemod.h"
17 #include "uibody.h"
18 #include "uifont.h"
19 #include "uiobj.h"
20 #include "uiparentbody.h"
21 
22 #include "color.h"
23 
24 class i_LayoutItem;
25 class i_LayoutMngr;
26 class uiPixmap;
27 class Timer;
28 
29 mFDQtclass(QCloseEvent)
30 mFDQtclass(QFontMetrics)
31 mFDQtclass(QWidget)
32 
33 #define USE_DISPLAY_TIMER 1
34 
35 mExpClass(uiBase) uiObjectBody : public uiBody, public NamedObject
36 {
37 friend class i_uiLayoutItem;
38 
39 protected:
40  uiObjectBody(uiParent*,const char* nm);
41 public:
42 
43  virtual ~uiObjectBody();
44 
45  void setToolTip(const uiString&);
46 
47  void display(bool yn,bool shrink=false,
48  bool maximized=false);
49  void uisetFocus();
50  bool uihasFocus() const;
51  bool uiCloseOK() { return uiObjHandle().closeOK(); }
52  bool isDisplayed() const { return display_; }
53 
54  Color uibackgroundColor() const;
55  void uisetBackgroundColor(const Color&);
56  void uisetBackgroundPixmap(const uiPixmap&);
57  void uisetTextColor(const Color&);
58  void uisetSensitive(bool yn=true);
59  bool uisensitive() const;
60  bool uivisible() const;
61 
62  int prefHNrPics() const;
63  void setPrefWidth(int);
64  float prefWidthInCharSet() const { return pref_char_width; }
65  void setPrefWidthInChar(float);
66  void setMinimumWidth(int);
67  void setMaximumWidth(int);
68 
69  int prefVNrPics() const;
70  void setPrefHeight(int);
71  float prefHeightInCharSet() const { return pref_char_height; }
72  void setPrefHeightInChar(float);
73  void setMinimumHeight(int);
74  void setMaximumHeight(int);
75 
76  void setStretch(int,int);
77  virtual int stretch(bool,bool retUndef=false) const;
78 
79  virtual int nrTxtLines() const { return -1; }
80 
81  void attach(constraintType,uiObject* other=0,
82  int margin=-1,bool reciprocal=true);
83  void attach(constraintType t,uiParent* other=0,
84  int m=-1,bool r=true)
85  { attach(t,other->mainObject(),m,r ); }
86 
87  void uisetFont(const uiFont&);
88  const uiFont* uifont() const;
89 
90  virtual uiSize actualsize(bool include_border=true) const;
93 
94  virtual uiSize minimumsize() const
95  { return uiSize(mUdf(int),mUdf(int)); }
96 
97  void uisetCaption(const uiString&);
98 
99  virtual void reDraw(bool);
100 
101  virtual uiObject& uiObjHandle() =0;
102 
103  const i_LayoutItem* layoutItem() { return layoutItem_; }
104  i_LayoutItem* mkLayoutItem(i_LayoutMngr&);
105 
106  virtual void finalise();
107  virtual bool finalised() const { return finalised_; }
108 
109  virtual void fontchanged();
110 
111  int fontHeight() const;
112  int fontWidth(bool max=false) const;
113  int fontWidthFor(const uiString&) const;
114  int fontWidthFor(const char*) const;
115 
116  void setHSzPol(uiObject::SzPolicy);
117  void setVSzPol(uiObject::SzPolicy);
118  uiObject::SzPolicy szPol(bool hor=true) const
119  { return hor ? hszpol: vszpol ; }
120 
121  void setShrinkAllowed(bool yn) { allowshrnk = yn; }
122  bool shrinkAllowed() { return allowshrnk; }
123 
124  bool isHidden() { return is_hidden; }
125  bool itemInited() const;
126 
127  void reParent(uiParentBody* pb)
128  { if ( pb ) parent_ = pb; }
129 
130 protected:
131 
132  int hStretch;
133  int vStretch;
134 
135  virtual const mQtclass(QWidget*) managewidg_() const { return qwidget_(); }
136 
137  virtual i_LayoutItem* mkLayoutItem_(i_LayoutMngr& mngr);
138 
139  virtual void finalise_() {}
140 
141  void doDisplay(CallBacker*);
142 
143  void loitemDeleted() { layoutItem_ = 0; }
144 
145 private:
146 
147  i_LayoutItem* layoutItem_;
148  uiParentBody* parent_;
149  const uiFont* font_;
150 
151  bool allowshrnk;
152 
153  bool is_hidden;
154  bool finalised_;
155  bool display_;
156  bool display_maximized;
157 
158  int pref_width_;
159  int pref_height_;
160 
161  int pref_width_set;
162  float pref_char_width;
163  int pref_height_set;
164  float pref_char_height;
165  int pref_width_hint;
166  int pref_height_hint;
167 
168  int fnt_hgt;
169  int fnt_wdt;
170  int fnt_maxwdt;
171  mQtclass(QFontMetrics*) fm;
172 
173  uiObject::SzPolicy hszpol;
174  uiObject::SzPolicy vszpol;
175 
176  void gtFntWdtHgt() const;
177  void getSzHint();
178 
179 #ifdef USE_DISPLAY_TIMER
180  Timer& displaytimer;
181 #endif
182 };
183 
184 
229 template <class C, class T>
230 mClass(uiBase) uiObjBodyImpl : public uiObjectBody, public T
231 {
232 public:
233 
234  uiObjBodyImpl( C& hndle, uiParent* parnt,
235  const char* nm )
236  : uiObjectBody( parnt, nm )
237  , T( parnt && parnt->pbody() ?
238  parnt->pbody()->managewidg() : 0 )
239  , handle_( hndle )
240  {
241  this->setObjectName( nm );
242  }
243 
244 #include "i_uiobjqtbody.h"
245 
246 };
247 
248 #endif
#define mExpClass(module)
Definition: commondefs.h:160
To be able to send and/or receive CallBacks, inherit from this class.
Definition: callback.h:272
C & handle_
Definition: i_uiobjqtbody.h:110
#define mQtclass(cls)
Definition: commondefs.h:229
Wrapper around QLayoutItem class. Stores some dGB specific layout info.
Definition: i_layoutitem.h:168
virtual uiObject & uiObjHandle()
Definition: i_uiobjqtbody.h:52
virtual bool closeOK()
hook. Accepts/denies closing of window.
Definition: uiobj.h:173
Definition: uifont.h:39
bool isHidden(const char *)
The base class for most UI elements.
Definition: uiobj.h:38
virtual uiSize minimumsize() const
Definition: i_layoutitem.h:178
Definition: uistring.h:89
Definition: uiparent.h:26
Default (Template) implementation of uiObjectBody.
Definition: uiobjbody.h:230
Definition: uigeom.h:25
virtual const QWidget * qwidget_() const
Definition: i_uiobjqtbody.h:28
SzPolicy
How should the object&#39;s size behave? Undef : use default. Small : 1 base sz. Medium : 2* base sz + 1...
Definition: uiobj.h:58
#define mUdf(type)
Use this macro to get the undefined for simple types.
Definition: undefval.h:272
#define mFDQtclass(cls)
Definition: commondefs.h:228
uiObjBodyImpl(C &hndle, uiParent *parnt, const char *nm)
Definition: uiobjbody.h:234
Off-screen pixel-based paint device.
Definition: uipixmap.h:34
Definition: uiparentbody.h:23
Object with a name.
Definition: namedobj.h:35
constraintType
Definition: uilayout.h:19
Color is an RGB color object, with a transparancy. The storage is in a 4-byte integer, similar to Qt.
Definition: color.h:26
#define mClass(module)
Definition: commondefs.h:164
Timer class.
Definition: timer.h:25
dGB&#39;s layout manager
Definition: i_layout.h:70

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