1
{$MainUnit customdrawnwsforms.pp}
5
class function TCDWSCustomForm.DoCreateHandle(const AWinControl: TWinControl;
6
const AParams: TCreateParams): TLCLIntfHandle;
9
winhandle: TCocoaWindow;
10
cnt : TCocoaCustomControl;
14
win := TCocoaForm(TCocoaForm.alloc);
16
if not Assigned(win) then
22
winhandle := TCocoaWindow.Create;
23
winhandle.LCLForm := TCustomForm(AWinControl);
25
if Application.ApplicationType = atMobileEmulator then lRect := GetNSRect(200, 200, 240, 320)
26
// else ToDo: for atPDA make it fullscreen
27
else lRect := CreateParamsToNSRect(AParams);
28
win:=TCocoaForm(win.initWithContentRect_styleMask_backing_defer(
29
lRect, CalcNSWindowStyle(AWinControl, AParams), NSBackingStoreBuffered, False));
30
win.WindowHandle := winhandle;
32
ns:=NSStringUtf8(AWinControl.Caption);
35
win.setAcceptsMouseMovedEvents(True);
37
cnt:=TCocoaCustomControl.alloc.init;
38
cnt.WindowHandle := winhandle;
39
win.setContentView(cnt);
41
winhandle.CocoaForm := win;
42
winhandle.ClientArea := cnt;
43
Result := TLCLIntfHandle(winhandle);
46
class procedure TCDWSCustomForm.DoShowHide(const AWinControl: TWinControl);
50
win := TCocoaWindow(AWinControl.Handle);
51
if not Assigned(win) then Exit;
53
if AWinControl.Visible then
54
win.CocoaForm.orderFrontRegardless
56
win.CocoaForm.orderOut(nil);
59
{------------------------------------------------------------------------------
60
Method: TCDWSCustomForm.CreateHandle
61
Params: AWinControl - LCL control
62
AParams - Creation parameters
63
Returns: Handle to the window in Cocoa interface
65
Creates new window in Cocoa interface with the specified parameters
66
------------------------------------------------------------------------------}
67
class function TCDWSCustomForm.CreateHandle(const AWinControl: TWinControl;
68
const AParams: TCreateParams): TLCLIntfHandle;
70
if LCLIntf.IsMobilePlatform() then
72
Result := TLCLIntfhandle(AddNewForm(TCustomForm(AWinControl)));
73
if AWinControl = Application.MainForm then
74
CDWidgetset.MobileMainForm := DoCreateHandle(AWinControl, AParams);
77
Result := DoCreateHandle(AWinControl, AParams);
80
class procedure TCDWSCustomForm.DestroyHandle(const AWinControl: TWinControl);
84
class procedure TCDWSCustomForm.SetBounds(const AWinControl: TWinControl;
85
const ALeft, ATop, AWidth, AHeight: Integer);
87
if AWinControl.Handle=0 then Exit;
88
{todo: setFrame_display(, true)? }
89
//sf:=NSScreen.mainScreen.frame;
90
TCocoaWindow(AWinControl.Handle).CocoaForm.lclSetFrame(Bounds(ALeft, ATop, AWidth, AHeight));
92
//LCLToCocoaRect( GetNSRect(ALeft,ATop,AWidth,AHeight), sf, wf);
93
//NSWindow(AWinControl.Handle).setFrame_display(wf, false);
94
//NSWindow(AWinControl.Handle).setFrame_display( GetNSRect(ALeft,ATop, AWidth, AHeight), false);
95
//NSWindow(AWinControl.Handle).setFrameTopLeftPoint( GetNSPoint(ALeft, ATop));
98
class procedure TCDWSCustomForm.SetBorderIcons(const AForm: TCustomForm;
99
const ABorderIcons: TBorderIcons);
103
class procedure TCDWSCustomForm.SetFormBorderStyle(const AForm: TCustomForm;
104
const AFormBorderStyle: TFormBorderStyle);
108
class procedure TCDWSCustomForm.SetIcon(const AForm: TCustomForm; const Small, Big: HICON);
112
class procedure TCDWSCustomForm.SetShowInTaskbar(const AForm: TCustomForm; const AValue: TShowInTaskbar);
116
class procedure TCDWSCustomForm.ShowModal(const ACustomForm: TCustomForm);
120
class procedure TCDWSCustomForm.ShowHide(const AWinControl: TWinControl);
122
DoShowHide(AWinControl);
125
class function TCDWSCustomForm.GetText(const AWinControl: TWinControl; var AText: String): Boolean;
129
win:=TCocoaWindow(AWinControl.Handle);
130
Result:=Assigned(win);
131
if not Result then Exit;
132
AText:=NSStringToString(win.CocoaForm.title);
136
class function TCDWSCustomForm.GetTextLen(const AWinControl: TWinControl; var ALength: Integer): Boolean;
140
win:=TCocoaWindow(AWinControl.Handle);
141
Result:=Assigned(win);
142
if not Result then Exit;
143
ALength:=win.CocoaForm.title.length;
146
class procedure TCDWSCustomForm.SetText(const AWinControl: TWinControl; const AText: String);
151
win:=TCocoaWindow(AWinControl.Handle);
152
if not Assigned(win) then Exit;
153
ns:=NSStringUtf8(AText);
154
win.CocoaForm.setTitle(ns);
158
class function TCDWSCustomForm.GetClientBounds(const AWinControl: TWinControl; var ARect: TRect): Boolean;
160
Result:=AWinControl.Handle<>0;
161
if not Result then Exit;
162
ARect:= TCocoaWindow(AWinControl.Handle).CocoaForm.lclClientFrame;
165
class function TCDWSCustomForm.GetClientRect(const AWinControl: TWinControl; var ARect: TRect): Boolean;
169
Result:=AWinControl.Handle<>0;
170
if not Result then Exit;
171
ARect:= TCocoaWindow(AWinControl.Handle).CocoaForm.lclClientFrame;
173
TCocoaWindow(AWinControl.Handle).CocoaForm.lclLocalToScreen(x,y);
174
MoveRect(ARect, x,y);