Skip to content

Commit

Permalink
More LCL import cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
ollydev committed Mar 11, 2024
1 parent edb7d29 commit c5e35ca
Show file tree
Hide file tree
Showing 14 changed files with 258 additions and 337 deletions.
61 changes: 58 additions & 3 deletions Examples/form.simba
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ begin
WriteLn('List selection changed to: ', TLazListBox(Sender).GetSelectedText());
end;

procedure DoTabChange(Sender: TObject);
begin
WriteLn('Tab changed to tab #', TLazPageControl(Sender).GetActiveTabIndex());
end;

procedure ShowMyForm;
var
Button: TLazButton;
Expand All @@ -40,24 +45,37 @@ var
Panel: TLazPanel;
Img: TLazImage;
SimbaImg: TImage;
Tabs: TLazPageControl;
Tab1, Tab2: TLazTabSheet;
SpeedButton: TLazSpeedButton;
LazBmp: TLazBitmap;
Group: TLazGroupBox;
begin
Form := TLazForm.Create();
Form.SetCaption('Example form');
Form.SetOnMouseDown(@FormMouseDown);
Form.SetOnMouseUp(@FormMouseUp);
Form.SetWidth(700);
Form.SetHeight(500);
Form.SetHeight(700);
Form.SetPosition(poScreenCenter);
Form.SetColor(Colors.DARK_GREY);
Form.SetBorderStyle(bsSingle); // Do not allow resizing

SimbaImg := TImage.CreateFromTarget([0,0,400,400]);

Img := TLazImage.Create(Form);
Img.SetParent(Form);
Group := TLazGroupBox.Create(Form);
Group.SetParent(Form);
Group.SetBounds(400,200,200,200);
Group.SetAutoSize(True);
Group.SetCaption('Target image');
Group.GetFont().SetSize(15);

Img := TLazImage.Create(Group);
Img.SetParent(Group);
Img.SetBounds(400,200,200,200);
Img.SetStretch(True);
Img.GetPicture().SetBitmap(SimbaImg.ToLazBitmap());
Img.GetBorderSpacing.SetAround(10);

SimbaImg.Free();

Expand Down Expand Up @@ -109,6 +127,43 @@ begin
List.GetItems().Add('Item 3');
List.SetOnSelectionChange(@DoSelectionChange);

Tabs := TLazPageControl.Create(Form);
Tabs.SetParent(Form);
Tabs.SetTop(450);
Tabs.SetLeft(50);
Tabs.SetWidth(400);
Tabs.SetOnChange(@DoTabChange);
Tab1 := Tabs.AddTab();
Tab1.SetCaption('Tab 1');
Tab2 := Tabs.AddTab();
Tab2.SetCaption('Tab 2');

Button := TLazButton.Create(Tab1);
Button.SetParent(Tab1);
Button.SetAutoSize(True);
Button.SetCaption('This button is on tab 1!');

Button := TLazButton.Create(Tab2);
Button.SetParent(Tab2);
Button.SetAutoSize(True);
Button.SetCaption('This button is on tab 2!');

LazBmp := TLazBitmap.Create();
LazBmp.SetWidth(25);
LazBmp.SetHeight(25);
with LazBmp.GetCanvas() do
begin
GetPen().SetColor(Colors.RED);
GetBrush().SetColor(Colors.WHITE);
Rectangle(0,0,25,25);
end;

SpeedButton := TLazSpeedButton.Create(Form);
SpeedButton.SetParent(Form);
SpeedButton.SetBounds(200,350,150,50);
SpeedButton.SetCaption('Hello World');
SpeedButton.SetGlyph(LazBmp);

Form.ShowModal();

WriteLn('Form has been closed.');
Expand Down
2 changes: 1 addition & 1 deletion Examples/image.simba
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ begin
Img.DrawText('Hello world', [125, 125], $00FF00);

WriteLn('Color at 250,250 is ', '$' + IntToHex(Img.GetPixel(250, 250)));
WriteLn('Available fonts: ', Img.LoadedFontNames());
WriteLn('Available fonts: ', Img.FontNames());

Img.Show(); // Show on Simba's debug image
Img.Free(); // Images must be freed
Expand Down
14 changes: 6 additions & 8 deletions Examples/stopwatch.simba
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@ program StopWatchExample;

procedure SomethingToTime;
var
Counter: Integer;
T: Integer;
begin
while (Counter < 100) do
begin
Sleep(Random(30));
Inc(Counter);
end;
T := Random(1500, 3000);
WriteLn('Sleeping for: ', T);
Sleep(T);
end;

var
StopWatch: TStopWatch;
Milliseconds: Integer;
Milliseconds: Double;
Formatted: String;
begin
StopWatch.Start();
Expand All @@ -24,5 +22,5 @@ begin
Formatted := StopWatch.ElapsedFmt('s');

WriteLn('Milliseconds: ', Milliseconds);
WriteLN('Seconds: ', Formatted);
WriteLn('Seconds: ', Formatted);
end.
Binary file modified Source/Simba.res
Binary file not shown.
2 changes: 1 addition & 1 deletion Source/array/simba.array_ord.pas
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface

uses
Classes, SysUtils,
simba.base, simba.colormath;
simba.base;

type
TIntegerArrayHelper = type helper for TIntegerArray
Expand Down
2 changes: 1 addition & 1 deletion Source/array/simba.array_point.pas
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ implementation
uses
Math,
simba.array_pointarray, simba.arraybuffer, simba.geometry, simba.math,
simba.algo_sort, simba.algo_intersection, simba.slacktree, simba.algo_unique,
simba.algo_sort, simba.algo_intersection, simba.slacktree,
simba.array_ord, simba.matrix_bool, simba.matrix_int, simba.box;

procedure GetAdjacent4(var Adj: TPointArray; const P: TPoint); inline;
Expand Down
1 change: 0 additions & 1 deletion Source/imagebox/simba.imagebox_canvas.pas
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,6 @@ procedure TSimbaImageBoxCanvas.DrawCross(Center: TPoint; Radius: Integer; Color:

procedure TSimbaImageBoxCanvas.DrawCrossArray(Centers: TPointArray; Radius: Integer; Color: TColor);
var
I: Integer;
Center: TPoint;
begin
Radius := Radius div 2;
Expand Down
2 changes: 1 addition & 1 deletion Source/imagebox/simba.imagebox_drawers.pas
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ implementation

uses
Math,
simba.matrix_float, simba.array_point, simba.box, simba.algo_sort;
simba.matrix_float, simba.algo_sort;

generic procedure DoDrawPolygonFilled<_T>(Poly: TPointArray; DrawInfo: TDrawInfo);
type
Expand Down
Loading

0 comments on commit c5e35ca

Please sign in to comment.