You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

344 lines
10KB

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