1
0
mirror of https://github.com/moparisthebest/Simba synced 2024-11-25 10:42:20 -05:00
git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@220 3f818213-9676-44b0-a9b4-5e4c4e03d09d
This commit is contained in:
Raymond 2009-11-09 19:32:09 +00:00
parent ca79137a39
commit edbed662b3
3 changed files with 274 additions and 273 deletions

View File

@ -1,71 +1,72 @@
object ColourHistoryForm: TColourHistoryForm object ColourHistoryForm: TColourHistoryForm
Left = 401 Left = 401
Height = 250 Height = 250
Top = 344 Top = 344
Width = 489 Width = 489
ActiveControl = SelectionName ActiveControl = SelectionName
Caption = 'Colour Picker History' Caption = 'Colour Picker History'
ClientHeight = 250 ClientHeight = 250
ClientWidth = 489 ClientWidth = 489
OnHide = UnSetCHShowMenu OnHide = UnSetCHShowMenu
OnShow = SetCHShowMenu OnShow = SetCHShowMenu
LCLVersion = '0.9.29' LCLVersion = '0.9.29'
object ColourList: TListView object ColourList: TListView
Left = 16 Left = 16
Height = 176 Height = 176
Top = 16 Top = 16
Width = 328 Width = 328
Columns = <> Columns = <>
TabOrder = 0 SmallImages = Form1.Mufasa_Image_List
OnSelectItem = ChangeViewData TabOrder = 0
end OnSelectItem = ChangeViewData
object DeleteButton: TButton end
Left = 16 object DeleteButton: TButton
Height = 25 Left = 16
Top = 208 Height = 25
Width = 128 Top = 208
Caption = 'Delete' Width = 128
OnClick = DeleteSelected Caption = 'Delete'
TabOrder = 1 OnClick = DeleteSelected
end TabOrder = 1
object SelectionName: TEdit end
Left = 360 object SelectionName: TEdit
Height = 27 Left = 360
Top = 16 Height = 21
Width = 112 Top = 16
OnChange = ChangeName Width = 112
TabOrder = 2 OnChange = ChangeName
Text = 'Name' TabOrder = 2
end Text = 'Name'
object PickNewColourButton: TButton end
Left = 216 object PickNewColourButton: TButton
Height = 25 Left = 216
Top = 208 Height = 25
Width = 128 Top = 208
Caption = 'Pick New Colour' Width = 128
TabOrder = 3 Caption = 'Pick New Colour'
end TabOrder = 3
object ColourValue: TEdit end
Left = 360 object ColourValue: TEdit
Height = 27 Left = 360
Top = 56 Height = 21
Width = 112 Top = 56
ReadOnly = True Width = 112
TabOrder = 4 ReadOnly = True
Text = 'ColourValue' TabOrder = 4
end Text = 'ColourValue'
object CoordValue: TLabel end
Left = 360 object CoordValue: TLabel
Height = 18 Left = 360
Top = 96 Height = 14
Width = 74 Top = 96
Caption = 'CoordValue' Width = 56
ParentColor = False Caption = 'CoordValue'
end ParentColor = False
object ColourImage: TImage end
Left = 152 object ColourImage: TImage
Height = 24 Left = 152
Top = 209 Height = 24
Width = 56 Top = 209
end Width = 56
end end
end

View File

