-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcolorframe1.pas
95 lines (77 loc) · 2.66 KB
/
colorframe1.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
{==============================================================================}
{ Copyright (c) 2010, 2011, 2012 by Donald R. Ziesig. All Rights Reserved. }
{==============================================================================}
{ This file is part of MagicWebsiteBuilder. }
{ }
{ MagicWebsiteBuilder is free software: you can redistribute it and/or modify }
{ it under the terms of the GNU General Public License as published by }
{ the Free Software Foundation, either version 3 of the License, or }
{ (at your option) any later version. }
{ }
{ MagicWebsiteBuilder is distributed in the hope that it will be useful, }
{ but WITHOUT ANY WARRANTY; without even the implied warranty of }
{ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the }
{ GNU General Public License for more details. }
{ }
{ You should have received a copy of the GNU General Public License }
{ along with MagicWebsiteBuilder in file COPYING. If not, see }
{ <http://www.gnu.org/licenses/>. }
{==============================================================================}
unit ColorFrame1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, StdCtrls, ExtCtrls, Dialogs;
type
{ TColorFrame }
TColorChange = procedure( var NewColor : Integer ) of object;
TColorFrame = class(TFrame)
ColorDialog1: TColorDialog;
ColorEdit: TLabeledEdit;
Panel1: TPanel;
procedure ColorEditExit(Sender: TObject);
procedure Panel1Click(Sender: TObject);
private
fColorChange : TColorChange;
function GetColor: Integer;
procedure SetColor(const AValue: Integer);
{ private declarations }
public
{ public declarations }
property Color : Integer read GetColor write SetColor;
property OnColorChange : TColorChange read fColorChange write fColorChange;
end;
implementation
uses
StrUtils;
{$R *.lfm}
{ TColorFrame }
procedure TColorFrame.ColorEditExit(Sender: TObject);
var
C : Integer;
begin
Color := Hex2Dec( ColorEdit.Text );
C := Color;
if Assigned(fColorChange) then OnColorChange( C );
end;
procedure TColorFrame.Panel1Click(Sender: TObject);
var
C : Integer;
begin
if ColorDialog1.Execute then
begin
Color := ColorDialog1.Color;
C := Color;
if Assigned(fColorChange) then OnColorChange( C );
end;
end;
function TColorFrame.GetColor: Integer;
begin
Result := Panel1.Color;
end;
procedure TColorFrame.SetColor(const AValue: Integer);
begin
Panel1.Color := AValue;
ColorEdit.Text := IntToHex( AValue, 6 );
end;
end.