mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-07 14:20:40 +01:00
gtk2 intf: fixed setting callbacks if no combobox items count=0, gtk2 intf: not setting gtk accelerators for buttons, gtk2 intf: fixed GetClientOrigin for TNoteBook
git-svn-id: trunk@11241 -
This commit is contained in:
parent
0e6eac99f2
commit
0154d0a518
@ -33,8 +33,8 @@ unit DesignerProcs;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, Types, LCLIntf, Forms, Controls, LCLType, Graphics,
|
Classes, SysUtils, Types, LCLProc, LCLIntf, LCLType, Forms, Controls,
|
||||||
FormEditingIntf;
|
Graphics, FormEditingIntf;
|
||||||
|
|
||||||
type
|
type
|
||||||
TDesignerDCFlag = (ddcDCOriginValid, ddcFormOriginValid,
|
TDesignerDCFlag = (ddcDCOriginValid, ddcFormOriginValid,
|
||||||
|
|||||||
@ -2284,9 +2284,9 @@ begin
|
|||||||
Invalidate;
|
Invalidate;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------}
|
{------------------------------------------------------------------------------
|
||||||
{ TControl SetEnabled }
|
TControl SetEnabled
|
||||||
{------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
procedure TControl.SetEnabled(Value: Boolean);
|
procedure TControl.SetEnabled(Value: Boolean);
|
||||||
begin
|
begin
|
||||||
if FEnabled <> Value
|
if FEnabled <> Value
|
||||||
@ -2296,9 +2296,9 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------}
|
{------------------------------------------------------------------------------
|
||||||
{ TControl SetMouseCapture }
|
TControl SetMouseCapture
|
||||||
{------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
procedure TControl.SetMouseCapture(Value : Boolean);
|
procedure TControl.SetMouseCapture(Value : Boolean);
|
||||||
begin
|
begin
|
||||||
if (MouseCapture <> Value) or (not Value and (CaptureControl=Self))
|
if (MouseCapture <> Value) or (not Value and (CaptureControl=Self))
|
||||||
|
|||||||
@ -987,18 +987,18 @@ begin
|
|||||||
LabelFromAmpersands(Caption, Pattern, AccelKey);
|
LabelFromAmpersands(Caption, Pattern, AccelKey);
|
||||||
gtk_label_set_text(ALabel, PChar(Caption));
|
gtk_label_set_text(ALabel, PChar(Caption));
|
||||||
|
|
||||||
{$ifdef gtk1}
|
|
||||||
gtk_label_set_pattern(ALabel, PChar(Pattern));
|
gtk_label_set_pattern(ALabel, PChar(Pattern));
|
||||||
{$endif gtk1}
|
|
||||||
|
|
||||||
if AComponent = nil then Exit;
|
if AComponent = nil then Exit;
|
||||||
if ASignalWidget = nil then Exit;
|
if ASignalWidget = nil then Exit;
|
||||||
if ASignal = '' then Exit;
|
if ASignal = '' then Exit;
|
||||||
|
|
||||||
|
{$IFDEF Gtk1}
|
||||||
// update the Accelerator
|
// update the Accelerator
|
||||||
if AccelKey = #0
|
if AccelKey = #0
|
||||||
then Accelerate(AComponent, ASignalWidget, GDK_VOIDSYMBOL, 0, ASignal)
|
then Accelerate(AComponent, ASignalWidget, GDK_VOIDSYMBOL, 0, ASignal)
|
||||||
else Accelerate(AComponent, ASignalWidget, Ord(AccelKey), 0, ASignal);
|
else Accelerate(AComponent, ASignalWidget, Ord(AccelKey), 0, ASignal);
|
||||||
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TGtkWidgetSet.SetWidgetColor(const AWidget: PGtkWidget;
|
procedure TGtkWidgetSet.SetWidgetColor(const AWidget: PGtkWidget;
|
||||||
|
|||||||
@ -2135,7 +2135,8 @@ var
|
|||||||
// emulate the keys
|
// emulate the keys
|
||||||
if not ABeforeEvent then exit;
|
if not ABeforeEvent then exit;
|
||||||
|
|
||||||
//DebugLn(['EmulateKeysEatenByGtk ',GetWidgetDebugReport(TargetWidget),' gdk_event_get_type(Event)=',gdk_event_get_type(Event),' GDK_KEY_PRESS=',GDK_KEY_PRESS,' VKey.VKey=',VKey.VKey]);
|
//DebugLn(['EmulateEatenKeys TargetWidget=',dbghex(PtrInt(TargetWidget))]);
|
||||||
|
//DebugLn(['EmulateEatenKeys ',GetWidgetDebugReport(TargetWidget),' gdk_event_get_type(AEvent)=',gdk_event_get_type(AEvent),' GDK_KEY_PRESS=',GDK_KEY_PRESS,' VKey=',VKey]);
|
||||||
{$IFDEF Gtk2}
|
{$IFDEF Gtk2}
|
||||||
// the gtk2 gtkentry handles the return key and emits an activate signal
|
// the gtk2 gtkentry handles the return key and emits an activate signal
|
||||||
// The LCL does not use that and needs the return key event
|
// The LCL does not use that and needs the return key event
|
||||||
@ -2213,6 +2214,8 @@ begin
|
|||||||
|
|
||||||
if TargetWidget = nil then Exit;
|
if TargetWidget = nil then Exit;
|
||||||
|
|
||||||
|
//DebugLn(['HandleGTKKeyUpDown TargetWidget=',GetWidgetDebugReport(TargetWidget)]);
|
||||||
|
|
||||||
gdk_event_key_get_string(AEvent, EventString);
|
gdk_event_key_get_string(AEvent, EventString);
|
||||||
FillChar(Msg, SizeOf(Msg), 0);
|
FillChar(Msg, SizeOf(Msg), 0);
|
||||||
|
|
||||||
@ -4485,6 +4488,39 @@ end;
|
|||||||
on the screen.
|
on the screen.
|
||||||
-------------------------------------------------------------------------------}
|
-------------------------------------------------------------------------------}
|
||||||
function GetWidgetClientOrigin(TheWidget: PGtkWidget): TPoint;
|
function GetWidgetClientOrigin(TheWidget: PGtkWidget): TPoint;
|
||||||
|
|
||||||
|
{$IFDEF Gtk2}
|
||||||
|
procedure GetNoteBookClientOrigin(NBWidget: PGtkNotebook);
|
||||||
|
var
|
||||||
|
PageIndex: LongInt;
|
||||||
|
PageWidget: PGtkWidget;
|
||||||
|
ClientWidget: PGTKWidget;
|
||||||
|
FrameBorders: TRect;
|
||||||
|
begin
|
||||||
|
// get current page
|
||||||
|
PageIndex:=gtk_notebook_get_current_page(NBWidget);
|
||||||
|
if PageIndex>=0 then
|
||||||
|
PageWidget:=gtk_notebook_get_nth_page(NBWidget,PageIndex)
|
||||||
|
else
|
||||||
|
PageWidget:=nil;
|
||||||
|
// get client widget of page
|
||||||
|
if (PageWidget<>nil) then
|
||||||
|
ClientWidget:=GetFixedWidget(PageWidget)
|
||||||
|
else
|
||||||
|
ClientWidget:=nil;
|
||||||
|
if ClientWidget^.window<>nil then begin
|
||||||
|
// get the position of the current page
|
||||||
|
gdk_window_get_origin(ClientWidget^.window,@Result.X,@Result.Y);
|
||||||
|
end else begin
|
||||||
|
// use defaults
|
||||||
|
Result:=GetWidgetOrigin(TheWidget);
|
||||||
|
FrameBorders:=GetStyleNotebookFrameBorders;
|
||||||
|
GetWidgetClientOrigin.x:=Result.x+FrameBorders.Left;
|
||||||
|
GetWidgetClientOrigin.y:=Result.y+FrameBorders.Top;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
var
|
var
|
||||||
ClientWidget: PGtkWidget;
|
ClientWidget: PGtkWidget;
|
||||||
ClientWindow: PGdkWindow;
|
ClientWindow: PGdkWindow;
|
||||||
@ -4493,7 +4529,9 @@ begin
|
|||||||
if ClientWidget<>TheWidget then begin
|
if ClientWidget<>TheWidget then begin
|
||||||
ClientWindow:=GetControlWindow(ClientWidget);
|
ClientWindow:=GetControlWindow(ClientWidget);
|
||||||
if ClientWindow<>nil then begin
|
if ClientWindow<>nil then begin
|
||||||
|
{$IFDEF DebugGDK}
|
||||||
BeginGDKErrorTrap;
|
BeginGDKErrorTrap;
|
||||||
|
{$ENDIF}
|
||||||
gdk_window_get_origin(ClientWindow,@Result.X,@Result.Y);
|
gdk_window_get_origin(ClientWindow,@Result.X,@Result.Y);
|
||||||
{$Ifdef GTK2}
|
{$Ifdef GTK2}
|
||||||
if GTK_WIDGET_NO_WINDOW(ClientWidget)
|
if GTK_WIDGET_NO_WINDOW(ClientWidget)
|
||||||
@ -4502,10 +4540,18 @@ begin
|
|||||||
Inc(Result.Y, ClientWidget^.Allocation.Y);
|
Inc(Result.Y, ClientWidget^.Allocation.Y);
|
||||||
end;
|
end;
|
||||||
{$EndIf}
|
{$EndIf}
|
||||||
|
{$IFDEF DebugGDK}
|
||||||
EndGDKErrorTrap;
|
EndGDKErrorTrap;
|
||||||
|
{$ENDIF}
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
{$IFDEF Gtk2}
|
||||||
|
end
|
||||||
|
else if GtkWidgetIsA(TheWidget,GTK_TYPE_NOTEBOOK) then begin
|
||||||
|
GetNoteBookClientOrigin(PGtkNoteBook(TheWidget));
|
||||||
|
exit;
|
||||||
end;
|
end;
|
||||||
|
{$ENDIF}
|
||||||
Result:=GetWidgetOrigin(TheWidget);
|
Result:=GetWidgetOrigin(TheWidget);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|||||||
@ -864,10 +864,12 @@ begin
|
|||||||
|
|
||||||
// we have to remove the handler gtk sets up because we will never get the mouse down messages
|
// we have to remove the handler gtk sets up because we will never get the mouse down messages
|
||||||
BtnPressID := g_signal_lookup('button_press_event', GTK_TYPE_COMBO_BOX);
|
BtnPressID := g_signal_lookup('button_press_event', GTK_TYPE_COMBO_BOX);
|
||||||
|
if AButton<>nil then begin
|
||||||
HandlerID := g_signal_handler_find(AButton, G_SIGNAL_MATCH_ID, BtnPressID, 0, nil, nil, nil);
|
HandlerID := g_signal_handler_find(AButton, G_SIGNAL_MATCH_ID, BtnPressID, 0, nil, nil, nil);
|
||||||
if HandlerID > 0 then begin
|
if HandlerID > 0 then begin
|
||||||
g_signal_handler_disconnect(AButton, HandlerID);
|
g_signal_handler_disconnect(AButton, HandlerID);
|
||||||
end;
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
g_signal_connect(ComboWidget, 'changed', TGCallback(@GtkChangedCB), AWidgetInfo);
|
g_signal_connect(ComboWidget, 'changed', TGCallback(@GtkChangedCB), AWidgetInfo);
|
||||||
|
|
||||||
@ -911,8 +913,10 @@ begin
|
|||||||
// Anything?
|
// Anything?
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
if APrivate^.popup_widget<>nil then begin
|
||||||
g_signal_connect(APrivate^.popup_widget, 'show', TGCallback(@GtkPopupShowCB), AWidgetInfo);
|
g_signal_connect(APrivate^.popup_widget, 'show', TGCallback(@GtkPopupShowCB), AWidgetInfo);
|
||||||
g_signal_connect(APrivate^.popup_widget, 'hide', TGCallback(@GtkPopupHideCB), AWidgetInfo);
|
g_signal_connect(APrivate^.popup_widget, 'hide', TGCallback(@GtkPopupHideCB), AWidgetInfo);
|
||||||
|
end;
|
||||||
//g_signal_connect(ComboWidget, 'popup-shown', TGCallback(@GtkPopupShowCB), AWidgetInfo);
|
//g_signal_connect(ComboWidget, 'popup-shown', TGCallback(@GtkPopupShowCB), AWidgetInfo);
|
||||||
g_object_set_data(G_OBJECT(AWidget), 'Menu', APrivate^.popup_widget);
|
g_object_set_data(G_OBJECT(AWidget), 'Menu', APrivate^.popup_widget);
|
||||||
end;
|
end;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user