OOFILE  1.9
oofpphier.h
Go to the documentation of this file.
1 // COPYRIGHT 1996 A.D. Software, All rights reserved
2 
3 // Public interface of PowerPlant Integration layer of OOFILE database
4 
5 #ifndef H_OOFPowerPlantHier
6 #define H_OOFPowerPlantHier
7 
8 // PowerPlant Integration layer of OOFILE database - Hierarchical tables
9 
10 // NOTE inline definitions included at end of this header file
11 #ifndef H_OOF2
12  #include "oof2.h"
13 #endif
14 #ifndef H_OOFMSG
15  #include "oofmsg.h"
16 #endif
17 #ifndef H_OOFPowerPlant
18  #include "oofpp.h"
19 #endif
20 
21 // include PowerPlant definitions
22 #include <PP_Types.h>
23 #include <LOutlineItem.h>
24 
25 class dbHierBrowseHelper;
26 class dbHierLevel;
27 
28 
36 
37 public:
39 
40 // our data access methods
41  bool selectItemRecord();
42  oidT oid() const;
43  oidT findOIDforData(const void* inDataPtr, UInt32 inDataSize) const;
44  bool isLeaf() const;
45  unsigned short indentLevel() const;
46 
47 // lookups, virtual for future overriding if different views at same level
48  virtual dbView* view() const;
49  virtual dbHierLevel* level() const;
50 
51 protected:
52  void GetDrawContentsFromView(const STableCell& inCell, SOutlineDrawContents& ioDrawContents);
53 
54 // data storage
55 protected:
57 private:
58  oidT mOID; // our link to an object in some view
59  unsigned short mIndentLevel; // needs to know as helper returns different dbViews
60  unsigned long mCacheIndex;
61  bool mIsLeaf;
62 };
63 
64 
70 public:
72  virtual ~dbViewOutlineItem();
73 
74  virtual Boolean CanExpand() const;
75 
76 
77 protected:
78  virtual void ClickCell(
79  const STableCell& inCell,
80  const SMouseDownEvent& inMouseDown);
81 
82  virtual void ExpandSelf();
83  virtual void GetDrawContentsSelf(
84  const STableCell& inCell,
85  SOutlineDrawContents& ioDrawContents);
86 };
87 
88 
89 
97 public:
98  dbHierBrowseHelper(LOutlineTable* inTable=0);
99  virtual ~dbHierBrowseHelper();
100 
101 // abstract overrides
102  virtual bool receiveMsg(OOFmsgT msg, unsigned long senderDefined);
103  virtual dbView* view() const; // topmost view
104  virtual unsigned long highlightedRecNo() const;
105  virtual dbSelection highlightedSelection() const;
106  virtual void highlightNothing() const;
107  virtual void highlightRecNo(unsigned long, bool bSelect=TRUE) const;
108  virtual void updateBrowserSelection() const;
109  virtual void refreshBrowser();
110 
111  void browseViewWithTable(LOutlineTable* inTable);
113  void deleteAllLevels();
114 
115  void appendLevel(dbHierLevel* adoptedLevel);
117 
118  dbHierLevel* level(unsigned short) const;
119  dbHierLevel* lowestLevel() const;
121  bool selectItemRecord();
122  bool itemIsAtBottom(const OOF_mixOutlineItem* theItem) const;
123  unsigned short deepestIndent() const;
124 
125  unsigned long countNestedItemsFromLevel(oidT, unsigned short) const;
126  dbView* viewAtLevel(unsigned short) const;
128 
129  oidT highlightedOID() const;
130 
131 // content cache
132  unsigned long nextCacheIndex();
133  void initCacheRow(unsigned long cacheIndex, fieldNumT numFields);
134  void setCachedContents(unsigned long cacheIndex, fieldNumT fieldNum, char* adoptedStr);
135  const char* getCachedContents(unsigned long cacheIndex, fieldNumT fieldNum);
136  void deleteContentsCache();
137 
138 protected:
139  void IncludeAllBelowItem(unsigned short inIndentLevel, oidT, dbSelection&) const;
140  oidT FirstOIDBelowItem(unsigned short inIndentLevel, oidT inOID) const;
141 
142 // data storage
144  LOutlineTable* mOutlineTable;
145  unsigned long mNextCacheIndex;
147 };
148 
149 
156 public:
157  virtual LOutlineItem* makeItem(oidT inOID, dbHierBrowseHelper* inHelper, unsigned short indentLevel); // overrideable factory
158 };
159 
160 
161 
172 public:
173  dbOutlineItemFactory(fieldNumT leafFieldNum);
174  dbOutlineItemFactory(const dbBool& leafField);
175  virtual LOutlineItem* makeItem(oidT inOID, dbHierBrowseHelper* inHelper, unsigned short indentLevel); // overrideable factory
176 
177 protected:
178  bool IsLeaf(dbHierBrowseHelper*, unsigned short indentLevel);
179 
180 private:
181  fieldNumT mLeafFieldNum;
182  // cached state
183  unsigned short mLastIndentLevel;
184  dbBool* mLastLeafField;
185 };
186 
187 
194  dbHierLevel(const dbHierLevel&) { assert(0); }; // never copy
195 public:
196  dbHierLevel(dbView* adoptedView, OOF_mixOutlineItemFactory* adoptedFactory=0);
197  dbHierLevel(dbView* adoptedView, const dbBool& isLeafField);
198  virtual ~dbHierLevel(); // will subclass to change traversal mechanism
199 
200  virtual unsigned long countNestedItemsFor(oidT)=0;
201  virtual dbTable* selectNestedItemsFor(oidT)=0;
202 
204  virtual dbHierLevel* makeNestedLevel() const;
205 
206  dbView* view() const;
207 
209  LOutlineItem* makeNestedOutlineItem(oidT inOID, dbHierBrowseHelper* inHelper, unsigned short indentLevel); // overrideable factory
211 
212 protected:
213  // data storage
214  dbView* mView; // owned
215  OOF_mixOutlineItemFactory* mItemFactory; // owned but default is this
216 };
217 
218 
224 public:
225  dbHierRelatedLevel(dbView* adoptedView, dbRelRefBase* inTraversalField=0, OOF_mixOutlineItemFactory* adoptedFactory=0);
226  dbHierRelatedLevel(dbView* adoptedView, dbRelRefBase& inTraversalField, OOF_mixOutlineItemFactory* adoptedFactory=0);
227  dbHierRelatedLevel(dbView* adoptedView, dbRelRefBase& inTraversalField, const dbBool& isLeafField);
228  // use default copy ctor, dtor
229 
230  virtual unsigned long countNestedItemsFor(oidT);
232 
233 protected:
234  // data storage
235  dbRelRefBase* mTraversalField; // in the adoptedView's table
236 };
237 
238 
246 public:
247  dbHierRecursiveRelatedLevel(dbView* adoptedView, dbRelRefBase* inTraversalField, OOF_mixOutlineItemFactory* adoptedFactory=0);
248  dbHierRecursiveRelatedLevel(dbView* adoptedView, dbRelRefBase& inTraversalField, OOF_mixOutlineItemFactory* adoptedFactory=0);
249  dbHierRecursiveRelatedLevel(dbView* adoptedView, dbRelRefBase& inTraversalField, const dbBool& isLeafField);
250  // use default copy ctor, dtor
251 
252  virtual dbHierLevel* makeNestedLevel() const;
253 };
254 
255 
256 // -------------------------------------------------------
257 // d b H i e r B r o w s e H e l p e r
258 // -------------------------------------------------------
259 inline dbHierBrowseHelper&
261 {
262  appendLevel(adoptedLevel);
263  return *this;
264 }
265 
266 
267 inline dbHierLevel*
268 dbHierBrowseHelper::level(unsigned short inLevel) const
269 {
270  dbHierLevel* ret = (dbHierLevel*) mHierLevels.value(inLevel); // safe downcast
271  return ret;
272 }
273 
274 
275 inline dbHierLevel*
277 {
278  dbHierLevel* ret = (dbHierLevel*) mHierLevels.value(mHierLevels.count()-1); // safe downcast
279  return ret;
280 }
281 
282 
283 inline bool
285 {
286 // this assumes a model where we have a fixed number of levels
287 // some dbHierLevel types may allow infinite nesting, so the following is
288 // only true in terms of the levels recursed to so far
289  bool ret = theItem->indentLevel()==mHierLevels.count()-1;
290  return ret;
291 }
292 
293 
294 inline unsigned short
296 {
297  return mHierLevels.count()-1;
298 }
299 
300 
301 // -------------------------------------------------------
302 // d b H i e r L e v e l
303 // -------------------------------------------------------
304 inline dbView*
306 {
307  return mView;
308 }
309 
310 
311 // -------------------------------------------------------
312 // O O F _ m i x O u t l i n e I t e m
313 // -------------------------------------------------------
314 inline bool
316 {
317  return mIsLeaf;
318 }
319 
320 
321 inline oidT
323 {
324  return mOID;
325 }
326 
327 
328 inline unsigned short
330 {
331  return mIndentLevel;
332 }
333 #endif
334 
OOF_mixOutlineItem * highlightedItem() const
Definition: oofpphier.cpp:627
messaging layer of OOFILE application development framework.
unsigned long nextCacheIndex()
Definition: oofpphier.cpp:325
virtual dbTable * selectNestedItemsFor(oidT)=0
void GetDrawContentsFromView(const STableCell &inCell, SOutlineDrawContents &ioDrawContents)
Definition: oofpphier.cpp:153
unsigned long countNestedItemsFromLevel(oidT, unsigned short) const
Definition: oofpphier.cpp:414
Link a dbView to one specific level in a tree control.
Definition: oofpphier.h:69
void initCacheRow(unsigned long cacheIndex, fieldNumT numFields)
Definition: oofpphier.cpp:355
dbView * mView
Definition: oofpphier.h:214
virtual dbSelection highlightedSelection() const
virtual void ClickCell(const STableCell &inCell, const SMouseDownEvent &inMouseDown)
Definition: oofpphier.cpp:77
Envelope class to contain an abstract selection apart from its dbTable.
Definition: oof1.h:316
unsigned short deepestIndent() const
Definition: oofpphier.h:295
unsigned short indentLevel() const
Definition: oofpphier.h:329
dbHierBrowseHelper & operator<<(dbHierLevel *)
Definition: oofpphier.h:260
unsigned long count() const
Definition: oofarray.h:126
Abstract for factory making recursive levels.
Definition: oofpphier.h:193
dbOutlineItemFactory(fieldNumT leafFieldNum)
virtual dbHierLevel * makeNestedLevel() const
factory for recursive levels, may return 0 if unable to recurse
virtual bool receiveMsg(OOFmsgT msg, unsigned long senderDefined)
The default receiveMsg behaviour is to delete yourself when the broadcaster closes.
bool itemIsAtBottom(const OOF_mixOutlineItem *theItem) const
Definition: oofpphier.h:284
dbHierLevel * lowestLevel() const
Definition: oofpphier.h:276
LOutlineItem * makeNestedOutlineItem(oidT inOID, dbHierBrowseHelper *inHelper, unsigned short indentLevel)
methods for making outline items, or changing the factory used to make them
virtual void highlightRecNo(unsigned long, bool bSelect=TRUE) const
virtual ~dbHierLevel()
OOF_mixOutlineItem(oidT, dbHierBrowseHelper *, unsigned short indentLevel, bool isLeaf)
Definition: oofpphier.cpp:114
virtual ~dbHierBrowseHelper()
Definition: oofpphier.cpp:241
dbHelper for managing lists of records.
Definition: oofgui.h:372
Create LOutlineItem's for each item displayed in tree control.
Definition: oofpphier.h:171
Parent for any field that is a relationship to another table.
Definition: oofrel.h:19
Public interface of PowerPlant Integration layer of OOFILE database.
void setCachedContents(unsigned long cacheIndex, fieldNumT fieldNum, char *adoptedStr)
Definition: oofpphier.cpp:379
oidT findOIDforData(const void *inDataPtr, UInt32 inDataSize) const
Definition: oofpphier.cpp:193
dbHierBrowseHelper(LOutlineTable *inTable=0)
Definition: oofpphier.cpp:232
Provide an iterable set of fields.
Definition: oofview.h:26
void deleteContentsCache()
Definition: oofpphier.cpp:335
void appendLevel(dbHierLevel *adoptedLevel)
Definition: oofpphier.cpp:397
virtual void insertItemsBelow(LOutlineItem *, OOF_mixOutlineItem *)
Definition: oofpphier.cpp:434
virtual dbHierLevel * level() const
Definition: oofpphier.cpp:131
void IncludeAllBelowItem(unsigned short inIndentLevel, oidT, dbSelection &) const
Definition: oofpphier.cpp:565
virtual unsigned long countNestedItemsFor(oidT)=0
oidT highlightedOID() const
Definition: oofpphier.cpp:484
unsigned long oidT
type we pass around pretending we have a real OID.
Definition: oof1.h:229
dbHierLevel * level(unsigned short) const
Definition: oofpphier.h:268
Mixin for factories that make LOutlineItem's.
Definition: oofpphier.h:155
virtual ~dbViewOutlineItem()
Definition: oofpphier.cpp:46
virtual dbView * view() const
Definition: oofpphier.cpp:124
dbViewOutlineItem(oidT, dbHierBrowseHelper *, unsigned short indentLevel, bool isLeaf)
Definition: oofpphier.cpp:40
Manage a tree control linked to one or more dbView's.
Definition: oofpphier.h:96
virtual void ExpandSelf()
Definition: oofpphier.cpp:60
const char * getCachedContents(unsigned long cacheIndex, fieldNumT fieldNum)
Definition: oofpphier.cpp:368
Array of longs which expands automatically as you write to cells.
Definition: oofarray.h:21
bool isLeaf() const
Definition: oofpphier.h:315
Persistent field used to store a boolean.
Definition: oof4.h:367
unsigned short fieldNumT
Definition: oof1.h:276
LOutlineTable * mOutlineTable
Definition: oofpphier.h:144
Base class for persistent tables.
Definition: oof1.h:452
PowerPlant base class for managing an item in a hierarchical tree.
dbView * viewAtLevel(unsigned short) const
Definition: oofpphier.cpp:424
OOF_ExpandableLongArray mContentsCache
Definition: oofpphier.h:146
virtual void updateBrowserSelection() const
Map LOutlineItem to specific record.
Definition: oofpphier.h:35
bool IsLeaf(dbHierBrowseHelper *, unsigned short indentLevel)
void resetTableAfterViewRestructure()
Definition: oofpphier.cpp:284
oidT FirstOIDBelowItem(unsigned short inIndentLevel, oidT inOID) const
Definition: oofpphier.cpp:594
void setAlternateItemFactory(OOF_mixOutlineItemFactory *adoptedFactory)
unsigned long mNextCacheIndex
Definition: oofpphier.h:145
virtual void GetDrawContentsSelf(const STableCell &inCell, SOutlineDrawContents &ioDrawContents)
Definition: oofpphier.cpp:67
OOF_ExpandableLongArray mHierLevels
Definition: oofpphier.h:143
void browseViewWithTable(LOutlineTable *inTable)
Definition: oofpphier.cpp:389
unsigned long OOFmsgT
Definition: oofmsg.h:31
virtual LOutlineItem * makeItem(oidT inOID, dbHierBrowseHelper *inHelper, unsigned short indentLevel)
virtual Boolean CanExpand() const
Definition: oofpphier.cpp:52
dbView * view() const
Definition: oofpphier.h:305
virtual void highlightNothing() const
virtual unsigned long highlightedRecNo() const
oidT oid() const
Definition: oofpphier.h:322
OOF_mixOutlineItemFactory * mItemFactory
Definition: oofpphier.h:215
virtual void refreshBrowser()
Definition: oofpphier.cpp:316
virtual dbView * view() const
virtual LOutlineItem * makeItem(oidT inOID, dbHierBrowseHelper *inHelper, unsigned short indentLevel)
unsigned long value(unsigned long index) const
Definition: oofarray.cpp:243
dbHierBrowseHelper * mHelper
Definition: oofpphier.h:56