mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 12:19:21 +02:00
customdrawnws: Implements redirecting events to subcontrols in X11 and implements using BaseWindowOrg and SaveState/ResetCanvasState/RestoreState for safer TWinControl drawing
git-svn-id: trunk@33849 -
This commit is contained in:
parent
9fb56a56d9
commit
70eea2d476
@ -218,15 +218,24 @@ begin
|
|||||||
lCDWinControl.Region.Rect := Bounds(lWinControl.Left, lWinControl.Top, lWinControl.Width, lWinControl.Height);
|
lCDWinControl.Region.Rect := Bounds(lWinControl.Left, lWinControl.Top, lWinControl.Width, lWinControl.Height);
|
||||||
ACanvas.ClipRegion := lCDWinControl.Region;
|
ACanvas.ClipRegion := lCDWinControl.Region;
|
||||||
ACanvas.UseRegionClipping := True;
|
ACanvas.UseRegionClipping := True;
|
||||||
ACanvas.WindowOrg := Point(lWinControl.Left, lWinControl.Top);
|
ACanvas.BaseWindowOrg := Point(lWinControl.Left, lWinControl.Top);
|
||||||
|
ACanvas.WindowOrg := Point(0, 0);
|
||||||
|
|
||||||
|
// Save the Canvas state
|
||||||
|
ACanvas.SaveState;
|
||||||
|
ACanvas.ResetCanvasState;
|
||||||
|
|
||||||
{$ifdef VerboseCDWinControl}
|
{$ifdef VerboseCDWinControl}
|
||||||
DebugLn(Format('[RenderChildWinControls] i=%d before LCLSendPaintMsg', [i]));
|
DebugLn(Format('[RenderChildWinControls] i=%d before LCLSendPaintMsg', [i]));
|
||||||
{$endif}
|
{$endif}
|
||||||
LCLSendPaintMsg(lCDWinControl.WinControl, struct.hdc, @struct);
|
LCLSendPaintMsg(lCDWinControl.WinControl, struct.hdc, @struct);
|
||||||
|
|
||||||
|
// Now restore it
|
||||||
|
ACanvas.RestoreState;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
ACanvas.Clipping := False;
|
ACanvas.Clipping := False;
|
||||||
|
ACanvas.BaseWindowOrg := Point(0, 0);
|
||||||
ACanvas.WindowOrg := Point(0, 0);
|
ACanvas.WindowOrg := Point(0, 0);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -4889,10 +4889,19 @@ begin
|
|||||||
|
|
||||||
SetLength(lPoints, NumPts);
|
SetLength(lPoints, NumPts);
|
||||||
for i := 0 to NumPts-1 do
|
for i := 0 to NumPts-1 do
|
||||||
|
begin
|
||||||
|
{$ifdef VerboseCDWinAPI}
|
||||||
|
LCLProc.DbgOut(Format(' P=%d,%d', [Points[i].X, Points[i].Y]));
|
||||||
|
{$endif}
|
||||||
lPoints[i] := Points[i];
|
lPoints[i] := Points[i];
|
||||||
|
end;
|
||||||
|
|
||||||
LazDC.Polygon(lPoints);
|
LazDC.Polygon(lPoints);
|
||||||
Result := True;
|
Result := True;
|
||||||
|
|
||||||
|
{$ifdef VerboseCDWinAPI}
|
||||||
|
DebugLn('');
|
||||||
|
{$endif}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
@ -5347,7 +5356,7 @@ begin
|
|||||||
{$ifdef VerboseCDWinAPI}ObjType := 'Pen';{$endif}
|
{$ifdef VerboseCDWinAPI}ObjType := 'Pen';{$endif}
|
||||||
|
|
||||||
Result := HGDIOBJ(TLazCanvas(DC).AssignedPen);
|
Result := HGDIOBJ(TLazCanvas(DC).AssignedPen);
|
||||||
TLazCanvas(DC).AssignPenData(lPen); // := doesn't work
|
TLazCanvas(DC).AssignPenData(lPen); // := doesn't work and Assign() raises exceptions
|
||||||
TLazCanvas(DC).AssignedPen := lPen;
|
TLazCanvas(DC).AssignedPen := lPen;
|
||||||
end
|
end
|
||||||
else if aObject is TFPCustomBrush then
|
else if aObject is TFPCustomBrush then
|
||||||
@ -5355,7 +5364,7 @@ begin
|
|||||||
{$ifdef VerboseCDWinAPI}ObjType := 'Brush';{$endif}
|
{$ifdef VerboseCDWinAPI}ObjType := 'Brush';{$endif}
|
||||||
|
|
||||||
Result := HGDIOBJ(TLazCanvas(DC).AssignedBrush);
|
Result := HGDIOBJ(TLazCanvas(DC).AssignedBrush);
|
||||||
TLazCanvas(DC).AssignBrushData(lBrush); // := doesn't work
|
TLazCanvas(DC).AssignBrushData(lBrush); // := doesn't work and Assign() raises exceptions
|
||||||
TLazCanvas(DC).AssignedBrush := lBrush;
|
TLazCanvas(DC).AssignedBrush := lBrush;
|
||||||
end(*
|
end(*
|
||||||
else if aObject is TQtImage then
|
else if aObject is TQtImage then
|
||||||
|
@ -524,10 +524,13 @@ class procedure TCDWSCustomForm.EvMousePressed(const AWinControl: TWinControl; A
|
|||||||
var Event: TXButtonEvent);
|
var Event: TXButtonEvent);
|
||||||
var
|
var
|
||||||
MouseButton: TMouseButton;
|
MouseButton: TMouseButton;
|
||||||
|
lTarget: TWinControl;
|
||||||
begin
|
begin
|
||||||
|
lTarget := FindControlWhichReceivedEvent(TCustomForm(AWinControl), AWindowInfo.Children, Event.x, Event.y);
|
||||||
|
|
||||||
if XButtonToMouseButton(Event.button, MouseButton) then
|
if XButtonToMouseButton(Event.button, MouseButton) then
|
||||||
begin
|
begin
|
||||||
LCLSendMouseDownMsg(AWinControl, Event.x, Event.y, MouseButton, []);
|
LCLSendMouseDownMsg(lTarget, Event.x, Event.y, MouseButton, []);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
@ -556,14 +559,17 @@ class procedure TCDWSCustomForm.EvMouseReleased(const AWinControl: TWinControl;
|
|||||||
var Event: TXButtonEvent);
|
var Event: TXButtonEvent);
|
||||||
var
|
var
|
||||||
MouseButton: TMouseButton;
|
MouseButton: TMouseButton;
|
||||||
|
lTarget: TWinControl;
|
||||||
begin
|
begin
|
||||||
|
lTarget := FindControlWhichReceivedEvent(TCustomForm(AWinControl), AWindowInfo.Children, Event.x, Event.y);
|
||||||
|
|
||||||
{ Release events are only for mouse buttons, and not mouse wheel moviments }
|
{ Release events are only for mouse buttons, and not mouse wheel moviments }
|
||||||
if (Event.button >= 1) and (Event.button <= 3) then
|
if (Event.button >= 1) and (Event.button <= 3) then
|
||||||
begin
|
begin
|
||||||
XButtonToMouseButton(Event.button, MouseButton);
|
XButtonToMouseButton(Event.button, MouseButton);
|
||||||
|
|
||||||
LCLSendMouseUpMsg(AWinControl, Event.x, Event.y, MouseButton, []);
|
LCLSendMouseUpMsg(lTarget, Event.x, Event.y, MouseButton, []);
|
||||||
LCLSendClickedMsg(AWinControl);
|
LCLSendClickedMsg(lTarget);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -577,8 +583,12 @@ end;
|
|||||||
|
|
||||||
class procedure TCDWSCustomForm.EvMouseMove(const AWinControl: TWinControl; AWindowInfo: TX11WindowInfo;
|
class procedure TCDWSCustomForm.EvMouseMove(const AWinControl: TWinControl; AWindowInfo: TX11WindowInfo;
|
||||||
var Event: TXMotionEvent);
|
var Event: TXMotionEvent);
|
||||||
|
var
|
||||||
|
lTarget: TWinControl;
|
||||||
begin
|
begin
|
||||||
LCLSendMouseMoveMsg(AWinControl, Event.x, Event.y, []);
|
lTarget := FindControlWhichReceivedEvent(TCustomForm(AWinControl), AWindowInfo.Children, Event.x, Event.y);
|
||||||
|
|
||||||
|
LCLSendMouseMoveMsg(lTarget, Event.x, Event.y, []);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// Top-level windows receive LM_ACTIVATE while constrols receive LM_SETFOCUS
|
// Top-level windows receive LM_ACTIVATE while constrols receive LM_SETFOCUS
|
||||||
|
Loading…
Reference in New Issue
Block a user