* Fix header checkbox display and click response. Issue 23443

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4135 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
blikblum
2015-05-17 02:37:41 +00:00
parent ef5d1c549c
commit f2794f8c30
2 changed files with 42 additions and 20 deletions

View File

@@ -6736,7 +6736,7 @@ begin
if not FCheckBox then if not FCheckBox then
HeaderGlyphSize := Point(FImages.Width, FImages.Height) HeaderGlyphSize := Point(FImages.Width, FImages.Height)
else else
HeaderGlyphSize := Point(Treeview.CheckImages.Width, Treeview.CheckImages.Height) HeaderGlyphSize := Point(Treeview.CheckImages.Height, Treeview.CheckImages.Height)
else else
HeaderGlyphSize := Point(0, 0); HeaderGlyphSize := Point(0, 0);
if UseSortGlyph then if UseSortGlyph then
@@ -7785,7 +7785,8 @@ var
begin begin
// Convert vertical position to local coordinates. // Convert vertical position to local coordinates.
Inc(P.Y, FHeader.FHeight); //lclheader
//Inc(P.Y, FHeader.FHeight);
NewClickIndex := ColumnFromPosition(P); NewClickIndex := ColumnFromPosition(P);
if (NewClickIndex > NoColumn) and (coAllowClick in Items[NewClickIndex].FOptions) and if (NewClickIndex > NoColumn) and (coAllowClick in Items[NewClickIndex].FOptions) and
((NewClickIndex = FDownIndex) or Force) then ((NewClickIndex = FDownIndex) or Force) then
@@ -8691,7 +8692,7 @@ begin
else else
DropMark := dmmNone; DropMark := dmmNone;
IsEnabled := (coEnabled in FOptions) and (FHeader.Treeview.Enabled); IsEnabled := (coEnabled in FOptions) and (FHeader.Treeview.Enabled);
ShowHeaderGlyph := (hoShowImages in FHeader.FOptions) and Assigned(Images) and (FImageIndex > -1); ShowHeaderGlyph := (hoShowImages in FHeader.FOptions) and ((Assigned(Images) and (FImageIndex > -1)) or FCheckBox);
ShowSortGlyph := (Integer(FPositionToIndex[I]) = FHeader.FSortColumn) and (hoShowSortGlyphs in FHeader.FOptions); ShowSortGlyph := (Integer(FPositionToIndex[I]) = FHeader.FSortColumn) and (hoShowSortGlyphs in FHeader.FOptions);
WrapCaption := coWrapCaption in FOptions; WrapCaption := coWrapCaption in FOptions;
@@ -8782,7 +8783,9 @@ begin
// main glyph // main glyph
FHasImage := False; FHasImage := False;
if not (hpeHeaderGlyph in ActualElements) and ShowHeaderGlyph and if not (hpeHeaderGlyph in ActualElements) and ShowHeaderGlyph and
(not ShowSortGlyph or (FBidiMode <> bdLeftToRight) or (GlyphPos.X + Images.Width <= SortGlyphPos.X) ) then (not ShowSortGlyph or (FBidiMode <> bdLeftToRight) or
(Assigned(Images) and (GlyphPos.X + Images.Width <= SortGlyphPos.X)) or
(FCheckBox and (GlyphPos.X + Header.Treeview.FCheckImages.Height <= SortGlyphPos.X))) then
begin begin
if not FCheckBox then if not FCheckBox then
begin begin
@@ -8814,8 +8817,16 @@ begin
begin begin
Left := GlyphPos.X; Left := GlyphPos.X;
Top := GlyphPos.Y; Top := GlyphPos.Y;
if not FCheckBox then
begin
Right := Left + ColImages.Width; Right := Left + ColImages.Width;
Bottom := Top + ColImages.Height; Bottom := Top + ColImages.Height;
end
else
begin
Right := Left + Header.Treeview.FCheckImages.Height;
Bottom := Top + Header.Treeview.FCheckImages.Height;
end;
end; end;
end; end;
@@ -9852,10 +9863,11 @@ begin
begin begin
//lclheader: NCMessages are given in screen coordinates unlike the ordinary //lclheader: NCMessages are given in screen coordinates unlike the ordinary
with TLMMButtonDown(Message) do with TLMMButtonDown(Message) do
P:= Point(XPos, YPos); P := Point(XPos, YPos);
//P := Treeview.ScreenToClient(Point(XPos, YPos)); //P := Treeview.ScreenToClient(Point(XPos, YPos));
//lclheader
if InHeader(P) then if InHeader(P) then
FOwner.DoHeaderMouseDown(mbMiddle, GetShiftState, P.X, P.Y + Integer(FHeight)); FOwner.DoHeaderMouseDown(mbMiddle, GetShiftState, P.X, P.Y { + Integer(FHeight)});
end; end;
LM_MBUTTONUP: LM_MBUTTONUP:
begin begin
@@ -9865,7 +9877,8 @@ begin
if InHeader(P) then if InHeader(P) then
begin begin
FColumns.HandleClick(P, mbMiddle, True, False); FColumns.HandleClick(P, mbMiddle, True, False);
FOwner.DoHeaderMouseUp(mbMiddle, GetShiftState, P.X, P.Y + Integer(FHeight)); //lclheader
FOwner.DoHeaderMouseUp(mbMiddle, GetShiftState, P.X, P.Y { + Integer(FHeight)});
FColumns.FDownIndex := NoColumn; FColumns.FDownIndex := NoColumn;
end; end;
end; end;
@@ -9968,8 +9981,9 @@ begin
end; end;
// This is a good opportunity to notify the application. // This is a good opportunity to notify the application.
//lclheader
if IsInHeader then if IsInHeader then
FOwner.DoHeaderMouseDown(mbLeft, GetShiftState, P.X, P.Y + Integer(FHeight)); FOwner.DoHeaderMouseDown(mbLeft, GetShiftState, P.X, P.Y { + Integer(FHeight)});
end; end;
LM_RBUTTONDOWN: LM_RBUTTONDOWN:
begin begin
@@ -9977,7 +9991,7 @@ begin
P:=Point(XPos,YPos); P:=Point(XPos,YPos);
//P := FOwner.ScreenToClient(Point(XPos, YPos)); //P := FOwner.ScreenToClient(Point(XPos, YPos));
if InHeader(P) then if InHeader(P) then
FOwner.DoHeaderMouseDown(mbRight, GetShiftState, P.X, P.Y + Integer(FHeight)); FOwner.DoHeaderMouseDown(mbRight, GetShiftState, P.X, P.Y { + Integer(FHeight)});
end; end;
LM_RBUTTONUP: LM_RBUTTONUP:
if not (csDesigning in FOwner.ComponentState) then if not (csDesigning in FOwner.ComponentState) then
@@ -9990,13 +10004,14 @@ begin
if InHeader(P) then if InHeader(P) then
begin begin
FColumns.HandleClick(P, mbRight, True, False); FColumns.HandleClick(P, mbRight, True, False);
FOwner.DoHeaderMouseUp(mbRight, GetShiftState, P.X, P.Y + Integer(FHeight)); FOwner.DoHeaderMouseUp(mbRight, GetShiftState, P.X, P.Y { + Integer(FHeight)});
FColumns.FDownIndex := NoColumn; FColumns.FDownIndex := NoColumn;
FColumns.FTrackIndex := NoColumn; FColumns.FTrackIndex := NoColumn;
Menu := FPopupMenu; Menu := FPopupMenu;
//lclheader
if not Assigned(Menu) then if not Assigned(Menu) then
Menu := DoGetPopupMenu(FColumns.ColumnFromPosition(Point(P.X, P.Y + Integer(FHeight))), P); Menu := DoGetPopupMenu(FColumns.ColumnFromPosition(Point(P.X, P.Y {+ Integer(FHeight)})), P);
// Trigger header popup if there's one. // Trigger header popup if there's one.
if Assigned(Menu) then if Assigned(Menu) then

