diff --git a/lcl/customdrawn_common.pas b/lcl/customdrawn_common.pas index 7ddb8e921c..02a401c699 100644 --- a/lcl/customdrawn_common.pas +++ b/lcl/customdrawn_common.pas @@ -363,13 +363,36 @@ end; function TCDDrawerCommon.GetClientArea(ADest: TCanvas; ASize: TSize; AControlId: TCDControlID; AState: TCDControlState; AStateEx: TCDControlStateEx ): TRect; +var + lWidth: Integer = 0; + lRows: Integer = 1; + lTabCtrlState : TCDCTabControlStateEx; + lLastIndex, i, lIndex: Integer; begin Result := Bounds(0, 0, ASize.cx, ASize.cy); case AControlId of cidCTabControl: 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.Right := Result.Right - 2; Result.Bottom := Result.Bottom - 2; @@ -1765,10 +1788,28 @@ procedure TCDDrawerCommon.DrawCTabControlFrame(ADest: TCanvas; ADestPos: TPoint; ASize: TSize; AState: TCDControlState; AStateEx: TCDCTabControlStateEx); var - CaptionHeight: Integer; + CaptionHeight, lIndex, i: Integer; + lWidth: Integer = 0; + lRows: Integer = 1; begin 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)); end; @@ -1787,22 +1828,31 @@ procedure TCDDrawerCommon.DrawTabs(ADest: TCanvas; ADestPos: TPoint; ASize: TSize; AState: TCDControlState; AStateEx: TCDCTabControlStateEx); var IsPainting: Boolean = False; - lLastTabIndex, i: Integer; + lLastTabIndex, i, lWidth: Integer; begin AStateEx.CurStartLeftPos := 0; + AStateEx.CurStartTopPos := 0; if nboShowAddTabButton in AStateEx.Options then lLastTabIndex := AStateEx.Tabs.Count else lLastTabIndex := AStateEx.Tabs.Count - 1; for i := 0 to lLastTabIndex do begin - if i = AStateEx.LeftmostTabVisibleIndex then + if (i = AStateEx.LeftmostTabVisibleIndex) or (nboMultiLine in AStateEx.Options) then IsPainting := True; if IsPainting then begin 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); - AStateEx.CurStartLeftPos := AStateEx.CurStartLeftPos + GetMeasuresEx(ADest, TCDCTABCONTROL_TAB_WIDTH, AState, AStateEx); + AStateEx.CurStartLeftPos := AStateEx.CurStartLeftPos + lWidth; end; end; end; @@ -1824,7 +1874,7 @@ begin if not IsSelected then lTabHeightCorrection := 3; if IsSelected then lTabRightBorderExtraHeight := 1; - lTabTopPos := lTabHeightCorrection; + lTabTopPos := lTabHeightCorrection+AStateEx.CurStartTopPos; lTabHeight := GetMeasuresEx(ADest, TCDCTABCONTROL_TAB_HEIGHT, AState, AStateEx)-lTabHeightCorrection; lTabWidth := GetMeasuresEx(ADest, TCDCTABCONTROL_TAB_WIDTH, AState, AStateEx); diff --git a/lcl/customdrawncontrols.pas b/lcl/customdrawncontrols.pas index 8aa51b27a9..d9b6bb2035 100644 --- a/lcl/customdrawncontrols.pas +++ b/lcl/customdrawncontrols.pas @@ -3270,6 +3270,7 @@ function TCDCustomTabControl.MousePosToTabIndex(X, Y: Integer): Integer; var i: Integer; CurStartLeftPos: Integer = 0; + CurStartTopPos: Integer = 0; VisiblePagesStarted: Boolean = False; lLastTab, lTabWidth, lTabHeight: Integer; begin @@ -3280,7 +3281,7 @@ begin for i := 0 to lLastTab do begin - if i = FTabCState.LeftmostTabVisibleIndex then + if (i = FTabCState.LeftmostTabVisibleIndex) or (nboMultiLine in Options) then VisiblePagesStarted := True; if VisiblePagesStarted then @@ -3288,9 +3289,17 @@ begin FTabCState.CurTabIndex := i; lTabWidth := FDrawer.GetMeasuresEx(Canvas, TCDCTABCONTROL_TAB_WIDTH, 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 (X < CurStartLeftPos + lTabWidth) and - (Y < lTabHeight) then + (Y < lTabHeight+CurStartTopPos) and + (Y >= CurStartTopPos) + then begin Exit(i); end; diff --git a/lcl/customdrawndrawers.pas b/lcl/customdrawndrawers.pas index 59e8c7d03e..a1e948ddb9 100644 --- a/lcl/customdrawndrawers.pas +++ b/lcl/customdrawndrawers.pas @@ -257,6 +257,7 @@ type // Used internally by the drawers CurTabIndex: Integer;// For Tab routines, obtain the index CurStartLeftPos: Integer; + CurStartTopPos: Integer; end; TCDSpinStateEx = class(TCDPositionedCStateEx)