- LCL and Win32 TListBox.Columns

git-svn-id: trunk@11083 -
This commit is contained in:
paul 2007-05-05 15:30:19 +00:00
parent 1cf140d3ce
commit 45f07afcc1
4 changed files with 45 additions and 0 deletions

View File

@ -157,6 +157,15 @@ begin
Result := FTopIndex; Result := FTopIndex;
end; 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; function TCustomListBox.GetCount: Integer;
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}

View File

@ -118,6 +118,8 @@ type
private private
protected protected
public public
class procedure AdaptBounds(const AWinControl: TWinControl;
var Left, Top, Width, Height: integer; var SuppressMove: boolean); override;
class function CreateHandle(const AWinControl: TWinControl; class function CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): HWND; override; const AParams: TCreateParams): HWND; override;
class function GetSelCount(const ACustomListBox: TCustomListBox): integer; override; class function GetSelCount(const ACustomListBox: TCustomListBox): integer; override;
@ -125,8 +127,10 @@ type
class function GetStrings(const ACustomListBox: TCustomListBox): TStrings; override; class function GetStrings(const ACustomListBox: TCustomListBox): TStrings; override;
class function GetItemIndex(const ACustomListBox: TCustomListBox): integer; override; class function GetItemIndex(const ACustomListBox: TCustomListBox): integer; override;
class function GetTopIndex(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 SelectItem(const ACustomListBox: TCustomListBox; AIndex: integer; ASelected: boolean); override;
class procedure SetBorder(const ACustomListBox: TCustomListBox); 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 SetItemIndex(const ACustomListBox: TCustomListBox; const AIndex: integer); override;
class procedure SetSelectionMode(const ACustomListBox: TCustomListBox; const AExtendedSelect, class procedure SetSelectionMode(const ACustomListBox: TCustomListBox; const AExtendedSelect,
AMultiSelect: boolean); override; AMultiSelect: boolean); override;
@ -433,6 +437,17 @@ end;
{ TWin32WSCustomListBox } { 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; class function TWin32WSCustomListBox.CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): HWND; const AParams: TCreateParams): HWND;
var var
@ -452,6 +467,8 @@ begin
Flags := Flags or LBS_EXTENDEDSEL Flags := Flags or LBS_EXTENDEDSEL
else else
Flags := Flags or LBS_MULTIPLESEL; Flags := Flags or LBS_MULTIPLESEL;
if Columns > 1 then
Flags := Flags or LBS_MULTICOLUMN;
if AWinControl.FCompStyle = csCheckListBox then if AWinControl.FCompStyle = csCheckListBox then
Flags := Flags or LBS_OWNERDRAWFIXED Flags := Flags or LBS_OWNERDRAWFIXED
else case Style of else case Style of
@ -554,6 +571,13 @@ begin
SetWindowLong(Handle, GWL_EXSTYLE, StyleEx); SetWindowLong(Handle, GWL_EXSTYLE, StyleEx);
end; 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); class procedure TWin32WSCustomListBox.SetItemIndex(const ACustomListBox: TCustomListBox; const AIndex: integer);
var var
Handle: HWND; Handle: HWND;

View File

@ -448,6 +448,7 @@ type
FCanvas: TCanvas; FCanvas: TCanvas;
FClickOnSelChange: boolean; FClickOnSelChange: boolean;
FClickTriggeredBySelectionChange: Boolean; FClickTriggeredBySelectionChange: Boolean;
FColumns: Integer;
FExtendedSelect: boolean; FExtendedSelect: boolean;
FIntegralHeight: boolean; FIntegralHeight: boolean;
FItemHeight: Integer; FItemHeight: Integer;
@ -463,6 +464,7 @@ type
FTopIndex: integer; FTopIndex: integer;
function GetCount: Integer; function GetCount: Integer;
function GetTopIndex: Integer; function GetTopIndex: Integer;
procedure SetColumns(const AValue: Integer);
procedure SetTopIndex(const AValue: Integer); procedure SetTopIndex(const AValue: Integer);
procedure UpdateSelectionMode; procedure UpdateSelectionMode;
procedure UpdateSorted; procedure UpdateSorted;
@ -521,6 +523,7 @@ type
property Canvas: TCanvas read FCanvas; property Canvas: TCanvas read FCanvas;
property ClickOnSelChange: boolean read FClickOnSelChange property ClickOnSelChange: boolean read FClickOnSelChange
write FClickOnSelChange default true; // true is Delphi behaviour write FClickOnSelChange default true; // true is Delphi behaviour
property Columns: Integer read FColumns write SetColumns default 0;
property Constraints; property Constraints;
property Count: Integer read GetCount; // for Delphi compatability property Count: Integer read GetCount; // for Delphi compatability
property ExtendedSelect: boolean read FExtendedSelect write SetExtendedSelect default true; property ExtendedSelect: boolean read FExtendedSelect write SetExtendedSelect default true;
@ -575,6 +578,7 @@ type
property BorderStyle; property BorderStyle;
property ClickOnSelChange; property ClickOnSelChange;
property Color; property Color;
property Columns;
property Constraints; property Constraints;
property DragCursor; property DragCursor;
property DragMode; property DragMode;
@ -1376,3 +1380,4 @@ end.

View File

@ -105,7 +105,9 @@ type
class function GetItemIndex(const ACustomListBox: TCustomListBox): integer; virtual; class function GetItemIndex(const ACustomListBox: TCustomListBox): integer; virtual;
class function GetTopIndex(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 SelectItem(const ACustomListBox: TCustomListBox; AIndex: integer; ASelected: boolean); virtual;
class procedure SetBorder(const ACustomListBox: TCustomListBox); 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 SetItemIndex(const ACustomListBox: TCustomListBox; const AIndex: integer); virtual;
class procedure SetSelectionMode(const ACustomListBox: TCustomListBox; const AExtendedSelect, class procedure SetSelectionMode(const ACustomListBox: TCustomListBox; const AExtendedSelect,
AMultiSelect: boolean); virtual; AMultiSelect: boolean); virtual;
@ -243,6 +245,11 @@ class procedure TWSCustomListBox.SetBorder(const ACustomListBox: TCustomListBox)
begin begin
end; end;
class procedure TWSCustomListBox.SetColumnCount(const ACustomListBox: TCustomListBox;
ACount: Integer);
begin
end;
class procedure TWSCustomListBox.SetItemIndex(const ACustomListBox: TCustomListBox; const AIndex: integer); class procedure TWSCustomListBox.SetItemIndex(const ACustomListBox: TCustomListBox; const AIndex: integer);
begin begin
end; end;