customdrawnws: Mode debug info and fixes an issue in the win32 backend painting, still missing something however

git-svn-id: trunk@33670 -
This commit is contained in:
sekelsenmat 2011-11-21 16:27:17 +00:00
parent 65165e6ebb
commit d8e9ca3b05
3 changed files with 28 additions and 25 deletions

View File

@ -64,7 +64,7 @@ begin
Result := IsValidDC(DC); Result := IsValidDC(DC);
if Result then if Result then
QPainter_drawChord(TQtDeviceContext(DC).Widget, x1, y1, x2, y2, Angle1, Angle2); QPainter_drawChord(TQtDeviceContext(DC).Widget, x1, y1, x2, y2, Angle1, Angle2);
end; end;*)
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
Function: BeginPaint Function: BeginPaint
@ -74,15 +74,14 @@ end;
This function is Called: This function is Called:
- Once on every OnPaint event - Once on every OnPaint event
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
function TQtWidgetSet.BeginPaint(Handle: hWnd; Var PS : TPaintStruct): hdc; function TCDWidgetSet.BeginPaint(Handle: hWnd; Var PS : TPaintStruct): hdc;
var var
Widget: TQtWidget; DC: TLazCanvas;
DC: TQtDeviceContext;
begin begin
{$ifdef VerboseQtWinAPI} {$ifdef VerboseCDWinAPI}
WriteLn('Trace:> [WinAPI BeginPaint] Handle=', dbghex(Handle)); DebugLn('Trace:> [WinAPI BeginPaint] Handle=', dbghex(Handle));
{$endif} {$endif}
Widget := TQtWidget(Handle); (* Widget := TQtWidget(Handle);
if Widget <> nil then if Widget <> nil then
DC := TQtDeviceContext.Create(Widget.PaintData.PaintWidget, True) DC := TQtDeviceContext.Create(Widget.PaintData.PaintWidget, True)
else else
@ -113,9 +112,9 @@ begin
{$ifdef VerboseQtWinAPI} {$ifdef VerboseQtWinAPI}
WriteLn('Trace:< [WinAPI BeginPaint] Result=', dbghex(Result)); WriteLn('Trace:< [WinAPI BeginPaint] Result=', dbghex(Result));
{$endif} {$endif}*)
end; end;
(*
function TQtWidgetSet.BitBlt(DestDC: HDC; X, Y, Width, Height: Integer; SrcDC: HDC; XSrc, YSrc: Integer; Rop: DWORD): Boolean; function TQtWidgetSet.BitBlt(DestDC: HDC; X, Y, Width, Height: Integer; SrcDC: HDC; XSrc, YSrc: Integer; Rop: DWORD): Boolean;
begin begin
{$ifdef VerboseQtWinAPI} {$ifdef VerboseQtWinAPI}
@ -482,7 +481,7 @@ function TQtWidgetSet.CreateCaret(Handle: HWND; Bitmap: hBitmap; Width, Height:
begin begin
Result := (Handle <> 0) and Result := (Handle <> 0) and
QtCaret.CreateCaret(TQtWidget(Handle), Bitmap, Width, Height); QtCaret.CreateCaret(TQtWidget(Handle), Bitmap, Width, Height);
end; end;*)
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
Function: CreateCompatibleDC Function: CreateCompatibleDC
@ -491,14 +490,14 @@ end;
Creates a memory device context (DC) compatible with the specified device. Creates a memory device context (DC) compatible with the specified device.
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
function TQtWidgetSet.CreateCompatibleDC(DC: HDC): HDC; function TCDWidgetSet.CreateCompatibleDC(DC: HDC): HDC;
begin begin
{$ifdef VerboseQtWinAPI} {$ifdef VerboseCDWinAPI}
WriteLn('[WinAPI CreateCompatibleDC] DC: ', dbghex(DC)); WriteLn('[WinAPI CreateCompatibleDC] DC: ', dbghex(DC));
{$endif} {$endif}
Result := HDC(TQtDeviceContext.Create(nil, True)); Result := 0;//HDC(TQtDeviceContext.Create(nil, True));
end; end;
(*
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
Function: CreateEllipticRgn Function: CreateEllipticRgn
Params: p1 - X position of the top-left corner Params: p1 - X position of the top-left corner

View File

@ -28,10 +28,10 @@
//##apiwiz##sps## // Do not remove, no wizard declaration before this line //##apiwiz##sps## // Do not remove, no wizard declaration before this line
(* (*
function Arc(DC: HDC; Left,Top,Right,Bottom,angle1,angle2 : Integer): Boolean; override; function Arc(DC: HDC; Left,Top,Right,Bottom,angle1,angle2 : Integer): Boolean; override;
function AngleChord(DC: HDC; x1, y1, x2, y2, angle1, angle2: Integer): Boolean; override; function AngleChord(DC: HDC; x1, y1, x2, y2, angle1, angle2: Integer): Boolean; override;*)
function BeginPaint(Handle: hWnd; Var PS : TPaintStruct) : hdc; override; function BeginPaint(Handle: hWnd; Var PS : TPaintStruct) : hdc; override;
function BitBlt(DestDC: HDC; X, Y, Width, Height: Integer; SrcDC: HDC; XSrc, YSrc: Integer; Rop: DWORD): Boolean; override; (*function BitBlt(DestDC: HDC; X, Y, Width, Height: Integer; SrcDC: HDC; XSrc, YSrc: Integer; Rop: DWORD): Boolean; override;
function CallNextHookEx(hHk: HHOOK; ncode : Integer; wParam: WParam; lParam : LParam) : Integer; override; function CallNextHookEx(hHk: HHOOK; ncode : Integer; wParam: WParam; lParam : LParam) : Integer; override;
function CallWindowProc(lpPrevWndFunc : TFarProc; Handle : HWND; Msg : UINT; wParam: WParam; lParam : lParam) : Integer; override; function CallWindowProc(lpPrevWndFunc : TFarProc; Handle : HWND; Msg : UINT; wParam: WParam; lParam : lParam) : Integer; override;
@ -52,9 +52,9 @@ function CombineRgn(Dest, Src1, Src2: HRGN; fnCombineMode: Longint): Longint; o
function CreateBitmap(Width, Height: Integer; Planes, BitCount: Longint; BitmapBits: Pointer): HBITMAP; override; function CreateBitmap(Width, Height: Integer; Planes, BitCount: Longint; BitmapBits: Pointer): HBITMAP; override;
function CreateBrushIndirect(const LogBrush: TLogBrush): HBRUSH; override; function CreateBrushIndirect(const LogBrush: TLogBrush): HBRUSH; override;
function CreateCaret(Handle : HWND; Bitmap : hBitmap; Width, Height : Integer) : Boolean; override; function CreateCaret(Handle : HWND; Bitmap : hBitmap; Width, Height : Integer) : Boolean; override;
function CreateCompatibleBitmap(DC: HDC; Width, Height: Integer): HBITMAP; override; function CreateCompatibleBitmap(DC: HDC; Width, Height: Integer): HBITMAP; override;*)
function CreateCompatibleDC(DC: HDC): HDC; override; function CreateCompatibleDC(DC: HDC): HDC; override;
function CreateEllipticRgn(p1, p2, p3, p4: Integer): HRGN; override; (*function CreateEllipticRgn(p1, p2, p3, p4: Integer): HRGN; override;
function CreateFontIndirect(const LogFont: TLogFont): HFONT; override; function CreateFontIndirect(const LogFont: TLogFont): HFONT; override;
function CreateFontIndirectEx(const LogFont: TLogFont; const LongFontName: string): HFONT; override; function CreateFontIndirectEx(const LogFont: TLogFont; const LongFontName: string): HFONT; override;
function CreateIconIndirect(IconInfo: PIconInfo): HICON; override; function CreateIconIndirect(IconInfo: PIconInfo): HICON; override;

View File

@ -260,6 +260,10 @@ Var
end; end;
if (WindowInfo^.Canvas = nil) then WindowInfo^.Canvas := TLazCanvas.Create(WindowInfo^.Image); if (WindowInfo^.Canvas = nil) then WindowInfo^.Canvas := TLazCanvas.Create(WindowInfo^.Image);
{$ifdef VerboseCDWinAPI}
DebugLn(Format('[SendPaintMessage] WindowInfo^.Canvas=%s', [dbghex(PtrInt(WindowInfo^.Canvas))]));
{$endif}
// main processing // main processing
WinProcess := false; WinProcess := false;
try try
@ -277,32 +281,32 @@ Var
GetLCLClientBoundsOffset(lWinControl, ORect); GetLCLClientBoundsOffset(lWinControl, ORect);
PaintMsg.Msg := LM_PAINT; PaintMsg.Msg := LM_PAINT;
PaintMsg.PaintStruct := @PS; PaintMsg.PaintStruct := @PS;
PaintMsg.DC := DC; PaintMsg.DC := HDC(WindowInfo^.Canvas);
if not needParentPaint then if not needParentPaint then
begin begin
// send through message to allow message override, moreover use SendMessage // send through message to allow message override, moreover use SendMessage
// to allow subclass window proc override this message too // to allow subclass window proc override this message too
Include(TWinControlAccess(lWinControl).FWinControlFlags, wcfEraseBackground); Include(TWinControlAccess(lWinControl).FWinControlFlags, wcfEraseBackground);
Windows.SendMessageW(lWinControl.Handle, WM_ERASEBKGND, Windows.WPARAM(PaintMsg.DC), 0); Windows.SendMessageW(lWinControl.Handle, WM_ERASEBKGND, Windows.WPARAM(DC), 0);
Exclude(TWinControlAccess(lWinControl).FWinControlFlags, wcfEraseBackground); Exclude(TWinControlAccess(lWinControl).FWinControlFlags, wcfEraseBackground);
end; end;
if (ControlDC = 0) or not needParentPaint then if (ControlDC = 0) or not needParentPaint then
begin begin
DCIndex := Windows.SaveDC(PaintMsg.DC); DCIndex := Windows.SaveDC(DC);
{$ifdef DEBUG_WINDOW_ORG} {$ifdef DEBUG_WINDOW_ORG}
LCLIntf.GetWindowOrgEx(PaintMsg.DC, @WindowOrg); LCLIntf.GetWindowOrgEx(DC, @WindowOrg);
DebugLn( DebugLn(
Format(':> [SendPaintMessage 2] Control=%s DC=%d Moving WindowOrg from %d,%d by DX=%d DY=%d', Format(':> [SendPaintMessage 2] Control=%s DC=%d Moving WindowOrg from %d,%d by DX=%d DY=%d',
[lWinControl.Name, PaintMsg.DC, WindowOrg.X, WindowOrg.Y, -parLeft, -parTop])); [lWinControl.Name, PaintMsg.DC, WindowOrg.X, WindowOrg.Y, -parLeft, -parTop]));
{$endif} {$endif}
MoveWindowOrgEx(PaintMsg.DC, ORect.Left, ORect.Top); MoveWindowOrgEx(DC, ORect.Left, ORect.Top);
DeliverMessage(lWinControl, PaintMsg); DeliverMessage(lWinControl, PaintMsg);
Windows.RestoreDC(PaintMsg.DC, DCIndex); Windows.RestoreDC(DC, DCIndex);
{$ifdef DEBUG_WINDOW_ORG} {$ifdef DEBUG_WINDOW_ORG}
LCLIntf.GetWindowOrgEx(PaintMsg.DC, @WindowOrg); LCLIntf.GetWindowOrgEx(DC, @WindowOrg);
DebugLn( DebugLn(
Format(':> [SendPaintMessage 3] Control=%s DC=%d WindowOrg=%d,%d', Format(':> [SendPaintMessage 3] Control=%s DC=%d WindowOrg=%d,%d',
[lWinControl.Name, PaintMsg.DC, WindowOrg.X, WindowOrg.Y])); [lWinControl.Name, PaintMsg.DC, WindowOrg.X, WindowOrg.Y]));