mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 06:56:10 +02:00
customdrawnws: Improves TCDWSPanel and implements Frame3D
git-svn-id: trunk@33996 -
This commit is contained in:
parent
e2870d69ef
commit
af69ab4b0a
@ -5,8 +5,8 @@ unit customdrawn_common;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
// RTL
|
// RTL / FCL
|
||||||
Classes, SysUtils, Types, Math,
|
Classes, SysUtils, Types, Math, fpcanvas,
|
||||||
// LazUtils
|
// LazUtils
|
||||||
lazutf8,
|
lazutf8,
|
||||||
// LCL -> Use only TForm, TWinControl, TCanvas and TLazIntfImage
|
// LCL -> Use only TForm, TWinControl, TCanvas and TLazIntfImage
|
||||||
@ -37,7 +37,7 @@ type
|
|||||||
// General drawing routines
|
// General drawing routines
|
||||||
procedure DrawFocusRect(ADest: TCanvas; ADestPos: TPoint; ASize: TSize); override;
|
procedure DrawFocusRect(ADest: TCanvas; ADestPos: TPoint; ASize: TSize); override;
|
||||||
procedure DrawRaisedFrame(ADest: TCanvas; ADestPos: TPoint; ASize: TSize); override;
|
procedure DrawRaisedFrame(ADest: TCanvas; ADestPos: TPoint; ASize: TSize); override;
|
||||||
procedure DrawFrame3D(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
|
procedure DrawFrame3D(ADest: TFPCustomCanvas; ADestPos: TPoint; ASize: TSize;
|
||||||
const FrameWidth : integer; const Style : TBevelCut); override;
|
const FrameWidth : integer; const Style : TBevelCut); override;
|
||||||
procedure DrawSunkenFrame(ADest: TCanvas; ADestPos: TPoint; ASize: TSize); override;
|
procedure DrawSunkenFrame(ADest: TCanvas; ADestPos: TPoint; ASize: TSize); override;
|
||||||
procedure DrawShallowSunkenFrame(ADest: TCanvas; ADestPos: TPoint; ASize: TSize); override;
|
procedure DrawShallowSunkenFrame(ADest: TCanvas; ADestPos: TPoint; ASize: TSize); override;
|
||||||
@ -342,7 +342,7 @@ begin
|
|||||||
ADest.LineTo(ADestPos.X+ASize.cx-2, ADestPos.Y-1);
|
ADest.LineTo(ADestPos.X+ASize.cx-2, ADestPos.Y-1);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCDDrawerCommon.DrawFrame3D(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
|
procedure TCDDrawerCommon.DrawFrame3D(ADest: TFPCustomCanvas; ADestPos: TPoint; ASize: TSize;
|
||||||
const FrameWidth : integer; const Style : TBevelCut);
|
const FrameWidth : integer; const Style : TBevelCut);
|
||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
@ -357,12 +357,12 @@ begin
|
|||||||
// white lines in the left and top
|
// white lines in the left and top
|
||||||
ADest.Pen.Style := psSolid;
|
ADest.Pen.Style := psSolid;
|
||||||
ADest.Brush.Style := bsClear;
|
ADest.Brush.Style := bsClear;
|
||||||
ADest.Pen.Color := WIN2000_FRAME_GRAY;
|
ADest.Pen.FPColor := TColorToFPColor(WIN2000_FRAME_GRAY);
|
||||||
ADest.MoveTo(ARect.Left, ARect.Bottom);
|
ADest.MoveTo(ARect.Left, ARect.Bottom);
|
||||||
ADest.LineTo(ARect.Left, ARect.Top);
|
ADest.LineTo(ARect.Left, ARect.Top);
|
||||||
ADest.LineTo(ARect.Right, ARect.Top);
|
ADest.LineTo(ARect.Right, ARect.Top);
|
||||||
// Dark grey line on the right and bottom
|
// Dark grey line on the right and bottom
|
||||||
ADest.Pen.Color := WIN2000_FRAME_WHITE;
|
ADest.Pen.FPColor := TColorToFPColor(WIN2000_FRAME_WHITE);
|
||||||
ADest.MoveTo(ARect.Left, ARect.Bottom);
|
ADest.MoveTo(ARect.Left, ARect.Bottom);
|
||||||
ADest.LineTo(ARect.Right, ARect.Bottom);
|
ADest.LineTo(ARect.Right, ARect.Bottom);
|
||||||
ADest.LineTo(ARect.Right, ARect.Top);
|
ADest.LineTo(ARect.Right, ARect.Top);
|
||||||
@ -372,12 +372,12 @@ begin
|
|||||||
// white lines in the left and top
|
// white lines in the left and top
|
||||||
ADest.Pen.Style := psSolid;
|
ADest.Pen.Style := psSolid;
|
||||||
ADest.Brush.Style := bsClear;
|
ADest.Brush.Style := bsClear;
|
||||||
ADest.Pen.Color := WIN2000_FRAME_WHITE;
|
ADest.Pen.FPColor := TColorToFPColor(WIN2000_FRAME_WHITE);
|
||||||
ADest.MoveTo(ARect.Left, ARect.Bottom);
|
ADest.MoveTo(ARect.Left, ARect.Bottom);
|
||||||
ADest.LineTo(ARect.Left, ARect.Top);
|
ADest.LineTo(ARect.Left, ARect.Top);
|
||||||
ADest.LineTo(ARect.Right, ARect.Top);
|
ADest.LineTo(ARect.Right, ARect.Top);
|
||||||
// Dark grey line on the right and bottom
|
// Dark grey line on the right and bottom
|
||||||
ADest.Pen.Color := WIN2000_FRAME_GRAY;
|
ADest.Pen.FPColor := TColorToFPColor(WIN2000_FRAME_GRAY);
|
||||||
ADest.MoveTo(ARect.Left, ARect.Bottom);
|
ADest.MoveTo(ARect.Left, ARect.Bottom);
|
||||||
ADest.LineTo(ARect.Right, ARect.Bottom);
|
ADest.LineTo(ARect.Right, ARect.Bottom);
|
||||||
ADest.LineTo(ARect.Right, ARect.Top);
|
ADest.LineTo(ARect.Right, ARect.Top);
|
||||||
|
@ -5,7 +5,7 @@ unit customdrawndrawers;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, Types,
|
Classes, SysUtils, Types, fpcanvas,
|
||||||
// LCL for types
|
// LCL for types
|
||||||
Controls, Graphics, ComCtrls, ExtCtrls;
|
Controls, Graphics, ComCtrls, ExtCtrls;
|
||||||
|
|
||||||
@ -285,10 +285,10 @@ type
|
|||||||
// To set a different position to draw the control then (0, 0) use the window org of the canvas
|
// To set a different position to draw the control then (0, 0) use the window org of the canvas
|
||||||
procedure DrawControl(ADest: TCanvas; ASize: TSize;
|
procedure DrawControl(ADest: TCanvas; ASize: TSize;
|
||||||
AControl: TCDControlID; AState: TCDControlState; AStateEx: TCDControlStateEx);
|
AControl: TCDControlID; AState: TCDControlState; AStateEx: TCDControlStateEx);
|
||||||
// General drawing routines
|
// General drawing routines. The ones using TFPCustomCanvas are reusable in LCL-CustomDrawn
|
||||||
procedure DrawFocusRect(ADest: TCanvas; ADestPos: TPoint; ASize: TSize); virtual; abstract;
|
procedure DrawFocusRect(ADest: TCanvas; ADestPos: TPoint; ASize: TSize); virtual; abstract;
|
||||||
procedure DrawRaisedFrame(ADest: TCanvas; ADestPos: TPoint; ASize: TSize); virtual; abstract;
|
procedure DrawRaisedFrame(ADest: TCanvas; ADestPos: TPoint; ASize: TSize); virtual; abstract;
|
||||||
procedure DrawFrame3D(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
|
procedure DrawFrame3D(ADest: TFPCustomCanvas; ADestPos: TPoint; ASize: TSize;
|
||||||
const FrameWidth : integer; const Style : TBevelCut); virtual; abstract;
|
const FrameWidth : integer; const Style : TBevelCut); virtual; abstract;
|
||||||
procedure DrawSunkenFrame(ADest: TCanvas; ADestPos: TPoint; ASize: TSize); virtual; abstract;
|
procedure DrawSunkenFrame(ADest: TCanvas; ADestPos: TPoint; ASize: TSize); virtual; abstract;
|
||||||
procedure DrawShallowSunkenFrame(ADest: TCanvas; ADestPos: TPoint; ASize: TSize); virtual; abstract;
|
procedure DrawShallowSunkenFrame(ADest: TCanvas; ADestPos: TPoint; ASize: TSize); virtual; abstract;
|
||||||
|
@ -2321,19 +2321,19 @@ begin
|
|||||||
ARect.Right - ARect.Left, ARect.Bottom - ARect.Top);
|
ARect.Right - ARect.Left, ARect.Bottom - ARect.Top);
|
||||||
|
|
||||||
Result := 1;
|
Result := 1;
|
||||||
end;
|
end;*)
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
Function: Frame3D
|
Function: Frame3D
|
||||||
Params: none
|
Params: none
|
||||||
Returns: Nothing
|
Returns: Nothing
|
||||||
|
|
||||||
Draws a 3d border in Qt native style.
|
Draws a 3d border in the native drawer style.
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
function TQtWidgetSet.Frame3d(DC : HDC; var ARect : TRect;
|
function TCDWidgetSet.Frame3d(DC : HDC; var ARect : TRect;
|
||||||
const FrameWidth : integer; const Style : TBevelCut) : boolean;
|
const FrameWidth : integer; const Style : TBevelCut) : boolean;
|
||||||
var
|
var
|
||||||
QtDC: TQtDeviceContext;
|
LazDC: TLazCanvas;
|
||||||
begin
|
begin
|
||||||
{$ifdef VerboseQtWinAPI}
|
{$ifdef VerboseQtWinAPI}
|
||||||
DebugLn('[TQtWidgetSet.Frame3d Rect=', dbgs(ARect));
|
DebugLn('[TQtWidgetSet.Frame3d Rect=', dbgs(ARect));
|
||||||
@ -2343,23 +2343,17 @@ begin
|
|||||||
|
|
||||||
if not IsValidDC(DC) then exit;
|
if not IsValidDC(DC) then exit;
|
||||||
|
|
||||||
QtDC := TQtDeviceContext(DC);
|
LazDC := TLazCanvas(DC);
|
||||||
|
|
||||||
case Style of
|
GetDefaultDrawer().DrawFrame3D(LazDC, Point(ARect.Left, ARect.Top),
|
||||||
bvNone: ;
|
Size(ARect), FrameWidth, Style);
|
||||||
bvLowered: QtDC.qDrawWinPanel(ARect.Left, ARect.Top,
|
|
||||||
ARect.Right - ARect.Left, ARect.Bottom - ARect.Top, nil, True, FrameWidth);
|
|
||||||
bvRaised: QtDC.qDrawWinPanel(ARect.Left, ARect.Top,
|
|
||||||
ARect.Right - ARect.Left, ARect.Bottom - ARect.Top, nil, False, FrameWidth);
|
|
||||||
bvSpace: QtDC.qDrawPlainRect(ARect.Left, ARect.Top,
|
|
||||||
ARect.Right - ARect.Left, ARect.Bottom - ARect.Top, nil, FrameWidth);
|
|
||||||
end;
|
|
||||||
|
|
||||||
InflateRect(ARect, -FrameWidth, -FrameWidth);
|
InflateRect(ARect, -FrameWidth, -FrameWidth);
|
||||||
|
|
||||||
Result := True;
|
Result := True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
(*{------------------------------------------------------------------------------
|
||||||
Function: FrameRect
|
Function: FrameRect
|
||||||
Params: none
|
Params: none
|
||||||
Returns: Nothing
|
Returns: Nothing
|
||||||
|
@ -88,9 +88,9 @@ function ExtTextOut(DC: HDC; X, Y: Integer; Options: Longint; Rect: PRect; Str:
|
|||||||
|
|
||||||
function FillRect(DC: HDC; const Rect: TRect; Brush: HBRUSH): Boolean; override;
|
function FillRect(DC: HDC; const Rect: TRect; Brush: HBRUSH): Boolean; override;
|
||||||
(*function FillRgn(DC: HDC; RegionHnd: HRGN; hbr: HBRUSH): Bool; override;
|
(*function FillRgn(DC: HDC; RegionHnd: HRGN; hbr: HBRUSH): Bool; override;
|
||||||
function Frame(DC: HDC; const ARect: TRect): Integer; override;
|
function Frame(DC: HDC; const ARect: TRect): Integer; override;*)
|
||||||
function Frame3d(DC: HDC; var ARect: TRect; const FrameWidth : integer; const Style : TBevelCut): Boolean; override;
|
function Frame3d(DC: HDC; var ARect: TRect; const FrameWidth : integer; const Style : TBevelCut): Boolean; override;
|
||||||
function FrameRect(DC: HDC; const ARect: TRect; hBr: HBRUSH): Integer; override;
|
(*function FrameRect(DC: HDC; const ARect: TRect; hBr: HBRUSH): Integer; override;
|
||||||
|
|
||||||
function GetActiveWindow : HWND; override;
|
function GetActiveWindow : HWND; override;
|
||||||
function GetBitmapBits(Bitmap: HBITMAP; Count: Longint; Bits: Pointer): Longint; override;
|
function GetBitmapBits(Bitmap: HBITMAP; Count: Longint; Bits: Pointer): Longint; override;
|
||||||
|
@ -134,12 +134,10 @@ type
|
|||||||
{ TCDWSCustomPanel }
|
{ TCDWSCustomPanel }
|
||||||
|
|
||||||
TCDWSCustomPanel = class(TWSCustomPanel)
|
TCDWSCustomPanel = class(TWSCustomPanel)
|
||||||
public
|
// TPanel draws itself, so there is no need to inject a sub-control
|
||||||
class procedure CreateCDControl(const AWinControl: TCustomPanel; var ACDControlField: TCDControl);
|
|
||||||
published
|
published
|
||||||
class function CreateHandle(const AWinControl: TWinControl;
|
class function CreateHandle(const AWinControl: TWinControl;
|
||||||
const AParams: TCreateParams): TLCLIntfHandle; override;
|
const AParams: TCreateParams): TLCLIntfHandle; override;
|
||||||
class procedure ShowHide(const AWinControl: TWinControl); override;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TCDWSPanel }
|
{ TCDWSPanel }
|
||||||
@ -216,19 +214,6 @@ end; *)
|
|||||||
|
|
||||||
{ TCDWSCustomPanel }
|
{ TCDWSCustomPanel }
|
||||||
|
|
||||||
class procedure TCDWSCustomPanel.CreateCDControl(
|
|
||||||
const AWinControl: TCustomPanel; var ACDControlField: TCDControl);
|
|
||||||
begin
|
|
||||||
ACDControlField := TCDPanel.Create(AWinControl);
|
|
||||||
//TCDIntfPanel(ACDControlField).LCLButton := TButton(AWinControl);
|
|
||||||
ACDControlField.Caption := AWinControl.Caption;
|
|
||||||
ACDControlField.Parent := AWinControl;
|
|
||||||
ACDControlField.Align := alClient;
|
|
||||||
TCDPanel(ACDControlField).BevelInner := AWinControl.BevelInner;
|
|
||||||
TCDPanel(ACDControlField).BevelOuter := AWinControl.BevelOuter;
|
|
||||||
TCDPanel(ACDControlField).BevelWidth := AWinControl.BevelWidth;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
Method: TCDWSCustomPanel.CreateHandle
|
Method: TCDWSCustomPanel.CreateHandle
|
||||||
Params: None
|
Params: None
|
||||||
@ -245,18 +230,6 @@ begin
|
|||||||
lCDWinControl := TCDWinControl(Result);
|
lCDWinControl := TCDWinControl(Result);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class procedure TCDWSCustomPanel.ShowHide(const AWinControl: TWinControl);
|
|
||||||
var
|
|
||||||
lCDWinControl: TCDWinControl;
|
|
||||||
begin
|
|
||||||
lCDWinControl := TCDWinControl(AWinControl.Handle);
|
|
||||||
|
|
||||||
TCDWSWinControl.ShowHide(AWinControl);
|
|
||||||
|
|
||||||
if lCDWinControl.CDControl = nil then
|
|
||||||
CreateCDControl(TCustomPanel(AWinControl), lCDWinControl.CDControl);
|
|
||||||
end;
|
|
||||||
|
|
||||||
(*{ TCDWSCustomTrayIcon }
|
(*{ TCDWSCustomTrayIcon }
|
||||||
|
|
||||||
class function TCDWSCustomTrayIcon.Hide(const ATrayIcon: TCustomTrayIcon): Boolean;
|
class function TCDWSCustomTrayIcon.Hide(const ATrayIcon: TCustomTrayIcon): Boolean;
|
||||||
|
Loading…
Reference in New Issue
Block a user