colorsel.pas 7.2 KB

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