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

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