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

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