1
0
mirror of https://github.com/moparisthebest/Simba synced 2024-11-22 01:02:17 -05:00

RGB in Colour History

git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@278 3f818213-9676-44b0-a9b4-5e4c4e03d09d
This commit is contained in:
Wizzup? 2009-12-16 13:37:07 +00:00
parent dfb8e0fa7a
commit a9b3f15758
4 changed files with 274 additions and 258 deletions

View File

@ -90,4 +90,14 @@ object ColourHistoryForm: TColourHistoryForm
OnClick = OkButtonClick OnClick = OkButtonClick
TabOrder = 5 TabOrder = 5
end 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
end end

View File

@ -26,5 +26,8 @@ LazarusResources.Add('TColourHistoryForm','FORMDATA',[
+'t'#3#152#0#6'Height'#2#24#3'Top'#3#209#0#5'Width'#2'9'#7'Anchors'#11#6'akLe' +'t'#3#152#0#6'Height'#2#24#3'Top'#3#209#0#5'Width'#2'9'#7'Anchors'#11#6'akLe'
+'ft'#7'akRight'#8'akBottom'#0#0#0#7'TButton'#8'OkButton'#4'Left'#3#137#1#6'H' +'ft'#7'akRight'#8'akBottom'#0#0#0#7'TButton'#8'OkButton'#4'Left'#3#137#1#6'H'
+'eight'#2#24#3'Top'#3#209#0#5'Width'#2'P'#7'Anchors'#11#7'akRight'#8'akBotto' +'eight'#2#24#3'Top'#3#209#0#5'Width'#2'P'#7'Anchors'#11#7'akRight'#8'akBotto'
+'m'#0#7'Caption'#6#2'Ok'#7'OnClick'#7#13'OkButtonClick'#8'TabOrder'#2#5#0#0#0 +'m'#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#18#3'Top'#3#128#0#5'Wid'
+'th'#2'p'#7'Anchors'#11#5'akTop'#7'akRight'#0#7'Caption'#6#9'RGBValues'#20'C'
+'onstraints.MinWidth'#2'p'#11'ParentColor'#8#0#0#0
]); ]);

View File

