1{
2 *****************************************************************************
3 *                             Gtk3WSComCtrls.pp                             *
4 *                             -----------------                             *
5 *                                                                           *
6 *                                                                           *
7 *****************************************************************************
8
9 *****************************************************************************
10  This file is part of the Lazarus Component Library (LCL)
11
12  See the file COPYING.modifiedLGPL.txt, included in this distribution,
13  for details about the license.
14 *****************************************************************************
15}
16unit Gtk3WSComCtrls;
17
18{$mode objfpc}{$H+}
19{$I gtk3defines.inc}
20
21interface
22
23uses
24  // libs
25  LazGtk3, LazGdk3, LazGlib2,
26  // RTL, FCL, LCL
27  ComCtrls, Classes, LCLType, LMessages, Controls, Graphics, StdCtrls, Forms,
28  LCLProc, LCLIntf, ImgList, Math, Sysutils, ctypes, InterfaceBase,
29  // widgetset
30  WSComCtrls, WSLCLClasses, WSControls, WSProc,
31  Gtk3WSControls, Gtk3Int, gtk3widgets;
32
33type
34  { TGtk3WSCustomPage }
35
36  TGtk3WSCustomPage = class(TWSCustomPage)
37  published
38    class function CreateHandle(const AWinControl: TWinControl;
39      const AParams: TCreateParams): TLCLIntfHandle; override;
40    class procedure UpdateProperties(const ACustomPage: TCustomPage); override;
41    class procedure SetBounds(const {%H-}AWinControl: TWinControl; const {%H-}ALeft, {%H-}ATop, {%H-}AWidth, {%H-}AHeight: Integer); override;
42    class procedure SetFont(const AWinControl: TWinControl; const AFont: TFont); override;
43    class procedure ShowHide(const AWinControl: TWinControl); override;
44    class function GetDefaultClientRect(const AWinControl: TWinControl;
45             const {%H-}aLeft, {%H-}aTop, {%H-}aWidth, {%H-}aHeight: integer; var aClientRect: TRect
46             ): boolean; override;
47  end;
48
49  { TGtk3WSCustomTabControl }
50
51  TGtk3WSCustomTabControl = class(TWSCustomTabControl)
52  published
53    class function CreateHandle(const AWinControl: TWinControl;
54                                const AParams: TCreateParams): TLCLIntfHandle; override;
55    (*
56    class function GetDefaultClientRect(const AWinControl: TWinControl;
57            const {%H-}aLeft, {%H-}aTop, aWidth, aHeight: integer; var aClientRect: TRect
58            ): boolean; override;
59    *)
60    class procedure AddPage(const ATabControl: TCustomTabControl;
61      const AChild: TCustomPage; const AIndex: integer); override;
62    class procedure MovePage(const ATabControl: TCustomTabControl;
63      const AChild: TCustomPage; const NewIndex: integer); override;
64    class procedure RemovePage(const ATabControl: TCustomTabControl; const AIndex: integer); override;
65
66    class function GetCapabilities: TCTabControlCapabilities; override;
67    class function GetNotebookMinTabHeight(const AWinControl: TWinControl): integer; override;
68    class function GetNotebookMinTabWidth(const AWinControl: TWinControl): integer; override;
69    class function GetTabIndexAtPos(const ATabControl: TCustomTabControl; const AClientPos: TPoint): integer; override;
70    class function GetTabRect(const ATabControl: TCustomTabControl; const AIndex: Integer): TRect; override;
71    class procedure SetPageIndex(const ATabControl: TCustomTabControl; const AIndex: integer); override;
72    class procedure SetTabCaption(const ATabControl: TCustomTabControl; const AChild: TCustomPage; const AText: string); override;
73    class procedure SetTabPosition(const ATabControl: TCustomTabControl; const ATabPosition: TTabPosition); override;
74    class procedure ShowTabs(const ATabControl: TCustomTabControl; AShowTabs: boolean); override;
75    class procedure UpdateProperties(const ATabControl: TCustomTabControl); override;
76  end;
77
78  { TGtk3WSStatusBar }
79
80  TGtk3WSStatusBar = class(TWSStatusBar)
81  published
82    class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
83    class procedure PanelUpdate(const AStatusBar: TStatusBar; PanelIndex: integer); override;
84    class procedure SetPanelText(const AStatusBar: TStatusBar; PanelIndex: integer); override;
85    class procedure Update(const AStatusBar: TStatusBar); override;
86    class procedure GetPreferredSize(const {%H-}AWinControl: TWinControl;
87                        var {%H-}PreferredWidth, PreferredHeight: integer;
88                        {%H-}WithThemeSpace: Boolean); override;
89
90    class procedure SetSizeGrip(const AStatusBar: TStatusBar; {%H-}SizeGrip: Boolean); override;
91  end;
92
93  { TGtk3WSTabSheet }
94
95  TGtk3WSTabSheet = class(TWSTabSheet)
96  published
97  end;
98
99  { TGtk3WSPageControl }
100
101  TGtk3WSPageControl = class(TWSPageControl)
102  published
103  end;
104
105  { TGtk3WSCustomListView }
106
107  TGtk3WSCustomListView = class(TWSCustomListView)
108  private
109    class procedure SetPropertyInternal(const ALV: TCustomListView; const AProp: TListViewProperty; const AIsSet: Boolean);
110  published
111    // columns
112    class procedure ColumnDelete(const ALV: TCustomListView; const AIndex: Integer); override;
113    class function  ColumnGetWidth(const ALV: TCustomListView; const {%H-}AIndex: Integer; const AColumn: TListColumn): Integer; override;
114    class procedure ColumnInsert(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn); override;
115    class procedure ColumnMove(const ALV: TCustomListView; const AOldIndex, ANewIndex: Integer; const {%H-}AColumn: TListColumn); override;
116    class procedure ColumnSetAlignment(const ALV: TCustomListView; const AIndex: Integer; const {%H-}AColumn: TListColumn; const AAlignment: TAlignment); override;
117    class procedure ColumnSetAutoSize(const ALV: TCustomListView; const AIndex: Integer; const {%H-}AColumn: TListColumn; const AAutoSize: Boolean); override;
118    class procedure ColumnSetCaption(const ALV: TCustomListView; const AIndex: Integer; const {%H-}AColumn: TListColumn; const ACaption: String); override;
119    class procedure ColumnSetImage(const ALV: TCustomListView; const {%H-}AIndex: Integer; const {%H-}AColumn: TListColumn; const {%H-}AImageIndex: Integer); override;
120    class procedure ColumnSetMaxWidth(const ALV: TCustomListView; const AIndex: Integer; const {%H-}AColumn: TListColumn; const AMaxWidth: Integer); override;
121    class procedure ColumnSetMinWidth(const ALV: TCustomListView; const AIndex: Integer; const {%H-}AColumn: TListColumn; const AMinWidth: integer); override;
122    class procedure ColumnSetWidth(const ALV: TCustomListView; const AIndex: Integer; const {%H-}AColumn: TListColumn; const AWidth: Integer); override;
123    class procedure ColumnSetVisible(const ALV: TCustomListView; const AIndex: Integer; const {%H-}AColumn: TListColumn; const AVisible: Boolean); override;
124    class procedure ColumnSetSortIndicator(const ALV: TCustomListView; const AIndex: Integer;
125      const AColumn: TListColumn; const ASortIndicator: TSortIndicator);override;
126
127    // items
128    class procedure ItemDelete(const ALV: TCustomListView; const AIndex: Integer); override;
129    class function  ItemDisplayRect(const ALV: TCustomListView; const AIndex, ASubItem: Integer; {%H-}ACode: TDisplayCode): TRect; override;
130    class procedure ItemExchange(const ALV: TCustomListView; {%H-}AItem: TListItem; const AIndex1, AIndex2: Integer); override;
131    class procedure ItemMove(const ALV: TCustomListView; {%H-}AItem: TListItem; const AFromIndex, AToIndex: Integer); override;
132    class function  ItemGetChecked(const {%H-}ALV: TCustomListView; const {%H-}AIndex: Integer; const AItem: TListItem): Boolean; override;
133    class function  ItemGetState(const ALV: TCustomListView; const AIndex: Integer; const {%H-}AItem: TListItem; const AState: TListItemState; out AIsSet: Boolean): Boolean; override; // returns True if supported
134    class procedure ItemInsert(const ALV: TCustomListView; const AIndex: Integer; const {%H-}AItem: TListItem); override;
135    class procedure ItemSetChecked(const ALV: TCustomListView; const {%H-}AIndex: Integer; const {%H-}AItem: TListItem; const {%H-}AChecked: Boolean); override;
136    class procedure ItemSetImage(const ALV: TCustomListView; const AIndex: Integer; const {%H-}AItem: TListItem; const {%H-}ASubIndex, AImageIndex: Integer); override;
137    class procedure ItemSetState(const ALV: TCustomListView; const AIndex: Integer; const {%H-}AItem: TListItem; const AState: TListItemState; const AIsSet: Boolean); override;
138    class procedure ItemSetText(const ALV: TCustomListView; const AIndex: Integer; const {%H-}AItem: TListItem; const {%H-}ASubIndex: Integer; const {%H-}AText: String); override;
139    class procedure ItemShow(const ALV: TCustomListView; const AIndex: Integer; const {%H-}AItem: TListItem; const {%H-}PartialOK: Boolean); override;
140    class function  ItemGetPosition(const ALV: TCustomListView; const AIndex: Integer): TPoint; override;
141    class procedure ItemUpdate(const ALV: TCustomListView; const {%H-}AIndex: Integer; const {%H-}AItem: TListItem); override;
142
143    // lv
144    class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
145    // class procedure DestroyHandle(const AWinControl: TWinControl); override;
146
147    class procedure BeginUpdate(const ALV: TCustomListView); override;
148    class procedure EndUpdate(const ALV: TCustomListView); override;
149
150    class function GetBoundingRect(const ALV: TCustomListView): TRect; override;
151    class function GetDropTarget(const ALV: TCustomListView): Integer; override;
152    class function GetFocused(const ALV: TCustomListView): Integer; override;
153    class function GetHoverTime(const ALV: TCustomListView): Integer; override;
154    class function GetItemAt(const ALV: TCustomListView; x,y: integer): Integer; override;
155    class function GetSelCount(const ALV: TCustomListView): Integer; override;
156    class function GetSelection(const ALV: TCustomListView): Integer; override;
157    class function GetTopItem(const ALV: TCustomListView): Integer; override;
158    class function GetViewOrigin(const ALV: TCustomListView): TPoint; override;
159    class function GetVisibleRowCount(const ALV: TCustomListView): Integer; override;
160
161    class procedure SetAllocBy(const ALV: TCustomListView; const {%H-}AValue: Integer); override;
162    class procedure SetColor(const AWinControl: TWinControl); override;
163    class procedure SetDefaultItemHeight(const ALV: TCustomListView; const {%H-}AValue: Integer); override;
164    class procedure SetFont(const AWinControl: TWinControl; const AFont: TFont); override;
165    class procedure SetHotTrackStyles(const ALV: TCustomListView; const {%H-}AValue: TListHotTrackStyles); override;
166    class procedure SetHoverTime(const ALV: TCustomListView; const {%H-}AValue: Integer); override;
167    //    class procedure SetIconOptions(const ALV: TCustomListView; const AValue: TIconOptions); override;
168    class procedure SetImageList(const ALV: TCustomListView; const AList: TListViewImageList; const AValue: TCustomImageListResolution); override;
169    class procedure SetItemsCount(const ALV: TCustomListView; const {%H-}Avalue: Integer); override;
170    class procedure SetProperty(const ALV: TCustomListView; const AProp: TListViewProperty; const AIsSet: Boolean); override;
171    class procedure SetProperties(const ALV: TCustomListView; const AProps: TListViewProperties); override;
172    class procedure SetScrollBars(const ALV: TCustomListView; const AValue: TScrollStyle); override;
173    class procedure SetSort(const ALV: TCustomListView; const {%H-}AType: TSortType; const {%H-}AColumn: Integer;
174      const {%H-}ASortDirection: TSortDirection); override;
175    class procedure SetViewOrigin(const ALV: TCustomListView; const AValue: TPoint); override;
176    class procedure SetViewStyle(const ALV: TCustomListView; const AValue: TViewStyle); override;
177  end;
178
179  { TGtk3WSListView }
180
181  TGtk3WSListView = class(TWSListView)
182  published
183  end;
184
185  { TGtk3WSProgressBar }
186
187  TGtk3WSProgressBar = class(TWSProgressBar)
188  published
189    class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
190    class procedure ApplyChanges(const AProgressBar: TCustomProgressBar); override;
191    class procedure SetPosition(const AProgressBar: TCustomProgressBar; const NewPosition: integer); override;
192    class procedure SetStyle(const AProgressBar: TCustomProgressBar; const NewStyle: TProgressBarStyle); override;
193  end;
194
195  { TGtk3WSCustomUpDown }
196
197  TGtk3WSCustomUpDown = class(TWSCustomUpDown)
198  published
199  end;
200
201  { TGtk3WSUpDown }
202
203  TGtk3WSUpDown = class(TWSUpDown)
204  published
205  end;
206
207  { TGtk3WSToolButton }
208
209  TGtk3WSToolButton = class(TWSToolButton)
210  published
211  end;
212
213  { TGtk3WSToolBar }
214
215  TGtk3WSToolBar = class(TWSToolBar)
216  published
217    class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
218  end;
219
220  { TGtk3WSTrackBar }
221
222  TGtk3WSTrackBar = class(TWSTrackBar)
223  published
224    class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
225    class procedure ApplyChanges(const ATrackBar: TCustomTrackBar); override;
226    class function  GetPosition(const ATrackBar: TCustomTrackBar): integer; override;
227    class procedure SetPosition(const ATrackBar: TCustomTrackBar; const NewPosition: integer); override;
228    class procedure SetOrientation(const ATrackBar: TCustomTrackBar; const {%H-}AOrientation: TTrackBarOrientation); override;
229  end;
230
231  { TGtk3WSCustomTreeView }
232
233  TGtk3WSCustomTreeView = class(TWSCustomTreeView)
234  published
235  end;
236
237  { TGtk3WSTreeView }
238
239  TGtk3WSTreeView = class(TWSTreeView)
240  published
241  end;
242
243
244implementation
245uses gtk3procs;
246
247{ TGtk3WSTrackBar }
248
249class function TGtk3WSTrackBar.CreateHandle(const AWinControl: TWinControl;
250  const AParams: TCreateParams): TLCLIntfHandle;
251var
252  ATrack: TGtk3TrackBar;
253  APt: TPoint;
254begin
255  ATrack := TGtk3TrackBar.Create(AWinControl, AParams);
256  Result := TLCLIntfHandle(ATrack);
257end;
258
259class procedure TGtk3WSTrackBar.ApplyChanges(const ATrackBar: TCustomTrackBar);
260var
261  ATrack: TGtk3TrackBar;
262  APt: TPoint;
263begin
264  // inherited ApplyChanges(ATrackBar);
265  if not WSCheckHandleAllocated(ATrackBar, 'ApplyChanges') then
266    Exit;
267  ATrack := TGtk3TrackBar(ATrackBar.Handle);
268  APt.X := ATrackBar.Min;
269  APt.Y := ATrackBar.Max;
270  ATrack.BeginUpdate;
271  ATrack.Range := APt;
272  ATrack.Position:=ATrackBar.Position;
273  ATrack.SetStep(ATrackBar.Frequency, ATrackBar.PageSize);
274  ATrack.SetScalePos(ATrackBar.ScalePos);
275  ATrack.SetTickMarks(ATrackbar.TickMarks, ATrackBar.TickStyle);
276  ATrack.Reversed := ATrackBar.Reversed;
277  ATrack.EndUpdate;
278end;
279
280class function TGtk3WSTrackBar.GetPosition(const ATrackBar: TCustomTrackBar
281  ): integer;
282begin
283  if not WSCheckHandleAllocated(ATrackBar, 'GetPosition') then
284    Exit(0);
285  Result := TGtk3TrackBar(ATrackBar.Handle).Position;
286end;
287
288class procedure TGtk3WSTrackBar.SetPosition(const ATrackBar: TCustomTrackBar;
289  const NewPosition: integer);
290begin
291  if not WSCheckHandleAllocated(ATrackBar, 'SetPosition') then
292    Exit;
293  TGtk3TrackBar(ATrackBar.Handle).BeginUpdate;
294  TGtk3TrackBar(ATrackBar.Handle).Position := NewPosition;
295  TGtk3TrackBar(ATrackBar.Handle).EndUpdate;
296end;
297
298class procedure TGtk3WSTrackBar.SetOrientation(
299  const ATrackBar: TCustomTrackBar; const AOrientation: TTrackBarOrientation);
300begin
301  // inherited SetOrientation(ATrackBar, AOrientation);
302  if not WSCheckHandleAllocated(ATrackBar, 'SetOrientation') then
303    Exit;
304  if TGtk3TrackBar(ATrackBar.Handle).GetTrackBarOrientation <> AOrientation then
305    RecreateWnd(ATrackBar);
306end;
307
308{ TGtk3WSToolBar }
309
310class function TGtk3WSToolBar.CreateHandle(const AWinControl: TWinControl;
311  const AParams: TCreateParams): TLCLIntfHandle;
312var
313  AToolBar: TGtk3ToolBar;
314begin
315  AToolBar := TGtk3ToolBar.Create(AWinControl, AParams);
316  Result := TLCLIntfHandle(AToolBar);
317end;
318
319{ TGtk3WSProgressBar }
320
321class function TGtk3WSProgressBar.CreateHandle(const AWinControl: TWinControl;
322  const AParams: TCreateParams): TLCLIntfHandle;
323var
324  AProgress: TGtk3ProgressBar;
325begin
326  AProgress := TGtk3ProgressBar.Create(AWinControl, AParams);
327  Result := TLCLIntfHandle(AProgress);
328end;
329
330class procedure TGtk3WSProgressBar.ApplyChanges(
331  const AProgressBar: TCustomProgressBar);
332begin
333  // inherited ApplyChanges(AProgressBar);
334  if not WSCheckHandleAllocated(AProgressBar, 'ApplyChanges') then
335    Exit;
336  TGtk3ProgressBar(AProgressBar.Handle).BeginUpdate;
337  SetPosition(AProgressBar, AProgressBar.Position);
338  SetStyle(AProgressBar, AProgressBar.Style);
339  TGtk3ProgressBar(AProgressBar.Handle).ShowText := AProgressBar.BarShowText;
340  TGtk3ProgressBar(AProgressBar.Handle).Orientation := AProgressBar.Orientation;
341  TGtk3ProgressBar(AProgressBar.Handle).EndUpdate;
342end;
343
344class procedure TGtk3WSProgressBar.SetPosition(
345  const AProgressBar: TCustomProgressBar; const NewPosition: integer);
346begin
347  if not WSCheckHandleAllocated(AProgressBar, 'SetPosition') then
348    Exit;
349  TGtk3ProgressBar(AProgressBar.Handle).BeginUpdate;
350  TGtk3ProgressBar(AProgressBar.Handle).Position := NewPosition;
351  TGtk3ProgressBar(AProgressBar.Handle).EndUpdate;
352end;
353
354class procedure TGtk3WSProgressBar.SetStyle(
355  const AProgressBar: TCustomProgressBar; const NewStyle: TProgressBarStyle);
356begin
357  // inherited SetStyle(AProgressBar, NewStyle);
358  if not WSCheckHandleAllocated(AProgressBar, 'SetStyle') then
359    Exit;
360  TGtk3ProgressBar(AProgressBar.Handle).BeginUpdate;
361  TGtk3ProgressBar(AProgressBar.Handle).Style := NewStyle;
362  TGtk3ProgressBar(AProgressBar.Handle).EndUpdate;
363end;
364
365{ TGtk3WSCustomListView }
366
367class function TGtk3WSCustomListView.CreateHandle(
368  const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle;
369var
370  AListView: TGtk3ListView;
371begin
372  // DebugLn('TGtk3WSCustomListView.CreateHandle');
373  AListView := TGtk3ListView.Create(AWinControl, AParams);
374  Result := TLCLIntfHandle(AListView);
375end;
376(*
377class procedure TGtk3WSCustomListView.DestroyHandle(
378  const AWinControl: TWinControl);
379begin
380  inherited DestroyHandle(AWinControl);
381end;
382*)
383
384class procedure TGtk3WSCustomListView.SetPropertyInternal(
385  const ALV: TCustomListView; const AProp: TListViewProperty;
386  const AIsSet: Boolean);
387const
388  BoolToSelectionMode: array[Boolean] of TGtkSelectionMode = (
389    1 {GTK_SELECTION_SINGLE},
390    3 {GTK_SELECTION_MULTIPLE}
391  );
392begin
393  case AProp of
394    lvpAutoArrange:
395    begin
396      // TODO: implement ??
397    end;
398    lvpCheckboxes:
399    begin
400      // if TListView(ALV).ViewStyle in [vsReport,vsList] then
401      // AddRemoveCheckboxRenderer(ALV, GetWidgetInfo(Widgets^.MainView), AIsSet);
402    end;
403    lvpColumnClick:
404    begin
405      // allow only column modifications when in report mode
406      if TListView(ALV).ViewStyle <> vsReport then Exit;
407      if TGtk3ListView(ALV.Handle).IsTreeView then
408        PGtkTreeView(TGtk3ListView(ALV.Handle).GetContainerWidget)^.set_headers_clickable(AIsSet);
409    end;
410    lvpFlatScrollBars:
411    begin
412      // TODO: implement ??
413    end;
414    lvpFullDrag:
415    begin
416      // TODO: implement ??
417    end;
418    lvpGridLines:
419    begin
420      // TODO: better implementation
421      // maybe possible with some cellwidget hacking
422      // this create rows with alternating colors
423      if TGtk3ListView(ALV.Handle).IsTreeView then
424      begin
425        if AIsSet then
426          PGtkTreeView(TGtk3ListView(ALV.Handle).GetContainerWidget)^.set_grid_lines(GTK_TREE_VIEW_GRID_LINES_BOTH)
427        else
428          PGtkTreeView(TGtk3ListView(ALV.Handle).GetContainerWidget)^.set_grid_lines(GTK_TREE_VIEW_GRID_LINES_NONE);
429      end;
430    end;
431    lvpHideSelection:
432    begin
433      // TODO: implement
434      // should be possible with some focus in/out events
435    end;
436    lvpHotTrack:
437    begin
438      // TODO: implement
439      // should be possible with some mouse tracking
440    end;
441    lvpMultiSelect:
442    begin
443      if TGtk3ListView(ALV.Handle).IsTreeView then
444        PGtkTreeView(TGtk3ListView(ALV.Handle).GetContainerWidget)^.get_selection^.set_mode(BoolToSelectionMode[AIsSet])
445      else
446        PGtkIconView(TGtk3ListView(ALV.Handle).GetContainerWidget)^.set_selection_mode(BoolToSelectionMode[AIsSet]);
447    end;
448    lvpOwnerDraw:
449    begin
450      // TODO: implement
451      // use custom images/widgets ?
452    end;
453    lvpReadOnly:
454    begin
455      // TODO: implement inline editor ?
456    end;
457    lvpRowSelect:
458    begin
459      // TODO: implement ???
460      // how to do cell select
461    end;
462    lvpShowColumnHeaders:
463    begin
464      // allow only column modifications when in report mode
465      if not (TListView(ALV).ViewStyle in [vsList, vsReport]) then Exit;
466      if TGtk3ListView(ALV.Handle).IsTreeView then
467      begin
468        PGtkTreeView(TGtk3ListView(ALV.Handle).GetContainerWidget)^.set_headers_visible(AIsSet and (TListView(ALV).ViewStyle = vsReport));
469        PGtkTreeView(TGtk3ListView(ALV.Handle).GetContainerWidget)^.resize_children;
470      end;
471    end;
472    lvpShowWorkAreas:
473    begin
474      // TODO: implement ???
475    end;
476    lvpWrapText:
477    begin
478      // TODO: implement ???
479    end;
480  end;
481end;
482
483class procedure TGtk3WSCustomListView.ColumnDelete(const ALV: TCustomListView;
484  const AIndex: Integer);
485begin
486  if not WSCheckHandleAllocated(ALV, 'ColumnDelete') then
487    Exit;
488  // DebugLn('TGtk3WSCustomListView.ColumnDelete ');
489  TGtk3ListView(ALV.Handle).ColumnDelete(AIndex);
490end;
491
492class function TGtk3WSCustomListView.ColumnGetWidth(const ALV: TCustomListView;
493  const AIndex: Integer; const AColumn: TListColumn): Integer;
494begin
495  if not WSCheckHandleAllocated(ALV, 'ColumnGetWidth') then
496    Exit;
497  // DebugLn('TGtk3WSCustomListView.ColumnGetWidth ');
498  Result := TGtk3ListView(ALV.Handle).ColumnGetWidth(AIndex);
499end;
500
501class procedure TGtk3WSCustomListView.ColumnInsert(const ALV: TCustomListView;
502  const AIndex: Integer; const AColumn: TListColumn);
503begin
504  // DebugLn('TGtk3WSCustomListView.ColumnInsert ');
505  if not WSCheckHandleAllocated(ALV, 'ColumnInsert') then
506    Exit;
507  TGtk3ListView(ALV.Handle).ColumnInsert(AIndex, AColumn);
508  // inherited ColumnInsert(ALV, AIndex, AColumn);
509end;
510
511class procedure TGtk3WSCustomListView.ColumnMove(const ALV: TCustomListView;
512  const AOldIndex, ANewIndex: Integer; const AColumn: TListColumn);
513begin
514  DebugLn('TGtk3WSCustomListView.ColumnMove ');
515  // inherited ColumnMove(ALV, AOldIndex, ANewIndex, AColumn);
516end;
517
518class procedure TGtk3WSCustomListView.ColumnSetAlignment(
519  const ALV: TCustomListView; const AIndex: Integer;
520  const AColumn: TListColumn; const AAlignment: TAlignment);
521begin
522  if not WSCheckHandleAllocated(ALV, 'ColumnSetAlignment') then
523    Exit;
524  // DebugLn('TGtk3WSCustomListView.ColumnSetAlignment ');
525  // inherited ColumnSetAlignment(ALV, AIndex, AColumn, AAlignment);
526  TGtk3ListView(ALV.Handle).SetAlignment(AIndex, AColumn, AAlignment);
527end;
528
529class procedure TGtk3WSCustomListView.ColumnSetAutoSize(
530  const ALV: TCustomListView; const AIndex: Integer;
531  const AColumn: TListColumn; const AAutoSize: Boolean);
532begin
533  if not WSCheckHandleAllocated(ALV, 'ColumnSetAutoSize') then
534    Exit;
535  // DebugLn('TGtk3WSCustomListView.ColumnSetAutoSize ');
536  TGtk3ListView(ALV.Handle).SetColumnAutoSize(AIndex, AColumn, AAutoSize);
537  // inherited ColumnSetAutoSize(ALV, AIndex, AColumn, AAutoSize);
538end;
539
540class procedure TGtk3WSCustomListView.ColumnSetCaption(
541  const ALV: TCustomListView; const AIndex: Integer;
542  const AColumn: TListColumn; const ACaption: String);
543begin
544  if not WSCheckHandleAllocated(ALV, 'ColumnSetCaption') then
545    Exit;
546  // DebugLn('TGtk3WSCustomListView.ColumnSetCaption ');
547  // inherited ColumnSetCaption(ALV, AIndex, AColumn, ACaption);
548  TGtk3ListView(ALV.Handle).SetColumnCaption(AIndex, AColumn, ACaption);
549end;
550
551class procedure TGtk3WSCustomListView.ColumnSetImage(
552  const ALV: TCustomListView; const AIndex: Integer;
553  const AColumn: TListColumn; const AImageIndex: Integer);
554begin
555  // DebugLn('TGtk3WSCustomListView.ColumnSetImage ');
556  // inherited ColumnSetImage(ALV, AIndex, AColumn, AImageIndex);
557end;
558
559class procedure TGtk3WSCustomListView.ColumnSetMaxWidth(
560  const ALV: TCustomListView; const AIndex: Integer;
561  const AColumn: TListColumn; const AMaxWidth: Integer);
562begin
563  if not WSCheckHandleAllocated(ALV, 'ColumnSetMaxWidth') then
564    Exit;
565  // DebugLn('TGtk3WSCustomListView.ColumnSetMaxWidth ');
566  TGtk3ListView(ALV.Handle).SetColumnMaxWidth(AIndex, AColumn, AMaxWidth);
567  // inherited ColumnSetMaxWidth(ALV, AIndex, AColumn, AMaxWidth);
568end;
569
570class procedure TGtk3WSCustomListView.ColumnSetMinWidth(
571  const ALV: TCustomListView; const AIndex: Integer;
572  const AColumn: TListColumn; const AMinWidth: integer);
573begin
574  if not WSCheckHandleAllocated(ALV, 'ColumnSetMinWidth') then
575    Exit;
576  // DebugLn('TGtk3WSCustomListView.ColumnSetMinWidth ');
577  TGtk3ListView(ALV.Handle).SetColumnMinWidth(AIndex, AColumn, AMinWidth);
578  // inherited ColumnSetMinWidth(ALV, AIndex, AColumn, AMinWidth);
579end;
580
581class procedure TGtk3WSCustomListView.ColumnSetWidth(
582  const ALV: TCustomListView; const AIndex: Integer;
583  const AColumn: TListColumn; const AWidth: Integer);
584begin
585  if not WSCheckHandleAllocated(ALV, 'ColumnSetWidth') then
586    Exit;
587  // DebugLn('TGtk3WSCustomListView.ColumnSetWidth ');
588  // inherited ColumnSetWidth(ALV, AIndex, AColumn, AWidth);
589  TGtk3ListView(ALV.Handle).SetColumnWidth(AIndex, AColumn, AWidth);
590end;
591
592class procedure TGtk3WSCustomListView.ColumnSetVisible(
593  const ALV: TCustomListView; const AIndex: Integer;
594  const AColumn: TListColumn; const AVisible: Boolean);
595begin
596  if not WSCheckHandleAllocated(ALV, 'ColumnSetVisible') then
597    Exit;
598  // DebugLn('TGtk3WSCustomListView.ColumnSetVisible ');
599  // inherited ColumnSetVisible(ALV, AIndex, AColumn, AVisible);
600  TGtk3ListView(ALV.Handle).SetColumnVisible(AIndex, AColumn, AVisible);
601end;
602
603class procedure TGtk3WSCustomListView.ColumnSetSortIndicator(
604  const ALV: TCustomListView; const AIndex: Integer;
605  const AColumn: TListColumn; const ASortIndicator: TSortIndicator);
606begin
607  if not WSCheckHandleAllocated(ALV, 'ColumnSetSortIndicator') then
608    Exit;
609
610  TGtk3ListView(ALV.Handle).ColumnSetSortIndicator(AIndex,AColumn,ASortIndicator);
611end;
612
613
614
615
616type
617  TListItemHack = class(TListItem)
618  end;
619
620class procedure TGtk3WSCustomListView.ItemDelete(const ALV: TCustomListView;
621  const AIndex: Integer);
622begin
623  if not WSCheckHandleAllocated(ALV, 'ItemDelete') then
624    Exit;
625  TGtk3ListView(ALV.Handle).ItemDelete(AIndex);
626  // DebugLn('TGtk3WSCustomListView.ItemDelete ');
627  // inherited ItemDelete(ALV, AIndex);
628end;
629
630class function TGtk3WSCustomListView.ItemDisplayRect(
631  const ALV: TCustomListView; const AIndex, ASubItem: Integer;
632  ACode: TDisplayCode): TRect;
633begin
634  DebugLn('TGtk3WSCustomListView.ItemDisplayRect ');
635  Result := Rect(0, 0, 0, 0);
636end;
637
638class procedure TGtk3WSCustomListView.ItemExchange(const ALV: TCustomListView;
639  AItem: TListItem; const AIndex1, AIndex2: Integer);
640begin
641  DebugLn('TGtk3WSCustomListView.ItemExchange ');
642  // inherited ItemExchange(ALV, AItem, AIndex1, AIndex2);
643end;
644
645class procedure TGtk3WSCustomListView.ItemMove(const ALV: TCustomListView;
646  AItem: TListItem; const AFromIndex, AToIndex: Integer);
647begin
648  DebugLn('TGtk3WSCustomListView.ItemMove ');
649  // inherited ItemMove(ALV, AItem, AFromIndex, AToIndex);
650end;
651
652class function TGtk3WSCustomListView.ItemGetChecked(const ALV: TCustomListView;
653  const AIndex: Integer; const AItem: TListItem): Boolean;
654begin
655  if not WSCheckHandleAllocated(ALV, 'ItemGetChecked') then
656    Exit;
657  // DebugLn('TGtk3WSCustomListView.ItemGetChecked ');
658  Result := TListItemHack(AItem).GetCheckedInternal;
659end;
660
661class function TGtk3WSCustomListView.ItemGetState(const ALV: TCustomListView;
662  const AIndex: Integer; const AItem: TListItem; const AState: TListItemState;
663  out AIsSet: Boolean): Boolean;
664begin
665  if not WSCheckHandleAllocated(ALV, 'ItemGetState') then
666    Exit;
667  // DebugLn('TGtk3WSCustomListView.ItemGetState ');
668  Result := TGtk3ListView(ALV.Handle).ItemGetState(AIndex, AItem, AState, AIsSet);
669end;
670
671class procedure TGtk3WSCustomListView.ItemInsert(const ALV: TCustomListView;
672  const AIndex: Integer; const AItem: TListItem);
673begin
674  if not WSCheckHandleAllocated(ALV, 'ItemInsert') then
675    Exit;
676  // DebugLn('TGtk3WSCustomListView.ItemInsert ');
677  TGtk3ListView(ALV.Handle).ItemInsert(AIndex, AItem);
678end;
679
680class procedure TGtk3WSCustomListView.ItemSetChecked(
681  const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem;
682  const AChecked: Boolean);
683begin
684  if not WSCheckHandleAllocated(ALV, 'ItemSetChecked') then
685    Exit;
686  // not needed
687  // DebugLn('TGtk3WSCustomListView.ItemSetChecked ');
688  // inherited ItemSetChecked(ALV, AIndex, AItem, AChecked);
689end;
690
691class procedure TGtk3WSCustomListView.ItemSetImage(const ALV: TCustomListView;
692  const AIndex: Integer; const AItem: TListItem; const ASubIndex,
693  AImageIndex: Integer);
694begin
695  if not WSCheckHandleAllocated(ALV, 'ItemSetImage') then
696    Exit;
697  TGtk3ListView(ALV.Handle).BeginUpdate;
698  TGtk3ListView(ALV.Handle).ItemSetImage(AIndex,ASubIndex, AItem);
699  TGtk3ListView(ALV.Handle).EndUpdate;
700end;
701
702class procedure TGtk3WSCustomListView.ItemSetState(const ALV: TCustomListView;
703  const AIndex: Integer; const AItem: TListItem; const AState: TListItemState;
704  const AIsSet: Boolean);
705begin
706  if not WSCheckHandleAllocated(ALV, 'ItemSetState') then
707    Exit;
708   // DebugLn('TGtk3WSCustomListView.ItemSetState ');
709  // inherited ItemSetState(ALV, AIndex, AItem, AState, AIsSet);
710  TGtk3ListView(ALV.Handle).BeginUpdate;
711  TGtk3ListView(ALV.Handle).ItemSetState(AIndex, AItem, AState, AIsSet);
712  TGtk3ListView(ALV.Handle).EndUpdate;
713end;
714
715class procedure TGtk3WSCustomListView.ItemSetText(const ALV: TCustomListView;
716  const AIndex: Integer; const AItem: TListItem; const ASubIndex: Integer;
717  const AText: String);
718begin
719  if not WSCheckHandleAllocated(ALV, 'ItemSetText') then
720    Exit;
721  // DebugLn('TGtk3WSCustomListView.ItemSetText ');
722  TGtk3ListView(ALV.Handle).ItemSetText(AIndex, ASubIndex, AItem, AText);
723end;
724
725class procedure TGtk3WSCustomListView.ItemShow(const ALV: TCustomListView;
726  const AIndex: Integer; const AItem: TListItem; const PartialOK: Boolean);
727begin
728  DebugLn('TGtk3WSCustomListView.ItemShow ');
729  // inherited ItemShow(ALV, AIndex, AItem, PartialOK);
730end;
731
732class function TGtk3WSCustomListView.ItemGetPosition(
733  const ALV: TCustomListView; const AIndex: Integer): TPoint;
734begin
735  DebugLn('TGtk3WSCustomListView.ItemGetPosition ');
736  Result := Point(0, 0); // inherited ItemGetPosition(ALV, AIndex);
737end;
738
739class procedure TGtk3WSCustomListView.ItemUpdate(const ALV: TCustomListView;
740  const AIndex: Integer; const AItem: TListItem);
741begin
742  DebugLn('TGtk3WSCustomListView.ItemUpdate ');
743  // inherited ItemUpdate(ALV, AIndex, AItem);
744end;
745
746class procedure TGtk3WSCustomListView.BeginUpdate(const ALV: TCustomListView);
747begin
748  // inherited BeginUpdate(ALV);
749  DebugLn('TGtk3WSCustomListView.BeginUpdate ');
750end;
751
752class procedure TGtk3WSCustomListView.EndUpdate(const ALV: TCustomListView);
753begin
754  // inherited EndUpdate(ALV);
755  DebugLn('TGtk3WSCustomListView.EndUpdate ');
756end;
757
758class function TGtk3WSCustomListView.GetBoundingRect(const ALV: TCustomListView
759  ): TRect;
760begin
761  DebugLn('TGtk3WSCustomListView.GetBoundingRect ');
762  Result := Rect(0, 0, 0, 0);
763end;
764
765class function TGtk3WSCustomListView.GetDropTarget(const ALV: TCustomListView
766  ): Integer;
767begin
768  DebugLn('TGtk3WSCustomListView.GetDropTarget ');
769  Result := -1;
770end;
771
772class function TGtk3WSCustomListView.GetFocused(const ALV: TCustomListView
773  ): Integer;
774begin
775  DebugLn('TGtk3WSCustomListView.GetFocused ');
776  Result := -1;
777end;
778
779class function TGtk3WSCustomListView.GetHoverTime(const ALV: TCustomListView
780  ): Integer;
781begin
782  DebugLn('TGtk3WSCustomListView.GetHoverTime ');
783  Result := 0;
784end;
785
786class function TGtk3WSCustomListView.GetItemAt(const ALV: TCustomListView; x,
787  y: integer): Integer;
788var
789  ItemPath: PGtkTreePath;
790  Column: PGtkTreeViewColumn;
791  cx, cy: gint;
792begin
793  Result := -1;
794  if not WSCheckHandleAllocated(ALV, 'GetItemAt') then
795    Exit;
796  if TGtk3ListView(ALV.Handle).IsTreeView then
797  begin
798    //PGtkTreeView(TGtk3ListView(ALV.Handle).GetContainerWidget)^.get_bin_window^.get_position(@cx, @cy);
799    //Dec(x, cx);
800    //Dec(y, cy);
801    ItemPath := nil;
802    Column := nil;
803    if PGtkTreeView(TGtk3ListView(ALV.Handle).GetContainerWidget)^.get_path_at_pos(x, y, @ItemPath, @Column, nil, nil) then
804    begin
805      if ItemPath <> nil then
806      begin
807        Result := gtk_tree_path_get_indices(ItemPath)^;
808        gtk_tree_path_free(ItemPath);
809      end;
810    end;
811  end else
812  begin
813    ItemPath := PGtkIconView(TGtk3ListView(ALV.Handle).GetContainerWidget)^.get_path_at_pos(x, y);
814    if ItemPath <> nil then
815    begin
816      Result := gtk_tree_path_get_indices(ItemPath)^;
817      gtk_tree_path_free(ItemPath);
818    end;
819  end;
820end;
821
822class function TGtk3WSCustomListView.GetSelCount(const ALV: TCustomListView
823  ): Integer;
824begin
825  DebugLn('TGtk3WSCustomListView.GetSelCount ');
826  Result := 0;
827end;
828
829class function TGtk3WSCustomListView.GetSelection(const ALV: TCustomListView
830  ): Integer;
831begin
832  DebugLn('TGtk3WSCustomListView.GetSelection ');
833  Result := -1;
834end;
835
836class function TGtk3WSCustomListView.GetTopItem(const ALV: TCustomListView
837  ): Integer;
838begin
839  DebugLn('TGtk3WSCustomListView.GetTopItem ');
840  Result := 0;
841end;
842
843class function TGtk3WSCustomListView.GetViewOrigin(const ALV: TCustomListView
844  ): TPoint;
845begin
846  DebugLn('TGtk3WSCustomListView.GetViewOrigin ');
847  Result := Point(0, 0);
848  // Result:=inherited GetViewOrigin(ALV);
849end;
850
851class function TGtk3WSCustomListView.GetVisibleRowCount(
852  const ALV: TCustomListView): Integer;
853begin
854  DebugLn('TGtk3WSCustomListView.GetVisibleRowCount ');
855  Result := 0;
856  // Result:=inherited GetVisibleRowCount(ALV);
857end;
858
859class procedure TGtk3WSCustomListView.SetAllocBy(const ALV: TCustomListView;
860  const AValue: Integer);
861begin
862  // DebugLn('TGtk3WSCustomListView.SetAllocBy ');
863  // inherited SetAllocBy(ALV, AValue);
864end;
865
866class procedure TGtk3WSCustomListView.SetColor(const AWinControl: TWinControl);
867begin
868  DebugLn('TGtk3WSCustomListView.SetColor ');
869  inherited SetColor(AWinControl);
870end;
871
872class procedure TGtk3WSCustomListView.SetDefaultItemHeight(
873  const ALV: TCustomListView; const AValue: Integer);
874begin
875  if not WSCheckHandleAllocated(ALV, 'SetDefaultItemHeight') then
876    Exit;
877  // DebugLn('TGtk3WSCustomListView.SetDefaultItemHeight ',dbgs(AValue));
878  if TGtk3ListView(ALV.Handle).IsTreeView then
879    PGtkTreeView(TGtk3ListView(ALV.Handle).GetContainerWidget)^.set_fixed_height_mode(AValue > 0);
880end;
881
882class procedure TGtk3WSCustomListView.SetFont(const AWinControl: TWinControl;
883  const AFont: TFont);
884begin
885  DebugLn('TGtk3WSCustomListView.SetFont ');
886  inherited SetFont(AWinControl, AFont);
887end;
888
889class procedure TGtk3WSCustomListView.SetHotTrackStyles(
890  const ALV: TCustomListView; const AValue: TListHotTrackStyles);
891begin
892  // DebugLn('TGtk3WSCustomListView.SetHotTrackStyles ');
893  // inherited SetHotTrackStyles(ALV, AValue);
894end;
895
896class procedure TGtk3WSCustomListView.SetHoverTime(const ALV: TCustomListView;
897  const AValue: Integer);
898begin
899  // DebugLn('TGtk3WSCustomListView.SetHoverTime ');
900  // inherited SetHoverTime(ALV, AValue);
901end;
902
903class procedure TGtk3WSCustomListView.SetImageList(const ALV: TCustomListView;
904  const AList: TListViewImageList; const AValue: TCustomImageListResolution);
905var
906  AView: TGtk3ListView;
907  i: Integer;
908  Bmp: TBitmap;
909begin
910  if not WSCheckHandleAllocated(ALV, 'SetImageList') then
911    exit;
912  DebugLn('TGtk3WSCustomListView.SetImageList ');
913  AView := TGtk3ListView(ALV.Handle);
914  // inherited SetImageList(ALV, AList, AValue);
915  if ((AList = lvilLarge) and not AView.IsTreeView) or
916     ((AList = lvilSmall) and AView.IsTreeView) then
917  begin
918    if Assigned(AView.Images) then
919      AView.ClearImages
920    else
921      AView.Images := TFPList.Create;
922    if Assigned(AValue) then
923    begin
924      for i := 0 to AValue.Count - 1 do
925      begin
926        Bmp := TBitmap.Create;
927        AValue.GetBitmap(i, Bmp);
928        AView.Images.Add(Bmp);
929      end;
930    end;
931
932    if AView.IsTreeView then
933      AView.UpdateImageCellsSize;
934
935    AView.Update(nil);
936  end;
937end;
938
939class procedure TGtk3WSCustomListView.SetItemsCount(const ALV: TCustomListView;
940  const Avalue: Integer);
941begin
942  DebugLn('TGtk3WSCustomListView.SetItemsCount ');
943  // inherited SetItemsCount(ALV, Avalue);
944end;
945
946class procedure TGtk3WSCustomListView.SetProperty(const ALV: TCustomListView;
947  const AProp: TListViewProperty; const AIsSet: Boolean);
948begin
949  if not WSCheckHandleAllocated(ALV, 'SetProperty') then
950    Exit;
951  // DebugLn('TGtk3WSCustomListView.SetProperty ');
952  SetPropertyInternal(ALV, AProp, AIsSet);
953end;
954
955class procedure TGtk3WSCustomListView.SetProperties(const ALV: TCustomListView;
956  const AProps: TListViewProperties);
957var
958  Prop: TListViewProperty;
959begin
960  if not WSCheckHandleAllocated(ALV, 'SetProperties') then
961    Exit;
962  for Prop := Low(Prop) to High(Prop) do
963    SetPropertyInternal(ALV, Prop, Prop in AProps);
964end;
965
966class procedure TGtk3WSCustomListView.SetScrollBars(const ALV: TCustomListView;
967  const AValue: TScrollStyle);
968var
969  SS: TPoint;
970begin
971  if not WSCheckHandleAllocated(ALV, 'SetScrollBars') then
972    Exit;
973  // DebugLn('TGtk3WSCustomListView.SetScrollbars ');
974  // inherited SetScrollBars(ALV, AValue);
975  SS := Gtk3TranslateScrollStyle(AValue);
976  TGtk3ListView(ALV.Handle).GetScrolledWindow^.set_policy(SS.X, SS.Y);
977end;
978
979class procedure TGtk3WSCustomListView.SetSort(const ALV: TCustomListView;
980  const AType: TSortType; const AColumn: Integer;
981  const ASortDirection: TSortDirection);
982begin
983  if not WSCheckHandleAllocated(ALV, 'SetSort') then
984    Exit;
985  if TGtk3ListView(ALV.Handle).GetContainerWidget^.get_realized then
986    TGtk3ListView(ALV.Handle).GetContainerWidget^.queue_draw;
987  // DebugLn('TGtk3WSCustomListView.SetSort ');
988  // inherited SetSort(ALV, AType, AColumn, ASortDirection);
989end;
990
991class procedure TGtk3WSCustomListView.SetViewOrigin(const ALV: TCustomListView;
992  const AValue: TPoint);
993begin
994  if not WSCheckHandleAllocated(ALV, 'SetViewOrigin') then
995    Exit;
996  if not TGtk3ListView(ALV.Handle).GetContainerWidget^.get_realized then
997    exit;
998  // DebugLn('TGtk3WSCustomListView.SetViewOrigin ');
999  if TGtk3ListView(ALV.Handle).IsTreeView then
1000    PGtkTreeView(TGtk3ListView(ALV.Handle).GetContainerWidget)^.scroll_to_point(AValue.X, AValue.Y);
1001  // TODO: else
1002  //  PGtkIconView(TGtk3ListView(ALV.Handle).GetContainerWidget)^.scroll_to_path();
1003end;
1004
1005class procedure TGtk3WSCustomListView.SetViewStyle(const ALV: TCustomListView;
1006  const AValue: TViewStyle);
1007begin
1008  if not WSCheckHandleAllocated(ALV, 'SetViewStyle') then
1009    Exit;
1010  DebugLn('TGtk3WSCustomListView.SetViewStyle ');
1011  // inherited SetViewStyle(ALV, AValue);
1012end;
1013
1014{ TGtk3WSStatusBar }
1015
1016class function TGtk3WSStatusBar.CreateHandle(const AWinControl: TWinControl;
1017  const AParams: TCreateParams): TLCLIntfHandle;
1018var
1019  AStatusBar: TGtk3StatusBar;
1020begin
1021  AStatusBar := TGtk3StatusBar.Create(AWinControl, AParams);
1022  Result := TLCLIntfHandle(AStatusBar);
1023end;
1024
1025class procedure TGtk3WSStatusBar.PanelUpdate(const AStatusBar: TStatusBar;
1026  PanelIndex: integer);
1027begin
1028  // inherited PanelUpdate(AStatusBar, PanelIndex);
1029end;
1030
1031class procedure TGtk3WSStatusBar.SetPanelText(const AStatusBar: TStatusBar;
1032  PanelIndex: integer);
1033begin
1034  // inherited SetPanelText(AStatusBar, PanelIndex);
1035end;
1036
1037class procedure TGtk3WSStatusBar.Update(const AStatusBar: TStatusBar);
1038begin
1039  // inherited Update(AStatusBar);
1040end;
1041
1042class procedure TGtk3WSStatusBar.GetPreferredSize(
1043  const AWinControl: TWinControl; var PreferredWidth, PreferredHeight: integer;
1044  WithThemeSpace: Boolean);
1045begin
1046  inherited GetPreferredSize(AWinControl, PreferredWidth, PreferredHeight,
1047    WithThemeSpace);
1048end;
1049
1050class procedure TGtk3WSStatusBar.SetSizeGrip(const AStatusBar: TStatusBar;
1051  SizeGrip: Boolean);
1052begin
1053  // inherited SetSizeGrip(AStatusBar, SizeGrip);
1054end;
1055
1056{ TGtk3WSCustomTabControl }
1057
1058class function TGtk3WSCustomTabControl.CreateHandle(
1059  const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle;
1060begin
1061  if AWinControl is TTabControl then
1062    Result := TLCLIntfHandle(TGtk3CustomControl.Create(AWinControl, AParams))
1063  else
1064    Result := TLCLIntfHandle(TGtk3NoteBook.Create(AWinControl, AParams));
1065end;
1066
1067(*
1068class function TGtk3WSCustomTabControl.GetDefaultClientRect(
1069  const AWinControl: TWinControl; const aLeft, aTop, aWidth, aHeight: integer;
1070  var aClientRect: TRect): boolean;
1071begin
1072  Result:=inherited GetDefaultClientRect(AWinControl, aLeft, aTop, aWidth,
1073    aHeight, aClientRect);
1074end;
1075*)
1076
1077class procedure TGtk3WSCustomTabControl.AddPage(
1078  const ATabControl: TCustomTabControl; const AChild: TCustomPage;
1079  const AIndex: integer);
1080begin
1081  if not WSCheckHandleAllocated(ATabControl, 'AddPage') then
1082    Exit;
1083  // set LCL size
1084  AChild.SetBounds(AChild.Left, AChild.Top, ATabControl.ClientWidth, ATabControl.ClientHeight);
1085
1086  if AChild.TabVisible then
1087    TGtk3Widget(AChild.Handle).Show;
1088
1089  if ATabControl is TTabControl then
1090    exit;
1091
1092  TGtk3Notebook(ATabControl.Handle).InsertPage(AChild, AIndex);
1093end;
1094
1095class procedure TGtk3WSCustomTabControl.MovePage(
1096  const ATabControl: TCustomTabControl; const AChild: TCustomPage;
1097  const NewIndex: integer);
1098begin
1099  if not WSCheckHandleAllocated(ATabControl, 'MovePage') then
1100    Exit;
1101  if (ATabControl is TTabControl) then
1102    exit;
1103  TGtk3Notebook(ATabControl.Handle).MovePage(AChild, NewIndex);
1104end;
1105
1106class procedure TGtk3WSCustomTabControl.RemovePage(
1107  const ATabControl: TCustomTabControl; const AIndex: integer);
1108begin
1109  if not WSCheckHandleAllocated(ATabControl, 'RemovePage') then
1110    Exit;
1111  if (ATabControl is TTabControl) then
1112    exit;
1113  TGtk3Notebook(ATabControl.Handle).RemovePage(AIndex);
1114end;
1115
1116class function TGtk3WSCustomTabControl.GetCapabilities: TCTabControlCapabilities;
1117begin
1118  Result := [nbcShowCloseButtons, nbcMultiLine, nbcPageListPopup, nbcShowAddTabButton];
1119end;
1120
1121class function TGtk3WSCustomTabControl.GetNotebookMinTabHeight(
1122  const AWinControl: TWinControl): integer;
1123begin
1124  Result := inherited GetNotebookMinTabHeight(AWinControl);
1125  // inherited GetNotebookMinTabHeight(AWinControl);
1126end;
1127
1128class function TGtk3WSCustomTabControl.GetNotebookMinTabWidth(
1129  const AWinControl: TWinControl): integer;
1130begin
1131  Result := TWSCustomTabControl.GetNotebookMinTabWidth(AWinControl);
1132end;
1133
1134class function TGtk3WSCustomTabControl.GetTabIndexAtPos(
1135  const ATabControl: TCustomTabControl; const AClientPos: TPoint): integer;
1136var
1137  NoteBookWidget: PGtkNotebook;
1138  TabWidget, PageWidget: PGtkWidget;
1139  i: integer;
1140  AList: PGList;
1141  Allocation: TGtkAllocation;
1142  ARect: TRect;
1143begin
1144  Result:=-1;
1145  if (ATabControl is TTabControl) then
1146    exit;
1147  NoteBookWidget := PGtkNotebook(TGtk3NoteBook(ATabControl.Handle).GetContainerWidget);
1148  if (NotebookWidget=nil) then exit;
1149
1150  AList := NoteBookWidget^.get_children;
1151  try
1152    for i := 0 to g_list_length(AList) - 1 do
1153    begin
1154      PageWidget := NoteBookWidget^.get_nth_page(i);
1155      if (PageWidget<>nil) then
1156      begin
1157        TabWidget := NoteBookWidget^.get_tab_label(PageWidget);
1158        if TabWidget <> nil then
1159        begin
1160          gtk_widget_get_allocation(TabWidget, @Allocation);
1161          ARect := RectFromGdkRect(Allocation);
1162          if PtInRect(ARect, AClientPos) then
1163          begin
1164            Result := I;
1165            break;
1166          end;
1167        end;
1168      end;
1169    end;
1170  finally
1171    if AList <> nil then
1172      g_list_free(Alist);
1173  end;
1174end;
1175
1176class function TGtk3WSCustomTabControl.GetTabRect(
1177  const ATabControl: TCustomTabControl; const AIndex: Integer): TRect;
1178var
1179  NoteBookWidget: PGtkNotebook;
1180  TabWidget, PageWidget: PGtkWidget;
1181  Count: guint;
1182  AList: PGList;
1183  Allocation: TGtkAllocation;
1184  X, Y: gint;
1185begin
1186  Result := inherited;
1187  if (ATabControl is TTabControl) then
1188    exit;
1189  Result := Rect(0, 0, 0, 0);
1190
1191  NoteBookWidget := PGtkNotebook(TGtk3NoteBook(ATabControl.Handle).GetContainerWidget);
1192  if (NotebookWidget=nil) then exit;
1193
1194  AList := NoteBookWidget^.get_children;
1195  try
1196    Count := g_list_length(AList);
1197    PageWidget := NoteBookWidget^.get_nth_page(AIndex);
1198    if (PageWidget<>nil) and (AIndex < Count) then
1199    begin
1200      TabWidget := NoteBookWidget^.get_tab_label(PageWidget);
1201      if TabWidget <> nil then
1202      begin
1203        gtk_widget_get_allocation(TabWidget, @Allocation);
1204        Result := RectFromGdkRect(Allocation);
1205        gtk_widget_get_allocation(NoteBookWidget, @Allocation);
1206        Y := Allocation.y;
1207        X := Allocation.x;
1208        if Y <= 0 then
1209          exit;
1210        case ATabControl.TabPosition of
1211          tpTop, tpBottom:
1212              OffsetRect(Result, 0, -Y);
1213          tpLeft, tpRight:
1214            OffsetRect(Result, -X, -Y);
1215        end;
1216      end;
1217    end;
1218  finally
1219    if AList <> nil then
1220      g_list_free(Alist);
1221  end;
1222end;
1223
1224class procedure TGtk3WSCustomTabControl.SetPageIndex(
1225  const ATabControl: TCustomTabControl; const AIndex: integer);
1226begin
1227  if (ATabControl is TTabControl) then
1228    exit;
1229  if not WSCheckHandleAllocated(ATabControl, 'SetPageIndex') then
1230    Exit;
1231  TGtk3Notebook(ATabControl.Handle).BeginUpdate;
1232  TGtk3Notebook(ATabControl.Handle).SetPageIndex(AIndex);
1233  TGtk3Notebook(ATabControl.Handle).EndUpdate;
1234end;
1235
1236class procedure TGtk3WSCustomTabControl.SetTabCaption(
1237  const ATabControl: TCustomTabControl; const AChild: TCustomPage;
1238  const AText: string);
1239begin
1240  if (ATabControl is TTabControl) then
1241    exit;
1242  if not WSCheckHandleAllocated(ATabControl, 'SetTabCaption') then
1243    Exit;
1244  TGtk3NoteBook(ATabControl.Handle).SetTabLabelText(AChild, AText);
1245end;
1246
1247class procedure TGtk3WSCustomTabControl.SetTabPosition(
1248  const ATabControl: TCustomTabControl; const ATabPosition: TTabPosition);
1249begin
1250  if (ATabControl is TTabControl) then
1251    exit;
1252  if not WSCheckHandleAllocated(ATabControl, 'SetTabPosition') then
1253    Exit;
1254  TGtk3NoteBook(ATabControl.Handle).SetTabPosition(ATabPosition);
1255end;
1256
1257class procedure TGtk3WSCustomTabControl.ShowTabs(
1258  const ATabControl: TCustomTabControl; AShowTabs: boolean);
1259begin
1260  if ATabControl is TTabControl then
1261    exit;
1262  if not WSCheckHandleAllocated(ATabControl, 'ShowTabs') then
1263    Exit;
1264  TGtk3NoteBook(ATabControl.Handle).SetShowTabs(AShowTabs);
1265end;
1266
1267class procedure TGtk3WSCustomTabControl.UpdateProperties(
1268  const ATabControl: TCustomTabControl);
1269begin
1270  if ATabControl is TTabControl then
1271    exit;
1272  // inherited UpdateProperties(ATabControl);
1273  if not WSCheckHandleAllocated(ATabControl, 'ATabControl') then
1274    Exit;
1275
1276  if (nboHidePageListPopup in ATabControl.Options) then
1277    PGtkNotebook(TGtk3NoteBook(ATabControl.Handle).GetContainerWidget)^.popup_disable
1278  else
1279    PGtkNotebook(TGtk3NoteBook(ATabControl.Handle).GetContainerWidget)^.popup_enable;
1280end;
1281
1282
1283{ TGtk3WSCustomPage }
1284
1285class function TGtk3WSCustomPage.CreateHandle(const AWinControl: TWinControl;
1286  const AParams: TCreateParams): TLCLIntfHandle;
1287begin
1288  Result := TLCLIntfHandle(TGtk3Page.Create(AWinControl, AParams));
1289end;
1290
1291class procedure TGtk3WSCustomPage.UpdateProperties(
1292  const ACustomPage: TCustomPage);
1293begin
1294  // inherited UpdateProperties(ACustomPage);
1295  DebugLn('TGtk3WSCustomPage.UpdateProperties missing implementation ');
1296end;
1297
1298class procedure TGtk3WSCustomPage.SetBounds(const AWinControl: TWinControl;
1299  const ALeft, ATop, AWidth, AHeight: Integer);
1300begin
1301  // ignore lcl bounds
1302  // inherited SetBounds(AWinControl, ALeft, ATop, AWidth, AHeight);
1303end;
1304
1305class procedure TGtk3WSCustomPage.SetFont(const AWinControl: TWinControl;
1306  const AFont: TFont);
1307begin
1308  inherited SetFont(AWinControl, AFont);
1309end;
1310
1311class procedure TGtk3WSCustomPage.ShowHide(const AWinControl: TWinControl);
1312begin
1313  // DebugLn('TGtk3WSCustomPage.ShowHide ',AWinControl.Caption);
1314  inherited ShowHide(AWinControl);
1315end;
1316
1317class function TGtk3WSCustomPage.GetDefaultClientRect(
1318  const AWinControl: TWinControl; const aLeft, aTop, aWidth, aHeight: integer;
1319  var aClientRect: TRect): boolean;
1320begin
1321  Result:=false;
1322  if AWinControl.Parent = nil then exit;
1323  if AWinControl.HandleAllocated and AWinControl.Parent.HandleAllocated and
1324    (TGtk3Widget(AWinControl.Handle).Widget^.parent <> nil) then
1325  begin
1326
1327  end else
1328  begin
1329    Result := True;
1330    aClientRect := AWinControl.Parent.ClientRect;
1331    // DebugLn(['TGtk3WSCustomPage.GetDefaultClientRect ',DbgSName(AWinControl),' Parent=',DbgSName(AWinControl.Parent),' ParentBounds=',dbgs(AWinControl.Parent.BoundsRect),' ParentClient=',dbgs(AWinControl.Parent.ClientRect)]);
1332  end;
1333end;
1334
1335end.
1336