OpendTect-6_4  6.4
uiparentbody.h
Go to the documentation of this file.
1 #ifndef uiparentbody_h
2 #define uiparentbody_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 #include "uiparent.h"
16 #include "uilayout.h"
17 #include "sets.h"
18 #include "uiobj.h"
19 #include "uibody.h"
20 
21 #include "uigroup.h"
22 
23 mClass(uiBase) uiParentBody : public uiBody, public NamedObject
24 {
25 friend class uiObjectBody;
26 public:
27  //uiParentBody( const char* nm = "uiParentBody")
28  uiParentBody( const char* nm )
29  : NamedObject( nm )
30  , finalised_( false )
31  {}
32 
33  virtual ~uiParentBody() { deleteAllChildren(); }
34 
35  virtual void addChild( uiBaseObject& child )
36  {
37  if ( children_.isPresent(&child ) ) return;
38  children_ += &child;
39  child.deleteNotify(mCB(this,uiParentBody,childDel));
40  }
41 
43  void manageChld( uiBaseObject& child, uiObjectBody& b)
44  {
45  addChild( child );
46  manageChld_(child,b);
47  }
48 
49  virtual void attachChild( constraintType tp, uiObject* child,
50  uiObject* other, int margin,
51  bool reciprocal ) =0;
52 
53  const ObjectSet<uiBaseObject>* childList() const { return &children_; }
54 
55  bool finalised() const { return finalised_; }
56  virtual void finalise() { finaliseChildren(); }
57  void finaliseChildren(); // body: uiobj.cc
58  void clearChildren(); // body: uiobj.cc
59 
61  inline const mQtclass(QWidget*) managewidg() const { return managewidg_();}
63  inline mQtclass(QWidget*) managewidg()
64  { return const_cast<mQtclass(QWidget*)>( managewidg_() ); }
65 
66 protected:
68  {
69  //avoid the problems from childDel() removal from
70  //children_
71  ObjectSet<uiBaseObject> childrencopy = children_;
72  children_.erase();
73  deepErase( childrencopy );
74  }
75 
76  void childDel( CallBacker* cb )
77  {
78  uiBaseObject* obj = static_cast<uiBaseObject*>( cb );
79  if ( obj ) children_ -= obj;
80  }
81 
82  virtual const mQtclass(QWidget*) managewidg_() const = 0;
83  virtual void manageChld_(uiBaseObject&,uiObjectBody&) {}
84 
86 
87 private:
88 
89  bool finalised_;
90 };
91 
92 #endif
To be able to send and/or receive CallBacks, inherit from this class.
Definition: callback.h:272
ObjectSet< uiBaseObject > children_
Definition: uiparentbody.h:85
#define mQtclass(cls)
Definition: commondefs.h:229
virtual void addChild(uiBaseObject &child)
Definition: uiparentbody.h:35
void manageChld(uiBaseObject &child, uiObjectBody &b)
child becomes mine.
Definition: uiparentbody.h:43
void deleteAllChildren()
Definition: uiparentbody.h:67
bool finalised() const
Definition: uiparentbody.h:55
The base class for most UI elements.
Definition: uiobj.h:38
virtual ~uiParentBody()
Definition: uiparentbody.h:33
void childDel(CallBacker *cb)
Definition: uiparentbody.h:76
const ObjectSet< uiBaseObject > * childList() const
Definition: uiparentbody.h:53
bool finalised_
Definition: uiparentbody.h:89
virtual void finalise()
Definition: uiparentbody.h:56
#define mCB(obj, clss, fn)
To make your CallBack. Used in many places, especially the UI.
Definition: callback.h:42
virtual void manageChld_(uiBaseObject &, uiObjectBody &)
Definition: uiparentbody.h:83
uiParentBody(const char *nm)
Definition: uiparentbody.h:28
Definition: uiparentbody.h:23
Object with a name.
Definition: namedobj.h:35
constraintType
Definition: uilayout.h:19
virtual void erase()
Definition: objectset.h:84
const mQtclass(QWidget *) managewidg() const
widget to be used as parent for QWidgets
Definition: uiparentbody.h:61
#define mClass(module)
Definition: commondefs.h:164
mQtclass(QWidget *) managewidg()
widget to be used as parent for QWidgets
Definition: uiparentbody.h:63
void deepErase(ObjectSet< T > &os)
empty the ObjectSet deleting all objects pointed to.
Definition: objectset.h:118

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