mirror of
https://github.com/moparisthebest/Simba
synced 2024-11-22 09:12:19 -05:00
Test
git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@220 3f818213-9676-44b0-a9b4-5e4c4e03d09d
This commit is contained in:
parent
ca79137a39
commit
edbed662b3
@ -1,71 +1,72 @@
|
||||
object ColourHistoryForm: TColourHistoryForm
|
||||
Left = 401
|
||||
Height = 250
|
||||
Top = 344
|
||||
Width = 489
|
||||
ActiveControl = SelectionName
|
||||
Caption = 'Colour Picker History'
|
||||
ClientHeight = 250
|
||||
ClientWidth = 489
|
||||
OnHide = UnSetCHShowMenu
|
||||
OnShow = SetCHShowMenu
|
||||
LCLVersion = '0.9.29'
|
||||
object ColourList: TListView
|
||||
Left = 16
|
||||
Height = 176
|
||||
Top = 16
|
||||
Width = 328
|
||||
Columns = <>
|
||||
TabOrder = 0
|
||||
OnSelectItem = ChangeViewData
|
||||
end
|
||||
object DeleteButton: TButton
|
||||
Left = 16
|
||||
Height = 25
|
||||
Top = 208
|
||||
Width = 128
|
||||
Caption = 'Delete'
|
||||
OnClick = DeleteSelected
|
||||
TabOrder = 1
|
||||
end
|
||||
object SelectionName: TEdit
|
||||
Left = 360
|
||||
Height = 27
|
||||
Top = 16
|
||||
Width = 112
|
||||
OnChange = ChangeName
|
||||
TabOrder = 2
|
||||
Text = 'Name'
|
||||
end
|
||||
object PickNewColourButton: TButton
|
||||
Left = 216
|
||||
Height = 25
|
||||
Top = 208
|
||||
Width = 128
|
||||
Caption = 'Pick New Colour'
|
||||
TabOrder = 3
|
||||
end
|
||||
object ColourValue: TEdit
|
||||
Left = 360
|
||||
Height = 27
|
||||
Top = 56
|
||||
Width = 112
|
||||
ReadOnly = True
|
||||
TabOrder = 4
|
||||
Text = 'ColourValue'
|
||||
end
|
||||
object CoordValue: TLabel
|
||||
Left = 360
|
||||
Height = 18
|
||||
Top = 96
|
||||
Width = 74
|
||||
Caption = 'CoordValue'
|
||||
ParentColor = False
|
||||
end
|
||||
object ColourImage: TImage
|
||||
Left = 152
|
||||
Height = 24
|
||||
Top = 209
|
||||
Width = 56
|
||||
end
|
||||
end
|
||||
object ColourHistoryForm: TColourHistoryForm
|
||||
Left = 401
|
||||
Height = 250
|
||||
Top = 344
|
||||
Width = 489
|
||||
ActiveControl = SelectionName
|
||||
Caption = 'Colour Picker History'
|
||||
ClientHeight = 250
|
||||
ClientWidth = 489
|
||||
OnHide = UnSetCHShowMenu
|
||||
OnShow = SetCHShowMenu
|
||||
LCLVersion = '0.9.29'
|
||||
object ColourList: TListView
|
||||
Left = 16
|
||||
Height = 176
|
||||
Top = 16
|
||||
Width = 328
|
||||
Columns = <>
|
||||
SmallImages = Form1.Mufasa_Image_List
|
||||
TabOrder = 0
|
||||
OnSelectItem = ChangeViewData
|
||||
end
|
||||
object DeleteButton: TButton
|
||||
Left = 16
|
||||
Height = 25
|
||||
Top = 208
|
||||
Width = 128
|
||||
Caption = 'Delete'
|
||||
OnClick = DeleteSelected
|
||||
TabOrder = 1
|
||||
end
|
||||
object SelectionName: TEdit
|
||||
Left = 360
|
||||
Height = 21
|
||||
Top = 16
|
||||
Width = 112
|
||||
OnChange = ChangeName
|
||||
TabOrder = 2
|
||||
Text = 'Name'
|
||||
end
|
||||
object PickNewColourButton: TButton
|
||||
Left = 216
|
||||
Height = 25
|
||||
Top = 208
|
||||
Width = 128
|
||||
Caption = 'Pick New Colour'
|
||||
TabOrder = 3
|
||||
end
|
||||
object ColourValue: TEdit
|
||||
Left = 360
|
||||
Height = 21
|
||||
Top = 56
|
||||
Width = 112
|
||||
ReadOnly = True
|
||||
TabOrder = 4
|
||||
Text = 'ColourValue'
|
||||
end
|
||||
object CoordValue: TLabel
|
||||
Left = 360
|
||||
Height = 14
|
||||
Top = 96
|
||||
Width = 56
|
||||
Caption = 'CoordValue'
|
||||
ParentColor = False
|
||||
end
|
||||
object ColourImage: TImage
|
||||
Left = 152
|
||||
Height = 24
|
||||
Top = 209
|
||||
Width = 56
|
||||
end
|
||||
end
|
||||
|
@ -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'
|
||||
+#3#250#0#3'Top'#3'X'#1#5'Width'#3#233#1#13'ActiveControl'#7#13'SelectionName'
|
||||
+#7'Caption'#6#21'Colour Picker History'#12'ClientHeight'#3#250#0#11'ClientWi'
|
||||
+'dth'#3#233#1#6'OnHide'#7#15'UnSetCHShowMenu'#6'OnShow'#7#13'SetCHShowMenu'
|
||||
+#10'LCLVersion'#6#6'0.9.29'#0#9'TListView'#10'ColourList'#4'Left'#2#16#6'Hei'
|
||||
+'ght'#3#176#0#3'Top'#2#16#5'Width'#3'H'#1#7'Columns'#14#0#8'TabOrder'#2#0#12
|
||||
+'OnSelectItem'#7#14'ChangeViewData'#0#0#7'TButton'#12'DeleteButton'#4'Left'#2
|
||||
+#16#6'Height'#2#25#3'Top'#3#208#0#5'Width'#3#128#0#7'Caption'#6#6'Delete'#7
|
||||
+'OnClick'#7#14'DeleteSelected'#8'TabOrder'#2#1#0#0#5'TEdit'#13'SelectionName'
|
||||
+#4'Left'#3'h'#1#6'Height'#2#27#3'Top'#2#16#5'Width'#2'p'#8'OnChange'#7#10'Ch'
|
||||
+'angeName'#8'TabOrder'#2#2#4'Text'#6#4'Name'#0#0#7'TButton'#19'PickNewColour'
|
||||
+'Button'#4'Left'#3#216#0#6'Height'#2#25#3'Top'#3#208#0#5'Width'#3#128#0#7'Ca'
|
||||
+'ption'#6#15'Pick New Colour'#8'TabOrder'#2#3#0#0#5'TEdit'#11'ColourValue'#4
|
||||
+'Left'#3'h'#1#6'Height'#2#27#3'Top'#2'8'#5'Width'#2'p'#8'ReadOnly'#9#8'TabOr'
|
||||
+'der'#2#4#4'Text'#6#11'ColourValue'#0#0#6'TLabel'#10'CoordValue'#4'Left'#3'h'
|
||||
+#1#6'Height'#2#18#3'Top'#2'`'#5'Width'#2'J'#7'Caption'#6#10'CoordValue'#11'P'
|
||||
+'arentColor'#8#0#0#6'TImage'#11'ColourImage'#4'Left'#3#152#0#6'Height'#2#24#3
|
||||
+'Top'#3#209#0#5'Width'#2'8'#0#0#0
|
||||
]);
|
||||
LazarusResources.Add('TColourHistoryForm','FORMDATA',[
|
||||
'TPF0'#18'TColourHistoryForm'#17'ColourHistoryForm'#4'Left'#3#145#1#6'Height'
|
||||
+#3#250#0#3'Top'#3'X'#1#5'Width'#3#233#1#13'ActiveControl'#7#13'SelectionName'
|
||||
+#7'Caption'#6#21'Colour Picker History'#12'ClientHeight'#3#250#0#11'ClientWi'
|
||||
+'dth'#3#233#1#6'OnHide'#7#15'UnSetCHShowMenu'#6'OnShow'#7#13'SetCHShowMenu'
|
||||
+#10'LCLVersion'#6#6'0.9.29'#0#9'TListView'#10'ColourList'#4'Left'#2#16#6'Hei'
|
||||
+'ght'#3#176#0#3'Top'#2#16#5'Width'#3'H'#1#7'Columns'#14#0#11'SmallImages'#7
|
||||
+#23'Form1.Mufasa_Image_List'#8'TabOrder'#2#0#12'OnSelectItem'#7#14'ChangeVie'
|
||||
+'wData'#0#0#7'TButton'#12'DeleteButton'#4'Left'#2#16#6'Height'#2#25#3'Top'#3
|
||||
+#208#0#5'Width'#3#128#0#7'Caption'#6#6'Delete'#7'OnClick'#7#14'DeleteSelecte'
|
||||
+'d'#8'TabOrder'#2#1#0#0#5'TEdit'#13'SelectionName'#4'Left'#3'h'#1#6'Height'#2
|
||||
+#21#3'Top'#2#16#5'Width'#2'p'#8'OnChange'#7#10'ChangeName'#8'TabOrder'#2#2#4
|
||||
+'Text'#6#4'Name'#0#0#7'TButton'#19'PickNewColourButton'#4'Left'#3#216#0#6'He'
|
||||
+'ight'#2#25#3'Top'#3#208#0#5'Width'#3#128#0#7'Caption'#6#15'Pick New Colour'
|
||||
+#8'TabOrder'#2#3#0#0#5'TEdit'#11'ColourValue'#4'Left'#3'h'#1#6'Height'#2#21#3
|
||||
+'Top'#2'8'#5'Width'#2'p'#8'ReadOnly'#9#8'TabOrder'#2#4#4'Text'#6#11'ColourVa'
|
||||
+'lue'#0#0#6'TLabel'#10'CoordValue'#4'Left'#3'h'#1#6'Height'#2#14#3'Top'#2'`'
|
||||
+#5'Width'#2'8'#7'Caption'#6#10'CoordValue'#11'ParentColor'#8#0#0#6'TImage'#11
|
||||
+'ColourImage'#4'Left'#3#152#0#6'Height'#2#24#3'Top'#3#209#0#5'Width'#2'8'#0#0
|
||||
+#0
|
||||
]);
|
||||
|
@ -1,180 +1,181 @@
|
||||
unit colourhistory;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
|
||||
ComCtrls, StdCtrls, ExtCtrls;
|
||||
|
||||
type
|
||||
TColourPickerObject = class(TObject)
|
||||
constructor Create(C: Integer; P: TPoint; N: String);
|
||||
destructor Destroy; override;
|
||||
|
||||
public
|
||||
Colour: Integer;
|
||||
Pos: TPoint;
|
||||
Name: String;
|
||||
end;
|
||||
|
||||
{ TColourHistoryForm }
|
||||
|
||||
TColourHistoryForm = class(TForm)
|
||||
ColourValue: TEdit;
|
||||
CoordValue: TLabel;
|
||||
ColourImage: TImage;
|
||||
PickNewColourButton: TButton;
|
||||
DeleteButton: TButton;
|
||||
ColourList: TListView;
|
||||
SelectionName: TEdit;
|
||||
procedure ChangeName(Sender: TObject);
|
||||
procedure ChangeViewData(Sender: TObject; Item: TListItem; Selected: Boolean
|
||||
);
|
||||
procedure DeleteSelected(Sender: TObject);
|
||||
procedure AddColObj(c: TColourPickerObject; autoName: Boolean);
|
||||
|
||||
constructor Create(TheOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
procedure SetCHShowMenu(Sender: TObject);
|
||||
procedure UnSetCHShowMenu(Sender: TObject);
|
||||
private
|
||||
Colour_Count: Integer;
|
||||
{ private declarations }
|
||||
protected
|
||||
procedure AddColObj(c: TColourPickerObject);
|
||||
public
|
||||
IndexSelected: Integer;
|
||||
{ public declarations }
|
||||
end;
|
||||
|
||||
|
||||
|
||||
var
|
||||
ColourHistoryForm: TColourHistoryForm;
|
||||
|
||||
implementation
|
||||
uses
|
||||
TestUnit;
|
||||
|
||||
constructor TColourPickerObject.Create(C: Integer; P: TPoint; N: String);
|
||||
begin
|
||||
inherited Create;
|
||||
Self.Colour := C;
|
||||
Self.Pos := P;
|
||||
Self.Name:= N;
|
||||
end;
|
||||
|
||||
destructor TColourPickerObject.Destroy;
|
||||
begin
|
||||
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
{ TColourHistoryForm }
|
||||
|
||||
procedure TColourHistoryForm.AddColObj(c: TColourPickerObject; autoName: Boolean);
|
||||
begin
|
||||
if autoName then
|
||||
begin
|
||||
Inc(Colour_Count);
|
||||
c.Name := 'Untitled (' + IntToStr(Colour_Count) + ')';
|
||||
end;
|
||||
Self.AddColObj(c);
|
||||
end;
|
||||
|
||||
procedure TColourHistoryForm.AddColObj(c: TColourPickerObject);
|
||||
|
||||
var
|
||||
it: TListItem;
|
||||
begin
|
||||
it := ColourList.Items.Add;
|
||||
it.Data := c;
|
||||
it.Caption:= c.Name;
|
||||
ColourList.Selected := it;
|
||||
end;
|
||||
|
||||
procedure TColourHistoryForm.DeleteSelected(Sender: TObject);
|
||||
|
||||
begin
|
||||
if (Assigned(ColourList.Selected)) then
|
||||
begin
|
||||
TColourPickerObject(ColourList.Selected.Data).Free;
|
||||
ColourList.Selected.Delete;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TColourHistoryForm.ChangeViewData(Sender: TObject; Item: TListItem;
|
||||
Selected: Boolean);
|
||||
begin
|
||||
if not Assigned(Item) then
|
||||
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
|
||||
exit;
|
||||
|
||||
{ Change Form Text / Values }
|
||||
ColourValue.Caption := IntToStr(TColourPickerObject(Item.Data).Colour);
|
||||
CoordValue.Caption := 'Coords: ' + IntToStr(TColourPickerObject(Item.Data).Pos.X) +
|
||||
', ' + IntToStr(TColourPickerObject(Item.Data).Pos.Y);
|
||||
SelectionName.Text := TColourPickerObject(Item.Data).Name;
|
||||
|
||||
{ Draw the Image }
|
||||
ColourImage.Canvas.Brush.Color := TColourPickerObject(Item.Data).Colour;
|
||||
ColourImage.Canvas.Rectangle(0,0,ColourImage.Width, ColourImage.Height);
|
||||
|
||||
if Self.Visible then
|
||||
begin
|
||||
try
|
||||
SelectionName.SetFocus;
|
||||
finally
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TColourHistoryForm.ChangeName(Sender: TObject);
|
||||
begin
|
||||
if not Assigned(ColourList.Selected) then
|
||||
begin
|
||||
WriteLn('We double clicked but have nothing Selected?');
|
||||
exit;
|
||||
end;
|
||||
ColourList.Selected.Caption := SelectionName.Text;
|
||||
TColourPickerObject(ColourList.Selected.Data).Name := SelectionName.Text;
|
||||
end;
|
||||
|
||||
constructor TColourHistoryForm.Create(TheOwner: TComponent);
|
||||
begin
|
||||
inherited Create(TheOwner);
|
||||
|
||||
Colour_Count := 0;
|
||||
PickNewColourButton.OnClick:= @Form1.ButtonPickClick;
|
||||
end;
|
||||
|
||||
destructor TColourHistoryForm.Destroy;
|
||||
begin
|
||||
PickNewColourButton.OnClick := nil;
|
||||
Colour_Count := 0;
|
||||
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TColourHistoryForm.SetCHShowMenu(Sender: TObject);
|
||||
begin
|
||||
Form1.View_CH_Menu.Checked := True;
|
||||
end;
|
||||
|
||||
procedure TColourHistoryForm.UnSetCHShowMenu(Sender: TObject);
|
||||
begin
|
||||
Form1.View_CH_Menu.Checked := False;
|
||||
end;
|
||||
|
||||
initialization
|
||||
{$I colourhistory.lrs}
|
||||
|
||||
end.
|
||||
|
||||
unit colourhistory;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
|
||||
ComCtrls, StdCtrls, ExtCtrls;
|
||||
|
||||
type
|
||||
TColourPickerObject = class(TObject)
|
||||
constructor Create(C: Integer; P: TPoint; N: String);
|
||||
destructor Destroy; override;
|
||||
|
||||
public
|
||||
Colour: Integer;
|
||||
Pos: TPoint;
|
||||
Name: String;
|
||||
end;
|
||||
|
||||
{ TColourHistoryForm }
|
||||
|
||||
TColourHistoryForm = class(TForm)
|
||||
ColourValue: TEdit;
|
||||
CoordValue: TLabel;
|
||||
ColourImage: TImage;
|
||||
PickNewColourButton: TButton;
|
||||
DeleteButton: TButton;
|
||||
ColourList: TListView;
|
||||
SelectionName: TEdit;
|
||||
procedure ChangeName(Sender: TObject);
|
||||
procedure ChangeViewData(Sender: TObject; Item: TListItem; Selected: Boolean
|
||||
);
|
||||
procedure DeleteSelected(Sender: TObject);
|
||||
procedure AddColObj(c: TColourPickerObject; autoName: Boolean);
|
||||
|
||||
constructor Create(TheOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
procedure SetCHShowMenu(Sender: TObject);
|
||||
procedure UnSetCHShowMenu(Sender: TObject);
|
||||
private
|
||||
Colour_Count: Integer;
|
||||
{ private declarations }
|
||||
protected
|
||||
procedure AddColObj(c: TColourPickerObject);
|
||||
public
|
||||
IndexSelected: Integer;
|
||||
{ public declarations }
|
||||
end;
|
||||
|
||||
|
||||
|
||||
var
|
||||
ColourHistoryForm: TColourHistoryForm;
|
||||
|
||||
implementation
|
||||
uses
|
||||
TestUnit;
|
||||
|
||||
constructor TColourPickerObject.Create(C: Integer; P: TPoint; N: String);
|
||||
begin
|
||||
inherited Create;
|
||||
Self.Colour := C;
|
||||
Self.Pos := P;
|
||||
Self.Name:= N;
|
||||
end;
|
||||
|
||||
destructor TColourPickerObject.Destroy;
|
||||
begin
|
||||
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
{ TColourHistoryForm }
|
||||
|
||||
procedure TColourHistoryForm.AddColObj(c: TColourPickerObject; autoName: Boolean);
|
||||
begin
|
||||
if autoName then
|
||||
begin
|
||||
Inc(Colour_Count);
|
||||
c.Name := 'Untitled (' + IntToStr(Colour_Count) + ')';
|
||||
end;
|
||||
Self.AddColObj(c);
|
||||
end;
|
||||
|
||||
procedure TColourHistoryForm.AddColObj(c: TColourPickerObject);
|
||||
|
||||
var
|
||||
it: TListItem;
|
||||
begin
|
||||
it := ColourList.Items.Add;
|
||||
it.Data := c;
|
||||
it.Caption:= c.Name;
|
||||
it.ImageIndex:= 7;//just an example
|
||||
ColourList.Selected := it;
|
||||
end;
|
||||
|
||||
procedure TColourHistoryForm.DeleteSelected(Sender: TObject);
|
||||
|
||||
begin
|
||||
if (Assigned(ColourList.Selected)) then
|
||||
begin
|
||||
TColourPickerObject(ColourList.Selected.Data).Free;
|
||||
ColourList.Selected.Delete;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TColourHistoryForm.ChangeViewData(Sender: TObject; Item: TListItem;
|
||||
Selected: Boolean);
|
||||
begin
|
||||
if not Assigned(Item) then
|
||||
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
|
||||
exit;
|
||||
|
||||
{ Change Form Text / Values }
|
||||
ColourValue.Caption := IntToStr(TColourPickerObject(Item.Data).Colour);
|
||||
CoordValue.Caption := 'Coords: ' + IntToStr(TColourPickerObject(Item.Data).Pos.X) +
|
||||
', ' + IntToStr(TColourPickerObject(Item.Data).Pos.Y);
|
||||
SelectionName.Text := TColourPickerObject(Item.Data).Name;
|
||||
|
||||
{ Draw the Image }
|
||||
ColourImage.Canvas.Brush.Color := TColourPickerObject(Item.Data).Colour;
|
||||
ColourImage.Canvas.Rectangle(0,0,ColourImage.Width, ColourImage.Height);
|
||||
|
||||
if Self.Visible then
|
||||
begin
|
||||
try
|
||||
SelectionName.SetFocus;
|
||||
finally
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TColourHistoryForm.ChangeName(Sender: TObject);
|
||||
begin
|
||||
if not Assigned(ColourList.Selected) then
|
||||
begin
|
||||
WriteLn('We double clicked but have nothing Selected?');
|
||||
exit;
|
||||
end;
|
||||
ColourList.Selected.Caption := SelectionName.Text;
|
||||
TColourPickerObject(ColourList.Selected.Data).Name := SelectionName.Text;
|
||||
end;
|
||||
|
||||
constructor TColourHistoryForm.Create(TheOwner: TComponent);
|
||||
begin
|
||||
inherited Create(TheOwner);
|
||||
|
||||
Colour_Count := 0;
|
||||
PickNewColourButton.OnClick:= @Form1.ButtonPickClick;
|
||||
end;
|
||||
|
||||
destructor TColourHistoryForm.Destroy;
|
||||
begin
|
||||
PickNewColourButton.OnClick := nil;
|
||||
Colour_Count := 0;
|
||||
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TColourHistoryForm.SetCHShowMenu(Sender: TObject);
|
||||
begin
|
||||
Form1.View_CH_Menu.Checked := True;
|
||||
end;
|
||||
|
||||
procedure TColourHistoryForm.UnSetCHShowMenu(Sender: TObject);
|
||||
begin
|
||||
Form1.View_CH_Menu.Checked := False;
|
||||
end;
|
||||
|
||||
initialization
|
||||
{$I colourhistory.lrs}
|
||||
|
||||
end.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user