2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
24 * $XConsortium: OutlineElement.hh /main/4 1996/08/30 17:21:04 drk $
26 * Copyright (c) 1992 HaL Computer Systems, Inc. All rights reserved.
27 * UNPUBLISHED -- rights reserved under the Copyright Laws of the United
28 * States. Use of a copyright notice is precautionary only and does not
29 * imply publication or disclosure.
31 * This software contains confidential information and trade secrets of HaL
32 * Computer Systems, Inc. Use, disclosure, or reproduction is prohibited
33 * without the prior express written permission of HaL Computer Systems, Inc.
35 * RESTRICTED RIGHTS LEGEND
36 * Use, duplication, or disclosure by the Government is subject to
37 * restrictions as set forth in subparagraph (c)(l)(ii) of the Rights in
38 * Technical Data and Computer Software clause at DFARS 252.227-7013.
39 * HaL Computer Systems, Inc.
40 * 1315 Dell Avenue, Campbell, CA 95008
46 class OutlineElement : public FolioObject
48 friend class OutlineList;
51 DEF_CLASS (OutlineElement);
53 OutlineElement (OutlineList *children = NULL)
54 : f_children (children),
55 f_xm_string (NULL), f_children_flag (0),
56 f_string_creator (0), f_display_flag (1),
58 { children_valid ((children != NULL) ? TRUE : FALSE); }
62 inline bool has_children();
64 virtual OutlineList *children()
65 { return (f_children); }
66 virtual void set_children (OutlineList *children)
67 { f_children = children;
68 children_valid (TRUE); }
70 bool children_cached()
71 { return (children_valid()); }
73 virtual void display() = 0;
77 void level (unsigned char level)
80 bool is_selected (BitHandle handle)
81 { return f_selected.is_set (handle); }
83 void set_selected (BitHandle handle)
84 { f_selected.set (handle) ; }
86 void unset_selected (BitHandle handle)
87 { f_selected.unset (handle); }
89 bool is_expanded (BitHandle handle)
90 { return f_expanded.is_set (handle); }
92 bool is_contracted (BitHandle handle)
93 { return !f_expanded.is_set (handle) ; }
95 void set_expanded (BitHandle handle)
96 { f_expanded.set (handle); }
98 void set_contracted (BitHandle handle)
99 { f_expanded.unset (handle); }
101 void set_xm_string (void *xm_string)
102 { f_xm_string = xm_string; }
104 { return (f_xm_string); }
106 void string_creator (u_int creator_id)
107 { f_string_creator = creator_id; }
108 u_int string_creator()
109 { return (f_string_creator); }
115 unsigned char display_flag()
116 { return (f_display_flag); }
117 void display_flag (unsigned char flag)
118 { f_display_flag = flag; }
120 protected: // functions
121 bool children_valid()
122 { return ((f_children_flag & CHILDREN_VALID_BIT) != 0); }
123 void children_valid (bool setting)
124 { f_children_flag = (setting ? f_children_flag | CHILDREN_VALID_BIT :
125 f_children_flag & ~CHILDREN_VALID_BIT);
127 bool has_children_valid()
128 { return ((f_children_flag & HAS_CHILDREN_VALID_BIT) != 0); }
129 void has_children_valid (bool setting)
130 { f_children_flag = (setting ? f_children_flag | HAS_CHILDREN_VALID_BIT :
131 f_children_flag & ~HAS_CHILDREN_VALID_BIT);
133 virtual bool has_children_internal()
134 { return (children() != NULL); }
135 void has_children (bool setting)
136 { f_children_flag = (setting ? f_children_flag | HAS_CHILDREN_BIT :
137 f_children_flag & ~HAS_CHILDREN_BIT);
140 protected: // variables
141 OutlineList *f_children; // Each outline element may have a list of children
143 BitField f_selected ;
144 BitField f_expanded ;
146 // NOTE: xm_string temporary until R2
148 unsigned char f_children_flag;
149 enum { CHILDREN_VALID_BIT = 0x01,
150 HAS_CHILDREN_VALID_BIT = 0x02, HAS_CHILDREN_BIT = 0x04 };
151 u_int f_string_creator;
153 unsigned char f_display_flag; // Able to be displayed on activate [rtp]
154 unsigned char f_level; // Level this element is at, zero-based
159 OutlineElement::has_children()
161 // Only calculate value of has_children once since it might be expensive.
162 if (!has_children_valid())
164 has_children (has_children_internal());
165 has_children_valid (TRUE);
168 return ((f_children_flag & HAS_CHILDREN_BIT) != 0);