@ -1,198 +1,205 @@
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)
OkButton: TButton; CH_RGB_Label: TLabel;
ColourValue: TEdit; OkButton: TButton;
CoordValue: TLabel; ColourValue: TEdit;
ColourImage: TImage; CoordValue: TLabel;
PickNewColourButton: TButton; ColourImage: TImage;
DeleteButton: TButton; PickNewColourButton: TButton;
ColourList: TListView; DeleteButton: TButton;
SelectionName: TEdit; ColourList: TListView;
procedure ChangeName(Sender: TObject); SelectionName: TEdit;
procedure ChangeViewData(Sender: TObject; Item: TListItem; Selected: Boolean procedure ChangeName(Sender: TObject);
); procedure ChangeViewData(Sender: TObject; Item: TListItem; Selected: Boolean
procedure DeleteSelected(Sender: TObject); );
procedure AddColObj(c: TColourPickerObject; autoName: Boolean); procedure DeleteSelected(Sender: TObject);
procedure AddColObj(c: TColourPickerObject; autoName: Boolean);
constructor Create(TheOwner: TComponent); override;
destructor Destroy; override; constructor Create(TheOwner: TComponent); override;
procedure OkButtonClick(Sender: TObject); destructor Destroy; override;
procedure SelectionNameKeyPress(Sender: TObject; var Key: char); procedure OkButtonClick(Sender: TObject);
procedure SetCHShowMenu(Sender: TObject); procedure SelectionNameKeyPress(Sender: TObject; var Key: char);
procedure UnSetCHShowMenu(Sender: TObject); procedure SetCHShowMenu(Sender: TObject);
private procedure UnSetCHShowMenu(Sender: TObject);
Colour_Count: Integer; private
{ private declarations } Colour_Count: Integer;
protected { private declarations }
procedure AddColObj(c: TColourPickerObject); protected
public procedure AddColObj(c: TColourPickerObject);
IndexSelected: Integer; public
{ public declarations } IndexSelected: Integer;
end; { public declarations }
end;
var
ColourHistoryForm: TColourHistoryForm; var
ColourHistoryForm: TColourHistoryForm;
implementation
uses implementation
TestUnit; uses
colour_conv, TestUnit;
constructor TColourPickerObject.Create(C: Integer; P: TPoint; N: String);
begin constructor TColourPickerObject.Create(C: Integer; P: TPoint; N: String);
inherited Create; begin
Self.Colour := C; inherited Create;
Self.Pos := P; Self.Colour := C;
Self.Name:= N; Self.Pos := P;
end; Self.Name:= N;
end;
destructor TColourPickerObject.Destroy;
begin destructor TColourPickerObject.Destroy;
begin
inherited Destroy;
end; inherited Destroy;
end;
{ TColourHistoryForm }
{ TColourHistoryForm }
procedure TColourHistoryForm.AddColObj(c: TColourPickerObject; autoName: Boolean);
begin procedure TColourHistoryForm.AddColObj(c: TColourPickerObject; autoName: Boolean);
if autoName then begin
begin if autoName then
Inc(Colour_Count); begin
c.Name := 'Untitled (' + IntToStr(Colour_Count) + ')'; Inc(Colour_Count);
end; c.Name := 'Untitled (' + IntToStr(Colour_Count) + ')';
Self.AddColObj(c); end;
end; Self.AddColObj(c);
end;
procedure TColourHistoryForm.AddColObj(c: TColourPickerObject);
procedure TColourHistoryForm.AddColObj(c: TColourPickerObject);
var
it: TListItem; var
begin it: TListItem;
it := ColourList.Items.Add; begin
it.Data := c; it := ColourList.Items.Add;
it.Caption:= c.Name; it.Data := c;
ColourList.Selected := it; it.Caption:= c.Name;
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 var
exit; r,g,b:integer;
if not Item.Selected then begin
exit; if not Assigned(Item) then
exit;
{ This only occurs when we have manually added an item with the Form Editor } if not Item.Selected then
if not Assigned(Item.Data) then exit;
exit;
{ This only occurs when we have manually added an item with the Form Editor }
{ Change Form Text / Values } if not Assigned(Item.Data) then
ColourValue.Caption := IntToStr(TColourPickerObject(Item.Data).Colour); exit;
CoordValue.Caption := 'Coords: ' + IntToStr(TColourPickerObject(Item.Data).Pos.X) +
', ' + IntToStr(TColourPickerObject(Item.Data).Pos.Y); colour_conv.ColorToRGB(TColourPickerObject(Item.Data).Colour, r, g, b);
SelectionName.Text := TColourPickerObject(Item.Data).Name;
{ Change Form Text / Values }
{ Draw the Image } ColourValue.Caption := IntToStr(TColourPickerObject(Item.Data).Colour);
ColourImage.Canvas.Brush.Color := TColourPickerObject(Item.Data).Colour; CoordValue.Caption := 'Coords: ' + IntToStr(TColourPickerObject(Item.Data).Pos.X) +
ColourImage.Canvas.Rectangle(0,0,ColourImage.Width, ColourImage.Height); ', ' + IntToStr(TColourPickerObject(Item.Data).Pos.Y);
SelectionName.Text := TColourPickerObject(Item.Data).Name;
if Self.Visible then
begin CH_RGB_Label.Caption:=Format('RGB:%d,%d%d', [r,g,b]);
try
SelectionName.SetFocus; { Draw the Image }
finally ColourImage.Canvas.Brush.Color := TColourPickerObject(Item.Data).Colour;
end; ColourImage.Canvas.Rectangle(0,0,ColourImage.Width, ColourImage.Height);
end;
end; if Self.Visible then
begin
procedure TColourHistoryForm.ChangeName(Sender: TObject); try
begin SelectionName.SetFocus;
if not Assigned(ColourList.Selected) then finally
begin end;
WriteLn('We double clicked but have nothing Selected?'); end;
exit; end;
end;
ColourList.Selected.Caption := SelectionName.Text; procedure TColourHistoryForm.ChangeName(Sender: TObject);
TColourPickerObject(ColourList.Selected.Data).Name := SelectionName.Text; begin
end; if not Assigned(ColourList.Selected) then
begin
constructor TColourHistoryForm.Create(TheOwner: TComponent); WriteLn('We double clicked but have nothing Selected?');
begin exit;
inherited Create(TheOwner); end;
ColourList.Selected.Caption := SelectionName.Text;
Colour_Count := 0; TColourPickerObject(ColourList.Selected.Data).Name := SelectionName.Text;
PickNewColourButton.OnClick:= @Form1.ButtonPickClick; end;
end;
constructor TColourHistoryForm.Create(TheOwner: TComponent);
destructor TColourHistoryForm.Destroy; begin
begin inherited Create(TheOwner);
PickNewColourButton.OnClick := nil;
Colour_Count := 0; Colour_Count := 0;
PickNewColourButton.OnClick:= @Form1.ButtonPickClick;
inherited Destroy; end;
end;
destructor TColourHistoryForm.Destroy;
procedure TColourHistoryForm.OkButtonClick(Sender: TObject); begin
begin PickNewColourButton.OnClick := nil;
Self.close; Colour_Count := 0;
end;
inherited Destroy;
procedure TColourHistoryForm.SelectionNameKeyPress(Sender: TObject; end;
var Key: char);
begin procedure TColourHistoryForm.OkButtonClick(Sender: TObject);
if key = #13 then begin
begin Self.close;
key := #0; end;
Self.close;
end; procedure TColourHistoryForm.SelectionNameKeyPress(Sender: TObject;
end; var Key: char);
begin
procedure TColourHistoryForm.SetCHShowMenu(Sender: TObject); if key = #13 then
begin begin
Form1.MenuItemColourHistory.Checked := True; key := #0;
end; Self.close;
end;
procedure TColourHistoryForm.UnSetCHShowMenu(Sender: TObject); end;
begin
Form1.MenuItemColourHistory.Checked := False; procedure TColourHistoryForm.SetCHShowMenu(Sender: TObject);
end; begin
Form1.MenuItemColourHistory.Checked := True;
initialization end;
{$I colourhistory.lrs}
procedure TColourHistoryForm.UnSetCHShowMenu(Sender: TObject);
end. begin
Form1.MenuItemColourHistory.Checked := False;
end;
initialization
{$I colourhistory.lrs}
end.

