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.

161 lines
4.0KB

  1. //
  2. // "$Id: Fl_Tree_Prefs.cxx 8340 2011-01-30 20:22:06Z greg.ercolano $"
  3. //
  4. #include <FL/Fl.H>
  5. #include <FL/Fl_Pixmap.H>
  6. #include <FL/Fl_Tree_Prefs.H>
  7. #include <string.h>
  8. //////////////////////
  9. // Fl_Tree_Prefs.cxx
  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. // INTERNAL: BUILT IN OPEN/STOW XPMS
  31. // These can be replaced via prefs.openicon()/closeicon()
  32. //
  33. static const char *L_open_xpm[] = {
  34. #ifdef __APPLE__
  35. "11 11 2 1",
  36. ". c None",
  37. "@ c #000000",
  38. "...@.......",
  39. "...@@......",
  40. "...@@@.....",
  41. "...@@@@....",
  42. "...@@@@@...",
  43. "...@@@@@@..",
  44. "...@@@@@...",
  45. "...@@@@....",
  46. "...@@@.....",
  47. "...@@......",
  48. "...@......."
  49. #else
  50. "11 11 3 1",
  51. ". c #fefefe",
  52. "# c #444444",
  53. "@ c #000000",
  54. "###########",
  55. "#.........#",
  56. "#.........#",
  57. "#....@....#",
  58. "#....@....#",
  59. "#..@@@@@..#",
  60. "#....@....#",
  61. "#....@....#",
  62. "#.........#",
  63. "#.........#",
  64. "###########"
  65. #endif
  66. };
  67. static Fl_Pixmap L_openpixmap(L_open_xpm);
  68. static const char *L_close_xpm[] = {
  69. #ifdef __APPLE__
  70. "11 11 2 1",
  71. ". c None",
  72. "@ c #000000",
  73. "...........",
  74. "...........",
  75. "...........",
  76. "...........",
  77. "...........",
  78. "@@@@@@@@@@@",
  79. ".@@@@@@@@@.",
  80. "..@@@@@@@..",
  81. "...@@@@@...",
  82. "....@@@....",
  83. ".....@....."
  84. #else
  85. "11 11 3 1",
  86. ". c #fefefe",
  87. "# c #444444",
  88. "@ c #000000",
  89. "###########",
  90. "#.........#",
  91. "#.........#",
  92. "#.........#",
  93. "#.........#",
  94. "#..@@@@@..#",
  95. "#.........#",
  96. "#.........#",
  97. "#.........#",
  98. "#.........#",
  99. "###########"
  100. #endif
  101. };
  102. static Fl_Pixmap L_closepixmap(L_close_xpm);
  103. /// Sets the default icon to be used as the 'open' icon
  104. /// when items are add()ed to the tree.
  105. /// This overrides the built in default '[+]' icon.
  106. ///
  107. /// \param[in] val -- The new image, or zero to use the default [+] icon.
  108. ///
  109. void Fl_Tree_Prefs::openicon(Fl_Image *val) {
  110. _openimage = val ? val : &L_openpixmap;
  111. }
  112. /// Sets the icon to be used as the 'close' icon.
  113. /// This overrides the built in default '[-]' icon.
  114. ///
  115. /// \param[in] val -- The new image, or zero to use the default [-] icon.
  116. ///
  117. void Fl_Tree_Prefs::closeicon(Fl_Image *val) {
  118. _closeimage = val ? val : &L_closepixmap;
  119. }
  120. /// Fl_Tree_Prefs constructor
  121. Fl_Tree_Prefs::Fl_Tree_Prefs() {
  122. _labelfont = FL_HELVETICA;
  123. _labelsize = FL_NORMAL_SIZE;
  124. _marginleft = 6;
  125. _margintop = 3;
  126. //_marginright = 3;
  127. //_marginbottom = 3;
  128. _openchild_marginbottom = 0;
  129. _usericonmarginleft = 3;
  130. _labelmarginleft = 3;
  131. _linespacing = 0;
  132. _labelfgcolor = FL_BLACK;
  133. _labelbgcolor = FL_WHITE;
  134. _connectorcolor = Fl_Color(43);
  135. #ifdef __APPLE__
  136. _connectorstyle = FL_TREE_CONNECTOR_NONE;
  137. #else
  138. _connectorstyle = FL_TREE_CONNECTOR_DOTTED;
  139. #endif
  140. _openimage = &L_openpixmap;
  141. _closeimage = &L_closepixmap;
  142. _userimage = 0;
  143. _showcollapse = 1;
  144. _showroot = 1;
  145. _connectorwidth = 17;
  146. _sortorder = FL_TREE_SORT_NONE;
  147. _selectbox = FL_FLAT_BOX;
  148. _selectmode = FL_TREE_SELECT_SINGLE;
  149. }
  150. //
  151. // End of "$Id: Fl_Tree_Prefs.cxx 8340 2011-01-30 20:22:06Z greg.ercolano $".
  152. //