Skip to content

Commit 88eb795

Browse files
committed
Creating FMX.Menus wrappers
1 parent 3232488 commit 88eb795

File tree

4 files changed

+186
-2
lines changed

4 files changed

+186
-2
lines changed

Packages/Delphi/Delphi 10.4+/PythonFmx.dpk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ contains
5151
WrapDelphiFmx in '..\..\..\Source\fmx\WrapDelphiFmx.pas',
5252
WrapFmxEdit in '..\..\..\Source\fmx\WrapFmxEdit.pas',
5353
WrapFmxListBox in '..\..\..\Source\fmx\WrapFmxListBox.pas',
54-
WrapFmxMedia in '..\..\..\Source\fmx\WrapFmxMedia.pas';
54+
WrapFmxMedia in '..\..\..\Source\fmx\WrapFmxMedia.pas',
55+
WrapFmxMenus in '..\..\..\Source\fmx\WrapFmxMenus.pas';
5556

5657
end.

Source/fmx/WrapDelphiFmx.pas

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ implementation
2323
WrapFmxLayouts,
2424
WrapFmxScrollBox,
2525
WrapFmxGrids,
26-
WrapFmxMedia;
26+
WrapFmxMedia,
27+
WrapFmxMenus;
2728

2829
end.

Source/fmx/WrapFmxMenus.pas

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
{$I ..\Definition.Inc}
2+
3+
unit WrapFmxMenus;
4+
5+
interface
6+
7+
uses
8+
WrapFmxControls, FMX.Menus, WrapFmxTypes;
9+
10+
type
11+
TPyDelphiMenuItem = class(TPyDelphiTextControl)
12+
private
13+
function GetDelphiObject: TMenuItem;
14+
procedure SetDelphiObject(const Value: TMenuItem);
15+
public
16+
class function DelphiObjectClass: TClass; override;
17+
property DelphiObject: TMenuItem read GetDelphiObject write SetDelphiObject;
18+
end;
19+
20+
TPyDelphiPopupMenu = class(TPyDelphiCustomPopupMenu)
21+
private
22+
function GetDelphiObject: TPopupMenu;
23+
procedure SetDelphiObject(const Value: TPopupMenu);
24+
public
25+
class function DelphiObjectClass: TClass; override;
26+
property DelphiObject: TPopupMenu read GetDelphiObject write SetDelphiObject;
27+
end;
28+
29+
TPyDelphiMenuBar = class(TPyDelphiStyledControl)
30+
private
31+
function GetDelphiObject: TMenuBar;
32+
procedure SetDelphiObject(const Value: TMenuBar);
33+
public
34+
class function DelphiObjectClass: TClass; override;
35+
property DelphiObject: TMenuBar read GetDelphiObject write SetDelphiObject;
36+
end;
37+
38+
TPyDelphiMainMenu = class(TPyDelphiFmxObject)
39+
private
40+
function GetDelphiObject: TMainMenu;
41+
procedure SetDelphiObject(const Value: TMainMenu);
42+
public
43+
class function DelphiObjectClass: TClass; override;
44+
property DelphiObject: TMainMenu read GetDelphiObject write SetDelphiObject;
45+
end;
46+
47+
implementation
48+
49+
uses
50+
WrapDelphi;
51+
52+
{ Register the wrappers, the globals and the constants }
53+
type
54+
TMenusRegistration = class(TRegisteredUnit)
55+
public
56+
function Name : string; override;
57+
procedure RegisterWrappers(APyDelphiWrapper : TPyDelphiWrapper); override;
58+
procedure DefineVars(APyDelphiWrapper : TPyDelphiWrapper); override;
59+
end;
60+
61+
{ TMenusRegistration }
62+
63+
function TMenusRegistration.Name: string;
64+
begin
65+
Result := 'Menus';
66+
end;
67+
68+
procedure TMenusRegistration.DefineVars(APyDelphiWrapper: TPyDelphiWrapper);
69+
begin
70+
inherited;
71+
end;
72+
73+
procedure TMenusRegistration.RegisterWrappers(
74+
APyDelphiWrapper: TPyDelphiWrapper);
75+
begin
76+
inherited;
77+
APyDelphiWrapper.RegisterDelphiWrapper(TPyDelphiMenuItem);
78+
APyDelphiWrapper.RegisterDelphiWrapper(TPyDelphiPopupMenu);
79+
APyDelphiWrapper.RegisterDelphiWrapper(TPyDelphiMenuBar);
80+
APyDelphiWrapper.RegisterDelphiWrapper(TPyDelphiMainMenu);
81+
end;
82+
83+
{ TPyDelphiMenuItem }
84+
85+
class function TPyDelphiMenuItem.DelphiObjectClass: TClass;
86+
begin
87+
Result := TMenuItem;
88+
end;
89+
90+
function TPyDelphiMenuItem.GetDelphiObject: TMenuItem;
91+
begin
92+
Result := TMenuItem(inherited DelphiObject);
93+
end;
94+
95+
procedure TPyDelphiMenuItem.SetDelphiObject(const Value: TMenuItem);
96+
begin
97+
inherited DelphiObject := Value;
98+
end;
99+
100+
{ TPyDelphiPopupMenu }
101+
102+
class function TPyDelphiPopupMenu.DelphiObjectClass: TClass;
103+
begin
104+
Result := TPopupMenu;
105+
end;
106+
107+
function TPyDelphiPopupMenu.GetDelphiObject: TPopupMenu;
108+
begin
109+
Result := TPopupMenu(inherited DelphiObject);
110+
end;
111+
112+
procedure TPyDelphiPopupMenu.SetDelphiObject(const Value: TPopupMenu);
113+
begin
114+
inherited DelphiObject := Value;
115+
end;
116+
117+
{ TPyDelphiMenuBar }
118+
119+
class function TPyDelphiMenuBar.DelphiObjectClass: TClass;
120+
begin
121+
Result := TMenuBar;
122+
end;
123+
124+
function TPyDelphiMenuBar.GetDelphiObject: TMenuBar;
125+
begin
126+
Result := TMenuBar(inherited DelphiObject);
127+
end;
128+
129+
procedure TPyDelphiMenuBar.SetDelphiObject(const Value: TMenuBar);
130+
begin
131+
inherited DelphiObject := Value;
132+
end;
133+
134+
{ TPyDelphiMainMenu }
135+
136+
class function TPyDelphiMainMenu.DelphiObjectClass: TClass;
137+
begin
138+
Result := TMainMenu;
139+
end;
140+
141+
function TPyDelphiMainMenu.GetDelphiObject: TMainMenu;
142+
begin
143+
Result := TMainMenu(inherited DelphiObject);
144+
end;
145+
146+
procedure TPyDelphiMainMenu.SetDelphiObject(const Value: TMainMenu);
147+
begin
148+
inherited DelphiObject := Value;
149+
end;
150+
151+
initialization
152+
RegisteredUnits.Add(TMenusRegistration.Create());
153+
154+
end.