@ -1,22 +1,21 @@
{ This is an automatically generated lazarus resource file } LazarusResources.Add('TColourHistoryForm','FORMDATA',[
'TPF0'#18'TColourHistoryForm'#17'ColourHistoryForm'#4'Left'#3#145#1#6'Height'
LazarusResources.Add('TColourHistoryForm','FORMDATA',[ +#3#250#0#3'Top'#3'X'#1#5'Width'#3#233#1#13'ActiveControl'#7#13'SelectionName'
'TPF0'#18'TColourHistoryForm'#17'ColourHistoryForm'#4'Left'#3#145#1#6'Height' +#7'Caption'#6#21'Colour Picker History'#12'ClientHeight'#3#250#0#11'ClientWi'
+#3#250#0#3'Top'#3'X'#1#5'Width'#3#233#1#13'ActiveControl'#7#13'SelectionName' +'dth'#3#233#1#6'OnHide'#7#15'UnSetCHShowMenu'#6'OnShow'#7#13'SetCHShowMenu'
+#7'Caption'#6#21'Colour Picker History'#12'ClientHeight'#3#250#0#11'ClientWi' +#10'LCLVersion'#6#6'0.9.29'#0#9'TListView'#10'ColourList'#4'Left'#2#16#6'Hei'
+'dth'#3#233#1#6'OnHide'#7#15'UnSetCHShowMenu'#6'OnShow'#7#13'SetCHShowMenu' +'ght'#3#176#0#3'Top'#2#16#5'Width'#3'H'#1#7'Columns'#14#0#11'SmallImages'#7
+#10'LCLVersion'#6#6'0.9.29'#0#9'TListView'#10'ColourList'#4'Left'#2#16#6'Hei' +#23'Form1.Mufasa_Image_List'#8'TabOrder'#2#0#12'OnSelectItem'#7#14'ChangeVie'
+'ght'#3#176#0#3'Top'#2#16#5'Width'#3'H'#1#7'Columns'#14#0#8'TabOrder'#2#0#12 +'wData'#0#0#7'TButton'#12'DeleteButton'#4'Left'#2#16#6'Height'#2#25#3'Top'#3
+'OnSelectItem'#7#14'ChangeViewData'#0#0#7'TButton'#12'DeleteButton'#4'Left'#2 +#208#0#5'Width'#3#128#0#7'Caption'#6#6'Delete'#7'OnClick'#7#14'DeleteSelecte'
+#16#6'Height'#2#25#3'Top'#3#208#0#5'Width'#3#128#0#7'Caption'#6#6'Delete'#7 +'d'#8'TabOrder'#2#1#0#0#5'TEdit'#13'SelectionName'#4'Left'#3'h'#1#6'Height'#2
+'OnClick'#7#14'DeleteSelected'#8'TabOrder'#2#1#0#0#5'TEdit'#13'SelectionName' +#21#3'Top'#2#16#5'Width'#2'p'#8'OnChange'#7#10'ChangeName'#8'TabOrder'#2#2#4
+#4'Left'#3'h'#1#6'Height'#2#27#3'Top'#2#16#5'Width'#2'p'#8'OnChange'#7#10'Ch' +'Text'#6#4'Name'#0#0#7'TButton'#19'PickNewColourButton'#4'Left'#3#216#0#6'He'
+'angeName'#8'TabOrder'#2#2#4'Text'#6#4'Name'#0#0#7'TButton'#19'PickNewColour' +'ight'#2#25#3'Top'#3#208#0#5'Width'#3#128#0#7'Caption'#6#15'Pick New Colour'
+'Button'#4'Left'#3#216#0#6'Height'#2#25#3'Top'#3#208#0#5'Width'#3#128#0#7'Ca' +#8'TabOrder'#2#3#0#0#5'TEdit'#11'ColourValue'#4'Left'#3'h'#1#6'Height'#2#21#3
+'ption'#6#15'Pick New Colour'#8'TabOrder'#2#3#0#0#5'TEdit'#11'ColourValue'#4 +'Top'#2'8'#5'Width'#2'p'#8'ReadOnly'#9#8'TabOrder'#2#4#4'Text'#6#11'ColourVa'
+'Left'#3'h'#1#6'Height'#2#27#3'Top'#2'8'#5'Width'#2'p'#8'ReadOnly'#9#8'TabOr' +'lue'#0#0#6'TLabel'#10'CoordValue'#4'Left'#3'h'#1#6'Height'#2#14#3'Top'#2'`'
+'der'#2#4#4'Text'#6#11'ColourValue'#0#0#6'TLabel'#10'CoordValue'#4'Left'#3'h' +#5'Width'#2'8'#7'Caption'#6#10'CoordValue'#11'ParentColor'#8#0#0#6'TImage'#11
+#1#6'Height'#2#18#3'Top'#2'`'#5'Width'#2'J'#7'Caption'#6#10'CoordValue'#11'P' +'ColourImage'#4'Left'#3#152#0#6'Height'#2#24#3'Top'#3#209#0#5'Width'#2'8'#0#0
+'arentColor'#8#0#0#6'TImage'#11'ColourImage'#4'Left'#3#152#0#6'Height'#2#24#3 +#0
+'Top'#3#209#0#5'Width'#2'8'#0#0#0 ]);
]);

View File

@ -1,180 +1,181 @@
unit colourhistory; unit colourhistory;
{$mode objfpc}{$H+} {$mode objfpc}{$H+}
interface interface
uses uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs, Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
ComCtrls, StdCtrls, ExtCtrls; ComCtrls, StdCtrls, ExtCtrls;
type type
TColourPickerObject = class(TObject) TColourPickerObject = class(TObject)
constructor Create(C: Integer; P: TPoint; N: String); constructor Create(C: Integer; P: TPoint; N: String);
destructor Destroy; override; destructor Destroy; override;
public public
Colour: Integer; Colour: Integer;
Pos: TPoint; Pos: TPoint;
Name: String; Name: String;
end; end;
{ TColourHistoryForm } { TColourHistoryForm }
TColourHistoryForm = class(TForm) TColourHistoryForm = class(TForm)
ColourValue: TEdit; ColourValue: TEdit;
CoordValue: TLabel; CoordValue: TLabel;
ColourImage: TImage; ColourImage: TImage;
PickNewColourButton: TButton; PickNewColourButton: TButton;
DeleteButton: TButton; DeleteButton: TButton;
ColourList: TListView; ColourList: TListView;
SelectionName: TEdit; SelectionName: TEdit;
procedure ChangeName(Sender: TObject); procedure ChangeName(Sender: TObject);
procedure ChangeViewData(Sender: TObject; Item: TListItem; Selected: Boolean procedure ChangeViewData(Sender: TObject; Item: TListItem; Selected: Boolean
); );
procedure DeleteSelected(Sender: TObject); procedure DeleteSelected(Sender: TObject);
procedure AddColObj(c: TColourPickerObject; autoName: Boolean); procedure AddColObj(c: TColourPickerObject; autoName: Boolean);
constructor Create(TheOwner: TComponent); override; constructor Create(TheOwner: TComponent); override;
destructor Destroy; override; destructor Destroy; override;
procedure SetCHShowMenu(Sender: TObject); procedure SetCHShowMenu(Sender: TObject);
procedure UnSetCHShowMenu(Sender: TObject); procedure UnSetCHShowMenu(Sender: TObject);
private private
Colour_Count: Integer; Colour_Count: Integer;
{ private declarations } { private declarations }
protected protected
procedure AddColObj(c: TColourPickerObject); procedure AddColObj(c: TColourPickerObject);
public public
IndexSelected: Integer; IndexSelected: Integer;
{ public declarations } { public declarations }
end; end;
var var
ColourHistoryForm: TColourHistoryForm; ColourHistoryForm: TColourHistoryForm;
implementation implementation
uses uses
TestUnit; TestUnit;
constructor TColourPickerObject.Create(C: Integer; P: TPoint; N: String); constructor TColourPickerObject.Create(C: Integer; P: TPoint; N: String);
begin begin
inherited Create; inherited Create;
Self.Colour := C; Self.Colour := C;
Self.Pos := P; Self.Pos := P;
Self.Name:= N; Self.Name:= N;
end; end;
destructor TColourPickerObject.Destroy; destructor TColourPickerObject.Destroy;
begin begin
inherited Destroy; inherited Destroy;
end; end;
{ TColourHistoryForm } { TColourHistoryForm }
procedure TColourHistoryForm.AddColObj(c: TColourPickerObject; autoName: Boolean); procedure TColourHistoryForm.AddColObj(c: TColourPickerObject; autoName: Boolean);
begin begin
if autoName then if autoName then
begin begin
Inc(Colour_Count); Inc(Colour_Count);
c.Name := 'Untitled (' + IntToStr(Colour_Count) + ')'; c.Name := 'Untitled (' + IntToStr(Colour_Count) + ')';
end; end;
Self.AddColObj(c); Self.AddColObj(c);
end; end;
procedure TColourHistoryForm.AddColObj(c: TColourPickerObject); procedure TColourHistoryForm.AddColObj(c: TColourPickerObject);
var var
it: TListItem; it: TListItem;
begin begin
it := ColourList.Items.Add; it := ColourList.Items.Add;
it.Data := c; it.Data := c;
it.Caption:= c.Name; it.Caption:= c.Name;
ColourList.Selected := it; it.ImageIndex:= 7;//just an example
end; ColourList.Selected := it;
end;
procedure TColourHistoryForm.DeleteSelected(Sender: TObject);
procedure TColourHistoryForm.DeleteSelected(Sender: TObject);
begin
if (Assigned(ColourList.Selected)) then begin
begin if (Assigned(ColourList.Selected)) then
TColourPickerObject(ColourList.Selected.Data).Free; begin
ColourList.Selected.Delete; TColourPickerObject(ColourList.Selected.Data).Free;
end; ColourList.Selected.Delete;
end; end;
end;
procedure TColourHistoryForm.ChangeViewData(Sender: TObject; Item: TListItem;
Selected: Boolean); procedure TColourHistoryForm.ChangeViewData(Sender: TObject; Item: TListItem;
begin Selected: Boolean);
if not Assigned(Item) then begin
exit; if not Assigned(Item) then
if not Item.Selected then exit;
exit; if not Item.Selected then
exit;
{ This only occurs when we have manually added an item with the Form Editor }
if not Assigned(Item.Data) then { This only occurs when we have manually added an item with the Form Editor }
exit; if not Assigned(Item.Data) then
exit;
{ Change Form Text / Values }
ColourValue.Caption := IntToStr(TColourPickerObject(Item.Data).Colour); { Change Form Text / Values }
CoordValue.Caption := 'Coords: ' + IntToStr(TColourPickerObject(Item.Data).Pos.X) + ColourValue.Caption := IntToStr(TColourPickerObject(Item.Data).Colour);
', ' + IntToStr(TColourPickerObject(Item.Data).Pos.Y); CoordValue.Caption := 'Coords: ' + IntToStr(TColourPickerObject(Item.Data).Pos.X) +
SelectionName.Text := TColourPickerObject(Item.Data).Name; ', ' + IntToStr(TColourPickerObject(Item.Data).Pos.Y);
SelectionName.Text := TColourPickerObject(Item.Data).Name;
{ Draw the Image }
ColourImage.Canvas.Brush.Color := TColourPickerObject(Item.Data).Colour; { Draw the Image }
ColourImage.Canvas.Rectangle(0,0,ColourImage.Width, ColourImage.Height); ColourImage.Canvas.Brush.Color := TColourPickerObject(Item.Data).Colour;
ColourImage.Canvas.Rectangle(0,0,ColourImage.Width, ColourImage.Height);
if Self.Visible then
begin if Self.Visible then
try begin
SelectionName.SetFocus; try
finally SelectionName.SetFocus;
end; finally
end; end;
end; end;
end;
procedure TColourHistoryForm.ChangeName(Sender: TObject);
begin procedure TColourHistoryForm.ChangeName(Sender: TObject);
if not Assigned(ColourList.Selected) then begin
begin if not Assigned(ColourList.Selected) then
WriteLn('We double clicked but have nothing Selected?'); begin
exit; WriteLn('We double clicked but have nothing Selected?');
end; exit;
ColourList.Selected.Caption := SelectionName.Text; end;
TColourPickerObject(ColourList.Selected.Data).Name := SelectionName.Text; ColourList.Selected.Caption := SelectionName.Text;
end; TColourPickerObject(ColourList.Selected.Data).Name := SelectionName.Text;
end;
constructor TColourHistoryForm.Create(TheOwner: TComponent);
begin constructor TColourHistoryForm.Create(TheOwner: TComponent);
inherited Create(TheOwner); begin
inherited Create(TheOwner);
Colour_Count := 0;
PickNewColourButton.OnClick:= @Form1.ButtonPickClick; Colour_Count := 0;
end; PickNewColourButton.OnClick:= @Form1.ButtonPickClick;
end;
destructor TColourHistoryForm.Destroy;
begin destructor TColourHistoryForm.Destroy;
PickNewColourButton.OnClick := nil; begin
Colour_Count := 0; PickNewColourButton.OnClick := nil;
Colour_Count := 0;
inherited Destroy;
end; inherited Destroy;
end;
procedure TColourHistoryForm.SetCHShowMenu(Sender: TObject);
begin procedure TColourHistoryForm.SetCHShowMenu(Sender: TObject);
Form1.View_CH_Menu.Checked := True; begin
end; Form1.View_CH_Menu.Checked := True;
end;
procedure TColourHistoryForm.UnSetCHShowMenu(Sender: TObject);
begin procedure TColourHistoryForm.UnSetCHShowMenu(Sender: TObject);
Form1.View_CH_Menu.Checked := False; begin
end; Form1.View_CH_Menu.Checked := False;
end;
initialization
{$I colourhistory.lrs} initialization
{$I colourhistory.lrs}
end.
end.