OpendTect-6_4  6.4
i_layoutitem.h
Go to the documentation of this file.
1 #ifndef i_layoutitem_h
2 #define i_layoutitem_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: 29/06/2001
10  RCS: $Id$
11 ________________________________________________________________________
12 
13 -*/
14 
15 #include "uibasemod.h"
16 #include "i_layout.h"
17 #include "uiobjbody.h"
18 
19 #include <QSize>
20 #include <QWidget>
21 
22 mFDQtclass(QLayoutItem)
23 
24 mExpClass(uiBase) i_LayoutItem : public uiBody, public NamedObject
26 {
27  friend class i_LayoutMngr;
28  friend class i_LayoutIterator;
29 #ifdef __debug__
30  friend class uiGroupParentBody;
31 #endif
32 
33 public:
34  i_LayoutItem(i_LayoutMngr&,
35  mQtclass(QLayoutItem&));
36  virtual ~i_LayoutItem();
37 
38  virtual int horAlign(LayoutMode m ) const
39  { return curpos(m).left(); }
40  virtual int centre(LayoutMode m, bool hor=true) const
41  {
42  if( hor ) return ( curpos(m).left()
43  + curpos(m).right() ) / 2;
44  return ( curpos(m).top()
45  + curpos(m).bottom() ) / 2;
46  }
47 
48  virtual uiSize minimumsize() const
49  {
50  mQtclass(QSize) s =qwidget()->minimumSize();
51 
52  return
53  uiSize( s.width(), s.height());
54  }
55 
56  uiSize prefSize() const
57  {
58  if( prefSzDone )
59  { pErrMsg("PrefSize already done.");}
60  else
61  {
62  i_LayoutItem* self =
63  const_cast<i_LayoutItem*>(this);
64  self->prefSzDone = true;
65  mQtclass(QSize) ps( qlayoutItm().sizeHint() );
66  int width = ps.width();
67  if ( width==0 ) width = 1;
68  int height = ps.height();
69  if ( height==0 ) height = 1;
70  self->prefSz =
71  uiSize(width,height);
72  }
73 
74  return prefSz;
75  }
76 
77  virtual void invalidate();
78  virtual void updatedAlignment(LayoutMode) {}
79  virtual void initChildLayout(LayoutMode) {}
80 
81  uiSize actualsize(bool include_border = true) const;
83 
84  inline const i_LayoutMngr& mngr() const { return mngr_; }
85 
86  inline const uiRect& curpos(LayoutMode m) const
87  { return layoutpos[m];}
88  inline uiRect& curpos(LayoutMode m) { return layoutpos[m];}
89 
90  bool inited() const
91  {
92  return minimum_pos_inited
93  || preferred_pos_inited;
94  }
95 
96 protected:
97 
98  bool preferred_pos_inited;
99  bool minimum_pos_inited;
100 
101  uiRect layoutpos[ nLayoutMode ];
102 
103  int stretch( bool hor ) const;
104  virtual void commitGeometrySet(bool);
105 
106  void initLayout( LayoutMode m, int mngrTop,
107  int mngrLeft );
108  bool layout( LayoutMode m, const int, bool );
109 
110  void attach( constraintType,
111  i_LayoutItem *other, int margin,
112  bool reciprocal=true);
113 
114  virtual uiObject* objLayouted() { return 0; }
115  inline const uiObject* objLayouted() const
116  {
117  return const_cast<i_LayoutItem*>
118  (this)->objLayouted();
119  }
120 
121  virtual uiObjectBody* bodyLayouted() { return 0; }
122  inline const uiObjectBody* bodyLayouted() const
123  {
124  return const_cast<i_LayoutItem*>
125  (this)->bodyLayouted();
126  }
127 
128  inline mQtclass(QLayoutItem&) qlayoutItm() { return *qlayoutitm; }
129  inline const mQtclass(QLayoutItem&) qlayoutItm() const
130  { return *qlayoutitm; }
131 
132  // Immediately delete me if you take my
133  // qlayoutitm !!
134  inline mQtclass(QLayoutItem*) takeQlayoutItm()
135  {
136  mQtclass(QLayoutItem*) ret = qlayoutitm;
137  qlayoutitm = 0;
138  return ret;
139  }
140 
141  virtual const mQtclass(QWidget*) qwidget_() const
142  { return qlayoutitm->widget(); }
143  virtual const mQtclass(QWidget*) managewidg_() const
144  { return qlayoutitm->widget(); }
145 
146  inline i_LayoutMngr& mngr() { return mngr_; }
147 
148  bool isAligned() const;
149 
150 private:
151 
152  mQtclass(QLayoutItem*) qlayoutitm;
153  i_LayoutMngr& mngr_;
154 
155  constraintList constrList;
156 
157 #ifdef __debug__
158  int isPosOk( uiConstraint*, int, bool );
159 #endif
160  bool prefSzDone;
161  uiSize prefSz;
162  bool hsameas;
163  bool vsameas;
164 };
165 
166 
168 mExpClass(uiBase) i_uiLayoutItem : public i_LayoutItem
169 {
170 public:
171  i_uiLayoutItem( i_LayoutMngr& mgr, uiObjectBody& obj )
172  : i_LayoutItem(mgr,
173  *new mQtclass(QWidgetItem)(obj.qwidget()) )
174  , uiObjBody_(obj) {}
175 
176  virtual ~i_uiLayoutItem();
177 
178  virtual uiSize minimumsize() const
179  {
180  uiSize s = uiObjBody_.minimumsize();
181  if ( !mIsUdf(s.hNrPics()) )
182  return s;
183 
184  return i_LayoutItem::minimumsize();
185  }
186 
187  virtual uiObject* objLayouted() { return &uiObjBody_.uiObjHandle(); }
188  virtual uiObjectBody* bodyLayouted(){ return &uiObjBody_; }
189 
190 
191 protected:
192 
193  uiObjectBody& uiObjBody_;
194 
195 
196 };
197 
198 #endif
#define mExpClass(module)
Definition: commondefs.h:160
#define mIsUdf(val)
Use mIsUdf to check for undefinedness of simple types.
Definition: undefval.h:287
Definition: uilayout.h:39
virtual uiObject * objLayouted()
Definition: i_layoutitem.h:187
Definition: uigeom.h:42
#define mQtclass(cls)
Definition: commondefs.h:229
Wrapper around QLayoutItem class. Stores some dGB specific layout info.
Definition: i_layoutitem.h:168
uiObjectBody & uiObjBody_
Definition: i_layoutitem.h:193
if(!noudf_ &&(mIsUdf(inpval)))
Definition: arrayndalgo.h:1662
Definition: i_layout.h:28
The base class for most UI elements.
Definition: uiobj.h:38
virtual uiSize minimumsize() const
Definition: i_layoutitem.h:178
Definition: uigeom.h:25
virtual const QWidget * qwidget_() const
Definition: i_uiobjqtbody.h:28
Set of (small) copyable elements.
Definition: commontypes.h:30
i_uiLayoutItem(i_LayoutMngr &mgr, uiObjectBody &obj)
Definition: i_layoutitem.h:171
LayoutMode
Definition: i_layout.h:35
virtual uiObjectBody * bodyLayouted()
Definition: i_layoutitem.h:188
#define mFDQtclass(cls)
Definition: commondefs.h:228
Object with a name.
Definition: namedobj.h:35
constraintType
Definition: uilayout.h:19
const int nLayoutMode
Definition: i_layout.h:37
int hNrPics() const
Definition: uigeom.h:33
#define pErrMsg(msg)
Definition: errmsg.h:60
dGB&#39;s layout manager
Definition: i_layout.h:70
Definition: i_layout.h:28

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