mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-15 23:39:24 +02:00
lcl: add support for invisible sections in THeaderControl (from Benito van der Zander #0011727)
git-svn-id: trunk@16817 -
This commit is contained in:
parent
e6b1fe55e0
commit
220ada332c
@ -2575,8 +2575,10 @@ type
|
|||||||
FMaxWidth: Integer;
|
FMaxWidth: Integer;
|
||||||
FState: THeaderSectionState;
|
FState: THeaderSectionState;
|
||||||
FText: string;
|
FText: string;
|
||||||
|
FVisible: Boolean;
|
||||||
FWidth: Integer;
|
FWidth: Integer;
|
||||||
FOriginalIndex: Integer;
|
FOriginalIndex: Integer;
|
||||||
|
function GetWidth: Integer;
|
||||||
function GetLeft: Integer;
|
function GetLeft: Integer;
|
||||||
function GetRight: Integer;
|
function GetRight: Integer;
|
||||||
procedure SetAlignment(const AValue: TAlignment);
|
procedure SetAlignment(const AValue: TAlignment);
|
||||||
@ -2584,6 +2586,7 @@ type
|
|||||||
procedure SetMinWidth(AValue: Integer);
|
procedure SetMinWidth(AValue: Integer);
|
||||||
procedure SetState(const AValue: THeaderSectionState);
|
procedure SetState(const AValue: THeaderSectionState);
|
||||||
procedure SetText(const Value: string);
|
procedure SetText(const Value: string);
|
||||||
|
procedure SetVisible(const AValue: Boolean);
|
||||||
procedure SetWidth(Value: Integer);
|
procedure SetWidth(Value: Integer);
|
||||||
procedure SetImageIndex(const Value: TImageIndex);
|
procedure SetImageIndex(const Value: TImageIndex);
|
||||||
procedure CheckConstraints;
|
procedure CheckConstraints;
|
||||||
@ -2599,7 +2602,8 @@ type
|
|||||||
property MaxWidth: Integer read FMaxWidth write SetMaxWidth default 10000;
|
property MaxWidth: Integer read FMaxWidth write SetMaxWidth default 10000;
|
||||||
property MinWidth: Integer read FMinWidth write SetMinWidth default 0;
|
property MinWidth: Integer read FMinWidth write SetMinWidth default 0;
|
||||||
property Text: string read FText write SetText;
|
property Text: string read FText write SetText;
|
||||||
property Width: Integer read FWidth write SetWidth;
|
property Width: Integer read GetWidth write SetWidth;
|
||||||
|
property Visible: Boolean read FVisible write SetVisible;
|
||||||
//index which doesn't change when the user reorders the sections
|
//index which doesn't change when the user reorders the sections
|
||||||
property OriginalIndex: Integer read FOriginalIndex;
|
property OriginalIndex: Integer read FOriginalIndex;
|
||||||
end;
|
end;
|
||||||
@ -2658,6 +2662,7 @@ type
|
|||||||
FOnSectionDrag: TSectionDragEvent;
|
FOnSectionDrag: TSectionDragEvent;
|
||||||
FOnSectionEndDrag: TNotifyEvent;
|
FOnSectionEndDrag: TNotifyEvent;
|
||||||
FOnCreateSectionClass: TCustomHCCreateSectionClassEvent;
|
FOnCreateSectionClass: TCustomHCCreateSectionClassEvent;
|
||||||
|
function GetSectionFromOriginalIndex(OriginalIndex: Integer): THeaderSection;
|
||||||
procedure SetImages(const AValue: TCustomImageList);
|
procedure SetImages(const AValue: TCustomImageList);
|
||||||
procedure SetSections(const AValue: THeaderSections);
|
procedure SetSections(const AValue: THeaderSections);
|
||||||
procedure UpdateSection(Index: Integer);
|
procedure UpdateSection(Index: Integer);
|
||||||
@ -2682,6 +2687,8 @@ type
|
|||||||
procedure UpdateState;
|
procedure UpdateState;
|
||||||
class function GetControlClassDefaultSize: TPoint; override;
|
class function GetControlClassDefaultSize: TPoint; override;
|
||||||
public
|
public
|
||||||
|
property SectionFromOriginalIndex[OriginalIndex: Integer]: THeaderSection read GetSectionFromOriginalIndex;
|
||||||
|
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
|
|
||||||
|
@ -28,6 +28,16 @@ begin
|
|||||||
FImages := AValue;
|
FImages := AValue;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TCustomHeaderControl.GetSectionFromOriginalIndex(OriginalIndex: Integer): THeaderSection;
|
||||||
|
var
|
||||||
|
i: Longint;
|
||||||
|
begin
|
||||||
|
Result := nil;
|
||||||
|
for i := 0 to FSections.Count - 1 do
|
||||||
|
if FSections[i].OriginalIndex = OriginalIndex then
|
||||||
|
Exit(FSections[i]);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCustomHeaderControl.SetSections(const AValue: THeaderSections);
|
procedure TCustomHeaderControl.SetSections(const AValue: THeaderSections);
|
||||||
begin
|
begin
|
||||||
FSections := AValue;
|
FSections := AValue;
|
||||||
@ -107,7 +117,7 @@ var
|
|||||||
begin
|
begin
|
||||||
Result := -1;
|
Result := -1;
|
||||||
for i := 0 to Sections.Count - 1 do
|
for i := 0 to Sections.Count - 1 do
|
||||||
if (Sections[i].Left <= P.X) and (Sections[i].Right >= P.X) then
|
if Sections[i].Visible and (Sections[i].Left <= P.X) and (Sections[i].Right >= P.X) then
|
||||||
begin
|
begin
|
||||||
Result := i;
|
Result := i;
|
||||||
break;
|
break;
|
||||||
@ -141,8 +151,7 @@ begin
|
|||||||
FOnSectionTrack(Self, Section, Section.FWidth, State);
|
FOnSectionTrack(Self, Section, Section.FWidth, State);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomHeaderControl.SectionSeparatorDblClick(Section: THeaderSection
|
procedure TCustomHeaderControl.SectionSeparatorDblClick(Section: THeaderSection);
|
||||||
);
|
|
||||||
begin
|
begin
|
||||||
if Assigned(FOnSectionSeparatorDblClick) then
|
if Assigned(FOnSectionSeparatorDblClick) then
|
||||||
FOnSectionSeparatorDblClick(Self, Section);
|
FOnSectionSeparatorDblClick(Self, Section);
|
||||||
@ -364,6 +373,7 @@ var
|
|||||||
Section: THeaderSection;
|
Section: THeaderSection;
|
||||||
begin
|
begin
|
||||||
Section := Sections[Index];
|
Section := Sections[Index];
|
||||||
|
if not Section.Visible then Exit;
|
||||||
ARect := FPaintRect;
|
ARect := FPaintRect;
|
||||||
ARect.Left := FPaintRect.Left + Section.Left;
|
ARect.Left := FPaintRect.Left + Section.Left;
|
||||||
ARect.Right := FPaintRect.Left + Section.Right;
|
ARect.Right := FPaintRect.Left + Section.Right;
|
||||||
@ -459,6 +469,14 @@ end;
|
|||||||
|
|
||||||
{ THeaderSection }
|
{ THeaderSection }
|
||||||
|
|
||||||
|
function THeaderSection.GetWidth: Integer;
|
||||||
|
begin
|
||||||
|
if Visible then
|
||||||
|
Result := FWidth
|
||||||
|
else
|
||||||
|
Result := 0;
|
||||||
|
end;
|
||||||
|
|
||||||
function THeaderSection.GetLeft: Integer;
|
function THeaderSection.GetLeft: Integer;
|
||||||
var
|
var
|
||||||
i: integer;
|
i: integer;
|
||||||
@ -530,6 +548,15 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure THeaderSection.SetVisible(const AValue: Boolean);
|
||||||
|
begin
|
||||||
|
if FVisible <> AValue then
|
||||||
|
begin
|
||||||
|
FVisible := AValue;
|
||||||
|
Changed(False);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure THeaderSection.SetWidth(Value: Integer);
|
procedure THeaderSection.SetWidth(Value: Integer);
|
||||||
begin
|
begin
|
||||||
if FWidth <> Value then
|
if FWidth <> Value then
|
||||||
@ -565,6 +592,7 @@ begin
|
|||||||
FText := '';
|
FText := '';
|
||||||
FAlignment := taLeftJustify;
|
FAlignment := taLeftJustify;
|
||||||
FState := hsNormal;
|
FState := hsNormal;
|
||||||
|
FVisible := True;
|
||||||
FMinWidth := 0;
|
FMinWidth := 0;
|
||||||
FMaxWidth := 10000;
|
FMaxWidth := 10000;
|
||||||
FOriginalIndex:=ACollection.Count-1;
|
FOriginalIndex:=ACollection.Count-1;
|
||||||
|
Loading…
Reference in New Issue
Block a user