00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #if defined( Uses_TOutlineViewer ) && !defined( __TOutlineViewer )
00013 #define __TOutlineViewer
00014
00019 const int
00020 ovExpanded = 0x01,
00021 ovChildren = 0x02,
00022 ovLast = 0x04;
00023
00024 const int
00025 cmOutlineItemSelected = 301;
00026
00033 class TNode
00034 {
00035 public:
00039 inline TNode(char* aText);
00045 inline TNode(char* aText, TNode* aChildren, TNode* aNext,
00046 Boolean initialState = True);
00050 virtual ~TNode();
00055 TNode* next;
00060 char* text;
00065 TNode* childList;
00070 Boolean expanded;
00071 };
00072
00073 inline TNode::TNode(char* aText) :
00074 next(0), text(newStr(aText)), childList(0), expanded(True)
00075 {
00076 }
00077
00078 inline TNode::TNode( char* aText, TNode* aChildren,
00079 TNode* aNext, Boolean initialState ) :
00080 next(aNext), text(newStr(aText)),
00081 childList(aChildren), expanded(initialState)
00082 {
00083 }
00084
00085 inline TNode::~TNode() {
00086 delete [] text;
00087 }
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099 class TRect;
00100 class TScrollBar;
00101 class TEvent;
00102
00112 class TOutlineViewer : public TScroller
00113 {
00114 public:
00121 TOutlineViewer(const TRect& bounds, TScrollBar* aHScrollBar,
00122 TScrollBar* aVScrollBar);
00129 TOutlineViewer(StreamableInit s);
00137 virtual void adjust(TNode* node, Boolean expand)=0;
00145 virtual void draw();
00151 virtual void focused(int i);
00160 virtual TNode* getChild(TNode* node, int i)=0;
00170 virtual char* getGraph(int level, long lines, ushort flags);
00177 virtual int getNumChildren(TNode* node)=0;
00182 virtual TNode* getNode(int i);
00186 virtual TPalette& getPalette() const;
00191 virtual TNode* getRoot()=0;
00196 virtual char* getText(TNode* node)=0;
00203 virtual void handleEvent(TEvent& event);
00215 virtual Boolean hasChildren(TNode* node)=0;
00222 virtual Boolean isExpanded(TNode* node)=0;
00229 virtual Boolean isSelected(int i);
00237 virtual void selected(int i);
00245 virtual void setState(ushort aState, Boolean enable);
00260 void update();
00266 void expandAll(TNode* node);
00279 TNode* firstThat(Boolean (*test)(TOutlineViewer* ov, TNode* node,
00280 int level, int position, long lines, ushort flags));
00316 TNode* forEach(Boolean (*action)(TOutlineViewer* ov, TNode* cur, int level,
00317 int position, long lines, ushort flags));
00321 char* createGraph(int level, long lines, ushort flags, int levWidth,
00322 int endWidth, const char* chars);
00326 int foc;
00330 static const char* graphChars;
00331 protected:
00335 static void disposeNode(TNode* node);
00339 virtual void write( opstream& os );
00343 virtual void *read( ipstream& is );
00344 public:
00348 static TStreamable *build();
00352 static const char * const name;
00353 private:
00354 void adjustFocus(int newFocus);
00355 TNode* iterate(Boolean (*action)(TOutlineViewer*, TNode*, int, int, long,
00356 ushort), Boolean checkResult);
00357 };
00358
00359 inline TOutlineViewer::TOutlineViewer( StreamableInit s) :
00360 TScroller(s)
00361 {
00362 }
00363
00364 #endif // Uses_TOutlineViewer
00365
00366 #if defined( Uses_TOutline ) && !defined( __TOutline )
00367 #define __TOutline
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379 class TRect;
00380 class TScrollBar;
00381 class TEvent;
00382
00392 class TOutline : public TOutlineViewer
00393 {
00394 public:
00402 TOutline(const TRect& bounds, TScrollBar* aHScrollBar,
00403 TScrollBar* aVScrollBar, TNode* aRoot);
00409 ~TOutline();
00415 virtual void adjust(TNode* node, Boolean expand);
00420 virtual TNode* getRoot();
00425 virtual int getNumChildren(TNode* node);
00429 virtual TNode* getChild(TNode* node, int i);
00433 virtual char* getText(TNode* node);
00437 virtual Boolean isExpanded(TNode* node);
00442 virtual Boolean hasChildren(TNode* node);
00446 TNode* root;
00447 protected:
00451 virtual void write( opstream& os );
00455 virtual void *read( ipstream& is );
00459 virtual void writeNode( TNode*, opstream& );
00463 virtual TNode* readNode( ipstream& );
00470 TOutline( StreamableInit );
00471 public:
00475 static TStreamable* build();
00479 static const char* const name;
00480 private:
00481 virtual const char *streamableName() const
00482 { return name; }
00483 };
00484
00485 inline TOutline::TOutline( StreamableInit s ) : TOutlineViewer( s )
00486 {
00487 }
00488
00492 inline ipstream& operator >> ( ipstream& is, TOutline& o )
00493 { return is >> (TStreamable&)o; }
00497 inline ipstream& operator >> ( ipstream& is, TOutline*& o )
00498 { return is >> (void *&)o; }
00499
00503 inline opstream& operator << ( opstream& os, TOutline& o )
00504 { return os << (TStreamable&)o; }
00508 inline opstream& operator << ( opstream& os, TOutline* o )
00509 { return os << (TStreamable*)o; }
00510
00511 #endif // Uses_TOutline