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:
mattias 2007-05-31 17:34:17 +00:00
parent 0e6eac99f2
commit 0154d0a518
5 changed files with 69 additions and 19 deletions

View File

@ -33,8 +33,8 @@ unit DesignerProcs;
interface
uses
Classes, SysUtils, Types, LCLIntf, Forms, Controls, LCLType, Graphics,
FormEditingIntf;
Classes, SysUtils, Types, LCLProc, LCLIntf, LCLType, Forms, Controls,
Graphics, FormEditingIntf;
type
TDesignerDCFlag = (ddcDCOriginValid, ddcFormOriginValid,

View File

@ -2284,9 +2284,9 @@ begin
Invalidate;
end;
{------------------------------------------------------------------------------}
{ TControl SetEnabled }
{------------------------------------------------------------------------------}
{------------------------------------------------------------------------------
TControl SetEnabled
------------------------------------------------------------------------------}
procedure TControl.SetEnabled(Value: Boolean);
begin
if FEnabled <> Value
@ -2296,9 +2296,9 @@ begin
end;
end;
{------------------------------------------------------------------------------}
{ TControl SetMouseCapture }
{------------------------------------------------------------------------------}
{------------------------------------------------------------------------------
TControl SetMouseCapture
------------------------------------------------------------------------------}
procedure TControl.SetMouseCapture(Value : Boolean);
begin
if (MouseCapture <> Value) or (not Value and (CaptureControl=Self))

View File

@ -987,18 +987,18 @@ begin
LabelFromAmpersands(Caption, Pattern, AccelKey);
gtk_label_set_text(ALabel, PChar(Caption));
{$ifdef gtk1}
gtk_label_set_pattern(ALabel, PChar(Pattern));
{$endif gtk1}
if AComponent = nil then Exit;
if ASignalWidget = nil then Exit;
if ASignal = '' then Exit;
{$IFDEF Gtk1}
// update the Accelerator
if AccelKey = #0
then Accelerate(AComponent, ASignalWidget, GDK_VOIDSYMBOL, 0, ASignal)
else Accelerate(AComponent, ASignalWidget, Ord(AccelKey), 0, ASignal);
{$ENDIF}
end;
procedure TGtkWidgetSet.SetWidgetColor(const AWidget: PGtkWidget;

View File

@ -2135,7 +2135,8 @@ var
// emulate the keys
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}
// the gtk2 gtkentry handles the return key and emits an activate signal
// The LCL does not use that and needs the return key event
@ -2212,6 +2213,8 @@ begin
RememberKeyEventWasHandledByLCL(AEvent, ABeforeEvent);
if TargetWidget = nil then Exit;
//DebugLn(['HandleGTKKeyUpDown TargetWidget=',GetWidgetDebugReport(TargetWidget)]);
gdk_event_key_get_string(AEvent, EventString);
FillChar(Msg, SizeOf(Msg), 0);
@ -2258,7 +2261,7 @@ begin
then Flags := Flags or KF_ALTDOWN;
CommonKeyData := KeyCode shl 16; // Not really scancode, but will do
if AHandleDown
then begin
{$IFDEF VerboseKeyboard}
@ -2401,9 +2404,9 @@ begin
end;
end;
end;
EmulateEatenKeys;
{$IFDEF Gtk1}
Result:=true;
{$ELSE}
@ -4485,6 +4488,39 @@ end;
on the screen.
-------------------------------------------------------------------------------}
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
ClientWidget: PGtkWidget;
ClientWindow: PGdkWindow;
@ -4493,7 +4529,9 @@ begin
if ClientWidget<>TheWidget then begin
ClientWindow:=GetControlWindow(ClientWidget);
if ClientWindow<>nil then begin
{$IFDEF DebugGDK}
BeginGDKErrorTrap;
{$ENDIF}
gdk_window_get_origin(ClientWindow,@Result.X,@Result.Y);
{$Ifdef GTK2}
if GTK_WIDGET_NO_WINDOW(ClientWidget)
@ -4502,10 +4540,18 @@ begin
Inc(Result.Y, ClientWidget^.Allocation.Y);
end;
{$EndIf}
{$IFDEF DebugGDK}
EndGDKErrorTrap;
{$ENDIF}
exit;
end;
{$IFDEF Gtk2}
end
else if GtkWidgetIsA(TheWidget,GTK_TYPE_NOTEBOOK) then begin
GetNoteBookClientOrigin(PGtkNoteBook(TheWidget));
exit;
end;
{$ENDIF}
Result:=GetWidgetOrigin(TheWidget);
end;

View File

@ -864,9 +864,11 @@ begin
// 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);
HandlerID := g_signal_handler_find(AButton, G_SIGNAL_MATCH_ID, BtnPressID, 0, nil, nil, nil);
if HandlerID > 0 then begin
g_signal_handler_disconnect(AButton, HandlerID);
if AButton<>nil then begin
HandlerID := g_signal_handler_find(AButton, G_SIGNAL_MATCH_ID, BtnPressID, 0, nil, nil, nil);
if HandlerID > 0 then begin
g_signal_handler_disconnect(AButton, HandlerID);
end;
end;
g_signal_connect(ComboWidget, 'changed', TGCallback(@GtkChangedCB), AWidgetInfo);
@ -911,8 +913,10 @@ begin
// Anything?
end;
g_signal_connect(APrivate^.popup_widget, 'show', TGCallback(@GtkPopupShowCB), AWidgetInfo);
g_signal_connect(APrivate^.popup_widget, 'hide', TGCallback(@GtkPopupHideCB), AWidgetInfo);
if APrivate^.popup_widget<>nil then begin
g_signal_connect(APrivate^.popup_widget, 'show', TGCallback(@GtkPopupShowCB), AWidgetInfo);
g_signal_connect(APrivate^.popup_widget, 'hide', TGCallback(@GtkPopupHideCB), AWidgetInfo);
end;
//g_signal_connect(ComboWidget, 'popup-shown', TGCallback(@GtkPopupShowCB), AWidgetInfo);
g_object_set_data(G_OBJECT(AWidget), 'Menu', APrivate^.popup_widget);
end;