From 5d9aaa8380fbaaa71fabb6c936348bd6e159efaf Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Wed, 12 Jun 2019 13:21:57 +0000 Subject: [PATCH] jvcllaz: Add TJvOfficeColorButton. Some cosmetic changes, less hints and warnings. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7006 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../jvcllaz/design/JvCore/jvdsgneditors.pas | 2 +- .../jvcllaz/design/JvCtrls/images/images.txt | 1 + .../JvCtrls/images/tjvofficecolorpanel.bmp | Bin 0 -> 1782 bytes .../jvcllaz/design/JvCtrls/jvctrlsreg.pas | 2 + .../design/JvStdCtrls/jvstdctrlsreg.pas | 8 +- .../JvOfficeColorPanelDemo.lpi | 84 + .../JvOfficeColorPanelDemo.lpr | 22 + .../examples/JvOfficeColorPanel/main.lfm | 418 +++ .../examples/JvOfficeColorPanel/main.pas | 198 ++ components/jvcllaz/packages/jvctrlslazr.lpk | 15 +- components/jvcllaz/resource/jvctrlsreg.res | Bin 35900 -> 37736 bytes .../jvcllaz/run/JvCore/jvexcontrols.pas | 7 +- components/jvcllaz/run/JvCore/jvjclutils.pas | 11 +- components/jvcllaz/run/JvCore/jvtypes.pas | 46 +- .../jvcllaz/run/JvCtrls/jvgroupheader.pas | 7 + .../jvcllaz/run/JvCtrls/jvhtcontrols.pas | 6 +- .../jvcllaz/run/JvCtrls/jvmovablebevel.pas | 1 + .../run/JvCtrls/jvofficecolorpanel.pas | 2487 +++++++++++++++++ components/jvcllaz/run/JvStdCtrls/jvpanel.pas | 6 +- 19 files changed, 3290 insertions(+), 31 deletions(-) create mode 100644 components/jvcllaz/design/JvCtrls/images/tjvofficecolorpanel.bmp create mode 100644 components/jvcllaz/examples/JvOfficeColorPanel/JvOfficeColorPanelDemo.lpi create mode 100644 components/jvcllaz/examples/JvOfficeColorPanel/JvOfficeColorPanelDemo.lpr create mode 100644 components/jvcllaz/examples/JvOfficeColorPanel/main.lfm create mode 100644 components/jvcllaz/examples/JvOfficeColorPanel/main.pas create mode 100644 components/jvcllaz/run/JvCtrls/jvofficecolorpanel.pas diff --git a/components/jvcllaz/design/JvCore/jvdsgneditors.pas b/components/jvcllaz/design/JvCore/jvdsgneditors.pas index d7c06541f..e6e593412 100644 --- a/components/jvcllaz/design/JvCore/jvdsgneditors.pas +++ b/components/jvcllaz/design/JvCore/jvdsgneditors.pas @@ -311,7 +311,7 @@ end; function TJvPersistentPropertyEditor.GetValue:string; begin - FmtStr(Result, '(%s)', [GetPropType^.Name]); + Result := Format('(%s)', [GetPropType^.Name]); end; diff --git a/components/jvcllaz/design/JvCtrls/images/images.txt b/components/jvcllaz/design/JvCtrls/images/images.txt index 53dc036ee..0e69eec03 100644 --- a/components/jvcllaz/design/JvCtrls/images/images.txt +++ b/components/jvcllaz/design/JvCtrls/images/images.txt @@ -28,3 +28,4 @@ tjvrollout_200.png tjvcombolistbox.bmp tjvlookupautocomplete.bmp tjvinstalllabel.bmp +tjvofficecolorpanel.bmp diff --git a/components/jvcllaz/design/JvCtrls/images/tjvofficecolorpanel.bmp b/components/jvcllaz/design/JvCtrls/images/tjvofficecolorpanel.bmp new file mode 100644 index 0000000000000000000000000000000000000000..fe0ca0adce06db9210179ddadf70a9cc6bc91f02 GIT binary patch literal 1782 zcmcJOy=}uV6og-zG+7{}%Ct)1I&hyI3>e-+FfxVVLZfH`afLTU+UGm|NR%AdVr(6b z)PX;rNJ`v(|GtXX2K5KZdn_+LiFD}yd<(@7MAeCkqPpu=lr|HSKfHi2ykf!;5>X + + + + + + + + + + + <Scaled Value="True"/> + <ResourceType Value="res"/> + <UseXPManifest Value="True"/> + <XPManifest> + <DpiAware Value="True"/> + </XPManifest> + <Icon Value="0"/> + </General> + <BuildModes Count="1"> + <Item1 Name="Default" Default="True"/> + </BuildModes> + <PublishOptions> + <Version Value="2"/> + <UseFileFilters Value="True"/> + </PublishOptions> + <RunParams> + <FormatVersion Value="2"/> + <Modes Count="0"/> + </RunParams> + <RequiredPackages Count="2"> + <Item1> + <PackageName Value="JvCtrlsLazR"/> + </Item1> + <Item2> + <PackageName Value="LCL"/> + </Item2> + </RequiredPackages> + <Units Count="2"> + <Unit0> + <Filename Value="JvOfficeColorPanelDemo.lpr"/> + <IsPartOfProject Value="True"/> + </Unit0> + <Unit1> + <Filename Value="main.pas"/> + <IsPartOfProject Value="True"/> + <ComponentName Value="Form1"/> + <HasResources Value="True"/> + <ResourceBaseClass Value="Form"/> + </Unit1> + </Units> + </ProjectOptions> + <CompilerOptions> + <Version Value="11"/> + <PathDelim Value="\"/> + <Target> + <Filename Value="..\..\bin\$(TargetCPU)-$(TargetOS)\JvOfficeColorPanelDemo"/> + </Target> + <SearchPaths> + <IncludeFiles Value="$(ProjOutDir)"/> + <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> + </SearchPaths> + <Linking> + <Options> + <Win32> + <GraphicApplication Value="True"/> + </Win32> + </Options> + </Linking> + </CompilerOptions> + <Debugging> + <Exceptions Count="3"> + <Item1> + <Name Value="EAbort"/> + </Item1> + <Item2> + <Name Value="ECodetoolError"/> + </Item2> + <Item3> + <Name Value="EFOpenError"/> + </Item3> + </Exceptions> + </Debugging> +</CONFIG> diff --git a/components/jvcllaz/examples/JvOfficeColorPanel/JvOfficeColorPanelDemo.lpr b/components/jvcllaz/examples/JvOfficeColorPanel/JvOfficeColorPanelDemo.lpr new file mode 100644 index 000000000..3efc7fea1 --- /dev/null +++ b/components/jvcllaz/examples/JvOfficeColorPanel/JvOfficeColorPanelDemo.lpr @@ -0,0 +1,22 @@ +program JvOfficeColorPanelDemo; + +{$mode objfpc}{$H+} + +uses + {$IFDEF UNIX}{$IFDEF UseCThreads} + cthreads, + {$ENDIF}{$ENDIF} + Interfaces, // this includes the LCL widgetset + Forms, main + { you can add units after this }; + +{$R *.res} + +begin + RequireDerivedFormResource:=True; + Application.Scaled:=True; + Application.Initialize; + Application.CreateForm(TForm1, Form1); + Application.Run; +end. + diff --git a/components/jvcllaz/examples/JvOfficeColorPanel/main.lfm b/components/jvcllaz/examples/JvOfficeColorPanel/main.lfm new file mode 100644 index 000000000..9eed11acd --- /dev/null +++ b/components/jvcllaz/examples/JvOfficeColorPanel/main.lfm @@ -0,0 +1,418 @@ +object Form1: TForm1 + Left = 361 + Height = 292 + Top = 225 + Width = 559 + AutoSize = True + Caption = 'JvOfficeColorPanel demo' + ClientHeight = 292 + ClientWidth = 559 + OnCreate = FormCreate + ShowHint = True + LCLVersion = '2.1.0.0' + object JvOfficeColorPanel1: TJvOfficeColorPanel + AnchorSideLeft.Control = gbColorView + AnchorSideTop.Control = gbColorView + AnchorSideTop.Side = asrBottom + Left = 6 + Height = 162 + Top = 117 + Width = 152 + BevelInner = bvRaised + BevelOuter = bvLowered + BorderSpacing.Bottom = 6 + FlatBorderColor = clHotLight + SelectedColor = clDefault + ColorDlgCustomColors.Strings = ( + 'ColorA=000000' + 'ColorB=000080' + 'ColorC=008000' + 'ColorD=008080' + 'ColorE=800000' + 'ColorF=800080' + 'ColorG=808000' + 'ColorH=808080' + 'ColorI=C0C0C0' + 'ColorJ=0000FF' + 'ColorK=00FF00' + 'ColorL=00FFFF' + 'ColorM=FF0000' + 'ColorN=FF00FF' + 'ColorO=FFFF00' + 'ColorP=FFFFFF' + 'ColorQ=C0DCC0' + 'ColorR=F0CAA6' + 'ColorS=F0FBFF' + 'ColorT=A4A0A0' + ) + TabOrder = 0 + Properties.NoneColorCaption = 'No Color' + Properties.DefaultColorCaption = 'Automatic' + Properties.CustomColorCaption = 'Other Colors...' + Properties.NoneColorHint = 'No Color' + Properties.DefaultColorHint = 'Automatic' + Properties.CustomColorHint = 'Other Colors...' + OnColorChange = JvOfficeColorPanel1ColorChange + end + object Panel1: TPanel + AnchorSideLeft.Control = JvOfficeColorPanel1 + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = Owner + Left = 188 + Height = 198 + Top = 6 + Width = 347 + BorderSpacing.Left = 24 + BorderSpacing.Around = 6 + BevelOuter = bvNone + ClientHeight = 198 + ClientWidth = 347 + TabOrder = 1 + object cbFlatBorder: TCheckBox + AnchorSideLeft.Control = Panel1 + AnchorSideTop.Control = Panel1 + Left = 0 + Height = 19 + Top = 0 + Width = 77 + Caption = 'Flat border' + OnChange = cbFlatBorderChange + TabOrder = 0 + end + object cbDefaultColorColor: TColorButton + AnchorSideLeft.Control = cbShowDefaultColor + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = cbShowDefaultColor + AnchorSideTop.Side = asrCenter + Left = 127 + Height = 25 + Top = 43 + Width = 33 + BorderSpacing.Left = 8 + BorderWidth = 2 + ButtonColorSize = 16 + ButtonColor = clBlack + Margin = 4 + OnColorChanged = cbDefaultColorColorColorChanged + end + object cbShowCustomColor: TCheckBox + AnchorSideLeft.Control = Panel1 + AnchorSideTop.Control = cbShowUserColor + AnchorSideTop.Side = asrBottom + Left = 0 + Height = 19 + Top = 103 + Width = 122 + Caption = 'Show custom color' + Checked = True + OnChange = cbShowCustomColorChange + State = cbChecked + TabOrder = 1 + end + object cbShowDefaultColor: TCheckBox + AnchorSideLeft.Control = Panel1 + AnchorSideTop.Control = cbShowNoneColor + AnchorSideTop.Side = asrBottom + Left = 0 + Height = 19 + Top = 46 + Width = 119 + Caption = 'Show default color' + Checked = True + OnChange = cbShowDefaultColorChange + State = cbChecked + TabOrder = 2 + end + object cbShowNoneColor: TCheckBox + AnchorSideLeft.Control = Panel1 + AnchorSideTop.Control = cbFlatBorder + AnchorSideTop.Side = asrBottom + Left = 0 + Height = 19 + Top = 27 + Width = 110 + BorderSpacing.Top = 8 + Caption = 'Show NoneColor' + OnChange = cbShowNoneColorChange + TabOrder = 3 + end + object cbShowSystemColors: TCheckBox + AnchorSideLeft.Control = Panel1 + AnchorSideTop.Control = cbShowDefaultColor + AnchorSideTop.Side = asrBottom + Left = 0 + Height = 19 + Top = 65 + Width = 124 + Caption = 'Show system colors' + OnChange = cbShowSystemColorsChange + TabOrder = 4 + end + object cbShowUserColor: TCheckBox + AnchorSideLeft.Control = Panel1 + AnchorSideTop.Control = cbShowSystemColors + AnchorSideTop.Side = asrBottom + Left = 0 + Height = 19 + Top = 84 + Width = 104 + Caption = 'Show user color' + OnChange = cbShowUserColorChange + TabOrder = 5 + end + object seButtonHeight: TSpinEdit + AnchorSideLeft.Control = seColorSpaceBottom + AnchorSideTop.Control = Panel1 + Left = 297 + Height = 23 + Top = 0 + Width = 50 + Alignment = taRightJustify + OnChange = seButtonHeightChange + TabOrder = 6 + Value = 25 + end + object Label1: TLabel + AnchorSideLeft.Control = lblColorSpaceBottom + AnchorSideTop.Control = seButtonHeight + AnchorSideTop.Side = asrCenter + Left = 184 + Height = 15 + Top = 4 + Width = 73 + BorderSpacing.Top = 16 + Caption = 'Button height' + ParentColor = False + end + object lblColorSize: TLabel + AnchorSideLeft.Control = lblColorSpaceBottom + AnchorSideTop.Control = seColorSize + AnchorSideTop.Side = asrCenter + Left = 184 + Height = 15 + Top = 29 + Width = 51 + BorderSpacing.Top = 16 + Caption = 'Color size' + ParentColor = False + end + object seColorSize: TSpinEdit + AnchorSideLeft.Control = seColorSpaceBottom + AnchorSideTop.Control = seButtonHeight + AnchorSideTop.Side = asrBottom + Left = 297 + Height = 23 + Top = 25 + Width = 50 + Alignment = taRightJustify + BorderSpacing.Top = 2 + OnChange = seColorSizeChange + TabOrder = 7 + Value = 25 + end + object lblColorSpace: TLabel + AnchorSideLeft.Control = lblColorSpaceBottom + AnchorSideTop.Control = seColorSpace + AnchorSideTop.Side = asrCenter + Left = 184 + Height = 15 + Top = 54 + Width = 62 + BorderSpacing.Top = 16 + Caption = 'Color space' + ParentColor = False + end + object seColorSpace: TSpinEdit + AnchorSideLeft.Control = seColorSpaceBottom + AnchorSideTop.Control = seColorSize + AnchorSideTop.Side = asrBottom + Left = 297 + Height = 23 + Top = 50 + Width = 50 + Alignment = taRightJustify + BorderSpacing.Top = 2 + OnChange = seColorSpaceChange + TabOrder = 8 + Value = 25 + end + object lblColorSpaceTop: TLabel + AnchorSideLeft.Control = lblColorSpaceBottom + AnchorSideTop.Control = seColorSpaceTop + AnchorSideTop.Side = asrCenter + Left = 184 + Height = 15 + Top = 79 + Width = 83 + BorderSpacing.Top = 16 + Caption = 'Color space top' + ParentColor = False + end + object seColorSpaceTop: TSpinEdit + AnchorSideLeft.Control = seColorSpaceBottom + AnchorSideTop.Control = seColorSpace + AnchorSideTop.Side = asrBottom + Left = 297 + Height = 23 + Top = 75 + Width = 50 + Alignment = taRightJustify + BorderSpacing.Top = 2 + OnChange = seColorSpaceTopChange + TabOrder = 9 + Value = 25 + end + object lblColorSpaceBottom: TLabel + AnchorSideLeft.Control = cbDefaultColorColor + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = seColorSpaceBottom + AnchorSideTop.Side = asrCenter + Left = 184 + Height = 15 + Top = 104 + Width = 105 + BorderSpacing.Left = 24 + BorderSpacing.Top = 16 + Caption = 'Color space bottom' + ParentColor = False + end + object seColorSpaceBottom: TSpinEdit + AnchorSideLeft.Control = lblColorSpaceBottom + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = seColorSpaceTop + AnchorSideTop.Side = asrBottom + Left = 297 + Height = 23 + Top = 100 + Width = 50 + Alignment = taRightJustify + BorderSpacing.Left = 8 + BorderSpacing.Top = 2 + OnChange = seColorSpaceBottomChange + TabOrder = 10 + Value = 25 + end + object lblTopMargin: TLabel + AnchorSideLeft.Control = lblColorSpaceBottom + AnchorSideTop.Control = seTopMargin + AnchorSideTop.Side = asrCenter + Left = 184 + Height = 15 + Top = 154 + Width = 61 + BorderSpacing.Top = 16 + Caption = 'Top margin' + ParentColor = False + end + object seTopMargin: TSpinEdit + AnchorSideLeft.Control = seColorSpaceBottom + AnchorSideTop.Control = seHorizontalMargin + AnchorSideTop.Side = asrBottom + Left = 297 + Height = 23 + Top = 150 + Width = 50 + Alignment = taRightJustify + BorderSpacing.Top = 2 + OnChange = seTopMarginChange + TabOrder = 11 + Value = 25 + end + object seBottomMargin: TSpinEdit + AnchorSideLeft.Control = seColorSpaceBottom + AnchorSideTop.Control = seTopMargin + AnchorSideTop.Side = asrBottom + Left = 297 + Height = 23 + Top = 175 + Width = 50 + Alignment = taRightJustify + BorderSpacing.Top = 2 + OnChange = seBottomMarginChange + TabOrder = 12 + Value = 25 + end + object lblBottomMargin: TLabel + AnchorSideLeft.Control = lblColorSpaceBottom + AnchorSideTop.Control = seBottomMargin + AnchorSideTop.Side = asrCenter + Left = 184 + Height = 15 + Top = 179 + Width = 81 + BorderSpacing.Top = 16 + Caption = 'Bottom margin' + ParentColor = False + end + object lblColorSpaceBottom1: TLabel + AnchorSideLeft.Control = lblColorSpaceBottom + AnchorSideTop.Control = seHorizontalMargin + AnchorSideTop.Side = asrCenter + Left = 184 + Height = 15 + Top = 129 + Width = 96 + BorderSpacing.Top = 16 + Caption = 'Horizontal margin' + ParentColor = False + end + object seHorizontalMargin: TSpinEdit + AnchorSideLeft.Control = seBottomMargin + AnchorSideTop.Control = seColorSpaceBottom + AnchorSideTop.Side = asrBottom + Left = 297 + Height = 23 + Top = 125 + Width = 50 + Alignment = taRightJustify + BorderSpacing.Top = 2 + OnChange = seHorizontalMarginChange + TabOrder = 13 + Value = 25 + end + object cbBackColor: TColorButton + AnchorSideLeft.Control = Panel1 + AnchorSideTop.Control = cbShowCustomColor + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = cbDefaultColorColor + AnchorSideRight.Side = asrBottom + Left = 0 + Height = 25 + Top = 130 + Width = 160 + Anchors = [akTop, akLeft, akRight] + BorderSpacing.Top = 8 + BorderWidth = 2 + ButtonColorAutoSize = False + ButtonColorSize = 16 + ButtonColor = clBlack + Caption = 'Background color' + Margin = 4 + OnColorChanged = cbBackColorColorChanged + end + end + object gbColorView: TGroupBox + AnchorSideLeft.Control = Owner + AnchorSideTop.Control = Owner + Left = 6 + Height = 105 + Top = 6 + Width = 152 + BorderSpacing.Around = 6 + Caption = 'Selected:' + ClientHeight = 85 + ClientWidth = 148 + TabOrder = 2 + object shColorView: TShape + Left = 8 + Height = 73 + Top = 4 + Width = 132 + Align = alClient + BorderSpacing.Left = 8 + BorderSpacing.Top = 4 + BorderSpacing.Right = 8 + BorderSpacing.Bottom = 8 + end + end +end diff --git a/components/jvcllaz/examples/JvOfficeColorPanel/main.pas b/components/jvcllaz/examples/JvOfficeColorPanel/main.pas new file mode 100644 index 000000000..076a84d06 --- /dev/null +++ b/components/jvcllaz/examples/JvOfficeColorPanel/main.pas @@ -0,0 +1,198 @@ +unit main; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls, + Spin, JvOfficeColorPanel; + +type + + { TForm1 } + + TForm1 = class(TForm) + cbFlatBorder: TCheckBox; + cbDefaultColorColor: TColorButton; + cbShowCustomColor: TCheckBox; + cbShowDefaultColor: TCheckBox; + cbShowNoneColor: TCheckBox; + cbShowSystemColors: TCheckBox; + cbShowUserColor: TCheckBox; + cbBackColor: TColorButton; + gbColorView: TGroupBox; + JvOfficeColorPanel1: TJvOfficeColorPanel; + Label1: TLabel; + lblColorSize: TLabel; + lblColorSpace: TLabel; + lblColorSpaceBottom1: TLabel; + lblColorSpaceTop: TLabel; + lblColorSpaceBottom: TLabel; + lblTopMargin: TLabel; + lblBottomMargin: TLabel; + Panel1: TPanel; + seColorSize: TSpinEdit; + seColorSpace: TSpinEdit; + seHorizontalMargin: TSpinEdit; + seColorSpaceTop: TSpinEdit; + seColorSpaceBottom: TSpinEdit; + seTopMargin: TSpinEdit; + seBottomMargin: TSpinEdit; + shColorView: TShape; + seButtonHeight: TSpinEdit; + procedure cbFlatBorderChange(Sender: TObject); + procedure cbDefaultColorColorColorChanged(Sender: TObject); + procedure cbShowCustomColorChange(Sender: TObject); + procedure cbShowDefaultColorChange(Sender: TObject); + procedure cbShowNoneColorChange(Sender: TObject); + procedure cbShowSystemColorsChange(Sender: TObject); + procedure cbShowUserColorChange(Sender: TObject); + procedure cbBackColorColorChanged(Sender: TObject); + procedure FormCreate(Sender: TObject); + procedure JvOfficeColorPanel1ColorChange(Sender: TObject); + procedure seButtonHeightChange(Sender: TObject); + procedure seColorSizeChange(Sender: TObject); + procedure seColorSpaceBottomChange(Sender: TObject); + procedure seColorSpaceChange(Sender: TObject); + procedure seColorSpaceTopChange(Sender: TObject); + procedure seBottomMarginChange(Sender: TObject); + procedure seHorizontalMarginChange(Sender: TObject); + procedure seTopMarginChange(Sender: TObject); + private + + public + + end; + +var + Form1: TForm1; + +implementation + +uses + LCLIntf, JvJCLUtils; + +{$R *.lfm} + +{ TForm1 } + +procedure TForm1.cbFlatBorderChange(Sender: TObject); +begin + JvOfficeColorPanel1.FlatBorder := cbFlatBorder.Checked; +end; + +procedure TForm1.cbShowCustomColorChange(Sender: TObject); +begin + JvOfficeColorPanel1.Properties.ShowCustomColor := cbShowCustomColor.Checked; +end; + +procedure TForm1.cbShowDefaultColorChange(Sender: TObject); +begin + JvOfficeColorPanel1.Properties.ShowDefaultColor := cbShowDefaultColor.Checked; +end; + +procedure TForm1.cbShowNoneColorChange(Sender: TObject); +begin + JvOfficeColorPanel1.Properties.ShowNoneColor := cbShowNoneColor.Checked; +end; + +procedure TForm1.cbShowSystemColorsChange(Sender: TObject); +begin + JvOfficeColorPanel1.Properties.ShowSystemColors := cbShowSystemColors.Checked; +end; + +procedure TForm1.cbShowUserColorChange(Sender: TObject); +begin + JvOfficeColorPanel1.Properties.ShowUserColors := cbShowUserColor.Checked; +end; + +procedure TForm1.cbBackColorColorChanged(Sender: TObject); +begin + JvOfficeColorPanel1.BackColor := cbBackColor.ButtonColor; +end; + +procedure TForm1.cbDefaultColorColorColorChanged(Sender: TObject); +begin + JvOfficeColorPanel1.Properties.DefaultColorColor := cbDefaultColorColor.ButtonColor; +end; + +procedure TForm1.FormCreate(Sender: TObject); +var + i: Integer; + c: TColor; +begin + JvOfficeColorPanel1.UserColors.BeginUpdate; + try + for i:=0 to 15 do begin + c := RGB(Random(256), Random(256), Random(256)); + JvOfficeColorPanel1.UserColors.Add(Format('$%.6x=($)', [c])); + end; + finally + JvOfficeColorPanel1.UserColors.EndUpdate; + end; + + cbBackColor.ButtonColor := JvOfficeColorPanel1.BackColor; + cbDefaultColorColor.ButtonColor := JvOfficeColorPanel1.Properties.DefaultColorColor; + seButtonHeight.Value := JvOfficeColorPanel1.Properties.ButtonHeight; + seColorSize.Value := JvOfficeColorPanel1.Properties.ColorSize; + seColorSpace.Value := JvOfficeColorPanel1.Properties.ColorSpace; + seColorSpaceTop.Value := JvOfficeColorPanel1.Properties.ColorSpaceTop; + seColorSpaceBottom.Value := JvOfficeColorPanel1.Properties.ColorSpaceBottom; + seHorizontalMargin.Value := JvOfficeColorPanel1.Properties.HorizontalMargin; + seTopMargin.Value := JvOfficeColorPanel1.Properties.TopMargin; + seBottomMargin.Value := JvOfficeColorPanel1.Properties.BottomMargin; +end; + +procedure TForm1.JvOfficeColorPanel1ColorChange(Sender: TObject); +begin + shColorView.Brush.Color := JvOfficeColorPanel1.SelectedColor; + if JvOfficeColorPanel1.SelectedColor = clNone then + shColorView.Brush.Style := bsClear + else + shColorView.Brush.Style := bsSolid; + gbColorView.Caption := 'Selected: ' + ColorToPrettyName(JvOfficeColorPanel1.SelectedColor); +end; + +procedure TForm1.seButtonHeightChange(Sender: TObject); +begin + JvOfficeColorPanel1.Properties.ButtonHeight := seButtonHeight.Value; +end; + +procedure TForm1.seColorSizeChange(Sender: TObject); +begin + JvOfficeColorPanel1.Properties.ColorSize := seColorSize.Value; +end; + +procedure TForm1.seColorSpaceBottomChange(Sender: TObject); +begin + JvOfficeColorPanel1.Properties.ColorSpaceBottom := seColorSpaceBottom.Value; +end; + +procedure TForm1.seColorSpaceChange(Sender: TObject); +begin + JvOfficeColorPanel1.Properties.ColorSpace := seColorSpace.Value; +end; + +procedure TForm1.seColorSpaceTopChange(Sender: TObject); +begin + JvOfficeColorPanel1.Properties.ColorSpaceTop := seColorSpaceTop.Value; +end; + +procedure TForm1.seHorizontalMarginChange(Sender: TObject); +begin + JvOfficeColorPanel1.Properties.HorizontalMargin := seHorizontalMargin.Value; +end; + +procedure TForm1.seBottomMarginChange(Sender: TObject); +begin + JvOfficeColorPanel1.Properties.BottomMargin := seBottomMargin.Value; +end; + +procedure TForm1.seTopMarginChange(Sender: TObject); +begin + JvOfficeColorPanel1.Properties.TopMargin := seTopMargin.Value; +end; + +end. + diff --git a/components/jvcllaz/packages/jvctrlslazr.lpk b/components/jvcllaz/packages/jvctrlslazr.lpk index c50283fcc..9f777d0e9 100644 --- a/components/jvcllaz/packages/jvctrlslazr.lpk +++ b/components/jvcllaz/packages/jvctrlslazr.lpk @@ -17,7 +17,7 @@ Movable bevel and panel, ruler, exandable panel (RollOut), group header, hyperte "/> <License Value="The JVCL is released in accordance with the MPL 1.1 license. To get your own copy or read it, go to http://www.mozilla.org/MPL/MPL-1.1.html. "/> <Version Major="1" Release="6"/> - <Files Count="9"> + <Files Count="10"> <Item1> <Filename Value="..\run\JvCtrls\jvhint.pas"/> <UnitName Value="JvHint"/> @@ -54,14 +54,21 @@ Movable bevel and panel, ruler, exandable panel (RollOut), group header, hyperte <Filename Value="..\run\JvCtrls\jvinstalllabel.pas"/> <UnitName Value="JvInstallLabel"/> </Item9> + <Item10> + <Filename Value="..\run\JvCtrls\jvofficecolorpanel.pas"/> + <UnitName Value="JvOfficeColorPanel"/> + </Item10> </Files> - <RequiredPkgs Count="2"> + <RequiredPkgs Count="3"> <Item1> - <PackageName Value="JvCoreLazR"/> + <PackageName Value="JvStdCtrlsLazR"/> </Item1> <Item2> - <PackageName Value="FCL"/> + <PackageName Value="JvCoreLazR"/> </Item2> + <Item3> + <PackageName Value="FCL"/> + </Item3> </RequiredPkgs> <UsageOptions> <UnitPath Value="$(PkgOutDir)"/> diff --git a/components/jvcllaz/resource/jvctrlsreg.res b/components/jvcllaz/resource/jvctrlsreg.res index 2fa2215e898a1c5e30c7a337df48c5ff5eb0206f..3da02600b558b24f3579494c0fb5b6b2a0e3d633 100644 GIT binary patch delta 1831 zcmb`HJx;?w5QU#o&>+!5nF~;ahK2&fj|4&lAw(SsMY#gqS`j5(8Wg2SMa=;y%mwT# zY?)gOZ+2~Gy#dFGm^|C#_3XDZ<8{8?JByFb=gHgQVh6YYAkx7jZt#RYuK2sgIWBqh zam(WY_c+7d<okGklDzDh1I_?a&OO@oha1o_SXiFcY7VOsfpGN|H4;ojuYp(!RS_FO z5r?-$LKR`@SX-e?<uy3IvgQ0TCn(6V%APe}qYf$1xOSBw%lWfhD0M_AI+<h?9g&Q3 zPOZ<&%!-68W7=`ddJtJ_EvhVdWxhjJ38_`lG+GPe+HU=D#69u>;W_NkuOO`><m8at zjg*exq%{to8;#k}+-|RdrUHtV&s2f)Jnc~&$nqXVM}|F0WAw{1^M3-7WeX|0t<~!< zzV!e!6i~Fv83PpXI#$v6*hL^23@9CH&*A!;ffT>FttQl+gVOikJyp?oa@QmQMN7IW zb)3}u6SO6V|39wV%HGPNgsM%@%1L30`DsyE>auAyIf^U^9!O3r)F`6(+koXktyoQ{ EAN^gE(f|Me delta 9 QcmaE{jA_pdrVTbd02k{7UjP6A diff --git a/components/jvcllaz/run/JvCore/jvexcontrols.pas b/components/jvcllaz/run/JvCore/jvexcontrols.pas index 221a4105e..e379fb60f 100644 --- a/components/jvcllaz/run/JvCore/jvexcontrols.pas +++ b/components/jvcllaz/run/JvCore/jvexcontrols.pas @@ -90,10 +90,7 @@ procedure DrawDotNetControl(Control: TWinControl; AColor: TColor; InControl: Boo procedure HandleDotNetHighlighting(Control: TWinControl; const Msg: TLMessage; MouseOver: Boolean; Color: TColor); -procedure CreateWMMessage(var Mesg: TLMessage; Msg: Cardinal; WParam: WPARAM; LParam: LPARAM); overload; {$IFDEF SUPPORTS_INLINE} inline {$ENDIF} -//function CreateWMMessage(Msg: Integer; WParam: PtrInt; LParam: PtrInt): TLMessage; overload; {$IFDEF SUPPORTS_INLINE} inline {$ENDIF} -//function CreateWMMessage(Msg: Integer; WParam: PtrInt; LParam: TControl): TLMessage; overload; {$IFDEF SUPPORTS_INLINE} inline {$ENDIF} - +procedure CreateWMMessage(out Mesg: TLMessage; Msg: Cardinal; WParam: WPARAM; LParam: LPARAM); overload; {$IFDEF SUPPORTS_INLINE} inline {$ENDIF} function SmallPointToLong(const Pt: TSmallPoint): LongInt; {$IFDEF SUPPORTS_INLINE} inline {$ENDIF} function ShiftStateToKeyData(Shift: TShiftState): Longint; function GetFocusedControl(AControl: TControl): TWinControl; @@ -303,7 +300,7 @@ end; begin end; -procedure CreateWMMessage(var Mesg: TLMessage; Msg: Cardinal; WParam: WPARAM; LParam: LPARAM); +procedure CreateWMMessage(out Mesg: TLMessage; Msg: Cardinal; WParam: WPARAM; LParam: LPARAM); begin Mesg.Msg := Msg; Mesg.WParam := WParam; diff --git a/components/jvcllaz/run/JvCore/jvjclutils.pas b/components/jvcllaz/run/JvCore/jvjclutils.pas index 36f43db49..ea329accb 100644 --- a/components/jvcllaz/run/JvCore/jvjclutils.pas +++ b/components/jvcllaz/run/JvCore/jvjclutils.pas @@ -47,7 +47,8 @@ interface uses LCLIntf, LCLType, - SysUtils, Classes, Graphics; + SysUtils, Classes, Graphics, + JvTypes; const (******************** NOT CONVERTED @@ -322,8 +323,10 @@ function TrueInflateRect(const R: TRect; const I: Integer): TRect; {**** Color routines } procedure RGBToHSV(R, G, B: Integer; var H, S, V: Integer); function RGBToBGR(Value: Cardinal): Cardinal; +***********************************) function ColorToPrettyName(Value: TColor): string; function PrettyNameToColor(const Value: string): TColor; +(******************** NOT CONVERTED *** {**** other routines } procedure SwapInt(var Int1, Int2: Integer); {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF SUPPORTS_INLINE} @@ -366,6 +369,7 @@ function ReplaceAllStrings(const S: string; Words, Frases: TStrings): string; function ReplaceStrings(const S: string; PosBeg, Len: Integer; Words, Frases: TStrings; var NewSelStart: Integer): string; { CountOfLines calculates the lines count in a string, S, each line must be separated from another with CrLf sequence } + *****************************) function CountOfLines(const S: string): Integer; { DeleteLines deletes all lines from strings which in the words, words. The word of will be deleted from strings. } @@ -373,6 +377,7 @@ procedure DeleteOfLines(Ss: TStrings; const Words: array of string); { DeleteEmptyLines deletes all empty lines from strings, Ss. Lines contained only spaces also deletes. } procedure DeleteEmptyLines(Ss: TStrings); +(************************** NOT CONVERTED ************ { SQLAddWhere addes or modifies existing where-statement, where, to the strings, SQL. Note: If strings SQL allready contains where-statement, @@ -3568,6 +3573,7 @@ begin for I := 0 to Words.Count - 1 do Result := ReplaceString(Result, Words[I], Frases[I]); end; +*********************************) function CountOfLines(const S: string): Integer; begin @@ -3600,6 +3606,7 @@ begin DeleteOfLines(Ss,['']); end; +(************************* NOT CONVERTED **** procedure SQLAddWhere(SQL: TStrings; const Where: string); var I, J: Integer; @@ -9667,6 +9674,7 @@ begin (Value and $0000FF00) or ((Value and $000000FF) shl 16); end; +*************************) function ColorToPrettyName(Value: TColor): string; var @@ -9728,6 +9736,7 @@ begin Result := clNone; end; +(********************** NOT CONVERTED **** {$IFNDEF CLR} function StartsText(const SubStr, S: string): Boolean; begin diff --git a/components/jvcllaz/run/JvCore/jvtypes.pas b/components/jvcllaz/run/JvCore/jvtypes.pas index 2e3f6d896..21bb4694f 100644 --- a/components/jvcllaz/run/JvCore/jvtypes.pas +++ b/components/jvcllaz/run/JvCore/jvtypes.pas @@ -39,7 +39,9 @@ unit JvTypes; interface uses - Classes, Controls, Forms, Graphics, LMessages, SysUtils; + LCLType, + Classes, Controls, Forms, Graphics, LMessages, SysUtils, + JvResources; const MaxPixelCount = 32767; @@ -385,11 +387,12 @@ const DefaultHotTrackColor = $00D2BDB6; DefaultHotTrackFrameColor = $006A240A; -(******************** type + (******************** NOT CONVERTED *********** // from JvListView.pas TJvSortMethod = (smAutomatic, smAlphabetic, smNonCaseSensitive, smNumeric, smDate, smTime, smDateTime, smCurrency); TJvListViewColumnSortEvent = procedure(Sender: TObject; Column: Integer; var AMethod: TJvSortMethod) of object; + **********************************************) // from JvOfficeColorPanel.pas TJvAddInControlSiteInfo = record @@ -404,6 +407,10 @@ type TJvColorQuadLayOut = (cqlNone, cqlLeft, cqlRight, cqlClient); TJvGetAddInControlSiteInfoEvent = procedure(Sender: TControl; var ASiteInfo: TJvAddInControlSiteInfo) of object; + TJvColorDialogOption = (jcdFullOpen, jcdPreventFullOpen, jcdShowHelp, + jcdSolidColor, jcdAnyColor); + TJvColorDialogOptions = set of TJvColorDialogOption; + // from JvColorProvider.pas TColorType = (ctStandard, ctSystem, ctCustom); @@ -417,19 +424,12 @@ const ColCount = 20; StandardColCount = 40; SysColCount = 30; - {$IFDEF COMPILER5} clSystemColor = TColor($80000000); clHotLight = TColor(clSystemColor or COLOR_HOTLIGHT); clGradientActiveCaption = TColor(clSystemColor or COLOR_GRADIENTACTIVECAPTION); clGradientInactiveCaption = TColor(clSystemColor or COLOR_GRADIENTINACTIVECAPTION); clMenuHighlight = TColor(clSystemColor or COLOR_MENUHILIGHT); clMenuBar = TColor(clSystemColor or COLOR_MENUBAR); - {$ENDIF COMPILER5} - {$IFDEF COMPILER6} - {$IF not declared(clHotLight)} - {$MESSAGE ERROR 'You do not have installed Delphi 6 Update 2. Please install this before installing the JVCL. http://www.borland.com/downloads/registered/del6_reg_updates_prompt.html'} - {$IFEND} - {$ENDIF COMPILER6} ColorValues: array [0 .. ColCount - 1] of TDefColorItem = ( (Value: clBlack; Constant: 'clBlack'; Description: RsClBlack), @@ -537,6 +537,7 @@ const ); +(********************** NOT CONVERTED **** type TJvSizeRect = packed record Top: Integer; @@ -692,6 +693,9 @@ type {$ENDIF !CLR} ***************) +function DrawTextBiDiModeFlags(AControl: TControl; AFlags: LongInt): LongInt; + + implementation { TJvPersistent } @@ -788,5 +792,29 @@ begin Changed; end; +{------------------------------------------------------------------------------} + +function DrawTextBiDiModeFlags(AControl: TControl; AFlags: LongInt): LongInt; +var + alignment: TAlignment; +begin + Result := AFlags; + if AControl.UseRightToLeftAlignment then begin + if AFlags and DT_RIGHT <> 0 then + alignment := taRightJustify + else + if AFlags and DT_CENTER <> 0 then + alignment := taCenter + else + alignment := taLeftJustify; + case alignment of + taLeftJustify: Result := Result or DT_RIGHT; + taRightJustify: Result := Result and not DT_RIGHT; + end; + end; + if AControl.UseRightToLeftReading then + Result := Result or DT_RTLREADING; +end; + end. diff --git a/components/jvcllaz/run/JvCtrls/jvgroupheader.pas b/components/jvcllaz/run/JvCtrls/jvgroupheader.pas index 305bd94f2..f2e09210a 100644 --- a/components/jvcllaz/run/JvCtrls/jvgroupheader.pas +++ b/components/jvcllaz/run/JvCtrls/jvgroupheader.pas @@ -270,6 +270,13 @@ begin ts := Canvas.TextStyle; ts.ShowPrefix := false; ts.RightToLeft := IsRightToLeft; + ts.ExpandTabs := Flags and DT_EXPANDTABS <> 0; + ts.Wordbreak := Flags and DT_WORDBREAK <> 0; + ts.SingleLine := not ts.WordBreak; + ts.EndEllipsis := Flags and DT_END_ELLIPSIS <> 0; + ts.Alignment := taLeftJustify; + if Flags and DT_RIGHT <> 0 then ts.Alignment := taRightJustify; + if Flags and DT_CENTER <> 0 then ts.Alignment := taCenter; Canvas.Font := Font; if not Enabled then begin diff --git a/components/jvcllaz/run/JvCtrls/jvhtcontrols.pas b/components/jvcllaz/run/JvCtrls/jvhtcontrols.pas index 3a89fac15..c74292334 100644 --- a/components/jvcllaz/run/JvCtrls/jvhtcontrols.pas +++ b/components/jvcllaz/run/JvCtrls/jvhtcontrols.pas @@ -341,8 +341,8 @@ type procedure SetSuperSubScriptRatio(const Value: Double); protected procedure CalculatePreferredSize(var PreferredWidth, PreferredHeight: integer; - WithThemeSpace: Boolean); override; - procedure CalculateSize(MaxWidth: integer; var NeededWidth, NeededHeight: integer); + {%H-}WithThemeSpace: Boolean); override; + procedure CalculateSize(MaxWidth: integer; out NeededWidth, NeededHeight: integer); function ComputeLayoutRect: TRect; procedure FontChanged(Sender: TObject); override; procedure MouseMove(Shift: TShiftState; X, Y: Integer); override; @@ -895,7 +895,7 @@ begin end; procedure TJvCustomHTLabel.CalculateSize(MaxWidth: integer; - var NeededWidth, NeededHeight: integer); + out NeededWidth, NeededHeight: integer); begin Canvas.Handle; Canvas.Font.Assign(Font); diff --git a/components/jvcllaz/run/JvCtrls/jvmovablebevel.pas b/components/jvcllaz/run/JvCtrls/jvmovablebevel.pas index 2c5a8e5b1..b7c2bcfcf 100644 --- a/components/jvcllaz/run/JvCtrls/jvmovablebevel.pas +++ b/components/jvcllaz/run/JvCtrls/jvmovablebevel.pas @@ -126,6 +126,7 @@ procedure TJvMovableBevel.DoMove(Shift: TShiftState; DeltaX, DeltaY: Integer); begin // Must work on it in order to make expand and shrink the way coreldraw does when // shift and ctrl keys are pressed. + { If ssCtrl in shift then begin if Abs(FStartPoint.X - Left) < Abs(FStartPoint.Y - Top) then diff --git a/components/jvcllaz/run/JvCtrls/jvofficecolorpanel.pas b/components/jvcllaz/run/JvCtrls/jvofficecolorpanel.pas new file mode 100644 index 000000000..b2426014d --- /dev/null +++ b/components/jvcllaz/run/JvCtrls/jvofficecolorpanel.pas @@ -0,0 +1,2487 @@ +{----------------------------------------------------------------------------- +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: JvOfficeColorPanel.PAS, released on 2004-02-26. + +The Initial Developer of the Original Code is dejoy [dejoy att ynl dott gov dott cn] +All Rights Reserved. + +Contributor(s): dejoy. + +You may retrieve the latest version of this file at the Project JEDI's JVCL home page, +located at http://jvcl.delphi-jedi.org + +Description: + a Color panel look like Microsoft office Color picker,make to customable Highly. + +Known Issues: +-----------------------------------------------------------------------------} +// $Id$ + +unit JvOfficeColorPanel; + +{$mode objfpc}{$H+} + +interface + +uses + LCLIntf, + SysUtils, Classes, Graphics, Controls, Forms, Buttons, Dialogs, ExtCtrls, + JvTypes, JvPanel; + +const + Tag_DefaultColorCaption = 0; + Tag_CustomColorCaption = 1; + Tag_NoneColorCaption = 2; + Tag_DefaultColorHint = 3; + Tag_CustomColorHint = 4; + Tag_NoneColorHint = 5; + Tag_ShowColorsHint = 10; + Tag_ShowAddInHint = 12; + Tag_ShowStandardColors = 15; + Tag_ShowSystemColors = 16; + Tag_ShowUserColors = 17; + Tag_HoldCustomColor = 18; + + Tag_ButtonHeight = 20; + Tag_ButtonWidth = 21; + Tag_ColorSize = 22; + Tag_ColorSpace = 23; + Tag_ColorSpaceTop = 24; + Tag_ColorSpaceBottom = 25; + Tag_TopMargin = 26; + Tag_BottomMargin = 27; + Tag_HorizontalMargin = 28; + Tag_RightClickSelect = 29; + Tag_SelectIfPopup = 30; + + MinColorSize = 18; + MinColorSpace = 0; + MinColorSpaceTop = 4; + MinColorSpaceBottom = 4; + MinTopMargin = 4; + MinBottomMargin = 4; + MinHorizontalMargin = 4; + MinButtonHeight = MinColorSize + 7; + MinButtonWidth = 23; + + PrimaryGroupIndex = 1; + LineColorCount = 8; + MaxLineRow = 8; + MaxSectColorCount = LineColorCount * MaxLineRow; + +type + TJvOfficeColorPanelClass = class of TJvCustomOfficeColorPanel; + + TJvColorSpeedButton = class(TSpeedButton) //TJvSpeedButton) + private + FDrawColor: TColor; + FDisabledDrawColor: TColor; + FCanDrawInnerFrame: Boolean; + FCanDrawGlyph: Boolean; + FCanDrawColorQuad: Boolean; + FColorQuadLayOut: TJvColorQuadLayOut; + FOnEnabledChanged: TNotifyEvent; + procedure SetDrawColor(const Value: TColor); + procedure SetDisabledDrawColor(const Value: TColor); + procedure SetEdgeWidth(const Value: Integer); + procedure SetFColorQuadLayOut(const Value: TJvColorQuadLayOut); + procedure SetCanDrawInnerFrame(const Value: Boolean); + procedure SetCanDrawGlyph(const Value: Boolean); + procedure SetCanDrawColorQuad(const Value: Boolean); + protected + FEdgeWidth: Integer; + procedure Paint; override; + procedure EnabledChanged; override; + function GetEdgeWidth: Integer; virtual; + public + constructor Create(AOwner: TComponent); override; + property Canvas; + property CanDrawColorQuad: Boolean read FCanDrawColorQuad write SetCanDrawColorQuad default True; + property CanDrawGlyph: Boolean read FCanDrawGlyph write SetCanDrawGlyph default True; + property CanDrawInnerFrame: Boolean read FCanDrawInnerFrame write SetCanDrawInnerFrame default False; + property ColorQuadLayOut: TJvColorQuadLayOut read FColorQuadLayOut write SetFColorQuadLayOut default cqlClient; + property DrawColor: TColor read FDrawColor write SetDrawColor default clDefault; + property DisabledDrawColor: TColor read FDisabledDrawColor write SetDisabledDrawColor default clGray; + property EdgeWidth: Integer read GetEdgeWidth write SetEdgeWidth; + property OnEnabledChanged: TNotifyEvent read FOnEnabledChanged write FOnEnabledChanged; + end; + + TJvOfficeColorDrawer = class(TJvColorSpeedButton) + public + constructor Create(AOwner: TComponent); override; + property CanDrawGlyph default False; + end; + + // (ahuser) TJvColorDialog is not registered as component + TJvOfficeColorDialog = class(TColorDialog) + published + property OnShow; + property OnClose; + end; + + TJvOfficeColorPanelProperties = class(TJvPersistentProperty) + private + FShowNoneColor: Boolean; + FShowDefaultColor: Boolean; + FShowCustomColor: Boolean; + FDefaultColorColor: TColor; + FNoneColorColor: TColor; + FShowColorsHint: Boolean; + FShowAddInHint: Boolean; + + FDefaultColorCaption: string; + FCustomColorCaption: string; + FNoneColorCaption: string; + FDefaultColorHint: string; + FCustomColorHint: string; + FNoneColorHint: string; + + FTopMargin: Integer; + FColorSpaceBottom: Integer; + FHorizontalMargin: Integer; + FColorSpace: Integer; + FColorSpaceTop: Integer; + FButtonHeight: Integer; + FColorSize: Integer; + FBottomMargin: Integer; + + FRightClickSelect: Boolean; + FSelectIfPopup: Boolean; + FCustomColorFont: TFont; + FDefaultColorFont: TFont; + FNoneColorFont: TFont; + FShowStandardColors: Boolean; + FShowSystemColors: Boolean; + FShowUserColors: Boolean; + FHoldCustomColor: Boolean; + FFilerTag:string; + procedure SetIntegerValue(const Index, Value: Integer); + procedure SetStringValue(const Index: Integer; const Value: string); + procedure SetBooleanValue(const Index: Integer; const Value: Boolean); + procedure SetColorValue(const Index: Integer; const Value: TColor); + procedure SetFontValue(const Index: Integer; const Value: TFont); + procedure OnFontChange(Sender: TObject); + procedure ReadData(Reader: TReader); + protected + procedure CreateDefaultText; virtual; + procedure DefineProperties(Filer: TFiler); override; + public + constructor Create(AOwner: TPersistent); override; + destructor Destroy; override; + procedure Assign(Source: TPersistent); override; + property ShowStandardColors: Boolean index Tag_ShowStandardColors read FShowStandardColors write SetBooleanValue default True; + published + property ShowNoneColor: Boolean index Tag_NoneColorCaption read FShowNoneColor write SetBooleanValue default False; + property ShowDefaultColor: Boolean index Tag_DefaultColorCaption read FShowDefaultColor write SetBooleanValue default True; + property ShowCustomColor: Boolean index Tag_CustomColorCaption read FShowCustomColor write SetBooleanValue default True; + property ShowAddInHint: Boolean index Tag_ShowAddInHint read FShowAddInHint write SetBooleanValue default True; + property ShowColorsHint: Boolean index Tag_ShowColorsHint read FShowColorsHint write SetBooleanValue default True; + property ShowSystemColors: Boolean index Tag_ShowSystemColors read FShowSystemColors write SetBooleanValue default False; + property ShowUserColors: Boolean index Tag_ShowUserColors read FShowUserColors write SetBooleanValue default False; + property HoldCustomColor: Boolean index Tag_HoldCustomColor read FHoldCustomColor write SetBooleanValue default False; + + property NoneColorCaption: string index Tag_NoneColorCaption read FNoneColorCaption write SetStringValue; + property DefaultColorCaption: string index Tag_DefaultColorCaption read FDefaultColorCaption write SetStringValue; + property CustomColorCaption: string index Tag_CustomColorCaption read FCustomColorCaption write SetStringValue; + property NoneColorHint: string index Tag_NoneColorHint read FNoneColorHint write SetStringValue; + property DefaultColorHint: string index Tag_DefaultColorHint read FDefaultColorHint write SetStringValue; + property CustomColorHint: string index Tag_CustomColorHint read FCustomColorHint write SetStringValue; + property NoneColorColor: TColor index Tag_NoneColorCaption read FNoneColorColor write SetColorValue default clNone; + property DefaultColorColor: TColor index Tag_DefaultColorCaption read FDefaultColorColor write SetColorValue default clDefault; + + property NoneColorFont: TFont index Tag_NoneColorCaption read FNoneColorFont write SetFontValue; + property DefaultColorFont: TFont index Tag_DefaultColorCaption read FDefaultColorFont write SetFontValue; + property CustomColorFont: TFont index Tag_CustomColorCaption read FCustomColorFont write SetFontValue; + + property TopMargin: Integer index Tag_TopMargin read FTopMargin write SetIntegerValue default MinTopMargin; + property BottomMargin: Integer index Tag_BottomMargin read FBottomMargin write SetIntegerValue default MinBottomMargin; + property HorizontalMargin: Integer index Tag_HorizontalMargin read FHorizontalMargin write SetIntegerValue default MinHorizontalMargin; + property ColorSpace: Integer index Tag_ColorSpace read FColorSpace write SetIntegerValue default MinColorSpace; + property ColorSpaceTop: Integer index Tag_ColorSpaceTop read FColorSpaceTop write SetIntegerValue default MinColorSpaceTop; + property ColorSpaceBottom: Integer index Tag_ColorSpaceBottom read FColorSpaceBottom write SetIntegerValue default MinColorSpaceBottom; + property ColorSize: Integer index Tag_ColorSize read FColorSize write SetIntegerValue default MinColorSize; + property ButtonHeight: Integer index Tag_ButtonHeight read FButtonHeight write SetIntegerValue default MinButtonHeight; + + property RightClickSelect: Boolean index Tag_RightClickSelect read FRightClickSelect write SetBooleanValue default False; + property SelectIfPopup: Boolean index Tag_SelectIfPopup read FSelectIfPopup write SetBooleanValue default False; + end; + + TJvCustomOfficeColorPanel = class(TJvCustomArrangePanel) //, IJvHotTrack) + private + FStandardColors: TStringList; + FSystemColors: TStringList; + FUserColors: TStringList; + FStandardColorDrawers: TList; + FSystemColorDrawers: TList; + FUserColorDrawers: TList; + FAddInControls: TList; + FButtonNoneColor: TJvColorSpeedButton; + FButtonDefaultColor: TJvColorSpeedButton; + FButtonCustomColor: TJvColorSpeedButton; + FCustomColorDrawer: TJvOfficeColorDrawer; + FPriorCheckedButton: TJvColorSpeedButton; + FDividerLine1: TControl; + FDividerLine2: TControl; + FDividerLine3: TControl; + FProperties: TJvOfficeColorPanelProperties; + FColorDialog: TJvOfficeColorDialog; + FSelectedColor: TColor; + FBackgroundColor: TColor; + FInited: Boolean; + FNeedReDrawDownState: Boolean; + //in SetSeletedColor,is need to refresh button down state. + FInRearrangeControls: Boolean; + FOnColorChange: TNotifyEvent; + FOnHoldCustomColor: TJvHoldCustomColorEvent; + FOnColorButtonClick: TNotifyEvent; + FOnShowOwnerColorDialog: TNotifyEvent; + FOnGetAddInControlSiteInfo: TJvGetAddInControlSiteInfoEvent; + FClickColorType: TJvClickColorType; + procedure SetSelectedColor(const Value: TColor); + function GetColorDlgCustomColors: TStrings; + procedure SetColorDlgCustomColors(const Value: TStrings); + procedure SetProperties(const Value: TJvOfficeColorPanelProperties); + function GetControlBackgroundColor: TColor; + procedure SetControlBackgroundColor(const Value: TColor); + + procedure SetStandardColors(const Value: TStringList); + procedure SetSystemColors(const Value: TStringList); + procedure SetUserColors(const Value: TStringList); + procedure RedirectToColorButtonClick(Sender: TObject; Button: TMouseButton; + Shift: TShiftState; X, Y: Integer); + + procedure DoColorDrawersEnabledChange(Sender: TObject); + procedure DoLoadedUserColors(Sender: TObject); + procedure DoHoldedCustomColor(Sender: TObject;AColor: TColor); + + private + (****************** NOT CONVERTED ************************ + FColorDialogOptions: TJvColorDialogOptions; // not supported by LCL + FHotTrack: Boolean; + FHotTrackFont: TFont; + FHotTrackFontOptions: TJvTrackFontOptions; + FHotTrackOptions: TJvHotTrackOptions; // would require TJvSpeedButton + procedure SetColorDialogOptions(const Value: TJvColorDialogOptions); + + {IJvHotTrack} + function GetHotTrack: Boolean; + function GetHotTrackFont: TFont; + function GetHotTrackFontOptions: TJvTrackFontOptions; + function GetHotTrackOptions: TJvHotTrackOptions; + procedure SetHotTrack(Value: Boolean); + procedure SetHotTrackOptions(Value: TJvHotTrackOptions); + procedure SetHotTrackFont(Value: TFont); + procedure SetHotTrackFontOptions(Value: TJvTrackFontOptions); + procedure IJvHotTrack_Assign(Source: IJvHotTrack); + procedure IJvHotTrack.Assign = IJvHotTrack_Assign; + procedure DoHotTrackOptionsChanged(Sender: TObject); + *********************************************************) + + protected + procedure DoColorButtonClick(Sender: TObject); virtual; + procedure DoSelectedColorChange(Sender: TObject); virtual; + procedure DoGetAddInControlSiteInfo(Sender: TControl; var ASiteInfo: + TJvAddInControlSiteInfo); virtual; + procedure DoPropertiesChanged(Sender: TObject; const PropName: string); virtual; + procedure CreateWnd; override; + procedure Loaded; override; + procedure Resize; override; + procedure ShowHintChanged; override; + function CreateStandardColors(ColorList: TStrings): Integer; virtual; + function CreateSystemColors(ColorList: TStrings): Integer; virtual; + + { If you wnat to create published color list by default,override this procedure. + If you want to change ColorList,make sure call strings.beginupdate before change, + and call strings.EndUpdate after changed. } + function CreateUserColors({%H-}ColorList: TStrings): Integer; virtual; + procedure CreateColorDrawersByColors(DrawersList: TList; ColorsList: TStringList; AVisible: Boolean); + procedure SetEnabled( Value: Boolean); override; + + // Don't change the following list, the result might unpredictability. + property StandardColorDrawers: TList read FStandardColorDrawers; + property SystemColorDrawers: TList read FSystemColorDrawers; + property UserColorDrawers: TList read FUserColorDrawers; + property AddInControls: TList read FAddInControls; + + property ButtonNoneColor: TJvColorSpeedButton read FButtonNoneColor; + property ButtonDefaultColor: TJvColorSpeedButton read FButtonDefaultColor; + property ButtonCustomColor: TJvColorSpeedButton read FButtonCustomColor; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + + procedure CreateStandardColorDrawers; virtual; + procedure CreateSystemColorDrawers; virtual; + procedure CreateUserColorDrawers; virtual; + procedure RearrangeControls; virtual; + procedure RefreshControls; + + property ColorDialog: TJvOfficeColorDialog read FColorDialog write FColorDialog; + property SelectedColor: TColor read FSelectedColor write SetSelectedColor default clBlack; + property BackColor: TColor read GetControlBackgroundColor write SetControlBackgroundColor default clBtnFace; + + property Color: TColor read GetControlBackgroundColor write SetControlBackgroundColor; + property ClickColorType: TJvClickColorType read FClickColorType; + + { //Each custom color is represented as a string of the form ColorValue=ColorDescription. + For example, the following string sets the custom color list. + clBlack = Black + $00003333 = Olive Green + if set ColorDescription to cUseDefaultColorHint('($)'),the ColorDescription will be put to ColorToPrettyName(ColorValue) at runtime, + such as: + 'clBlack = ($)' will be put to 'clBlack = Black' at runtime; + '$00113333 = ($)' will be put to '$00113333 = $00113333' at runtime; + + Up to MaxSectColorCount custom colors can be set. + + // If you changed Colors list manual,also you must call CreateXXXColorButtons and RearrangeControls to refresh manual, + or call RefreshControls to refresh. + // The StandardColors and SystemColors did't published by default,so it's not stroed in DFM, you just only change the value at runtime, + if you want stroed StandardColors and SystemColors,create a new control descended from TJvOfficeColorPanel and + put them to published section. + + //if you want to change ColorList,make sure call strings.beginupdate before change, + //and call strings.EndUpdate after changed. } + property StandardColors: TStringList read FStandardColors write SetStandardColors; + property SystemColors: TStringList read FSystemColors write SetSystemColors; + property UserColors: TStringList read FUserColors write SetUserColors; + property ColorDlgCustomColors: TStrings read GetColorDlgCustomColors write SetColorDlgCustomColors; + property Properties: TJvOfficeColorPanelProperties read FProperties write SetProperties; + + (****************** NOT CONVERTED ******** + property ColorDialogOptions: TJvColorDialogOptions + read FColorDialogOptions write SetColorDialogOptions default []; + + property HotTrack: Boolean read GetHotTrack write SetHotTrack default False; + property HotTrackFont: TFont read GetHotTrackFont write SetHotTrackFont; + property HotTrackFontOptions: TJvTrackFontOptions read GetHotTrackFontOptions write SetHotTrackFontOptions default DefaultTrackFontOptions; + property HotTrackOptions: TJvHotTrackOptions read GetHotTrackOptions write SetHotTrackOptions; + *****************************************) + + property OnColorChange: TNotifyEvent read FOnColorChange write FOnColorChange; + property OnColorButtonClick: TNotifyEvent read FOnColorButtonClick write FOnColorButtonClick; + property OnHoldCustomColor: TJvHoldCustomColorEvent read FOnHoldCustomColor write FOnHoldCustomColor; + property OnShowOwnerColorDialog: TNotifyEvent read FOnShowOwnerColorDialog write FOnShowOwnerColorDialog; + property OnGetAddInControlSiteInfo: TJvGetAddInControlSiteInfoEvent read FOnGetAddInControlSiteInfo write FOnGetAddInControlSiteInfo; + end; + + TJvOfficeColorPanel = class(TJvCustomOfficeColorPanel) + private + FFilerTag: string; + procedure ReadData(Reader: TReader); + protected + procedure DefineProperties(Filer: TFiler); override; + published + // UserColors must be load fist on read from the DFM file. + property UserColors; + property BevelInner; + property BevelOuter; + property BevelWidth; + property BorderSpacing; + property BorderWidth; + property FlatBorder; + property FlatBorderColor; + property BackColor; + property SelectedColor; + property ColorDlgCustomColors; + property BiDiMode; + property DragCursor; + property DragKind; + property ParentBiDiMode; + property OnEndDock; + property OnGetSiteInfo; + + (************************ NOT CONVERTED ***** + property ColorDialogOptions; + property HotTrack; + property HotTrackFont; + property HotTrackFontOptions; + property HotTrackOptions; + property OnCanResize; + ********************************************) + + property Align; + property Anchors; + property Constraints; + property DragMode; + property Enabled; + property Font; + property ParentFont; + property ParentShowHint; + property PopupMenu; + property ShowHint; + property TabOrder; + property TabStop; + property Visible; + property OnConstrainedResize; + property OnContextPopup; + property OnDragDrop; + property OnDragOver; + property OnEndDrag; + property OnEnter; + property OnExit; + property OnMouseDown; + property OnMouseMove; + property OnMouseUp; + property OnMouseEnter; + property OnMouseLeave; + property OnResize; + property OnStartDrag; + + property Properties; + property OnColorChange; + property OnColorButtonClick; + + { If OnShowOwnerColorDialog not nil,the default ColorDialog will not show, + so you can show coustom ColorDialog yourself. } + property OnShowOwnerColorDialog; + property OnClick; + end; + + TJvOfficePanelDividerLine = class(TBevel) + public + constructor Create(AOwner: TComponent); override; + published + property Shape default bsTopLine; + end; + +var + JvDividerLineClass: TControlClass = TJvOfficePanelDividerLine; + +function GetTopOwner(AComponent: TComponent): TComponent; +function JvReaderReadColor(Reader: TReader):TColor; +procedure JvReaderReadStrings(Reader: TReader;Strings:TStrings); +(******************** NOT CONVERTED ******** +function JvReaderReadColorDialogOptions(Reader: TReader): TJvColorDialogOptions; +*******************************************) + + +implementation + +uses + JvJCLUtils, JvResources, Math; + +const + cNoneColorCaption = 'NoneColorCaption'; + cNoneColorColor = 'NoneColorColor'; + cNoneColorFont = 'NoneColorFont'; + cNoneColorHint = 'NoneColorHint'; + cDefaultColorCaption = 'DefaultColorCaption'; + cDefaultColorColor = 'DefaultColorColor'; + cDefaultColorFont = 'DefaultColorFont'; + cDefaultColorHint = 'DefaultColorHint'; + cCustomColorCaption = 'CustomColorCaption'; + cCustomColorFont = 'CustomColorFont'; + cCustomColorHint = 'CustomColorHint'; + cShowNoneColor = 'ShowNoneColor'; + cShowDefaultColor = 'ShowDefaultColor'; + cShowCustomColor = 'ShowCustomColor'; + cShowAddInHint = 'ShowAddInHint'; + cShowColorsHint = 'ShowColorsHint'; + cShowStandardColors = 'ShowStandardColors'; + cShowSystemColors = 'ShowSystemColors'; + cShowUserColors = 'ShowUserColors'; + cHoldCustomColor = 'HoldCustomColor'; + cRightClickSelect = 'RightClickSelect'; + cSelectIfPopup = 'SelectIfPopup'; + + cUseDefaultColorHint = '($)'; + +type + TControlAccessProtected = class(TControl); + TWinControlAccessProtected = class(TWinControl); + + +{ TJvOfficePanelDividerLine } + +constructor TJvOfficePanelDividerLine.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + Shape := bsTopLine; +end; + +{ TJvOfficeColorPanelProperties } + +constructor TJvOfficeColorPanelProperties.Create(AOwner: TPersistent); +begin + inherited Create(AOwner); + FShowNoneColor := False; + FShowDefaultColor := True; + FShowCustomColor := True; + FShowColorsHint := True; + FShowAddInHint := True; + FShowStandardColors := True; + FShowSystemColors := False; + FShowUserColors := False; + FHoldCustomColor := False; + FNoneColorColor := clNone; + FDefaultColorColor := clDefault; + + FDefaultColorFont := TFont.Create; + FDefaultColorFont.OnChange := @OnFontChange; + FNoneColorFont := TFont.Create; + FNoneColorFont.OnChange := @OnFontChange; + FCustomColorFont := TFont.Create; + FCustomColorFont.OnChange := @OnFontChange; + + FHorizontalMargin := MinHorizontalMargin; + FTopMargin := MinTopMargin; + FBottomMargin := MinBottomMargin; + FButtonHeight := MinButtonHeight; + FColorSpace := MinColorSpace; + FColorSpaceTop := MinColorSpaceTop; + FColorSpaceBottom := MinColorSpaceBottom; + FColorSize := MinColorSize; + + FRightClickSelect := False; + FSelectIfPopup := False; +end; + +destructor TJvOfficeColorPanelProperties.Destroy; +begin + FreeAndNil(FNoneColorFont); + FreeAndNil(FDefaultColorFont); + FreeAndNil(FCustomColorFont); + inherited Destroy; +end; + +procedure TJvOfficeColorPanelProperties.Assign(Source: TPersistent); +begin + if Source is TJvOfficeColorPanelProperties then + begin + BeginUpdate; + try + with TJvOfficeColorPanelProperties(Source) do + begin + Self.ShowNoneColor := ShowNoneColor; + Self.ShowDefaultColor := ShowDefaultColor; + Self.ShowCustomColor := ShowCustomColor; + Self.ShowStandardColors := ShowStandardColors; + Self.ShowSystemColors := ShowSystemColors; + Self.ShowUserColors := ShowUserColors; + Self.ShowAddInHint := ShowAddInHint; + Self.ShowColorsHint := ShowColorsHint; + Self.HoldCustomColor := HoldCustomColor; + + Self.TopMargin := TopMargin; + Self.BottomMargin := BottomMargin; + Self.HorizontalMargin := HorizontalMargin; + Self.ButtonHeight := ButtonHeight; + Self.ColorSpace := ColorSpace; + Self.ColorSpaceTop := ColorSpaceTop; + Self.ColorSpaceBottom := ColorSpaceBottom; + Self.ColorSize := ColorSize; + + Self.NoneColorCaption := NoneColorCaption; + Self.DefaultColorCaption := DefaultColorCaption; + Self.CustomColorCaption := CustomColorCaption; + Self.NoneColorHint := NoneColorHint; + Self.DefaultColorHint := DefaultColorHint; + Self.CustomColorHint := CustomColorHint; + Self.NoneColorColor := NoneColorColor; + Self.DefaultColorColor := DefaultColorColor; + Self.NoneColorFont.Assign(NoneColorFont); + Self.DefaultColorFont.Assign(DefaultColorFont); + Self.CustomColorFont.Assign(CustomColorFont); + + Self.RightClickSelect := RightClickSelect; + Self.SelectIfPopup := SelectIfPopup; + end; + finally + EndUpdate; + end; + end + else + inherited Assign(Source); +end; + +const + cShowAutoButton = 'ShowAutoButton'; + cShowOtherButton = 'ShowOtherButton'; + cShowColorHint ='ShowColorHint'; + cAutoCaption ='AutoCaption'; + cOtherCaption ='OtherCaption'; + cAutoHint ='AutoHint'; + cOtherHint = 'OtherHint'; + +procedure TJvOfficeColorPanelProperties.DefineProperties(Filer: TFiler); +begin + inherited DefineProperties(Filer);; + { For backwards compatibility } + BeginUpdate; + try + FFilerTag := cShowAutoButton; + Filer.DefineProperty(FFilerTag, @ReadData, nil, False); + FFilerTag := cShowOtherButton; + Filer.DefineProperty(FFilerTag, @ReadData, nil, False); + FFilerTag := cShowColorHint; + Filer.DefineProperty(FFilerTag, @ReadData, nil, False); + FFilerTag := cAutoCaption; + Filer.DefineProperty(FFilerTag, @ReadData, nil, False); + FFilerTag := cOtherCaption; + Filer.DefineProperty(FFilerTag, @ReadData, nil, False); + FFilerTag := cAutoHint; + Filer.DefineProperty(FFilerTag, @ReadData, nil, False); + FFilerTag := cOtherHint; + Filer.DefineProperty(FFilerTag, @ReadData, nil, False); + finally + EndUpdate; + end; +end; + +procedure TJvOfficeColorPanelProperties.ReadData(Reader: TReader); +begin + if SameText(FFilerTag, cShowAutoButton) then + ShowDefaultColor := Reader.ReadBoolean + else + if SameText(FFilerTag, cShowOtherButton) then + ShowCustomColor := Reader.ReadBoolean + else + if SameText(FFilerTag, cShowColorHint) then + ShowColorsHint := Reader.ReadBoolean + else + if SameText(FFilerTag, cAutoCaption) then + DefaultColorCaption := Reader.ReadString + else + if SameText(FFilerTag, cOtherCaption) then + CustomColorCaption := Reader.ReadString + else + if SameText(FFilerTag, cAutoHint) then + DefaultColorHint := Reader.ReadString + else + if SameText(FFilerTag, cOtherHint) then + CustomColorHint := Reader.ReadString; +end; + +procedure TJvOfficeColorPanelProperties.CreateDefaultText; +begin + BeginUpdate; + try + NoneColorCaption := RsNoneColorCaption; + DefaultColorCaption := RsDefaultColorCaption; + CustomColorCaption := RsCustomColorCaption; + DefaultColorHint := RsDefaultColorCaption; + NoneColorHint := RsNoneColorCaption; + CustomColorHint := RsCustomColorCaption; + finally + EndUpdate; + end; +end; + +procedure TJvOfficeColorPanelProperties.SetIntegerValue(const Index, Value: + Integer); +var + MeasureItem: PInteger; + MeasureConst: Integer; + LName: string; +begin + case Index of + Tag_TopMargin: + begin + MeasureItem := @FTopMargin; + MeasureConst := MinTopMargin; + LName := 'TopMargin'; + end; + Tag_BottomMargin: + begin + MeasureItem := @FBottomMargin; + MeasureConst := MinBottomMargin; + LName := 'BottomMargin'; + end; + Tag_HorizontalMargin: + begin + MeasureItem := @FHorizontalMargin; + MeasureConst := MinHorizontalMargin; + LName := 'HorizontalMargin'; + end; + Tag_ColorSpace: + begin + MeasureItem := @FColorSpace; + MeasureConst := MinColorSpace; + LName := 'ColorSpace'; + end; + Tag_ColorSpaceTop: + begin + MeasureItem := @FColorSpaceTop; + MeasureConst := MinColorSpaceTop; + LName := 'ColorSpaceTop'; + end; + Tag_ColorSpaceBottom: + begin + MeasureItem := @FColorSpaceBottom; + MeasureConst := MinColorSpaceBottom; + LName := 'ColorSpaceBottom'; + end; + Tag_ColorSize: + begin + MeasureItem := @FColorSize; + MeasureConst := MinColorSize; + LName := 'ColorSize'; + end; + Tag_ButtonHeight: + begin + MeasureItem := @FButtonHeight; + MeasureConst := MinButtonHeight; + LName := 'ButtonHeight'; + end; + else + Exit; + end; + if MeasureItem^ = Value then + Exit; + + Changing; + ChangingProperty(LName); + MeasureItem^ := Value; + if MeasureItem^ < MeasureConst then + MeasureItem^ := MeasureConst; + ChangedProperty(LName); + Changed; +end; + +procedure TJvOfficeColorPanelProperties.SetStringValue(const Index: Integer; + const Value: string); +var + Prop: PString; + lName: string; +begin + case Index of + Tag_NoneColorCaption: + begin + Prop := @FNoneColorCaption; + lName := cNoneColorCaption; + end; + Tag_DefaultColorCaption: + begin + Prop := @FDefaultColorCaption; + lName := cDefaultColorCaption; + end; + Tag_CustomColorCaption: + begin + Prop := @FCustomColorCaption; + lName := cCustomColorCaption; + end; + Tag_NoneColorHint: + begin + Prop := @FNoneColorHint; + lName := cNoneColorHint; + end; + Tag_DefaultColorHint: + begin + Prop := @FDefaultColorHint; + lName := cDefaultColorHint; + end; + Tag_CustomColorHint: + begin + Prop := @FCustomColorHint; + lName := cCustomColorHint; + end; + else + Exit; + end; + + if (Prop^ <> Value) then + begin + Changing; + ChangingProperty(lName); + Prop^ := Value; + ChangedProperty(lName); + Changed; + end; +end; + +procedure TJvOfficeColorPanelProperties.SetBooleanValue(const Index: Integer; + const Value: Boolean); +var + Prop: PBoolean; + lName: string; +begin + case Index of + Tag_NoneColorCaption: + begin + Prop := @FShowNoneColor; + lName := cShowNoneColor; + end; + Tag_DefaultColorCaption: + begin + Prop := @FShowDefaultColor; + lName := cShowDefaultColor; + end; + Tag_CustomColorCaption: + begin + Prop := @FShowCustomColor; + lName := cShowCustomColor; + end; + Tag_ShowAddInHint: + begin + Prop := @FShowAddInHint; + lName := cShowAddInHint; + end; + Tag_ShowColorsHint: + begin + Prop := @FShowColorsHint; + lName := cShowColorsHint; + end; + Tag_ShowStandardColors: + begin + Prop := @FShowStandardColors; + lName := cShowStandardColors; + end; + Tag_ShowSystemColors: + begin + Prop := @FShowSystemColors; + lName := cShowSystemColors; + end; + Tag_ShowUserColors: + begin + Prop := @FShowUserColors; + lName := cShowUserColors; + end; + Tag_RightClickSelect: + begin + Prop := @FRightClickSelect; + lName := cRightClickSelect; + end; + Tag_SelectIfPopup: + begin + Prop := @FSelectIfPopup; + lName := cSelectIfPopup; + end; + Tag_HoldCustomColor: + begin + Prop := @HoldCustomColor; + lName := cHoldCustomColor; + end; + else + Exit; + end; + + if (Prop^ <> Value) then + begin + Changing; + ChangingProperty(lName); + Prop^ := Value; + ChangedProperty(lName); + Changed; + end; +end; + +procedure TJvOfficeColorPanelProperties.SetColorValue(const Index: Integer; + const Value: TColor); +var + Prop: PColor; + lName: string; +begin + case Index of + Tag_NoneColorCaption: + begin + Prop := @FNoneColorColor; + lName := cNoneColorColor; + end; + Tag_DefaultColorCaption: + begin + Prop := @FDefaultColorColor; + lName := cDefaultColorColor; + end; + else + Exit; + end; + + if (Prop^ <> Value) then + begin + Changing; + ChangingProperty(lName); + Prop^ := Value; + ChangedProperty(lName); + Changed; + end; +end; + +procedure TJvOfficeColorPanelProperties.SetFontValue(const Index: Integer; + const Value: TFont); +var + Prop: TFont; + lName: string; +begin + case Index of + Tag_NoneColorCaption: + begin + Prop := FNoneColorFont; + lName := cNoneColorFont; + end; + Tag_DefaultColorCaption: + begin + Prop := FDefaultColorFont; + lName := cDefaultColorFont; + end; + Tag_CustomColorCaption: + begin + Prop := FCustomColorFont; + lName := cCustomColorFont; + end; + else + Exit; + end; + + if (Prop <> Value) then + begin + Changing; + ChangingProperty(lName); + Prop.Assign(Value); + ChangedProperty(lName); + Changed; + end; +end; + +procedure TJvOfficeColorPanelProperties.OnFontChange(Sender: TObject); +begin + if Sender = FNoneColorFont then + ChangedProperty(cNoneColorFont) + else + if Sender = FDefaultColorFont then + ChangedProperty(cDefaultColorFont) + else + if Sender = FCustomColorFont then + ChangedProperty(cCustomColorFont); +end; + + +{ TJvColorSpeedButton } + +constructor TJvColorSpeedButton.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + FDrawColor := clDefault; + FDisabledDrawColor := clGray; + FEdgeWidth := 4; + FColorQuadLayOut := cqlClient; + FCanDrawColorQuad := True; + FCanDrawGlyph := True; + FCanDrawInnerFrame := False; +end; + +function TJvColorSpeedButton.GetEdgeWidth: Integer; +begin + Result := Height div 5; +end; + +procedure TJvColorSpeedButton.Paint; +var + B, X, Y: Integer; + PaintColor: TColor; + R: TRect; +begin + inherited Paint; + + if Enabled then + PaintColor := DrawColor + else + PaintColor := DisabledDrawColor; + if EdgeWidth >= 0 then + B := EdgeWidth + else + B := Height div 5; + R := Rect(0, 0, Width, Height); + with Canvas do + begin + if CanDrawGlyph and (not Glyph.Empty) then + begin + Glyph.Transparent := True; + X := Width div 2 - 9 + Integer(Down); + Y := Height div 2 + 4 - Integer(Down); + if CanDrawColorQuad then + begin + Pen.Color := PaintColor; + Brush.Color := PaintColor; + Brush.Style := bsSolid; + Rectangle(X, Y, X + 17, Y + 4); + end; + end + else + begin + if CanDrawInnerFrame then + begin + Pen.Color := clGray; + Brush.Style := bsClear; + InflateRect(R, -2, -2); + Rectangle(R); + end; + if CanDrawColorQuad then + begin + Pen.Color := clGray; + Brush.Color := PaintColor; + Brush.Style := bsSolid; + InflateRect(R, -B, -B); + case ColorQuadLayOut of + cqlLeft: + R.Right := R.Left + (R.Bottom - R.Top); + cqlRight: + R.Left := R.Right - (R.Bottom - R.Top); + cqlClient: ; + end; + Rectangle(R); + end; + end; + end; +end; + +procedure TJvColorSpeedButton.EnabledChanged; +begin + inherited EnabledChanged; + if Assigned(OnEnabledChanged) then + OnEnabledChanged(Self); +end; + +procedure TJvColorSpeedButton.SetDrawColor(const Value: TColor); +begin + if FDrawColor <> Value then + begin + FDrawColor := Value; + Invalidate; + end; +end; + +procedure TJvColorSpeedButton.SetDisabledDrawColor(const Value: TColor); +begin + if FDisabledDrawColor <> Value then + begin + FDisabledDrawColor := Value; + Invalidate; + end; +end; + +procedure TJvColorSpeedButton.SetCanDrawColorQuad(const Value: Boolean); +begin + if CanDrawColorQuad <> Value then + begin + FCanDrawColorQuad := Value; + Invalidate; + end; +end; + +procedure TJvColorSpeedButton.SetCanDrawGlyph(const Value: Boolean); +begin + if FCanDrawGlyph <> Value then + begin + FCanDrawGlyph := Value; + Invalidate; + end; +end; + +procedure TJvColorSpeedButton.SetCanDrawInnerFrame(const Value: Boolean); +begin + if FCanDrawInnerFrame <> Value then + begin + FCanDrawInnerFrame := Value; + Invalidate; + end; +end; + +procedure TJvColorSpeedButton.SetEdgeWidth(const Value: Integer); +begin + if FEdgeWidth <> Value then + begin + FEdgeWidth := Value; + Invalidate; + end; +end; + +procedure TJvColorSpeedButton.SetFColorQuadLayOut( + const Value: TJvColorQuadLayOut); +begin + if FColorQuadLayOut <> Value then + begin + FColorQuadLayOut := Value; + Invalidate; + end; +end; + +//if you directed set the Visible property, the control visible state never changed in design mode. +//That can be hide control in design mode. + +procedure SetControlVisible(Ctl: TControl; AVisible: Boolean); +begin + if Ctl.Visible = AVisible then + Exit; + + if csDesigning in Ctl.ComponentState then + begin + with Ctl do + if AVisible then + ControlStyle := ControlStyle - [csNoDesignVisible] + else + ControlStyle := ControlStyle + [csNoDesignVisible]; + end; + + Ctl.Visible := AVisible; +end; + +function GetTopOwner(AComponent: TComponent): TComponent; +begin + Result := AComponent; + while (AComponent <> nil) and + (AComponent.ComponentState * [csReading, csLoading] = []) do + AComponent := AComponent.Owner; + + if AComponent <> nil then + Result := AComponent; +end; + +function JvReaderReadColor(Reader: TReader):TColor; +begin + with Reader do + begin + if NextValue = vaIdent then + Result := StringToColor(ReadIdent) + else + Result := ReadInteger; + end; +end; + + +(**************************** NOT CONVERTED ***** +function JvReaderReadColorDialogOptions(Reader: TReader): TJvColorDialogOptions; +var + EnumName: string; + + procedure SkipSetBody; + begin + while Reader.ReadString <> '' do // wp: was Reader.ReadStr + {nothing}; + end; + +begin + try + if Reader.ReadValue <> vaSet then + Exit; + Result := []; + while True do + begin + EnumName := Reader.ReadString; // wp: was Reader.ReadStr + if EnumName = '' then + Break; + if SameText(EnumName, 'cdFullOpen') then + Include(Result, jcdFullOpen) + else + if SameText(EnumName, 'cdPreventFullOpen') then + Include(Result, jcdPreventFullOpen) + else + if SameText(EnumName, 'cdShowHelp') then + Include(Result, jcdShowHelp) + else + if SameText(EnumName, 'cdSolidColor') then + Include(Result, jcdSolidColor) + else + if SameText(EnumName, 'cdAnyColor') then + Include(Result, jcdAnyColor); + end; + except + SkipSetBody; + end; +end; +******************************************************) + +procedure JvReaderReadStrings(Reader: TReader;Strings:TStrings); +begin + Reader.ReadListBegin; + with Strings do + begin + BeginUpdate; + try + Clear; + while not Reader.EndOfList do + Add(Reader.ReadString); + finally + EndUpdate; + end; + end; + Reader.ReadListEnd; +end; + +//=== { TJvOfficeColorDrawer } =============================================== + +constructor TJvOfficeColorDrawer.Create(AOwner: TComponent); +begin + inherited; + FCanDrawGlyph := True; +end; + +type + TJvDefaultColorSpeendButton = class(TJvColorSpeedButton) + public + (******************** NOT CONVERTED **** + function HintShow(var HintInfo: THintInfo): Boolean; override; + ***************************************) + end; + +//=== { TJvDefaultColorSpeendButton } ======================================== + +(********************* NOT CONVERTED *** +function TJvDefaultColorSpeendButton.HintShow(var HintInfo: THintInfo): Boolean; +var + ColorQuadRect:TRect; + B: Integer; +begin + Result := inherited HintShow(HintInfo); + if CanDrawColorQuad then + begin + if EdgeWidth >= 0 then + B := EdgeWidth + else + B := Height div 5; + case ColorQuadLayOut of + cqlLeft: + ColorQuadRect:= Rect(B + 1, B + 1, Height, Height - B); + cqlRight: + ColorQuadRect:= Rect(Width - Height + 1, B + 1, Width - B, Height - B); + cqlClient: + ColorQuadRect:= Rect(B, B, Width - B, Height - B); + end; + if PtInRect(ColorQuadRect,ScreenToClient(Mouse.CursorPos)) then + HintInfo.HintStr := ColorToPrettyName(DrawColor); + end; +end; +****************************) + +//=== { TJvCustomOfficeColorPanel } ========================================== + +constructor TJvCustomOfficeColorPanel.Create(AOwner: TComponent); +var + TopOwner: TComponent; +begin + inherited Create(AOwner); + ControlStyle := ControlStyle - [csAcceptsControls]; + FInited := False; + FNeedReDrawDownState := True; + FBackgroundColor := clBtnFace; + + FStandardColors := TStringList.Create; + FSystemColors := TStringList.Create; + FUserColors := TStringList.Create; + FStandardColorDrawers := TList.Create; + FSystemColorDrawers := TList.Create; + FUserColorDrawers := TList.Create; + FAddInControls := TList.Create; + + (******************** NOT CONVERTED ***** + FHotTrack := False; + FHotTrackFont := TFont.Create; + FHotTrackFontOptions := DefaultTrackFontOptions; + FHotTrackOptions := TJvHotTrackOptions.Create(Self); + FHotTrackOptions.OnChanged := @DoHotTrackOptionsChanged; + FColorDialogOptions := []; + ****************************************) + + FClickColorType := cctNone; + FProperties := TJvOfficeColorPanelProperties.Create(Self); + FProperties.OnChangedProperty := @DoPropertiesChanged; + FSelectedColor := FProperties.DefaultColorColor; + + FButtonNoneColor := TJvColorSpeedButton.Create(Self); + with FButtonNoneColor do + begin + Parent := Self; + GroupIndex := PrimaryGroupIndex; + Tag := FStandardColors.Count + 1; + DrawColor := FProperties.NoneColorColor; + Flat := True; + CanDrawColorQuad := False; + CanDrawGlyph := False; + CanDrawInnerFrame := False; + OnClick := @DoColorButtonClick; + OnEnabledChanged := @DoColorDrawersEnabledChange; + end; + FAddInControls.Add(FButtonNoneColor); + + FButtonDefaultColor := TJvDefaultColorSpeendButton.Create(Self); + with FButtonDefaultColor do + begin + Parent := Self; + GroupIndex := PrimaryGroupIndex; + Tag := FButtonNoneColor.Tag + 1; + Down := True; + DrawColor := FProperties.DefaultColorColor; + Flat := True; + CanDrawColorQuad := True; + CanDrawGlyph := False; + CanDrawInnerFrame := True; + ColorQuadLayOut := cqlLeft; + OnClick := @DoColorButtonClick; + OnMouseUp := @RedirectToColorButtonClick; + OnEnabledChanged := @DoColorDrawersEnabledChange; + end; + FAddInControls.Add(FButtonDefaultColor); + FPriorCheckedButton := FButtonDefaultColor; + + FButtonCustomColor := TJvColorSpeedButton.Create(Self); + with FButtonCustomColor do + begin + Parent := Self; + GroupIndex := PrimaryGroupIndex; + Tag := FButtonDefaultColor.Tag + 1; + DrawColor := clDefault; + Flat := True; + CanDrawColorQuad := False; + CanDrawGlyph := False; + CanDrawInnerFrame := True; + OnClick := @DoColorButtonClick; + OnMouseUp := @RedirectToColorButtonClick; + OnEnabledChanged := @DoColorDrawersEnabledChange; + end; + FAddInControls.Add(FButtonCustomColor); + + FCustomColorDrawer := TJvOfficeColorDrawer.Create(Self); + with FCustomColorDrawer do + begin + Parent := Self; + GroupIndex := PrimaryGroupIndex; + Tag := FButtonCustomColor.Tag + 1; + Flat := True; + DrawColor := clDefault; + Hint := ColorToString(DrawColor); + CanDrawColorQuad := True; + CanDrawGlyph := False; + CanDrawInnerFrame := False; + ColorQuadLayOut := cqlClient; + OnClick := @DoColorButtonClick; + OnMouseUp := @RedirectToColorButtonClick; + OnEnabledChanged := @DoColorDrawersEnabledChange; + end; + FAddInControls.Add(FCustomColorDrawer); + + FDividerLine1 := JvDividerLineClass.Create(Self); + with FDividerLine1 do + begin + Parent := Self; + Visible := False; + Height := 2; + end; + FDividerLine2 := JvDividerLineClass.Create(Self); + with FDividerLine2 do + begin + Parent := Self; + Visible := False; + Height := 2; + end; + FDividerLine3 := JvDividerLineClass.Create(Self); + with FDividerLine3 do + begin + Parent := Self; + Visible := False; + Height := 2; + end; + + FColorDialog := TJvOfficeColorDialog.Create(Self); + (*********************** NOT CONVERTED ************ + FColorDialog.Options := FColorDialogOptions; + **************************************************) + + FStandardColors.BeginUpdate; + try + CreateStandardColors(FStandardColors); + finally + FStandardColors.EndUpdate; + end; + + FSystemColors.BeginUpdate; + try + CreateSystemColors(FSystemColors); + finally + FSystemColors.EndUpdate; + end; + + TopOwner := GetTopOwner(Self); + // make sure that if this is not loading from DFM file or stream. + if (TopOwner <> nil) and (TopOwner.ComponentState * [csReading, csLoading] = []) + then + begin + FUserColors.BeginUpdate; + try + CreateUserColors(FUserColors); + finally + FUserColors.EndUpdate; + end; + + CreateUserColorDrawers; + FProperties.CreateDefaultText; + end + else //When loaded UserColors, call CreateUserColorDrawers at once in DoLoadedUserColors + FUserColors.OnChange := @DoLoadedUserColors; + + CreateStandardColorDrawers; + CreateSystemColorDrawers; + + FInited := True; +end; + +destructor TJvCustomOfficeColorPanel.Destroy; +begin + (***************** NOT CONVERTED **** + FreeAndNil(FHotTrackFont); + FreeAndNil(FHotTrackOptions); + ************************************) + FreeAndNil(FProperties); + FreeAndNil(FStandardColors); + FreeAndNil(FSystemColors); + FreeAndNil(FUserColors); + FreeAndNil(FStandardColorDrawers); + FreeAndNil(FSystemColorDrawers); + FreeAndNil(FUserColorDrawers); + FreeAndNil(FAddInControls); + inherited Destroy; +end; + +function TJvCustomOfficeColorPanel.CreateStandardColors(ColorList: TStrings): Integer; +var + Index: Integer; +begin + Result := 0; + if ColorList <> nil then + begin + ColorList.BeginUpdate; + ColorList.Clear; + for Index := Low(StandardColorValues) to High(StandardColorValues) do + ColorList.Values[ + ColorToString(StandardColorValues[Index].Value)] := + StandardColorValues[Index].Description; + ColorList.EndUpdate; + Result := ColorList.Count; + end; +end; + +function TJvCustomOfficeColorPanel.CreateSystemColors(ColorList: TStrings): Integer; +var + Index: Integer; +begin + Result := 0; + if ColorList <> nil then + begin + ColorList.BeginUpdate; + ColorList.Clear; + for Index := Low(SysColorValues) to High(SysColorValues) do + ColorList.Values[ + ColorToString(SysColorValues[Index].Value)] := + SysColorValues[Index].Description; + Result := ColorList.Count; + ColorList.EndUpdate; + end; +end; + +function TJvCustomOfficeColorPanel.CreateUserColors(ColorList: TStrings): Integer; +begin + Result := 0; +end; + +procedure TJvCustomOfficeColorPanel.CreateColorDrawersByColors(DrawersList: TList; + ColorsList: TStringList; AVisible: Boolean); +var + I, ValidColCount: Integer; + Drawer: TJvOfficeColorDrawer; + Value, NewHint: string; + ExceptionRaised: Boolean; +begin + DeleteEmptyLines(ColorsList); + if ColorsList.Count < 1 then + Exit; + + //ignore the record that more then MaxSectColorCount . + ValidColCount := Min(ColorsList.Count, MaxSectColorCount); + if DrawersList.Count > ValidColCount then + begin + for I := ValidColCount to DrawersList.Count - 1 do + SetControlVisible(TControl(DrawersList[I]), False); + end + else + while DrawersList.Count < ValidColCount do + begin + Drawer := TJvOfficeColorDrawer.Create(Self); + with Drawer do + begin + CanDrawColorQuad := True; + CanDrawGlyph := False; + CanDrawInnerFrame := False; + ColorQuadLayOut := cqlClient; + end; + DrawersList.Add(Drawer); + end; + + for I := 0 to ValidColCount - 1 do + begin + ExceptionRaised := False; + Drawer := TJvOfficeColorDrawer(DrawersList[I]); + with Drawer do + begin + Parent := Self; + GroupIndex := PrimaryGroupIndex; + Tag := I; + Flat := True; + try + Value := Trim(ColorsList.Names[I]); + if Value = '' then Value := ColorsList.ValueFromIndex[I]; + DrawColor := StringToColor(Value); + Hint := ColorToPrettyName(DrawColor); + except + on EConvertError do + begin + DrawColor := clDefault; + DisabledDrawColor := Self.BackColor; + ExceptionRaised := True; + end; + end; + + if ExceptionRaised then + begin + Drawer.Enabled := False; + SetControlVisible(Drawer, False); + end + else + SetControlVisible(Drawer, AVisible); + {$IFDEF COMPILER7_UP} + NewHint := ColorsList.ValueFromIndex[I]; + {$ELSE} + NewHint := ColorsList.Values[ColorsList.Names[I]]; + {$ENDIF} + if SameText(NewHint, cUseDefaultColorHint) then + NewHint := ColorToPrettyName(DrawColor); + Hint := NewHint; + Transparent := False; + Color := Self.BackColor; + DisabledDrawColor := Self.BackColor; + HotTrack := Self.HotTrack; + HotTrackFont := Self.HotTrackFont; + HotTrackFontOptions := Self.HotTrackFontOptions; + HotTrackOptions := Self.HotTrackOptions; + + OnClick := @DoColorButtonClick; + OnEnabledChanged := @DoColorDrawersEnabledChange; + OnMouseUp := @RedirectToColorButtonClick; + end; + end; +end; + +procedure TJvCustomOfficeColorPanel.CreateStandardColorDrawers; +begin + CreateColorDrawersByColors(FStandardColorDrawers, FStandardColors, Properties.ShowStandardColors); +end; + +procedure TJvCustomOfficeColorPanel.CreateSystemColorDrawers; +begin + CreateColorDrawersByColors(FSystemColorDrawers, FSystemColors, Properties.ShowSystemColors); +end; + +procedure TJvCustomOfficeColorPanel.CreateUserColorDrawers; +begin + CreateColorDrawersByColors(FUserColorDrawers, FUserColors, Properties.ShowUserColors); +end; + +procedure TJvCustomOfficeColorPanel.RearrangeControls; +var + I, CtrlHeight: Integer; + ValidColCount: Integer; + TempTopInc: Integer; + StdColBtnsTop, StdColBtnsLeft: Integer; + SysColBtnsTop, SysColBtnsLeft: Integer; + UserColBtnsTop, UserColBtnsLeft: Integer; + Control, BottomControl: TControl; // the bottom most Button + CaclButtonWidth: Integer; + //HotTrackIntf: IJvHotTrack; + R: TRect; + lSiteInfo: TJvAddInControlSiteInfo; +begin + if (not FInited) or (Parent = nil) or FInRearrangeControls then + Exit; + DisableAlign; + BottomControl := nil; + TempTopInc := 0; + FInRearrangeControls := True; + + with Properties do + begin + CaclButtonWidth := LineColorCount * (ColorSize + ColorSpace) - ColorSpace; + StdColBtnsTop := BorderWidth; + StdColBtnsLeft :=BorderWidth + HorizontalMargin; + + //set None Color Button Bounds + //do't direct set value to Visible property. + SetControlVisible(FButtonNoneColor, ShowNoneColor); + if FButtonNoneColor.Visible then + begin + FButtonNoneColor.Caption := NoneColorCaption; + FButtonNoneColor.SetBounds(HorizontalMargin + BorderWidth,BorderWidth + TopMargin + TempTopInc, + CaclButtonWidth, ButtonHeight); + StdColBtnsTop := FButtonNoneColor.Top + FButtonNoneColor.Height; + StdColBtnsLeft := FButtonNoneColor.Left; + TempTopInc := BorderWidth + TopMargin + FButtonNoneColor.Height; + BottomControl := FButtonNoneColor; + end; + + //set Default Color Button Bounds + SetControlVisible(FButtonDefaultColor, ShowDefaultColor); + if FButtonDefaultColor.Visible then + begin + FButtonDefaultColor.Caption := DefaultColorCaption; + FButtonDefaultColor.SetBounds(StdColBtnsLeft, TopMargin + TempTopInc, + CaclButtonWidth, ButtonHeight); + StdColBtnsTop := FButtonDefaultColor.Top + FButtonDefaultColor.Height; + StdColBtnsLeft := FButtonDefaultColor.Left; + BottomControl := FButtonDefaultColor; + end; + + //set Standard Colors drawer position + ValidColCount := Min(FStandardColors.Count, MaxSectColorCount); + if FStandardColorDrawers.Count < ValidColCount then + CreateStandardColorDrawers + else + if FStandardColorDrawers.Count > ValidColCount then + for I := ValidColCount to FStandardColorDrawers.Count - 1 do + SetControlVisible(TControl(FStandardColorDrawers[I]), False); + + for I := 0 to ValidColCount - 1 do + begin + Control := TJvColorSpeedButton(FStandardColorDrawers[I]); + + SetControlVisible(Control, ShowStandardColors); + if Control.Visible then + begin + Control.SetBounds(StdColBtnsLeft + (I mod LineColorCount) * (ColorSpace + + ColorSize), + StdColBtnsTop + ColorSpaceTop + (I div LineColorCount) * (ColorSpace + + ColorSize), + ColorSize, ColorSize); + BottomControl := Control; + end; + end; + + SysColBtnsLeft := StdColBtnsLeft; + UserColBtnsLeft := StdColBtnsLeft; + if not Properties.ShowStandardColors then + SysColBtnsTop := StdColBtnsTop + else + SysColBtnsTop := BottomControl.Top + BottomControl.Height; + + //System colors + + ValidColCount := Min(FSystemColors.Count, MaxSectColorCount); + if FSystemColorDrawers.Count < ValidColCount then + CreateSystemColorDrawers + else + if FSystemColorDrawers.Count > ValidColCount then + for I := ValidColCount to FSystemColorDrawers.Count - 1 do + SetControlVisible(TControl(FSystemColorDrawers[I]), False); + + //set Divider Line position up System Colors + SetControlVisible(FDividerLine1, (ShowSystemColors and (FSystemColorDrawers.Count > 0)) and + ShowStandardColors); + if FDividerLine1.Visible then + with FDividerLine1 do + begin + SetBounds(StdColBtnsLeft, SysColBtnsTop + ColorSpaceBottom, CaclButtonWidth, Height); + SysColBtnsTop := Top + Height; + end; + + //set system Colors drawer position + for I := 0 to ValidColCount - 1 do + begin + Control := TControl(FSystemColorDrawers[I]); + + SetControlVisible(Control, ShowSystemColors); + if Control.Visible then + begin + Control.SetBounds(SysColBtnsLeft + (I mod LineColorCount) * (ColorSpace + ColorSize), + SysColBtnsTop + ColorSpaceTop + (I div LineColorCount) * (ColorSpace + ColorSize), + ColorSize, ColorSize); + BottomControl := Control; + end; + end; + + if not Properties.ShowSystemColors then + UserColBtnsTop := SysColBtnsTop + else + UserColBtnsTop := BottomControl.Top + BottomControl.Height; + + // User colors + ValidColCount := Min(FUserColors.Count, MaxSectColorCount); + if FUserColorDrawers.Count < ValidColCount then + CreateUserColorDrawers + else + if FUserColorDrawers.Count > ValidColCount then + for I := ValidColCount to FUserColorDrawers.Count - 1 do + SetControlVisible(TControl(FUserColorDrawers[I]), False); + + // set Divider Line position up user Colors + SetControlVisible(FDividerLine2, + (ShowUserColors and (FUserColorDrawers.Count > 0)) and + (ShowSystemColors or ShowStandardColors)); + if FDividerLine2.Visible then + with FDividerLine2 do + begin + SetBounds(StdColBtnsLeft, UserColBtnsTop + ColorSpaceBottom, + CaclButtonWidth, Height); + UserColBtnsTop := Top + Height; + end; + + // set User Colors drawer position + for I := 0 to ValidColCount - 1 do + begin + Control := TControl(FUserColorDrawers[I]); + + SetControlVisible(Control, ShowUserColors); + if Control.Visible then + begin + Control.SetBounds(UserColBtnsLeft + (I mod LineColorCount) * + (ColorSpace + ColorSize), + UserColBtnsTop + ColorSpaceTop + (I div LineColorCount) * (ColorSpace + ColorSize), + ColorSize, ColorSize); + BottomControl := Control; + end; + end; + + //set Divider Line position up custom color button + if BottomControl = nil then + TempTopInc := TopMargin + else + TempTopInc := BottomControl.Top + BottomControl.Height + + ColorSpaceBottom; + + SetControlVisible(FDividerLine3, + (ShowCustomColor and + (ShowSystemColors or ShowStandardColors or ShowUserColors)) ); + if FDividerLine3.Visible then + with FDividerLine3 do + begin + SetBounds(StdColBtnsLeft, TempTopInc, CaclButtonWidth, Height); + BottomControl := FDividerLine3; + end; + + //set Custom color button Bounds + if BottomControl = nil then + TempTopInc := TopMargin + else + TempTopInc := BottomControl.Top + BottomControl.Height + + ColorSpaceBottom; + + SetControlVisible(FCustomColorDrawer, ShowCustomColor); + SetControlVisible(FButtonCustomColor, ShowCustomColor); + with FCustomColorDrawer do + if Visible then + begin + CtrlHeight := ButtonHeight; + SetBounds(StdColBtnsLeft + CaclButtonWidth - CtrlHeight, TempTopInc, + CtrlHeight, CtrlHeight); + BottomControl := FCustomColorDrawer; + end; + with FButtonCustomColor do + if Visible then + begin + TSpeedButton(FButtonCustomColor).Caption := CustomColorCaption; + //TJvSpeedButton(FButtonCustomColor).Caption := CustomColorCaption; + CtrlHeight := ButtonHeight; + SetBounds(StdColBtnsLeft, TempTopInc, + CaclButtonWidth - FCustomColorDrawer.Width - ColorSpace, CtrlHeight); + BottomControl := FButtonCustomColor; + end; + + //set Other Add-in Controls Bounds + for I := 0 to FAddInControls.Count - 1 do + begin + Control := TControl(FAddInControls[I]); + if (Control = FButtonNoneColor) or (Control = FButtonDefaultColor) or + (Control = FButtonCustomColor) or (Control = FCustomColorDrawer) then + Continue; + + if BottomControl = nil then + TempTopInc := TopMargin + else + TempTopInc := BottomControl.Top + BottomControl.Height + ColorSpaceBottom; + + with Control do + begin + if Visible then + begin + Parent := Self; + CtrlHeight := Height; + { was: + if Control is TJvCustomSpeedButton then + with TJvSpeedButton(Control) do } + if Control is TCustomSpeedButton then + with TSpeedButton(Control) do + begin + Flat := True; + Color := Self.BackColor; + Enabled := Self.Enabled; + end; + + (***************** NOT CONVERTED ****** + if Supports(Control, IJvHotTrack, HotTrackIntf) then + with HotTrackIntf do + begin + HotTrack := Self.HotTrack; + HotTrackFont := Self.HotTrackFont; + HotTrackFontOptions := Self.HotTrackFontOptions; + HotTrackOptions := Self.HotTrackOptions; + end; + *************************************) + + R := Rect( + StdColBtnsLeft, + TempTopInc, + StdColBtnsLeft + CaclButtonWidth, + TempTopInc + CtrlHeight + ); + lSiteInfo.AddInControl:= Control; + lSiteInfo.BoundsRect := R; + DoGetAddInControlSiteInfo(Self, lSiteInfo); + BoundsRect := lSiteInfo.BoundsRect; + + BottomControl := Control; + end; + end; + end; + + //Set panel size + Width := (HorizontalMargin + BorderWidth) * 2 + ColorSize * LineColorCount + + ColorSpace * (LineColorCount - 1); + if BottomControl = nil then + Height := 0 + else + Height := BottomControl.Top + BottomControl.Height + BottomMargin + BorderWidth; + end; + EnableAlign; + + FInRearrangeControls := False; +end; + +procedure TJvCustomOfficeColorPanel.RefreshControls; +begin + if FInRearrangeControls then + Exit; + with Properties do + begin + if ShowStandardColors then + CreateStandardColorDrawers; + if ShowSystemColors then + CreateSystemColorDrawers; + if ShowUserColors then + CreateUserColorDrawers; + if ShowStandardColors or ShowSystemColors or ShowUserColors then + RearrangeControls; + end; +end; + +procedure TJvCustomOfficeColorPanel.DoColorButtonClick(Sender: TObject); +var + LastColor: TColor; + + procedure HoldCustomColor(AColor: TColor); + var + StrColor: string; + begin + if ClickColorType = cctCustomColor then + begin + StrColor := ColorToString(AColor); + if (FButtonCustomColor.DrawColor <> AColor) then + begin //refresh CustomColorDrawer + FButtonCustomColor.DrawColor := AColor; + FCustomColorDrawer.DrawColor := AColor; + FCustomColorDrawer.Hint := ColorToPrettyName(AColor); + end; + + if Properties.HoldCustomColor and + ((FButtonCustomColor.DrawColor <> AColor) or (UserColors.IndexOfName(StrColor) = -1)) then + begin + UserColors.BeginUpdate; + try + UserColors.Values[StrColor] := cUseDefaultColorHint; + finally + UserColors.EndUpdate; + end; + CreateUserColorDrawers; + RearrangeControls; + DoHoldedCustomColor(Self,AColor); + end; + end; + end; + +begin + if Sender is TJvColorSpeedButton then + begin + if Sender = FButtonNoneColor then + FClickColorType := cctNoneColor + else + if Sender = FButtonDefaultColor then + FClickColorType := cctDefaultColor + else + if Sender = FButtonCustomColor then + FClickColorType := cctCustomColor + else + if FAddInControls.IndexOf(Sender) <> -1 then + FClickColorType := cctAddInControl + else + FClickColorType := cctColors; + end + else + FClickColorType := cctNone; + + FNeedReDrawDownState := False; + try + if Assigned(FOnColorButtonClick) then + FOnColorButtonClick(Sender); + + if FClickColorType <> cctNone then + begin + if (FClickColorType = cctCustomColor) then + begin + LastColor := SelectedColor; + if Assigned(FOnShowOwnerColorDialog) then + begin + FOnShowOwnerColorDialog(Sender); + if LastColor = SelectedColor then //never changed SelectedColor + begin + if (FPriorCheckedButton <> nil) then + FPriorCheckedButton.Down := True; + end + else + HoldCustomColor(SelectedColor); + end + else + begin + (***************** NOT CONVERTED **** + FColorDialog.Options := FColorDialogOptions; + ************************************) + FColorDialog.Color := SelectedColor{FCustomColorDrawer.DrawColor}; + if FColorDialog.Execute then + begin + HoldCustomColor(FColorDialog.Color); + SelectedColor := FColorDialog.Color; + end + else + if FPriorCheckedButton <> nil then //cancel the color dialog selection, restore the Prior Checked Button down + FPriorCheckedButton.Down := True; + end; + // the PriorCheckedButton have not been assign. + if ((FPriorCheckedButton <> nil) and (not FPriorCheckedButton.Down)) or + // if the PriorCheckedButton is ButtonCustom,Set CustomColorDrawer.Down to true for ever. + (FPriorCheckedButton = FButtonCustomColor) then + FCustomColorDrawer.Down := True; + end + else + SelectedColor := TJvColorSpeedButton(Sender).DrawColor; + end; + finally + FNeedReDrawDownState := True; + end; + //if Sender is TJvCustomSpeedButton then + if Sender is TCustomSpeedButton then + // the PriorCheckedButton have not been assign. + if (FPriorCheckedButton <> nil) and (not FPriorCheckedButton.Down) then + FPriorCheckedButton := TJvColorSpeedButton(Sender); + + FClickColorType := cctNone; +end; + +procedure TJvCustomOfficeColorPanel.DoSelectedColorChange(Sender: TObject); +begin + if Assigned(FOnColorChange) then + FOnColorChange(Self); +end; + +procedure TJvCustomOfficeColorPanel.DoGetAddInControlSiteInfo(Sender: TControl; + var ASiteInfo: TJvAddInControlSiteInfo); +begin + if Assigned(FOnGetAddInControlSiteInfo) then + FOnGetAddInControlSiteInfo(Sender, ASiteInfo); +end; + +function TJvCustomOfficeColorPanel.GetControlBackgroundColor: TColor; +begin + Result := FBackgroundColor; +end; + +procedure TJvCustomOfficeColorPanel.SetControlBackgroundColor(const Value: TColor); +var + I: Integer; +begin + if FBackgroundColor <> Value then + begin + inherited Color := Value; + FBackgroundColor := Value; + for I := 0 to FStandardColorDrawers.Count - 1 do + with TJvColorSpeedButton(FStandardColorDrawers[I]) do + begin + Color := Value; + DisabledDrawColor := Value; + end; + for I := 0 to FSystemColorDrawers.Count - 1 do + with TJvColorSpeedButton(FSystemColorDrawers[I]) do + begin + Color := Value; + DisabledDrawColor := Value; + end; + for I := 0 to FUserColorDrawers.Count - 1 do + with TJvColorSpeedButton(FUserColorDrawers[I]) do + begin + Color := Value; + DisabledDrawColor := Value; + end; + for I := 0 to FAddInControls.Count - 1 do + begin + TControlAccessProtected(FAddInControls[I]).Color := Value; + if TObject(FAddInControls[I]) is TJvColorSpeedButton then + TJvColorSpeedButton(FAddInControls[I]).DisabledDrawColor := Value; + end; + end; +end; + +procedure TJvCustomOfficeColorPanel.SetSelectedColor(const Value: TColor); + + function FindColorButton(Buttons: TList; ValidColCount: Integer): TJvColorSpeedButton; + var + I: Integer; + begin + for I := 0 to ValidColCount - 1 do + begin + Result := TJvColorSpeedButton(Buttons[I]); + if Result.DrawColor = Value then + Exit; + end; + Result := nil; + end; + +var + Button: TJvColorSpeedButton; +begin + if FSelectedColor <> Value then + begin + FSelectedColor := Value; + if FNeedReDrawDownState then + begin + if FButtonDefaultColor.DrawColor = Value then + begin + FButtonDefaultColor.Down := True; + if FPriorCheckedButton = nil then + FPriorCheckedButton := FButtonDefaultColor; + end + else + begin + FButtonDefaultColor.Down := False; + Button := FindColorButton(FStandardColorDrawers, Min(FStandardColorDrawers.Count, MaxSectColorCount)); + if Button <> nil then + Button.Down := True // all other buttons automatically switch to False due to their GroupIndex + else + begin + Button := FindColorButton(FSystemColorDrawers, Min(FSystemColorDrawers.Count, MaxSectColorCount)); + if Button <> nil then + Button.Down := True // all other buttons automatically switch to False due to their GroupIndex + else + begin + Button := FindColorButton(FUserColorDrawers, Min(FUserColorDrawers.Count, MaxSectColorCount)); + if Button <> nil then + Button.Down := True // all other buttons automatically switch to False due to their GroupIndex + end; + end; + if (FPriorCheckedButton = nil) and (Button <> nil) then + FPriorCheckedButton := Button; + end; + end; + + DoSelectedColorChange(Self); + end; +end; + +(**************************** NOT CONVERTED **************************** +function TJvCustomOfficeColorPanel.GetHotTrack: Boolean; +begin + Result := FHotTrack; +end; + +function TJvCustomOfficeColorPanel.GetHotTrackFont: TFont; +begin + Result := FHotTrackFont; +end; + +function TJvCustomOfficeColorPanel.GetHotTrackFontOptions: TJvTrackFontOptions; +begin + Result := FHotTrackFontOptions; +end; + +function TJvCustomOfficeColorPanel.GetHotTrackOptions: TJvHotTrackOptions; +begin + Result := FHotTrackOptions; +end; + +procedure TJvCustomOfficeColorPanel.SetHotTrack(Value: Boolean); +var + I: Integer; + HotTrackIntf: IJvHotTrack; +begin + if FHotTrack <> Value then + begin + FHotTrack := Value; + for I := 0 to FStandardColorDrawers.Count - 1 do + TJvColorSpeedButton(FStandardColorDrawers[I]).HotTrack := Value; + for I := 0 to FSystemColorDrawers.Count - 1 do + TJvColorSpeedButton(FSystemColorDrawers[I]).HotTrack := Value; + for I := 0 to FUserColorDrawers.Count - 1 do + TJvColorSpeedButton(FUserColorDrawers[I]).HotTrack := Value; + for I := 0 to FAddInControls.Count - 1 do + if Supports(TObject(FAddInControls[I]), IJvHotTrack, HotTrackIntf) then + HotTrackIntf.HotTrack := Value; + end; +end; + +procedure TJvCustomOfficeColorPanel.SetHotTrackFont(Value: TFont); +var + I: Integer; + HotTrackIntf: IJvHotTrack; +begin + if (FHotTrackFont <> Value) and (Value <> nil) then + begin + FHotTrackFont.Assign(Value); + for I := 0 to FStandardColorDrawers.Count - 1 do + TJvColorSpeedButton(FStandardColorDrawers[I]).HotTrackFont := Value; + for I := 0 to FSystemColorDrawers.Count - 1 do + TJvColorSpeedButton(FSystemColorDrawers[I]).HotTrackFont := Value; + for I := 0 to FAddInControls.Count - 1 do + if Supports(TObject(FAddInControls[I]), IJvHotTrack, HotTrackIntf) then + HotTrackIntf.HotTrackFont := Value; + end; +end; + +procedure TJvCustomOfficeColorPanel.SetHotTrackFontOptions(Value: TJvTrackFontOptions); +var + I: Integer; + HotTrackIntf: IJvHotTrack; +begin + if FHotTrackFontOptions <> Value then + begin + FHotTrackFontOptions := Value; + for I := 0 to FStandardColorDrawers.Count - 1 do + TJvColorSpeedButton(FStandardColorDrawers[I]).HotTrackFontOptions := + Value; + for I := 0 to FSystemColorDrawers.Count - 1 do + TJvColorSpeedButton(FSystemColorDrawers[I]).HotTrackFontOptions := Value; + for I := 0 to FAddInControls.Count - 1 do + if Supports(TObject(FAddInControls[I]), IJvHotTrack, HotTrackIntf) then + HotTrackIntf.HotTrackFontOptions := Value; + end; +end; + +procedure TJvCustomOfficeColorPanel.SetHotTrackOptions(Value: TJvHotTrackOptions); +var + I: Integer; + HotTrackIntf: IJvHotTrack; +begin + if (FHotTrackOptions <> Value) and (Value <> nil) then + begin + FHotTrackOptions.Assign(Value); + for I := 0 to FStandardColorDrawers.Count - 1 do + TJvColorSpeedButton(FStandardColorDrawers[I]).HotTrackOptions := Value; + for I := 0 to FSystemColorDrawers.Count - 1 do + TJvColorSpeedButton(FSystemColorDrawers[I]).HotTrackOptions := Value; + for I := 0 to FUserColorDrawers.Count - 1 do + TJvColorSpeedButton(FUserColorDrawers[I]).HotTrackOptions := Value; + + for I := 0 to FAddInControls.Count - 1 do + if Supports(TObject(FAddInControls[I]), IJvHotTrack, HotTrackIntf) then + HotTrackIntf.HotTrackOptions := Value; + end; +end; + +procedure TJvCustomOfficeColorPanel.IJvHotTrack_Assign( + Source: IJvHotTrack); +begin + if (Source <> nil) and (IJvHotTrack(Self) <> Source) then + begin + HotTrack := Source.HotTrack; + HotTrackFont :=Source.HotTrackFont; + HotTrackFontOptions := Source.HotTrackFontOptions; + HotTrackOptions := Source.HotTrackOptions; + end; +end; + +procedure TJvCustomOfficeColorPanel.DoHotTrackOptionsChanged(Sender: TObject); +var + I: Integer; + HotTrackIntf: IJvHotTrack; + DrawInnerFrame: Boolean; +begin + DrawInnerFrame := not HotTrackOptions.Enabled; + FButtonDefaultColor.CanDrawInnerFrame := DrawInnerFrame; + FButtonCustomColor.CanDrawInnerFrame := DrawInnerFrame; + for I := 0 to FStandardColorDrawers.Count - 1 do + TJvColorSpeedButton(FStandardColorDrawers[I]).HotTrackOptions := + FHotTrackOptions; + for I := 0 to FSystemColorDrawers.Count - 1 do + TJvColorSpeedButton(FSystemColorDrawers[I]).HotTrackOptions := + FHotTrackOptions; + for I := 0 to FUserColorDrawers.Count - 1 do + TJvColorSpeedButton(FUserColorDrawers[I]).HotTrackOptions := + FHotTrackOptions; + for I := 0 to FAddInControls.Count - 1 do + if Supports(TObject(FAddInControls[I]), IJvHotTrack, HotTrackIntf) then + HotTrackIntf.HotTrackOptions := FHotTrackOptions; +end; +********************************************************************) + +function TJvCustomOfficeColorPanel.GetColorDlgCustomColors: TStrings; +begin + Result := FColorDialog.CustomColors; +end; + +procedure TJvCustomOfficeColorPanel.SetColorDlgCustomColors(const Value: TStrings); +begin + FColorDialog.CustomColors.Assign(Value); +end; + +procedure TJvCustomOfficeColorPanel.SetStandardColors(const Value: TStringList); +begin + if (FStandardColors <> Value) and (Value <> nil) then + begin + FStandardColors.Assign(Value); + RefreshControls; + end; +end; + +procedure TJvCustomOfficeColorPanel.SetSystemColors(const Value: TStringList); +begin + if (FSystemColors <> Value) and (Value <> nil) then + begin + FSystemColors.Assign(Value); + RefreshControls; + end; +end; + +procedure TJvCustomOfficeColorPanel.SetUserColors(const Value: TStringList); +begin + if (FUserColors <> Value) and (Value <> nil) then + begin + FUserColors.Assign(Value); + RefreshControls; + end; +end; + +procedure TJvCustomOfficeColorPanel.DoColorDrawersEnabledChange(Sender: TObject); +begin + if Sender is TJvColorSpeedButton then + TJvColorSpeedButton(Sender).DisabledDrawColor := BackColor; +end; + +procedure TJvCustomOfficeColorPanel.DoLoadedUserColors(Sender: TObject); +begin + FUserColors.OnChange := nil; // Run once time only. + CreateUserColorDrawers; +end; + +procedure TJvCustomOfficeColorPanel.DoHoldedCustomColor(Sender: TObject;AColor: TColor); +begin + if Assigned(FOnHoldCustomColor) then + FOnHoldCustomColor(Self,AColor); +end; + +procedure TJvCustomOfficeColorPanel.Loaded; +begin + inherited Loaded; + FUserColors.OnChange := nil; +end; + +procedure TJvCustomOfficeColorPanel.Resize; +begin + inherited Resize; + if not FInRearrangeControls then + RearrangeControls; +end; + +procedure TJvCustomOfficeColorPanel.SetEnabled(Value: Boolean); +var + I: Integer; +begin + inherited SetEnabled(Value); + for I := 0 to FStandardColorDrawers.Count - 1 do + TControl(FStandardColorDrawers[I]).Enabled := Value; + for I := 0 to FSystemColorDrawers.Count - 1 do + TControl(FSystemColorDrawers[I]).Enabled := Value; + for I := 0 to FUserColorDrawers.Count - 1 do + TControl(FUserColorDrawers[I]).Enabled := Value; + for I := 0 to FAddInControls.Count - 1 do + TControl(FAddInControls[I]).Enabled := Value; +end; + +procedure TJvCustomOfficeColorPanel.ShowHintChanged; +var + I: Integer; +begin + inherited ShowHintChanged; + for I := 0 to FStandardColorDrawers.Count - 1 do + TControl(FStandardColorDrawers[I]).ShowHint := ShowHint; + for I := 0 to FSystemColorDrawers.Count - 1 do + TControl(FSystemColorDrawers[I]).ShowHint := ShowHint; + for I := 0 to FUserColorDrawers.Count - 1 do + TControl(FUserColorDrawers[I]).ShowHint := ShowHint; + for I := 0 to FAddInControls.Count - 1 do + TControl(FAddInControls[I]).ShowHint := ShowHint; +end; + +(**************************** NOT CONVERTED ************** +procedure TJvCustomOfficeColorPanel.SetColorDialogOptions(const Value: TJvColorDialogOptions); +begin + FColorDialogOptions := Value; +end; +********************************************************) + +procedure TJvCustomOfficeColorPanel.CreateWnd; +begin + inherited CreateWnd; + RearrangeControls; +end; + +procedure TJvCustomOfficeColorPanel.SetProperties(const Value: TJvOfficeColorPanelProperties); +begin + if (FProperties <> Value) and (Value <> nil) then + FProperties.Assign(Value); +end; + +procedure TJvCustomOfficeColorPanel.DoPropertiesChanged(Sender: TObject; + const PropName: string); +var + RealignFlag: Boolean; + I: Integer; +begin + { The initial value is do't Adjust size,if you wan't adjust size when a property changed, + add a sentence like following to do nothing to skip notify. } + RealignFlag := False; + + if SameText(PropName, cNoneColorCaption) then + FButtonNoneColor.Caption := Properties.NoneColorCaption + else + if SameText(PropName, cDefaultColorCaption) then + FButtonDefaultColor.Caption := Properties.DefaultColorCaption + else + if SameText(PropName, cCustomColorCaption) then + FButtonCustomColor.Caption := Properties.CustomColorCaption + else + if SameText(PropName, cNoneColorHint) then + FButtonNoneColor.Hint := Properties.NoneColorHint + else + if SameText(PropName, cDefaultColorHint) then + FButtonDefaultColor.Hint := Properties.DefaultColorHint + else + if SameText(PropName, cCustomColorHint) then + FButtonCustomColor.Hint := Properties.CustomColorHint + else + if SameText(PropName, cNoneColorColor) then + FButtonNoneColor.DrawColor := Properties.NoneColorColor + else + if SameText(PropName, cDefaultColorColor) then + FButtonDefaultColor.DrawColor := Properties.DefaultColorColor + else + if SameText(PropName, cNoneColorFont) then + FButtonNoneColor.Font := Properties.NoneColorFont + else + if SameText(PropName, cDefaultColorFont) then + FButtonDefaultColor.Font := Properties.DefaultColorFont + else + if SameText(PropName, cCustomColorFont) then + FButtonCustomColor.Font := Properties.CustomColorFont + else + if SameText(PropName, cShowAddInHint) then + begin + FButtonNoneColor.ShowHint := Properties.ShowAddInHint; + FButtonDefaultColor.ShowHint := Properties.ShowAddInHint; + FButtonCustomColor.ShowHint := Properties.ShowAddInHint; + end + else + if SameText(PropName, cShowColorsHint) then + begin + for I := 0 to FStandardColorDrawers.Count - 1 do + TControl(FStandardColorDrawers[I]).ShowHint := Properties.ShowColorsHint; + for I := 0 to FSystemColorDrawers.Count - 1 do + TControl(FSystemColorDrawers[I]).ShowHint := Properties.ShowColorsHint; + for I := 0 to FUserColorDrawers.Count - 1 do + TControl(FUserColorDrawers[I]).ShowHint := Properties.ShowColorsHint; + end + else + if SameText(PropName, cRightClickSelect) or + SameText(PropName, cHoldCustomColor) or + SameText(PropName, cRightClickSelect) then + else // Other property change will adjust size by default. + RealignFlag := True; + + if RealignFlag then + RearrangeControls; +end; + +procedure TJvCustomOfficeColorPanel.RedirectToColorButtonClick(Sender: TObject; + Button: TMouseButton; Shift: TShiftState; X, Y: Integer); +var + lParent: TWinControl; +begin + if Assigned(OnMouseUp) then + OnMouseUp(Sender, Button, Shift, X, Y); + + // If any of the possible parents has a popup menu, we let it + // run, and do not select the button (hence the exit), unless + // the properties tell us to select anyway + lParent := Self; + while Assigned(lParent) do + if Assigned(TWinControlAccessProtected(lParent).PopupMenu) then + begin + if not Properties.SelectIfPopup then + Exit; + end + else + lParent := lParent.Parent; + + // if the user asked not to right click select, we stop here + if not Properties.RightClickSelect then + Exit; + + if Button = mbRight then + DoColorButtonClick(Sender); +end; + + +{ TJvOfficeColorPanel } + +procedure TJvOfficeColorPanel.DefineProperties(Filer: TFiler); +begin + inherited DefineProperties(Filer); + { For backwards compatibility } + FFilerTag := 'Color'; + Filer.DefineProperty(FFilerTag, @ReadData, nil, False); + FFilerTag := 'Flat'; + Filer.DefineProperty(FFilerTag, @ReadData, nil, False); + FFilerTag := 'CustomColors'; + Filer.DefineProperty(FFilerTag, @ReadData, nil, False); + FFilerTag := 'Options'; + Filer.DefineProperty(FFilerTag, @ReadData, nil, False); +end; + +procedure TJvOfficeColorPanel.ReadData(Reader: TReader); +begin + if SameText(FFilerTag, 'Color') then + SelectedColor := JvReaderReadColor(Reader) + else + if SameText(FFilerTag, 'Flat') then + FlatBorder := Reader.ReadBoolean + else + if SameText(FFilerTag, 'CustomColors') then + JvReaderReadStrings(Reader, ColorDlgCustomColors) + (*************************** NOT CONVERTED ******************** + else + if SameText(FFilerTag, 'Options') then + ColorDialogOptions := JvReaderReadColorDialogOptions(Reader) + *************************************************************) + ; +end; + + +end. + diff --git a/components/jvcllaz/run/JvStdCtrls/jvpanel.pas b/components/jvcllaz/run/JvStdCtrls/jvpanel.pas index 3c10c3174..3d73a2769 100644 --- a/components/jvcllaz/run/JvStdCtrls/jvpanel.pas +++ b/components/jvcllaz/run/JvStdCtrls/jvpanel.pas @@ -44,7 +44,7 @@ interface uses LCLType, LCLIntf, LMessages, Types, SysUtils, Classes, Graphics, Controls, Forms, ExtCtrls, - JvTypes, JvExtComponent, JvExControls, JvHotTrackPersistent; + JvTypes, JvExtComponent, JvHotTrackPersistent; type TJvPanelResizeParentEvent = procedure(Sender: TObject; nLeft, nTop, nWidth, nHeight: Integer) of object; @@ -869,9 +869,7 @@ begin Inc(BevelSize, BevelWidth); InflateRect(ATextRect, -BevelSize, -BevelSize); Flags := DT_EXPANDTABS or WORDWRAPS[MultiLine] or ALIGNMENTS[Alignment]; - (*************** NOT CONVERTED *** - Flags := DrawTextBiDiModeFlags(Flags); - *********************************) + Flags := DrawTextBiDiModeFlags(Self, Flags); //calculate required rectangle size DrawText(ACanvas.Handle, PChar(Caption), -1, ATextRect, Flags or DT_CALCRECT);