Skip to content

Commit 1584e86

Browse files
committed
Merge remote-tracking branch 'remotes/origin/dev/acaform' into simba2000
2 parents de32fd0 + 29cde22 commit 1584e86

13 files changed

Lines changed: 709 additions & 342 deletions

Examples/form_aca.simba

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
var
2+
AcaForm: TACAForm;
3+
4+
function GetImageForACA: TImage;
5+
begin
6+
Result := Target.GetImage();
7+
end;
8+
9+
// On button click, set a custom image.
10+
// Clicking Update Image will still use GetImageForACA though
11+
procedure OnSomeButtonClick(Sender: TLazObject);
12+
var
13+
img: TImage;
14+
begin
15+
img := new TImage(100,100);
16+
img.Fill(Random($FFFFFF));
17+
for 1 to 100 do
18+
img.Pixel[Random(100), Random(100)] := Random($FFFFFF);
19+
20+
AcaForm.Image := img;
21+
// can also maniplate the imagebox with some zooming
22+
AcaForm.ImageBox.Zoom := 800;
23+
end;
24+
25+
begin
26+
AcaForm := TACAForm.Create(@GetImageForACA);
27+
AcaForm.Width := 1600;
28+
AcaForm.Height := 800;
29+
30+
// Add custom things to user panel
31+
// sorry no custom (themed) components for the time being
32+
with TLazButton.Create(AcaForm) do
33+
begin
34+
Parent := AcaForm.UserPanel;
35+
Caption := 'SomeButton';
36+
AutoSize := True;
37+
Align := ELazAlign.LEFT;
38+
BorderSpacing.Around := 5;
39+
OnClick := @OnSomeButtonClick;
40+
end;
41+
42+
with TLazEdit.Create(AcaForm) do
43+
begin
44+
Parent := AcaForm.UserPanel;
45+
Caption := 'SomeInput';
46+
Align := ELazAlign.LEFT;
47+
Width := 200;
48+
Font.Color := $000000;
49+
BorderSpacing.Around := 5;
50+
end;
51+
52+
// can populate the colors too
53+
AcaForm.Colors := [Colors.RED, Colors.GREEN];
54+
AcaForm.ShowModal();
55+
56+
WriteLn('The best color was: ', AcaForm.BestColor);
57+
58+
AcaForm.Free();
59+
end;

Source/Simba.lpi

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<TextDesc Value=""/>
1818
</XPManifest>
1919
<Icon Value="0"/>
20-
<Resources Count="28">
20+
<Resources Count="29">
2121
<Resource_0 FileName="..\Examples\array.simba" Type="RCDATA" ResourceName="EXAMPLE_ARRAY"/>
2222
<Resource_1 FileName="..\Examples\function.simba" Type="RCDATA" ResourceName="EXAMPLE_FUNCTION"/>
2323
<Resource_2 FileName="..\Examples\static_method.simba" Type="RCDATA" ResourceName="EXAMPLE_STATIC_METHOD"/>
@@ -27,11 +27,11 @@
2727
<Resource_6 FileName="..\Examples\image_drawtext.simba" Type="RCDATA" ResourceName="EXAMPLE_IMAGE_DRAW_TEXT"/>
2828
<Resource_7 FileName="..\Examples\cluster_points.simba" Type="RCDATA" ResourceName="EXAMPLE_CLUSTER_POINTS"/>
2929
<Resource_8 FileName="..\Examples\form.simba" Type="RCDATA" ResourceName="EXAMPLE_FORM"/>
30-
<Resource_9 FileName="..\Examples\form_dragablepanel.simba" Type="RCDATA" ResourceName="EXAMPLE_FORM_DRAGABLE_PANEL"/>
31-
<Resource_10 FileName="..\Examples\form_imagebox.simba" Type="RCDATA" ResourceName="EXAMPLE_FORM_IMAGEBOX"/>
30+
<Resource_9 FileName="..\Examples\form_dragablepanel.simba" Type="RCDATA" ResourceName="EXAMPLE_FORM_DRAGABLE_PANEL"/>
31+
<Resource_10 FileName="..\Examples\form_imagebox.simba" Type="RCDATA" ResourceName="EXAMPLE_FORM_IMAGEBOX"/>
3232
<Resource_11 FileName="..\Examples\irc.simba" Type="RCDATA" ResourceName="EXAMPLE_IRC"/>
3333
<Resource_12 FileName="..\Examples\asyncmouse.simba" Type="RCDATA" ResourceName="EXAMPLE_ASYNCMOUSE"/>
34-
<Resource_13 FileName="..\Examples\mouse_path.simba" Type="RCDATA" ResourceName="MOUSE_PATH"/>
34+
<Resource_13 FileName="..\Examples\mouse_path.simba" Type="RCDATA" ResourceName="MOUSE_PATH"/>
3535
<Resource_14 FileName="..\Examples\randomleft.simba" Type="RCDATA" ResourceName="EXAMPLE_RANDOM_LEFT"/>
3636
<Resource_15 FileName="..\Examples\method-property.simba" Type="RCDATA" ResourceName="EXAMPLE_METHOD_PROPERTY"/>
3737
<Resource_16 FileName="..\Examples\method-property-index.simba" Type="RCDATA" ResourceName="EXAMPLE_METHOD_PROPERTY_INDEX"/>
@@ -46,6 +46,7 @@
4646
<Resource_25 FileName="..\Images\arrow_right.png" Type="RCDATA" ResourceName="ARROW_RIGHT"/>
4747
<Resource_26 FileName="..\Images\arrow_right_150.png" Type="RCDATA" ResourceName="ARROW_RIGHT_150"/>
4848
<Resource_27 FileName="..\Images\arrow_right_200.png" Type="RCDATA" ResourceName="ARROW_RIGHT_200"/>
49+
<Resource_28 FileName="..\Examples\form_aca.simba" Type="RCDATA" ResourceName="EXAMPLE_FORM_ACA"/>
4950
</Resources>
5051
</General>
5152
<VersionInfo>

