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:
sekelsenmat 2011-11-29 09:52:44 +00:00
parent 9fb56a56d9
commit 70eea2d476
3 changed files with 35 additions and 7 deletions

View File

@ -218,15 +218,24 @@ begin
lCDWinControl.Region.Rect := Bounds(lWinControl.Left, lWinControl.Top, lWinControl.Width, lWinControl.Height);
ACanvas.ClipRegion := lCDWinControl.Region;
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}
DebugLn(Format('[RenderChildWinControls] i=%d before LCLSendPaintMsg', [i]));
{$endif}
LCLSendPaintMsg(lCDWinControl.WinControl, struct.hdc, @struct);
// Now restore it
ACanvas.RestoreState;
end;
ACanvas.Clipping := False;
ACanvas.BaseWindowOrg := Point(0, 0);
ACanvas.WindowOrg := Point(0, 0);
end;

View File

@ -4889,10 +4889,19 @@ begin
SetLength(lPoints, NumPts);
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];
end;
LazDC.Polygon(lPoints);
Result := True;
{$ifdef VerboseCDWinAPI}
DebugLn('');
{$endif}
end;
{------------------------------------------------------------------------------
@ -5347,7 +5356,7 @@ begin
{$ifdef VerboseCDWinAPI}ObjType := 'Pen';{$endif}
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;
end
else if aObject is TFPCustomBrush then
@ -5355,7 +5364,7 @@ begin
{$ifdef VerboseCDWinAPI}ObjType := 'Brush';{$endif}
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;
end(*
else if aObject is TQtImage then

View File

@ -524,10 +524,13 @@ class procedure TCDWSCustomForm.EvMousePressed(const AWinControl: TWinControl; A
var Event: TXButtonEvent);
var
MouseButton: TMouseButton;
lTarget: TWinControl;
begin
lTarget := FindControlWhichReceivedEvent(TCustomForm(AWinControl), AWindowInfo.Children, Event.x, Event.y);
if XButtonToMouseButton(Event.button, MouseButton) then
begin
LCLSendMouseDownMsg(AWinControl, Event.x, Event.y, MouseButton, []);
LCLSendMouseDownMsg(lTarget, Event.x, Event.y, MouseButton, []);
end
else
begin
@ -556,14 +559,17 @@ class procedure TCDWSCustomForm.EvMouseReleased(const AWinControl: TWinControl;
var Event: TXButtonEvent);
var
MouseButton: TMouseButton;
lTarget: TWinControl;
begin
lTarget := FindControlWhichReceivedEvent(TCustomForm(AWinControl), AWindowInfo.Children, Event.x, Event.y);
{ Release events are only for mouse buttons, and not mouse wheel moviments }
if (Event.button >= 1) and (Event.button <= 3) then
begin
XButtonToMouseButton(Event.button, MouseButton);
LCLSendMouseUpMsg(AWinControl, Event.x, Event.y, MouseButton, []);
LCLSendClickedMsg(AWinControl);
LCLSendMouseUpMsg(lTarget, Event.x, Event.y, MouseButton, []);
LCLSendClickedMsg(lTarget);
end;
end;
@ -577,8 +583,12 @@ end;
class procedure TCDWSCustomForm.EvMouseMove(const AWinControl: TWinControl; AWindowInfo: TX11WindowInfo;
var Event: TXMotionEvent);
var
lTarget: TWinControl;
begin
LCLSendMouseMoveMsg(AWinControl, Event.x, Event.y, []);
lTarget := FindControlWhichReceivedEvent(TCustomForm(AWinControl), AWindowInfo.Children, Event.x, Event.y);
LCLSendMouseMoveMsg(lTarget, Event.x, Event.y, []);
end;
// Top-level windows receive LM_ACTIVATE while constrols receive LM_SETFOCUS