ScummVM API documentation
tree_item.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef ULTIMA_SHARED_CORE_TREE_ITEM_H
23 #define ULTIMA_SHARED_CORE_TREE_ITEM_H
24 
25 #include "ultima/shared/core/message_target.h"
26 
27 namespace Ultima {
28 namespace Shared {
29 
30 namespace Gfx {
31 class VisualItem;
32 } // End of namespace Gfx
33 
34 namespace Maps {
35 class Map;
36 } // End of namespace Maps
37 
38 class Game;
39 class GameManager;
40 class GameState;
41 class Events;
42 class Map;
43 class NamedItem;
44 class CMessage;
45 
50 class TreeItem: public MessageTarget {
51  friend class CMessage;
52  DECLARE_MESSAGE_MAP;
53 private:
54  TreeItem *_parent;
55  TreeItem *_nextSibling;
56  TreeItem *_priorSibling;
57  TreeItem *_firstChild;
58  DisposeAfterUse::Flag _disposeAfterUse;
59 public:
60  CLASSDEF;
61  TreeItem();
62 
66  virtual const Common::String getName() const {
67  return Common::String();
68  }
69 
73  virtual bool isEquals(const Common::String &name, int maxLen = 0) const {
74  return false;
75  }
76 
80  virtual int compareTo(const Common::String &name, int maxLen = 0) const {
81  return false;
82  }
83 
87  virtual void viewChange() {
88  }
89 
93  TreeItem *getParent() const {
94  return _parent;
95  }
96 
100  Game *getGame();
101 
105  const Game *getGame() const;
106 
110  Gfx::VisualItem *getView();
111 
116  return _nextSibling;
117  }
118 
123  return _priorSibling;
124  }
125 
129  TreeItem *getLastSibling();
130 
135  return _firstChild;
136  }
137 
141  TreeItem *getLastChild() const;
142 
147  TreeItem *scan(TreeItem *item) const;
148 
152  TreeItem *findChildInstanceOf(const ClassDef &classDef) const;
153 
157  TreeItem *findNextInstanceOf(const ClassDef &classDef, TreeItem *startItem) const;
158 
162  void addUnder(TreeItem *newParent);
163 
167  void addChild(TreeItem *child);
168 
172  void setParent(TreeItem *newParent);
173 
177  void addSibling(TreeItem *item);
178 
182  void moveUnder(TreeItem *newParent);
183 
187  void destroyAll();
188 
193  int destroyChildren();
194 
198  void detach();
199 
203  void attach(TreeItem *item);
204 
209  NamedItem *findByName(const Common::String &name);
210 };
211 
212 } // End of namespace Shared
213 } // End of namespace Ultima
214 
215 #endif
Definition: str.h:59
Definition: messages.h:87
Definition: game.h:42
TreeItem * getFirstChild() const
Definition: tree_item.h:134
Definition: message_target.h:97
Definition: tree_item.h:50
Definition: visual_item.h:39
TreeItem * getPriorSibling() const
Definition: tree_item.h:122
virtual void viewChange()
Definition: tree_item.h:87
Definition: detection.h:27
virtual int compareTo(const Common::String &name, int maxLen=0) const
Definition: tree_item.h:80
virtual bool isEquals(const Common::String &name, int maxLen=0) const
Definition: tree_item.h:73
Definition: base_object.h:43
virtual const Common::String getName() const
Definition: tree_item.h:66
TreeItem * getNextSibling() const
Definition: tree_item.h:115
Definition: named_item.h:33
TreeItem * getParent() const
Definition: tree_item.h:93