37
36
appkit, foundation, lobjc,
38
37
{$endif CarbonUseCocoa}
40
Classes, Controls, ExtCtrls, LCLType, LCLProc, Graphics, Math, SysUtils,
39
Classes, Controls, ExtCtrls, LCLType, LCLProc, Graphics, SysUtils,
43
WSExtCtrls, WSLCLClasses, WSControls, WSProc,
42
WSExtCtrls, WSLCLClasses,
45
carbongdiobjects, CarbonWSControls;
49
{ TCarbonWSCustomPage }
51
TCarbonWSCustomPage = class(TWSCustomPage)
53
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
54
class procedure UpdateProperties(const ACustomPage: TCustomPage); override;
57
{ TCarbonWSCustomNotebook }
59
TCarbonWSCustomNotebook = class(TWSCustomNotebook)
61
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
63
class procedure AddPage(const ANotebook: TCustomNotebook; const AChild: TCustomPage; const AIndex: integer); override;
64
class procedure MovePage(const ANotebook: TCustomNotebook; const AChild: TCustomPage; const NewIndex: integer); override;
65
class procedure RemovePage(const ANotebook: TCustomNotebook; const AIndex: integer); override;
67
//class function GetNotebookMinTabHeight(const AWinControl: TWinControl): integer; override;
68
//class function GetNotebookMinTabWidth(const AWinControl: TWinControl): integer; override;
69
//class function GetPageRealIndex(const ANotebook: TCustomNotebook; AIndex: Integer): Integer; override;
70
class function GetTabIndexAtPos(const ANotebook: TCustomNotebook; const AClientPos: TPoint): integer; override;
71
class procedure SetPageIndex(const ANotebook: TCustomNotebook; const AIndex: integer); override;
72
class procedure SetTabPosition(const ANotebook: TCustomNotebook; const ATabPosition: TTabPosition); override;
73
class procedure ShowTabs(const ANotebook: TCustomNotebook; AShowTabs: boolean); override;
78
50
TCarbonWSPage = class(TWSPage)
196
CarbonProc, CarbonDef, CarbonTabs, CarbonCanvas;
198
{ TCarbonWSCustomPage }
200
{------------------------------------------------------------------------------
201
Method: TCarbonWSCustomPage.CreateHandle
202
Params: AWinControl - LCL control
203
AParams - Creation parameters
204
Returns: Handle to the control in Carbon interface
206
Creates new custom page in Carbon interface with the specified parameters
207
------------------------------------------------------------------------------}
208
class function TCarbonWSCustomPage.CreateHandle(const AWinControl: TWinControl;
209
const AParams: TCreateParams): TLCLIntfHandle;
211
Result := TLCLIntfHandle(TCarbonTab.Create(AWinControl, AParams));
214
{------------------------------------------------------------------------------
215
Method: TCarbonWSCustomPage.UpdateProperties
216
Params: ACustomPage - LCL custom page
218
Update properties of the specified custom page in Carbon interface
219
------------------------------------------------------------------------------}
220
class procedure TCarbonWSCustomPage.UpdateProperties(const ACustomPage: TCustomPage);
222
if not CheckHandle(ACustomPage, Self, 'UpdateProperties') then Exit;
224
TCarbonTab(ACustomPage.Handle).UpdateTab;
227
{ TCarbonWSCustomNotebook }
229
{------------------------------------------------------------------------------
230
Method: TCarbonWSCustomNotebook.CreateHandle
231
Params: AWinControl - LCL control
232
AParams - Creation parameters
233
Returns: Handle to the control in Carbon interface
235
Creates new custom notebook in Carbon interface with the specified parameters
236
------------------------------------------------------------------------------}
237
class function TCarbonWSCustomNotebook.CreateHandle(const AWinControl: TWinControl;
238
const AParams: TCreateParams): TLCLIntfHandle;
240
Result := TLCLIntfHandle(TCarbonTabsControl.Create(AWinControl, AParams));
243
{------------------------------------------------------------------------------
244
Method: TCarbonWSCustomNotebook.AddPage
245
Params: ANotebook - LCL custom notebook
247
AIndex - New tab index
249
Adds tab with the specified index in notebook in Carbon interface
250
------------------------------------------------------------------------------}
251
class procedure TCarbonWSCustomNotebook.AddPage(const ANotebook: TCustomNotebook;
252
const AChild: TCustomPage; const AIndex: integer);
254
if not CheckHandle(ANotebook, Self, 'AddPage') then Exit;
255
if AChild.HandleAllocated and not CheckHandle(AChild, Self, 'AddPage AChild') then Exit;
257
// create child handle
260
TCarbonTabsControl(ANotebook.Handle).Add(TCarbonTab(AChild.Handle), AIndex);
261
// sync PageIndex with LCL
262
TCarbonTabsControl(ANotebook.Handle).SetPageIndex(ANotebook.PageIndex);
265
{------------------------------------------------------------------------------
266
Method: TCarbonWSCustomNotebook.MovePage
267
Params: ANotebook - LCL custom notebook
269
AIndex - New tab index
271
Moves tab to the specified index in notebook in Carbon interface
272
------------------------------------------------------------------------------}
273
class procedure TCarbonWSCustomNotebook.MovePage(const ANotebook: TCustomNotebook;
274
const AChild: TCustomPage; const NewIndex: integer);
276
if not CheckHandle(ANotebook, Self, 'MovePage') then Exit;
277
if not CheckHandle(AChild, Self, 'MovePage AChild') then Exit;
279
TCarbonTabsControl(ANotebook.Handle).Remove(AChild.PageIndex);
280
TCarbonTabsControl(ANotebook.Handle).Add(TCarbonTab(AChild.Handle), NewIndex);
283
{------------------------------------------------------------------------------
284
Method: TCarbonWSCustomNotebook.RemovePage
285
Params: ANotebook - LCL custom notebook
286
AIndex - Removed tab index
288
Removes tab with the specified index from notebook in Carbon interface
289
------------------------------------------------------------------------------}
290
class procedure TCarbonWSCustomNotebook.RemovePage(const ANotebook: TCustomNotebook;
291
const AIndex: integer);
293
if not CheckHandle(ANotebook, Self, 'RemovePage') then Exit;
295
TCarbonTabsControl(ANotebook.Handle).Remove(AIndex);
296
// sync PageIndex with LCL
297
TCarbonTabsControl(ANotebook.Handle).SetPageIndex(ANotebook.PageIndex);
301
class function TCarbonWSCustomNotebook.GetTabIndexAtPos(const ANotebook: TCustomNotebook; const AClientPos: TPoint): integer;
305
if not CheckHandle(ANotebook, Self, 'GetTabIndexAtPos') then Exit;
307
inc(p.y, 35); // todo: find out why AClientPos incorrect for TNotebook
308
Result := TCarbonTabsControl(ANotebook.Handle).GetPageIndexAtCursor(p);
311
{------------------------------------------------------------------------------
312
Method: TCarbonWSCustomNotebook.SetPageIndex
313
Params: ANotebook - LCL custom notebook
314
AIndex - New tab index
316
Selects tab with the specified index in notebook in Carbon interface
317
------------------------------------------------------------------------------}
318
class procedure TCarbonWSCustomNotebook.SetPageIndex(const ANotebook: TCustomNotebook;
319
const AIndex: integer);
321
if not CheckHandle(ANotebook, Self, 'SetPageIndex') then Exit;
323
TCarbonTabsControl(ANotebook.Handle).SetPageIndex(AIndex);
326
{------------------------------------------------------------------------------
327
Method: TCarbonWSCustomNotebook.SetTabPosition
328
Params: ANotebook - LCL custom notebook
329
ATabPosition - New position of tabs
331
Changes position of the tabs of notebook in Carbon interface
332
------------------------------------------------------------------------------}
333
class procedure TCarbonWSCustomNotebook.SetTabPosition(const ANotebook: TCustomNotebook;
334
const ATabPosition: TTabPosition);
336
if not CheckHandle(ANotebook, Self, 'SetTabPosition') then Exit;
338
TCarbonTabsControl(ANotebook.Handle).SetTabPosition(ATabPosition);
341
{------------------------------------------------------------------------------
342
Method: TCarbonWSCustomNotebook.ShowTabs
343
Params: ANotebook - LCL custom notebook
344
AShowTabs - Tabs visibility
346
Changes visibility of all tabs of notebook in Carbon interface
347
------------------------------------------------------------------------------}
348
class procedure TCarbonWSCustomNotebook.ShowTabs(const ANotebook: TCustomNotebook;
351
if not CheckHandle(ANotebook, Self, 'ShowTabs') then Exit;
353
TCarbonTabsControl(ANotebook.Handle).ShowTabs(AShowTabs);
356
170
{ TCarbonWSCustomPanel }