1
0
mirror of https://github.com/moparisthebest/Simba synced 2024-08-13 16:53:59 -04: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
TabOrder = 5
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

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'
+'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'
+'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;
{$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)
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 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
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.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;
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 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
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);
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);
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.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.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.

View File

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