Fl_Tree_Prefs.H 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  1. //
  2. // "$Id: Fl_Tree_Prefs.H 7903 2010-11-28 21:06:39Z matt $"
  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. int _labelfont; // label's font face
  79. int _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 _fgcolor; // label's foreground color
  91. Fl_Color _bgcolor; // background color
  92. Fl_Color _selectcolor; // selection color
  93. Fl_Color _inactivecolor; // inactive color
  94. Fl_Color _connectorcolor; // connector dotted line color
  95. Fl_Tree_Connector _connectorstyle; // connector line style
  96. Fl_Image *_openimage; // the 'open' icon [+]
  97. Fl_Image *_closeimage; // the 'close' icon [-]
  98. Fl_Image *_userimage; // user's own icon
  99. char _showcollapse; // 1=show collapse icons, 0=don't
  100. char _showroot; // show the root item as part of the tree
  101. Fl_Tree_Sort _sortorder; // none, ascening, descending, etc.
  102. Fl_Boxtype _selectbox; // selection box type
  103. Fl_Tree_Select _selectmode; // selection mode
  104. public:
  105. Fl_Tree_Prefs();
  106. ////////////////////////////
  107. // Labels
  108. ////////////////////////////
  109. /// Return the label's font.
  110. inline int labelfont() const {
  111. return(_labelfont);
  112. }
  113. /// Set the label's font to \p val.
  114. inline void labelfont(int val) {
  115. _labelfont = val;
  116. }
  117. /// Return the label's size in pixels.
  118. inline int labelsize() const {
  119. return(_labelsize);
  120. }
  121. /// Set the label's size in pixels to \p val.
  122. inline void labelsize(int val) {
  123. _labelsize = val;
  124. }
  125. ////////////////////////////
  126. // Margins
  127. ////////////////////////////
  128. /// Get the left margin's value in pixels
  129. inline int marginleft() const {
  130. return(_marginleft);
  131. }
  132. /// Set the left margin's value in pixels
  133. inline void marginleft(int val) {
  134. _marginleft = val;
  135. }
  136. /// Get the top margin's value in pixels
  137. inline int margintop() const {
  138. return(_margintop);
  139. }
  140. /// Set the top margin's value in pixels
  141. inline void margintop(int val) {
  142. _margintop = val;
  143. }
  144. /// Get the margin below an open child in pixels
  145. inline int openchild_marginbottom() const {
  146. return(_openchild_marginbottom);
  147. }
  148. /// Set the margin below an open child in pixels
  149. inline void openchild_marginbottom(int val) {
  150. _openchild_marginbottom = val;
  151. }
  152. /****** NOT IMPLEMENTED
  153. inline int marginright() const {
  154. return(_marginright);
  155. }
  156. inline void marginright(int val) {
  157. _marginright = val;
  158. }
  159. inline int marginbottom() const {
  160. return(_marginbottom);
  161. }
  162. inline void marginbottom(int val) {
  163. _marginbottom = val;
  164. }
  165. *******/
  166. /// Get the user icon's left margin value in pixels
  167. inline int usericonmarginleft() const {
  168. return(_usericonmarginleft);
  169. }
  170. /// Set the user icon's left margin value in pixels
  171. inline void usericonmarginleft(int val) {
  172. _usericonmarginleft = val;
  173. }
  174. /// Get the label's left margin value in pixels
  175. inline int labelmarginleft() const {
  176. return(_labelmarginleft);
  177. }
  178. /// Set the label's left margin value in pixels
  179. inline void labelmarginleft(int val) {
  180. _labelmarginleft = val;
  181. }
  182. /// Get the line spacing value in pixels
  183. inline int linespacing() const {
  184. return(_linespacing);
  185. }
  186. /// Set the line spacing value in pixels
  187. inline void linespacing(int val) {
  188. _linespacing = val;
  189. }
  190. ////////////////////////////
  191. // Colors and Styles
  192. ////////////////////////////
  193. /// Get the default label foreground color
  194. inline Fl_Color fgcolor() const {
  195. return(_fgcolor);
  196. }
  197. /// Set the default label foreground color
  198. inline void fgcolor(Fl_Color val) {
  199. _fgcolor = val;
  200. }
  201. /// Get the default label background color
  202. inline Fl_Color bgcolor() const {
  203. return(_bgcolor);
  204. }
  205. /// Set the default label background color
  206. inline void bgcolor(Fl_Color val) {
  207. _bgcolor = val;
  208. }
  209. /// Get the default selection color
  210. inline Fl_Color selectcolor() const {
  211. return(_selectcolor);
  212. }
  213. /// Set the default selection color
  214. inline void selectcolor(Fl_Color val) {
  215. _selectcolor = val;
  216. }
  217. /// Get the default inactive color
  218. inline Fl_Color inactivecolor() const {
  219. return(_inactivecolor);
  220. }
  221. /// Set the default inactive color
  222. inline void inactivecolor(Fl_Color val) {
  223. _inactivecolor = val;
  224. }
  225. /// Get the connector color; the color used for tree connection lines
  226. inline Fl_Color connectorcolor() const {
  227. return(_connectorcolor);
  228. }
  229. /// Set the connector color; the color used for tree connection lines
  230. inline void connectorcolor(Fl_Color val) {
  231. _connectorcolor = val;
  232. }
  233. /// Get the connector style
  234. inline Fl_Tree_Connector connectorstyle() const {
  235. return(_connectorstyle);
  236. }
  237. /// Set the connector style
  238. inline void connectorstyle(Fl_Tree_Connector val) {
  239. _connectorstyle = val;
  240. }
  241. /// Set the connector style [integer].
  242. inline void connectorstyle(int val) {
  243. _connectorstyle = Fl_Tree_Connector(val);
  244. }
  245. /// Get the tree connection line's width
  246. inline int connectorwidth() const {
  247. return(_connectorwidth);
  248. }
  249. /// Set the tree connection line's width
  250. inline void connectorwidth(int val) {
  251. _connectorwidth = val;
  252. }
  253. ////////////////////////////
  254. // Icons
  255. ////////////////////////////
  256. /// Get the current default 'open' icon.
  257. /// Returns the Fl_Image* of the icon, or 0 if none.
  258. ///
  259. inline Fl_Image *openicon() const {
  260. return(_openimage);
  261. }
  262. void openicon(Fl_Image *val);
  263. /// Gets the default 'close' icon
  264. /// Returns the Fl_Image* of the icon, or 0 if none.
  265. ///
  266. inline Fl_Image *closeicon() const {
  267. return(_closeimage);
  268. }
  269. void closeicon(Fl_Image *val);
  270. /// Gets the default 'user icon' (default is 0)
  271. inline Fl_Image *usericon() const {
  272. return(_userimage);
  273. }
  274. /// Sets the default 'user icon'
  275. /// Returns the Fl_Image* of the icon, or 0 if none (default).
  276. ///
  277. inline void usericon(Fl_Image *val) {
  278. _userimage = val;
  279. }
  280. ////////////////////////////
  281. // Options
  282. ////////////////////////////
  283. /// Returns 1 if the collapse icon is enabled, 0 if not.
  284. inline char showcollapse() const {
  285. return(_showcollapse);
  286. }
  287. /// Set if we should show the collapse icon or not.
  288. /// If collapse icons are disabled, the user will not be able
  289. /// to interactively collapse items in the tree, unless the application
  290. /// provides some other means via open() and close().
  291. ///
  292. /// \param[in] val 1: shows collapse icons (default),\n
  293. /// 0: hides collapse icons.
  294. ///
  295. inline void showcollapse(int val) {
  296. _showcollapse = val;
  297. }
  298. /// Get the default sort order value
  299. inline Fl_Tree_Sort sortorder() const {
  300. return(_sortorder);
  301. }
  302. /// Set the default sort order value.
  303. /// Defines the order new items appear when add()ed to the tree.
  304. /// See Fl_Tree_Sort for possible values.
  305. ///
  306. inline void sortorder(Fl_Tree_Sort val) {
  307. _sortorder = val;
  308. }
  309. /// Get the default selection box's box drawing style as an Fl_Boxtype.
  310. inline Fl_Boxtype selectbox() const {
  311. return(_selectbox);
  312. }
  313. /// Set the default selection box's box drawing style to \p val.
  314. inline void selectbox(Fl_Boxtype val) {
  315. _selectbox = val;
  316. }
  317. /// Returns 1 if the root item is to be shown, or 0 if not.
  318. inline int showroot() const {
  319. return(int(_showroot));
  320. }
  321. /// Set if the root item should be shown or not.
  322. /// \param[in] val 1 -- show the root item (default)\n
  323. /// 0 -- hide the root item.
  324. ///
  325. inline void showroot(int val) {
  326. _showroot = char(val);
  327. }
  328. /// Get the selection mode used for the tree
  329. inline Fl_Tree_Select selectmode() const {
  330. return(_selectmode);
  331. }
  332. /// Set the selection mode used for the tree to \p val.
  333. /// This affects how items in the tree are selected
  334. /// when clicked on and dragged over by the mouse.
  335. /// See Fl_Tree_Select for possible values.
  336. ///
  337. inline void selectmode(Fl_Tree_Select val) {
  338. _selectmode = val;
  339. }
  340. };
  341. #endif /*FL_TREE_PREFS_H*/
  342. //
  343. // End of "$Id: Fl_Tree_Prefs.H 7903 2010-11-28 21:06:39Z matt $".
  344. //