diff --git a/components/jvcllaz/design/JvCtrls/images/images.txt b/components/jvcllaz/design/JvCtrls/images/images.txt index 77cd3a466..53dc036ee 100644 --- a/components/jvcllaz/design/JvCtrls/images/images.txt +++ b/components/jvcllaz/design/JvCtrls/images/images.txt @@ -27,3 +27,4 @@ tjvrollout_150.png tjvrollout_200.png tjvcombolistbox.bmp tjvlookupautocomplete.bmp +tjvinstalllabel.bmp diff --git a/components/jvcllaz/design/JvCtrls/images/tjvinstalllabel.bmp b/components/jvcllaz/design/JvCtrls/images/tjvinstalllabel.bmp new file mode 100644 index 000000000..56fca8834 Binary files /dev/null and b/components/jvcllaz/design/JvCtrls/images/tjvinstalllabel.bmp differ diff --git a/components/jvcllaz/design/JvCtrls/jvctrlsreg.pas b/components/jvcllaz/design/JvCtrls/jvctrlsreg.pas index f50aa59ff..e0f282669 100644 --- a/components/jvcllaz/design/JvCtrls/jvctrlsreg.pas +++ b/components/jvcllaz/design/JvCtrls/jvctrlsreg.pas @@ -16,7 +16,7 @@ implementation uses Classes, Controls, ActnList, PropEdits, JvDsgnConsts, JvMovableBevel, JvRuler, JvGroupHeader, JvRollOut, - JvHtControls, JvHint, JvHTHintForm, JvComboListBox, + JvHtControls, JvHint, JvHTHintForm, JvComboListBox, JvInstallLabel, JvAutoComplete; // original JVCL has this in package JvCore procedure Register; @@ -24,7 +24,7 @@ begin RegisterComponents(RsPaletteJvcl, [ TJvMovableBevel, TJvMovablePanel, TJvRuler, TJvGroupHeader, TJvRollOut, TJvHint, TJvHTLabel, TJvHTListbox, TJvHTCombobox, TJvComboListBox, - TJvLookupAutoComplete + TJvLookupAutoComplete, TJvInstallLabel ]); RegisterPropertyEditor(TypeInfo(TCaption), TJvHTLabel, 'Caption', TJvHintProperty); RegisterActions(RsJVCLActionsCategory, [TJvRollOutAction], nil); diff --git a/components/jvcllaz/examples/JvInstallLabel/Install2LabelDemo.lpi b/components/jvcllaz/examples/JvInstallLabel/Install2LabelDemo.lpi new file mode 100644 index 000000000..78b4e1069 --- /dev/null +++ b/components/jvcllaz/examples/JvInstallLabel/Install2LabelDemo.lpi @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + <UseAppBundle Value="False"/> + <ResourceType Value="res"/> + <UseXPManifest Value="True"/> + </General> + <BuildModes> + <Item Name="Default" Default="True"/> + </BuildModes> + <PublishOptions> + <Version Value="2"/> + <UseFileFilters Value="True"/> + </PublishOptions> + <RunParams> + <FormatVersion Value="2"/> + <Modes Count="0"/> + </RunParams> + <RequiredPackages Count="3"> + <Item1> + <PackageName Value="JvCtrlsLazR"/> + </Item1> + <Item2> + <PackageName Value="JvCoreLazR"/> + </Item2> + <Item3> + <PackageName Value="LCL"/> + </Item3> + </RequiredPackages> + <Units> + <Unit> + <Filename Value="Install2LabelDemo.lpr"/> + <IsPartOfProject Value="True"/> + </Unit> + <Unit> + <Filename Value="InstallLabelMainFormU.pas"/> + <IsPartOfProject Value="True"/> + <ComponentName Value="InstallLabelMainForm"/> + <HasResources Value="True"/> + <ResourceBaseClass Value="Form"/> + </Unit> + </Units> + </ProjectOptions> + <CompilerOptions> + <Version Value="11"/> + <PathDelim Value="\"/> + <Target> + <Filename Value="..\..\bin\Install2LabelDemo"/> + </Target> + <SearchPaths> + <IncludeFiles Value="$(ProjOutDir)"/> + <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> + <ObjectPath Value="..\..\run"/> + </SearchPaths> + <Parsing> + <SyntaxOptions> + <SyntaxMode Value="Delphi"/> + </SyntaxOptions> + </Parsing> + <Linking> + <Options> + <Win32> + <GraphicApplication Value="True"/> + </Win32> + </Options> + </Linking> + <Other> + <CustomOptions Value="-dBorland -dVer150 -dDelphi7 -dCompiler6_Up -dPUREPASCAL"/> + </Other> + </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/JvInstallLabel/Install2LabelDemo.lpr b/components/jvcllaz/examples/JvInstallLabel/Install2LabelDemo.lpr new file mode 100644 index 000000000..707d3f439 --- /dev/null +++ b/components/jvcllaz/examples/JvInstallLabel/Install2LabelDemo.lpr @@ -0,0 +1,15 @@ +program Install2LabelDemo; + +{$MODE Delphi} + +uses + Forms, Interfaces, + InstallLabelMainFormU in 'InstallLabelMainFormU.pas' {InstallLabelMainForm}; + +{$R *.res} + +begin + Application.Initialize; + Application.CreateForm(TInstallLabelMainForm, InstallLabelMainForm); + Application.Run; +end. diff --git a/components/jvcllaz/examples/JvInstallLabel/InstallLabelMainFormU.lfm b/components/jvcllaz/examples/JvInstallLabel/InstallLabelMainFormU.lfm new file mode 100644 index 000000000..160e84f7c --- /dev/null +++ b/components/jvcllaz/examples/JvInstallLabel/InstallLabelMainFormU.lfm @@ -0,0 +1,174 @@ +object InstallLabelMainForm: TInstallLabelMainForm + Left = 339 + Height = 237 + Top = 142 + Width = 293 + BorderIcons = [biSystemMenu] + BorderStyle = bsSingle + Caption = 'Installation in progress' + ClientHeight = 237 + ClientWidth = 293 + Color = clBtnFace + DefaultMonitor = dmDesktop + KeyPreview = True + OnCreate = FormCreate + Position = poScreenCenter + LCLVersion = '2.1.0.0' + Scaled = False + object Image1: TImage + Left = 8 + Height = 32 + Top = 8 + Width = 32 + AutoSize = True + Picture.Data = { + 055449636F6EFE0200000000010001002020100001001000E802000016000000 + 2800000020000000400000000100040000000000800200000000000000000000 + 0000000000000000000000000000800000800000008080008000000080008000 + 80800000C0C0C000808080000000FF0000FF000000FFFF00FF000000FF00FF00 + FFFF0000FFFFFF00000000000000000000000000000000000000000000000000 + 00000000000000000000000000BBBBBB000000000000000000000000BBB0000B + BB000000000000000000000BB00000000BBB0000000000000000000BB0000000 + 0BBB000000000000000000BBBB0000000BBBB00000000000000000BBBB000000 + 00BBBB0000000000000000BBBBB0000000BBBB0000000000000000BBBBB00000 + 00BBBB0000000000000000BBBBB0000000BBBB00000000000000000BBB000000 + 00BBBB0000000000000000000000000000BBBB00000000000000000000000000 + 00BBBB0000000000000000000000000000BBBB00000000000000000000000000 + 00BBBB0000000000000000000000000000BBBB00000000000000000000000000 + 00BBBB0000000000000000000000000000BBBB00000000000000000000000000 + 00BBBB0000000000000000000000000000BBBB00000000000000000000000000 + 00BBBB0000000000000000000000000000BBBB00000000000000000000000000 + 00BBBB0000000000000000000000000000BBBB00000000000000000000000000 + 00BBBB0000000000000000000000000000BBBB00000000000000000000000000 + 00BBBB00000000000000000000000000BBBBBBB00000000000000000000000BB + BBBBBBBBBB000000000000000000000000000000000000000000000000000000 + 0000000000000000FFFFFFFFFFFFFFFFFFC0FFFFFF1E3FFFFE7F8FFFFE7F8FFF + FC3F87FFFC3FC3FFFC1FC3FFFC1FC3FFFC1FC3FFFE3FC3FFFFFFC3FFFFFFC3FF + FFFFC3FFFFFFC3FFFFFFC3FFFFFFC3FFFFFFC3FFFFFFC3FFFFFFC3FFFFFFC3FF + FFFFC3FFFFFFC3FFFFFFC3FFFFFFC3FFFFFFC3FFFFFFC3FFFFFF01FFFFFC003F + FFFFFFFFFFFFFFFF + } + Transparent = True + end + object Next: TButton + Left = 121 + Height = 25 + Top = 204 + Width = 75 + Caption = '&Next >>' + Default = True + OnClick = NextClick + TabOrder = 0 + end + object Button1: TButton + Left = 201 + Height = 25 + Top = 204 + Width = 75 + Caption = 'Close' + OnClick = Button1Click + TabOrder = 1 + end + object Panel1: TPanel + Left = 8 + Height = 146 + Top = 48 + Width = 276 + BevelOuter = bvLowered + ClientHeight = 146 + ClientWidth = 276 + TabOrder = 2 + object InstallLabel1: TJvInstallLabel + Left = 1 + Height = 144 + Top = 1 + Width = 274 + Align = alClient + Font.CharSet = ANSI_CHARSET + Font.Color = clBlack + Font.Height = -13 + Images = ImageList1 + Lines.Strings = ( + 'Install JCL' + 'Generate JVCL resources' + 'Generate JVCL DCR files' + 'Compile JVCL packages' + 'Install JVCL into Delphi IDE' + ) + ParentFont = False + TextOffset = 40 + ImageOffset = 8 + end + end + object ImageList1: TImageList + left = 48 + top = 8 + Bitmap = { + 4C69020000001000000010000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000FF000000FF0000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000FF000000FF000000FF00000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000FF000000FF000000FF000000FF000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000FF000000FF000000FF000000FF000000FF0000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000FF000000FF000000FF000000FF000000FF0000 + 00FF000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000FF000000FF000000FF000000FF000000FF0000 + 00FF000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000FF000000FF000000FF000000FF000000FF0000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000FF000000FF000000FF000000FF000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000FF000000FF000000FF00000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000FF000000FF0000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000008484FF00000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000008400FF0000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000084 + 00FF008484FF0000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000008484FF0084 + 00FF000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000008484FF008400FF0084 + 84FF000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000008400FF008400FF008400FF0000 + 0000000000000000000000000000008484FF008400FF008400FF000000000000 + 0000000000000000000000000000008400FF008400FF008400FF000000000000 + 000000000000000000000000000000000000008400FF008400FF008400FF0000 + 00000000000000000000008400FF008400FF008400FF008484FF000000000000 + 000000000000000000000000000000000000008484FF008400FF008400FF0084 + 00FF00000000008400FF008400FF008400FF008400FF00000000000000000000 + 00000000000000000000000000000000000000000000008400FF008400FF0084 + 00FF008400FF008400FF008400FF008400FF0000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000008400FF0084 + 00FF008400FF008400FF008400FF008484FF0000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000008484FF0084 + 00FF008400FF008400FF008484FF000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000084 + 00FF008400FF008400FF00000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000008400FF0000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000 + } + end +end diff --git a/components/jvcllaz/examples/JvInstallLabel/InstallLabelMainFormU.pas b/components/jvcllaz/examples/JvInstallLabel/InstallLabelMainFormU.pas new file mode 100644 index 000000000..ecf13163f --- /dev/null +++ b/components/jvcllaz/examples/JvInstallLabel/InstallLabelMainFormU.pas @@ -0,0 +1,89 @@ +{****************************************************************** + + JEDI-VCL Demo + + Copyright (C) 2002 Project JEDI + + Original author: + + Contributor(s): + + You may retrieve the latest version of this file at the JEDI-JVCL + home page, located at http://jvcl.delphi-jedi.org + + The contents of this file are used with permission, 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_1Final.html + + Software distributed under the License is distributed on an + "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + implied. See the License for the specific language governing + rights and limitations under the License. + +******************************************************************} + +unit InstallLabelMainFormU; + +{$MODE Delphi} + +interface + +uses + LCLIntf, LCLType, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, + StdCtrls, ExtCtrls, ImgList, JvInstallLabel; + +type + TInstallLabelMainForm = class(TForm) + ImageList1: TImageList; + Next: TButton; + Button1: TButton; + Image1: TImage; + Panel1: TPanel; + InstallLabel1: TJvInstallLabel; + procedure NextClick(Sender: TObject); + procedure FormCreate(Sender: TObject); + procedure Button1Click(Sender: TObject); + private + FIndex: Integer; + end; + +var + InstallLabelMainForm: TInstallLabelMainForm; + +implementation + +{$R *.lfm} + +procedure TInstallLabelMainForm.NextClick(Sender: TObject); +begin + Next.Caption := '&Next >>'; + if FIndex = 0 then { first line, so clear all others } + InstallLabel1.SetExclusive(FIndex, 0, [fsBold]) + else + begin + InstallLabel1.SetStyle(FIndex, 0, [fsBold]); { current line is an arrow } + InstallLabel1.SetStyle(FIndex - 1, 1, []); { prev line is a check mark } + + if FIndex = InstallLabel1.Lines.Count - 1 then { this is the last line } + begin + FIndex := -1; { incremented below...} + Next.Caption := '&Again...'; + end; + end; + + Inc(FIndex); +end; + +procedure TInstallLabelMainForm.FormCreate(Sender: TObject); +begin + FIndex := 0; +end; + +procedure TInstallLabelMainForm.Button1Click(Sender: TObject); +begin + Close; +end; + +end. diff --git a/components/jvcllaz/packages/jvctrlslazr.lpk b/components/jvcllaz/packages/jvctrlslazr.lpk index ef818ab44..737edb325 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="4"/> - <Files Count="8"> + <Files Count="9"> <Item1> <Filename Value="..\run\JvCtrls\jvhint.pas"/> <UnitName Value="JvHint"/> @@ -50,6 +50,10 @@ Movable bevel and panel, ruler, exandable panel (RollOut), group header, hyperte <Filename Value="..\run\JvCtrls\jvautocomplete.pas"/> <UnitName Value="JvAutoComplete"/> </Item8> + <Item9> + <Filename Value="..\run\JvCtrls\jvinstalllabel.pas"/> + <UnitName Value="JvInstallLabel"/> + </Item9> </Files> <RequiredPkgs Count="2"> <Item1> diff --git a/components/jvcllaz/resource/jvctrlsreg.res b/components/jvcllaz/resource/jvctrlsreg.res index 58fdc1a08..2fa2215e8 100644 Binary files a/components/jvcllaz/resource/jvctrlsreg.res and b/components/jvcllaz/resource/jvctrlsreg.res differ diff --git a/components/jvcllaz/run/JvCtrls/jvinstalllabel.pas b/components/jvcllaz/run/JvCtrls/jvinstalllabel.pas new file mode 100644 index 000000000..7ffa3499b --- /dev/null +++ b/components/jvcllaz/run/JvCtrls/jvinstalllabel.pas @@ -0,0 +1,339 @@ +{----------------------------------------------------------------------------- +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: JvInstallLabel.PAS, released on 2002-05-26. + +The Initial Developer of the Original Code is Peter Thörnqvist [peter3 at sourceforge dot net] +Portions created by Peter Thörnqvist are Copyright (C) 2002 Peter Thörnqvist. +All Rights Reserved. + +Contributor(s): + +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 component that makes it dead easy to have those nifty installation screens + with a list of tasks to perform and some formatting and icons to make sure the + user don't get lost when the big software company is stuffing his PC with rubbish. + +Known Issues: +-----------------------------------------------------------------------------} +// $Id$ + +unit JvInstallLabel; + +{$mode objfpc} +{$H+} + +interface + +uses + SysUtils, Classes, + Graphics, Controls, ImgList, LCLIntf, LCLType, + JvJCLUtils, JvComponent; + +type + TJvInstallLabel = class(TJvGraphicControl) + private + FImageList: TCustomImageList; + FImageChangeLink: TChangeLink; + FLines: TStringList; + FStyles: TList; + FTextOffset: Integer; + FImageOffset: Integer; + FLineSpacing: Integer; + FDefaultImage: Integer; + procedure SetIndex(Value: Integer); + procedure SetStyles(Index: Integer; Value: TFontStyles); + function GetStyles(Index: Integer): TFontStyles; + procedure SetImageList(Value: TCustomImageList); + function GetLines: TStrings; + procedure SetLines(Value: TStrings); + procedure SetImageOffset(Value: Integer); + procedure SetTextOffset(Value: Integer); + procedure SetLineSpacing(Value: Integer); + procedure Change(Sender: TObject); + procedure UpdateStyles; + function CheckBounds(Index: Integer): Boolean; + protected + procedure Paint; override; + procedure Notification(AComponent: TComponent; Operation: TOperation); override; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + procedure SetStyle(LineIndex, ImageIndex: Integer; LineStyle: TFontStyles); + procedure SetExclusive(LineIndex, ImageIndex: Integer; LineStyle: TFontStyles); + procedure SetImage(LineIndex, ImageIndex: Integer); + property Styles[Index: Integer]: TFontStyles read GetStyles write SetStyles; + published + property Align; + property Font; + property Color default clBtnFace; + property DefaultImage: Integer read FDefaultImage write SetIndex default -1; + property Images: TCustomImageList read FImageList write SetImageList; + property Lines: TStrings read GetLines write SetLines; + property LineSpacing: Integer read FLineSpacing write SetLineSpacing default 10; + property ShowHint; + property ParentShowHint; + property ParentFont; + property TextOffset: Integer read FTextOffset write SetTextOffset default 24; + property ImageOffset: Integer read FImageOffset write SetImageOffset default 2; + property DragCursor; + property DragMode; + property PopupMenu; + property OnClick; + property OnDragDrop; + property OnDragOver; + property OnEndDrag; + property OnMouseDown; + property OnMouseMove; + property OnMouseUp; + property OnStartDrag; + end; + +implementation + +uses + JvTypes, JvThemes, JvJVCLUtils, JvResources; + +type + PStyles = ^TStyles; + TStyles = record + Style: TFontStyles; + Index: Integer; + end; + +constructor TJvInstallLabel.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + IncludeThemeStyle(Self, [csParentBackground]); + FLines := TStringList.Create; + FLines.OnChange := @Change; + FStyles := TList.Create; + FImageChangeLink := TChangeLink.Create; + FImageChangeLink.OnChange := @Change; + FTextOffset := 24; + FImageOffset := 2; + FLineSpacing := 10; + FDefaultImage := -1; + SetBounds(0, 0, 180, 120); +end; + +destructor TJvInstallLabel.Destroy; +var + I: Integer; +begin + FLines.Free; + FImageChangeLink.Free; + for I := 0 to FStyles.Count - 1 do + if FStyles[I] <> nil then + Dispose(PStyles(FStyles[I])); + FStyles.Free; + inherited Destroy; +end; + +{ make sure Lines.Count = Styles.Count } + +procedure TJvInstallLabel.UpdateStyles; +var + Style: PStyles; +begin + while FStyles.Count > Lines.Count do + begin + if FStyles.Last <> nil then + Dispose(PStyles(FStyles.Last)); + FStyles.Delete(FStyles.Count - 1); + end; + + while FStyles.Count < Lines.Count do + begin + New(Style); + Style^.Style := Font.Style; { default } + Style^.Index := FDefaultImage; + FStyles.Add(Style); + end; +end; + +procedure TJvInstallLabel.SetIndex(Value: Integer); +var + I: Integer; +begin + if FDefaultImage <> Value then + begin + for I := 0 to FStyles.Count - 1 do + if PStyles(FStyles[I])^.Index = FDefaultImage then + PStyles(FStyles[I])^.Index := Value; + FDefaultImage := Value; + Invalidate; + end; +end; + +procedure TJvInstallLabel.SetStyles(Index: Integer; Value: TFontStyles); +begin + SetStyle(Index, FDefaultImage, Value); +end; + +function TJvInstallLabel.GetStyles(Index: Integer): TFontStyles; +begin + if not CheckBounds(Index) then + raise EJVCLException.CreateResFmt(@RsEListOutOfBounds, [Index]) + else + Result := PStyles(FStyles[Index])^.Style; +end; + +procedure TJvInstallLabel.SetImageList(Value: TCustomImageList); +begin + ReplaceImageListReference(Self, Value, FImageList, FImageChangeLink); +end; + +function TJvInstallLabel.GetLines: TStrings; +begin + Result := FLines; +end; + +procedure TJvInstallLabel.SetLines(Value: TStrings); +begin + FLines.Assign(Value); + UpdateStyles; + Invalidate; +end; + +procedure TJvInstallLabel.SetImageOffset(Value: Integer); +begin + if FImageOffset <> Value then + begin + FImageOffset := Value; + Invalidate; + end; +end; + +{ offset from left edge } + +procedure TJvInstallLabel.SetTextOffset(Value: Integer); +begin + if FTextOffset <> Value then + begin + FTextOffset := Value; + Invalidate; + end; +end; + +{ space between lines } + +procedure TJvInstallLabel.SetLineSpacing(Value: Integer); +begin + if FLineSpacing <> Value then + begin + FLineSpacing := Value; + Invalidate; + end; +end; + +procedure TJvInstallLabel.Notification(AComponent: TComponent; Operation: + TOperation); +begin + inherited Notification(AComponent, Operation); + if (AComponent = FImageList) and (Operation = opRemove) then + FImageList := nil; +end; + +procedure TJvInstallLabel.Paint; +var + Tmp, H, W, I: Integer; + aRect: TRect; +begin + if csDestroying in ComponentState then + Exit; + + DrawThemedBackground(Self, Canvas, ClientRect, Self.Color); + + if csDesigning in ComponentState then + with Canvas do + begin + Pen.Style := psDash; + Brush.Style := bsClear; + Rectangle(0, 0, Width, Height); + end; + + UpdateStyles; + Canvas.Font := Font; + SetBkMode(Canvas.Handle, LCLType.Transparent); + H := CanvasMaxTextHeight(Canvas); + for I := 0 to Lines.Count - 1 do + begin + Canvas.Font.Style := PStyles(FStyles[I])^.Style; + W := Canvas.TextWidth(Lines[I]); + Tmp := I * (H + FLineSpacing) + FLineSpacing; + aRect := Rect(FTextOffset, Tmp, FTextOffset + W, Tmp + H); + DrawText(Canvas, Lines[I], -1, aRect, DT_CENTER or DT_VCENTER or + DT_SINGLELINE or DT_NOPREFIX or DT_NOCLIP); + if Assigned(FImageList) then + begin + aRect.Top := aRect.Top + ((aRect.Bottom - aRect.Top) div 2); + FImageList.Draw(Canvas, FImageOffset, aRect.Top - FImageList.Height div 2, + PStyles(FStyles[I])^.Index); + end; + end; +end; + +{ set the style of this line without affecting any others } + +procedure TJvInstallLabel.SetStyle(LineIndex, ImageIndex: Integer; LineStyle: + TFontStyles); +begin + CheckBounds(LineIndex); + UpdateStyles; + PStyles(FStyles[LineIndex])^.Style := LineStyle; + PStyles(FStyles[LineIndex])^.Index := ImageIndex; + Invalidate; +end; + +{ reset all lines to default style except this one } + +procedure TJvInstallLabel.SetExclusive(LineIndex, ImageIndex: Integer; + LineStyle: TFontStyles); +var + I: Integer; +begin + CheckBounds(LineIndex); + UpdateStyles; + for I := 0 to FStyles.Count - 1 do + begin + PStyles(FStyles[I])^.Style := Font.Style; + PStyles(FStyles[I])^.Index := FDefaultImage; + end; + + PStyles(FStyles[LineIndex])^.Style := LineStyle; + PStyles(FStyles[LineIndex])^.Index := ImageIndex; + Invalidate; +end; + +procedure TJvInstallLabel.SetImage(LineIndex, ImageIndex: Integer); +begin + CheckBounds(LineIndex); + UpdateStyles; + PStyles(FStyles[LineIndex])^.Index := ImageIndex; + Invalidate; +end; + +procedure TJvInstallLabel.Change(Sender: TObject); +begin + Invalidate; +end; + +function TJvInstallLabel.CheckBounds(Index: Integer): Boolean; +begin + Result := (Index > -1) and (Index < Lines.Count); + if not Result then + raise EJVCLException.CreateResFmt(@RsEListOutOfBounds, [Index]); +end; + +end.