Преглед изворни кода

Merge branch 'leserg73-patch' into main. Updated whatsnew during merge + minor tweaks. Closes #390 for real.

Martijn Laan пре 4 година
родитељ
комит
b76815ecc4

+ 42 - 0
Components/NewCheckListBox.pas

@@ -37,6 +37,8 @@ type
     SubItem: string;
     SubItem: string;
     ThreadCache: set of Byte;
     ThreadCache: set of Byte;
     MeasuredHeight: Integer;
     MeasuredHeight: Integer;
+    ItemFontStyle: TFontStyles;
+    SubItemFontStyle: TFontStyles;
   end;
   end;
 
 
   TCheckItemOperation = (coUncheck, coCheck, coCheckWithChildren); 
   TCheckItemOperation = (coUncheck, coCheck, coCheckWithChildren); 
@@ -109,10 +111,12 @@ type
     function GetCaption(Index: Integer): String;
     function GetCaption(Index: Integer): String;
     function GetChecked(Index: Integer): Boolean;
     function GetChecked(Index: Integer): Boolean;
     function GetItemEnabled(Index: Integer): Boolean;
     function GetItemEnabled(Index: Integer): Boolean;
+    function GetItemFontStyle(Index: Integer): TFontStyles;
     function GetLevel(Index: Integer): Byte;
     function GetLevel(Index: Integer): Byte;
     function GetObject(Index: Integer): TObject;
     function GetObject(Index: Integer): TObject;
     function GetState(Index: Integer): TCheckBoxState;
     function GetState(Index: Integer): TCheckBoxState;
     function GetSubItem(Index: Integer): string;
     function GetSubItem(Index: Integer): string;
+    function GetSubItemFontStyle(Index: Integer): TFontStyles;
     procedure KeyDown(var Key: Word; Shift: TShiftState); override;
     procedure KeyDown(var Key: Word; Shift: TShiftState); override;
     procedure KeyUp(var Key: Word; Shift: TShiftState); override;
     procedure KeyUp(var Key: Word; Shift: TShiftState); override;
     procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
     procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
@@ -124,10 +128,12 @@ type
     procedure SetChecked(Index: Integer; const AChecked: Boolean);
     procedure SetChecked(Index: Integer; const AChecked: Boolean);
     procedure SetFlat(Value: Boolean);
     procedure SetFlat(Value: Boolean);
     procedure SetItemEnabled(Index: Integer; const AEnabled: Boolean);
     procedure SetItemEnabled(Index: Integer; const AEnabled: Boolean);
+    procedure SetItemFontStyle(Index: Integer; const AItemFontStyle: TFontStyles);
     procedure SetObject(Index: Integer; const AObject: TObject);
     procedure SetObject(Index: Integer; const AObject: TObject);
     procedure SetOffset(AnOffset: Integer);
     procedure SetOffset(AnOffset: Integer);
     procedure SetShowLines(Value: Boolean);
     procedure SetShowLines(Value: Boolean);
     procedure SetSubItem(Index: Integer; const ASubItem: String);
     procedure SetSubItem(Index: Integer; const ASubItem: String);
+    procedure SetSubItemFontStyle(Index: Integer; const ASubItemFontStyle: TFontStyles);
     property ItemStates[Index: Integer]: TItemState read GetItemState;
     property ItemStates[Index: Integer]: TItemState read GetItemState;
   public
   public
     constructor Create(AOwner: TComponent); override;
     constructor Create(AOwner: TComponent); override;
@@ -147,10 +153,12 @@ type
     property Checked[Index: Integer]: Boolean read GetChecked write SetChecked;
     property Checked[Index: Integer]: Boolean read GetChecked write SetChecked;
     property ItemCaption[Index: Integer]: String read GetCaption write SetCaption;
     property ItemCaption[Index: Integer]: String read GetCaption write SetCaption;
     property ItemEnabled[Index: Integer]: Boolean read GetItemEnabled write SetItemEnabled;
     property ItemEnabled[Index: Integer]: Boolean read GetItemEnabled write SetItemEnabled;
