dtinfo: remove register keyword
[oweals/cde.git] / cde / programs / dtinfo / dtinfo / src / Basic / OutlineElement.hh
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
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)
10  * any later version.
11  *
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
16  * details.
17  *
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
22  */
23 /*
24  * $XConsortium: OutlineElement.hh /main/4 1996/08/30 17:21:04 drk $
25  *
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.
30  * 
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.
34  * 
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
41  * 
42  */
43
44 class OutlineList;
45
46 class OutlineElement : public FolioObject
47 {
48 friend class OutlineList;
49   
50 public: // functions
51   DEF_CLASS (OutlineElement);
52
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),
57       f_level (0)
58   { children_valid ((children != NULL) ? TRUE : FALSE); }
59
60   ~OutlineElement();
61
62   inline bool has_children();
63
64   virtual OutlineList *children()
65     { return (f_children); }
66   virtual void set_children (OutlineList *children)
67     { f_children = children;
68       children_valid (TRUE); }
69
70   bool children_cached()
71     { return (children_valid()); }
72
73   virtual void display() = 0;
74
75   unsigned char level()
76     { return (f_level); }
77   void level (unsigned char level)
78     { f_level = level; }
79   
80   bool is_selected (BitHandle handle)
81     { return f_selected.is_set (handle); }
82
83   void set_selected (BitHandle handle)
84     { f_selected.set (handle) ; }
85
86   void unset_selected (BitHandle handle)
87     { f_selected.unset (handle); }
88
89   bool is_expanded (BitHandle handle)
90     { return f_expanded.is_set (handle); }
91
92   bool is_contracted (BitHandle handle)
93     { return !f_expanded.is_set (handle) ; }
94
95   void set_expanded (BitHandle handle)
96     { f_expanded.set (handle); }
97
98   void set_contracted (BitHandle handle)
99     { f_expanded.unset (handle); }
100   
101   void set_xm_string (void *xm_string)
102     { f_xm_string = xm_string; }
103   void *xm_string()
104     { return (f_xm_string); }
105
106   void string_creator (u_int creator_id)
107     { f_string_creator = creator_id; }
108   u_int string_creator()
109     { return (f_string_creator); }
110
111 #ifdef DEBUG
112   void print();
113 #endif
114
115   unsigned char display_flag()
116     { return (f_display_flag); }
117   void display_flag (unsigned char flag)
118     { f_display_flag = flag; }
119
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);
126     }
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);
132     }
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);
138     }
139
140 protected: // variables
141   OutlineList *f_children;  // Each outline element may have a list of children
142   
143   BitField      f_selected ;
144   BitField      f_expanded ;
145
146   // NOTE: xm_string temporary until R2
147   void        *f_xm_string;
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;
152
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
155 };
156
157
158 inline bool
159 OutlineElement::has_children()
160 {
161   // Only calculate value of has_children once since it might be expensive. 
162   if (!has_children_valid())
163     {
164       has_children (has_children_internal());
165       has_children_valid (TRUE);
166     }
167
168   return ((f_children_flag & HAS_CHILDREN_BIT) != 0);
169 }
170