diff --git a/Projects/SAMufasaGUI/colourhistory.lfm b/Projects/SAMufasaGUI/colourhistory.lfm
index 3aabf87..c3d3b21 100644
--- a/Projects/SAMufasaGUI/colourhistory.lfm
+++ b/Projects/SAMufasaGUI/colourhistory.lfm
@@ -1,116 +1,108 @@
-object ColourHistoryForm: TColourHistoryForm
- Left = 420
- Height = 250
- Top = 318
- Width = 490
- ActiveControl = SelectionName
- Caption = 'Colour Picker History'
- ClientHeight = 250
- ClientWidth = 490
- Constraints.MinHeight = 200
- Constraints.MinWidth = 490
- OnCreate = FormCreate
- OnHide = UnSetCHShowMenu
- OnShow = SetCHShowMenu
- LCLVersion = '0.9.29'
- object ColourList: TListView
- Left = 16
- Height = 176
- Top = 16
- Width = 329
- Anchors = [akTop, akLeft, akRight, akBottom]
- Columns = <
- item
- Caption = 'Colour'
- MaxWidth = 50
- MinWidth = 50
- Width = 10
- end
- item
- Caption = 'Woot'
- Width = 10
- end>
- ItemIndex = -1
- TabOrder = 0
- ViewStyle = vsReport
- OnAdvancedCustomDrawSubItem = ColourListAdvancedCustomDrawSubItem
- OnSelectItem = ChangeViewData
- end
- object DeleteButton: TButton
- Left = 16
- Height = 25
- Top = 208
- Width = 128
- Anchors = [akLeft, akBottom]
- Caption = 'Delete'
- OnClick = DeleteSelected
- TabOrder = 1
- end
- object SelectionName: TEdit
- Left = 361
- Height = 21
- Top = 16
- Width = 112
- Anchors = [akTop, akRight]
- OnChange = ChangeName
- OnKeyPress = SelectionNameKeyPress
- TabOrder = 2
- Text = 'Name'
- end
- object PickNewColourButton: TButton
- Left = 217
- Height = 25
- Top = 208
- Width = 128
- Anchors = [akRight, akBottom]
- Caption = 'Pick New Colour'
- TabOrder = 3
- end
- object ColourValue: TEdit
- Left = 361
- Height = 21
- Top = 56
- Width = 112
- Anchors = [akTop, akRight]
- ReadOnly = True
- TabOrder = 4
- Text = 'ColourValue'
- end
- object CoordValue: TLabel
- Left = 361
- Height = 14
- Top = 96
- Width = 112
- Anchors = [akTop, akRight]
- Caption = 'CoordValue'
- Constraints.MinWidth = 112
- ParentColor = False
- end
- object ColourImage: TImage
- Left = 152
- Height = 24
- Top = 209
- Width = 57
- Anchors = [akLeft, akRight, akBottom]
- end
- object OkButton: TButton
- Left = 393
- Height = 24
- Top = 209
- Width = 80
- Anchors = [akRight, akBottom]
- Caption = 'Ok'
- OnClick = OkButtonClick
- TabOrder = 5
- end
- object CH_RGB_Label: TLabel
- Left = 361
- Height = 14
- Top = 128
- Width = 112
- Anchors = [akTop, akRight]
- Caption = 'RGBValues'
- Constraints.MinWidth = 112
- ParentColor = False
- end
-end
+object ColourHistoryForm: TColourHistoryForm
+ Left = 373
+ Height = 250
+ Top = 308
+ Width = 490
+ ActiveControl = SelectionName
+ Caption = 'Colour Picker History'
+ ClientHeight = 250
+ ClientWidth = 490
+ Constraints.MinHeight = 200
+ Constraints.MinWidth = 490
+ OnHide = UnSetCHShowMenu
+ OnShow = SetCHShowMenu
+ LCLVersion = '0.9.29'
+ object DeleteButton: TButton
+ Left = 16
+ Height = 25
+ Top = 208
+ Width = 128
+ Anchors = [akLeft, akBottom]
+ Caption = 'Delete'
+ OnClick = DeleteSelected
+ TabOrder = 0
+ end
+ object SelectionName: TEdit
+ Left = 361
+ Height = 27
+ Top = 16
+ Width = 112
+ Anchors = [akTop, akRight]
+ OnChange = ChangeName
+ OnKeyPress = SelectionNameKeyPress
+ TabOrder = 1
+ Text = 'Name'
+ end
+ object PickNewColourButton: TButton
+ Left = 217
+ Height = 25
+ Top = 208
+ Width = 128
+ Anchors = [akRight, akBottom]
+ Caption = 'Pick New Colour'
+ TabOrder = 2
+ end
+ object ColourValue: TEdit
+ Left = 361
+ Height = 27
+ Top = 56
+ Width = 112
+ Anchors = [akTop, akRight]
+ ReadOnly = True
+ TabOrder = 3
+ Text = 'ColourValue'
+ end
+ object CoordValue: TLabel
+ Left = 361
+ Height = 18
+ Top = 96
+ Width = 112
+ Anchors = [akTop, akRight]
+ Caption = 'CoordValue'
+ Constraints.MinWidth = 112
+ ParentColor = False
+ end
+ object ColourImage: TImage
+ Left = 152
+ Height = 24
+ Top = 209
+ Width = 57
+ Anchors = [akLeft, akRight, akBottom]
+ end
+ object OkButton: TButton
+ Left = 393
+ Height = 24
+ Top = 209
+ Width = 80
+ Anchors = [akRight, akBottom]
+ Caption = 'Ok'
+ OnClick = OkButtonClick
+ TabOrder = 4
+ end
+ object CH_RGB_Label: TLabel
+ Left = 361
+ Height = 18
+ Top = 128
+ Width = 112
+ Anchors = [akTop, akRight]
+ Caption = 'RGBValues'
+ Constraints.MinWidth = 112
+ ParentColor = False
+ end
+ object ColourTree: TTreeView
+ Left = 8
+ Height = 169
+ Top = 16
+ Width = 337
+ Anchors = [akTop, akLeft, akRight, akBottom]
+ DefaultItemHeight = 19
+ Images = CHImages
+ ScrollBars = ssAutoBoth
+ TabOrder = 5
+ OnChange = ColourTreeChange
+ end
+ object CHImages: TImageList
+ left = 360
+ top = 200
+ end
+end
diff --git a/Projects/SAMufasaGUI/colourhistory.lrs b/Projects/SAMufasaGUI/colourhistory.lrs
index 5eb11c1..5ead42c 100644
--- a/Projects/SAMufasaGUI/colourhistory.lrs
+++ b/Projects/SAMufasaGUI/colourhistory.lrs
@@ -1,36 +1,34 @@
-{ This is an automatically generated lazarus resource file }
-
-LazarusResources.Add('TColourHistoryForm','FORMDATA',[
- 'TPF0'#18'TColourHistoryForm'#17'ColourHistoryForm'#4'Left'#3#164#1#6'Height'
- +#3#250#0#3'Top'#3'>'#1#5'Width'#3#234#1#13'ActiveControl'#7#13'SelectionName'
- +#7'Caption'#6#21'Colour Picker History'#12'ClientHeight'#3#250#0#11'ClientWi'
- +'dth'#3#234#1#21'Constraints.MinHeight'#3#200#0#20'Constraints.MinWidth'#3
- +#234#1#8'OnCreate'#7#10'FormCreate'#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'Height'#3#176#0#3'Top'#2#16#5'Width'#3'I'#1#7'Anchors'#11#5
- +'akTop'#6'akLeft'#7'akRight'#8'akBottom'#0#7'Columns'#14#1#7'Caption'#6#6'Co'
- +'lour'#8'MaxWidth'#2'2'#8'MinWidth'#2'2'#5'Width'#2#10#0#1#7'Caption'#6#4'Wo'
- +'ot'#5'Width'#2#10#0#0#9'ItemIndex'#2#255#8'TabOrder'#2#0#9'ViewStyle'#7#8'v'
- +'sReport'#27'OnAdvancedCustomDrawSubItem'#7'#ColourListAdvancedCustomDrawSub'
- +'Item'#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'Anchors'#11#6
- +'akLeft'#8'akBottom'#0#7'Caption'#6#6'Delete'#7'OnClick'#7#14'DeleteSelected'
- +#8'TabOrder'#2#1#0#0#5'TEdit'#13'SelectionName'#4'Left'#3'i'#1#6'Height'#2#21
- +#3'Top'#2#16#5'Width'#2'p'#7'Anchors'#11#5'akTop'#7'akRight'#0#8'OnChange'#7
- +#10'ChangeName'#10'OnKeyPress'#7#21'SelectionNameKeyPress'#8'TabOrder'#2#2#4
- +'Text'#6#4'Name'#0#0#7'TButton'#19'PickNewColourButton'#4'Left'#3#217#0#6'He'
- +'ight'#2#25#3'Top'#3#208#0#5'Width'#3#128#0#7'Anchors'#11#7'akRight'#8'akBot'
- +'tom'#0#7'Caption'#6#15'Pick New Colour'#8'TabOrder'#2#3#0#0#5'TEdit'#11'Col'
- +'ourValue'#4'Left'#3'i'#1#6'Height'#2#21#3'Top'#2'8'#5'Width'#2'p'#7'Anchors'
- +#11#5'akTop'#7'akRight'#0#8'ReadOnly'#9#8'TabOrder'#2#4#4'Text'#6#11'ColourV'
- +'alue'#0#0#6'TLabel'#10'CoordValue'#4'Left'#3'i'#1#6'Height'#2#14#3'Top'#2'`'
- +#5'Width'#2'p'#7'Anchors'#11#5'akTop'#7'akRight'#0#7'Caption'#6#10'CoordValu'
- +'e'#20'Constraints.MinWidth'#2'p'#11'ParentColor'#8#0#0#6'TImage'#11'ColourI'
- +'mage'#4'Left'#3#152#0#6'Height'#2#24#3'Top'#3#209#0#5'Width'#2'9'#7'Anchors'
- +#11#6'akLeft'#7'akRight'#8'akBottom'#0#0#0#7'TButton'#8'OkButton'#4'Left'#3
- +#137#1#6'Height'#2#24#3'Top'#3#209#0#5'Width'#2'P'#7'Anchors'#11#7'akRight'#8
- +'akBottom'#0#7'Caption'#6#2'Ok'#7'OnClick'#7#13'OkButtonClick'#8'TabOrder'#2
- +#5#0#0#6'TLabel'#12'CH_RGB_Label'#4'Left'#3'i'#1#6'Height'#2#14#3'Top'#3#128
- +#0#5'Width'#2'p'#7'Anchors'#11#5'akTop'#7'akRight'#0#7'Caption'#6#9'RGBValue'
- +'s'#20'Constraints.MinWidth'#2'p'#11'ParentColor'#8#0#0#0
-]);
+{ This is an automatically generated lazarus resource file }
+
+LazarusResources.Add('TColourHistoryForm','FORMDATA',[
+ 'TPF0'#18'TColourHistoryForm'#17'ColourHistoryForm'#4'Left'#3'u'#1#6'Height'#3
+ +#250#0#3'Top'#3'4'#1#5'Width'#3#234#1#13'ActiveControl'#7#13'SelectionName'#7
+ +'Caption'#6#21'Colour Picker History'#12'ClientHeight'#3#250#0#11'ClientWidt'
+ +'h'#3#234#1#21'Constraints.MinHeight'#3#200#0#20'Constraints.MinWidth'#3#234
+ +#1#6'OnHide'#7#15'UnSetCHShowMenu'#6'OnShow'#7#13'SetCHShowMenu'#10'LCLVersi'
+ +'on'#6#6'0.9.29'#0#7'TButton'#12'DeleteButton'#4'Left'#2#16#6'Height'#2#25#3
+ +'Top'#3#208#0#5'Width'#3#128#0#7'Anchors'#11#6'akLeft'#8'akBottom'#0#7'Capti'
+ +'on'#6#6'Delete'#7'OnClick'#7#14'DeleteSelected'#8'TabOrder'#2#0#0#0#5'TEdit'
+ +#13'SelectionName'#4'Left'#3'i'#1#6'Height'#2#27#3'Top'#2#16#5'Width'#2'p'#7
+ +'Anchors'#11#5'akTop'#7'akRight'#0#8'OnChange'#7#10'ChangeName'#10'OnKeyPres'
+ +'s'#7#21'SelectionNameKeyPress'#8'TabOrder'#2#1#4'Text'#6#4'Name'#0#0#7'TBut'
+ +'ton'#19'PickNewColourButton'#4'Left'#3#217#0#6'Height'#2#25#3'Top'#3#208#0#5
+ +'Width'#3#128#0#7'Anchors'#11#7'akRight'#8'akBottom'#0#7'Caption'#6#15'Pick '
+ +'New Colour'#8'TabOrder'#2#2#0#0#5'TEdit'#11'ColourValue'#4'Left'#3'i'#1#6'H'
+ +'eight'#2#27#3'Top'#2'8'#5'Width'#2'p'#7'Anchors'#11#5'akTop'#7'akRight'#0#8
+ +'ReadOnly'#9#8'TabOrder'#2#3#4'Text'#6#11'ColourValue'#0#0#6'TLabel'#10'Coor'
+ +'dValue'#4'Left'#3'i'#1#6'Height'#2#18#3'Top'#2'`'#5'Width'#2'p'#7'Anchors'
+ +#11#5'akTop'#7'akRight'#0#7'Caption'#6#10'CoordValue'#20'Constraints.MinWidt'
+ +'h'#2'p'#11'ParentColor'#8#0#0#6'TImage'#11'ColourImage'#4'Left'#3#152#0#6'H'
+ +'eight'#2#24#3'Top'#3#209#0#5'Width'#2'9'#7'Anchors'#11#6'akLeft'#7'akRight'
+ +#8'akBottom'#0#0#0#7'TButton'#8'OkButton'#4'Left'#3#137#1#6'Height'#2#24#3'T'
+ +'op'#3#209#0#5'Width'#2'P'#7'Anchors'#11#7'akRight'#8'akBottom'#0#7'Caption'
+ +#6#2'Ok'#7'OnClick'#7#13'OkButtonClick'#8'TabOrder'#2#4#0#0#6'TLabel'#12'CH_'
+ +'RGB_Label'#4'Left'#3'i'#1#6'Height'#2#18#3'Top'#3#128#0#5'Width'#2'p'#7'Anc'
+ +'hors'#11#5'akTop'#7'akRight'#0#7'Caption'#6#9'RGBValues'#20'Constraints.Min'
+ +'Width'#2'p'#11'ParentColor'#8#0#0#9'TTreeView'#10'ColourTree'#4'Left'#2#8#6
+ +'Height'#3#169#0#3'Top'#2#16#5'Width'#3'Q'#1#7'Anchors'#11#5'akTop'#6'akLeft'
+ +#7'akRight'#8'akBottom'#0#17'DefaultItemHeight'#2#19#6'Images'#7#8'CHImages'
+ +#10'ScrollBars'#7#10'ssAutoBoth'#8'TabOrder'#2#5#8'OnChange'#7#16'ColourTree'
+ +'Change'#0#0#10'TImageList'#8'CHImages'#4'left'#3'h'#1#3'top'#3#200#0#0#0#0
+]);
diff --git a/Projects/SAMufasaGUI/colourhistory.pas b/Projects/SAMufasaGUI/colourhistory.pas
index 2412d7c..29214bf 100644
--- a/Projects/SAMufasaGUI/colourhistory.pas
+++ b/Projects/SAMufasaGUI/colourhistory.pas
@@ -1,226 +1,217 @@
-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)
- CH_RGB_Label: TLabel;
- OkButton: TButton;
- 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 ColourListAdvancedCustomDrawSubItem(Sender: TCustomListView;
- Item: TListItem; SubItem: Integer; State: TCustomDrawState;
- Stage: TCustomDrawStage; var DefaultDraw: Boolean);
- procedure DeleteSelected(Sender: TObject);
- procedure AddColObj(c: TColourPickerObject; autoName: Boolean);
-
- constructor Create(TheOwner: TComponent); override;
- destructor Destroy; override;
- procedure FormCreate(Sender: TObject);
- procedure OkButtonClick(Sender: TObject);
- procedure SelectionNameKeyPress(Sender: TObject; var Key: char);
- 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
- colour_conv, 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);
- // TODO: Proper name
- c.Name := IntToStr(c.Colour) + ' (' + 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);
-var
- r,g,b:integer;
-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;
-
- colour_conv.ColorToRGB(TColourPickerObject(Item.Data).Colour, r, g, b);
-
- { 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;
-
- CH_RGB_Label.Caption:=Format('RGB:%d,%d,%d', [r,g,b]);
-
- { 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.ColourListAdvancedCustomDrawSubItem(
- Sender: TCustomListView; Item: TListItem; SubItem: Integer;
- State: TCustomDrawState; Stage: TCustomDrawStage; var DefaultDraw: Boolean);
-begin
- if SubItem = 0 then
- ColourList.Canvas.Brush.Color := clWhite
- else
- ColourList.Canvas.Brush.Color := TColourPickerObject(Item.Data).Colour;
-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.FormCreate(Sender: TObject);
-begin
- ColourList.Column[0].Width:= 100;
- ColourList.Column[1].Width:= 500;
-end;
-
-procedure TColourHistoryForm.OkButtonClick(Sender: TObject);
-begin
- Self.close;
-end;
-
-procedure TColourHistoryForm.SelectionNameKeyPress(Sender: TObject;
- var Key: char);
-begin
- if key = #13 then
- begin
- key := #0;
- Self.close;
- end;
-end;
-
-procedure TColourHistoryForm.SetCHShowMenu(Sender: TObject);
-begin
- Form1.MenuItemColourHistory.Checked := True;
-end;
-
-procedure TColourHistoryForm.UnSetCHShowMenu(Sender: TObject);
-begin
- Form1.MenuItemColourHistory.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)
+ CH_RGB_Label: TLabel;
+ CHImages: TImageList;
+ OkButton: TButton;
+ ColourValue: TEdit;
+ CoordValue: TLabel;
+ ColourImage: TImage;
+ PickNewColourButton: TButton;
+ DeleteButton: TButton;
+ SelectionName: TEdit;
+ ColourTree: TTreeView;
+ procedure ChangeName(Sender: TObject);
+ procedure ColourTreeChange(Sender: TObject; Node: TTreeNode);
+ procedure DeleteSelected(Sender: TObject);
+ procedure AddColObj(c: TColourPickerObject; autoName: Boolean);
+
+ constructor Create(TheOwner: TComponent); override;
+ destructor Destroy; override;
+ procedure OkButtonClick(Sender: TObject);
+ procedure SelectionNameKeyPress(Sender: TObject; var Key: char);
+ procedure SetCHShowMenu(Sender: TObject);
+ procedure UnSetCHShowMenu(Sender: TObject);
+ private
+ { private declarations }
+ protected
+ procedure AddColObj(c: TColourPickerObject);
+ public
+ IndexSelected: Integer;
+ { public declarations }
+ end;
+
+
+
+var
+ ColourHistoryForm: TColourHistoryForm;
+
+implementation
+uses
+ colour_conv, 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
+ // TODO: Proper name
+ c.Name := IntToStr(c.Colour);
+ end;
+ Self.AddColObj(c);
+end;
+
+procedure TColourHistoryForm.AddColObj(c: TColourPickerObject);
+
+var
+ it: TTreeNode;
+ bmp: TBitmap;
+begin
+ it := ColourTree.Items.Add(nil, c.Name);
+ it.Data := c;
+ ColourTree.Selected := it;
+
+ bmp:=TBitmap.Create;
+ bmp.SetSize(16,16);
+ bmp.Canvas.Brush.Color:=c.Colour;
+ bmp.Canvas.Rectangle(0,0,16,16);
+
+ it.ImageIndex:= CHImages.Add(bmp,nil);
+ bmp.Free;
+end;
+
+procedure TColourHistoryForm.DeleteSelected(Sender: TObject);
+
+var
+ i:integer;
+
+begin
+ if (Assigned(ColourTree.Selected)) then
+ begin
+ if Assigned(ColourTree.Selected.Data) then
+ TColourPickerObject(ColourTree.Selected.Data).Free;
+ i:=ColourTree.Selected.ImageIndex;
+ ColourTree.Selected.ImageIndex:=0;
+ CHImages.Delete(i);
+
+ ColourTree.Selected.Delete;
+ end;
+end;
+
+procedure TColourHistoryForm.ColourTreeChange(Sender: TObject; Node: TTreeNode);
+var
+ r,g,b:integer;
+begin
+ if not Assigned(Node) then
+ exit;
+ if not Node.Selected then
+ exit;
+
+ { This only occurs when we have manually added an item with the Form Editor }
+ if not Assigned(Node.Data) then
+ exit;
+
+ colour_conv.ColorToRGB(TColourPickerObject(Node.Data).Colour, r, g, b);
+
+ { Change Form Text / Values }
+ ColourValue.Caption := IntToStr(TColourPickerObject(Node.Data).Colour);
+ CoordValue.Caption := 'Coords: ' + IntToStr(TColourPickerObject(Node.Data).Pos.X) +
+ ', ' + IntToStr(TColourPickerObject(Node.Data).Pos.Y);
+ SelectionName.Text := TColourPickerObject(Node.Data).Name;
+
+ CH_RGB_Label.Caption:=Format('RGB:%d,%d,%d', [r,g,b]);
+
+ { Draw the Image }
+ ColourImage.Canvas.Brush.Color := TColourPickerObject(Node.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(ColourTree.Selected) then
+ begin
+ WriteLn('We double clicked but have nothing Selected?');
+ exit;
+ end;
+ ColourTree.Selected.Text := SelectionName.Text;
+ TColourPickerObject(ColourTree.Selected.Data).Name := SelectionName.Text;
+end;
+
+constructor TColourHistoryForm.Create(TheOwner: TComponent);
+begin
+ inherited Create(TheOwner);
+
+ PickNewColourButton.OnClick:= @Form1.ButtonPickClick;
+end;
+
+destructor TColourHistoryForm.Destroy;
+begin
+ PickNewColourButton.OnClick := nil;
+
+ inherited Destroy;
+end;
+
+procedure TColourHistoryForm.OkButtonClick(Sender: TObject);
+begin
+ Self.Close;
+end;
+
+procedure TColourHistoryForm.SelectionNameKeyPress(Sender: TObject;
+ var Key: char);
+begin
+ if key = #13 then
+ begin
+ key := #0;
+ Self.close;
+ end;
+end;
+
+procedure TColourHistoryForm.SetCHShowMenu(Sender: TObject);
+begin
+ Form1.MenuItemColourHistory.Checked := True;
+end;
+
+procedure TColourHistoryForm.UnSetCHShowMenu(Sender: TObject);
+begin
+ Form1.MenuItemColourHistory.Checked := False;
+end;
+
+initialization
+ {$I colourhistory.lrs}
+
+end.
+
diff --git a/Projects/SAMufasaGUI/project1.lpi b/Projects/SAMufasaGUI/project1.lpi
index 9fd763a..93ab813 100644
--- a/Projects/SAMufasaGUI/project1.lpi
+++ b/Projects/SAMufasaGUI/project1.lpi
@@ -10,7 +10,7 @@