blob: 57d72e38230c84b010b232d23eb97f1756cf6321 [file] [log] [blame]
DRC2ff39b82011-07-28 08:38:59 +00001//
2// "$Id: Fl_Tree_Prefs.H 8340 2011-01-30 20:22:06Z greg.ercolano $"
3//
4
5#ifndef FL_TREE_PREFS_H
6#define FL_TREE_PREFS_H
7
8//////////////////////
9// FL/Fl_Tree_Prefs.H
10//////////////////////
11//
12// Fl_Tree -- This file is part of the Fl_Tree widget for FLTK
13// Copyright (C) 2009-2010 by Greg Ercolano.
14//
15// This library is free software; you can redistribute it and/or
16// modify it under the terms of the GNU Library General Public
17// License as published by the Free Software Foundation; either
18// version 2 of the License, or (at your option) any later version.
19//
20// This library is distributed in the hope that it will be useful,
21// but WITHOUT ANY WARRANTY; without even the implied warranty of
22// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23// Library General Public License for more details.
24//
25// You should have received a copy of the GNU Library General Public
26// License along with this library; if not, write to the Free Software
27// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
28// USA.
29//
30
31///
32/// \file
33/// \brief This file contains the definitions for Fl_Tree's preferences.
34///
35/// \code
36/// Fl_Tree_Prefs
37/// :
38/// .....:.......
39/// : :
40/// Fl_Tree :
41/// |_____ Fl_Tree_Item
42///
43/// \endcode
44///
45
46/// \class Fl_Tree_Prefs
47/// \brief Tree widget's preferences.
48
49/// \enum Fl_Tree_Sort
50/// Sort order options for items added to the tree
51///
52enum Fl_Tree_Sort {
53 FL_TREE_SORT_NONE=0, ///< No sorting; items are added in the order defined (default).
54 FL_TREE_SORT_ASCENDING=1, ///< Add items in ascending sort order.
55 FL_TREE_SORT_DESCENDING=2 ///< Add items in descending sort order.
56};
57
58/// \enum Fl_Tree_Connector
59/// Defines the style of connection lines between items.
60///
61enum Fl_Tree_Connector {
62 FL_TREE_CONNECTOR_NONE=0, ///< Use no lines connecting items
63 FL_TREE_CONNECTOR_DOTTED=1, ///< Use dotted lines connecting items (default)
64 FL_TREE_CONNECTOR_SOLID=2 ///< Use solid lines connecting items
65};
66
67/// \enum Fl_Tree_Select
68/// Tree selection style.
69///
70enum Fl_Tree_Select {
71 FL_TREE_SELECT_NONE=0, ///< Nothing selected when items are clicked
72 FL_TREE_SELECT_SINGLE=1, ///< Single item selected when item is clicked (default)
73 FL_TREE_SELECT_MULTI=2 ///< Multiple items can be selected by clicking with
74 ///< SHIFT or CTRL or mouse drags.
75};
76
77/// \class Fl_Tree_Prefs
78///
79/// \brief Fl_Tree's Preferences class.
80///
81/// This class manages the Fl_Tree's defaults.
82/// You should probably be using the methods in Fl_Tree
83/// instead of trying to accessing tree's preferences settings directly.
84///
85class FL_EXPORT Fl_Tree_Prefs {
86 Fl_Font _labelfont; // label's font face
87 Fl_Fontsize _labelsize; // label's font size
88 int _margintop; // --
89 int _marginleft; // |- tree's margins
90 //int _marginright; // |
91 //int _marginbottom; // --
92 int _openchild_marginbottom; // extra space below an open child tree
93 int _usericonmarginleft; // space to left of user icon (if any)
94 int _labelmarginleft; // space to left of label
95 int _connectorwidth; // connector width (right of open/close icon)
96 int _linespacing; // vertical space between lines
97 // Colors
98 Fl_Color _labelfgcolor; // label's foreground color
99 Fl_Color _labelbgcolor; // background color
100 Fl_Color _connectorcolor; // connector dotted line color
101 Fl_Tree_Connector _connectorstyle; // connector line style
102 Fl_Image *_openimage; // the 'open' icon [+]
103 Fl_Image *_closeimage; // the 'close' icon [-]
104 Fl_Image *_userimage; // user's own icon
105 char _showcollapse; // 1=show collapse icons, 0=don't
106 char _showroot; // show the root item as part of the tree
107 Fl_Tree_Sort _sortorder; // none, ascening, descending, etc.
108 Fl_Boxtype _selectbox; // selection box type
109 Fl_Tree_Select _selectmode; // selection mode
110public:
111 Fl_Tree_Prefs();
112
113 ////////////////////////////
114 // Labels
115 ////////////////////////////
116 /// Return the label's font.
117 inline Fl_Font labelfont() const {
118 return(_labelfont);
119 }
120 /// Set the label's font to \p val.
121 inline void labelfont(Fl_Font val) {
122 _labelfont = val;
123 }
124 /// Return the label's size in pixels.
125 inline Fl_Fontsize labelsize() const {
126 return(_labelsize);
127 }
128 /// Set the label's size in pixels to \p val.
129 inline void labelsize(Fl_Fontsize val) {
130 _labelsize = val;
131 }
132
133 ////////////////////////////
134 // Margins
135 ////////////////////////////
136 /// Get the left margin's value in pixels
137 inline int marginleft() const {
138 return(_marginleft);
139 }
140 /// Set the left margin's value in pixels
141 inline void marginleft(int val) {
142 _marginleft = val;
143 }
144 /// Get the top margin's value in pixels
145 inline int margintop() const {
146 return(_margintop);
147 }
148 /// Set the top margin's value in pixels
149 inline void margintop(int val) {
150 _margintop = val;
151 }
152 /// Get the margin below an open child in pixels
153 inline int openchild_marginbottom() const {
154 return(_openchild_marginbottom);
155 }
156 /// Set the margin below an open child in pixels
157 inline void openchild_marginbottom(int val) {
158 _openchild_marginbottom = val;
159 }
160
161 /****** NOT IMPLEMENTED
162 inline int marginright() const {
163 return(_marginright);
164 }
165 inline void marginright(int val) {
166 _marginright = val;
167 }
168 inline int marginbottom() const {
169 return(_marginbottom);
170 }
171 inline void marginbottom(int val) {
172 _marginbottom = val;
173 }
174 *******/
175
176 /// Get the user icon's left margin value in pixels
177 inline int usericonmarginleft() const {
178 return(_usericonmarginleft);
179 }
180 /// Set the user icon's left margin value in pixels
181 inline void usericonmarginleft(int val) {
182 _usericonmarginleft = val;
183 }
184 /// Get the label's left margin value in pixels
185 inline int labelmarginleft() const {
186 return(_labelmarginleft);
187 }
188 /// Set the label's left margin value in pixels
189 inline void labelmarginleft(int val) {
190 _labelmarginleft = val;
191 }
192 /// Get the line spacing value in pixels
193 inline int linespacing() const {
194 return(_linespacing);
195 }
196 /// Set the line spacing value in pixels
197 inline void linespacing(int val) {
198 _linespacing = val;
199 }
200
201 ////////////////////////////
202 // Colors and Styles
203 ////////////////////////////
204 /// Get the default label foreground color
205 inline Fl_Color labelfgcolor() const {
206 return(_labelfgcolor);
207 }
208 /// Set the default label foreground color
209 inline void labelfgcolor(Fl_Color val) {
210 _labelfgcolor = val;
211 }
212 /// Get the default label background color
213 inline Fl_Color labelbgcolor() const {
214 return(_labelbgcolor);
215 }
216 /// Set the default label background color
217 inline void labelbgcolor(Fl_Color val) {
218 _labelbgcolor = val;
219 }
220 /// Get the connector color used for tree connection lines.
221 inline Fl_Color connectorcolor() const {
222 return(_connectorcolor);
223 }
224 /// Set the connector color used for tree connection lines.
225 inline void connectorcolor(Fl_Color val) {
226 _connectorcolor = val;
227 }
228 /// Get the connector style.
229 inline Fl_Tree_Connector connectorstyle() const {
230 return(_connectorstyle);
231 }
232 /// Set the connector style.
233 inline void connectorstyle(Fl_Tree_Connector val) {
234 _connectorstyle = val;
235 }
236 /// Set the connector style [integer].
237 inline void connectorstyle(int val) {
238 _connectorstyle = Fl_Tree_Connector(val);
239 }
240 /// Get the tree connection line's width.
241 inline int connectorwidth() const {
242 return(_connectorwidth);
243 }
244 /// Set the tree connection line's width.
245 inline void connectorwidth(int val) {
246 _connectorwidth = val;
247 }
248
249 ////////////////////////////
250 // Icons
251 ////////////////////////////
252 /// Get the current default 'open' icon.
253 /// Returns the Fl_Image* of the icon, or 0 if none.
254 ///
255 inline Fl_Image *openicon() const {
256 return(_openimage);
257 }
258 void openicon(Fl_Image *val);
259 /// Gets the default 'close' icon
260 /// Returns the Fl_Image* of the icon, or 0 if none.
261 ///
262 inline Fl_Image *closeicon() const {
263 return(_closeimage);
264 }
265 void closeicon(Fl_Image *val);
266 /// Gets the default 'user icon' (default is 0)
267 inline Fl_Image *usericon() const {
268 return(_userimage);
269 }
270 /// Sets the default 'user icon'
271 /// Returns the Fl_Image* of the icon, or 0 if none (default).
272 ///
273 inline void usericon(Fl_Image *val) {
274 _userimage = val;
275 }
276
277 ////////////////////////////
278 // Options
279 ////////////////////////////
280 /// Returns 1 if the collapse icon is enabled, 0 if not.
281 inline char showcollapse() const {
282 return(_showcollapse);
283 }
284 /// Set if we should show the collapse icon or not.
285 /// If collapse icons are disabled, the user will not be able
286 /// to interactively collapse items in the tree, unless the application
287 /// provides some other means via open() and close().
288 ///
289 /// \param[in] val 1: shows collapse icons (default),\n
290 /// 0: hides collapse icons.
291 ///
292 inline void showcollapse(int val) {
293 _showcollapse = val;
294 }
295 /// Get the default sort order value
296 inline Fl_Tree_Sort sortorder() const {
297 return(_sortorder);
298 }
299 /// Set the default sort order value.
300 /// Defines the order new items appear when add()ed to the tree.
301 /// See Fl_Tree_Sort for possible values.
302 ///
303 inline void sortorder(Fl_Tree_Sort val) {
304 _sortorder = val;
305 }
306 /// Get the default selection box's box drawing style as an Fl_Boxtype.
307 inline Fl_Boxtype selectbox() const {
308 return(_selectbox);
309 }
310 /// Set the default selection box's box drawing style to \p val.
311 inline void selectbox(Fl_Boxtype val) {
312 _selectbox = val;
313 }
314 /// Returns 1 if the root item is to be shown, or 0 if not.
315 inline int showroot() const {
316 return(int(_showroot));
317 }
318 /// Set if the root item should be shown or not.
319 /// \param[in] val 1 -- show the root item (default)\n
320 /// 0 -- hide the root item.
321 ///
322 inline void showroot(int val) {
323 _showroot = char(val);
324 }
325 /// Get the selection mode used for the tree
326 inline Fl_Tree_Select selectmode() const {
327 return(_selectmode);
328 }
329 /// Set the selection mode used for the tree to \p val.
330 /// This affects how items in the tree are selected
331 /// when clicked on and dragged over by the mouse.
332 /// See Fl_Tree_Select for possible values.
333 ///
334 inline void selectmode(Fl_Tree_Select val) {
335 _selectmode = val;
336 }
337};
338
339#endif /*FL_TREE_PREFS_H*/
340
341//
342// End of "$Id: Fl_Tree_Prefs.H 8340 2011-01-30 20:22:06Z greg.ercolano $".
343//