32
31
GLib2, Gtk2, Gdk2, Gdk2pixbuf,
34
ComCtrls, Classes, FPCAdds, LCLType, LMessages, Controls, Graphics,
35
StdCtrls, LCLProc, ImgList, Math, Sysutils, InterfaceBase,
33
ComCtrls, Classes, LCLType, LMessages, Controls, Graphics,
34
StdCtrls, Forms, LCLProc, LCLIntf, ImgList, Math, Sysutils, InterfaceBase,
37
36
WSComCtrls, WSLCLClasses, WSControls, WSProc,
53
52
//this is created and destroyed as needed
54
53
//it only holds items which are about to be changed the list is emptied in Gtk2_ItemSelectionChanged
55
54
ItemCache: TStringList;
55
OldTreeSelection: PGList; // needed only by gtk < 2.10 ! issue #19820
62
TGtk2WSCustomPage = class(TWSCustomPage)
64
class procedure SetCallbacks(const AGtkWidget: PGtkWidget; const AWidgetInfo: PWidgetInfo); virtual;
66
class function CreateHandle(const AWinControl: TWinControl;
67
const AParams: TCreateParams): TLCLIntfHandle; override;
68
class procedure UpdateProperties(const ACustomPage: TCustomPage); override;
69
class procedure SetBounds(const {%H-}AWinControl: TWinControl; const {%H-}ALeft, {%H-}ATop, {%H-}AWidth, {%H-}AHeight: Integer); override;
70
class procedure SetFont(const AWinControl: TWinControl; const AFont: TFont); override;
71
class procedure ShowHide(const AWinControl: TWinControl); override;
72
class function GetDefaultClientRect(const AWinControl: TWinControl;
73
const {%H-}aLeft, {%H-}aTop, {%H-}aWidth, {%H-}aHeight: integer; var aClientRect: TRect
77
{ TGtk2WSCustomTabControl }
79
TGtk2WSCustomTabControl = class(TWSCustomTabControl)
81
class function CreateTTabControlHandle(const AWinControl: TWinControl;
82
const AParams: TCreateParams): HWND;
84
class procedure SetCallbacks(const AGtkWidget: PGtkWidget; const AWidgetInfo: PWidgetInfo); virtual;
86
class function CreateHandle(const AWinControl: TWinControl;
87
const AParams: TCreateParams): HWND; override;
88
class function GetDefaultClientRect(const AWinControl: TWinControl;
89
const {%H-}aLeft, {%H-}aTop, aWidth, aHeight: integer; var aClientRect: TRect
91
class procedure AddPage(const ATabControl: TCustomTabControl;
92
const AChild: TCustomPage; const AIndex: integer); override;
93
class procedure MovePage(const ATabControl: TCustomTabControl;
94
const AChild: TCustomPage; const NewIndex: integer); override;
96
class function GetCapabilities: TCTabControlCapabilities; override;
97
class function GetNotebookMinTabHeight(const AWinControl: TWinControl): integer; override;
98
class function GetNotebookMinTabWidth(const AWinControl: TWinControl): integer; override;
99
class function GetTabIndexAtPos(const ATabControl: TCustomTabControl; const AClientPos: TPoint): integer; override;
100
class function GetTabRect(const ATabControl: TCustomTabControl; const AIndex: Integer): TRect; override;
101
class procedure SetPageIndex(const ATabControl: TCustomTabControl; const AIndex: integer); override;
102
class procedure SetTabPosition(const ATabControl: TCustomTabControl; const ATabPosition: TTabPosition); override;
103
class procedure ShowTabs(const ATabControl: TCustomTabControl; AShowTabs: boolean); override;
104
class procedure UpdateProperties(const ATabControl: TCustomTabControl); override;
61
107
{ TGtk2WSStatusBar }
68
114
class procedure PanelUpdate(const AStatusBar: TStatusBar; PanelIndex: integer); override;
69
115
class procedure SetPanelText(const AStatusBar: TStatusBar; PanelIndex: integer); override;
70
116
class procedure Update(const AStatusBar: TStatusBar); override;
71
class procedure GetPreferredSize(const AWinControl: TWinControl;
72
var PreferredWidth, PreferredHeight: integer;
73
WithThemeSpace: Boolean); override;
117
class procedure GetPreferredSize(const {%H-}AWinControl: TWinControl;
118
var {%H-}PreferredWidth, PreferredHeight: integer;
119
{%H-}WithThemeSpace: Boolean); override;
75
class procedure SetSizeGrip(const AStatusBar: TStatusBar; SizeGrip: Boolean); override;
121
class procedure SetSizeGrip(const AStatusBar: TStatusBar; {%H-}SizeGrip: Boolean); override;
78
124
{ TGtk2WSTabSheet }
96
142
class procedure AddRemoveCheckboxRenderer(const ALV: TCustomListView; const WidgetInfo: PWidgetInfo; const Add: Boolean);
97
143
class function GetViewModel(const AView: PGtkWidget): PGtkTreeModel;
99
class procedure SetCallbacks(const AScrollWidget: PGtkWidget; const Widgets: PTVWidgets; const AWidgetInfo: PWidgetInfo); virtual;
145
class procedure SetListCallbacks(const AScrollWidget: PGtkWidget; const Widgets: PTVWidgets; const AWidgetInfo: PWidgetInfo);
102
148
class procedure ColumnDelete(const ALV: TCustomListView; const AIndex: Integer); override;
103
class function ColumnGetWidth(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn): Integer; override;
149
class function ColumnGetWidth(const ALV: TCustomListView; const {%H-}AIndex: Integer; const AColumn: TListColumn): Integer; override;
104
150
class procedure ColumnInsert(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn); override;
105
class procedure ColumnMove(const ALV: TCustomListView; const AOldIndex, ANewIndex: Integer; const AColumn: TListColumn); override;
106
class procedure ColumnSetAlignment(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const AAlignment: TAlignment); override;
107
class procedure ColumnSetAutoSize(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const AAutoSize: Boolean); override;
108
class procedure ColumnSetCaption(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const ACaption: String); override;
109
class procedure ColumnSetImage(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const AImageIndex: Integer); override;
110
class procedure ColumnSetMaxWidth(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const AMaxWidth: Integer); override;
111
class procedure ColumnSetMinWidth(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const AMinWidth: integer); override;
112
class procedure ColumnSetWidth(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const AWidth: Integer); override;
113
class procedure ColumnSetVisible(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn; const AVisible: Boolean); override;
151
class procedure ColumnMove(const ALV: TCustomListView; const AOldIndex, ANewIndex: Integer; const {%H-}AColumn: TListColumn); override;
152
class procedure ColumnSetAlignment(const ALV: TCustomListView; const AIndex: Integer; const {%H-}AColumn: TListColumn; const AAlignment: TAlignment); override;
153
class procedure ColumnSetAutoSize(const ALV: TCustomListView; const AIndex: Integer; const {%H-}AColumn: TListColumn; const AAutoSize: Boolean); override;
154
class procedure ColumnSetCaption(const ALV: TCustomListView; const AIndex: Integer; const {%H-}AColumn: TListColumn; const ACaption: String); override;
155
class procedure ColumnSetImage(const ALV: TCustomListView; const {%H-}AIndex: Integer; const {%H-}AColumn: TListColumn; const {%H-}AImageIndex: Integer); override;
156
class procedure ColumnSetMaxWidth(const ALV: TCustomListView; const AIndex: Integer; const {%H-}AColumn: TListColumn; const AMaxWidth: Integer); override;
157
class procedure ColumnSetMinWidth(const ALV: TCustomListView; const AIndex: Integer; const {%H-}AColumn: TListColumn; const AMinWidth: integer); override;
158
class procedure ColumnSetWidth(const ALV: TCustomListView; const AIndex: Integer; const {%H-}AColumn: TListColumn; const AWidth: Integer); override;
159
class procedure ColumnSetVisible(const ALV: TCustomListView; const AIndex: Integer; const {%H-}AColumn: TListColumn; const AVisible: Boolean); override;
116
162
class procedure ItemDelete(const ALV: TCustomListView; const AIndex: Integer); override;
117
class function ItemDisplayRect(const ALV: TCustomListView; const AIndex, ASubItem: Integer; ACode: TDisplayCode): TRect; override;
118
class function ItemGetChecked(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem): Boolean; override;
119
class function ItemGetState(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const AState: TListItemState; out AIsSet: Boolean): Boolean; override; // returns True if supported
120
class procedure ItemInsert(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem); override;
121
class procedure ItemSetChecked(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const AChecked: Boolean); override;
122
class procedure ItemSetImage(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const ASubIndex, AImageIndex: Integer); override;
123
class procedure ItemSetState(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const AState: TListItemState; const AIsSet: Boolean); override;
124
class procedure ItemSetText(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const ASubIndex: Integer; const AText: String); override;
125
class procedure ItemShow(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const PartialOK: Boolean); override;
163
class function ItemDisplayRect(const ALV: TCustomListView; const AIndex, ASubItem: Integer; {%H-}ACode: TDisplayCode): TRect; override;
164
class procedure ItemExchange(const ALV: TCustomListView; {%H-}AItem: TListItem; const AIndex1, AIndex2: Integer); override;
165
class procedure ItemMove(const ALV: TCustomListView; {%H-}AItem: TListItem; const AFromIndex, AToIndex: Integer); override;
166
class function ItemGetChecked(const {%H-}ALV: TCustomListView; const {%H-}AIndex: Integer; const AItem: TListItem): Boolean; override;
167
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
168
class procedure ItemInsert(const ALV: TCustomListView; const AIndex: Integer; const {%H-}AItem: TListItem); override;
169
class procedure ItemSetChecked(const ALV: TCustomListView; const {%H-}AIndex: Integer; const {%H-}AItem: TListItem; const {%H-}AChecked: Boolean); override;
170
class procedure ItemSetImage(const ALV: TCustomListView; const AIndex: Integer; const {%H-}AItem: TListItem; const {%H-}ASubIndex, AImageIndex: Integer); override;
171
class procedure ItemSetState(const ALV: TCustomListView; const AIndex: Integer; const {%H-}AItem: TListItem; const AState: TListItemState; const AIsSet: Boolean); override;
172
class procedure ItemSetText(const ALV: TCustomListView; const AIndex: Integer; const {%H-}AItem: TListItem; const {%H-}ASubIndex: Integer; const {%H-}AText: String); override;
173
class procedure ItemShow(const ALV: TCustomListView; const AIndex: Integer; const {%H-}AItem: TListItem; const {%H-}PartialOK: Boolean); override;
126
174
class function ItemGetPosition(const ALV: TCustomListView; const AIndex: Integer): TPoint; override;
127
class procedure ItemUpdate(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem); override;
175
class procedure ItemUpdate(const ALV: TCustomListView; const {%H-}AIndex: Integer; const {%H-}AItem: TListItem); override;
130
178
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): HWND; override;
144
192
class function GetViewOrigin(const ALV: TCustomListView): TPoint; override;
145
193
class function GetVisibleRowCount(const ALV: TCustomListView): Integer; override;
147
class procedure SetAllocBy(const ALV: TCustomListView; const AValue: Integer); override;
195
class procedure SetAllocBy(const ALV: TCustomListView; const {%H-}AValue: Integer); override;
148
196
class procedure SetColor(const AWinControl: TWinControl); override;
149
class procedure SetDefaultItemHeight(const ALV: TCustomListView; const AValue: Integer); override;
197
class procedure SetDefaultItemHeight(const ALV: TCustomListView; const {%H-}AValue: Integer); override;
150
198
class procedure SetFont(const AWinControl: TWinControl; const AFont: TFont); override;
151
class procedure SetHotTrackStyles(const ALV: TCustomListView; const AValue: TListHotTrackStyles); override;
152
class procedure SetHoverTime(const ALV: TCustomListView; const AValue: Integer); override;
199
class procedure SetHotTrackStyles(const ALV: TCustomListView; const {%H-}AValue: TListHotTrackStyles); override;
200
class procedure SetHoverTime(const ALV: TCustomListView; const {%H-}AValue: Integer); override;
153
201
// class procedure SetIconOptions(const ALV: TCustomListView; const AValue: TIconOptions); override;
154
202
class procedure SetImageList(const ALV: TCustomListView; const AList: TListViewImageList; const AValue: TCustomImageList); override;
155
class procedure SetItemsCount(const ALV: TCustomListView; const Avalue: Integer); override;
203
class procedure SetItemsCount(const ALV: TCustomListView; const {%H-}Avalue: Integer); override;
156
204
class procedure SetProperty(const ALV: TCustomListView; const AProp: TListViewProperty; const AIsSet: Boolean); override;
157
205
class procedure SetProperties(const ALV: TCustomListView; const AProps: TListViewProperties); override;
158
206
class procedure SetScrollBars(const ALV: TCustomListView; const AValue: TScrollStyle); override;
159
class procedure SetSort(const ALV: TCustomListView; const AType: TSortType; const AColumn: Integer); override;
207
class procedure SetSort(const ALV: TCustomListView; const {%H-}AType: TSortType; const {%H-}AColumn: Integer;
208
const {%H-}ASortDirection: TSortDirection); override;
160
209
class procedure SetViewOrigin(const ALV: TCustomListView; const AValue: TPoint); override;
161
210
class procedure SetViewStyle(const ALV: TCustomListView; const AValue: TViewStyle); override;
285
337
gtk_range_set_inverted(PGtkRange(Widget), Reversed);
286
338
gtk_scale_set_digits(PGtkScale(Widget), 0);
288
Result := TLCLIntfHandle(PtrUInt(Widget));
340
Result := TLCLIntfHandle({%H-}PtrUInt(Widget));
289
341
{$IFDEF DebugLCLComponents}
290
342
DebugGtkWidgets.MarkCreated(Widget, dbgsName(AWinControl));
292
WidgetInfo := CreateWidgetInfo(Pointer(Result), AWinControl, AParams);
344
WidgetInfo := CreateWidgetInfo({%H-}Pointer(Result), AWinControl, AParams);
293
345
Set_RC_Name(AWinControl, Widget);
294
346
SetCallbacks(Widget, WidgetInfo);
313
365
with ATrackBar do
315
367
wHandle := Handle;
316
if gtk_range_get_inverted(PGtkRange(wHandle)) <> Reversed then
317
gtk_range_set_inverted(PGtkRange(wHandle), Reversed);
368
if gtk_range_get_inverted({%H-}PGtkRange(wHandle)) <> Reversed then
369
gtk_range_set_inverted({%H-}PGtkRange(wHandle), Reversed);
319
Adjustment := gtk_range_get_adjustment(GTK_RANGE(Pointer(wHandle)));
371
Adjustment := gtk_range_get_adjustment(GTK_RANGE({%H-}Pointer(wHandle)));
320
372
// min >= max causes crash
321
373
Adjustment^.lower := Min;
322
374
if Min < Max then
324
376
Adjustment^.upper := Max;
325
gtk_widget_set_sensitive(PgtkWidget(wHandle), ATrackBar.Enabled);
377
gtk_widget_set_sensitive({%H-}PgtkWidget(wHandle), ATrackBar.Enabled);
329
381
Adjustment^.upper := Min + 1;
330
gtk_widget_set_sensitive(PgtkWidget(wHandle), False);
382
gtk_widget_set_sensitive({%H-}PgtkWidget(wHandle), False);
332
384
Adjustment^.step_increment := LineSize;
333
385
Adjustment^.page_increment := PageSize;
335
387
{ now do some of the more sophisticated features }
336
388
{ Hint: For some unknown reason we have to disable the draw_value first,
337
389
otherwise it's set always to true }
338
gtk_scale_set_draw_value (GTK_SCALE (Pointer(wHandle)), false);
390
gtk_scale_set_draw_value (GTK_SCALE ({%H-}Pointer(wHandle)), false);
340
392
if (TickStyle <> tsNone) then
342
gtk_scale_set_draw_value (GTK_SCALE (Pointer(wHandle)), true);
343
gtk_scale_set_value_pos (GTK_SCALE (Pointer(wHandle)), ValuePositionMap[ScalePos]);
394
gtk_scale_set_draw_value (GTK_SCALE ({%H-}Pointer(wHandle)), true);
395
gtk_scale_set_value_pos (GTK_SCALE ({%H-}Pointer(wHandle)), ValuePositionMap[ScalePos]);
345
397
//Not here (Delphi compatibility): gtk_signal_emit_by_name (GTK_Object (Adjustment), 'value_changed');
398
468
AProgressBar: PGtkProgressBar absolute data;
400
Result := PtrUInt(g_object_get_data(data, 'ProgressStyle')) = 1;
470
Result := {%H-}PtrUInt(g_object_get_data(data, 'ProgressStyle')) = 1;
402
472
gtk_progress_bar_pulse(AProgressBar);
405
475
procedure ProgressDestroy(data: gpointer); cdecl;
407
g_source_remove(PtrUInt(data));
477
g_source_remove({%H-}PtrUInt(data));
410
480
class procedure TGtk2WSProgressBar.InternalSetStyle(
411
481
AProgressBar: PGtkProgressBar; AStyle: TProgressBarStyle);
413
g_object_set_data(PGObject(AProgressBar), 'ProgressStyle', Pointer(PtrUInt(Ord(AStyle))));
483
g_object_set_data(PGObject(AProgressBar), 'ProgressStyle', {%H-}Pointer(PtrUInt(Ord(AStyle))));
414
484
if AStyle = pbstMarquee then
416
486
g_object_set_data_full(PGObject(AProgressBar), 'timeout',
417
Pointer(PtrUInt(g_timeout_add(100, @ProgressPulseTimeout, AProgressBar))), @ProgressDestroy);
487
{%H-}Pointer(PtrUInt(g_timeout_add(100, @ProgressPulseTimeout, AProgressBar))), @ProgressDestroy);
418
488
gtk_progress_bar_pulse(AProgressBar);
519
589
gtk_container_add(PGtkContainer(EventBox), HBox);
520
590
gtk_widget_show(HBox);
521
591
UpdateStatusBarPanels(AWinControl, HBox);
522
Result := TLCLIntfHandle(PtrUInt(EventBox));
592
Result := TLCLIntfHandle({%H-}PtrUInt(EventBox));
523
593
{$IFDEF DebugLCLComponents}
524
594
DebugGtkWidgets.MarkCreated(EventBox, dbgsName(AWinControl));
526
WidgetInfo := CreateWidgetInfo(Pointer(Result), AWinControl, AParams);
596
WidgetInfo := CreateWidgetInfo({%H-}Pointer(Result), AWinControl, AParams);
527
597
Set_RC_Name(AWinControl, EventBox);
528
598
SetCallbacks(EventBox, WidgetInfo);