mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-10-01 03:49:22 +02:00
implements Canvas.DrawFocusRect in windows and gtk issue #2095
git-svn-id: trunk@9290 -
This commit is contained in:
parent
d6e20f3d08
commit
675ab2b3f5
@ -943,6 +943,7 @@ type
|
||||
Procedure CopyRect(const Dest: TRect; SrcCanvas: TCanvas;
|
||||
const Source: TRect); virtual;
|
||||
Procedure Draw(X,Y: Integer; SrcGraphic: TGraphic); virtual;
|
||||
Procedure DrawFocusRect(const ARect: TRect); virtual;
|
||||
procedure StretchDraw(const DestRect: TRect; SrcGraphic: TGraphic); virtual;
|
||||
procedure Ellipse(const ARect: TRect); // already in fpcanvas
|
||||
procedure Ellipse(x1, y1, x2, y2: Integer); virtual; // already in fpcanvas
|
||||
|
@ -32,6 +32,17 @@ begin
|
||||
StretchDraw(ARect,SrcGraphic);
|
||||
end;
|
||||
|
||||
{-----------------------------------------------}
|
||||
{-- TCanvas.DrawFocusRect --}
|
||||
{-----------------------------------------------}
|
||||
procedure TCanvas.DrawFocusRect(const ARect: TRect);
|
||||
begin
|
||||
Changing;
|
||||
RequiredState([csHandleValid, csBrushValid]);
|
||||
LCLIntf.DrawFocusRect(FHandle, ARect);
|
||||
Changed;
|
||||
end;
|
||||
|
||||
{-----------------------------------------------}
|
||||
{-- TCanvas.StretchDraw --}
|
||||
{-----------------------------------------------}
|
||||
|
@ -201,6 +201,11 @@ begin
|
||||
Result := False;
|
||||
end;
|
||||
|
||||
function TWidgetset.DrawFocusRect(DC: HDC; const Rect: TRect): boolean;
|
||||
begin
|
||||
Result := false;
|
||||
end;
|
||||
|
||||
function TWidgetSet.DrawEdge(DC: HDC; var Rect: TRect; edge: Cardinal; grfFlags: Cardinal): Boolean;
|
||||
Begin
|
||||
Result := False;
|
||||
|
@ -171,6 +171,11 @@ Begin
|
||||
Result := WidgetSet.DrawFrameControl(DC, Rect, uType, uState);
|
||||
end;
|
||||
|
||||
function DrawFocusRect(DC: HDC; const Rect: TRect): boolean;
|
||||
begin
|
||||
Result := WidgetSet.DrawFocusRect(DC, Rect);
|
||||
end;
|
||||
|
||||
function DrawEdge(DC: HDC; var Rect: TRect; edge: Cardinal; grfFlags: Cardinal): Boolean;
|
||||
Begin
|
||||
Result := WidgetSet.DrawEdge(DC, Rect, edge, grfFlags);
|
||||
|
@ -77,6 +77,7 @@ function DeleteObject(GDIObject: HGDIOBJ): Boolean; {$IFDEF IF_BASE_MEMBER}virtu
|
||||
function DestroyCaret(Handle : HWND): Boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
||||
function DPtoLP(DC: HDC; var Points; Count: Integer): BOOL; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
||||
function DrawFrameControl(DC: HDC; var Rect : TRect; uType, uState : Cardinal) : Boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
||||
function DrawFocusRect(DC: HDC; const Rect: TRect): Boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
||||
function DrawEdge(DC: HDC; var Rect: TRect; edge: Cardinal; grfFlags: Cardinal): Boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
||||
function DrawText(DC: HDC; Str: PChar; Count: Integer; var Rect: TRect; Flags: Cardinal): Integer; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
|
||||
|
||||
|
@ -2595,6 +2595,80 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function TGTKWidgetSet.DrawFocusRect(DC: HDC; const Rect: TRect): boolean;
|
||||
var
|
||||
Origin: TPoint;
|
||||
|
||||
procedure DrawPixel(X1,Y1: Integer);
|
||||
begin
|
||||
inc(X1,Origin.X);
|
||||
inc(Y1,Origin.Y);
|
||||
gdk_draw_point(TDeviceContext(DC).Drawable, TDeviceContext(DC).GC, X1, Y1);
|
||||
end;
|
||||
|
||||
procedure DrawVertLine(X1,Y1,Y2: integer);
|
||||
begin
|
||||
if Y2<Y1 then
|
||||
while Y2<Y1 do begin
|
||||
DrawPixel(X1, Y1);
|
||||
dec(Y1, 2);
|
||||
end
|
||||
else
|
||||
while Y1<Y2 do begin
|
||||
DrawPixel(X1, Y1);
|
||||
inc(Y1, 2);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure DrawHorzLine(X1,Y1,X2: integer);
|
||||
begin
|
||||
if X2<X1 then
|
||||
while X2<X1 do begin
|
||||
DrawPixel(X1, Y1);
|
||||
dec(X1, 2);
|
||||
end
|
||||
else
|
||||
while X1<X2 do begin
|
||||
DrawPixel(X1, Y1);
|
||||
inc(X1, 2);
|
||||
end;
|
||||
end;
|
||||
|
||||
var
|
||||
OldROP: Integer;
|
||||
APen, TempPen: HPEN;
|
||||
LogPen : TLogPen;
|
||||
begin
|
||||
Result := False;
|
||||
if IsValidDC(DC) then begin
|
||||
with LogPen do begin
|
||||
lopnStyle := PS_DOT;
|
||||
lopnWidth.X := 2;
|
||||
lopnColor := clWhite;
|
||||
end;
|
||||
APen := CreatePenIndirect(LogPen);
|
||||
TempPen := SelectObject(DC, APen);
|
||||
OldRop := SetROP2(DC, R2_XORPEN);
|
||||
|
||||
Origin := GetDCOffset(TDeviceContext(DC));
|
||||
try
|
||||
|
||||
with Rect do begin
|
||||
DrawHorzLine(Left, Top, Right-1);
|
||||
DrawVertLine(Right-1, Top, Bottom-1);
|
||||
DrawHorzLine(Right-1, Bottom-1, Left);
|
||||
DrawVertLine(Left, Bottom-1, Top);
|
||||
end;
|
||||
|
||||
Result := True;
|
||||
finally
|
||||
SelectObject(DC, TempPen);
|
||||
DeleteObject(APen);
|
||||
SetROP2(DC, OldROP);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Function: DrawEdge
|
||||
Params: DC: HDC; var Rect: TRect; edge: Cardinal; grfFlags: Cardinal
|
||||
@ -4417,14 +4491,14 @@ begin
|
||||
if ClientWidget<>nil then begin
|
||||
DebugLn('GetClientRect Widget=',DbgS(handle),
|
||||
' Client=',DbgS(ClientWidget),
|
||||
' WindowSize=',ARect.Right,',',ARect.Bottom,
|
||||
' Allocation=',ClientWidget^.Allocation.Width,',',ClientWidget^.Allocation.Height
|
||||
' WindowSize=',dbgs(ARect.Right),',',dbgs(ARect.Bottom),
|
||||
' Allocation=',dbgs(ClientWidget^.Allocation.Width),',',dbgs(ClientWidget^.Allocation.Height)
|
||||
);
|
||||
end else begin
|
||||
DebugLn('GetClientRect Widget=',DbgS(handle),
|
||||
' Client=',DbgS(ClientWidget),
|
||||
' WindowSize=',ARect.Right,',',ARect.Bottom,
|
||||
' Allocation=',Widget^.Allocation.Width,',',Widget^.Allocation.Height
|
||||
' WindowSize=',dbgs(ARect.Right),',',dbgs(ARect.Bottom),
|
||||
' Allocation=',dbgs(Widget^.Allocation.Width),',',dbgs(Widget^.Allocation.Height)
|
||||
);
|
||||
end;
|
||||
{$EndIf}
|
||||
|
@ -66,6 +66,7 @@ function DeleteDC(hDC: HDC): Boolean; override;
|
||||
function DeleteObject(GDIObject: HGDIOBJ): Boolean; override;
|
||||
function DestroyCaret(Handle : HWND): Boolean; override;
|
||||
Function DrawFrameControl(DC: HDC; var Rect : TRect; uType, uState : Cardinal) : Boolean; override;
|
||||
function DrawFocusRect(DC: HDC; const Rect: TRect): boolean; override;
|
||||
function DrawEdge(DC: HDC; var ARect: TRect; Edge: Cardinal; grfFlags: Cardinal): Boolean; override;
|
||||
function DrawText(DC: HDC; Str: PChar; Count: Integer; var Rect: TRect; Flags: Cardinal): Integer; Override;
|
||||
|
||||
|
@ -1080,6 +1080,15 @@ Begin
|
||||
end;
|
||||
End;
|
||||
|
||||
function TWin32WidgetSet.DrawFocusRect(DC: HDC; const Rect: TRect): boolean;
|
||||
var
|
||||
lRect: Windows.RECT;
|
||||
begin
|
||||
{$message warn TWin32WidgetSet.FrameRect TODO: optimize ARect copying?}
|
||||
lRect:=Rect;
|
||||
Result:= Windows.DrawFocusRect(DC, lRect);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Method: DrawEdge
|
||||
Params: DC - handle to device context
|
||||
|
@ -63,6 +63,7 @@ function DeleteDC(HDC: HDC): Boolean; Override;
|
||||
function DeleteObject(GDIObject: HGDIOBJ): Boolean; Override;
|
||||
function DestroyCaret(Handle: HWND): Boolean; Override;
|
||||
function DrawFrameControl(DC: HDC; Var Rect: TRect; UType, UState: Cardinal): Boolean; Override;
|
||||
function DrawFocusRect(DC: HDC; const Rect: TRect): boolean; override;
|
||||
function DrawEdge(DC: HDC; Var Rect: TRect; Edge: Cardinal; GrfFlags: Cardinal): Boolean; Override;
|
||||
function DrawText(DC: HDC; Str: PChar; Count: Integer; var Rect: TRect; Flags: Cardinal): Integer; Override;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user