mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-15 21:39:12 +02:00
- added WsWinControl.CanFocus that inform about ability of control to be focused with default widgetset value = True (overrided for gtk)
- changed CanTab of TWinControl to use TWSWinControlClass.CanFocus - published TRadioGroup.TabStop git-svn-id: trunk@10829 -
This commit is contained in:
parent
c44f23e18d
commit
78187ac487
@ -751,6 +751,7 @@ type
|
|||||||
property PopupMenu;
|
property PopupMenu;
|
||||||
property ShowHint;
|
property ShowHint;
|
||||||
property TabOrder;
|
property TabOrder;
|
||||||
|
property TabStop;
|
||||||
property Visible;
|
property Visible;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -26,9 +26,4 @@ begin
|
|||||||
Height:= 105;
|
Height:= 105;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCustomGroupBox.CanTab: boolean;
|
|
||||||
begin
|
|
||||||
Result:=false;
|
|
||||||
end;
|
|
||||||
|
|
||||||
// included by stdctrls.pp
|
// included by stdctrls.pp
|
||||||
|
@ -2184,7 +2184,7 @@ end;
|
|||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
Function TWinControl.CanTab: Boolean;
|
Function TWinControl.CanTab: Boolean;
|
||||||
begin
|
begin
|
||||||
Result := CanFocus;
|
Result := CanFocus and TWSWinControlClass(WidgetSetClass).CanFocus(Self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TWinControl.DoDragMsg(var DragMsg: TCMDrag);
|
procedure TWinControl.DoDragMsg(var DragMsg: TCMDrag);
|
||||||
|
@ -8690,7 +8690,93 @@ begin
|
|||||||
end;
|
end;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
|
function FindFocusWidget(AWidget: PGtkWidget): PGtkWidget;
|
||||||
|
var
|
||||||
|
WinWidgetInfo: PWinWidgetInfo;
|
||||||
|
ImplWidget: PGtkWidget;
|
||||||
|
GList: PGlist;
|
||||||
|
LastFocusWidget: PGtkWidget;
|
||||||
|
begin
|
||||||
|
// Default to the widget, try to find other
|
||||||
|
Result := AWidget;
|
||||||
|
|
||||||
|
// Combo
|
||||||
|
if GtkWidgetIsA(AWidget, gtk_combo_get_type)
|
||||||
|
then begin
|
||||||
|
// handle is a gtk combo
|
||||||
|
{$IfDef VerboseFocus}
|
||||||
|
DebugLn(' D taking gtkcombo entry');
|
||||||
|
{$EndIf}
|
||||||
|
Result := PgtkWidget(PGtkCombo(AWidget)^.entry);
|
||||||
|
Exit;
|
||||||
|
end;
|
||||||
|
|
||||||
|
// check if widget has a WinWidgetInfo record
|
||||||
|
WinWidgetInfo := GetWidgetInfo(AWidget, false);
|
||||||
|
if WinWidgetInfo = nil then Exit;
|
||||||
|
|
||||||
|
ImplWidget:= WinWidgetInfo^.CoreWidget;
|
||||||
|
if ImplWidget = nil then Exit;
|
||||||
|
// set default to the implementation widget
|
||||||
|
Result := ImplWidget;
|
||||||
|
|
||||||
|
// handle has an ImplementationWidget
|
||||||
|
if GtkWidgetIsA(ImplWidget, gtk_list_get_type)
|
||||||
|
then begin
|
||||||
|
{$IfDef VerboseFocus}
|
||||||
|
DebugLn(' E using list');
|
||||||
|
{$EndIf}
|
||||||
|
// Try the last added selected
|
||||||
|
if not (selection_mode(PGtkList(ImplWidget)^) in [GTK_SELECTION_SINGLE, GTK_SELECTION_BROWSE])
|
||||||
|
and (PGtkList(ImplWidget)^.last_focus_child <> nil)
|
||||||
|
then begin
|
||||||
|
LastFocusWidget:=PGtkList(ImplWidget)^.last_focus_child;
|
||||||
|
if g_list_find(PGtkList(ImplWidget)^.selection,LastFocusWidget)<>nil
|
||||||
|
then begin
|
||||||
|
Result := PGtkList(ImplWidget)^.last_focus_child;
|
||||||
|
{$IfDef VerboseFocus}
|
||||||
|
DebugLn(' E.1 using last_focus_child');
|
||||||
|
{$EndIf}
|
||||||
|
Exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
// If there is a selection, try the first
|
||||||
|
GList := PGtkList(ImplWidget)^.selection;
|
||||||
|
if (GList <> nil) and (GList^.data <> nil)
|
||||||
|
then begin
|
||||||
|
Result := GList^.data;
|
||||||
|
{$IfDef VerboseFocus}
|
||||||
|
DebugLn(' E.2 using 1st selection');
|
||||||
|
{$EndIf}
|
||||||
|
Exit;
|
||||||
|
end;
|
||||||
|
|
||||||
|
// If not in browse mode, set focus to the first child
|
||||||
|
// in browsemode, the focused item cannot be selected by mouse
|
||||||
|
// if selection_mode(PGtkList(ImplWidget)^) = GTK_SELECTION_BROWSE
|
||||||
|
// then begin
|
||||||
|
// {$IfDef VerboseFocus}
|
||||||
|
// DebugLn(' E.3 Browse mode -> using ImplWidget');
|
||||||
|
// {$EndIf}
|
||||||
|
// Exit;
|
||||||
|
// end;
|
||||||
|
|
||||||
|
GList := PGtkList(ImplWidget)^.children;
|
||||||
|
if GList = nil then Exit;
|
||||||
|
if GList^.Data = nil then Exit;
|
||||||
|
Result := GList^.Data;
|
||||||
|
{$IfDef VerboseFocus}
|
||||||
|
DebugLn(' E.4 using 1st child');
|
||||||
|
{$EndIf}
|
||||||
|
|
||||||
|
Exit;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{$IfDef VerboseFocus}
|
||||||
|
DebugLn(' E taking ImplementationWidget');
|
||||||
|
{$EndIf}
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
{$IFDEF ASSERT_IS_ON}
|
{$IFDEF ASSERT_IS_ON}
|
||||||
|
@ -789,6 +789,7 @@ function GetGtkContainerBorderWidth(Widget: PGtkContainer): gint;
|
|||||||
// X functions
|
// X functions
|
||||||
function FormToX11Window(const AForm: TCustomForm): X.TWindow;
|
function FormToX11Window(const AForm: TCustomForm): X.TWindow;
|
||||||
{$endif}
|
{$endif}
|
||||||
|
function FindFocusWidget(AWidget: PGtkWidget): PGtkWidget;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
@ -8703,96 +8703,6 @@ end;
|
|||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
function TGtkWidgetSet.SetFocus(hWnd: HWND): HWND;
|
function TGtkWidgetSet.SetFocus(hWnd: HWND): HWND;
|
||||||
{off $DEFINE VerboseFocus}
|
{off $DEFINE VerboseFocus}
|
||||||
|
|
||||||
|
|
||||||
function FindFocusWidget(AWidget: PGtkWidget): PGtkWidget;
|
|
||||||
var
|
|
||||||
WinWidgetInfo: PWinWidgetInfo;
|
|
||||||
ImplWidget: PGtkWidget;
|
|
||||||
GList: PGlist;
|
|
||||||
LastFocusWidget: PGtkWidget;
|
|
||||||
begin
|
|
||||||
// Default to the widget, try to find other
|
|
||||||
Result := AWidget;
|
|
||||||
|
|
||||||
// Combo
|
|
||||||
if GtkWidgetIsA(AWidget, gtk_combo_get_type)
|
|
||||||
then begin
|
|
||||||
// handle is a gtk combo
|
|
||||||
{$IfDef VerboseFocus}
|
|
||||||
DebugLn(' D taking gtkcombo entry');
|
|
||||||
{$EndIf}
|
|
||||||
Result := PgtkWidget(PGtkCombo(AWidget)^.entry);
|
|
||||||
Exit;
|
|
||||||
end;
|
|
||||||
|
|
||||||
// check if widget has a WinWidgetInfo record
|
|
||||||
WinWidgetInfo := GetWidgetInfo(AWidget, false);
|
|
||||||
if WinWidgetInfo = nil then Exit;
|
|
||||||
|
|
||||||
ImplWidget:= WinWidgetInfo^.CoreWidget;
|
|
||||||
if ImplWidget = nil then Exit;
|
|
||||||
// set default to the implementation widget
|
|
||||||
Result := ImplWidget;
|
|
||||||
|
|
||||||
// handle has an ImplementationWidget
|
|
||||||
if GtkWidgetIsA(ImplWidget, gtk_list_get_type)
|
|
||||||
then begin
|
|
||||||
{$IfDef VerboseFocus}
|
|
||||||
DebugLn(' E using list');
|
|
||||||
{$EndIf}
|
|
||||||
// Try the last added selected
|
|
||||||
if not (selection_mode(PGtkList(ImplWidget)^) in [GTK_SELECTION_SINGLE, GTK_SELECTION_BROWSE])
|
|
||||||
and (PGtkList(ImplWidget)^.last_focus_child <> nil)
|
|
||||||
then begin
|
|
||||||
LastFocusWidget:=PGtkList(ImplWidget)^.last_focus_child;
|
|
||||||
if g_list_find(PGtkList(ImplWidget)^.selection,LastFocusWidget)<>nil
|
|
||||||
then begin
|
|
||||||
Result := PGtkList(ImplWidget)^.last_focus_child;
|
|
||||||
{$IfDef VerboseFocus}
|
|
||||||
DebugLn(' E.1 using last_focus_child');
|
|
||||||
{$EndIf}
|
|
||||||
Exit;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
// If there is a selection, try the first
|
|
||||||
GList := PGtkList(ImplWidget)^.selection;
|
|
||||||
if (GList <> nil) and (GList^.data <> nil)
|
|
||||||
then begin
|
|
||||||
Result := GList^.data;
|
|
||||||
{$IfDef VerboseFocus}
|
|
||||||
DebugLn(' E.2 using 1st selection');
|
|
||||||
{$EndIf}
|
|
||||||
Exit;
|
|
||||||
end;
|
|
||||||
|
|
||||||
// If not in browse mode, set focus to the first child
|
|
||||||
// in browsemode, the focused item cannot be selected by mouse
|
|
||||||
// if selection_mode(PGtkList(ImplWidget)^) = GTK_SELECTION_BROWSE
|
|
||||||
// then begin
|
|
||||||
// {$IfDef VerboseFocus}
|
|
||||||
// DebugLn(' E.3 Browse mode -> using ImplWidget');
|
|
||||||
// {$EndIf}
|
|
||||||
// Exit;
|
|
||||||
// end;
|
|
||||||
|
|
||||||
GList := PGtkList(ImplWidget)^.children;
|
|
||||||
if GList = nil then Exit;
|
|
||||||
if GList^.Data = nil then Exit;
|
|
||||||
Result := GList^.Data;
|
|
||||||
{$IfDef VerboseFocus}
|
|
||||||
DebugLn(' E.4 using 1st child');
|
|
||||||
{$EndIf}
|
|
||||||
|
|
||||||
Exit;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{$IfDef VerboseFocus}
|
|
||||||
DebugLn(' E taking ImplementationWidget');
|
|
||||||
{$EndIf}
|
|
||||||
end;
|
|
||||||
|
|
||||||
var
|
var
|
||||||
Widget, TopLevel, NewFocusWidget: PGtkWidget;
|
Widget, TopLevel, NewFocusWidget: PGtkWidget;
|
||||||
{$IfDef VerboseFocus}
|
{$IfDef VerboseFocus}
|
||||||
|
@ -72,13 +72,13 @@ type
|
|||||||
class procedure SetCallbacks(const AGTKObject: PGTKObject; const AComponent: TComponent);
|
class procedure SetCallbacks(const AGTKObject: PGTKObject; const AComponent: TComponent);
|
||||||
public
|
public
|
||||||
class procedure AddControl(const AControl: TControl); override;
|
class procedure AddControl(const AControl: TControl); override;
|
||||||
|
class function CanFocus(const AWinControl: TWinControl): Boolean; override;
|
||||||
class function GetText(const AWinControl: TWinControl; var AText: String): Boolean; override;
|
|
||||||
|
|
||||||
class procedure ConstraintsChange(const AWinControl: TWinControl); override;
|
class procedure ConstraintsChange(const AWinControl: TWinControl); override;
|
||||||
class procedure DestroyHandle(const AWinControl: TWinControl); override;
|
class procedure DestroyHandle(const AWinControl: TWinControl); override;
|
||||||
class procedure Invalidate(const AWinControl: TWinControl); override;
|
class procedure Invalidate(const AWinControl: TWinControl); override;
|
||||||
|
|
||||||
|
class function GetText(const AWinControl: TWinControl; var AText: String): Boolean; override;
|
||||||
|
|
||||||
class procedure SetBorderStyle(const AWinControl: TWinControl; const ABorderStyle: TBorderStyle); override;
|
class procedure SetBorderStyle(const AWinControl: TWinControl; const ABorderStyle: TBorderStyle); override;
|
||||||
class procedure SetBounds(const AWinControl: TWinControl; const ALeft, ATop, AWidth, AHeight: Integer); override;
|
class procedure SetBounds(const AWinControl: TWinControl; const ALeft, ATop, AWidth, AHeight: Integer); override;
|
||||||
class procedure SetChildZPosition(const AWinControl, AChild: TWinControl; const AOldPos, ANewPos: Integer; const AChildren: TFPList); override;
|
class procedure SetChildZPosition(const AWinControl, AChild: TWinControl; const AOldPos, ANewPos: Integer; const AChildren: TFPList); override;
|
||||||
@ -188,6 +188,19 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
class function TGtkWSWinControl.CanFocus(const AWinControl: TWinControl): Boolean;
|
||||||
|
var
|
||||||
|
Widget, FocusWidget: PGtkWidget;
|
||||||
|
begin
|
||||||
|
if AWinControl.HandleAllocated then
|
||||||
|
begin
|
||||||
|
Widget := PGtkWidget(AWinControl.Handle);
|
||||||
|
FocusWidget := FindFocusWidget(Widget);
|
||||||
|
Result := (FocusWidget <> nil) and GTK_WIDGET_CAN_FOCUS(FocusWidget);
|
||||||
|
end else
|
||||||
|
Result := False;
|
||||||
|
end;
|
||||||
|
|
||||||
class procedure TGtkWSWinControl.ConstraintsChange(const AWinControl: TWinControl);
|
class procedure TGtkWSWinControl.ConstraintsChange(const AWinControl: TWinControl);
|
||||||
var
|
var
|
||||||
Widget: PGtkWidget;
|
Widget: PGtkWidget;
|
||||||
|
@ -160,7 +160,6 @@ type
|
|||||||
protected
|
protected
|
||||||
public
|
public
|
||||||
constructor Create(AOwner: TComponent); Override;
|
constructor Create(AOwner: TComponent); Override;
|
||||||
function CanTab: boolean; override;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
@ -72,6 +72,8 @@ type
|
|||||||
{ TWSWinControl }
|
{ TWSWinControl }
|
||||||
|
|
||||||
TWSWinControl = class(TWSControl)
|
TWSWinControl = class(TWSControl)
|
||||||
|
class function CanFocus(const AWincontrol: TWinControl): Boolean; virtual;
|
||||||
|
|
||||||
class function GetClientBounds(const AWincontrol: TWinControl; var ARect: TRect): Boolean; virtual;
|
class function GetClientBounds(const AWincontrol: TWinControl; var ARect: TRect): Boolean; virtual;
|
||||||
class function GetClientRect(const AWincontrol: TWinControl; var ARect: TRect): Boolean; virtual;
|
class function GetClientRect(const AWincontrol: TWinControl; var ARect: TRect): Boolean; virtual;
|
||||||
class procedure GetPreferredSize(const AWinControl: TWinControl; var PreferredWidth, PreferredHeight: integer; WithThemeSpace: Boolean); virtual;
|
class procedure GetPreferredSize(const AWinControl: TWinControl; var PreferredWidth, PreferredHeight: integer; WithThemeSpace: Boolean); virtual;
|
||||||
@ -147,6 +149,12 @@ class procedure TWSWinControl.DestroyHandle(const AWinControl: TWinControl);
|
|||||||
begin
|
begin
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
class function TWSWinControl.CanFocus(const AWincontrol: TWinControl): Boolean;
|
||||||
|
begin
|
||||||
|
// lets consider that by deafult all WinControls can be focused
|
||||||
|
Result := True;
|
||||||
|
end;
|
||||||
|
|
||||||
class function TWSWinControl.GetClientBounds(const AWincontrol: TWinControl; var ARect: TRect): Boolean;
|
class function TWSWinControl.GetClientBounds(const AWincontrol: TWinControl; var ARect: TRect): Boolean;
|
||||||
begin
|
begin
|
||||||
// for now default to the WinAPI version
|
// for now default to the WinAPI version
|
||||||
|
@ -51,10 +51,10 @@ uses
|
|||||||
type
|
type
|
||||||
{ TWSScrollBar }
|
{ TWSScrollBar }
|
||||||
|
|
||||||
TWSScrollBarClass = class of TWSScrollBar;
|
|
||||||
TWSScrollBar = class(TWSWinControl)
|
TWSScrollBar = class(TWSWinControl)
|
||||||
class procedure SetParams(const AScrollBar: TCustomScrollBar); virtual;
|
class procedure SetParams(const AScrollBar: TCustomScrollBar); virtual;
|
||||||
end;
|
end;
|
||||||
|
TWSScrollBarClass = class of TWSScrollBar;
|
||||||
|
|
||||||
{ TWSCustomGroupBox }
|
{ TWSCustomGroupBox }
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user