+    property ItemFontStyle[Index: Integer]: TFontStyles read GetItemFontStyle write SetItemFontStyle;
     property ItemLevel[Index: Integer]: Byte read GetLevel;
     property ItemLevel[Index: Integer]: Byte read GetLevel;
     property ItemObject[Index: Integer]: TObject read GetObject write SetObject;
     property ItemObject[Index: Integer]: TObject read GetObject write SetObject;
     property ItemSubItem[Index: Integer]: string read GetSubItem write SetSubItem;
     property ItemSubItem[Index: Integer]: string read GetSubItem write SetSubItem;
     property State[Index: Integer]: TCheckBoxState read GetState;
     property State[Index: Integer]: TCheckBoxState read GetState;
+    property SubItemFontStyle[Index: Integer]: TFontStyles read GetSubItemFontStyle write SetSubItemFontStyle;
   published
   published
     property Align;
     property Align;
     property Anchors;
     property Anchors;
@@ -859,6 +867,7 @@ begin
       DrawTextFormat := DT_NOCLIP or DT_NOPREFIX or DT_SINGLELINE or DT_VCENTER;
       DrawTextFormat := DT_NOCLIP or DT_NOPREFIX or DT_SINGLELINE or DT_VCENTER;
       if FUseRightToLeft then
       if FUseRightToLeft then
         DrawTextFormat := DrawTextFormat or (DT_RIGHT or DT_RTLREADING);
         DrawTextFormat := DrawTextFormat or (DT_RIGHT or DT_RTLREADING);
+      Font.Style := ItemState.SubItemFontStyle;
       SetRectEmpty(SubItemRect);
       SetRectEmpty(SubItemRect);
       InternalDrawText(ItemState.SubItem, SubItemRect, DrawTextFormat or
       InternalDrawText(ItemState.SubItem, SubItemRect, DrawTextFormat or
         DT_CALCRECT, False);
         DT_CALCRECT, False);
@@ -883,6 +892,7 @@ begin
       DrawTextFormat := DrawTextFormat or DT_HIDEPREFIX;
       DrawTextFormat := DrawTextFormat or DT_HIDEPREFIX;
     if FUseRightToLeft then
     if FUseRightToLeft then
       DrawTextFormat := DrawTextFormat or (DT_RIGHT or DT_RTLREADING);
       DrawTextFormat := DrawTextFormat or (DT_RIGHT or DT_RTLREADING);
