diff options
author | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2008-03-24 13:42:48 +0000 |
---|---|---|
committer | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2008-03-24 13:42:48 +0000 |
commit | 529d90f24a75126e3db72283cbaf9612be76b3fb (patch) | |
tree | 2b60efef73ff9b76a7c5f6913ff3e0cb377fb33c | |
parent | 5a9025391a90f6c66a38436c74e7de88efd68621 (diff) | |
download | fpGUI-529d90f24a75126e3db72283cbaf9612be76b3fb.tar.xz |
* More improvements to the ColorListBox component.
* Created a new Color ListBox example project.
-rw-r--r-- | examples/gui/colorlistbox/colorlistboxtest.lpi | 62 | ||||
-rw-r--r-- | examples/gui/colorlistbox/colorlistboxtest.lpr | 30 | ||||
-rw-r--r-- | examples/gui/colorlistbox/extrafpc.cfg | 5 | ||||
-rw-r--r-- | examples/gui/colorlistbox/frmMain.pas | 204 | ||||
-rw-r--r-- | src/gui/fpgui_package.pas | 11 | ||||
-rw-r--r-- | src/gui/gui_listbox.pas | 238 |
6 files changed, 521 insertions, 29 deletions
diff --git a/examples/gui/colorlistbox/colorlistboxtest.lpi b/examples/gui/colorlistbox/colorlistboxtest.lpi new file mode 100644 index 00000000..2e83aa6d --- /dev/null +++ b/examples/gui/colorlistbox/colorlistboxtest.lpi @@ -0,0 +1,62 @@ +<?xml version="1.0"?> +<CONFIG> + <ProjectOptions> + <PathDelim Value="/"/> + <Version Value="6"/> + <General> + <Flags> + <SaveOnlyProjectUnits Value="True"/> + </Flags> + <SessionStorage Value="InProjectDir"/> + <MainUnit Value="0"/> + <IconPath Value="./"/> + <TargetFileExt Value=""/> + <Title Value="colorlistboxtest"/> + </General> + <VersionInfo> + <ProjectVersion Value=""/> + </VersionInfo> + <PublishOptions> + <Version Value="2"/> + <IgnoreBinaries Value="False"/> + <IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/> + <ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/> + </PublishOptions> + <RunParams> + <local> + <FormatVersion Value="1"/> + <LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/> + </local> + </RunParams> + <RequiredPackages Count="1"> + <Item1> + <PackageName Value="fpgui_package"/> + </Item1> + </RequiredPackages> + <Units Count="2"> + <Unit0> + <Filename Value="colorlistboxtest.lpr"/> + <IsPartOfProject Value="True"/> + <UnitName Value="colorlistboxtest"/> + </Unit0> + <Unit1> + <Filename Value="frmMain.pas"/> + <IsPartOfProject Value="True"/> + <UnitName Value="frmMain"/> + </Unit1> + </Units> + </ProjectOptions> + <CompilerOptions> + <Version Value="5"/> + <CodeGeneration> + <Generate Value="Faster"/> + </CodeGeneration> + <Linking> + <LinkSmart Value="True"/> + </Linking> + <Other> + <CustomOptions Value="-FUunits"/> + <CompilerPath Value="$(CompPath)"/> + </Other> + </CompilerOptions> +</CONFIG> diff --git a/examples/gui/colorlistbox/colorlistboxtest.lpr b/examples/gui/colorlistbox/colorlistboxtest.lpr new file mode 100644 index 00000000..6bea991c --- /dev/null +++ b/examples/gui/colorlistbox/colorlistboxtest.lpr @@ -0,0 +1,30 @@ +program colorlistboxtest; + +{$mode objfpc}{$H+} + +uses + {$IFDEF UNIX}{$IFDEF UseCThreads} + cthreads, + {$ENDIF}{$ENDIF} + Classes, fpgfx, frmMain; + + +procedure MainProc; +var + frm: TMainForm; +begin + fpgApplication.Initialize; + frm := TMainForm.Create(nil); + try + frm.Show; + fpgApplication.Run; + finally + frm.Free; + end; +end; + +begin + MainProc; +end. + + diff --git a/examples/gui/colorlistbox/extrafpc.cfg b/examples/gui/colorlistbox/extrafpc.cfg new file mode 100644 index 00000000..073dc4b6 --- /dev/null +++ b/examples/gui/colorlistbox/extrafpc.cfg @@ -0,0 +1,5 @@ +-FUunits +-Fu../../../lib +-Xs +-XX +-CX diff --git a/examples/gui/colorlistbox/frmMain.pas b/examples/gui/colorlistbox/frmMain.pas new file mode 100644 index 00000000..7fbe0327 --- /dev/null +++ b/examples/gui/colorlistbox/frmMain.pas @@ -0,0 +1,204 @@ +unit frmMain; + +{$mode objfpc}{$H+} + +interface + +uses + SysUtils, Classes, gfxbase, fpgfx, gui_edit, + gfx_widget, gui_form, gui_label, gui_button, + gui_listbox, gui_memo, gui_combobox, gui_grid, + gui_dialogs, gui_checkbox, gui_tree, gui_trackbar, + gui_progressbar, gui_radiobutton, gui_tab, gui_menu, + gui_bevel, gui_popupcalendar, gui_gauge, gui_editcombo; + +type + + TMainForm = class(TfpgForm) + private + procedure chkColorNameChange(Sender: TObject); + procedure cbName1Change(Sender: TObject); + procedure btnName1Clicked(Sender: TObject); + procedure SetBGColor(Sender: TObject); + procedure PopulatePaletteColorCombo; + public + {@VFD_HEAD_BEGIN: MainForm} + cbName1: TfpgComboBox; + lblName4: TfpgLabel; + btnName1: TfpgButton; + lbColorPick: TfpgColorListBox; + btnName2: TfpgButton; + btnName3: TfpgButton; + btnName4: TfpgButton; + lblName1: TfpgLabel; + chkColorName: TfpgCheckBox; + {@VFD_HEAD_END: MainForm} + procedure AfterCreate; override; + end; + + + +{@VFD_NEWFORM_DECL} + +implementation + +uses + TypInfo; + +{@VFD_NEWFORM_IMPL} + +procedure TMainForm.chkColorNameChange(Sender: TObject); +begin + lbColorPick.ShowColorNames := chkColorName.Checked; +end; + +procedure TMainForm.cbName1Change(Sender: TObject); +begin + if cbName1.Text = 'cpStandardColors' then + lbColorPick.ColorPalette := cpStandardColors + else if cbName1.Text = 'cpSystemColors' then + lbColorPick.ColorPalette := cpSystemColors + else + lbColorPick.ColorPalette := cpWebColors; +end; + +procedure TMainForm.btnName1Clicked (Sender: TObject ); +begin + BackgroundColor := lbColorPick.Color; +end; + +procedure TMainForm.SetBGColor (Sender: TObject ); +begin + lbColorPick.Color := TfpgButton(Sender).BackgroundColor; + lbColorPick.SetFocus; +end; + +procedure TMainForm.PopulatePaletteColorCombo; +var + TypeData: PTypeData; + I: Integer; + S: string; +begin + cbName1.Items.Clear; + cbName1.Items.Add('cpStandardColors'); + cbName1.Items.Add('cpSystemColors'); + cbName1.Items.Add('cpWebColors'); + cbName1.FocusItem := 1; + cbName1.OnChange := @cbName1Change; +end; + +procedure TMainForm.AfterCreate; +begin + {@VFD_BODY_BEGIN: MainForm} + Name := 'MainForm'; + SetPosition(286, 264, 413, 250); + WindowTitle := 'Color ListBox Test'; + WindowPosition := wpScreenCenter; + + cbName1 := TfpgComboBox.Create(self); + with cbName1 do + begin + Name := 'cbName1'; + SetPosition(12, 36, 172, 22); + FontDesc := '#List'; + end; + + lblName4 := TfpgLabel.Create(self); + with lblName4 do + begin + Name := 'lblName4'; + SetPosition(12, 16, 168, 16); + FontDesc := '#Label1'; + Text := 'Predefined Color Palettes'; + end; + + btnName1 := TfpgButton.Create(self); + with btnName1 do + begin + Name := 'btnName1'; + SetPosition(12, 180, 171, 24); + Text := 'Set Form.Background'; + FontDesc := '#Label1'; + ImageName := ''; + TabOrder := 7; + OnClick := @btnName1Clicked; + end; + + lbColorPick := TfpgColorListBox.Create(self); + with lbColorPick do + begin + Name := 'lbColorPick'; + SetPosition(216, 20, 184, 148); + end; + + btnName2 := TfpgButton.Create(self); + with btnName2 do + begin + Name := 'btnName2'; + SetPosition(12, 96, 24, 24); + Text := ''; + Embedded := True; + FontDesc := '#Label1'; + ImageName := ''; + TabOrder := 9; + BackgroundColor := clBlue; + OnClick := @SetBGColor; + end; + + btnName3 := TfpgButton.Create(self); + with btnName3 do + begin + Name := 'btnName3'; + SetPosition(44, 96, 24, 24); + Text := ''; + Embedded := True; + FontDesc := '#Label1'; + ImageName := ''; + TabOrder := 10; + BackgroundColor := clPurple; + OnClick := @SetBGColor; + end; + + btnName4 := TfpgButton.Create(self); + with btnName4 do + begin + Name := 'btnName4'; + SetPosition(76, 96, 24, 24); + Text := ''; + Embedded := True; + FontDesc := '#Label1'; + ImageName := ''; + TabOrder := 11; + BackgroundColor := clSteelBlue; + OnClick := @SetBGColor; + end; + + lblName1 := TfpgLabel.Create(self); + with lblName1 do + begin + Name := 'lblName1'; + SetPosition(12, 76, 164, 16); + FontDesc := '#Label1'; + Text := 'Set FocusItem Color'; + end; + + chkColorName := TfpgCheckBox.Create(self); + with chkColorName do + begin + Name := 'chkColorName'; + SetPosition(12, 140, 164, 20); + Checked := True; + FontDesc := '#Label1'; + TabOrder := 8; + Text := 'Show Color Names'; + OnChange := @chkColorNameChange; + end; + + {@VFD_BODY_END: MainForm} + PopulatePaletteColorCombo; + +end; + + + +end. diff --git a/src/gui/fpgui_package.pas b/src/gui/fpgui_package.pas index 46ff405f..964bea47 100644 --- a/src/gui/fpgui_package.pas +++ b/src/gui/fpgui_package.pas @@ -7,11 +7,12 @@ unit fpgui_package; interface uses - gui_button, gui_combobox, gui_dialogs, gui_edit, gui_form, gui_label, gui_listbox, - gui_memo, gui_scrollbar, gui_bevel, gui_checkbox, gui_radiobutton, gui_trackbar, - gui_tab, gui_basegrid, gui_listview, gui_customgrid, gui_progressbar, gui_menu, - gui_style, gui_grid, gui_tree, gui_iniutils, gui_mru, fpgui_db, gui_popupcalendar, - gui_gauge, gui_editcombo; + gui_button, gui_combobox, gui_dialogs, gui_edit, gui_form, gui_label, + gui_listbox, gui_memo, gui_scrollbar, gui_bevel, gui_checkbox, + gui_radiobutton, gui_trackbar, gui_tab, gui_basegrid, gui_listview, + gui_customgrid, gui_progressbar, gui_menu, gui_style, gui_grid, gui_tree, + gui_iniutils, gui_mru, fpgui_db, gui_popupcalendar, gui_gauge, + gui_editcombo; implementation diff --git a/src/gui/gui_listbox.pas b/src/gui/gui_listbox.pas index 298b998f..265649fb 100644 --- a/src/gui/gui_listbox.pas +++ b/src/gui/gui_listbox.pas @@ -26,6 +26,7 @@ unit gui_listbox; * Only surface properties as published in TfpgListBox * Implement .BeginUpdate and .EndUpdate methods so we know when to refresh the items list. + * Color Listbox: User Defined color palette support. } interface @@ -141,15 +142,19 @@ type end; - TfpgColorPalette = (cpStandardColors, cpSystemColors, cpWebColors); + TfpgColorPalette = (cpStandardColors, cpSystemColors, cpWebColors, cpUserDefined); - TfpgColorListBox = class(TfpgBaseListBox) + TfpgBaseColorListBox = class(TfpgBaseListBox) private FColorBoxWidth: TfpgCoord; FColorBoxHeight: TfpgCoord; FColorPalette: TfpgColorPalette; - procedure SetColorPalette (const AValue: TfpgColorPalette ); + FShowColorNames: Boolean; + function GetColor: TfpgColor; + procedure SetColor(const AValue: TfpgColor); + procedure SetColorPalette(const AValue: TfpgColorPalette); + procedure SetShowColorNames (const AValue: Boolean ); procedure SetupColorPalette; procedure FreeAndClearColors; protected @@ -157,12 +162,31 @@ type procedure DrawItem(num: integer; rect: TfpgRect; flags: integer); override; // procedure HandleKeyChar(var AText: TfpgChar; var shiftstate: TShiftState; var consumed: boolean); override; property Items: TList read FItems; + property Color: TfpgColor read GetColor write SetColor; + property ColorPalette: TfpgColorPalette read FColorPalette write SetColorPalette; + property ShowColorNames: Boolean read FShowColorNames write SetShowColorNames default True; public constructor Create(AOwner: TComponent); override; destructor Destroy; override; function ItemCount: integer; override; - function Color: TfpgColor; - property ColorPalette: TfpgColorPalette read FColorPalette write SetColorPalette; + + end; + + + TfpgColorListBox = class(TfpgBaseColorListBox) + published + property AutoHeight; + property BackgroundColor default clListBox; + property Color; + property ColorPalette; + property FocusItem; + property FontDesc; + property HotTrack; + property Items; + property PopupFrame; + property ShowColorNames; + property TabOrder; + property TextColor; end; @@ -756,18 +780,47 @@ begin ColorValue := AColorValue; end; -{ TfpgColorListBox } +{ TfpgBaseColorListBox } -procedure TfpgColorListBox.SetColorPalette (const AValue: TfpgColorPalette ); +procedure TfpgBaseColorListBox.SetColorPalette (const AValue: TfpgColorPalette ); begin if FColorPalette = AValue then - exit; + Exit; FColorPalette := AValue; SetupColorPalette; -// Repaint; + RePaint; +end; + +procedure TfpgBaseColorListBox.SetShowColorNames (const AValue: Boolean ); +begin + if FShowColorNames = AValue then + Exit; + FShowColorNames := AValue; + Repaint; +end; + +function TfpgBaseColorListBox.GetColor: TfpgColor; +begin + Result := TColorItem(FItems.Items[FocusItem-1]).ColorValue; +end; + +procedure TfpgBaseColorListBox.SetColor(const AValue: TfpgColor); +var + i: integer; +begin + if GetColor = AValue then + Exit; + for i := 0 to FItems.Count-1 do + begin + if TColorItem(FItems.Items[i]).ColorValue = AValue then + begin + FocusItem := i+1; + Exit; + end; + end; end; -procedure TfpgColorListBox.SetupColorPalette; +procedure TfpgBaseColorListBox.SetupColorPalette; begin FreeAndClearColors; @@ -829,15 +882,155 @@ begin cpWebColors: begin { TODO : Need to add the web colors } - FItems.Add(TColorItem.Create('clRed', clRed)); - FItems.Add(TColorItem.Create('clGreen', clGreen)); - FItems.Add(TColorItem.Create('clBlue', clBlue)); + FItems.Add(TColorItem.Create('clAliceBlue', clAliceBlue)); + FItems.Add(TColorItem.Create('clAntiqueWhite', clAntiqueWhite)); + FItems.Add(TColorItem.Create('clAqua', clAqua)); + FItems.Add(TColorItem.Create('clAquamarine', clAquamarine)); + FItems.Add(TColorItem.Create('clAzure', clAzure)); + FItems.Add(TColorItem.Create('clBeige', clBeige)); + FItems.Add(TColorItem.Create('clBisque', clBisque)); FItems.Add(TColorItem.Create('clBlack', clBlack)); + FItems.Add(TColorItem.Create('clBlanchedAlmond', clBlanchedAlmond)); + FItems.Add(TColorItem.Create('clBlue', clBlue)); + FItems.Add(TColorItem.Create('clBlueViolet', clBlueViolet)); + FItems.Add(TColorItem.Create('clBrown', clBrown)); + FItems.Add(TColorItem.Create('clBurlyWood', clBurlyWood)); + FItems.Add(TColorItem.Create('clCadetBlue', clCadetBlue)); + FItems.Add(TColorItem.Create('clChartreuse', clChartreuse)); + FItems.Add(TColorItem.Create('clChocolate', clChocolate)); + FItems.Add(TColorItem.Create('clCoral', clCoral)); + FItems.Add(TColorItem.Create('clCornflowerBlue', clCornflowerBlue)); + FItems.Add(TColorItem.Create('clCornsilk', clCornsilk)); + FItems.Add(TColorItem.Create('clCrimson', clCrimson)); + FItems.Add(TColorItem.Create('clCyan', clCyan)); + FItems.Add(TColorItem.Create('clDarkBlue', clDarkBlue)); + FItems.Add(TColorItem.Create('clDarkCyan', clDarkCyan)); + FItems.Add(TColorItem.Create('clDarkGoldenrod', clDarkGoldenrod)); + FItems.Add(TColorItem.Create('clDarkGray', clDarkGray)); + FItems.Add(TColorItem.Create('clDarkGreen', clDarkGreen)); + FItems.Add(TColorItem.Create('clDarkKhaki', clDarkKhaki)); + FItems.Add(TColorItem.Create('clDarkMagenta', clDarkMagenta)); + FItems.Add(TColorItem.Create('clDarkOliveGreen', clDarkOliveGreen)); + FItems.Add(TColorItem.Create('clDarkOrange', clDarkOrange)); + FItems.Add(TColorItem.Create('clDarkOrchid', clDarkOrchid)); + FItems.Add(TColorItem.Create('clDarkRed', clDarkRed)); + FItems.Add(TColorItem.Create('clDarkSalmon', clDarkSalmon)); + FItems.Add(TColorItem.Create('clDarkSeaGreen', clDarkSeaGreen)); + FItems.Add(TColorItem.Create('clDarkSlateBlue', clDarkSlateBlue)); + FItems.Add(TColorItem.Create('clDarkSlateGray', clDarkSlateGray)); + FItems.Add(TColorItem.Create('clDarkTurquoise', clDarkTurquoise)); + FItems.Add(TColorItem.Create('clDarkViolet', clDarkViolet)); + FItems.Add(TColorItem.Create('clDeepPink', clDeepPink)); + FItems.Add(TColorItem.Create('clDeepSkyBlue', clDeepSkyBlue)); + FItems.Add(TColorItem.Create('clDimGray',clDimGray )); + FItems.Add(TColorItem.Create('clDodgerBlue', clDodgerBlue)); + FItems.Add(TColorItem.Create('clFireBrick', clFireBrick)); + FItems.Add(TColorItem.Create('clFloralWhite', clFloralWhite)); + FItems.Add(TColorItem.Create('clForestGreen', clForestGreen)); + FItems.Add(TColorItem.Create('clFuchsia', clFuchsia)); + FItems.Add(TColorItem.Create('clGainsboro', clGainsboro)); + FItems.Add(TColorItem.Create('clGhostWhite', clGhostWhite)); + FItems.Add(TColorItem.Create('clGold', clGold)); + FItems.Add(TColorItem.Create('clGoldenrod', clGoldenrod)); + FItems.Add(TColorItem.Create('clGray', clGray)); + FItems.Add(TColorItem.Create('clGreen', clGreen)); + FItems.Add(TColorItem.Create('clGreenYellow', clGreenYellow)); + FItems.Add(TColorItem.Create('clHoneydew', clHoneydew)); + FItems.Add(TColorItem.Create('clHotPink', clHotPink)); + FItems.Add(TColorItem.Create('clIndianRed', clIndianRed)); + FItems.Add(TColorItem.Create('clIndigo', clIndigo)); + FItems.Add(TColorItem.Create('clIvory', clIvory)); + FItems.Add(TColorItem.Create('clKhaki', clKhaki)); + FItems.Add(TColorItem.Create('clLavender', clLavender)); + FItems.Add(TColorItem.Create('clLavenderBlush', clLavenderBlush)); + FItems.Add(TColorItem.Create('clLawnGreen', clLawnGreen)); + FItems.Add(TColorItem.Create('clLemonChiffon', clLemonChiffon)); + FItems.Add(TColorItem.Create('clLightBlue', clLightBlue)); + FItems.Add(TColorItem.Create('clLightCoral', clLightCoral)); + FItems.Add(TColorItem.Create('clLightCyan', clLightCyan)); + FItems.Add(TColorItem.Create('clLightGoldenrodYellow', clLightGoldenrodYellow)); + FItems.Add(TColorItem.Create('clLightGreen', clLightGreen)); + FItems.Add(TColorItem.Create('clLightGrey', clLightGrey)); + FItems.Add(TColorItem.Create('clLightPink', clLightPink)); + FItems.Add(TColorItem.Create('clLightSalmon', clLightSalmon)); + FItems.Add(TColorItem.Create('clLightSeaGreen', clLightSeaGreen)); + FItems.Add(TColorItem.Create('clLightSkyBlue', clLightSkyBlue)); + FItems.Add(TColorItem.Create('clLightSlateGray', clLightSlateGray)); + FItems.Add(TColorItem.Create('clLightSteelBlue', clLightSteelBlue)); + FItems.Add(TColorItem.Create('clLightYellow', clLightYellow)); + FItems.Add(TColorItem.Create('clLime', clLime)); + FItems.Add(TColorItem.Create('clLimeGreen', clLimeGreen)); + FItems.Add(TColorItem.Create('clLinen', clLinen)); + FItems.Add(TColorItem.Create('clMagenta', clMagenta)); + FItems.Add(TColorItem.Create('clMaroon', clMaroon)); + FItems.Add(TColorItem.Create('clMediumAquamarine', clMediumAquamarine)); + FItems.Add(TColorItem.Create('clMediumBlue', clMediumBlue)); + FItems.Add(TColorItem.Create('clMediumOrchid', clMediumOrchid)); + FItems.Add(TColorItem.Create('clMediumPurple', clMediumPurple)); + FItems.Add(TColorItem.Create('clMediumSeaGreen', clMediumSeaGreen)); + FItems.Add(TColorItem.Create('clMediumSlateBlue', clMediumSlateBlue)); + FItems.Add(TColorItem.Create('clMediumSpringGreen', clMediumSpringGreen)); + FItems.Add(TColorItem.Create('clMediumTurquoise', clMediumTurquoise)); + FItems.Add(TColorItem.Create('clMediumVioletRed', clMediumVioletRed)); + FItems.Add(TColorItem.Create('clMidnightBlue', clMidnightBlue)); + FItems.Add(TColorItem.Create('clMintCream', clMintCream)); + FItems.Add(TColorItem.Create('clMistyRose', clMistyRose)); + FItems.Add(TColorItem.Create('clMoccasin', clMoccasin)); + FItems.Add(TColorItem.Create('clNavajoWhite', clNavajoWhite)); + FItems.Add(TColorItem.Create('clNavy', clNavy)); + FItems.Add(TColorItem.Create('clOldLace', clOldLace)); + FItems.Add(TColorItem.Create('clOlive', clOlive)); + FItems.Add(TColorItem.Create('clOliveDrab', clOliveDrab)); + FItems.Add(TColorItem.Create('clOrange', clOrange)); + FItems.Add(TColorItem.Create('clOrangeRed', clOrangeRed)); + FItems.Add(TColorItem.Create('clOrchid', clOrchid)); + FItems.Add(TColorItem.Create('clPaleGoldenrod', clPaleGoldenrod)); + FItems.Add(TColorItem.Create('clPaleGreen', clPaleGreen)); + FItems.Add(TColorItem.Create('clPaleTurquoise', clPaleTurquoise)); + FItems.Add(TColorItem.Create('clPaleVioletRed', clPaleVioletRed)); + FItems.Add(TColorItem.Create('clPaleBlue',clPaleBlue )); + FItems.Add(TColorItem.Create('clPapayaWhip', clPapayaWhip)); + FItems.Add(TColorItem.Create('clPeachPuff',clPeachPuff )); + FItems.Add(TColorItem.Create('clPeru', clPeru)); + FItems.Add(TColorItem.Create('clPink', clPink)); + FItems.Add(TColorItem.Create('clPlum', clPlum)); + FItems.Add(TColorItem.Create('clPowderBlue', clPowderBlue)); + FItems.Add(TColorItem.Create('clPurple', clPurple)); + FItems.Add(TColorItem.Create('clRed', clRed)); + FItems.Add(TColorItem.Create('clRosyBrown', clRosyBrown)); + FItems.Add(TColorItem.Create('clRoyalBlue', clRoyalBlue)); + FItems.Add(TColorItem.Create('clSaddleBrown', clSaddleBrown)); + FItems.Add(TColorItem.Create('clSalmon', clSalmon)); + FItems.Add(TColorItem.Create('clSandyBrown', clSandyBrown)); + FItems.Add(TColorItem.Create('clSeaGreen', clSeaGreen)); + FItems.Add(TColorItem.Create('clSeashell', clSeashell)); + FItems.Add(TColorItem.Create('clSienna', clSienna)); + FItems.Add(TColorItem.Create('clSilver', clSilver)); + FItems.Add(TColorItem.Create('clSkyBlue2', clSkyBlue2)); + FItems.Add(TColorItem.Create('clSlateBlue', clSlateBlue)); + FItems.Add(TColorItem.Create('clSlateGray', clSlateGray)); + FItems.Add(TColorItem.Create('clSnow', clSnow)); + FItems.Add(TColorItem.Create('clSpringGreen', clSpringGreen)); + FItems.Add(TColorItem.Create('clSteelBlue', clSteelBlue)); + FItems.Add(TColorItem.Create('clTan', clTan)); + FItems.Add(TColorItem.Create('clTeal', clTeal)); + FItems.Add(TColorItem.Create('clThistle', clThistle)); + FItems.Add(TColorItem.Create('clTomato', clTomato)); + FItems.Add(TColorItem.Create('clTurquoise', clTurquoise)); + FItems.Add(TColorItem.Create('clViolet', clViolet)); + FItems.Add(TColorItem.Create('clWheat', clWheat)); + FItems.Add(TColorItem.Create('clWhite', clWhite)); + FItems.Add(TColorItem.Create('clWhiteSmoke', clWhiteSmoke)); + FItems.Add(TColorItem.Create('clYellow', clYellow)); + FItems.Add(TColorItem.Create('clYellowGreen', clYellowGreen)); end; end; + FocusItem := 1; + FollowFocus; + UpdateScrollbar; end; -procedure TfpgColorListBox.FreeAndClearColors; +procedure TfpgBaseColorListBox.FreeAndClearColors; var i: integer; begin @@ -846,7 +1039,7 @@ begin FItems.Clear; end; -procedure TfpgColorListBox.DrawItem (num: integer; rect: TfpgRect; flags: integer ); +procedure TfpgBaseColorListBox.DrawItem (num: integer; rect: TfpgRect; flags: integer ); var itm: TColorItem; begin @@ -859,14 +1052,16 @@ begin Canvas.SetColor(clBlack); Canvas.DrawRectangle(rect.Left + 2, rect.Top + 4, FColorBoxWidth, FColorboxHeight); // color text - fpgStyle.DrawString(Canvas, FColorboxWidth + 8 + rect.left, rect.top+1, itm.ColorName, Enabled); + if FShowColorNames then + fpgStyle.DrawString(Canvas, FColorboxWidth + 8 + rect.left, rect.top+1, itm.ColorName, Enabled); end; -constructor TfpgColorListBox.Create (AOwner: TComponent ); +constructor TfpgBaseColorListBox.Create (AOwner: TComponent ); begin inherited Create (AOwner ); FColorBoxWidth := 35; FColorBoxHeight := 10; + FShowColorNames := True; FItems := TList.Create; // default Delphi colors @@ -874,22 +1069,17 @@ begin SetupColorPalette; end; -destructor TfpgColorListBox.Destroy; +destructor TfpgBaseColorListBox.Destroy; begin FreeAndClearColors; FItems.Free; inherited Destroy; end; -function TfpgColorListBox.ItemCount: integer; +function TfpgBaseColorListBox.ItemCount: integer; begin result := FItems.Count; end; -function TfpgColorListBox.Color: TfpgColor; -begin - Result := TColorItem(FItems.Items[FocusItem]).ColorValue; -end; - end. |