From 11ba71dc58496a70016e267017453b7d40f551f7 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Sun, 4 Dec 2016 17:28:50 +0000 Subject: [PATCH] jvcllaz: Add TJvXPCheckbox git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5405 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../jvcllaz/examples/JvXPBar/MainFrm.lfm | 4 +- .../jvcllaz/examples/JvXPBar/MainFrm.pas | 4 +- components/jvcllaz/packages/JvXPBarLaz.lpk | 6 +- components/jvcllaz/packages/JvXPBarLaz.pas | 2 +- components/jvcllaz/packages/JvXPBarReg.pp | 11 +- components/jvcllaz/resource/JvXPBar.res | Bin 0 -> 6180 bytes components/jvcllaz/resource/JvXPBarLaz.lrs | 23 +- components/jvcllaz/resource/JvXPCore.res | Bin 0 -> 4200 bytes .../jvcllaz/resource/JvxCheckListBox.res | Bin 0 -> 2080 bytes components/jvcllaz/run/JvXPBar.pas | 14 +- components/jvcllaz/run/JvXPButtons.pas | 9 +- components/jvcllaz/run/JvXPCheckCtrls.pas | 456 ++++++++++++++++++ components/jvcllaz/run/JvXPCore.pas | 42 +- components/jvcllaz/run/JvXPCoreUtils.pas | 7 +- 14 files changed, 535 insertions(+), 43 deletions(-) create mode 100644 components/jvcllaz/resource/JvXPBar.res create mode 100644 components/jvcllaz/resource/JvXPCore.res create mode 100644 components/jvcllaz/resource/JvxCheckListBox.res create mode 100644 components/jvcllaz/run/JvXPCheckCtrls.pas diff --git a/components/jvcllaz/examples/JvXPBar/MainFrm.lfm b/components/jvcllaz/examples/JvXPBar/MainFrm.lfm index 1d87954dd..ebd8c570f 100644 --- a/components/jvcllaz/examples/JvXPBar/MainFrm.lfm +++ b/components/jvcllaz/examples/JvXPBar/MainFrm.lfm @@ -320,14 +320,14 @@ object frmMain: TfrmMain TabOrder = 3 OnClick = btnToggleVisibleModeClick end - object chkGrouped: TCheckBox + object chkGrouped: TJvXPCheckbox Left = 24 Height = 19 Top = 152 Width = 66 Caption = 'Grouped' - OnClick = chkGroupedClick TabOrder = 4 + OnClick = chkGroupedClick end end object StatusBar1: TStatusBar diff --git a/components/jvcllaz/examples/JvXPBar/MainFrm.pas b/components/jvcllaz/examples/JvXPBar/MainFrm.pas index c36fde649..071d85fc9 100644 --- a/components/jvcllaz/examples/JvXPBar/MainFrm.pas +++ b/components/jvcllaz/examples/JvXPBar/MainFrm.pas @@ -7,7 +7,7 @@ interface uses SysUtils, Classes, Graphics, Controls, Forms, Dialogs, JvXPCore, JvXPBar, JvXPContainer, ImgList, ActnList, ExtCtrls, - StdCtrls, ComCtrls, JvExControls, JvComponent {, JvXPCheckCtrls}, JvXPButtons; + StdCtrls, ComCtrls, JvExControls, JvComponent, JvXPCheckCtrls, JvXPButtons; resourcestring SClickEventAc = ' You clicked on the action "%s"...'; @@ -37,7 +37,7 @@ type btnToogleEnableMode: TJvXPButton; btnToggleVisibleMode: TJvXPButton; ilOldButtons: TImageList; - chkGrouped: TCheckbox; // was: TJvXPCheckbox; + chkGrouped: TJvXPCheckbox; ilWhiteButtons: TImageList; ilRedButtons: TImageList; ilBlackButtons: TImageList; diff --git a/components/jvcllaz/packages/JvXPBarLaz.lpk b/components/jvcllaz/packages/JvXPBarLaz.lpk index 0b37b9cfa..29eea1830 100644 --- a/components/jvcllaz/packages/JvXPBarLaz.lpk +++ b/components/jvcllaz/packages/JvXPBarLaz.lpk @@ -24,7 +24,7 @@ "/> - + @@ -50,6 +50,10 @@ + + + + diff --git a/components/jvcllaz/packages/JvXPBarLaz.pas b/components/jvcllaz/packages/JvXPBarLaz.pas index 4c20a10c7..a650d1827 100644 --- a/components/jvcllaz/packages/JvXPBarLaz.pas +++ b/components/jvcllaz/packages/JvXPBarLaz.pas @@ -9,7 +9,7 @@ interface uses JvXPCoreUtils, JvXPBar, JvXPCore, JvXPBarReg, JvXPContainer, JvXPButtons, - LazarusPackageIntf; + JvXPCheckCtrls, LazarusPackageIntf; implementation diff --git a/components/jvcllaz/packages/JvXPBarReg.pp b/components/jvcllaz/packages/JvXPBarReg.pp index 1834f03c2..099c6aff4 100644 --- a/components/jvcllaz/packages/JvXPBarReg.pp +++ b/components/jvcllaz/packages/JvXPBarReg.pp @@ -11,20 +11,23 @@ procedure Register; implementation +//{$R ../resource/JvXPCore.res} + uses - JvXPBar, JvXPContainer, JvXPButtons; + JvXPBar, JvXPContainer, JvXPButtons, JvXPCheckCtrls; procedure Register; begin - RegisterComponents('JvXP', [ + RegisterComponents('JvXPCtrls', [ TJvXPBar, TJvXPContainer, - TJvXPButton + TJvXPButton, + TJvXPCheckbox ]); end; initialization - {$I JvXPBarLaz.lrs} + {$I ../resource/JvXPBarLaz.lrs} end. diff --git a/components/jvcllaz/resource/JvXPBar.res b/components/jvcllaz/resource/JvXPBar.res new file mode 100644 index 0000000000000000000000000000000000000000..10a4e10cf2ed9f29b73ed2627a7f2b10d21b7ab4 GIT binary patch literal 6180 zcmeI0!A{#i5QfJPDM(a3aLSQmPX$Uzat$qqA|Qwq=p*#8xDbe{UU>mtsBe(|_Jm(% zW@iaWq)OC|?aa*npJ!uc7q3M`wsB0Sdcb_Pby_0d5t&Zcixgt zZu^3rcgnbor|t{2G$^N$;?SrB&J-FW;1o65y6ZU8H{%j@oMzG>E!5JWoJNWx3XVc!1e~HqTX$owuJZQV=a!voJ~eYq@MxB*9Wx}1tM!-S z&_XQ@Q?3C=6r3T{jX6b=5P~Vr^v$^0eALn~iBtJhq6E%{$mS!OgbbZ zx-aEibB_69-Zj)wwVoPaUG=qDKc#PKwodQ68<|oK>NG!?f_xmaG<;&0@ArOZ++U+G zLLFBpXnP~z7W#eT-a0tsh&qWTmk-*9k2~zxq`Nsect@9p%'#172'c'#250#13'w'#228#229'NGO\?'#0#0#0#0'IEND'#174'B' +'`'#130 ]); -LazarusResources.Add('TJvXPContainer','PNG',[ +LazarusResources.Add('TJvXpContainer','PNG',[ #137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#24#0#0#0#24#8#6#0#0#0#224'w='#248#0 +#0#0#9'pHYs'#0#0#11#19#0#0#11#19#1#0#154#156#24#0#0#1#17'IDATH'#137#173'U' +#203#177#195' '#12'\2'#233#195#156'S'#5'M'#228#158'N'#158'_'')'#133't'#178'U' @@ -31,7 +31,7 @@ LazarusResources.Add('TJvXPContainer','PNG',[ +#162'g'#225#136'DG'#171#227'rD'#20#178'n'#160#166#252'Q'#248#139','#254#0#27 +'='#239'S'#30'9'#228#160#0#0#0#0'IEND'#174'B`'#130 ]); -LazarusResources.Add('TJvXPButton','PNG',[ +LazarusResources.Add('TJvXpButton','PNG',[ #137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#24#0#0#0#24#8#6#0#0#0#224'w='#248#0 +#0#0#9'pHYs'#0#0#11#19#0#0#11#19#1#0#154#156#24#0#0#1'0IDATH'#137#181'U;'#146 +#132' '#16'}Ly'#133'1'#213'X'#15#1#151#152'|o'#178#238'M&'#223'K'#192'!4'#238 @@ -48,3 +48,20 @@ LazarusResources.Add('TJvXPButton','PNG',[ +#137#220#239' ,'#151' h&'#202''''#144#139#252#171#225#236'1'#253#7#147#182 +#239#202'!'#176#21#156#0#0#0#0'IEND'#174'B`'#130 ]); +LazarusResources.Add('TJvXpCheckbox','PNG',[ + #137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#24#0#0#0#24#8#6#0#0#0#224'w='#248#0 + +#0#0#9'pHYs'#0#0#11#19#0#0#11#19#1#0#154#156#24#0#0#1#24'IDATH'#137#181#148 + +'Ar'#195' '#12'E'#31#29#223#195'^'#247#20#190'D'#246#189'I'#157#155#244'(' + +#248#18'Yk'#223'}'#182#234#2'c'#227'X'#17'Nc'#255#25#13#16#194#251'H`'#130'D' + +#148#172#142'C$E'#255#227'L'#248'bp'#18'<'#25#156#8'O'#6''''#194#15'1'#240 + +#224#0#13'@'#215'9'#0#135'P'#131'C'#145#129#170#174'#'#14'Wo'#225#30#248#202 + +#0#128#223#219'8'#135#161#156'in{'#163#205'a'#27'T$'#146#224'Q'#210'8J'#130 + +#149#227#178'}'#217' '#195#203#29#150'z'#204#8#166'C'#6'`'#188'Vkn'#237#240 + +'Y?+'#136#160#181'[d'#172#219'%a'#202#224#221#171#232#173's'#207#224']8'#148 + +'g'#240'Ox'#223#170';o'#26#236#133#207#10#207#167'6%z'#25'nHuq\'#25#28#1#223 + +'H'#4#5'?'#162'l'#199#243'o'#170#10#235'Pe'#238'7@'#245'a'#27#25#190'a'#249 + +#144#242#243#16#5#250#233'?'#170#129#16#182#7#222#8#208'~^'#250#205'L'#169 + +#251'`g'#239'.'#154#244#152#190#21'V'#137'~'#140#18#229#151#190',W'#16#162 + +#138#248#9'x;'#255'j'#213#189#166#127#166'I'#183#254#181'|i5'#0#0#0#0'IEND' + +#174'B`'#130 +]); diff --git a/components/jvcllaz/resource/JvXPCore.res b/components/jvcllaz/resource/JvXPCore.res new file mode 100644 index 0000000000000000000000000000000000000000..d775a948ea588a118782ce0292ac9a4caf4d08b6 GIT binary patch literal 4200 zcmeI!v2q+m5P;z}r79g10guojAt7O7moNr|R01185%gmac6g7`0Y&Ub=$L09=tpo) zaQw5gCznpbwp4}7foAWUo}Jy*-OTijPDDhp+f6jD6+aUBhMwK-Bl%Wd$fcai6M9al zzmvyuM$h5-{ttX1pYrr9pA(K(k7ToSemO7QQiljHiI{Cghlvj6Pl_?XwI=pS(@OI&)cI>$}xJxjxngq`Vb`_xmp zkgw#I`5x2{`;`lej6|VDcs=Y_%HCvf1QLaoV0s?*D-~t~jzD4@&7LGs7#x8_q1lrJ z3WFn%C^UPLKw)qM5`~`W8cH-c0*OM;R8A!t9DzikXPTE14UWLO?^i7Uy~<0Ty2SP0 zRnO%|`HA0Dr%Qb%-^*ipPJ8tIz+QF1aV9_0eQkuQDUiISNrqr+I4mR`uv!O-*CTqxR7V^lwYI!nYg)! zzn8g)&9%8;IGdmvC6@YiwVp56ujXQXe$2(q|6y;=i6`X38Ci3(zQtiKd_w>Kp9@>k zfw3|Tp`|rYMR{(@y`4LEq5Ftl!R!&xS=1N9$g^hgz!a2f*PFj0~ z$$FDf^QzkIvCRy4TjTj$&#$Yy%k3s2dX6iEc;R-|erH4q2=rz5^v#TM)E6SdvWG`{^3)c%=k0{FDkUOBiU);YUpqfq&f6 zZnp#VflgKtBJdyQAILqh-34t2cNb(k=V`rXZ3ov2Nu)%c(+lMB@Kcv>l{t$s8}bn6 zt>%MnO#X}RM%3SOWla8zOHse-%E8}sU6;29hshuj^ugaCp6P=h=`U{N;E<-Rz~o2z zteonD|F$dkUA}QWZ|_;aA^$CBC7a$>rlB$f7JIZxE z7(hlp#wi&(hyf(6*N8Z~oF50lZm3-iKQ#*6)lo&#c z&yYi~4vE2g>kybvv9Gb=uAMuwuImHhxZnQf((lp!;ct*Wc;}k1FN}4yt!u=Z-&kgm zRcjpm_+GW27tsYA{Y24^4@vtk{k6zE|2h9KAAjG@^UvpF8%FD+8_zh@M>n*tdr3W7 z)Hl+5>?g#`r|5)89NJnsF*`b}q$Xe8;(2u)Upud$mIZaO@)%K`8nKo|`!9L)<4&LZ z*875EW;)JQaGVd$EA8=^5gSTeOkxC&r83}|3CG& Oa}4>`a^<;}&c8p6i_lU4 literal 0 HcmV?d00001 diff --git a/components/jvcllaz/run/JvXPBar.pas b/components/jvcllaz/run/JvXPBar.pas index 557a935fb..de393843a 100644 --- a/components/jvcllaz/run/JvXPBar.pas +++ b/components/jvcllaz/run/JvXPBar.pas @@ -548,6 +548,8 @@ procedure RoundedFrame(Canvas: TCanvas; ARect: TRect; AColor: TColor; R: Integer implementation +{$R ../resource/JvXPBar.res} + uses Menus; @@ -2028,11 +2030,11 @@ var end; Bitmap.Assign(nil); // fixes GDI resource leak if FCollapsed then - //Bitmap.LoadFromResourceName(HInstance, 'JvXPCustomWinXPBarEXPAND' + IntToStr(Index)) - Bitmap.LoadFromLazarusResource('JvXPCustomWinXPBarEXPAND' + IntToStr(Index)) + Bitmap.LoadFromResourceName(HInstance, 'JvXPCustomWinXPBarEXPAND' + IntToStr(Index)) + //Bitmap.LoadFromLazarusResource('JvXPCustomWinXPBarEXPAND' + IntToStr(Index)) else - //Bitmap.LoadFromResourceName(HInstance, 'JvXPCustomWinXPBarCOLLAPSE' + IntToStr(Index)); - Bitmap.LoadFromLazarusResource('JvXPCustomWinXPBarCOLLAPSE' + IntToStr(Index)); + Bitmap.LoadFromResourceName(HInstance, 'JvXPCustomWinXPBarCOLLAPSE' + IntToStr(Index)); + //Bitmap.LoadFromLazarusResource('JvXPCustomWinXPBarCOLLAPSE' + IntToStr(Index)); end; // Transparency fix not needed Here! -WPostma Bitmap.Transparent := True; @@ -2332,8 +2334,8 @@ begin end; end; -initialization - {$I JvXPBar.lrs} +//initialization +// {$I JvXPBar.lrs} end. diff --git a/components/jvcllaz/run/JvXPButtons.pas b/components/jvcllaz/run/JvXPButtons.pas index 877467626..a43ef7394 100644 --- a/components/jvcllaz/run/JvXPButtons.pas +++ b/components/jvcllaz/run/JvXPButtons.pas @@ -47,8 +47,7 @@ type TJvXPLayout = (blGlyphLeft, blGlyphRight, blGlyphTop, blGlyphBottom); -// TJvXPCustomButton = class(TJvXPCustomStyleControl) - TJvXPCustomButton = class(TJvXPCustomControl) + TJvXPCustomButton = class(TJvXPCustomStyleControl) private FAutoGray: Boolean; FBgGradient: TBitmap; @@ -159,7 +158,7 @@ type property ParentShowHint; property PopupMenu; property ShowHint; -// property Style; + property Style; // property StyleManager; property Visible; //property OnDockDrop; @@ -190,7 +189,7 @@ type TJvXPToolType = (ttArrowLeft, ttArrowRight, ttClose, ttMaximize, ttMinimize, ttPopup, ttRestore, ttImage); - TJvXPCustomToolButton = class(TJvXPCustomControl) + TJvXPCustomToolButton = class(TJvXPCustomStyleControl) private FToolType: TJvXPToolType; FDropDownMenu: TPopupMenu; @@ -255,7 +254,7 @@ type property ParentShowHint; property PopupMenu; property ShowHint; -// property Style; + property Style; // property StyleManager; property Visible; //property OnDockDrop; diff --git a/components/jvcllaz/run/JvXPCheckCtrls.pas b/components/jvcllaz/run/JvXPCheckCtrls.pas new file mode 100644 index 000000000..383cdeee6 --- /dev/null +++ b/components/jvcllaz/run/JvXPCheckCtrls.pas @@ -0,0 +1,456 @@ +{----------------------------------------------------------------------------- +The contents of this file are subject to the Mozilla Public License +Version 1.1 (the "License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at +http://www.mozilla.org/MPL/MPL-1.1.html + +Software distributed under the License is distributed on an "AS IS" basis, +WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See the License for +the specific language governing rights and limitations under the License. + +The Original Code is: JvXPCheckCtrls.PAS, released on 2004-01-01. + +The Initial Developer of the Original Code is Marc Hoffman. +Portions created by Marc Hoffman are Copyright (C) 2002 APRIORI business solutions AG. +Portions created by APRIORI business solutions AG are Copyright (C) 2002 APRIORI business solutions AG +All Rights Reserved. + +Contributor(s): + ZENSan : State and AllowGrayed properties + Anudedeus (Alexandre Pranke) : State and AllowGrayed properties + +You may retrieve the latest version of this file at the Project JEDI's JVCL home page, +located at http://jvcl.sourceforge.net + +Known Issues: +-----------------------------------------------------------------------------} +// $Id: JvXPCheckCtrls.pas 11400 2007-06-28 21:24:06Z ahuser $ + +{$MODE DELPHI} + +unit JvXPCheckCtrls; + +interface + +uses + Classes, LCLIntf, LCLProc, LCLType, LResources, Graphics, Controls, StdCtrls, + JvXPCore, JvXPCoreUtils; + +type + TJvXPCustomCheckControl = class(TJvXPCustomStyleControl) +// TJvXPCustomCheckControl = class(TJvXPCustomControl) + private + FBgGradient: TBitmap; + FBoundLines: TJvXPBoundLines; + FChecked: Boolean; + FCheckSize: Byte; + FCkGradient: TBitmap; + FHlGradient: TBitmap; + FSpacing: Byte; + FState: TCheckBoxState; + FAllowGrayed: Boolean; + procedure SetState(const Value: TCheckBoxState); + procedure SetAllowGrayed(const Value: Boolean); + protected + procedure SetBoundLines(Value: TJvXPBoundLines); virtual; + procedure SetChecked(Value: Boolean); virtual; + procedure SetSpacing(Value: Byte); virtual; + procedure DrawCheckSymbol(const R: TRect); virtual; abstract; + procedure Click; override; + procedure Paint; override; + procedure HookResized; override; + procedure KeyDown(var Key: Word; Shift: TShiftState); override; + property BoundLines: TJvXPBoundLines read FBoundLines write SetBoundLines default []; + property AllowGrayed: Boolean read FAllowGrayed write SetAllowGrayed default False; + property Checked: Boolean read FChecked write SetChecked default False; + property Spacing: Byte read FSpacing write SetSpacing default 3; + property State: TCheckBoxState read FState write SetState default cbUnchecked; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + end; + + TJvXPCheckbox = class(TJvXPCustomCheckControl) + protected + procedure DrawCheckSymbol(const R: TRect); override; + published + // common properties. + property Caption; + property AllowGrayed; + property Enabled; + property TabOrder; + property TabStop default True; + // advanced properties. + property BoundLines; + property Checked; + property Spacing; + property ParentColor; + property State; + property Color; + //property BevelInner; + //property BevelOuter; + //property BevelWidth; + //property BiDiMode; + //property Ctl3D; + //property DockSite; + //property ParentBiDiMode; + //property ParentCtl3D; + //property TabOrder; + //property TabStop; + //property UseDockManager default True; + property Align; + property Anchors; + //property AutoSize; + property Constraints; + property BiDiMode; + property DragCursor; + property DragKind; +// property OnCanResize; + property DragMode; + //property Enabled; + property Font; + property ParentFont; + property ParentShowHint; + property PopupMenu; + property ShowHint; +// property Style; +// property StyleManager; + property Visible; + //property OnDockDrop; + //property OnDockOver; + //property OnEndDock; + //property OnGetSiteInfo; + //property OnStartDock; + //property OnUnDock; + property OnClick; + property OnConstrainedResize; + {$IFDEF COMPILER6_UP} + property OnContextPopup; + {$ENDIF COMPILER6_UP} + property OnDragDrop; + property OnDragOver; + property OnEndDrag; + property OnEnter; + property OnExit; + property OnKeyDown; + property OnKeyPress; + property OnKeyUp; + property OnMouseDown; + property OnMouseEnter; + property OnMouseLeave; + property OnMouseMove; + property OnMouseUp; + property OnStartDrag; + end; + + +implementation + +{ $R } +//=== { TJvXPCustomCheckControl } ============================================ + +constructor TJvXPCustomCheckControl.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + + // set default properties. + ControlStyle := ControlStyle - [csDoubleClicks]; + Height := 17; + TabStop := True; + Width := 161; + + // set custom properties. + FBoundLines := []; + FChecked := False; + FCheckSize := 13; + FSpacing := 3; + + // create ... + FBgGradient := TBitmap.Create; // background gradient + FCkGradient := TBitmap.Create; // clicked gradient + FHlGradient := TBitmap.Create; // Highlight gradient +end; + +destructor TJvXPCustomCheckControl.Destroy; +begin + FBgGradient.Free; + FCkGradient.Free; + FHlGradient.Free; + inherited Destroy; +end; + +procedure TJvXPCustomCheckControl.Click; +begin + if not AllowGrayed then + Checked := not Checked + else + State := TCheckBoxState((Byte(State) + 1) mod 3); + inherited Click; +end; + +procedure TJvXPCustomCheckControl.HookResized; +begin + // create gradient rectangles for... + + // background. + JvXPCreateGradientRect(FCheckSize - 2, FCheckSize - 2, dxColor_Btn_Enb_BgFrom_WXP, + dxColor_Btn_Enb_BgTo_WXP, 16, gsTop, False, FBgGradient); + + // clicked. + JvXPCreateGradientRect(FCheckSize - 2, FCheckSize - 2, dxColor_Btn_Enb_CkFrom_WXP, + dxColor_Btn_Enb_CkTo_WXP, 16, gsTop, True, FCkGradient); + + // highlight. + JvXPCreateGradientRect(FCheckSize - 2, FCheckSize - 2, dxColor_Btn_Enb_HlFrom_WXP, + dxColor_Btn_Enb_HlTo_WXP, 16, gsTop, True, FHlGradient); + + LockedInvalidate; +end; + +procedure TJvXPCustomCheckControl.KeyDown(var Key: Word; Shift: TShiftState); +begin + case Key of + VK_SPACE: + Checked := not Checked; + end; + inherited KeyDown(Key, Shift); +end; + +procedure TJvXPCustomCheckControl.SetAllowGrayed(const Value: Boolean); +begin + FAllowGrayed := Value; + if Value = False then + if FState = cbGrayed then + begin + State := cbUnchecked; + LockedInvalidate; + end; +end; + +procedure TJvXPCustomCheckControl.SetBoundLines(Value: TJvXPBoundLines); +begin + if Value <> FBoundLines then + begin + FBoundLines := Value; + LockedInvalidate; + end; +end; + +procedure TJvXPCustomCheckControl.SetChecked(Value: Boolean); +begin + if Value <> FChecked then + begin + FChecked := Value; + if Value then + FState := cbChecked + else + FState := cbUnchecked; + LockedInvalidate; + end; +end; + +procedure TJvXPCustomCheckControl.SetSpacing(Value: Byte); +begin + if Value <> FSpacing then + begin + FSpacing := Value; + LockedInvalidate; + end; +end; + +procedure TJvXPCustomCheckControl.SetState(const Value: TCheckBoxState); +begin + // will not change FState if FAllowGrayed = false and passed Value is cbGrayed + if (FState <> Value) and (FAllowGrayed or (Value <> cbGrayed)) then + begin + FState := Value; + if FState = cbChecked then + FChecked := True + else + FChecked := False; + LockedInvalidate; + end; +end; + +procedure TJvXPCustomCheckControl.Paint; +var + Rect: TRect; + BoundColor: TColor; +begin + with Canvas do + begin + // clear background. + Rect := GetClientRect; + Brush.Color := Color; + FillRect(Rect); + // draw designtime rect. + if csDesigning in ComponentState then + DrawFocusRect(Rect); + + // draw boundlines. + if BoundLines <> [] then + begin + if Style.GetTheme = WindowsXP then + BoundColor := dxColor_Btn_Enb_Border_WXP + else + BoundColor := dxColor_DotNetFrame; + JvXPDrawBoundLines(Self.Canvas, BoundLines, BoundColor, Rect); + end; + + // draw focusrect. + if dsFocused in DrawState then + begin + Brush.Style := bsSolid; + DrawFocusRect(Rect); + end; + + // draw check symbol. + DrawCheckSymbol(Rect); + + // draw caption. + SetBkMode(Handle, Transparent); + Font.Assign(Self.Font); + if BiDiMode = bdRightToLeft then + begin + Dec(Rect.Right, FCheckSize + 4 + Spacing); + JvXPPlaceText(Self, Canvas, Caption, Font, Enabled, True, taRightJustify, True, Rect) + end + else + begin + Inc(Rect.Left, FCheckSize + 4 + Spacing); + JvXPPlaceText(Self, Canvas, Caption, Font, Enabled, True, taLeftJustify, True, Rect); + end; + end; +end; + +//=== { TJvXPCheckbox } ====================================================== + +procedure TJvXPCheckbox.DrawCheckSymbol(const R: TRect); +var + ClipW: Integer; + Bitmap: TBitmap; + Theme: TJvXPTheme; + + procedure DrawGradient(const Bitmap: TBitmap); + begin + if BiDiMode = bdRightToLeft then + BitBlt(Canvas.Handle, R.Right - 1 - FCheckSize, (ClientHeight - FCheckSize) div 2 + 1, + FCheckSize - 2, FCheckSize - 2, Bitmap.Canvas.Handle, 0, 0, SRCCOPY) + else + BitBlt(Canvas.Handle, R.Left + 3, (ClientHeight - FCheckSize) div 2 + 1, + FCheckSize - 2, FCheckSize - 2, Bitmap.Canvas.Handle, 0, 0, SRCCOPY); + end; + +begin + // get current theme. + Theme := Style.GetTheme; + + with Canvas do + begin + // check for highlight. + ClipW := Ord(dsHighlight in DrawState); + + // draw border. + if (Theme = WindowsXP) or ((Theme = OfficeXP) and (ClipW = 0)) then + Pen.Color := dxColor_Chk_Enb_Border_WXP + else + Pen.Color := dxColor_BorderLineOXP; + if BiDiMode = bdRightToLeft then + Rectangle(Bounds(R.Right - 2 - FCheckSize , (ClientHeight - FCheckSize) div 2,FCheckSize, FCheckSize)) + else + Rectangle(Bounds(R.Left + 2, (ClientHeight - FCheckSize) div 2,FCheckSize, FCheckSize)); + + // draw background. + case Theme of + WindowsXP: + begin + if not ((ClipW <> 0) and (dsClicked in DrawState)) then + begin + if ClipW <> 0 then + DrawGradient(FHlGradient); + if BiDiMode = bdRightToLeft then + BitBlt(Handle, R.Right - 1 - FCheckSize + ClipW, (ClientHeight - FCheckSize) div 2 + 1 + + ClipW, FCheckSize - 2 - ClipW * 2, FCheckSize - 2 - ClipW * 2, + FBgGradient.Canvas.Handle, 0, 0, SRCCOPY) + else + BitBlt(Handle, R.Left + 3 + ClipW, (ClientHeight - FCheckSize) div 2 + 1 + + ClipW, FCheckSize - 2 - ClipW * 2, FCheckSize - 2 - ClipW * 2, + FBgGradient.Canvas.Handle, 0, 0, SRCCOPY); + end + else + DrawGradient(FCkGradient); + end; + OfficeXP: + begin + if ClipW <> 0 then + begin + if not (dsClicked in DrawState) then + Brush.Color := dxColor_BgOXP + else + Brush.Color := dxColor_BgCkOXP; + if BiDiMode = bdRightToLeft then + FillRect(Bounds(R.Right - 1, (ClientHeight - FCheckSize) div 2 + 1, + FCheckSize - 2, FCheckSize - 2)) + else + FillRect(Bounds(R.Left + 3, (ClientHeight - FCheckSize) div 2 + 1, + FCheckSize - 2, FCheckSize - 2)) + end; + end; + end; + + // draw checked or grayed symbols: + if FState in [cbChecked, cbGrayed] then + begin + Brush.Color := clSilver; + Pen.Color := dxColor_Btn_Enb_Border_WXP; + Bitmap := TBitmap.Create; + try + Bitmap.Transparent := True; + Bitmap.Assign(nil); // fixes GDI resource leak + if FState = cbChecked then + begin + //Bitmap.LoadFromLazarusResource(HInstance, 'JvXPCheckboxCHECKBOX') + Bitmap.LoadFromResourceName(HInstance, 'JvXPCheckboxCHECKBOX') + end + else + begin + Bitmap.Transparent := false; + //Bitmap.LoadFromLazarusResource(HInstance, 'JvXPCheckboxCHECKBOXGRAY'); + Bitmap.LoadFromResourceName(HInstance, 'JvXPCheckboxCHECKBOXGRAY'); + end; + if Theme = WindowsXP then + begin + if FState = cbChecked then + JvXPColorizeBitmap(Bitmap, dxColor_Chk_Enb_NmSymb_WXP) + else + JvXPColorizeBitmap(Bitmap, dxColor_Chk_Enb_GraSymb_WXP); + end + else + if (dsClicked in DrawState) and (dsHighlight in DrawState) then + begin + JvXPColorizeBitmap(Bitmap, clWhite); + end; + if BiDiMode = bdRightToLeft then + Draw(R.Right - FCheckSize + 1, (ClientHeight - FCheckSize) div 2 + 3, Bitmap) + else + Draw(FCheckSize div 2 - 1, (ClientHeight - FCheckSize) div 2 + 3, Bitmap); + finally + Bitmap.Free; + end; + end; + end; +end; + +{$IFDEF USEJVCL} +{$IFDEF UNITVERSIONING} +initialization + RegisterUnitVersion(HInstance, UnitVersioning); + +finalization + UnregisterUnitVersion(HInstance); +{$ENDIF UNITVERSIONING} +{$ENDIF USEJVCL} + +end. + + diff --git a/components/jvcllaz/run/JvXPCore.pas b/components/jvcllaz/run/JvXPCore.pas index 2f38f60db..3dd73c759 100644 --- a/components/jvcllaz/run/JvXPCore.pas +++ b/components/jvcllaz/run/JvXPCore.pas @@ -72,7 +72,7 @@ const dxColor_BgCkOXP = TColor($00CC9999); type -// TJvXPCustomStyleControl = class; + TJvXPCustomStyleControl = class; TJvXPBoundLines = set of ( blLeft, // left line @@ -248,23 +248,25 @@ type property OnMouseUp; property OnStartDrag; end; + ******************** NOT CONVERTED *) TJvXPStyle = class(TPersistent) private FTheme: TJvXPTheme; - FUseStyleManager: Boolean; + //FUseStyleManager: Boolean; protected Parent: TJvXPCustomStyleControl; procedure SetTheme(Value: TJvXPTheme); virtual; - procedure SetUseStyleManager(Value: Boolean); virtual; + //procedure SetUseStyleManager(Value: Boolean); virtual; public constructor Create(AOwner: TComponent); function GetTheme: TJvXPTheme; published property Theme: TJvXPTheme read FTheme write SetTheme default WindowsXP; - property UseStyleManager: Boolean read FUseStyleManager write SetUseStyleManager default True; + //property UseStyleManager: Boolean read FUseStyleManager write SetUseStyleManager default True; end; + (******************** NOT CONVERTED TJvXPStyleManager = class(TJvXPCustomComponent) private FControls: TList; @@ -282,21 +284,21 @@ type property Theme: TJvXPTheme read FTheme write SetTheme default WindowsXP; property OnThemeChanged: TNotifyEvent read FOnThemeChanged write FOnThemeChanged; end; + ******************** NOT CONVERTED *) TJvXPCustomStyleControl = class(TJvXPCustomControl) private FStyle: TJvXPStyle; - FStyleManager: TJvXPStyleManager; + //FStyleManager: TJvXPStyleManager; protected - procedure SetStyleManager(Value: TJvXPStyleManager); virtual; - procedure Notification(AComponent: TComponent; Operation: TOperation); override; + //procedure SetStyleManager(Value: TJvXPStyleManager); virtual; + //procedure Notification(AComponent: TComponent; Operation: TOperation); override; property Style: TJvXPStyle read FStyle write FStyle; - property StyleManager: TJvXPStyleManager read FStyleManager write SetStyleManager; + //property StyleManager: TJvXPStyleManager read FStyleManager write SetStyleManager; public constructor Create(AOwner: TComponent); override; destructor Destroy; override; end; - ******************** NOT CONVERTED *) TJvXPGradientColors = 2..255; @@ -336,6 +338,8 @@ type implementation +{$R ../resource/JvXPCore.res} + //=== { TJvXPCustomControl } ================================================= constructor TJvXPCustomControl.Create(AOwner: TComponent); @@ -664,8 +668,6 @@ begin end; -(******************** NOT CONVERTED - //=== { TJvXPStyle } ========================================================= constructor TJvXPStyle.Create(AOwner: TComponent); @@ -673,7 +675,7 @@ begin inherited Create; Parent := TJvXPCustomStyleControl(AOwner); FTheme := WindowsXP; - FUseStyleManager := True; + //FUseStyleManager := True; end; procedure TJvXPStyle.SetTheme(Value: TJvXPTheme); @@ -688,10 +690,13 @@ end; function TJvXPStyle.GetTheme: TJvXPTheme; begin Result := FTheme; + { if FUseStyleManager and Assigned(Parent.StyleManager) then Result := Parent.StyleManager.Theme; + } end; +{ procedure TJvXPStyle.SetUseStyleManager(Value: Boolean); begin if Value <> FUseStyleManager then @@ -700,6 +705,9 @@ begin Parent.InternalRedraw; end; end; + } + +(******************** NOT CONVERTED //=== { TJvXPStyleManager } ================================================== @@ -754,6 +762,7 @@ begin if FControls.IndexOf(AControls[I]) <> -1 then FControls.Delete(FControls.IndexOf(AControls[I])); end; +******************** NOT CONVERTED *) //=== { TJvXPCustomStyleControl } ============================================ @@ -762,17 +771,19 @@ constructor TJvXPCustomStyleControl.Create(AOwner: TComponent); begin inherited Create(AOwner); FStyle := TJvXPStyle.Create(Self); - FStyleManager := nil; + //FStyleManager := nil; end; destructor TJvXPCustomStyleControl.Destroy; begin + { if FStyleManager <> nil then FStyleManager.UnregisterControls([Self]); + } FStyle.Free; inherited Destroy; end; - + { procedure TJvXPCustomStyleControl.Notification(AComponent: TComponent; Operation: TOperation); begin @@ -792,9 +803,10 @@ begin FStyleManager := Value; InternalRedraw; end; -end; +end; } +(******************** NOT CONVERTED //=== { TJvXPGradient } ====================================================== constructor TJvXPGradient.Create(AOwner: TControl); diff --git a/components/jvcllaz/run/JvXPCoreUtils.pas b/components/jvcllaz/run/JvXPCoreUtils.pas index 23df70688..7ce21b78b 100644 --- a/components/jvcllaz/run/JvXPCoreUtils.pas +++ b/components/jvcllaz/run/JvXPCoreUtils.pas @@ -61,13 +61,14 @@ procedure JvXPFrame3D(const ACanvas: TCanvas; const ARect: TRect; const TopColor, BottomColor: TColor; const Swapped: Boolean = False); procedure JvXPColorizeBitmap(ABitmap: TBitmap; const AColor: TColor); -(******************** NOT CONVERTED - NOT USED + procedure JvXPSetDrawFlags(const AAlignment: TAlignment; const AWordWrap: Boolean; var Flags: Integer); + procedure JvXPPlaceText(const AParent: TControl; const ACanvas: TCanvas; const AText: TCaption; const AFont: TFont; const AEnabled, AShowAccelChar: Boolean; const AAlignment: TAlignment; const AWordWrap: Boolean; var Rect: TRect); -******************** NOT CONVERTED *) + implementation @@ -406,7 +407,6 @@ begin end; end; -(******************** NOT CONVERTED procedure JvXPSetDrawFlags(const AAlignment: TAlignment; const AWordWrap: Boolean; var Flags: Integer); begin @@ -446,7 +446,6 @@ begin OffsetRect(Rect, DX, (OH - Rect.Bottom) div 2); JvXPRenderText(AParent, ACanvas, AText, AFont, AEnabled, AShowAccelChar, Rect, Flags); end; -******************** NOT CONVERTED *) end.