2 * $XConsortium: OutlineElement.hh /main/4 1996/08/30 17:21:04 drk $
4 * Copyright (c) 1992 HaL Computer Systems, Inc. All rights reserved.
5 * UNPUBLISHED -- rights reserved under the Copyright Laws of the United
6 * States. Use of a copyright notice is precautionary only and does not
7 * imply publication or disclosure.
9 * This software contains confidential information and trade secrets of HaL
10 * Computer Systems, Inc. Use, disclosure, or reproduction is prohibited
11 * without the prior express written permission of HaL Computer Systems, Inc.
13 * RESTRICTED RIGHTS LEGEND
14 * Use, duplication, or disclosure by the Government is subject to
15 * restrictions as set forth in subparagraph (c)(l)(ii) of the Rights in
16 * Technical Data and Computer Software clause at DFARS 252.227-7013.
17 * HaL Computer Systems, Inc.
18 * 1315 Dell Avenue, Campbell, CA 95008
24 class OutlineElement : public FolioObject
26 friend class OutlineList;
29 DEF_CLASS (OutlineElement);
31 OutlineElement (OutlineList *children = NULL)
32 : f_children (children),
33 f_xm_string (NULL), f_children_flag (0),
34 f_string_creator (0), f_display_flag (1),
36 { children_valid ((children != NULL) ? TRUE : FALSE); }
40 inline bool has_children();
42 virtual OutlineList *children()
43 { return (f_children); }
44 virtual void set_children (OutlineList *children)
45 { f_children = children;
46 children_valid (TRUE); }
48 bool children_cached()
49 { return (children_valid()); }
51 virtual void display() = 0;
55 void level (unsigned char level)
58 bool is_selected (BitHandle handle)
59 { return f_selected.is_set (handle); }
61 void set_selected (BitHandle handle)
62 { f_selected.set (handle) ; }
64 void unset_selected (BitHandle handle)
65 { f_selected.unset (handle); }
67 bool is_expanded (BitHandle handle)
68 { return f_expanded.is_set (handle); }
70 bool is_contracted (BitHandle handle)
71 { return !f_expanded.is_set (handle) ; }
73 void set_expanded (BitHandle handle)
74 { f_expanded.set (handle); }
76 void set_contracted (BitHandle handle)
77 { f_expanded.unset (handle); }
79 void set_xm_string (void *xm_string)
80 { f_xm_string = xm_string; }
82 { return (f_xm_string); }
84 void string_creator (u_int creator_id)
85 { f_string_creator = creator_id; }
86 u_int string_creator()
87 { return (f_string_creator); }
93 unsigned char display_flag()
94 { return (f_display_flag); }
95 void display_flag (unsigned char flag)
96 { f_display_flag = flag; }
98 protected: // functions
100 { return ((f_children_flag & CHILDREN_VALID_BIT) != 0); }
101 void children_valid (bool setting)
102 { f_children_flag = (setting ? f_children_flag | CHILDREN_VALID_BIT :
103 f_children_flag & ~CHILDREN_VALID_BIT);
105 bool has_children_valid()
106 { return ((f_children_flag & HAS_CHILDREN_VALID_BIT) != 0); }
107 void has_children_valid (bool setting)
108 { f_children_flag = (setting ? f_children_flag | HAS_CHILDREN_VALID_BIT :
109 f_children_flag & ~HAS_CHILDREN_VALID_BIT);
111 virtual bool has_children_internal()
112 { return (children() != NULL); }
113 void has_children (bool setting)
114 { f_children_flag = (setting ? f_children_flag | HAS_CHILDREN_BIT :
115 f_children_flag & ~HAS_CHILDREN_BIT);
118 protected: // variables
119 OutlineList *f_children; // Each outline element may have a list of children
121 BitField f_selected ;
122 BitField f_expanded ;
124 // NOTE: xm_string temporary until R2
126 unsigned char f_children_flag;
127 enum { CHILDREN_VALID_BIT = 0x01,
128 HAS_CHILDREN_VALID_BIT = 0x02, HAS_CHILDREN_BIT = 0x04 };
129 u_int f_string_creator;
131 unsigned char f_display_flag; // Able to be displayed on activate [rtp]
132 unsigned char f_level; // Level this element is at, zero-based
137 OutlineElement::has_children()
139 // Only calculate value of has_children once since it might be expensive.
140 if (!has_children_valid())
142 has_children (has_children_internal());
143 has_children_valid (TRUE);
146 return ((f_children_flag & HAS_CHILDREN_BIT) != 0);