mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 03:29:28 +02:00
gtk: move CreateComponent code for ToggleBox, RadioButton, Checkbox, PopupMenu, MainMenu to CreateHandle and FinishComponentCreate to SetCallbacks
git-svn-id: trunk@13457 -
This commit is contained in:
parent
760f373489
commit
07cb989050
@ -4731,15 +4731,9 @@ end;
|
|||||||
function TGTKWidgetSet.CreateComponentWidget(Sender: TObject; ACompStyle: Integer; const ACaption: String): PGtkWidget;
|
function TGTKWidgetSet.CreateComponentWidget(Sender: TObject; ACompStyle: Integer; const ACaption: String): PGtkWidget;
|
||||||
var
|
var
|
||||||
p: Pointer absolute Result;
|
p: Pointer absolute Result;
|
||||||
|
|
||||||
TempWidget,
|
TempWidget,
|
||||||
TempWidget2 : PGTKWidget; // pointer to gtk-widget (local use when neccessary)
|
TempWidget2 : PGTKWidget; // pointer to gtk-widget (local use when neccessary)
|
||||||
TempInt : Integer; // local use when neccessary
|
|
||||||
|
|
||||||
Box : Pointer; // currently only used for MainMenu
|
|
||||||
ParentForm: TCustomForm;
|
|
||||||
Adjustment: PGtkAdjustment;
|
Adjustment: PGtkAdjustment;
|
||||||
LabelWidget: PGtkLabel;
|
|
||||||
begin
|
begin
|
||||||
Result := nil;
|
Result := nil;
|
||||||
|
|
||||||
@ -4769,12 +4763,6 @@ begin
|
|||||||
gtk_widget_show_all(p);
|
gtk_widget_show_all(p);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
csCheckbox :
|
|
||||||
begin
|
|
||||||
p := gtk_check_button_new_with_label(PChar(ACaption));
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
csColorDialog :
|
csColorDialog :
|
||||||
begin
|
begin
|
||||||
P := gtk_color_selection_dialog_new(PChar(ACaption));
|
P := gtk_color_selection_dialog_new(PChar(ACaption));
|
||||||
@ -4785,7 +4773,6 @@ begin
|
|||||||
InitializeCommonDialog(TCommonDialog(Sender),p);
|
InitializeCommonDialog(TCommonDialog(Sender),p);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
csFileDialog, csOpenFileDialog, csSaveFileDialog, csSelectDirectoryDialog,
|
csFileDialog, csOpenFileDialog, csSaveFileDialog, csSelectDirectoryDialog,
|
||||||
csPreviewFileDialog:
|
csPreviewFileDialog:
|
||||||
InitializeFileDialog(TFileDialog(Sender),p,PChar(ACaption));
|
InitializeFileDialog(TFileDialog(Sender),p,PChar(ACaption));
|
||||||
@ -4802,32 +4789,6 @@ begin
|
|||||||
p := gtk_image_new();
|
p := gtk_image_new();
|
||||||
end;
|
end;
|
||||||
|
|
||||||
csMainMenu:
|
|
||||||
begin
|
|
||||||
p := gtk_menu_bar_new();
|
|
||||||
// get the VBox, the form has one child, a VBox
|
|
||||||
ParentForm:=TCustomForm(TMenu(Sender).Parent);
|
|
||||||
if (ParentForm=nil) or (not (ParentForm is TCustomForm)) then
|
|
||||||
RaiseGDBException('MainMenu without form');
|
|
||||||
if ParentForm.Menu<>TMenu(Sender) then
|
|
||||||
RaiseGDBException('form has already a MainMenu');
|
|
||||||
if ParentForm.HandleAllocated then begin
|
|
||||||
Box := PGTKBin(ParentForm.Handle)^.Child;
|
|
||||||
gtk_box_pack_start(Box, p, False, False, 0);
|
|
||||||
end;
|
|
||||||
gtk_widget_show(p);
|
|
||||||
end;
|
|
||||||
|
|
||||||
csMenuBar :
|
|
||||||
begin
|
|
||||||
P := gtk_menu_bar_new();
|
|
||||||
gtk_container_add(
|
|
||||||
GTK_Container(
|
|
||||||
GetFixedWidget(Pointer(TWinControl(TMenu(Sender).Owner).Handle))), P);
|
|
||||||
gtk_widget_show(p);
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
csPage: // TCustomPage - Notebook page
|
csPage: // TCustomPage - Notebook page
|
||||||
P:=CreateSimpleClientAreaWidget(Sender, true);
|
P:=CreateSimpleClientAreaWidget(Sender, true);
|
||||||
|
|
||||||
@ -4837,9 +4798,6 @@ begin
|
|||||||
csPairSplitterSide:
|
csPairSplitterSide:
|
||||||
P:=CreateSimpleClientAreaWidget(Sender,true);
|
P:=CreateSimpleClientAreaWidget(Sender,true);
|
||||||
|
|
||||||
csPopupMenu :
|
|
||||||
P := gtk_menu_new();
|
|
||||||
|
|
||||||
csPreviewFileControl:
|
csPreviewFileControl:
|
||||||
P:=CreateSimpleClientAreaWidget(Sender,true);
|
P:=CreateSimpleClientAreaWidget(Sender,true);
|
||||||
|
|
||||||
@ -4852,29 +4810,6 @@ begin
|
|||||||
P := gtk_progress_bar_new_with_adjustment (PGtkAdjustment (TempWidget));
|
P := gtk_progress_bar_new_with_adjustment (PGtkAdjustment (TempWidget));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
csRadioButton :
|
|
||||||
with TRadioButton(Sender) do
|
|
||||||
begin
|
|
||||||
// Look for our parent's control and use the first radio we find for grouping
|
|
||||||
TempWidget:= nil;
|
|
||||||
if (Parent <> nil) then begin
|
|
||||||
for TempInt:= 0 to Parent.ControlCount - 1 do begin
|
|
||||||
if (Parent.Controls[TempInt] is TRadioButton)
|
|
||||||
and TWinControl(Parent.Controls[TempInt]).HandleAllocated then begin
|
|
||||||
TempWidget:= PGtkWidget(TWinControl(Parent.Controls[TempInt]).Handle);
|
|
||||||
Break;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
if TempWidget <> nil then
|
|
||||||
P:= gtk_radio_button_new_with_label(PGtkRadioButton(TempWidget)^.group,'')
|
|
||||||
else
|
|
||||||
P:= gtk_radio_button_new_with_label(nil, '');
|
|
||||||
LabelWidget:=pGtkLabel(gtk_bin_get_child(PGtkBin(@PGTKToggleButton(P)^.Button)));
|
|
||||||
SetLabelCaption(LabelWidget, PChar(ACaption)
|
|
||||||
{$IFDEF Gtk1}, TWinControl(Sender),PGtkWidget(p), 'clicked'{$ENDIF});
|
|
||||||
end;
|
|
||||||
|
|
||||||
csScrollBar :
|
csScrollBar :
|
||||||
begin
|
begin
|
||||||
Adjustment := PgtkAdjustment(
|
Adjustment := PgtkAdjustment(
|
||||||
@ -4904,11 +4839,6 @@ begin
|
|||||||
p:=CreateStatusBar(Sender);
|
p:=CreateStatusBar(Sender);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
csToggleBox :
|
|
||||||
begin
|
|
||||||
P := gtk_toggle_button_new_with_label(PChar(ACaption));
|
|
||||||
end;
|
|
||||||
|
|
||||||
csToolbar:
|
csToolbar:
|
||||||
P:=CreateToolBar(Sender);
|
P:=CreateToolBar(Sender);
|
||||||
|
|
||||||
@ -4980,8 +4910,12 @@ begin
|
|||||||
csForm,
|
csForm,
|
||||||
csEdit,
|
csEdit,
|
||||||
csBitBtn,
|
csBitBtn,
|
||||||
csButton: DebugLn('[WARNING] Obsolete call to TGTKOBject.CreateComponent for ', Sender.ClassName);
|
csButton,
|
||||||
|
csToggleBox,
|
||||||
|
csRadioButton,
|
||||||
|
csPopupMenu,
|
||||||
|
csCheckbox,
|
||||||
|
csMainMenu: DebugLn('[WARNING] Obsolete call to TGTKOBject.CreateComponent for ', Sender.ClassName);
|
||||||
end; //end case
|
end; //end case
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ uses
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
GtkInt, gtkProc, gtkglobals, GTKExtra,
|
GtkInt, gtkProc, gtkglobals, GTKExtra,
|
||||||
Classes, InterfaceBase, Types, LCLProc, LCLType, WSMenus, WSLCLClasses,
|
Classes, InterfaceBase, Types, LCLProc, LCLType, WSMenus, WSLCLClasses,
|
||||||
Graphics, Menus;
|
Graphics, Menus, Forms;
|
||||||
|
|
||||||
type
|
type
|
||||||
{ TGtkWSMenuItem }
|
{ TGtkWSMenuItem }
|
||||||
@ -62,7 +62,7 @@ type
|
|||||||
private
|
private
|
||||||
protected
|
protected
|
||||||
public
|
public
|
||||||
class function CreateHandle(const AMenu: TMenu): HMENU; override;
|
class function CreateHandle(const AMenu: TMenu): HMENU; override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TGtkWSMainMenu }
|
{ TGtkWSMainMenu }
|
||||||
@ -79,6 +79,7 @@ type
|
|||||||
private
|
private
|
||||||
protected
|
protected
|
||||||
public
|
public
|
||||||
|
class function CreateHandle(const AMenu: TMenu): HMENU; override;
|
||||||
class procedure Popup(const APopupMenu: TPopupMenu; const X, Y: integer); override;
|
class procedure Popup(const APopupMenu: TPopupMenu; const X, Y: integer); override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -157,10 +158,7 @@ class function TGtkWSMenuItem.CreateHandle(const AMenuItem: TMenuItem): HMENU;
|
|||||||
var
|
var
|
||||||
MenuItemWidget: PGtkWidget;
|
MenuItemWidget: PGtkWidget;
|
||||||
begin
|
begin
|
||||||
//Result := HMENU(TGtkWidgetSet(WidgetSet).CreateComponent(AMenuItem));
|
MenuItemWidget := CreateMenuItem(AMenuItem);
|
||||||
MenuItemWidget:=CreateMenuItem(AMenuItem);
|
|
||||||
//Set_RC_Name(AMenuItem,MenuItemWidget);
|
|
||||||
|
|
||||||
{$IFDEF DebugLCLComponents}
|
{$IFDEF DebugLCLComponents}
|
||||||
DebugGtkWidgets.MarkCreated(MenuItemWidget,dbgsName(AMenuItem));
|
DebugGtkWidgets.MarkCreated(MenuItemWidget,dbgsName(AMenuItem));
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
@ -268,13 +266,34 @@ end;
|
|||||||
{ TGtkWSMenu }
|
{ TGtkWSMenu }
|
||||||
|
|
||||||
class function TGtkWSMenu.CreateHandle(const AMenu: TMenu): HMENU;
|
class function TGtkWSMenu.CreateHandle(const AMenu: TMenu): HMENU;
|
||||||
|
var
|
||||||
|
Widget: PGtkWidget;
|
||||||
|
Box: Pointer;
|
||||||
|
ParentForm: TCustomForm;
|
||||||
begin
|
begin
|
||||||
{ TODO: cleanup }
|
Widget := gtk_menu_bar_new();
|
||||||
Result := HMENU(TGtkWidgetSet(WidgetSet).CreateComponent(AMenu));
|
// get the VBox, the form has one child, a VBox
|
||||||
|
ParentForm := TCustomForm(AMenu.Parent);
|
||||||
|
if (ParentForm=nil) or (not (ParentForm is TCustomForm)) then
|
||||||
|
RaiseGDBException('MainMenu without form');
|
||||||
|
if ParentForm.Menu <> AMenu then
|
||||||
|
RaiseGDBException('Form already has a MainMenu');
|
||||||
|
if ParentForm.HandleAllocated then
|
||||||
|
begin
|
||||||
|
Box := PGTKBin(ParentForm.Handle)^.Child;
|
||||||
|
gtk_box_pack_start(Box, Widget, False, False, 0);
|
||||||
|
end;
|
||||||
|
gtk_widget_show(Widget);
|
||||||
|
|
||||||
|
{$IFDEF DebugLCLComponents}
|
||||||
|
DebugGtkWidgets.MarkCreated(Widget, dbgsName(AMenu));
|
||||||
|
{$ENDIF}
|
||||||
|
Result := THandle(PtrUInt(Widget));
|
||||||
|
// no callbacks for main menu
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TGtkWSPopupMenu }
|
{ TGtkWSPopupMenu }
|
||||||
procedure GtkWS_Popup(menu: PGtkMenu; X, Y: pgint;
|
procedure GtkWS_Popup(menu: PGtkMenu; X, Y: pgint;
|
||||||
{$IFDEF GTK2} ForceInScreen: pgboolean; {$ENDIF}
|
{$IFDEF GTK2} ForceInScreen: pgboolean; {$ENDIF}
|
||||||
Point: PPoint); cdecl;
|
Point: PPoint); cdecl;
|
||||||
begin
|
begin
|
||||||
@ -282,6 +301,18 @@ begin
|
|||||||
Y^ := Point^.Y;
|
Y^ := Point^.Y;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
class function TGtkWSPopupMenu.CreateHandle(const AMenu: TMenu): HMENU;
|
||||||
|
var
|
||||||
|
Widget: PGtkWidget;
|
||||||
|
begin
|
||||||
|
Widget := gtk_menu_new;
|
||||||
|
Result := HMENU(PtrUInt(Widget));
|
||||||
|
{$IFDEF DebugLCLComponents}
|
||||||
|
DebugGtkWidgets.MarkCreated(Widget, dbgsName(Sender));
|
||||||
|
{$ENDIF}
|
||||||
|
// no callbacks for popup menu
|
||||||
|
end;
|
||||||
|
|
||||||
class procedure TGtkWSPopupMenu.Popup(const APopupMenu: TPopupMenu;
|
class procedure TGtkWSPopupMenu.Popup(const APopupMenu: TPopupMenu;
|
||||||
const X, Y: integer);
|
const X, Y: integer);
|
||||||
var
|
var
|
||||||
@ -296,7 +327,7 @@ begin
|
|||||||
AProc := nil
|
AProc := nil
|
||||||
else
|
else
|
||||||
AProc := @GtkWS_Popup;
|
AProc := @GtkWS_Popup;
|
||||||
gtk_menu_popup(PgtkMenu(APopupMenu.Handle),
|
gtk_menu_popup(PGtkMenu(APopupMenu.Handle),
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
TGtkMenuPositionFunc(AProc),
|
TGtkMenuPositionFunc(AProc),
|
||||||
|
@ -58,7 +58,6 @@ type
|
|||||||
class procedure SetCallbacks(const AGtkWidget: PGtkWidget; const AWidgetInfo: PWidgetInfo); virtual;
|
class procedure SetCallbacks(const AGtkWidget: PGtkWidget; const AWidgetInfo: PWidgetInfo); virtual;
|
||||||
public
|
public
|
||||||
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
|
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
|
||||||
// class procedure DestroyHandle(const AWinControl: TWinControl); override;
|
|
||||||
class procedure GetPreferredSize(const AWinControl: TWinControl;
|
class procedure GetPreferredSize(const AWinControl: TWinControl;
|
||||||
var PreferredWidth, PreferredHeight: integer;
|
var PreferredWidth, PreferredHeight: integer;
|
||||||
WithThemeSpace: Boolean); override;
|
WithThemeSpace: Boolean); override;
|
||||||
@ -148,11 +147,9 @@ type
|
|||||||
TGtkWSCustomEdit = class(TWSCustomEdit)
|
TGtkWSCustomEdit = class(TWSCustomEdit)
|
||||||
private
|
private
|
||||||
protected
|
protected
|
||||||
|
class procedure SetCallbacks(const AGtkWidget: PGtkWidget; const AWidgetInfo: PWidgetInfo); virtual;
|
||||||
public
|
public
|
||||||
{$IFDEF GTK1}
|
|
||||||
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
|
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
|
||||||
// class procedure DestroyHandle(const AWinControl: TWinControl); override;
|
|
||||||
{$ENDIF}
|
|
||||||
class function GetSelStart(const ACustomEdit: TCustomEdit): integer; override;
|
class function GetSelStart(const ACustomEdit: TCustomEdit): integer; override;
|
||||||
class function GetSelLength(const ACustomEdit: TCustomEdit): integer; override;
|
class function GetSelLength(const ACustomEdit: TCustomEdit): integer; override;
|
||||||
|
|
||||||
@ -282,7 +279,9 @@ type
|
|||||||
TGtkWSCustomCheckBox = class(TWSCustomCheckBox)
|
TGtkWSCustomCheckBox = class(TWSCustomCheckBox)
|
||||||
private
|
private
|
||||||
protected
|
protected
|
||||||
|
class procedure SetCallbacks(const AGtkWidget: PGtkWidget; const AWidgetInfo: PWidgetInfo); virtual;
|
||||||
public
|
public
|
||||||
|
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
|
||||||
class function RetrieveState(const ACustomCheckBox: TCustomCheckBox
|
class function RetrieveState(const ACustomCheckBox: TCustomCheckBox
|
||||||
): TCheckBoxState; override;
|
): TCheckBoxState; override;
|
||||||
class procedure SetShortCut(const ACustomCheckBox: TCustomCheckBox;
|
class procedure SetShortCut(const ACustomCheckBox: TCustomCheckBox;
|
||||||
@ -310,6 +309,7 @@ type
|
|||||||
private
|
private
|
||||||
protected
|
protected
|
||||||
public
|
public
|
||||||
|
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TGtkWSRadioButton }
|
{ TGtkWSRadioButton }
|
||||||
@ -318,6 +318,7 @@ type
|
|||||||
private
|
private
|
||||||
protected
|
protected
|
||||||
public
|
public
|
||||||
|
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function WidgetGetSelStart(const Widget: PGtkWidget): integer;
|
function WidgetGetSelStart(const Widget: PGtkWidget): integer;
|
||||||
@ -934,21 +935,39 @@ end;
|
|||||||
|
|
||||||
{ TGtkWSCustomEdit }
|
{ TGtkWSCustomEdit }
|
||||||
|
|
||||||
{$IFDEF GTK1}
|
class procedure TGtkWSCustomEdit.SetCallbacks(const AGtkWidget: PGtkWidget;
|
||||||
|
const AWidgetInfo: PWidgetInfo);
|
||||||
|
begin
|
||||||
|
TGtkWSWinControl.SetCallbacks(PGtkObject(AGtkWidget), TComponent(AWidgetInfo^.LCLObject));
|
||||||
|
|
||||||
|
with TGtkWidgetset(Widgetset) do
|
||||||
|
begin
|
||||||
|
SetCallback(LM_CHANGED, PGtkObject(AGtkWidget), AWidgetInfo^.LCLObject);
|
||||||
|
SetCallback(LM_ACTIVATE, PGtkObject(AGtkWidget), AWidgetInfo^.LCLObject);
|
||||||
|
SetCallback(LM_CUTTOCLIP, PGtkObject(AGtkWidget), AWidgetInfo^.LCLObject);
|
||||||
|
SetCallback(LM_COPYTOCLIP, PGtkObject(AGtkWidget), AWidgetInfo^.LCLObject);
|
||||||
|
SetCallback(LM_PASTEFROMCLIP, PGtkObject(AGtkWidget), AWidgetInfo^.LCLObject);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
class function TGtkWSCustomEdit.CreateHandle(const AWinControl: TWinControl;
|
class function TGtkWSCustomEdit.CreateHandle(const AWinControl: TWinControl;
|
||||||
const AParams: TCreateParams): TLCLIntfHandle;
|
const AParams: TCreateParams): TLCLIntfHandle;
|
||||||
var
|
var
|
||||||
p: pointer; // ptr to the newly created GtkWidget
|
Widget: PGtkWidget; // ptr to the newly created GtkWidget
|
||||||
|
WidgetInfo: PWidgetInfo;
|
||||||
begin
|
begin
|
||||||
p := gtk_entry_new();
|
Widget := gtk_entry_new();
|
||||||
|
gtk_editable_set_editable(PGtkEditable(Widget), not TCustomEdit(AWinControl).ReadOnly);
|
||||||
GtkWidgetSet.FinishComponentCreate(AWinControl, P);
|
gtk_widget_show_all(Widget);
|
||||||
|
Result := TLCLIntfHandle(PtrUInt(Widget));
|
||||||
{$IFDEF DebugLCLComponents}
|
{$IFDEF DebugLCLComponents}
|
||||||
DebugGtkWidgets.MarkCreated(P,dbgsName(AWinControl));
|
DebugGtkWidgets.MarkCreated(Widget, dbgsName(AWinControl));
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
Result := TLCLIntfHandle(PtrUInt(P));
|
if Result = 0 then
|
||||||
|
Exit;
|
||||||
|
WidgetInfo := CreateWidgetInfo(Pointer(Result), AWinControl, AParams);
|
||||||
|
SetCallbacks(Widget, WidgetInfo);
|
||||||
end;
|
end;
|
||||||
{$ENDIF}
|
|
||||||
|
|
||||||
class function TGtkWSCustomEdit.GetSelStart(const ACustomEdit: TCustomEdit): integer;
|
class function TGtkWSCustomEdit.GetSelStart(const ACustomEdit: TCustomEdit): integer;
|
||||||
begin
|
begin
|
||||||
@ -1375,6 +1394,36 @@ end;
|
|||||||
|
|
||||||
{ TGtkWSCustomCheckBox }
|
{ TGtkWSCustomCheckBox }
|
||||||
|
|
||||||
|
class procedure TGtkWSCustomCheckBox.SetCallbacks(const AGtkWidget: PGtkWidget; const AWidgetInfo: PWidgetInfo);
|
||||||
|
begin
|
||||||
|
TGtkWSWinControl.SetCallbacks(PGtkObject(AGtkWidget), TComponent(AWidgetInfo^.LCLObject));
|
||||||
|
TGtkWidgetset(WidgetSet).SetCallback(LM_CHANGED, PGtkObject(AGtkWidget), AWidgetInfo^.LCLObject);
|
||||||
|
end;
|
||||||
|
|
||||||
|
class function TGtkWSCustomCheckBox.CreateHandle(
|
||||||
|
const AWinControl: TWinControl; const AParams: TCreateParams
|
||||||
|
): TLCLIntfHandle;
|
||||||
|
var
|
||||||
|
Widget: PGtkWidget;
|
||||||
|
WidgetInfo: PWidgetInfo;
|
||||||
|
Allocation: TGTKAllocation;
|
||||||
|
begin
|
||||||
|
Widget := gtk_check_button_new_with_label(AParams.Caption);
|
||||||
|
{$IFDEF DebugLCLComponents}
|
||||||
|
DebugGtkWidgets.MarkCreated(Widget, dbgsName(AWinControl));
|
||||||
|
{$ENDIF}
|
||||||
|
Result := THandle(PtrUInt(Widget));
|
||||||
|
WidgetInfo := CreateWidgetInfo(Pointer(Result), AWinControl, AParams);
|
||||||
|
|
||||||
|
Allocation.X := AParams.X;
|
||||||
|
Allocation.Y := AParams.Y;
|
||||||
|
Allocation.Width := AParams.Width;
|
||||||
|
Allocation.Height := AParams.Height;
|
||||||
|
gtk_widget_size_allocate(PGtkWidget(Result), @Allocation);
|
||||||
|
|
||||||
|
SetCallbacks(PGtkWidget(Result), WidgetInfo);
|
||||||
|
end;
|
||||||
|
|
||||||
class function TGtkWSCustomCheckBox.RetrieveState(
|
class function TGtkWSCustomCheckBox.RetrieveState(
|
||||||
const ACustomCheckBox: TCustomCheckBox): TCheckBoxState;
|
const ACustomCheckBox: TCustomCheckBox): TCheckBoxState;
|
||||||
var
|
var
|
||||||
@ -1721,6 +1770,84 @@ begin
|
|||||||
//debugln('TGtkWSCustomGroupBox.GetPreferredSize ',DbgSName(AWinControl),' PreferredWidth=',dbgs(PreferredWidth),' PreferredHeight=',dbgs(PreferredHeight));
|
//debugln('TGtkWSCustomGroupBox.GetPreferredSize ',DbgSName(AWinControl),' PreferredWidth=',dbgs(PreferredWidth),' PreferredHeight=',dbgs(PreferredHeight));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ TGtkWSRadioButton }
|
||||||
|
|
||||||
|
class function TGtkWSRadioButton.CreateHandle(const AWinControl: TWinControl;
|
||||||
|
const AParams: TCreateParams): TLCLIntfHandle;
|
||||||
|
var
|
||||||
|
Widget, TempWidget: PGtkWidget;
|
||||||
|
LabelWidget: PGtkLabel;
|
||||||
|
TempInt: Integer;
|
||||||
|
WidgetInfo: PWidgetInfo;
|
||||||
|
Allocation: TGTKAllocation;
|
||||||
|
begin
|
||||||
|
with TRadioButton(AWinControl) do
|
||||||
|
begin
|
||||||
|
// Look for our parent's control and use the first radio we find for grouping
|
||||||
|
TempWidget := nil;
|
||||||
|
if (Parent <> nil) then
|
||||||
|
begin
|
||||||
|
for TempInt := 0 to Parent.ControlCount - 1 do
|
||||||
|
begin
|
||||||
|
if (Parent.Controls[TempInt] is TRadioButton) and
|
||||||
|
TWinControl(Parent.Controls[TempInt]).HandleAllocated then
|
||||||
|
begin
|
||||||
|
TempWidget := PGtkWidget(TWinControl(Parent.Controls[TempInt]).Handle);
|
||||||
|
Break;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
if TempWidget <> nil then
|
||||||
|
Widget := gtk_radio_button_new_with_label(PGtkRadioButton(TempWidget)^.group,'')
|
||||||
|
else
|
||||||
|
Widget := gtk_radio_button_new_with_label(nil, '');
|
||||||
|
|
||||||
|
LabelWidget := PGtkLabel(gtk_bin_get_child(PGtkBin(@PGTKToggleButton(Widget)^.Button)));
|
||||||
|
GtkWidgetSet.SetLabelCaption(LabelWidget, AParams.Caption
|
||||||
|
{$IFDEF Gtk1}, AWinControl, Widget, 'clicked'{$ENDIF});
|
||||||
|
end;
|
||||||
|
|
||||||
|
{$IFDEF DebugLCLComponents}
|
||||||
|
DebugGtkWidgets.MarkCreated(Widget, dbgsName(AWinControl));
|
||||||
|
{$ENDIF}
|
||||||
|
Result := THandle(PtrUInt(Widget));
|
||||||
|
WidgetInfo := CreateWidgetInfo(Pointer(Result), AWinControl, AParams);
|
||||||
|
|
||||||
|
Allocation.X := AParams.X;
|
||||||
|
Allocation.Y := AParams.Y;
|
||||||
|
Allocation.Width := AParams.Width;
|
||||||
|
Allocation.Height := AParams.Height;
|
||||||
|
gtk_widget_size_allocate(PGtkWidget(Result), @Allocation);
|
||||||
|
|
||||||
|
TGtkWSCustomCheckBox.SetCallbacks(PGtkWidget(Result), WidgetInfo);
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ TGtkWSToggleBox }
|
||||||
|
|
||||||
|
class function TGtkWSToggleBox.CreateHandle(const AWinControl: TWinControl;
|
||||||
|
const AParams: TCreateParams): TLCLIntfHandle;
|
||||||
|
var
|
||||||
|
Widget: PGtkWidget;
|
||||||
|
WidgetInfo: PWidgetInfo;
|
||||||
|
Allocation: TGTKAllocation;
|
||||||
|
begin
|
||||||
|
Widget := gtk_toggle_button_new_with_label(AParams.Caption);
|
||||||
|
{$IFDEF DebugLCLComponents}
|
||||||
|
DebugGtkWidgets.MarkCreated(Widget, dbgsName(AWinControl));
|
||||||
|
{$ENDIF}
|
||||||
|
Result := THandle(PtrUInt(Widget));
|
||||||
|
WidgetInfo := CreateWidgetInfo(Pointer(Result), AWinControl, AParams);
|
||||||
|
|
||||||
|
Allocation.X := AParams.X;
|
||||||
|
Allocation.Y := AParams.Y;
|
||||||
|
Allocation.Width := AParams.Width;
|
||||||
|
Allocation.Height := AParams.Height;
|
||||||
|
gtk_widget_size_allocate(PGtkWidget(Result), @Allocation);
|
||||||
|
|
||||||
|
TGtkWSCustomCheckBox.SetCallbacks(PGtkWidget(Result), WidgetInfo);
|
||||||
|
end;
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
|
|
||||||
////////////////////////////////////////////////////
|
////////////////////////////////////////////////////
|
||||||
@ -1746,8 +1873,8 @@ initialization
|
|||||||
{$endif}
|
{$endif}
|
||||||
RegisterWSComponent(TCustomCheckBox, TGtkWSCustomCheckBox);
|
RegisterWSComponent(TCustomCheckBox, TGtkWSCustomCheckBox);
|
||||||
// RegisterWSComponent(TCheckBox, TGtkWSCheckBox);
|
// RegisterWSComponent(TCheckBox, TGtkWSCheckBox);
|
||||||
// RegisterWSComponent(TToggleBox, TGtkWSToggleBox);
|
RegisterWSComponent(TToggleBox, TGtkWSToggleBox);
|
||||||
// RegisterWSComponent(TRadioButton, TGtkWSRadioButton);
|
RegisterWSComponent(TRadioButton, TGtkWSRadioButton);
|
||||||
RegisterWSComponent(TCustomStaticText, TGtkWSCustomStaticText);
|
RegisterWSComponent(TCustomStaticText, TGtkWSCustomStaticText);
|
||||||
// RegisterWSComponent(TStaticText, TGtkWSStaticText);
|
// RegisterWSComponent(TStaticText, TGtkWSStaticText);
|
||||||
////////////////////////////////////////////////////
|
////////////////////////////////////////////////////
|
||||||
|
@ -179,9 +179,8 @@ type
|
|||||||
private
|
private
|
||||||
protected
|
protected
|
||||||
public
|
public
|
||||||
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
|
class function GetSelStart(const ACustomEdit: TCustomEdit): integer; override;
|
||||||
class function GetSelStart(const ACustomEdit: TCustomEdit): integer; override;
|
class function GetSelLength(const ACustomEdit: TCustomEdit): integer; override;
|
||||||
class function GetSelLength(const ACustomEdit: TCustomEdit): integer; override;
|
|
||||||
class procedure SetEchoMode(const ACustomEdit: TCustomEdit; NewMode: TEchoMode); override;
|
class procedure SetEchoMode(const ACustomEdit: TCustomEdit; NewMode: TEchoMode); override;
|
||||||
class procedure SetPasswordChar(const ACustomEdit: TCustomEdit; NewChar: char); override;
|
class procedure SetPasswordChar(const ACustomEdit: TCustomEdit; NewChar: char); override;
|
||||||
class procedure SetSelStart(const ACustomEdit: TCustomEdit; NewStart: integer); override;
|
class procedure SetSelStart(const ACustomEdit: TCustomEdit; NewStart: integer); override;
|
||||||
@ -723,22 +722,6 @@ end;
|
|||||||
|
|
||||||
{ TGtk2WSCustomEdit }
|
{ TGtk2WSCustomEdit }
|
||||||
|
|
||||||
class function TGtk2WSCustomEdit.CreateHandle(const AWinControl: TWinControl;
|
|
||||||
const AParams: TCreateParams): TLCLIntfHandle;
|
|
||||||
var
|
|
||||||
p: PGtkWidget; // ptr to the newly created GtkWidget
|
|
||||||
begin
|
|
||||||
p := gtk_entry_new();
|
|
||||||
gtk_editable_set_editable (PGtkEditable(P), not TCustomEdit(AWinControl).ReadOnly);
|
|
||||||
gtk_widget_show_all(P);
|
|
||||||
Result := TLCLIntfHandle(PtrUInt(P));
|
|
||||||
{$IFDEF DebugLCLComponents}
|
|
||||||
DebugGtkWidgets.MarkCreated(p,dbgsName(AWinControl));
|
|
||||||
{$ENDIF}
|
|
||||||
gtk2WidgetSet.FinishComponentCreate(AWinControl, P);
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
class function TGtk2WSCustomEdit.GetSelStart(const ACustomEdit: TCustomEdit
|
class function TGtk2WSCustomEdit.GetSelStart(const ACustomEdit: TCustomEdit
|
||||||
): integer;
|
): integer;
|
||||||
var
|
var
|
||||||
|
Loading…
Reference in New Issue
Block a user