MG: design signals for gtk internal widgets

git-svn-id: trunk@1922 -
This commit is contained in:
lazarus 2002-08-17 23:40:13 +00:00
parent f77728bd78
commit f4a51bed65

View File

@ -162,34 +162,18 @@ begin
if TheWinControl<>nil then begin if TheWinControl<>nil then begin
SetCursor(TheWinControl); SetCursor(TheWinControl);
ConnectInternalWidgetsSignals(TheWinControl); ConnectInternalWidgetsSignals(MainWidget,TheWinControl);
end; end;
end; end;
end else begin end else begin
// this is a hidden child widget of a lcl widget // this is a hidden child widget of a lcl widget
if HiddenLCLObject is TWinControl then
ConnectInternalWidgetsSignals(Widget,TWinControl(HiddenLCLObject));
end; end;
Result := True; Result := True;
end; end;
{-------------------------------------------------------------------------------
function GTKHiddenRealizeAfterCB
Params: Widget: PGtkWidget; Data: Pointer
Result: GBoolean
GTKHiddenRealizeAfterCB is called by the gtk, whenever a hidden widget is
realized (ie mapped), and after the widget itself got the realize signal.
That means that the gdk window on the xserver has been created and the widget
has initialized the gdkwindow.
-------------------------------------------------------------------------------}
function GTKHiddenRealizeAfterCB(Widget: PGtkWidget; Data: Pointer): GBoolean; cdecl;
begin
EventTrace('hiddenrealizeafter', nil);
writeln('CCC1 GTKHiddenRealizeAfterCB ',HexStr(Cardinal(Widget),8));
Result := True;
end;
function gtkshowCB( widget: PGtkWidget; data: gPointer) : GBoolean; cdecl; function gtkshowCB( widget: PGtkWidget; data: gPointer) : GBoolean; cdecl;
var var
Mess : TLMShowWindow; Mess : TLMShowWindow;
@ -521,28 +505,22 @@ end;
If the mouse is on the top-left pixel of the container widget then the If the mouse is on the top-left pixel of the container widget then the
coordinates can be negative, if there is frame around the client area. coordinates can be negative, if there is frame around the client area.
-------------------------------------------------------------------------------} -------------------------------------------------------------------------------}
function GTKMotionNotify(Widget:PGTKWidget; event: PGDKEventMotion; function GTKMotionNotify(Widget:PGTKWidget; Event: PGDKEventMotion;
data: gPointer): GBoolean; cdecl; Data: gPointer): GBoolean; cdecl;
var var
Msg: TLMMouseMove; Msg: TLMMouseMove;
ShiftState: TShiftState; ShiftState: TShiftState;
MappedXY: TPoint; MappedXY: TPoint;
HiddenLCLObject: TObject; DesignOnlySignal: boolean;
begin begin
Result:=true; Result:=true;
HiddenLCLObject:=GetHiddenLCLObject(Widget);
if HiddenLCLObject<>nil then begin
// this is a hidden widget (= a gtk internal widget of a lcl widget)
if not (csDesigning in TControl(HiddenLCLObject).ComponentState) then begin
// if not in design mode, hidden widgets are controlled by the gtk ...
exit;
end;
end;
{$IFDEF VerboseMouseBugfix} {$IFDEF VerboseMouseBugfix}
DesignOnlySignal:=GetDesignOnlySignalFlag(Widget,dstMouseMotion);
writeln('[GTKMotionNotify] ', writeln('[GTKMotionNotify] ',
TControl(Data).Name,':',TControl(Data).ClassName, TControl(Data).Name,':',TControl(Data).ClassName,
' Widget=',HexStr(Cardinal(Widget),8),
' DSO=',DesignOnlySignal,
' Event^.X=',trunc(Event^.X),' Event^.Y=',trunc(Event^.Y) ' Event^.X=',trunc(Event^.X),' Event^.Y=',trunc(Event^.Y)
); );
{$ENDIF} {$ENDIF}
@ -550,6 +528,9 @@ begin
if csDesigning in TControl(Data).ComponentState then begin if csDesigning in TControl(Data).ComponentState then begin
// stop the signal, so that the widget does not auto react // stop the signal, so that the widget does not auto react
gtk_signal_emit_stop_by_name(PGTKObject(Widget),'motion-notify-event'); gtk_signal_emit_stop_by_name(PGTKObject(Widget),'motion-notify-event');
end else begin
DesignOnlySignal:=GetDesignOnlySignalFlag(Widget,dstMouseMotion);
if DesignOnlySignal then exit;
end; end;
MappedXY:=TranslateGdkPointToClientArea(Event^.Window, MappedXY:=TranslateGdkPointToClientArea(Event^.Window,
@ -620,7 +601,8 @@ var
MappedXY: TPoint; MappedXY: TPoint;
//ShowDebugging : Boolean; //ShowDebugging : Boolean;
//parWindow : PgdkWindow; //the Parent's GDKWindow //parWindow : PgdkWindow; //the Parent's GDKWindow
HiddenLCLObject: TObject; DesignOnlySignal: boolean;
{ $DEFINE VerboseMouseBugfix} { $DEFINE VerboseMouseBugfix}
function CheckMouseButtonDown(var LastMouse: TLastMouseClick; function CheckMouseButtonDown(var LastMouse: TLastMouseClick;
@ -663,21 +645,13 @@ var
begin begin
Result:=true; Result:=true;
HiddenLCLObject:=GetHiddenLCLObject(Widget);
if HiddenLCLObject<>nil then begin
writeln('DDD1 Hidden=',HexStr(Cardinal(Data),8),' ',HexStr(Cardinal(HiddenLCLObject),8));
writeln(' ',TControl(Data).Name,':',TControl(Data).ClassName);
// this is a hidden widget (= a child widget of a lcl widget)
if not (csDesigning in TControl(HiddenLCLObject).ComponentState) then begin
// if not in design mode, hidden widgets are controlled by the gtk ...
exit;
end;
end;
{$IFDEF VerboseMouseBugfix} {$IFDEF VerboseMouseBugfix}
DesignOnlySignal:=GetDesignOnlySignalFlag(Widget,dstMousePress);
writeln('[gtkMouseBtnPress] ', writeln('[gtkMouseBtnPress] ',
TControl(Data).Name,':',TObject(Data).ClassName,' ', TControl(Data).Name,':',TObject(Data).ClassName,
Trunc(Event^.X),',',Trunc(Event^.Y)); ' Widget=',HexStr(Cardinal(Widget),8),
' DSO=',DesignOnlySignal,
' ',Trunc(Event^.X),',',Trunc(Event^.Y));
{$ENDIF} {$ENDIF}
//writeln('DDD1 MousePress Widget=',HexStr(Cardinal(Widget),8), //writeln('DDD1 MousePress Widget=',HexStr(Cardinal(Widget),8),
//' ClientWidget=',HexStr(Cardinal(GetFixedWidget(Widget)),8), //' ClientWidget=',HexStr(Cardinal(GetFixedWidget(Widget)),8),
@ -695,6 +669,9 @@ begin
// stop the signal, so that the widget does not auto react // stop the signal, so that the widget does not auto react
if TControl(Data).FCompStyle<>csNotebook then if TControl(Data).FCompStyle<>csNotebook then
gtk_signal_emit_stop_by_name(PGTKObject(Widget),'button-press-event'); gtk_signal_emit_stop_by_name(PGTKObject(Widget),'button-press-event');
end else begin
DesignOnlySignal:=GetDesignOnlySignalFlag(Widget,dstMousePress);
if DesignOnlySignal then exit;
end; end;
ShiftState := GTKEventState2ShiftState(Event^.State); ShiftState := GTKEventState2ShiftState(Event^.State);
@ -702,26 +679,6 @@ begin
Point(trunc(Event^.X),trunc(Event^.Y)), Point(trunc(Event^.X),trunc(Event^.Y)),
PGtkWidget(TWinControl(Data).Handle)); PGtkWidget(TWinControl(Data).Handle));
{ShowDebugging := False;
if ShowDebugging then
Begin
writeln('_______________');
Writeln('Button Down');
Writeln('Control = ',TControl(data).Name);
Writeln('Handle = ',Longint(TWinControl(data).Handle));
Writeln('Widget = ',LongInt(widget));
Writeln('Window = ',Longint(Event^.Window));
Writeln('Coords = ',trunc(Event^.x),',',trunc(Event^.Y));
Writeln('Event Type',Event^.thetype);
Writeln('Coords root = ',trunc(Event^.x_root),',',trunc(Event^.Y_root));
Writeln('State = ',event^.state);
Writeln('TGtkWidget^.Window is ',Longint(Widget^.Window));
parWindow := gtk_widget_get_parent_window(widget);
Writeln('Parwindow is ',LongInt(parwindow));
Writeln('_______________');
end;}
if event^.Button in [4,5] then begin if event^.Button in [4,5] then begin
// this is a mouse wheel event // this is a mouse wheel event
MessE.Msg := LM_MOUSEWHEEL; MessE.Msg := LM_MOUSEWHEEL;
@ -771,7 +728,7 @@ begin
end; end;
{------------------------------------------------------------------------------- {-------------------------------------------------------------------------------
gtkMouseBtnPress gtkMouseBtnPressAfter
Params: widget: PGTKWidget; event: PGDKEventMotion; data: gPointer Params: widget: PGTKWidget; event: PGDKEventMotion; data: gPointer
Returns: GBoolean Returns: GBoolean
@ -784,8 +741,9 @@ begin
Result:=true; Result:=true;
{$IFDEF VerboseMouseBugfix} {$IFDEF VerboseMouseBugfix}
writeln('[gtkMouseBtnPressAfter] ', writeln('[gtkMouseBtnPressAfter] ',
TControl(Data).Name,':',TObject(Data).ClassName,' ', TControl(Data).Name,':',TObject(Data).ClassName,
Trunc(Event^.X),',',Trunc(Event^.Y)); ' Widget=',HexStr(Cardinal(Widget),8),
' ',Trunc(Event^.X),',',Trunc(Event^.Y));
{$ENDIF} {$ENDIF}
// stop the signal, so that it is not sent to the parent widgets // stop the signal, so that it is not sent to the parent widgets
@ -805,8 +763,8 @@ var
MessI : TLMMouse; MessI : TLMMouse;
ShiftState: TShiftState; ShiftState: TShiftState;
MappedXY: TPoint; MappedXY: TPoint;
HiddenLCLObject: TObject; DesignOnlySignal: boolean;
function CheckMouseButtonUp(var LastMouse: TLastMouseClick; function CheckMouseButtonUp(var LastMouse: TLastMouseClick;
MsgUp: integer): boolean; MsgUp: integer): boolean;
begin begin
@ -825,28 +783,25 @@ begin
Result:=true; Result:=true;
{$IFDEF VerboseMouseBugfix} {$IFDEF VerboseMouseBugfix}
DesignOnlySignal:=GetDesignOnlySignalFlag(Widget,dstMouseRelease);
writeln('[gtkMouseBtnRelease] A ', writeln('[gtkMouseBtnRelease] A ',
TControl(Data).Name,':',TObject(Data).ClassName,' ', TControl(Data).Name,':',TObject(Data).ClassName,' ',
Trunc(Event^.X),',',Trunc(Event^.Y),' Btn=',event^.Button); ' Widget=',HexStr(Cardinal(Widget),8),
' DSO=',DesignOnlySignal,
' ',Trunc(Event^.X),',',Trunc(Event^.Y),' Btn=',event^.Button);
{$ENDIF} {$ENDIF}
//writeln('EEE1 MouseRelease Widget=',HexStr(Cardinal(Widget),8), //writeln('EEE1 MouseRelease Widget=',HexStr(Cardinal(Widget),8),
//' EventMask=',HexStr(Cardinal(gdk_window_get_events(Widget^.Window)),8), //' EventMask=',HexStr(Cardinal(gdk_window_get_events(Widget^.Window)),8),
//' GDK_BUTTON_RELEASE_MASK=',HexStr(Cardinal(GDK_BUTTON_RELEASE_MASK),8)); //' GDK_BUTTON_RELEASE_MASK=',HexStr(Cardinal(GDK_BUTTON_RELEASE_MASK),8));
HiddenLCLObject:=GetHiddenLCLObject(Widget);
if HiddenLCLObject<>nil then begin
// this is a hidden widget (= a child widget of a lcl widget)
if not (csDesigning in TControl(HiddenLCLObject).ComponentState) then begin
// if not in design mode, hidden widgets are controlled by the gtk ...
exit;
end;
end;
if csDesigning in TControl(Data).ComponentState then begin if csDesigning in TControl(Data).ComponentState then begin
// stop the signal, so that the widget does not auto react // stop the signal, so that the widget does not auto react
if TControl(Data).FCompStyle<>csNotebook then if TControl(Data).FCompStyle<>csNotebook then
gtk_signal_emit_stop_by_name(PGTKObject(Widget),'button-release-event'); gtk_signal_emit_stop_by_name(PGTKObject(Widget),'button-release-event');
end else begin
DesignOnlySignal:=GetDesignOnlySignalFlag(Widget,dstMouseRelease);
if DesignOnlySignal then exit;
end; end;
EventTrace('Mouse button release', data); EventTrace('Mouse button release', data);
@ -2143,6 +2098,9 @@ end;
{ ============================================================================= { =============================================================================
$Log$ $Log$
Revision 1.101 2002/08/19 18:00:02 lazarus
MG: design signals for gtk internal widgets
Revision 1.100 2002/08/19 08:50:28 lazarus Revision 1.100 2002/08/19 08:50:28 lazarus
MG: fixed parser for Clx enums and empty param lists MG: fixed parser for Clx enums and empty param lists