View File

@ -10,7 +10,7 @@
<TargetFileExt Value=""/> <TargetFileExt Value=""/>
<Title Value="Mufasa Stand Alone"/> <Title Value="Mufasa Stand Alone"/>
<UseXPManifest Value="True"/> <UseXPManifest Value="True"/>
<ActiveEditorIndexAtStart Value="4"/> <ActiveEditorIndexAtStart Value="5"/>
</General> </General>
<VersionInfo> <VersionInfo>
<ProjectVersion Value=""/> <ProjectVersion Value=""/>
@ -167,8 +167,8 @@
<HasResources Value="True"/> <HasResources Value="True"/>
<ResourceBaseClass Value="Form"/> <ResourceBaseClass Value="Form"/>
<UnitName Value="TestUnit"/> <UnitName Value="TestUnit"/>
<CursorPos X="32" Y="742"/> <CursorPos X="61" Y="756"/>
<TopLine Value="734"/> <TopLine Value="110"/>
<EditorIndex Value="4"/> <EditorIndex Value="4"/>
<UsageCount Value="202"/> <UsageCount Value="202"/>
<Loaded Value="True"/> <Loaded Value="True"/>
@ -730,7 +730,7 @@
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="colourpicker"/> <UnitName Value="colourpicker"/>
<CursorPos X="1" Y="148"/> <CursorPos X="1" Y="148"/>
<TopLine Value="113"/> <TopLine Value="1"/>
<EditorIndex Value="8"/> <EditorIndex Value="8"/>
<UsageCount Value="201"/> <UsageCount Value="201"/>
<Loaded Value="True"/> <Loaded Value="True"/>
@ -1513,9 +1513,11 @@
<ComponentName Value="ColourHistoryForm"/> <ComponentName Value="ColourHistoryForm"/>
<ResourceBaseClass Value="Form"/> <ResourceBaseClass Value="Form"/>
<UnitName Value="colourhistory"/> <UnitName Value="colourhistory"/>
<CursorPos X="88" Y="7"/> <CursorPos X="75" Y="103"/>
<TopLine Value="1"/> <TopLine Value="79"/>
<EditorIndex Value="5"/>
<UsageCount Value="93"/> <UsageCount Value="93"/>
<Loaded Value="True"/>
</Unit208> </Unit208>
<Unit209> <Unit209>
<Filename Value="../../../Documents/lazarus/lcl/comctrls.pp"/> <Filename Value="../../../Documents/lazarus/lcl/comctrls.pp"/>
@ -1799,7 +1801,7 @@
<ComponentState Value="1"/> <ComponentState Value="1"/>
<CursorPos X="62" Y="62"/> <CursorPos X="62" Y="62"/>
<TopLine Value="54"/> <TopLine Value="54"/>
<EditorIndex Value="5"/> <EditorIndex Value="6"/>
<UsageCount Value="36"/> <UsageCount Value="36"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit249> </Unit249>
@ -1856,13 +1858,11 @@
<UsageCount Value="10"/> <UsageCount Value="10"/>
</Unit257> </Unit257>
<Unit258> <Unit258>
<Filename Value="../../../../../../../usr/lib/lazarus/components/mouseandkeyinput/keyinputintf.pas"/> <Filename Value="../../../../../../usr/lib/lazarus/components/mouseandkeyinput/keyinputintf.pas"/>
<UnitName Value="KeyInputIntf"/> <UnitName Value="KeyInputIntf"/>
<CursorPos X="16" Y="50"/> <CursorPos X="16" Y="50"/>
<TopLine Value="47"/> <TopLine Value="47"/>
<EditorIndex Value="6"/>
<UsageCount Value="13"/> <UsageCount Value="13"/>
<Loaded Value="True"/>
</Unit258> </Unit258>
<Unit259> <Unit259>
<Filename Value="project1.lpi"/> <Filename Value="project1.lpi"/>
@ -1872,127 +1872,123 @@
<SyntaxHighlighter Value="XML"/> <SyntaxHighlighter Value="XML"/>
</Unit259> </Unit259>
</Units> </Units>
<JumpHistory Count="30" HistoryIndex="29"> <JumpHistory Count="29" HistoryIndex="28">
<Position1> <Position1>
<Filename Value="../../Units/MMLCore/finder.pas"/> <Filename Value="../../Units/MMLCore/finder.pas"/>
<Caret Line="1681" Column="29" TopLine="1656"/> <Caret Line="1616" Column="14" TopLine="1601"/>
</Position1> </Position1>
<Position2> <Position2>
<Filename Value="../../Units/MMLCore/finder.pas"/> <Filename Value="../../Units/MMLCore/finder.pas"/>
<Caret Line="1616" Column="14" TopLine="1601"/> <Caret Line="104" Column="31" TopLine="89"/>
</Position2> </Position2>
<Position3> <Position3>
<Filename Value="../../Units/MMLCore/finder.pas"/> <Filename Value="../../Units/MMLCore/finder.pas"/>
<Caret Line="104" Column="31" TopLine="89"/> <Caret Line="1681" Column="96" TopLine="1662"/>
</Position3> </Position3>
<Position4> <Position4>
<Filename Value="../../Units/MMLCore/finder.pas"/>
<Caret Line="1681" Column="96" TopLine="1662"/>
</Position4>
<Position5>
<Filename Value="../../Units/MMLAddon/colourpicker.pas"/> <Filename Value="../../Units/MMLAddon/colourpicker.pas"/>
<Caret Line="137" Column="23" TopLine="121"/> <Caret Line="137" Column="23" TopLine="121"/>
</Position4>
<Position5>
<Filename Value="testunit.pas"/>
<Caret Line="40" Column="51" TopLine="40"/>
</Position5> </Position5>
<Position6> <Position6>
<Filename Value="testunit.pas"/> <Filename Value="testunit.pas"/>
<Caret Line="40" Column="51" TopLine="40"/> <Caret Line="45" Column="51" TopLine="1"/>
</Position6> </Position6>
<Position7> <Position7>
<Filename Value="testunit.pas"/> <Filename Value="testunit.pas"/>
<Caret Line="45" Column="51" TopLine="1"/> <Caret Line="379" Column="26" TopLine="359"/>
</Position7> </Position7>
<Position8> <Position8>
<Filename Value="testunit.pas"/> <Filename Value="testunit.pas"/>
<Caret Line="379" Column="26" TopLine="359"/> <Caret Line="362" Column="32" TopLine="359"/>
</Position8> </Position8>
<Position9> <Position9>
<Filename Value="testunit.pas"/> <Filename Value="testunit.pas"/>
<Caret Line="362" Column="32" TopLine="359"/> <Caret Line="1311" Column="57" TopLine="1291"/>
</Position9> </Position9>
<Position10> <Position10>
<Filename Value="testunit.pas"/> <Filename Value="testunit.pas"/>
<Caret Line="1311" Column="57" TopLine="1291"/> <Caret Line="1316" Column="57" TopLine="1291"/>
</Position10> </Position10>
<Position11> <Position11>
<Filename Value="testunit.pas"/> <Filename Value="testunit.pas"/>
<Caret Line="1316" Column="57" TopLine="1291"/> <Caret Line="10" Column="75" TopLine="1"/>
</Position11> </Position11>
<Position12> <Position12>
<Filename Value="testunit.pas"/> <Filename Value="testunit.pas"/>
<Caret Line="10" Column="75" TopLine="1"/> <Caret Line="1311" Column="65" TopLine="1291"/>
</Position12> </Position12>
<Position13> <Position13>
<Filename Value="testunit.pas"/> <Filename Value="testunit.pas"/>
<Caret Line="1311" Column="65" TopLine="1291"/> <Caret Line="8" Column="103" TopLine="3"/>
</Position13> </Position13>
<Position14> <Position14>
<Filename Value="testunit.pas"/> <Filename Value="testunit.pas"/>
<Caret Line="8" Column="103" TopLine="3"/> <Caret Line="180" Column="25" TopLine="160"/>
</Position14> </Position14>
<Position15> <Position15>
<Filename Value="testunit.pas"/> <Filename Value="testunit.pas"/>
<Caret Line="180" Column="25" TopLine="160"/> <Caret Line="1311" Column="57" TopLine="1291"/>
</Position15> </Position15>
<Position16> <Position16>
<Filename Value="testunit.pas"/> <Filename Value="testunit.pas"/>
<Caret Line="1311" Column="57" TopLine="1291"/> <Caret Line="10" Column="108" TopLine="1"/>
</Position16> </Position16>
<Position17> <Position17>
<Filename Value="testunit.pas"/>
<Caret Line="10" Column="108" TopLine="1"/>
</Position17>
<Position18>
<Filename Value="../../Units/MMLAddon/mmlpsthread.pas"/> <Filename Value="../../Units/MMLAddon/mmlpsthread.pas"/>
<Caret Line="104" Column="73" TopLine="73"/> <Caret Line="104" Column="73" TopLine="73"/>
</Position18> </Position17>
<Position19> <Position18>
<Filename Value="testunit.pas"/> <Filename Value="testunit.pas"/>
<Caret Line="165" Column="119" TopLine="160"/> <Caret Line="165" Column="119" TopLine="160"/>
</Position19> </Position18>
<Position20> <Position19>
<Filename Value="../../../../../../../usr/lib/lazarus/components/mouseandkeyinput/keyinputintf.pas"/>
<Caret Line="1" Column="1" TopLine="1"/>
</Position20>
<Position21>
<Filename Value="project1.lpr"/> <Filename Value="project1.lpr"/>
<Caret Line="38" Column="79" TopLine="5"/> <Caret Line="38" Column="79" TopLine="5"/>
</Position19>
<Position20>
<Filename Value="testunit.pas"/>
<Caret Line="1129" Column="75" TopLine="1105"/>
</Position20>
<Position21>
<Filename Value="debugimage.pas"/>
<Caret Line="115" Column="99" TopLine="94"/>
</Position21> </Position21>
<Position22> <Position22>
<Filename Value="testunit.pas"/> <Filename Value="testunit.pas"/>
<Caret Line="1129" Column="75" TopLine="1105"/> <Caret Line="1053" Column="33" TopLine="1049"/>
</Position22> </Position22>
<Position23> <Position23>
<Filename Value="debugimage.pas"/> <Filename Value="debugimage.pas"/>
<Caret Line="115" Column="99" TopLine="94"/> <Caret Line="81" Column="35" TopLine="78"/>
</Position23> </Position23>
<Position24> <Position24>
<Filename Value="testunit.pas"/>
<Caret Line="1053" Column="33" TopLine="1049"/>
</Position24>
<Position25>
<Filename Value="debugimage.pas"/>
<Caret Line="81" Column="35" TopLine="78"/>
</Position25>
<Position26>
<Filename Value="debugimage.pas"/> <Filename Value="debugimage.pas"/>
<Caret Line="71" Column="47" TopLine="59"/> <Caret Line="71" Column="47" TopLine="59"/>
</Position24>
<Position25>
<Filename Value="testunit.pas"/>
<Caret Line="1052" Column="53" TopLine="1049"/>
</Position25>
<Position26>
<Filename Value="testunit.pas"/>
<Caret Line="993" Column="49" TopLine="736"/>
</Position26> </Position26>
<Position27> <Position27>
<Filename Value="testunit.pas"/> <Filename Value="testunit.pas"/>
<Caret Line="1052" Column="53" TopLine="1049"/> <Caret Line="817" Column="39" TopLine="23"/>
</Position27> </Position27>
<Position28> <Position28>
<Filename Value="testunit.pas"/> <Filename Value="testunit.pas"/>
<Caret Line="993" Column="49" TopLine="736"/> <Caret Line="24" Column="53" TopLine="1"/>
</Position28> </Position28>
<Position29> <Position29>
<Filename Value="testunit.pas"/> <Filename Value="colourhistory.pas"/>
<Caret Line="817" Column="39" TopLine="23"/> <Caret Line="7" Column="88" TopLine="1"/>
</Position29> </Position29>
<Position30>
<Filename Value="testunit.pas"/>
<Caret Line="24" Column="53" TopLine="1"/>
</Position30>
</JumpHistory> </JumpHistory>
</ProjectOptions> </ProjectOptions>
<CompilerOptions> <CompilerOptions>