Source/fmx/WrapFmxTypes.pas

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,15 @@ TPyDelphiPosition = class(TPyDelphiPersistent)
9494
property DelphiObject: TPosition read GetDelphiObject write SetDelphiObject;
9595
end;
9696

97+
TPyDelphiCustomPopupMenu = class(TPyDelphiFMXObject)
98+
private
99+
function GetDelphiObject: TCustomPopupMenu;
100+
procedure SetDelphiObject(const Value: TCustomPopupMenu);
101+
public
102+
class function DelphiObjectClass: TClass; override;
103+
property DelphiObject: TCustomPopupMenu read GetDelphiObject write SetDelphiObject;
104+
end;
105+
97106
{Helper functions}
98107
function WrapPointF(APyDelphiWrapper: TPyDelphiWrapper; const APoint : TPointF) : PPyObject;
99108
function WrapSizeF(APyDelphiWrapper: TPyDelphiWrapper; const ASize : TSizeF) : PPyObject;
@@ -233,6 +242,7 @@ procedure TTypesRegistration.RegisterWrappers(
233242
APyDelphiWrapper.RegisterHelperType(TPyDelphiSizeF);
234243
APyDelphiWrapper.RegisterDelphiWrapper(TPyDelphiFmxObject);
235244
APyDelphiWrapper.RegisterDelphiWrapper(TPyDelphiPosition);
245+
APyDelphiWrapper.RegisterDelphiWrapper(TPyDelphiCustomPopupMenu);
236246
end;
237247

238248
{ Helper functions }
@@ -539,6 +549,24 @@ function TPyDelphiSizeF.Set_Width(AValue: PPyObject;
539549
Result := -1;
540550
end;
541551

552+
{ TPyDelphiCustomPopupMenu }
553+
554+
class function TPyDelphiCustomPopupMenu.DelphiObjectClass: TClass;
555+
begin
556+
Result := TCustomPopupMenu;
557+
end;
558+
559+
function TPyDelphiCustomPopupMenu.GetDelphiObject: TCustomPopupMenu;
560+
begin
561+
Result := TCustomPopupMenu(inherited DelphiObject)
562+
end;
563+
564+
procedure TPyDelphiCustomPopupMenu.SetDelphiObject(
565+
const Value: TCustomPopupMenu);
566+
begin
567+
inherited DelphiObject := Value;
568+
end;
569+
542570
initialization
543571
RegisteredUnits.Add(TTypesRegistration.Create);
544572

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy