From 0f6162b2a8cf79578c713e71b30c3098dc9f9185 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Mon, 24 Aug 2015 20:08:06 +0000 Subject: [PATCH] ColorPalette: Fix demo (Colornames in LblMouseColorInfo not changing). git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4290 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/colorpalette/demo/unit1.pas | 27 ++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/components/colorpalette/demo/unit1.pas b/components/colorpalette/demo/unit1.pas index fdcb981e1..219ea6457 100644 --- a/components/colorpalette/demo/unit1.pas +++ b/components/colorpalette/demo/unit1.pas @@ -88,7 +88,7 @@ type private { private declarations } procedure EditCurColor; - procedure SetColorInfo(ALabel: TLabel; ATitle: string; AColor: TColor); + procedure SetColorInfo(ALabel: TLabel; ATitle: string; AIndex: Integer); procedure UpdateCaption; procedure UpdatePalette; public @@ -147,7 +147,7 @@ begin ColorSample.Brush.Style := bsClear else ColorSample.Brush.Style := bsSolid; UpdateCaption; - SetColorInfo(LblColorInfo, 'Current', Colors[SelectedIndex]); + SetColorInfo(LblColorInfo, 'Current', SelectedIndex); end; end; @@ -244,7 +244,7 @@ begin ColorPalette.Colors[ColorPalette.SelectedIndex] := Color; ColorSample.Brush.Color := Color; ColorSample.Brush.Style := bsSolid; - SetColorInfo(LblColorInfo, 'Current', Color); + SetColorInfo(LblColorInfo, 'Current', ColorPalette.SelectedIndex); with BtnEditColor do begin Caption := 'Edit'; @@ -281,7 +281,7 @@ begin if MouseColorSample.Brush.Color = clNone then MouseColorSample.Brush.Style := bsClear else MouseColorSample.Brush.Style := bsSolid; - SetColorInfo(LblMouseColorInfo, 'MouseColor', MouseColorSample.Brush.Color); + SetColorInfo(LblMouseColorInfo, 'MouseColor', ColorPalette.MouseIndex); end; procedure TMainForm.ColorPaletteSelectColor(Sender: TObject; AColor: TColor); @@ -290,7 +290,7 @@ begin if AColor = clNone then ColorSample.Brush.Style := bsClear else ColorSample.Brush.Style := bsSolid; - SetColorInfo(LblColorInfo, 'SelectedColor', AColor); + SetColorInfo(LblColorInfo, 'SelectedColor', ColorPalette.SelectedIndex); BtnDeleteColor.Caption := 'Delete color #' + IntToStr(ColorPalette.SelectedIndex); UpdateCaption; end; @@ -331,7 +331,7 @@ begin begin BtnEditColor.caption := 'Update >'; BtnEditColor.hint := 'Update palette'; - SetColorInfo(LblColorInfo, 'New color', ColorSample.Brush.Color); + SetColorInfo(LblColorInfo, 'New color', ColorPalette.SelectedIndex); end; end; @@ -348,7 +348,7 @@ begin EdBoxSize.Value := ColorPalette.ButtonWidth; ColorSample.Brush.Color := ColorPalette.SelectedColor; - SetColorInfo(LblColorInfo, 'Current', ColorPalette.SelectedColor); + SetColorInfo(LblColorInfo, 'Current', ColorPalette.SelectedIndex); UpdateCaption; { ColorPalette.PickShift must contain ssRight in order to be able to select @@ -368,9 +368,12 @@ begin BtnEditColorClick(self); end; -procedure TMainForm.SetColorInfo(ALabel: TLabel; ATitle: string; AColor: TColor); +procedure TMainForm.SetColorInfo(ALabel: TLabel; ATitle: string; AIndex: Integer); +var + C: TColor; begin - if AColor = clNone then + C := ColorPalette.Colors[AIndex]; + if C = clNone then ALabel.Caption := Format( '%s: None', [ATitle] ) @@ -380,8 +383,8 @@ begin ' red = %d'#13+ ' green = %d'#13+ ' blue = %d', [ - ATitle, ColorPalette.ColorNames[ColorPalette.SelectedIndex], - Red(AColor), Green(AColor), Blue(AColor) + ATitle, ColorPalette.ColorNames[AIndex], + Red(C), Green(C), Blue(C) ]); end; @@ -395,7 +398,7 @@ end; procedure TMainForm.UpdatePalette; begin ColorPalette.Colors[ColorPalette.SelectedIndex] := ColorSample.Brush.Color; - SetColorInfo(LblColorInfo, 'Current', ColorSample.Brush.Color); + SetColorInfo(LblColorInfo, 'Current', ColorPalette.SelectedIndex); with BtnEditColor do begin Caption := 'Edit';