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
This commit is contained in:
wp_xxyyzz 2015-08-24 20:08:06 +00:00
parent ec4cc3f4b3
commit 0f6162b2a8

View File

@ -88,7 +88,7 @@ type
private private
{ private declarations } { private declarations }
procedure EditCurColor; procedure EditCurColor;
procedure SetColorInfo(ALabel: TLabel; ATitle: string; AColor: TColor); procedure SetColorInfo(ALabel: TLabel; ATitle: string; AIndex: Integer);
procedure UpdateCaption; procedure UpdateCaption;
procedure UpdatePalette; procedure UpdatePalette;
public public
@ -147,7 +147,7 @@ begin
ColorSample.Brush.Style := bsClear else ColorSample.Brush.Style := bsClear else
ColorSample.Brush.Style := bsSolid; ColorSample.Brush.Style := bsSolid;
UpdateCaption; UpdateCaption;
SetColorInfo(LblColorInfo, 'Current', Colors[SelectedIndex]); SetColorInfo(LblColorInfo, 'Current', SelectedIndex);
end; end;
end; end;
@ -244,7 +244,7 @@ begin
ColorPalette.Colors[ColorPalette.SelectedIndex] := Color; ColorPalette.Colors[ColorPalette.SelectedIndex] := Color;
ColorSample.Brush.Color := Color; ColorSample.Brush.Color := Color;
ColorSample.Brush.Style := bsSolid; ColorSample.Brush.Style := bsSolid;
SetColorInfo(LblColorInfo, 'Current', Color); SetColorInfo(LblColorInfo, 'Current', ColorPalette.SelectedIndex);
with BtnEditColor do with BtnEditColor do
begin begin
Caption := 'Edit'; Caption := 'Edit';
@ -281,7 +281,7 @@ begin
if MouseColorSample.Brush.Color = clNone then if MouseColorSample.Brush.Color = clNone then
MouseColorSample.Brush.Style := bsClear else MouseColorSample.Brush.Style := bsClear else
MouseColorSample.Brush.Style := bsSolid; MouseColorSample.Brush.Style := bsSolid;
SetColorInfo(LblMouseColorInfo, 'MouseColor', MouseColorSample.Brush.Color); SetColorInfo(LblMouseColorInfo, 'MouseColor', ColorPalette.MouseIndex);
end; end;
procedure TMainForm.ColorPaletteSelectColor(Sender: TObject; AColor: TColor); procedure TMainForm.ColorPaletteSelectColor(Sender: TObject; AColor: TColor);
@ -290,7 +290,7 @@ begin
if AColor = clNone then if AColor = clNone then
ColorSample.Brush.Style := bsClear else ColorSample.Brush.Style := bsClear else
ColorSample.Brush.Style := bsSolid; ColorSample.Brush.Style := bsSolid;
SetColorInfo(LblColorInfo, 'SelectedColor', AColor); SetColorInfo(LblColorInfo, 'SelectedColor', ColorPalette.SelectedIndex);
BtnDeleteColor.Caption := 'Delete color #' + IntToStr(ColorPalette.SelectedIndex); BtnDeleteColor.Caption := 'Delete color #' + IntToStr(ColorPalette.SelectedIndex);
UpdateCaption; UpdateCaption;
end; end;
@ -331,7 +331,7 @@ begin
begin begin
BtnEditColor.caption := 'Update >'; BtnEditColor.caption := 'Update >';
BtnEditColor.hint := 'Update palette'; BtnEditColor.hint := 'Update palette';
SetColorInfo(LblColorInfo, 'New color', ColorSample.Brush.Color); SetColorInfo(LblColorInfo, 'New color', ColorPalette.SelectedIndex);
end; end;
end; end;
@ -348,7 +348,7 @@ begin
EdBoxSize.Value := ColorPalette.ButtonWidth; EdBoxSize.Value := ColorPalette.ButtonWidth;
ColorSample.Brush.Color := ColorPalette.SelectedColor; ColorSample.Brush.Color := ColorPalette.SelectedColor;
SetColorInfo(LblColorInfo, 'Current', ColorPalette.SelectedColor); SetColorInfo(LblColorInfo, 'Current', ColorPalette.SelectedIndex);
UpdateCaption; UpdateCaption;
{ ColorPalette.PickShift must contain ssRight in order to be able to select { ColorPalette.PickShift must contain ssRight in order to be able to select
@ -368,9 +368,12 @@ begin
BtnEditColorClick(self); BtnEditColorClick(self);
end; end;
procedure TMainForm.SetColorInfo(ALabel: TLabel; ATitle: string; AColor: TColor); procedure TMainForm.SetColorInfo(ALabel: TLabel; ATitle: string; AIndex: Integer);
var
C: TColor;
begin begin
if AColor = clNone then C := ColorPalette.Colors[AIndex];
if C = clNone then
ALabel.Caption := Format( ALabel.Caption := Format(
'%s: None', [ATitle] '%s: None', [ATitle]
) )
@ -380,8 +383,8 @@ begin
' red = %d'#13+ ' red = %d'#13+
' green = %d'#13+ ' green = %d'#13+
' blue = %d', [ ' blue = %d', [
ATitle, ColorPalette.ColorNames[ColorPalette.SelectedIndex], ATitle, ColorPalette.ColorNames[AIndex],
Red(AColor), Green(AColor), Blue(AColor) Red(C), Green(C), Blue(C)
]); ]);
end; end;
@ -395,7 +398,7 @@ end;
procedure TMainForm.UpdatePalette; procedure TMainForm.UpdatePalette;
begin begin
ColorPalette.Colors[ColorPalette.SelectedIndex] := ColorSample.Brush.Color; ColorPalette.Colors[ColorPalette.SelectedIndex] := ColorSample.Brush.Color;
SetColorInfo(LblColorInfo, 'Current', ColorSample.Brush.Color); SetColorInfo(LblColorInfo, 'Current', ColorPalette.SelectedIndex);
with BtnEditColor do with BtnEditColor do
begin begin
Caption := 'Edit'; Caption := 'Edit';