View Issue Details

IDProjectCategoryView StatusLast Update
0031011PatchesWidgetsetpublic2017-04-08 11:26
ReporterStefan KopfAssigned ToJuha Manninen 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
PlatformCarbonOSOS-XOS Version
Product Version1.6Product Build 
Target VersionFixed in Version 
Summary0031011: [PATCH] Fix: TListBox.ScrollWidth not implemented on Mac / Carbon
DescriptionThe TCustomListBox.ScrollWidth property is implemented in the Win32 Widgetset, but not yet in the Carbon Widgetset.

This patch adds this functionality to TCarbonListBox.
Steps To ReproduceOn OS-X / Carbon:
1. Add a ListBox to a form
2. Add some lines to the listbox that extend the width of the listbox
3. set ListBox.ScrollWidth to a value larger than the ListBox.Width
Expected:
A horizontal scrollbar appears like on Windows
However:
The value ListBox.ScrollWidth is reset to 0
TagsNo tags attached.
Fixed in Revisionr54565, r54569
LazTarget-
WidgetsetCarbon
Attached Files
  • Carbon_ListBox_ScrollWidth.patch (4,105 bytes)
    Index: lcl/interfaces/carbon/carbonlistviews.pp
    ===================================================================
    --- lcl/interfaces/carbon/carbonlistviews.pp	(revision 53067)
    +++ lcl/interfaces/carbon/carbonlistviews.pp	(working copy)
    @@ -148,7 +148,7 @@
         
         function GetItemChecked(AIndex: Integer): Boolean;
         function GetItemIndex: Integer;
    -    function GetItemsRect: TRect;
    +    function GetItemsRect: TRect; virtual;
         function GetItemsCount: Integer;
         function GetItemRect(AIndex: Integer): TRect;
         function GetItemRect(AIndex, {%H-}ASubIndex: Integer; {%H-}ACode: TDisplayCode): TRect;
    @@ -262,6 +262,8 @@
       { TCarbonListBox }
     
       TCarbonListBox = class(TCarbonDataBrowser)
    +  private
    +    FScrollWidth : Integer;
       protected
         procedure CreateWidget(const AParams: TCreateParams); override;
       protected
    @@ -273,6 +275,8 @@
         procedure DrawItem(AIndex: Integer; AState: DataBrowserItemState); override;
         procedure SelectionChanged(AIndex: Integer; ASelect: Boolean); override;
         procedure FocusedChanged({%H-}AIndex: Integer); override;
    +    function GetItemsRect: TRect; override;
    +    procedure SetScrollWidth(AScrollWidth: Integer);
       end;
       
       { TCarbonCheckListBox }
    @@ -1946,7 +1950,7 @@
       ShowAsList(True);
       SetItemsHeight((LCLObject as TCustomListBox).ItemHeight);
       SetRowSelect(True);
    -  SetScrollBars(ssAutoVertical);
    +  SetScrollBars(ssAutoBoth);
       SetSelectionMode((LCLObject as TCustomListBox).ExtendedSelect,
         (LCLObject as TCustomListBox).MultiSelect);
       //Set BorderStyle according to the provided Params
    @@ -2011,6 +2015,23 @@
       LCLSendSelectionChangedMsg(LCLObject);
     end;
     
    +function TCarbonListBox.GetItemsRect: TRect;
    +begin
    +  Result := inherited GetItemsRect;
    +  If FScrollWidth > 0 then
    +    Result.Right := FScrollWidth;
    +end;
    +
    +procedure TCarbonListBox.SetScrollWidth(AScrollWidth: Integer);
    +begin
    +  FScrollWidth := AScrollWidth;
    +  If AScrollWidth > 0 then
    +    FCaptionListColumn.SetWidth(AScrollWidth)
    +  Else
    +    FCaptionListColumn.SetWidth($FFFF);
    +  CheckNeedsScrollBars();
    +end;
    +
     { TCarbonCheckListBox }
     
     procedure TCarbonCheckListBox.CreateWidget(const AParams: TCreateParams);
    Index: lcl/interfaces/carbon/carbonwsstdctrls.pp
    ===================================================================
    --- lcl/interfaces/carbon/carbonwsstdctrls.pp	(revision 53067)
    +++ lcl/interfaces/carbon/carbonwsstdctrls.pp	(working copy)
    @@ -104,6 +104,7 @@
         class procedure SetBorderStyle(const AWinControl: TWinControl; const ABorderStyle: TBorderStyle); override;
         //class procedure SetBorder(const ACustomListBox: TCustomListBox); override;
         class procedure SetItemIndex(const ACustomListBox: TCustomListBox; const AIndex: integer); override;
    +    class procedure SetScrollWidth(const ACustomListBox: TCustomListBox; const AScrollWidth: Integer); override;
         class procedure SetSelectionMode(const ACustomListBox: TCustomListBox; const AExtendedSelect, AMultiSelect: boolean); override;
         class procedure SetStyle(const ACustomListBox: TCustomListBox); override;
         class procedure SetSorted(const ACustomListBox: TCustomListBox; AList: TStrings; ASorted: boolean); override;
    @@ -689,6 +690,21 @@
     end;
     
     {------------------------------------------------------------------------------
    +  Method:  TCarbonWSCustomListBox.SetScrollWidth
    +  Params:  ACustomListBox - LCL custom list box
    +           AScrollWidth   - Scroll width
    +
    +  Sets scroll width of list box in Carbon interface
    + ------------------------------------------------------------------------------}
    +class procedure TCarbonWSCustomListBox.SetScrollWidth(
    +  const ACustomListBox: TCustomListBox; const AScrollWidth: Integer);
    +begin
    +  if not CheckHandle(ACustomListBox, Self, 'SetScrollWidth') then Exit;
    +
    +  TCarbonListBox(ACustomListBox.Handle).SetScrollWidth(AScrollWidth);
    +end;
    +
    +{------------------------------------------------------------------------------
       Method:  TCarbonWSCustomListBox.SetSelectionMode
       Params:  ACustomListBox  - LCL custom list box
                AExtendedSelect - New extended selection value
    
  • fix.diff (824 bytes)
    Index: lcl/interfaces/carbon/carbonlistviews.pp
    ===================================================================
    --- lcl/interfaces/carbon/carbonlistviews.pp	(revision 54568)
    +++ lcl/interfaces/carbon/carbonlistviews.pp	(working copy)
    @@ -271,11 +271,13 @@
         function GetReadOnly: Boolean; override;
         function MultiSelect: Boolean; override;
         function IsOwnerDrawn: Boolean; override;
    +    function GetItemsRect: TRect; override;
       public
         procedure DrawItem(AIndex: Integer; AState: DataBrowserItemState); override;
         procedure SelectionChanged(AIndex: Integer; ASelect: Boolean); override;
         procedure FocusedChanged({%H-}AIndex: Integer); override;
         procedure SetFont(const AFont: TFont); override;
    +    procedure SetScrollWidth(AScrollWidth: Integer);
       end;
       
       { TCarbonCheckListBox }
    
    fix.diff (824 bytes)

Activities

Stefan Kopf

2016-11-26 16:38

reporter  

Carbon_ListBox_ScrollWidth.patch (4,105 bytes)
Index: lcl/interfaces/carbon/carbonlistviews.pp
===================================================================
--- lcl/interfaces/carbon/carbonlistviews.pp	(revision 53067)
+++ lcl/interfaces/carbon/carbonlistviews.pp	(working copy)
@@ -148,7 +148,7 @@
     
     function GetItemChecked(AIndex: Integer): Boolean;
     function GetItemIndex: Integer;
-    function GetItemsRect: TRect;
+    function GetItemsRect: TRect; virtual;
     function GetItemsCount: Integer;
     function GetItemRect(AIndex: Integer): TRect;
     function GetItemRect(AIndex, {%H-}ASubIndex: Integer; {%H-}ACode: TDisplayCode): TRect;
@@ -262,6 +262,8 @@
   { TCarbonListBox }
 
   TCarbonListBox = class(TCarbonDataBrowser)
+  private
+    FScrollWidth : Integer;
   protected
     procedure CreateWidget(const AParams: TCreateParams); override;
   protected
@@ -273,6 +275,8 @@
     procedure DrawItem(AIndex: Integer; AState: DataBrowserItemState); override;
     procedure SelectionChanged(AIndex: Integer; ASelect: Boolean); override;
     procedure FocusedChanged({%H-}AIndex: Integer); override;
+    function GetItemsRect: TRect; override;
+    procedure SetScrollWidth(AScrollWidth: Integer);
   end;
   
   { TCarbonCheckListBox }
@@ -1946,7 +1950,7 @@
   ShowAsList(True);
   SetItemsHeight((LCLObject as TCustomListBox).ItemHeight);
   SetRowSelect(True);
-  SetScrollBars(ssAutoVertical);
+  SetScrollBars(ssAutoBoth);
   SetSelectionMode((LCLObject as TCustomListBox).ExtendedSelect,
     (LCLObject as TCustomListBox).MultiSelect);
   //Set BorderStyle according to the provided Params
@@ -2011,6 +2015,23 @@
   LCLSendSelectionChangedMsg(LCLObject);
 end;
 
+function TCarbonListBox.GetItemsRect: TRect;
+begin
+  Result := inherited GetItemsRect;
+  If FScrollWidth > 0 then
+    Result.Right := FScrollWidth;
+end;
+
+procedure TCarbonListBox.SetScrollWidth(AScrollWidth: Integer);
+begin
+  FScrollWidth := AScrollWidth;
+  If AScrollWidth > 0 then
+    FCaptionListColumn.SetWidth(AScrollWidth)
+  Else
+    FCaptionListColumn.SetWidth($FFFF);
+  CheckNeedsScrollBars();
+end;
+
 { TCarbonCheckListBox }
 
 procedure TCarbonCheckListBox.CreateWidget(const AParams: TCreateParams);
Index: lcl/interfaces/carbon/carbonwsstdctrls.pp
===================================================================
--- lcl/interfaces/carbon/carbonwsstdctrls.pp	(revision 53067)
+++ lcl/interfaces/carbon/carbonwsstdctrls.pp	(working copy)
@@ -104,6 +104,7 @@
     class procedure SetBorderStyle(const AWinControl: TWinControl; const ABorderStyle: TBorderStyle); override;
     //class procedure SetBorder(const ACustomListBox: TCustomListBox); override;
     class procedure SetItemIndex(const ACustomListBox: TCustomListBox; const AIndex: integer); override;
+    class procedure SetScrollWidth(const ACustomListBox: TCustomListBox; const AScrollWidth: Integer); override;
     class procedure SetSelectionMode(const ACustomListBox: TCustomListBox; const AExtendedSelect, AMultiSelect: boolean); override;
     class procedure SetStyle(const ACustomListBox: TCustomListBox); override;
     class procedure SetSorted(const ACustomListBox: TCustomListBox; AList: TStrings; ASorted: boolean); override;
@@ -689,6 +690,21 @@
 end;
 
 {------------------------------------------------------------------------------
+  Method:  TCarbonWSCustomListBox.SetScrollWidth
+  Params:  ACustomListBox - LCL custom list box
+           AScrollWidth   - Scroll width
+
+  Sets scroll width of list box in Carbon interface
+ ------------------------------------------------------------------------------}
+class procedure TCarbonWSCustomListBox.SetScrollWidth(
+  const ACustomListBox: TCustomListBox; const AScrollWidth: Integer);
+begin
+  if not CheckHandle(ACustomListBox, Self, 'SetScrollWidth') then Exit;
+
+  TCarbonListBox(ACustomListBox.Handle).SetScrollWidth(AScrollWidth);
+end;
+
+{------------------------------------------------------------------------------
   Method:  TCarbonWSCustomListBox.SetSelectionMode
   Params:  ACustomListBox  - LCL custom list box
            AExtendedSelect - New extended selection value

Juha Manninen

2017-04-07 23:59

developer   ~0099484

Applied, thanks.

Alexey Tor.

2017-04-08 01:02

reporter  

fix.diff (824 bytes)
Index: lcl/interfaces/carbon/carbonlistviews.pp
===================================================================
--- lcl/interfaces/carbon/carbonlistviews.pp	(revision 54568)
+++ lcl/interfaces/carbon/carbonlistviews.pp	(working copy)
@@ -271,11 +271,13 @@
     function GetReadOnly: Boolean; override;
     function MultiSelect: Boolean; override;
     function IsOwnerDrawn: Boolean; override;
+    function GetItemsRect: TRect; override;
   public
     procedure DrawItem(AIndex: Integer; AState: DataBrowserItemState); override;
     procedure SelectionChanged(AIndex: Integer; ASelect: Boolean); override;
     procedure FocusedChanged({%H-}AIndex: Integer); override;
     procedure SetFont(const AFont: TFont); override;
+    procedure SetScrollWidth(AScrollWidth: Integer);
   end;
   
   { TCarbonCheckListBox }
fix.diff (824 bytes)

Alexey Tor.

2017-04-08 01:02

reporter   ~0099486

Last edited: 2017-04-08 01:03

View 3 revisions

Patch was incorrectly applied.Must run fix.diff.

Juha Manninen

2017-04-08 10:32

developer   ~0099494

Applied fix.diff.
AlexeyT, next time in similar situation please use the Reopen button. Notes in a resolved issue are easily ignored.

Juha Manninen

2017-04-08 11:26

developer   ~0099498

Applied. Resolving again.

Issue History

Date Modified Username Field Change
2016-11-26 16:38 Stefan Kopf New Issue
2016-11-26 16:38 Stefan Kopf File Added: Carbon_ListBox_ScrollWidth.patch
2017-04-07 23:23 Juha Manninen Assigned To => Juha Manninen
2017-04-07 23:23 Juha Manninen Status new => assigned
2017-04-07 23:59 Juha Manninen Fixed in Revision => r54565
2017-04-07 23:59 Juha Manninen LazTarget => -
2017-04-07 23:59 Juha Manninen Note Added: 0099484
2017-04-07 23:59 Juha Manninen Status assigned => resolved
2017-04-07 23:59 Juha Manninen Resolution open => fixed
2017-04-08 01:02 Alexey Tor. File Added: fix.diff
2017-04-08 01:02 Alexey Tor. Note Added: 0099486
2017-04-08 01:02 Alexey Tor. Note Edited: 0099486 View Revisions
2017-04-08 01:03 Alexey Tor. Note Edited: 0099486 View Revisions
2017-04-08 10:24 Juha Manninen Status resolved => assigned
2017-04-08 10:24 Juha Manninen Resolution fixed => reopened
2017-04-08 10:32 Juha Manninen Note Added: 0099494
2017-04-08 11:26 Juha Manninen Fixed in Revision r54565 => r54565, r54569
2017-04-08 11:26 Juha Manninen Note Added: 0099498
2017-04-08 11:26 Juha Manninen Status assigned => resolved
2017-04-08 11:26 Juha Manninen Resolution reopened => fixed