mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-22 14:39:13 +02:00
Customdrawn: Implement multiline for TCDPageControl tabs. Merge request !136 by Andrew Haines.
This commit is contained in:
parent
eca20fe8c6
commit
cdf90a24d6
@ -363,13 +363,36 @@ end;
|
|||||||
function TCDDrawerCommon.GetClientArea(ADest: TCanvas; ASize: TSize;
|
function TCDDrawerCommon.GetClientArea(ADest: TCanvas; ASize: TSize;
|
||||||
AControlId: TCDControlID; AState: TCDControlState; AStateEx: TCDControlStateEx
|
AControlId: TCDControlID; AState: TCDControlState; AStateEx: TCDControlStateEx
|
||||||
): TRect;
|
): TRect;
|
||||||
|
var
|
||||||
|
lWidth: Integer = 0;
|
||||||
|
lRows: Integer = 1;
|
||||||
|
lTabCtrlState : TCDCTabControlStateEx;
|
||||||
|
lLastIndex, i, lIndex: Integer;
|
||||||
begin
|
begin
|
||||||
Result := Bounds(0, 0, ASize.cx, ASize.cy);
|
Result := Bounds(0, 0, ASize.cx, ASize.cy);
|
||||||
|
|
||||||
case AControlId of
|
case AControlId of
|
||||||
cidCTabControl:
|
cidCTabControl:
|
||||||
begin
|
begin
|
||||||
Result.Top := GetMeasuresEx(ADest, TCDCTABCONTROL_TAB_HEIGHT, AState, AStateEx) + 2;
|
lTabCtrlState := TCDCTabControlStateEx(AStateEx);
|
||||||
|
lLastIndex := lTabCtrlState.TabCount - Ord(not(nboShowAddTabButton in lTabCtrlState.Options));
|
||||||
|
if nboMultiLine in lTabCtrlState.Options then
|
||||||
|
begin
|
||||||
|
lIndex := lTabCtrlState.CurTabIndex;
|
||||||
|
for i := 0 to lLastIndex do
|
||||||
|
begin
|
||||||
|
lTabCtrlState.TabIndex:=i;
|
||||||
|
lWidth := lWidth + GetMeasuresEx(ADest, TCDCTABCONTROL_TAB_WIDTH, AState, AStateEx);
|
||||||
|
if lWidth > ASize.Width then
|
||||||
|
begin
|
||||||
|
lWidth:=0;
|
||||||
|
Inc(lRows);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
lTabCtrlState.TabIndex:=lIndex;
|
||||||
|
end;
|
||||||
|
|
||||||
|
Result.Top := GetMeasuresEx(ADest, TCDCTABCONTROL_TAB_HEIGHT, AState, AStateEx)*lRows + 2;
|
||||||
Result.Left := 2;
|
Result.Left := 2;
|
||||||
Result.Right := Result.Right - 2;
|
Result.Right := Result.Right - 2;
|
||||||
Result.Bottom := Result.Bottom - 2;
|
Result.Bottom := Result.Bottom - 2;
|
||||||
@ -1765,10 +1788,28 @@ procedure TCDDrawerCommon.DrawCTabControlFrame(ADest: TCanvas;
|
|||||||
ADestPos: TPoint; ASize: TSize; AState: TCDControlState;
|
ADestPos: TPoint; ASize: TSize; AState: TCDControlState;
|
||||||
AStateEx: TCDCTabControlStateEx);
|
AStateEx: TCDCTabControlStateEx);
|
||||||
var
|
var
|
||||||
CaptionHeight: Integer;
|
CaptionHeight, lIndex, i: Integer;
|
||||||
|
lWidth: Integer = 0;
|
||||||
|
lRows: Integer = 1;
|
||||||
begin
|
begin
|
||||||
if AStateEx.TabCount = 0 then CaptionHeight := 0
|
if AStateEx.TabCount = 0 then CaptionHeight := 0
|
||||||
else CaptionHeight := GetMeasuresEx(ADest, TCDCTABCONTROL_TAB_HEIGHT, AState, AStateEx);
|
else if not (nboMultiLine in AStateEx.Options) then
|
||||||
|
CaptionHeight := GetMeasuresEx(ADest, TCDCTABCONTROL_TAB_HEIGHT, AState, AStateEx)
|
||||||
|
else begin
|
||||||
|
lIndex := AStateEx.TabIndex;
|
||||||
|
for i := 0 to AStateEx.TabCount - ord(not(nboShowAddTabButton in AStateEx.Options)) do
|
||||||
|
begin
|
||||||
|
lWidth := lWidth + GetMeasuresEx(ADest, TCDCTABCONTROL_TAB_WIDTH, AState, AStateEx);
|
||||||
|
if lWidth > ASize.Width then
|
||||||
|
begin
|
||||||
|
lWidth := 0;
|
||||||
|
Inc(lRows);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
AStateEx.TabIndex := lIndex;
|
||||||
|
CaptionHeight := GetMeasuresEx(ADest, TCDCTABCONTROL_TAB_HEIGHT, AState, AStateEx) * lRows;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
DrawRaisedFrame(ADest, Point(0, CaptionHeight), Size(ASize.cx, ASize.cy-CaptionHeight));
|
DrawRaisedFrame(ADest, Point(0, CaptionHeight), Size(ASize.cx, ASize.cy-CaptionHeight));
|
||||||
end;
|
end;
|
||||||
@ -1787,22 +1828,31 @@ procedure TCDDrawerCommon.DrawTabs(ADest: TCanvas; ADestPos: TPoint;
|
|||||||
ASize: TSize; AState: TCDControlState; AStateEx: TCDCTabControlStateEx);
|
ASize: TSize; AState: TCDControlState; AStateEx: TCDCTabControlStateEx);
|
||||||
var
|
var
|
||||||
IsPainting: Boolean = False;
|
IsPainting: Boolean = False;
|
||||||
lLastTabIndex, i: Integer;
|
lLastTabIndex, i, lWidth: Integer;
|
||||||
begin
|
begin
|
||||||
AStateEx.CurStartLeftPos := 0;
|
AStateEx.CurStartLeftPos := 0;
|
||||||
|
AStateEx.CurStartTopPos := 0;
|
||||||
if nboShowAddTabButton in AStateEx.Options then lLastTabIndex := AStateEx.Tabs.Count
|
if nboShowAddTabButton in AStateEx.Options then lLastTabIndex := AStateEx.Tabs.Count
|
||||||
else lLastTabIndex := AStateEx.Tabs.Count - 1;
|
else lLastTabIndex := AStateEx.Tabs.Count - 1;
|
||||||
|
|
||||||
for i := 0 to lLastTabIndex do
|
for i := 0 to lLastTabIndex do
|
||||||
begin
|
begin
|
||||||
if i = AStateEx.LeftmostTabVisibleIndex then
|
if (i = AStateEx.LeftmostTabVisibleIndex) or (nboMultiLine in AStateEx.Options) then
|
||||||
IsPainting := True;
|
IsPainting := True;
|
||||||
|
|
||||||
if IsPainting then
|
if IsPainting then
|
||||||
begin
|
begin
|
||||||
AStateEx.CurTabIndex := i;
|
AStateEx.CurTabIndex := i;
|
||||||
|
lWidth := GetMeasuresEx(ADest, TCDCTABCONTROL_TAB_WIDTH, AState, AStateEx);
|
||||||
|
|
||||||
|
if (nboMultiLine in AStateEx.Options) and (AStateEx.CurStartLeftPos+lWidth > ADest.Width) then
|
||||||
|
begin
|
||||||
|
AStateEx.CurStartLeftPos := 0;
|
||||||
|
AStateEx.CurStartTopPos:=AStateEx.CurStartTopPos+GetMeasuresEx(ADest, TCDCTABCONTROL_TAB_HEIGHT, AState, AStateEx) ;
|
||||||
|
end;
|
||||||
|
|
||||||
DrawTab(ADest, ADestPos, ASize, AState, AStateEx);
|
DrawTab(ADest, ADestPos, ASize, AState, AStateEx);
|
||||||
AStateEx.CurStartLeftPos := AStateEx.CurStartLeftPos + GetMeasuresEx(ADest, TCDCTABCONTROL_TAB_WIDTH, AState, AStateEx);
|
AStateEx.CurStartLeftPos := AStateEx.CurStartLeftPos + lWidth;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -1824,7 +1874,7 @@ begin
|
|||||||
if not IsSelected then lTabHeightCorrection := 3;
|
if not IsSelected then lTabHeightCorrection := 3;
|
||||||
if IsSelected then lTabRightBorderExtraHeight := 1;
|
if IsSelected then lTabRightBorderExtraHeight := 1;
|
||||||
|
|
||||||
lTabTopPos := lTabHeightCorrection;
|
lTabTopPos := lTabHeightCorrection+AStateEx.CurStartTopPos;
|
||||||
lTabHeight := GetMeasuresEx(ADest, TCDCTABCONTROL_TAB_HEIGHT, AState, AStateEx)-lTabHeightCorrection;
|
lTabHeight := GetMeasuresEx(ADest, TCDCTABCONTROL_TAB_HEIGHT, AState, AStateEx)-lTabHeightCorrection;
|
||||||
lTabWidth := GetMeasuresEx(ADest, TCDCTABCONTROL_TAB_WIDTH, AState, AStateEx);
|
lTabWidth := GetMeasuresEx(ADest, TCDCTABCONTROL_TAB_WIDTH, AState, AStateEx);
|
||||||
|
|
||||||
|
@ -3270,6 +3270,7 @@ function TCDCustomTabControl.MousePosToTabIndex(X, Y: Integer): Integer;
|
|||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
CurStartLeftPos: Integer = 0;
|
CurStartLeftPos: Integer = 0;
|
||||||
|
CurStartTopPos: Integer = 0;
|
||||||
VisiblePagesStarted: Boolean = False;
|
VisiblePagesStarted: Boolean = False;
|
||||||
lLastTab, lTabWidth, lTabHeight: Integer;
|
lLastTab, lTabWidth, lTabHeight: Integer;
|
||||||
begin
|
begin
|
||||||
@ -3280,7 +3281,7 @@ begin
|
|||||||
|
|
||||||
for i := 0 to lLastTab do
|
for i := 0 to lLastTab do
|
||||||
begin
|
begin
|
||||||
if i = FTabCState.LeftmostTabVisibleIndex then
|
if (i = FTabCState.LeftmostTabVisibleIndex) or (nboMultiLine in Options) then
|
||||||
VisiblePagesStarted := True;
|
VisiblePagesStarted := True;
|
||||||
|
|
||||||
if VisiblePagesStarted then
|
if VisiblePagesStarted then
|
||||||
@ -3288,9 +3289,17 @@ begin
|
|||||||
FTabCState.CurTabIndex := i;
|
FTabCState.CurTabIndex := i;
|
||||||
lTabWidth := FDrawer.GetMeasuresEx(Canvas, TCDCTABCONTROL_TAB_WIDTH, FState, FTabCState);
|
lTabWidth := FDrawer.GetMeasuresEx(Canvas, TCDCTABCONTROL_TAB_WIDTH, FState, FTabCState);
|
||||||
lTabHeight := FDrawer.GetMeasuresEx(Canvas, TCDCTABCONTROL_TAB_HEIGHT, FState, FTabCState);
|
lTabHeight := FDrawer.GetMeasuresEx(Canvas, TCDCTABCONTROL_TAB_HEIGHT, FState, FTabCState);
|
||||||
|
if (nboMultiLine in Options) and (lTabWidth+CurStartLeftPos > Width) then
|
||||||
|
begin
|
||||||
|
Inc(CurStartTopPos, lTabHeight);
|
||||||
|
CurStartLeftPos := 0;
|
||||||
|
end;
|
||||||
|
|
||||||
if (X > CurStartLeftPos) and
|
if (X > CurStartLeftPos) and
|
||||||
(X < CurStartLeftPos + lTabWidth) and
|
(X < CurStartLeftPos + lTabWidth) and
|
||||||
(Y < lTabHeight) then
|
(Y < lTabHeight+CurStartTopPos) and
|
||||||
|
(Y >= CurStartTopPos)
|
||||||
|
then
|
||||||
begin
|
begin
|
||||||
Exit(i);
|
Exit(i);
|
||||||
end;
|
end;
|
||||||
|
@ -257,6 +257,7 @@ type
|
|||||||
// Used internally by the drawers
|
// Used internally by the drawers
|
||||||
CurTabIndex: Integer;// For Tab routines, obtain the index
|
CurTabIndex: Integer;// For Tab routines, obtain the index
|
||||||
CurStartLeftPos: Integer;
|
CurStartLeftPos: Integer;
|
||||||
|
CurStartTopPos: Integer;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TCDSpinStateEx = class(TCDPositionedCStateEx)
|
TCDSpinStateEx = class(TCDPositionedCStateEx)
|
||||||
|
Loading…
Reference in New Issue
Block a user