colorsel.pas 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. {
  2. (Still unused) skeleton for Colorsel replacement, based on mostly the
  3. use by the fpmopts.inc file, to be added on as details emerge.
  4. Copyright 2008 by Marco van de Voort and Andreas Jakobsche
  5. This library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Library General Public
  7. License as published by the Free Software Foundation; either
  8. version 2 of the License, or (at your option) any later version.
  9. This library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Library General Public License for more details.
  13. You should have received a copy of the GNU Library General Public
  14. License along with this library; if not, write to the Free
  15. Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************}
  17. }
  18. unit ColorSel;
  19. interface
  20. uses Objects, Dialogs, Views;
  21. type
  22. PColorItem = ^TColorItem;
  23. TColorItem = record
  24. Name: PString;
  25. Index: Byte;
  26. Next: PColorItem;
  27. end;
  28. PColorGroup = ^TColorGroup;
  29. TColorGroup = record
  30. Name: PString;
  31. Index: Byte;
  32. Items: PColorItem;
  33. Next: PColorGroup;
  34. end;
  35. PColorGroupList = ^TColorGroupList;
  36. TColorGroupList = object(TListViewer)
  37. Groups: PColorGroup;
  38. constructor Init(var Bounds: TRect; AScrollBar: PScrollBar; AGroups: PColorGroup);
  39. end;
  40. PColorDialog = ^TColorDialog;
  41. TColorDialog = object(TDialog)
  42. Groups: PColorGroupList;
  43. Pal: TPalette;
  44. constructor Init(APalette: TPalette; AGroups: PColorGroup);
  45. constructor Load(var S: TStream);
  46. procedure Store(var S: TStream);
  47. end;
  48. function ColorGroup(Name: string; Items: PColorItem; Next: PColorGroup): PColorGroup;
  49. function ColorItem(Name: string; Index: Byte; Next: PColorItem): PColorItem;
  50. implementation
  51. uses App;
  52. const
  53. RColorDialog: TStreamRec = (
  54. ObjType: idColorDialog;
  55. VmtLink: Ofs(TypeOf(TColorDialog)^);
  56. Load: @TColorDialog.Load;
  57. Store: @TColorDialog.Store
  58. );
  59. procedure RegisterColorsel;
  60. begin
  61. // according to help should register TColorSelector, TMonoSelector, TColorDisplay, TColorGroupList, TColorItemList, TColorDialog
  62. // probably don't bother with the mono variants. Except for (P/T)colordialog, these don't grep in FV/IDE src.
  63. // TColorSelector -> the square colorselection widget (instantiated twice once for front, once for back?)
  64. // TColorGrouplist-> the selection of the color group (left list) (TListbox or whatever the TV eq is?)
  65. // TColorItemList -> the selection of the color identifier (right list) (TListbox or whatever the TV eq is?)
  66. RegisterType(RColorDialog);
  67. end ;
  68. function ColorGroup(Name: string; Items: PColorItem; Next: PColorGroup): PColorGroup;
  69. var
  70. R: PColorGroup;
  71. begin
  72. New(R);
  73. R^.Name := NewStr(Name);
  74. R^.Items := Items;
  75. R^.Next := Next;
  76. ColorGroup := R;
  77. end;
  78. function ColorItem(Name: string; Index: Byte; Next: PColorItem): PColorItem;
  79. var R: PColorItem;
  80. begin
  81. New(R);
  82. R^.Name := NewStr(Name);
  83. R^.Index := Index;
  84. R^.Next := Next;
  85. ColorItem := R
  86. end;
  87. constructor TColorGroupList.Init(var Bounds: TRect; AScrollBar: PScrollBar; AGroups: PColorGroup);
  88. var
  89. x: PColorGroup;
  90. begin
  91. inherited Init(Bounds, 1, nil, AScrollBar);
  92. Range := 0;
  93. Groups := AGroups;
  94. x := AGroups;
  95. while Assigned(x) do begin
  96. x^.Index := Range;
  97. Inc(Range);
  98. x := x^.Next
  99. end;
  100. end;
  101. constructor TColorDialog.Init(APalette: TPalette; AGroups: PColorGroup);
  102. var
  103. Bounds: TRect;
  104. begin
  105. Bounds.Assign(0, 0, 62, 19);
  106. inherited Init(Bounds, 'Colors');
  107. Options := Options or ofCentered;
  108. Pal := APalette;
  109. Bounds.Grow(-1, -1);
  110. Groups := New(PColorGroupList, Init(Bounds, nil, AGroups));
  111. end;
  112. constructor TColorDialog.Load(var S: TStream);
  113. begin
  114. end;
  115. procedure TColorDialog.Store(var S: TStream);
  116. begin
  117. end;
  118. end.
  119. {
  120. ColorGroup(label_colors_grp_menus, MenuColorItems(nil),
  121. ColorGroup(label_colors_grp_desktop, DesktopColorItems(nil),
  122. ColorGroup(label_colors_grp_dialogs, DialogColorItems(dpGrayDialog,nil),
  123. from fpmopts.inc
  124. procedure TIDEApp.Colors;
  125. var D: PColorDialog;
  126. begin
  127. New(D, Init(AppPalette,
  128. ColorGroup(label_colors_grp_browser,
  129. ColorItem(label_colors_framepassive , 215,
  130. ColorItem(label_colors_frameactive , 216,
  131. ColorItem(label_colors_frameicon , 217,
  132. ColorItem(label_colors_scrollbarpage , 218,
  133. ColorItem(label_colors_scrollbaricons , 219,
  134. ColorItem(label_colors_normaltext , 220,
  135. ColorItem(label_colors_selectedtext , 221,
  136. ColorItem(label_colors_activeitem , 222,
  137. ColorItem(label_colors_inactiveitem , 223,
  138. ColorItem(label_colors_focuseditem , 224,
  139. ColorItem(label_colors_selecteditem , 225,
  140. ColorItem(label_colors_divider , 226,
  141. nil)))))))))))),
  142. ColorGroup(label_colors_grp_clock,
  143. ColorItem(label_colors_clockview , 227,
  144. nil),
  145. ColorGroup(label_colors_grp_menus, MenuColorItems(nil),
  146. ColorGroup(label_colors_grp_desktop, DesktopColorItems(nil),
  147. ColorGroup(label_colors_grp_dialogs, DialogColorItems(dpGrayDialog,nil),
  148. ColorGroup(label_colors_grp_editor,
  149. ColorItem(label_colors_framepassive , 167,
  150. ColorItem(label_colors_frameactive , 168,
  151. ColorItem(label_colors_frameicon , 169,
  152. ColorItem(label_colors_scrollbarpage , 170,
  153. ColorItem(label_colors_scrollbaricons , 171,
  154. ColorItem(label_colors_normaltext , 199,
  155. ColorItem(label_colors_selectedtext , 208,
  156. ColorItem(label_colors_highlighcolumn , 209,
  157. ColorItem(label_colors_highlightrow , 210,
  158. ColorItem(label_colors_errormessages , 214,
  159. nil)))))))))),
  160. ColorGroup(label_colors_grp_help,
  161. ColorItem(label_colors_framepassive , 128,
  162. ColorItem(label_colors_frameactive , 129,
  163. ColorItem(label_colors_frameicon , 130,
  164. ColorItem(label_colors_scrollbarpage , 131,
  165. ColorItem(label_colors_scrollbaricons , 132,
  166. ColorItem(label_colors_helptext , 160,
  167. ColorItem(label_colors_helplinks , 161,
  168. ColorItem(label_colors_selectedlink , 162,
  169. ColorItem(label_colors_selectedtext , 163,
  170. ColorItem(label_colors_html_heading1 , 229,
  171. ColorItem(label_colors_html_heading2 , 230,
  172. ColorItem(label_colors_html_heading3 , 231,
  173. ColorItem(label_colors_html_heading4 , 232,
  174. ColorItem(label_colors_html_heading5 , 233,
  175. ColorItem(label_colors_html_heading6 , 234,
  176. nil))))))))))))))),
  177. ColorGroup(label_colors_grp_menus, MenuColorItems(nil),
  178. ColorGroup(label_colors_grp_syntax,
  179. ColorItem(label_colors_whitespace , 200,
  180. ColorItem(label_colors_comments , 201,
  181. ColorItem(label_colors_reservedwords , 202,
  182. ColorItem(label_colors_identifiers , 203,
  183. ColorItem(label_colors_strings , 204,
  184. ColorItem(label_colors_numbers , 205,
  185. ColorItem(label_colors_hexnumbers , 212,
  186. ColorItem(label_colors_assembler , 206,
  187. ColorItem(label_colors_symbols , 207,
  188. ColorItem(label_colors_directives , 211,
  189. ColorItem(label_colors_tabs , 213,
  190. nil))))))))))),
  191. nil))))))))));
  192. end;
  193. fvconsts.pas: idColorSelector = 92;
  194. fvconsts.pas: idMonoSelector = 93;
  195. }