2 // "$Id: Fl_Tree_Prefs.H 8340 2011-01-30 20:22:06Z greg.ercolano $"
5 #ifndef FL_TREE_PREFS_H
6 #define FL_TREE_PREFS_H
10 //////////////////////
12 // Fl_Tree -- This file is part of the Fl_Tree widget for FLTK
13 // Copyright (C) 2009-2010 by Greg Ercolano.
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.
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.
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
33 /// \brief This file contains the definitions for Fl_Tree's preferences.
41 /// |_____ Fl_Tree_Item
46 /// \class Fl_Tree_Prefs
47 /// \brief Tree widget's preferences.
49 /// \enum Fl_Tree_Sort
50 /// Sort order options for items added to the tree
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.
58 /// \enum Fl_Tree_Connector
59 /// Defines the style of connection lines between items.
61 enum 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
67 /// \enum Fl_Tree_Select
68 /// Tree selection style.
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.
77 /// \class Fl_Tree_Prefs
79 /// \brief Fl_Tree's Preferences class.
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.
85 class FL_EXPORT Fl_Tree_Prefs {
86 Fl_Font _labelfont; // label's font face
87 Fl_Fontsize _labelsize; // label's font size
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
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
113 ////////////////////////////
115 ////////////////////////////
116 /// Return the label's font.
117 inline Fl_Font labelfont() const {
120 /// Set the label's font to \p val.
121 inline void labelfont(Fl_Font val) {
124 /// Return the label's size in pixels.
125 inline Fl_Fontsize labelsize() const {
128 /// Set the label's size in pixels to \p val.
129 inline void labelsize(Fl_Fontsize val) {
133 ////////////////////////////
135 ////////////////////////////
136 /// Get the left margin's value in pixels
137 inline int marginleft() const {
140 /// Set the left margin's value in pixels
141 inline void marginleft(int val) {
144 /// Get the top margin's value in pixels
145 inline int margintop() const {
148 /// Set the top margin's value in pixels
149 inline void margintop(int val) {
152 /// Get the margin below an open child in pixels
153 inline int openchild_marginbottom() const {
154 return(_openchild_marginbottom);
156 /// Set the margin below an open child in pixels
157 inline void openchild_marginbottom(int val) {
158 _openchild_marginbottom = val;
161 /****** NOT IMPLEMENTED
162 inline int marginright() const {
163 return(_marginright);
165 inline void marginright(int val) {
168 inline int marginbottom() const {
169 return(_marginbottom);
171 inline void marginbottom(int val) {
176 /// Get the user icon's left margin value in pixels
177 inline int usericonmarginleft() const {
178 return(_usericonmarginleft);
180 /// Set the user icon's left margin value in pixels
181 inline void usericonmarginleft(int val) {
182 _usericonmarginleft = val;
184 /// Get the label's left margin value in pixels
185 inline int labelmarginleft() const {
186 return(_labelmarginleft);
188 /// Set the label's left margin value in pixels
189 inline void labelmarginleft(int val) {
190 _labelmarginleft = val;
192 /// Get the line spacing value in pixels
193 inline int linespacing() const {
194 return(_linespacing);
196 /// Set the line spacing value in pixels
197 inline void linespacing(int val) {
201 ////////////////////////////
203 ////////////////////////////
204 /// Get the default label foreground color
205 inline Fl_Color labelfgcolor() const {
206 return(_labelfgcolor);
208 /// Set the default label foreground color
209 inline void labelfgcolor(Fl_Color val) {
212 /// Get the default label background color
213 inline Fl_Color labelbgcolor() const {
214 return(_labelbgcolor);
216 /// Set the default label background color
217 inline void labelbgcolor(Fl_Color val) {
220 /// Get the connector color used for tree connection lines.
221 inline Fl_Color connectorcolor() const {
222 return(_connectorcolor);
224 /// Set the connector color used for tree connection lines.
225 inline void connectorcolor(Fl_Color val) {
226 _connectorcolor = val;
228 /// Get the connector style.
229 inline Fl_Tree_Connector connectorstyle() const {
230 return(_connectorstyle);
232 /// Set the connector style.
233 inline void connectorstyle(Fl_Tree_Connector val) {
234 _connectorstyle = val;
236 /// Set the connector style [integer].
237 inline void connectorstyle(int val) {
238 _connectorstyle = Fl_Tree_Connector(val);
240 /// Get the tree connection line's width.
241 inline int connectorwidth() const {
242 return(_connectorwidth);
244 /// Set the tree connection line's width.
245 inline void connectorwidth(int val) {
246 _connectorwidth = val;
249 ////////////////////////////
251 ////////////////////////////
252 /// Get the current default 'open' icon.
253 /// Returns the Fl_Image* of the icon, or 0 if none.
255 inline Fl_Image *openicon() const {
258 void openicon(Fl_Image *val);
259 /// Gets the default 'close' icon
260 /// Returns the Fl_Image* of the icon, or 0 if none.
262 inline Fl_Image *closeicon() const {
265 void closeicon(Fl_Image *val);
266 /// Gets the default 'user icon' (default is 0)
267 inline Fl_Image *usericon() const {
270 /// Sets the default 'user icon'
271 /// Returns the Fl_Image* of the icon, or 0 if none (default).
273 inline void usericon(Fl_Image *val) {
277 ////////////////////////////
279 ////////////////////////////
280 /// Returns 1 if the collapse icon is enabled, 0 if not.
281 inline char showcollapse() const {
282 return(_showcollapse);
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().
289 /// \param[in] val 1: shows collapse icons (default),\n
290 /// 0: hides collapse icons.
292 inline void showcollapse(int val) {
295 /// Get the default sort order value
296 inline Fl_Tree_Sort sortorder() const {
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.
303 inline void sortorder(Fl_Tree_Sort val) {
306 /// Get the default selection box's box drawing style as an Fl_Boxtype.
307 inline Fl_Boxtype selectbox() const {
310 /// Set the default selection box's box drawing style to \p val.
311 inline void selectbox(Fl_Boxtype val) {
314 /// Returns 1 if the root item is to be shown, or 0 if not.
315 inline int showroot() const {
316 return(int(_showroot));
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.
322 inline void showroot(int val) {
323 _showroot = char(val);
325 /// Get the selection mode used for the tree
326 inline Fl_Tree_Select selectmode() const {
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.
334 inline void selectmode(Fl_Tree_Select val) {
339 #endif /*FL_TREE_PREFS_H*/
342 // End of "$Id: Fl_Tree_Prefs.H 8340 2011-01-30 20:22:06Z greg.ercolano $".