Source/ide/simba.form_main.lfm

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
object SimbaMainForm: TSimbaMainForm
22
Left = -1136
3-
Height = 646
3+
Height = 861
44
Top = 461
5-
Width = 1218
5+
Width = 1624
66
Caption = 'Simba'
7-
ClientHeight = 646
8-
ClientWidth = 1218
9-
DesignTimePPI = 144
7+
ClientHeight = 861
8+
ClientWidth = 1624
9+
DesignTimePPI = 192
1010
Position = poScreenCenter
1111
LCLVersion = '4.0.0.4'
1212
OnClose = FormClose
@@ -119,13 +119,13 @@ object SimbaMainForm: TSimbaMainForm
119119
}
120120
Visible = True
121121
OnClick = TrayIconClick
122-
Left = 228
123-
Top = 60
122+
Left = 304
123+
Top = 80
124124
end
125125
object TrayPopup: TPopupMenu
126126
Images = Images
127-
Left = 228
128-
Top = 156
127+
Left = 304
128+
Top = 208
129129
object TrayPopupExit: TMenuItem
130130
Caption = 'Close Simba'
131131
ImageIndex = 4
@@ -136,8 +136,8 @@ object SimbaMainForm: TSimbaMainForm
136136
Images = Images
137137
OnMeasureItem = MainMenuMeasureItem
138138
OnPopup = MenuFileClick
139-
Left = 456
140-
Top = 156
139+
Left = 608
140+
Top = 208
141141
object MenuItemNew: TMenuItem
142142
Caption = '&New'
143143
ImageIndex = 5
@@ -220,8 +220,8 @@ object SimbaMainForm: TSimbaMainForm
220220
Images = Images
221221
OnMeasureItem = MainMenuMeasureItem
222222
OnPopup = MenuEditClick
223-
Left = 768
224-
Top = 156
223+
Left = 1024
224+
Top = 208
225225
object MenuItemUndo: TMenuItem
226226
Caption = 'Undo'
227227
ImageIndex = 32
@@ -293,8 +293,8 @@ object SimbaMainForm: TSimbaMainForm
293293
object MainMenuScript: TPopupMenu
294294
Images = Images
295295
OnMeasureItem = MainMenuMeasureItem
296-
Left = 612
297-
Top = 156
296+
Left = 816
297+
Top = 208
298298
object MenuItemCompile: TMenuItem
299299
Caption = 'Compile'
300300
Hint = 'Compile Script'
@@ -337,8 +337,8 @@ object SimbaMainForm: TSimbaMainForm
337337
object MainMenuTools: TPopupMenu
338338
Images = Images
339339
OnMeasureItem = MainMenuMeasureItem
340-
Left = 768
341-
Top = 60
340+
Left = 1024
341+
Top = 80
342342
object MenuItemSettings: TMenuItem
343343
Caption = 'Settings'
344344
ImageIndex = 34
@@ -396,8 +396,8 @@ object SimbaMainForm: TSimbaMainForm
396396
object MainMenuView: TPopupMenu
397397
Images = Images
398398
OnMeasureItem = MainMenuMeasureItem
399-
Left = 456
400-
Top = 60
399+
Left = 608
400+
Top = 80
401401
object MenuItemTrayIcon: TMenuItem
402402
AutoCheck = True
403403
Caption = 'Tray Icon'
@@ -463,8 +463,8 @@ object SimbaMainForm: TSimbaMainForm
463463
object MainMenuHelp: TPopupMenu
464464
Images = Images
465465
OnMeasureItem = MainMenuMeasureItem
466-
Left = 612
467-
Top = 60
466+
Left = 816
467+
Top = 80
468468
object MenuItemAbout: TMenuItem
469469
Caption = 'About'
470470
ImageIndex = 40
@@ -488,14 +488,14 @@ object SimbaMainForm: TSimbaMainForm
488488
object RecentFilesPopup: TPopupMenu
489489
OnMeasureItem = MainMenuMeasureItem
490490
OnPopup = RecentFilesPopupPopup
491-
Left = 228
492-
Top = 264
491+
Left = 304
492+
Top = 352
493493
end
494494
object Images: TImageList
495495
ShareImages = True
496496
OnGetWidthForPPI = ImagesGetWidthForPPI
497-
Left = 72
498-
Top = 60
497+
Left = 96
498+
Top = 80
499499
Bitmap = {
500500
4C7A420000001000000010000000ED3900000000000078DAED9D075814D7D7C6
501501
C71A1335B16B2CD81B9A184B8C2DB144638D511135F6164B346AD468D4A888D8
@@ -2889,8 +2889,8 @@ object SimbaMainForm: TSimbaMainForm
28892889
end
28902890
object MainMenuSearch: TPopupMenu
28912891
Images = Images
2892-
Left = 456
2893-
Top = 264
2892+
Left = 608
2893+
Top = 352
28942894
object MenuItemFind: TMenuItem
28952895
Caption = 'Find'
28962896
ImageIndex = 28

Source/ide/simba.form_main.pas

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ interface
1212
uses
1313
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ComCtrls, ExtCtrls,
1414
Menus, ImgList, AnchorDockPanel, LMessages,
15-
simba.base, simba.settings, simba.ide_mouselogger;
15+
simba.base, simba.settings, simba.ide_mouselogger, simba.image;
1616

1717
const
1818
IMG_NONE = -1;
@@ -251,7 +251,7 @@ TSimbaMainForm = class(TForm)
251251
// Handle main menu shortcuts if editor is focused
252252
procedure DoApplicationKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
253253
procedure DoTabLoaded(Sender: TObject);
254-
function DoGetWindowForACA: TWindowHandle;
254+
function DoGetWindowForACA: TSimbaImage;
255255

256256
procedure SetCustomFontSize(Value: Integer);
257257
procedure SetLayoutLocked(Value: Boolean);
@@ -291,8 +291,7 @@ implementation
291291
simba.aca, simba.dtmeditor, simba.env, simba.ide_dockinghelpers, simba.nativeinterface,
292292
simba.ide_simpleformatter, simba.component_theme,
293293
simba.threading, simba.ide_editor, simba.vartype_string, simba.misc,
294-
simba.target,
295-
simba.vartype_windowhandle;
294+
simba.target;
296295

297296
procedure TSimbaMainForm.HandleException(Sender: TObject; E: Exception);
298297

@@ -748,7 +747,11 @@ procedure TSimbaMainForm.MenuItemDocumentationClick(Sender: TObject);
748747

749748
procedure TSimbaMainForm.MenuItemACAClick(Sender: TObject);
750749
begin
751-
ShowACA(@DoGetWindowForACA);
750+
with TSimbaACA.Create(@DoGetWindowForACA) do
751+
begin
752+
FreeOnClose := True;
753+
Show();
754+
end;
752755
end;
753756

754757
procedure TSimbaMainForm.DoMenuItemRunClick(Sender: TObject);
@@ -1047,12 +1050,9 @@ procedure TSimbaMainForm.DoTabLoaded(Sender: TObject);
10471050
AddRecentFile(TSimbaScriptTab(Sender).ScriptFileName);
10481051
end;
10491052

1050-
function TSimbaMainForm.DoGetWindowForACA: TWindowHandle;
1053+
function TSimbaMainForm.DoGetWindowForACA: TSimbaImage;
10511054
begin
1052-
if (SimbaMainToolBar.WindowSelection = 0) or (not SimbaMainToolBar.WindowSelection.IsValid) then
1053-
Result := GetDesktopWindow
1054-
else
1055-
Result := SimbaMainToolBar.WindowSelection;
1055+
Result := TSimbaImage.CreateFromWindow(SimbaMainToolBar.WindowSelectionOrDesktop);
10561056
end;
10571057

10581058
procedure TSimbaMainForm.MenuEditClick(Sender: TObject);

Source/ide/simba.ide_maintoolbar.pas

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ TSimbaMainToolBar = class(TComponent)
4141

4242
FAreaSelection: TBox;
4343

44+
function GetWindowSelectionOrDesktop: TWindowHandle;
45+
4446
procedure SetStates(ScriptState: ESimbaScriptState);
4547

4648
procedure DoTabScriptStateChange(Sender: TObject);
@@ -74,6 +76,7 @@ TSimbaMainToolBar = class(TComponent)
7476
property ButtonPackage: TSimbaButton read FButtonPackage;
7577

7678
property WindowSelection: TWindowHandle read FWindowSelection;
79+
property WindowSelectionOrDesktop: TWindowHandle read GetWindowSelectionOrDesktop;
7780
property ProcessSelection: TProcessID read FProcessSelection;
7881
property AreaSelection: TBox read FAreaSelection;
7982

@@ -92,6 +95,13 @@ implementation
9295
simba.ide_colorpicker, simba.ide_windowselector, simba.ide_areaselector,
9396
simba.vartype_windowhandle, simba.vartype_box;
9497

98+
function TSimbaMainToolBar.GetWindowSelectionOrDesktop: TWindowHandle;
99+
begin
100+
Result := WindowSelection;
101+
if (Result = 0) or (not Result.IsValid()) then
102+
Result := GetDesktopWindow()
103+
end;
104+
95105
procedure TSimbaMainToolBar.SetStates(ScriptState: ESimbaScriptState);
96106

97107
procedure UpdateButtons(RunEnabled, PauseEnabed, CompileEnabled, StopEnabled: Boolean; StopImageIndex: Integer);

Source/script/imports/simba.import_imagebox.pas

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
interface
66

77
uses
8-
Classes, SysUtils, Controls, Graphics,
8+
Classes, SysUtils, Controls, ExtCtrls, Graphics,
99
simba.base, simba.script, simba.script_objectutil;
1010

1111
procedure ImportSimbaImageBox(Script: TSimbaScript);
@@ -24,6 +24,7 @@ implementation
2424

2525
type
2626
PComponent = ^TComponent;
27+
PPanel = ^TPanel;
2728
PBitmap = ^TBitmap;
2829
PSimbaImageBox = ^TSimbaImageBox;
2930
PSimbaImageBoxCanvas = ^TSimbaImageBoxCanvas;
@@ -239,6 +240,11 @@ procedure _LapeImageBox_OnImgKeyUp_Read(const Params: PParamArray; const Result:
239240
TImageBoxKeyEvent(Result^) := PSimbaImageBox(Params^[0])^.OnImgKeyUp;
240241
end;
241242

243+
procedure _LapeImageBox_UserPanel_Read(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV
244+
begin
245+
PPanel(Result)^ := PSimbaImageBox(Params^[0])^.UserPanel;
246+
end;
247+
242248
procedure _LapeImageBox_OnImgKeyUp_Write(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV
243249
begin
244250
PSimbaImageBox(Params^[0])^.OnImgKeyUp := TImageBoxKeyEvent(Params^[1]^);
@@ -459,6 +465,7 @@ procedure ImportSimbaImageBox(Script: TSimbaScript);
459465
addProperty('TImageBox', 'OnImgKeyDown', 'TImageBoxKeyEvent', @_LapeImageBox_OnImgKeyDown_Read, @_LapeImageBox_OnImgKeyDown_Write);
460466
addProperty('TImageBox', 'OnImgKeyUp', 'TImageBoxKeyEvent', @_LapeImageBox_OnImgKeyUp_Read, @_LapeImageBox_OnImgKeyUp_Write);
461467

468+
addProperty('TImageBox', 'UserPanel', 'TLazPanel', @_LapeImageBox_UserPanel_Read);
462469
addProperty('TImageBox', 'ShowScrollBars', 'Boolean', @_LapeImageBox_ShowScrollBars_Read, @_LapeImageBox_ShowScrollBars_Write);
463470
addProperty('TImageBox', 'ShowStatusBar', 'Boolean', @_LapeImageBox_ShowStatusBar_Read, @_LapeImageBox_ShowStatusBar_Write);
464471
addProperty('TImageBox', 'AllowMoving', 'Boolean', @_LapeImageBox_AllowMoving_Read, @_LapeImageBox_AllowMoving_Write);

0 commit comments

Comments
 (0)