+    Font.Style := ItemState.ItemFontStyle;
     { When you call DrawText with the DT_CALCRECT flag and there's a word wider
     { When you call DrawText with the DT_CALCRECT flag and there's a word wider
       than the rectangle width, it increases the rectangle width and wraps
       than the rectangle width, it increases the rectangle width and wraps
       at the new Right point. On the other hand, when you call DrawText
       at the new Right point. On the other hand, when you call DrawText
@@ -1065,6 +1075,11 @@ begin
   Result := ItemStates[Index].Enabled;
   Result := ItemStates[Index].Enabled;
 end;
 end;
 
 
+function TNewCheckListBox.GetItemFontStyle(Index: Integer): TFontStyles;
+begin
+  Result := ItemStates[Index].ItemFontStyle;
+end;
+
 function TNewCheckListBox.GetItemState(Index: Integer): TItemState;
 function TNewCheckListBox.GetItemState(Index: Integer): TItemState;
 begin
 begin
   Result := FStateList[Index];
   Result := FStateList[Index];
@@ -1106,6 +1121,11 @@ begin
   Result := ItemStates[Index].SubItem;
   Result := ItemStates[Index].SubItem;
 end;
 end;
 
 
+function TNewCheckListBox.GetSubItemFontStyle(Index: Integer): TFontStyles;
+begin
+  Result := ItemStates[Index].SubItemFontStyle;
+end;
+
 procedure TNewCheckListBox.InvalidateCheck(Index: Integer);
 procedure TNewCheckListBox.InvalidateCheck(Index: Integer);
 var
 var
   IRect: TRect;
   IRect: TRect;
@@ -1481,6 +1501,17 @@ begin
   end;
   end;
 end;
 end;
 
 
+procedure TNewCheckListBox.SetItemFontStyle(Index: Integer; const AItemFontStyle: TFontStyles);
+var
+  R: TRect;
+begin
+  if ItemStates[Index].ItemFontStyle <> AItemFontStyle then begin
+    ItemStates[Index].ItemFontStyle := AItemFontStyle;
+    R := ItemRect(Index);
+    InvalidateRect(Handle, @R, True);
+  end;
+end;
+
 procedure TNewCheckListBox.SetObject(Index: Integer; const AObject: TObject);
 procedure TNewCheckListBox.SetObject(Index: Integer; const AObject: TObject);
 begin
 begin
   ItemStates[Index].Obj := AObject;
   ItemStates[Index].Obj := AObject;
@@ -1530,6 +1561,17 @@ begin
   end;
   end;
 end;
 end;
 
 
+procedure TNewCheckListBox.SetSubItemFontStyle(Index: Integer; const ASubItemFontStyle: TFontStyles);
+var
+  R: TRect;
+begin
+  if ItemStates[Index].SubItemFontStyle <> ASubItemFontStyle then begin
+    ItemStates[Index].SubItemFontStyle := ASubItemFontStyle;
+    R := ItemRect(Index);
+    InvalidateRect(Handle, @R, True);
+  end;
+end;
+
 procedure TNewCheckListBox.Toggle(Index: Integer);
 procedure TNewCheckListBox.Toggle(Index: Integer);
 begin
 begin
   case ItemStates[Index].ItemType of
   case ItemStates[Index].ItemType of

+ 6 - 2
Examples/CodeClasses.iss

@@ -277,9 +277,13 @@ begin
   CheckListBox.AddRadioButton('TNewCheckListBox', '', 1, False, True, nil);
   CheckListBox.AddRadioButton('TNewCheckListBox', '', 1, False, True, nil);
   CheckListBox.AddCheckBox('TNewCheckListBox', '', 0, True, True, False, True, nil);
   CheckListBox.AddCheckBox('TNewCheckListBox', '', 0, True, True, False, True, nil);
   CheckListBox.AddCheckBox('TNewCheckListBox', '', 1, True, True, False, True, nil);
   CheckListBox.AddCheckBox('TNewCheckListBox', '', 1, True, True, False, True, nil);
-  CheckListBox.AddCheckBox('TNewCheckListBox', '', 2, True, True, False, True, nil);
-  CheckListBox.AddCheckBox('TNewCheckListBox', '', 2, False, True, False, True, nil);
+  CheckListBox.AddCheckBox('TNewCheckListBox', '123', 2, True, True, False, True, nil);
+  CheckListBox.AddCheckBox('TNewCheckListBox', '456', 2, False, True, False, True, nil);
   CheckListBox.AddCheckBox('TNewCheckListBox', '', 1, False, True, False, True, nil);
   CheckListBox.AddCheckBox('TNewCheckListBox', '', 1, False, True, False, True, nil);
+  CheckListBox.ItemFontStyle[5] := [fsBold];
+  CheckListBox.SubItemFontStyle[5] := [fsBold];
+  CheckListBox.ItemFontStyle[6] := [fsBold, fsItalic];
+  CheckListBox.SubItemFontStyle[6] := [fsBold, fsUnderline];
 
 
   CheckListBox2 := TNewCheckListBox.Create(Page);
   CheckListBox2 := TNewCheckListBox.Create(Page);
   CheckListBox2.Top := CheckListBox.Top + CheckListBox.Height + ScaleY(8);
   CheckListBox2.Top := CheckListBox.Top + CheckListBox.Height + ScaleY(8);

+ 2 - 0
ISHelp/isxclasses.pas

@@ -543,9 +543,11 @@ TNewCheckListBox = class(TCustomListBox)
   property State[Index: Integer]: TCheckBoxState; read write;
   property State[Index: Integer]: TCheckBoxState; read write;
   property ItemCaption[Index: Integer]: String; read write;
   property ItemCaption[Index: Integer]: String; read write;
   property ItemEnabled[Index: Integer]: Boolean; read write;
   property ItemEnabled[Index: Integer]: Boolean; read write;
+  property ItemFontStyle[Index: Integer]: TFontStyles; read write;
   property ItemLevel[Index: Integer]: Byte; read;
   property ItemLevel[Index: Integer]: Byte; read;
   property ItemObject[Index: Integer]: TObject; read write;
   property ItemObject[Index: Integer]: TObject; read write;
   property ItemSubItem[Index: Integer]: String; read write;
   property ItemSubItem[Index: Integer]: String; read write;
+  property SubItemFontStyle[Index: Integer]: TFontStyles; read write;
   property Flat: Boolean; read write;
   property Flat: Boolean; read write;
   property MinItemHeight: Integer; read write;
   property MinItemHeight: Integer; read write;
   property Offset: Integer; read write;
   property Offset: Integer; read write;

+ 3 - 1
Projects/ScriptClasses_C.pas

@@ -2,7 +2,7 @@ unit ScriptClasses_C;
 
 
 {
 {
   Inno Setup
   Inno Setup
-  Copyright (C) 1997-2019 Jordan Russell
+  Copyright (C) 1997-2020 Jordan Russell
   Portions by Martijn Laan
   Portions by Martijn Laan
   For conditions of distribution and use, see LICENSE.TXT.
   For conditions of distribution and use, see LICENSE.TXT.
 
 
@@ -86,6 +86,8 @@ begin
     RegisterProperty('ItemLevel', 'Byte Integer', iptr);
     RegisterProperty('ItemLevel', 'Byte Integer', iptr);
     RegisterProperty('ItemObject', 'TObject Integer', iptrw);
     RegisterProperty('ItemObject', 'TObject Integer', iptrw);
     RegisterProperty('ItemSubItem', 'String Integer', iptrw);
     RegisterProperty('ItemSubItem', 'String Integer', iptrw);
+    RegisterProperty('ItemFontStyle', 'TFontStyles Integer', iptrw);
+    RegisterProperty('SubItemFontStyle', 'TFontStyles Integer', iptrw);
     RegisterProperty('Flat', 'Boolean', iptrw);
     RegisterProperty('Flat', 'Boolean', iptrw);
     RegisterProperty('MinItemHeight', 'Integer', iptrw);
     RegisterProperty('MinItemHeight', 'Integer', iptrw);
     RegisterProperty('Offset', 'Integer', iptrw);
     RegisterProperty('Offset', 'Integer', iptrw);

+ 7 - 1
Projects/ScriptClasses_R.pas

@@ -2,7 +2,7 @@ unit ScriptClasses_R;
 
 
 {
 {
   Inno Setup
   Inno Setup
-  Copyright (C) 1997-2019 Jordan Russell
+  Copyright (C) 1997-2020 Jordan Russell
   Portions by Martijn Laan
   Portions by Martijn Laan
   For conditions of distribution and use, see LICENSE.TXT.
   For conditions of distribution and use, see LICENSE.TXT.
 
 
@@ -66,6 +66,10 @@ procedure TNewCheckListBoxItemObject_R(Self: TNewCheckListBox; var T: TObject; t
 procedure TNewCheckListBoxItemObject_W(Self: TNewCheckListBox; const T: TObject; t1: Integer); begin Self.ItemObject[t1] := T; end;
 procedure TNewCheckListBoxItemObject_W(Self: TNewCheckListBox; const T: TObject; t1: Integer); begin Self.ItemObject[t1] := T; end;
 procedure TNewCheckListBoxItemSubItem_R(Self: TNewCheckListBox; var T: String; t1: Integer); begin T := Self.ItemSubItem[t1]; end;
 procedure TNewCheckListBoxItemSubItem_R(Self: TNewCheckListBox; var T: String; t1: Integer); begin T := Self.ItemSubItem[t1]; end;
 procedure TNewCheckListBoxItemSubItem_W(Self: TNewCheckListBox; const T: String; t1: Integer); begin Self.ItemSubItem[t1] := T; end;
 procedure TNewCheckListBoxItemSubItem_W(Self: TNewCheckListBox; const T: String; t1: Integer); begin Self.ItemSubItem[t1] := T; end;
+procedure TNewCheckListBoxItemFontStyle_R(Self: TNewCheckListBox; var T: TFontStyles; const t1: Integer); begin T := Self.ItemFontStyle[t1]; end;
+procedure TNewCheckListBoxItemFontStyle_W(Self: TNewCheckListBox; const T: TFontStyles; const t1: Integer); begin Self.ItemFontStyle[t1] := T; end;
+procedure TNewCheckListBoxSubItemFontStyle_R(Self: TNewCheckListBox; var T: TFontStyles; const t1: Integer); begin T := Self.SubItemFontStyle[t1]; end;
+procedure TNewCheckListBoxSubItemFontStyle_W(Self: TNewCheckListBox; const T: TFontStyles; const t1: Integer); begin Self.SubItemFontStyle[t1] := T; end;
 
 
 procedure RegisterNewCheckListBox_R(Cl: TPSRuntimeClassImporter);
 procedure RegisterNewCheckListBox_R(Cl: TPSRuntimeClassImporter);
 begin
 begin
@@ -82,6 +86,8 @@ begin
     RegisterPropertyHelper(@TNewCheckListBoxItemLevel_R, nil, 'ItemLevel');
     RegisterPropertyHelper(@TNewCheckListBoxItemLevel_R, nil, 'ItemLevel');
     RegisterPropertyHelper(@TNewCheckListBoxItemObject_R, @TNewCheckListBoxItemObject_W, 'ItemObject');
     RegisterPropertyHelper(@TNewCheckListBoxItemObject_R, @TNewCheckListBoxItemObject_W, 'ItemObject');
     RegisterPropertyHelper(@TNewCheckListBoxItemSubItem_R, @TNewCheckListBoxItemSubItem_W, 'ItemSubItem');
     RegisterPropertyHelper(@TNewCheckListBoxItemSubItem_R, @TNewCheckListBoxItemSubItem_W, 'ItemSubItem');
+    RegisterPropertyHelper(@TNewCheckListBoxItemFontStyle_R, @TNewCheckListBoxItemFontStyle_W, 'ItemFontStyle');
+    RegisterPropertyHelper(@TNewCheckListBoxSubItemFontStyle_R, @TNewCheckListBoxSubItemFontStyle_W, 'SubItemFontStyle');
   end;
   end;
 end;
 end;
 
 

+ 7 - 0
whatsnew.htm

@@ -28,6 +28,13 @@ For conditions of distribution and use, see <a href="https://jrsoftware.org/file
 
 
 <p><b>Want to be notified by e-mail of new Inno Setup releases?</b> <a href="https://jrsoftware.org/ismail.php">Subscribe</a> to the Inno Setup Mailing List!</p>
 <p><b>Want to be notified by e-mail of new Inno Setup releases?</b> <a href="https://jrsoftware.org/ismail.php">Subscribe</a> to the Inno Setup Mailing List!</p>
 
 
+<p><a name="6.1.3"></a><span class="ver">6.1.3-dev </span><span class="date">(?)</span></p>
+<ul>
+  <li>Pascal Scripting change: Added new <tt>ItemFontStyle</tt> and <tt>SubItemFontStyle</tt> properties to the <tt/>TNewCheckListBox<tt> support class. See the <i><a href="https://jrsoftware.github.io/issrc/Examples/CodeClasses.iss">CodeClasses.iss</a></i> example script for an example.</li>
+</ul>
+
+<p>Contributions via <a href="https://github.com/jrsoftware/issrc" target="_blank">GitHub</a>: <b>Thanks to Sergii Leonov for their contributions.</b></p>
+
 <p><a name="6.1.2"></a><span class="ver">6.1.2 </span><span class="date">(2020-11-15)</span></p>
 <p><a name="6.1.2"></a><span class="ver">6.1.2 </span><span class="date">(2020-11-15)</span></p>
 <ul>
 <ul>
   <li>Compiler IDE change: Added new <i>Print... (Ctrl+P)</i> menu item to the <i>File</i> menu.</li>
   <li>Compiler IDE change: Added new <i>Print... (Ctrl+P)</i> menu item to the <i>File</i> menu.</li>