mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-01 21:40:25 +02:00
- LCL and Win32 TListBox.Columns
git-svn-id: trunk@11083 -
This commit is contained in:
parent
1cf140d3ce
commit
45f07afcc1
@ -157,6 +157,15 @@ begin
|
||||
Result := FTopIndex;
|
||||
end;
|
||||
|
||||
procedure TCustomListBox.SetColumns(const AValue: Integer);
|
||||
begin
|
||||
if (FColumns = AValue) or (AValue < 0) then
|
||||
exit;
|
||||
FColumns := AValue;
|
||||
if HandleAllocated then
|
||||
TWSCustomListBoxClass(WidgetSetClass).SetColumnCount(Self, FColumns);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
function TCustomListBox.GetCount: Integer;
|
||||
------------------------------------------------------------------------------}
|
||||
|
@ -118,6 +118,8 @@ type
|
||||
private
|
||||
protected
|
||||
public
|
||||
class procedure AdaptBounds(const AWinControl: TWinControl;
|
||||
var Left, Top, Width, Height: integer; var SuppressMove: boolean); override;
|
||||
class function CreateHandle(const AWinControl: TWinControl;
|
||||
const AParams: TCreateParams): HWND; override;
|
||||
class function GetSelCount(const ACustomListBox: TCustomListBox): integer; override;
|
||||
@ -125,8 +127,10 @@ type
|
||||
class function GetStrings(const ACustomListBox: TCustomListBox): TStrings; override;
|
||||
class function GetItemIndex(const ACustomListBox: TCustomListBox): integer; override;
|
||||
class function GetTopIndex(const ACustomListBox: TCustomListBox): integer; override;
|
||||
|
||||
class procedure SelectItem(const ACustomListBox: TCustomListBox; AIndex: integer; ASelected: boolean); override;
|
||||
class procedure SetBorder(const ACustomListBox: TCustomListBox); override;
|
||||
class procedure SetColumnCount(const ACustomListBox: TCustomListBox; ACount: Integer); override;
|
||||
class procedure SetItemIndex(const ACustomListBox: TCustomListBox; const AIndex: integer); override;
|
||||
class procedure SetSelectionMode(const ACustomListBox: TCustomListBox; const AExtendedSelect,
|
||||
AMultiSelect: boolean); override;
|
||||
@ -433,6 +437,17 @@ end;
|
||||
|
||||
{ TWin32WSCustomListBox }
|
||||
|
||||
class procedure TWin32WSCustomListBox.AdaptBounds(
|
||||
const AWinControl: TWinControl; var Left, Top, Width, Height: integer;
|
||||
var SuppressMove: boolean);
|
||||
var
|
||||
ColCount: Integer;
|
||||
begin
|
||||
ColCount := TCustomListBox(AWinControl).Columns;
|
||||
if ColCount > 1 then
|
||||
SendMessage(AWinControl.Handle, LB_SETCOLUMNWIDTH, Max(1, Width div ColCount), 0);
|
||||
end;
|
||||
|
||||
class function TWin32WSCustomListBox.CreateHandle(const AWinControl: TWinControl;
|
||||
const AParams: TCreateParams): HWND;
|
||||
var
|
||||
@ -452,6 +467,8 @@ begin
|
||||
Flags := Flags or LBS_EXTENDEDSEL
|
||||
else
|
||||
Flags := Flags or LBS_MULTIPLESEL;
|
||||
if Columns > 1 then
|
||||
Flags := Flags or LBS_MULTICOLUMN;
|
||||
if AWinControl.FCompStyle = csCheckListBox then
|
||||
Flags := Flags or LBS_OWNERDRAWFIXED
|
||||
else case Style of
|
||||
@ -554,6 +571,13 @@ begin
|
||||
SetWindowLong(Handle, GWL_EXSTYLE, StyleEx);
|
||||
end;
|
||||
|
||||
class procedure TWin32WSCustomListBox.SetColumnCount(const ACustomListBox: TCustomListBox;
|
||||
ACount: Integer);
|
||||
begin
|
||||
// The listbox styles can't be updated, so recreate the listbox
|
||||
RecreateWnd(ACustomListBox);
|
||||
end;
|
||||
|
||||
class procedure TWin32WSCustomListBox.SetItemIndex(const ACustomListBox: TCustomListBox; const AIndex: integer);
|
||||
var
|
||||
Handle: HWND;
|
||||
|
@ -448,6 +448,7 @@ type
|
||||
FCanvas: TCanvas;
|
||||
FClickOnSelChange: boolean;
|
||||
FClickTriggeredBySelectionChange: Boolean;
|
||||
FColumns: Integer;
|
||||
FExtendedSelect: boolean;
|
||||
FIntegralHeight: boolean;
|
||||
FItemHeight: Integer;
|
||||
@ -463,6 +464,7 @@ type
|
||||
FTopIndex: integer;
|
||||
function GetCount: Integer;
|
||||
function GetTopIndex: Integer;
|
||||
procedure SetColumns(const AValue: Integer);
|
||||
procedure SetTopIndex(const AValue: Integer);
|
||||
procedure UpdateSelectionMode;
|
||||
procedure UpdateSorted;
|
||||
@ -521,6 +523,7 @@ type
|
||||
property Canvas: TCanvas read FCanvas;
|
||||
property ClickOnSelChange: boolean read FClickOnSelChange
|
||||
write FClickOnSelChange default true; // true is Delphi behaviour
|
||||
property Columns: Integer read FColumns write SetColumns default 0;
|
||||
property Constraints;
|
||||
property Count: Integer read GetCount; // for Delphi compatability
|
||||
property ExtendedSelect: boolean read FExtendedSelect write SetExtendedSelect default true;
|
||||
@ -575,6 +578,7 @@ type
|
||||
property BorderStyle;
|
||||
property ClickOnSelChange;
|
||||
property Color;
|
||||
property Columns;
|
||||
property Constraints;
|
||||
property DragCursor;
|
||||
property DragMode;
|
||||
@ -1376,3 +1380,4 @@ end.
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -105,7 +105,9 @@ type
|
||||
class function GetItemIndex(const ACustomListBox: TCustomListBox): integer; virtual;
|
||||
class function GetTopIndex(const ACustomListBox: TCustomListBox): integer; virtual;
|
||||
class procedure SelectItem(const ACustomListBox: TCustomListBox; AIndex: integer; ASelected: boolean); virtual;
|
||||
|
||||
class procedure SetBorder(const ACustomListBox: TCustomListBox); virtual;
|
||||
class procedure SetColumnCount(const ACustomListBox: TCustomListBox; ACount: Integer); virtual;
|
||||
class procedure SetItemIndex(const ACustomListBox: TCustomListBox; const AIndex: integer); virtual;
|
||||
class procedure SetSelectionMode(const ACustomListBox: TCustomListBox; const AExtendedSelect,
|
||||
AMultiSelect: boolean); virtual;
|
||||
@ -243,6 +245,11 @@ class procedure TWSCustomListBox.SetBorder(const ACustomListBox: TCustomListBox)
|
||||
begin
|
||||
end;
|
||||
|
||||
class procedure TWSCustomListBox.SetColumnCount(const ACustomListBox: TCustomListBox;
|
||||
ACount: Integer);
|
||||
begin
|
||||
end;
|
||||
|
||||
class procedure TWSCustomListBox.SetItemIndex(const ACustomListBox: TCustomListBox; const AIndex: integer);
|
||||
begin
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user