diff --git a/lcl/customdrawn_common.pas b/lcl/customdrawn_common.pas index cbbfc1300b..6eb9ac9e2f 100644 --- a/lcl/customdrawn_common.pas +++ b/lcl/customdrawn_common.pas @@ -5,8 +5,8 @@ unit customdrawn_common; interface uses - // RTL - Classes, SysUtils, Types, Math, + // RTL / FCL + Classes, SysUtils, Types, Math, fpcanvas, // LazUtils lazutf8, // LCL -> Use only TForm, TWinControl, TCanvas and TLazIntfImage @@ -37,7 +37,7 @@ type // General drawing routines procedure DrawFocusRect(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; procedure DrawSunkenFrame(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); 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); var i: Integer; @@ -357,12 +357,12 @@ begin // white lines in the left and top ADest.Pen.Style := psSolid; ADest.Brush.Style := bsClear; - ADest.Pen.Color := WIN2000_FRAME_GRAY; + ADest.Pen.FPColor := TColorToFPColor(WIN2000_FRAME_GRAY); ADest.MoveTo(ARect.Left, ARect.Bottom); ADest.LineTo(ARect.Left, ARect.Top); ADest.LineTo(ARect.Right, ARect.Top); // 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.LineTo(ARect.Right, ARect.Bottom); ADest.LineTo(ARect.Right, ARect.Top); @@ -372,12 +372,12 @@ begin // white lines in the left and top ADest.Pen.Style := psSolid; ADest.Brush.Style := bsClear; - ADest.Pen.Color := WIN2000_FRAME_WHITE; + ADest.Pen.FPColor := TColorToFPColor(WIN2000_FRAME_WHITE); ADest.MoveTo(ARect.Left, ARect.Bottom); ADest.LineTo(ARect.Left, ARect.Top); ADest.LineTo(ARect.Right, ARect.Top); // 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.LineTo(ARect.Right, ARect.Bottom); ADest.LineTo(ARect.Right, ARect.Top); diff --git a/lcl/customdrawndrawers.pas b/lcl/customdrawndrawers.pas index 79da4450f2..333e485c38 100644 --- a/lcl/customdrawndrawers.pas +++ b/lcl/customdrawndrawers.pas @@ -5,7 +5,7 @@ unit customdrawndrawers; interface uses - Classes, SysUtils, Types, + Classes, SysUtils, Types, fpcanvas, // LCL for types 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 procedure DrawControl(ADest: TCanvas; ASize: TSize; 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 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; procedure DrawSunkenFrame(ADest: TCanvas; ADestPos: TPoint; ASize: TSize); virtual; abstract; procedure DrawShallowSunkenFrame(ADest: TCanvas; ADestPos: TPoint; ASize: TSize); virtual; abstract; diff --git a/lcl/interfaces/customdrawn/customdrawnwinapi.inc b/lcl/interfaces/customdrawn/customdrawnwinapi.inc index 58a80720f6..42d7ef8886 100644 --- a/lcl/interfaces/customdrawn/customdrawnwinapi.inc +++ b/lcl/interfaces/customdrawn/customdrawnwinapi.inc @@ -2321,19 +2321,19 @@ begin ARect.Right - ARect.Left, ARect.Bottom - ARect.Top); Result := 1; -end; +end;*) {------------------------------------------------------------------------------ Function: Frame3D Params: none 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; var - QtDC: TQtDeviceContext; + LazDC: TLazCanvas; begin {$ifdef VerboseQtWinAPI} DebugLn('[TQtWidgetSet.Frame3d Rect=', dbgs(ARect)); @@ -2343,23 +2343,17 @@ begin if not IsValidDC(DC) then exit; - QtDC := TQtDeviceContext(DC); + LazDC := TLazCanvas(DC); - case Style of - bvNone: ; - 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; + GetDefaultDrawer().DrawFrame3D(LazDC, Point(ARect.Left, ARect.Top), + Size(ARect), FrameWidth, Style); InflateRect(ARect, -FrameWidth, -FrameWidth); + Result := True; end; -{------------------------------------------------------------------------------ +(*{------------------------------------------------------------------------------ Function: FrameRect Params: none Returns: Nothing diff --git a/lcl/interfaces/customdrawn/customdrawnwinapih.inc b/lcl/interfaces/customdrawn/customdrawnwinapih.inc index ccc3ce975f..2a5ac6ec8d 100644 --- a/lcl/interfaces/customdrawn/customdrawnwinapih.inc +++ b/lcl/interfaces/customdrawn/customdrawnwinapih.inc @@ -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 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 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 GetBitmapBits(Bitmap: HBITMAP; Count: Longint; Bits: Pointer): Longint; override; diff --git a/lcl/interfaces/customdrawn/customdrawnwsextctrls.pas b/lcl/interfaces/customdrawn/customdrawnwsextctrls.pas index cf3208e7e4..62a884d44d 100644 --- a/lcl/interfaces/customdrawn/customdrawnwsextctrls.pas +++ b/lcl/interfaces/customdrawn/customdrawnwsextctrls.pas @@ -134,12 +134,10 @@ type { TCDWSCustomPanel } TCDWSCustomPanel = class(TWSCustomPanel) - public - class procedure CreateCDControl(const AWinControl: TCustomPanel; var ACDControlField: TCDControl); + // TPanel draws itself, so there is no need to inject a sub-control published class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override; - class procedure ShowHide(const AWinControl: TWinControl); override; end; { TCDWSPanel } @@ -216,19 +214,6 @@ end; *) { 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 Params: None @@ -245,18 +230,6 @@ begin lCDWinControl := TCDWinControl(Result); 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 } class function TCDWSCustomTrayIcon.Hide(const ATrayIcon: TCustomTrayIcon): Boolean;