From fbeb3489be3916df0a6f7cf34591fb226a824273 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Tue, 20 Mar 2018 23:37:49 +0000 Subject: [PATCH] jvcllaz: Add ImageIndex property editor to NavigationPane components git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6262 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../design/JvPageComps/JvPageCompsReg.pas | 10 ++- .../design/JvPageComps/jvnavpaneeditors.pas | 73 +++++++++++++++++++ 2 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 components/jvcllaz/design/JvPageComps/jvnavpaneeditors.pas diff --git a/components/jvcllaz/design/JvPageComps/JvPageCompsReg.pas b/components/jvcllaz/design/JvPageComps/JvPageCompsReg.pas index 4c75ce493..a9cdeb616 100644 --- a/components/jvcllaz/design/JvPageComps/JvPageCompsReg.pas +++ b/components/jvcllaz/design/JvPageComps/JvPageCompsReg.pas @@ -14,9 +14,13 @@ implementation {$R ..\..\resource\jvpagecompsreg.res} uses - JvDsgnConsts, JvNavigationPane; + ImgList, PropEdits, + JvDsgnConsts, + JvNavigationPane, JvNavPaneEditors; procedure Register; +const + cImageIndex = 'ImageIndex'; begin RegisterComponents(RsPaletteJvcl, [ // was: RsPaletteNavPane TJvNavigationPane, @@ -25,6 +29,10 @@ begin TJvOutlookSplitter, TJvNavPaneStyleManager, TJvNavPaneToolPanel ]); + RegisterPropertyEditor(TypeInfo(TImageIndex), TJvNavPanelPage, cImageIndex, TJvNavPanePageImageIndexProperty); + RegisterPropertyEditor(TypeInfo(TImageIndex), TJvNavPanelHeader, cImageIndex, TJvNavPanelHeaderImageIndexProperty); + RegisterPropertyEditor(TypeInfo(TImageIndex), TJvNavPanelButton, cImageIndex, TJvNavPanelButtonImageIndexProperty); + RegisterPropertyEditor(TypeInfo(TImageIndex), TJvNavIconButton, cImageIndex, TJvNavIconButtonImageIndexProperty); end; end. diff --git a/components/jvcllaz/design/JvPageComps/jvnavpaneeditors.pas b/components/jvcllaz/design/JvPageComps/jvnavpaneeditors.pas new file mode 100644 index 000000000..129112f68 --- /dev/null +++ b/components/jvcllaz/design/JvPageComps/jvnavpaneeditors.pas @@ -0,0 +1,73 @@ +unit JvNavPaneEditors; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, SysUtils, ImgList, + PropEdits, GraphPropEdits; + +type + TJvNavPanePageImageIndexProperty = class(TImageIndexPropertyEditor) + protected + function GetImageList: TCustomImageList; override; + end; + + TJvNavPanelHeaderImageIndexProperty = class(TImageIndexPropertyEditor) + protected + function GetImageList: TCustomImageList; override; + end; + + TJvNavPanelButtonImageIndexProperty = class(TImageIndexPropertyEditor) + protected + function GetImageList: TCustomImageList; override; + end; + + TJvNavIconButtonImageIndexProperty = class(TImageIndexPropertyEditor) + protected + function GetImageList: TCustomImageList; override; + end; + +implementation + +uses + JvPageList, JvNavigationPane; + +function TJvNavPanePageImageIndexProperty.GetImageList: TCustomImageList; +var + P: TJvNavigationPane; +begin + P := TJvNavigationPane(TJvNavPanelPage(GetComponent(0)).PageList); + if P = nil then + Result := nil + else + if P.SmallImages <> nil then // small images fit better into the OI, so prefer those + Result := P.SmallImages + else + Result := P.LargeImages; +end; + +//=== { TJvNavPanelHeaderImageIndexProperty } ================================ + +function TJvNavPanelHeaderImageIndexProperty.GetImageList: TCustomImageList; +begin + Result := TJvNavPanelHeader(GetComponent(0)).Images; +end; + +//=== { TJvNavPanelButtonImageIndexProperty } ================================ + +function TJvNavPanelButtonImageIndexProperty.GetImageList: TCustomImageList; +begin + Result := TJvNavPanelButton(GetComponent(0)).Images; +end; + +//=== { TJvNavIconButtonImageIndexProperty } ================================= + +function TJvNavIconButtonImageIndexProperty.GetImageList: TCustomImageList; +begin + Result := TJvNavIconButton(GetComponent(0)).Images; +end; + +end. +