OpendTect  6.3
uiparent.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: 16/05/2001
9 ________________________________________________________________________
10 
11 -*/
12 
13 #include "uibasemod.h"
14 #include "uiobj.h"
15 #include "uilayout.h"
16 
17 class MouseCursor;
18 class uiObjectBody;
19 class uiObject;
20 class uiMainWin;
21 class uiParentBody;
22 
23 
24 mExpClass(uiBase) uiParent : public uiBaseObject
25 {
26 friend class uiParentBody;
27 friend class uiObjectBody;
28 public:
29  uiParent(const char* nm,uiParentBody*);
30 
31  void addChild(uiBaseObject&);
32  void manageChld(uiBaseObject&,uiObjectBody&);
33  void attachChild(constraintType tp,uiObject* child,
34  uiObject* other,int margin,
35  bool reciprocal);
36 
37  const ObjectSet<uiBaseObject>* childList() const;
38 
39  virtual uiMainWin* mainwin() { return 0; }
40 
41  uiObject* mainObject() { return mainobject(); }
42  const uiObject* mainObject() const
43  { return const_cast<uiParent*>(this)->mainobject();}
44 
45  uiParentBody* pbody();
46  const uiParentBody* pbody() const
47  { return const_cast<uiParent*>(this)->pbody(); }
48 
49 
50 #define mIfMO() if ( mainObject() ) mainObject()
51 #define mRetMO(fn,val) return mainObject() ? mainObject()->fn() : val;
52 
53  void attach( constraintType t, int margin=-1 )
54  { mIfMO()->attach(t,margin); }
55  void attach( constraintType t, uiParent* oth, int margin=-1,
56  bool reciprocal=true)
57  { attach(t,oth->mainObject(),margin,reciprocal); }
58  void attach( constraintType t, uiObject* oth, int margin=-1,
59  bool reciprocal=true)
60  { attach_(t,oth,margin,reciprocal); }
61 
62 
63  virtual void display( bool yn, bool shrk=false,
64  bool maximize=false )
65  { finalise(); mIfMO()->display(yn,shrk,maximize); }
66  bool isDisplayed() const { mRetMO(isDisplayed,false); }
67 
68  void setFocus() { mIfMO()->setFocus(); }
69  bool hasFocus() const { mRetMO(hasFocus,false); }
70 
71  void setSensitive(bool yn=true){ mIfMO()->setSensitive(yn); }
72  bool sensitive() const { mRetMO(sensitive,false); }
73 
74  const uiFont* font() const { mRetMO(font,0); }
75  void setFont( const uiFont& f) { mIfMO()->setFont(f); }
76  void setCaption(const uiString& c) { mIfMO()->setCaption(c);}
77  void setCursor(const MouseCursor& c) {mIfMO()->setCursor(c);}
78 
79  uiSize actualsize( bool include_border) const
80  {
81  if ( mainObject() )
82  return mainObject()->actualsize(include_border);
83  return uiSize();
84  }
85 
86  int prefHNrPics() const { mRetMO(prefHNrPics, -1 ); }
87  int prefVNrPics() const { mRetMO(prefVNrPics,-1); }
88  void setPrefHeight( int h ) { mIfMO()->setPrefHeight(h); }
89  void setPrefWidth( int w ) { mIfMO()->setPrefWidth(w); }
90  void setPrefHeightInChar( int h )
91  { mIfMO()->setPrefWidthInChar(h); }
92  void setPrefHeightInChar( float h )
93  { mIfMO()->setPrefHeightInChar(h); }
94  void setPrefWidthInChar( float w )
95  { mIfMO()->setPrefWidthInChar(w); }
96  void setPrefWidthInChar( int w )
97  { mIfMO()->setPrefWidthInChar(w); }
98 
99  virtual void reDraw( bool deep ) { mIfMO()->reDraw( deep ); }
100  void shallowRedraw( CallBacker* =0 ) {reDraw(false);}
101  void deepRedraw( CallBacker* =0 ) {reDraw(true); }
102 
103  void setStretch( int h, int v ){ mIfMO()->setStretch(h,v); }
104 
105  Color backgroundColor() const;
106  Color roBackgroundColor() const;
107  void setBackgroundColor( const Color& c )
108  { mIfMO()->setBackgroundColor(c); }
109 
110  void translateText();
111 
112 protected:
113 
114  virtual void attach_( constraintType t, uiObject* oth, int margin=-1,
115  bool reciprocal=true)
116  { mIfMO()->attach(t,oth,margin,reciprocal); }
117 
118 #undef mIfMO
119 #undef mRetMO
120 
121  virtual uiObject* mainobject() { return 0; }
122 };
void shallowRedraw(CallBacker *=0)
Definition: uiparent.h:100
#define mExpClass(module)
Definition: commondefs.h:157
User interface main window.
Definition: uimainwin.h:34
int prefVNrPics() const
Definition: uiparent.h:87
Inherit from this class to be able to send and/or receive CallBacks.
Definition: callback.h:182
bool sensitive() const
Definition: uiparent.h:72
void attach(constraintType t, int margin=-1)
Definition: uiparent.h:53
Definition of a mouse cursor, can be either a predefined shape (from the enum, or a file...
Definition: mousecursor.h:24
bool hasFocus() const
Definition: uiparent.h:69
Definition: uifont.h:38
const uiParentBody * pbody() const
Definition: uiparent.h:46
The base class for most UI elements.
Definition: uiobj.h:35
Definition: uistring.h:88
Definition: uiparent.h:24
void setBackgroundColor(const Color &c)
Definition: uiparent.h:107
uiSize actualsize(bool include_border) const
Definition: uiparent.h:79
Definition: uigeom.h:23
virtual void attach_(constraintType t, uiObject *oth, int margin=-1, bool reciprocal=true)
Definition: uiparent.h:114
void setFocus()
Definition: uiparent.h:68
void setCaption(const uiString &c)
Definition: uiparent.h:76
#define mRetMO(fn, val)
Definition: uiparent.h:51
virtual void reDraw(bool deep)
Definition: uiparent.h:99
const uiFont * font() const
Definition: uiparent.h:74
void setPrefWidthInChar(int w)
Definition: uiparent.h:96
bool isDisplayed() const
Definition: uiparent.h:66
void setPrefHeightInChar(float h)
Definition: uiparent.h:92
void setPrefHeight(int h)
Definition: uiparent.h:88
void deepRedraw(CallBacker *=0)
Definition: uiparent.h:101
virtual uiMainWin * mainwin()
Definition: uiparent.h:39
void setFont(const uiFont &f)
Definition: uiparent.h:75
Definition: uiparentbody.h:21
void setPrefWidthInChar(float w)
Definition: uiparent.h:94
uiObject * mainObject()
Definition: uiparent.h:41
#define mIfMO()
Definition: uiparent.h:50
void attach(constraintType t, uiParent *oth, int margin=-1, bool reciprocal=true)
Definition: uiparent.h:55
constraintType
Definition: uilayout.h:17
int prefHNrPics() const
Definition: uiparent.h:86
virtual uiObject * mainobject()
Definition: uiparent.h:121
Color is an RGB color object, with a transparancy. The storage is in a 4-byte integer, similar to Qt.
Definition: color.h:24
const uiObject * mainObject() const
Definition: uiparent.h:42
void setPrefWidth(int w)
Definition: uiparent.h:89
void setCursor(const MouseCursor &c)
Definition: uiparent.h:77
void setStretch(int h, int v)
Definition: uiparent.h:103
void attach(constraintType t, uiObject *oth, int margin=-1, bool reciprocal=true)
Definition: uiparent.h:58
void setSensitive(bool yn=true)
Definition: uiparent.h:71
virtual void display(bool yn, bool shrk=false, bool maximize=false)
Definition: uiparent.h:63
void setPrefHeightInChar(int h)
Definition: uiparent.h:90

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