View File

@@ -8165,7 +8165,8 @@ var
begin begin
// Convert vertical position to local coordinates. // Convert vertical position to local coordinates.
Inc(P.Y, FHeader.FHeight); //lclheader
//Inc(P.Y, FHeader.FHeight);
NewClickIndex := ColumnFromPosition(P); NewClickIndex := ColumnFromPosition(P);
with HitInfo do with HitInfo do
begin begin
@@ -10466,8 +10467,9 @@ begin
with TLMMButtonDown(Message) do with TLMMButtonDown(Message) do
P:= Point(XPos, YPos); P:= Point(XPos, YPos);
//P := Treeview.ScreenToClient(Point(XPos, YPos)); //P := Treeview.ScreenToClient(Point(XPos, YPos));
//lclheader
if InHeader(P) then if InHeader(P) then
FOwner.DoHeaderMouseDown(mbMiddle, GetShiftState, P.X, P.Y + Integer(FHeight)); FOwner.DoHeaderMouseDown(mbMiddle, GetShiftState, P.X, P.Y { + Integer(FHeight)});
end; end;
LM_MBUTTONUP: LM_MBUTTONUP:
begin begin
@@ -10477,7 +10479,8 @@ begin
if InHeader(P) then if InHeader(P) then
begin begin
FColumns.HandleClick(P, mbMiddle, True, False); FColumns.HandleClick(P, mbMiddle, True, False);
FOwner.DoHeaderMouseUp(mbMiddle, GetShiftState, P.X, P.Y + Integer(FHeight)); //lclheader
FOwner.DoHeaderMouseUp(mbMiddle, GetShiftState, P.X, P.Y { + Integer(FHeight)});
FColumns.FDownIndex := NoColumn; FColumns.FDownIndex := NoColumn;
FColumns.FCheckBoxHit := False; FColumns.FCheckBoxHit := False;
end; end;
@@ -10593,16 +10596,18 @@ begin
end; end;
// This is a good opportunity to notify the application. // This is a good opportunity to notify the application.
//lclheader
if not (csDesigning in Treeview.ComponentState) and IsInHeader then if not (csDesigning in Treeview.ComponentState) and IsInHeader then
FOwner.DoHeaderMouseDown(mbLeft, GetShiftState, P.X, P.Y + Integer(FHeight)); FOwner.DoHeaderMouseDown(mbLeft, GetShiftState, P.X, P.Y { + Integer(FHeight)});
end; end;
LM_RBUTTONDOWN: LM_RBUTTONDOWN:
begin begin
with TLMRButtonDown(Message) do with TLMRButtonDown(Message) do
P:=Point(XPos,YPos); P:=Point(XPos,YPos);
//P := FOwner.ScreenToClient(Point(XPos, YPos)); //P := FOwner.ScreenToClient(Point(XPos, YPos));
//lclheader
if InHeader(P) then if InHeader(P) then
FOwner.DoHeaderMouseDown(mbRight, GetShiftState, P.X, P.Y + Integer(FHeight)); FOwner.DoHeaderMouseDown(mbRight, GetShiftState, P.X, P.Y { + Integer(FHeight)});
end; end;
LM_RBUTTONUP: LM_RBUTTONUP:
if not (csDesigning in FOwner.ComponentState) then if not (csDesigning in FOwner.ComponentState) then
@@ -10615,14 +10620,16 @@ begin
if InHeader(P) then if InHeader(P) then
begin begin
FColumns.HandleClick(P, mbRight, True, False); FColumns.HandleClick(P, mbRight, True, False);
FOwner.DoHeaderMouseUp(mbRight, GetShiftState, P.X, P.Y + Integer(FHeight)); //lclheader
FOwner.DoHeaderMouseUp(mbRight, GetShiftState, P.X, P.Y { + Integer(FHeight)});
FColumns.FDownIndex := NoColumn; FColumns.FDownIndex := NoColumn;
FColumns.FTrackIndex := NoColumn; FColumns.FTrackIndex := NoColumn;
FColumns.FCheckBoxHit := False; FColumns.FCheckBoxHit := False;
Menu := FPopupMenu; Menu := FPopupMenu;
//lclheader
if not Assigned(Menu) then if not Assigned(Menu) then
Menu := DoGetPopupMenu(FColumns.ColumnFromPosition(Point(P.X, P.Y + Integer(FHeight))), P); Menu := DoGetPopupMenu(FColumns.ColumnFromPosition(Point(P.X, P.Y { + Integer(FHeight)})), P);
// Trigger header popup if there's one. // Trigger header popup if there's one.
if Assigned(Menu) then if Assigned(Menu) then