From 6bec10272d58c24d40dbdb31050dedfe8c432b18 Mon Sep 17 00:00:00 2001 From: sekelsenmat Date: Mon, 5 Dec 2011 21:37:41 +0000 Subject: [PATCH] customdrawn: Finishes initial support for TCDPanel and TPanel git-svn-id: trunk@33982 - --- lcl/customdrawn_common.pas | 16 +++++++ lcl/customdrawncontrols.pas | 44 +++++++++++++++++++ lcl/customdrawndrawers.pas | 6 ++- .../customdrawn/customdrawnwsextctrls.pas | 29 ++++++++---- lcl/interfaces/lcl.lpk | 7 ++- 5 files changed, 92 insertions(+), 10 deletions(-) diff --git a/lcl/customdrawn_common.pas b/lcl/customdrawn_common.pas index 4afa6e9aa1..1658082b4e 100644 --- a/lcl/customdrawn_common.pas +++ b/lcl/customdrawn_common.pas @@ -78,6 +78,9 @@ type // TCDGroupBox procedure DrawGroupBox(ADest: TCanvas; ASize: TSize; AState: TCDControlState; AStateEx: TCDControlStateEx); override; + // TCDPanel + procedure DrawPanel(ADest: TCanvas; ASize: TSize; + AState: TCDControlState; AStateEx: TCDControlStateEx); override; // =================================== // Additional Tab // =================================== @@ -1066,6 +1069,19 @@ begin ADest.TextOut(FCaptionMiddle+3, 0, lCaption); end; +procedure TCDDrawerCommon.DrawPanel(ADest: TCanvas; ASize: TSize; + AState: TCDControlState; AStateEx: TCDControlStateEx); +begin + // Background + ADest.Brush.Color := Palette.BtnFace; + ADest.Brush.Style := bsSolid; + ADest.Pen.Style := psClear; + ADest.FillRect(0, 0, ASize.cx, ASize.cy); + + // The frame + DrawRaisedFrame(ADest, Point(0, 0), ASize); +end; + procedure TCDDrawerCommon.DrawStaticText(ADest: TCanvas; ASize: TSize; AState: TCDControlState; AStateEx: TCDControlStateEx); var diff --git a/lcl/customdrawncontrols.pas b/lcl/customdrawncontrols.pas index 19ebd53f10..dd19925c1f 100644 --- a/lcl/customdrawncontrols.pas +++ b/lcl/customdrawncontrols.pas @@ -351,6 +351,23 @@ type property TabStop default False; end; + { TCDPanel } + + TCDPanel = class(TCDControl) + private + function GetControlId: TCDControlID; override; + protected + procedure RealSetText(const Value: TCaption); override; // to update on caption changes + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + published + //property AutoSize; + property DrawStyle; + property Caption; + property TabStop default False; + end; + // =================================== // Additional Tab // =================================== @@ -619,6 +636,33 @@ implementation resourcestring sTABSHEET_DEFAULT_NAME = 'CTabSheet'; +{ TCDPanel } + +function TCDPanel.GetControlId: TCDControlID; +begin + Result := cidPanel; +end; + +procedure TCDPanel.RealSetText(const Value: TCaption); +begin + inherited RealSetText(Value); + if not (csLoading in ComponentState) then Invalidate; +end; + +constructor TCDPanel.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + Width := 170; + Height := 50; + TabStop := False; + AutoSize := False; +end; + +destructor TCDPanel.Destroy; +begin + inherited Destroy; +end; + { TCDScrollableControl } procedure TCDScrollableControl.SetScrollBars(AValue: TScrollStyle); diff --git a/lcl/customdrawndrawers.pas b/lcl/customdrawndrawers.pas index 18a03e152d..afcb980290 100644 --- a/lcl/customdrawndrawers.pas +++ b/lcl/customdrawndrawers.pas @@ -212,7 +212,7 @@ type cidControl, // Standard cidMenu, cidPopUp, cidButton, cidEdit, cidCheckBox, cidRadioButton, - cidListBox, cidComboBox, cidScrollBar, cidGroupBox, + cidListBox, cidComboBox, cidScrollBar, cidGroupBox, cidPanel, // Additional cidStaticText, // Common Controls @@ -319,6 +319,9 @@ type // TCDGroupBox procedure DrawGroupBox(ADest: TCanvas; ASize: TSize; AState: TCDControlState; AStateEx: TCDControlStateEx); virtual; abstract; + // TCDPanel + procedure DrawPanel(ADest: TCanvas; ASize: TSize; + AState: TCDControlState; AStateEx: TCDControlStateEx); virtual; abstract; // =================================== // Additional Tab // =================================== @@ -619,6 +622,7 @@ begin cidRadioButton:DrawRadioButton(ADest, ASize, AState, AStateEx); cidScrollBar: DrawScrollBar(ADest, ASize, AState, TCDPositionedCStateEx(AStateEx)); cidGroupBox: DrawGroupBox(ADest, ASize, AState, AStateEx); + cidPanel: DrawPanel(ADest, ASize, AState, AStateEx); // cidStaticText: DrawStaticText(ADest, ASize, AState, AStateEx); // diff --git a/lcl/interfaces/customdrawn/customdrawnwsextctrls.pas b/lcl/interfaces/customdrawn/customdrawnwsextctrls.pas index 75d1c06f70..a0a15580ff 100644 --- a/lcl/interfaces/customdrawn/customdrawnwsextctrls.pas +++ b/lcl/interfaces/customdrawn/customdrawnwsextctrls.pas @@ -34,7 +34,7 @@ uses ImgList, // Widgetset WSExtCtrls, WSProc, WSLCLClasses, - customdrawncontrols; + customdrawncontrols, customdrawnwscontrols, customdrawnproc; type { TCDWSPage } @@ -139,6 +139,7 @@ type published class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override; + class procedure ShowHide(const AWinControl: TWinControl); override; end; { TCDWSPanel } @@ -218,7 +219,11 @@ end; *) class procedure TCDWSCustomPanel.CreateCDControl( const AWinControl: TWinControl; var ACDControlField: TCDControl); begin - + ACDControlField := TCDPanel.Create(AWinControl); +// TCDIntfButton(ACDControlField).LCLButton := TButton(AWinControl); + ACDControlField.Caption := AWinControl.Caption; + ACDControlField.Parent := AWinControl; + ACDControlField.Align := alClient; end; {------------------------------------------------------------------------------ @@ -230,15 +235,23 @@ end; ------------------------------------------------------------------------------} class function TCDWSCustomPanel.CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; +var + lCDWinControl: TCDWinControl; begin -{ QtFrame := TQtFrame.Create(AWinControl, AParams); - QtFrame.AttachEvents; + Result := TCDWSWinControl.CreateHandle(AWinControl, AParams); + lCDWinControl := TCDWinControl(Result); +end; - // Set's initial properties - QtFrame.setFrameShape(TBorderStyleToQtFrameShapeMap[TCustomPanel(AWinControl).BorderStyle]); +class procedure TCDWSCustomPanel.ShowHide(const AWinControl: TWinControl); +var + lCDWinControl: TCDWinControl; +begin + lCDWinControl := TCDWinControl(AWinControl.Handle); - // Return the Handle - Result := TLCLIntfHandle(QtFrame);} + TCDWSWinControl.ShowHide(AWinControl); + + if lCDWinControl.CDControl = nil then + CreateCDControl(AWinControl, lCDWinControl.CDControl); end; (*{ TCDWSCustomTrayIcon } diff --git a/lcl/interfaces/lcl.lpk b/lcl/interfaces/lcl.lpk index 18ba3526a3..2acf3bd2ea 100644 --- a/lcl/interfaces/lcl.lpk +++ b/lcl/interfaces/lcl.lpk @@ -114,7 +114,7 @@ end;"/> - + @@ -1898,6 +1898,11 @@ end;"/> + + + + +