OpendTect  6.3
uitreeitem.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: Kristofer Tingdahl
8  Date: 4-11-2002
9 ________________________________________________________________________
10 
11 
12 -*/
13 
14 #include "uitoolsmod.h"
15 #include "sets.h"
16 #include "iopar.h"
17 #include "notify.h"
18 #include "bufstring.h"
19 #include "task.h"
20 #include "thread.h"
21 
22 class uiTreeViewItem;
23 class uiTreeView;
24 class uiParent;
25 namespace ColTab { class Sequence; }
26 
27 
34 mExpClass(uiTools) uiTreeItem : public CallBacker
36 public:
37  uiTreeItem(const uiString& nm=
39  virtual ~uiTreeItem();
40  virtual void prepareForShutdown();
44  virtual bool askContinueAndSaveIfNeeded(bool withcancel);
45  void setName( const uiString& nm ) { name_ = nm; }
46  uiString name() const;
47 
48  bool areAllParentsChecked();
49 
50  void entryInEditMode(int col);
51 
52  virtual int selectionKey() const { return -1; }
53  virtual bool select();
55  virtual bool isSelected() const;
56  void setChecked(bool yn,bool trigger=false);
57  virtual bool isChecked() const;
58  NotifierAccess* checkStatusChange();
59  NotifierAccess* keyPressed();
60  void expand();
61  bool isExpanded() const;
62  void collapse();
63  bool isCollapsed() const;
64 
65  bool allChildrenExpanded() const;
66  bool allChildrenCollapsed() const;
67  bool allChildrenChecked() const;
68  bool allChildrenUnchecked() const;
69 
70  virtual int siblingIndex() const;
71  /*\returns the index of this item among
72  its siblings.
73  \note this index is not neseccarely the same
74  as the item's index in the parent's
75  child-list. */
76 
77  virtual uiTreeItem* siblingAbove();
78  virtual uiTreeItem* siblingBelow();
79  virtual void moveItem(uiTreeItem* after);
80  virtual void moveItemToTop();
81  uiTreeItem* lastChild();
82 
83  int nrChildren() const { return children_.size(); }
84  const uiTreeItem* getChild(int) const;
85  uiTreeItem* getChild(int);
86  ObjectSet<uiTreeItem>& getChildren() { return children_; }
87  const ObjectSet<uiTreeItem>& getChildren() const { return children_; }
88 
89  virtual bool addChild(uiTreeItem* child,bool below);
99  virtual void removeChild(uiTreeItem*);
100  virtual void removeAllChildren();
101 
102  virtual const uiTreeItem* findChild(const char* name) const;
105  virtual const uiTreeItem* findChild(int selkey) const;
108  virtual uiTreeItem* findChild(const char* name);
111  virtual uiTreeItem* findChild(int selkey);
114  virtual void findChildren(const char*,
119  template<class T> inline void setProperty(const char* key,const T&);
128  inline void setPropertyPtr(const char* key,void*);
132  template<class T> inline bool getProperty(const char* key, T& res) const;
145  inline bool getPropertyPtr(const char* key,void*&) const;
154  void updateSelTreeColumnText(int col);
155  virtual void updateColumnText(int col);
156  virtual void updateCheckStatus();
157 
158  virtual void translateText() { updateColumnText( 0 ); }
159  uiTreeViewItem* getItem() { return uitreeviewitem_; }
160  const uiTreeViewItem* getItem() const { return uitreeviewitem_; }
161 
162  void setPixmap(int col,const ColTab::Sequence*);
163 
164 protected:
165 
166  virtual int uiTreeViewItemType() const;
169  virtual uiParent* getUiParent() const;
170 
171  virtual bool addChld(uiTreeItem*,bool below,bool downwards);
183  virtual const char* parentType() const = 0;
185  virtual bool useParentType() const { return true; }
186  virtual bool init() { return true; }
187 
188  virtual bool rightClick(uiTreeViewItem*);
189  virtual bool anyButtonClick(uiTreeViewItem*);
190  virtual bool doubleClick(uiTreeViewItem*);
191  virtual void setTreeViewItem(uiTreeViewItem*);
192  virtual void removeItem(uiTreeViewItem*);
193  virtual void renameItem(uiTreeViewItem*);
194 
195  virtual bool showSubMenu() { return true; }
196  virtual bool selectWithKey(int selkey);
197 
198  virtual bool isSelectable() const { return false; }
199  virtual bool isExpandable() const { return true; }
200 
201  virtual void updateSelection(int selectionKey,
202  bool dw=false );
204  virtual bool shouldSelect(int selectionkey) const;
209 
212 
215  friend class uiTreeTopItem;
216  friend class uiODTreeTop;
217 
218 private:
219 
220  bool addChildImpl(CallBacker*,uiTreeItem*,bool,bool);
221 
222 };
223 
225 {
226 public:
227  uiTreeItemRemover(uiTreeItem* parent,uiTreeItem* child);
228  int nextStep();
229 
230 protected:
233 };
234 
235 
236 
239 public:
240  uiTreeTopItem(uiTreeView*, bool=false );
241  ~uiTreeTopItem();
242 
243  virtual bool addChild(uiTreeItem*,bool below);
244  virtual void updateSelection(int selectionkey, bool=false );
246  virtual void updateColumnText(int col);
247  bool isChecked() const { return true; }
248 
249  void disabRightClick(bool yn) { disabrightclick_=yn; }
250  void disabAnyClick(bool yn) { disabanyclick_=yn; }
251  uiTreeView* getTreeView() const { return listview_; }
252 
253 protected:
254 
255  virtual bool addChld(uiTreeItem*,bool below,bool downwards);
256  virtual void removeItem(uiTreeViewItem*);
257 
258  void selectionChanged(CallBacker*);
259  void rightClickCB(CallBacker*);
260  void anyButtonClickCB(CallBacker*);
261  void doubleClickCB(CallBacker*);
262  void itemRenamed(CallBacker*);
263  void handleSelectionChanged(bool frmbtclk);
264 
265  virtual const char* parentType() const { return 0; }
266  virtual uiParent* getUiParent() const;
267 
272 
273 };
274 
275 
277 {
278 public:
279  virtual ~uiTreeItemFactory() {}
280  virtual const char* name() const = 0;
281  virtual uiTreeItem* create() const = 0;
282 };
283 
284 
286 {
287 public:
289  ~uiTreeFactorySet();
290  void addFactory(uiTreeItemFactory* ptr,
291  int placementindex=-1,
292  int pol2d=1);
301  void remove( const char* );
302 
303  int nrFactories() const;
304  const uiTreeItemFactory* getFactory(int) const;
305  int getPlacementIdx(int) const;
306  int getPol2D(int) const;
307 
310 
311 protected:
312 
316 
317 };
318 
319 
320 template<class T>
321 bool inline uiTreeItem::getProperty( const char* propertykey, T& res ) const
322 {
323  if ( properties_.get( propertykey, res ))
324  return true;
325 
326  return parent_ ? parent_->getProperty( propertykey, res ) : false;
327 }
328 
329 
330 inline bool uiTreeItem::getPropertyPtr(const char* propertykey,void*& res) const
331 {
332  if ( properties_.getPtr( propertykey, res ))
333  return true;
334 
335  return parent_ ? parent_->getPropertyPtr( propertykey, res ) : false;
336 }
337 
338 
339 #include <typeinfo>
340 
341 template<class T>
342 void inline uiTreeItem::setProperty( const char* propertykey, const T& val )
343 {
344  if ( typeid(T)==typeid(void*) )
345  properties_.set( propertykey, (od_int64)val );
346  else
347  properties_.set( propertykey, val );
348 }
349 
350 
351 void inline uiTreeItem::setPropertyPtr( const char* propertykey, void* val )
352 {
353  properties_.setPtr( propertykey, val );
354 }
#define mExpClass(module)
Definition: commondefs.h:157
int nrChildren() const
Definition: uitreeitem.h:83
CNotifier< uiTreeFactorySet, int > removenotifier
Definition: uitreeitem.h:309
Inherit from this class to be able to send and/or receive CallBacks.
Definition: callback.h:182
ObjectSet< uiTreeItem > children_
Definition: uitreeitem.h:214
uiTreeViewItem * uitreeviewitem_
Definition: uitreeitem.h:213
bool getPropertyPtr(const char *key, void *&) const
Definition: uitreeitem.h:330
#define mODTextTranslationClass(clss)
Definition: uistring.h:37
A series of color control points able to give an (interpolated) color for every position [0...
Definition: coltabsequence.h:37
void disabAnyClick(bool yn)
Definition: uitreeitem.h:250
Interface class for Notifier. See comments there.
Definition: notify.h:20
IOPar properties_
Definition: uitreeitem.h:208
#define od_int64
Definition: plftypes.h:34
ObjectSet< uiTreeItemFactory > factories_
Definition: uitreeitem.h:313
virtual int selectionKey() const
Definition: uitreeitem.h:52
static const uiString & emptyString()
Definition: uistring.h:107
Definition: uistring.h:88
Definition: uiparent.h:24
uiTreeItem * child_
Definition: uitreeitem.h:232
bool isChecked() const
Definition: uitreeitem.h:247
TypeSet< int > pol2ds_
Definition: uitreeitem.h:315
virtual bool isExpandable() const
Definition: uitreeitem.h:199
The generalization of something (e.g. a computation) where the steps must be done in sequence...
Definition: task.h:147
virtual bool showSubMenu()
Definition: uitreeitem.h:195
Definition: uitreeview.h:194
void setName(const uiString &nm)
Definition: uitreeitem.h:45
Generalized set of parameters of the keyword-value type.
Definition: iopar.h:53
TypeSet< int > placementidxs_
Definition: uitreeitem.h:314
uiTreeViewItem * getItem()
Definition: uitreeitem.h:159
const uiTreeViewItem * getItem() const
Definition: uitreeitem.h:160
Definition: uitreeitem.h:224
virtual bool init()
Definition: uitreeitem.h:186
Definition: uitreeitem.h:276
bool disabselcngresp_
Definition: uitreeitem.h:271
Definition: uitreeview.h:29
bool getProperty(const char *key, T &res) const
Definition: uitreeitem.h:321
uiString name_
Definition: uitreeitem.h:211
ObjectSet< uiTreeItem > & getChildren()
Definition: uitreeitem.h:86
static uiHor3DInterpol * create(uiParent *)
uiTreeItem * parent_
Definition: uitreeitem.h:210
bool disabrightclick_
Definition: uitreeitem.h:269
Definition: uitreeitem.h:237
uiTreeView * listview_
Definition: uitreeitem.h:268
virtual bool isSelectable() const
Definition: uitreeitem.h:198
Definition: coltab.h:20
void setPropertyPtr(const char *key, void *)
Definition: uitreeitem.h:351
virtual ~uiTreeItemFactory()
Definition: uitreeitem.h:279
Definition: i_layout.h:26
virtual bool useParentType() const
Definition: uitreeitem.h:185
Definition: uitreeitem.h:285
void setProperty(const char *key, const T &)
Definition: uitreeitem.h:342
virtual const char * parentType() const
Definition: uitreeitem.h:265
bool disabanyclick_
Definition: uitreeitem.h:270
const ObjectSet< uiTreeItem > & getChildren() const
Definition: uitreeitem.h:87
uiTreeItem * parent_
Definition: uitreeitem.h:231
are helping classes for uiTreeViews, wich makes it easy to bundle inteligence and data to treeitems...
Definition: uitreeitem.h:34
virtual void translateText()
Definition: uitreeitem.h:158
uiTreeView * getTreeView() const
Definition: uitreeitem.h:251
void disabRightClick(bool yn)
Definition: uitreeitem.h:249
CNotifier< uiTreeFactorySet, int > addnotifier
Definition: uitreeitem.h:308

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