35 :
Window(), icoTitle(icoTitle), cHotkey(0), dwCaptionClr(0u), fHasCloseButton(fHasCloseButton), fCloseButtonHighlighted(false), fTitleMarkup(fTitleMarkup)
50 int32_t iTxtHgt, iTxtWdt;
51 GetCaptionSize(&iTxtWdt, &iTxtHgt, fLarge, fActive, pfctClip, pfctIcon, pUseFont);
52 if (pfctClip) iMaxWdt = iTxtWdt;
54 if (pfctClip && pfctIcon)
59 int32_t xCenter = x + iTxtWdt/2, yCenter = y + iTxtHgt/2;
60 int32_t iLabelHgt = rUseFont.
GetLineHeight(); int32_t iIconLabelSpacing = 2;
61 int32_t yTop = yCenter - (pfctIcon->
Hgt+iIconLabelSpacing+iLabelHgt)/2;
62 pfctIcon->
Draw(cgo.
Surface, xCenter-pfctIcon->
Wdt/2, yTop, icoTitle);
72 if (!(pfctClip && pfctIcon))
89 cgoIcon.
X -= iTxtWdt / 2;
95 if (!fLarge && fHasCloseButton) x -= iTxtHgt/2;
96 uint32_t dwClr = dwCaptionClr;
102 xo += iTxtWdt / (2 - fLarge) - iTxtHgt + 1;
114 if (pfctClip && pfctIcon)
117 if (piHgt) *piHgt = pfctClip->
Hgt;
123 if (!rUseFont.
GetTextExtent(sTitle.getData(), iWdt, iHgt, fTitleMarkup))
127 if (fLarge) { iWdt = iWdt * 6 / 5; iHgt = iHgt * 6 / 5; }
129 if (icoTitle>=0) iWdt += iHgt + fLarge*2;
131 if (fHasCloseButton) iWdt += iHgt + fLarge*2;
133 if (piWdt) *piWdt = iWdt;
134 if (piHgt) *piHgt = iHgt;
140 return fHasCloseButton && Inside<int32_t>(x, iCaptWdt-iCaptHgt+1, iCaptWdt-2) && Inside<int32_t>(y, 1, iCaptHgt-2);
145 if (sTitle == szNewTitle)
return;
148 sTitle.Copy(szNewTitle);
157 if (pTabular) pTabular->SheetsChanged();
171 iCaptionLengthTotal(0), iCaptionScrollPos(0), fScrollingLeft(false), fScrollingRight(false), fScrollingLeftDown(false),
172 fScrollingRightDown(false), iSheetMargin(4), fDrawSelf(true), pfctBack(nullptr), pfctClip(nullptr), pfctIcons(nullptr), pSheetCaptionFont(nullptr)
182 Keys.emplace_back(K_UP);
191 Keys.emplace_back(K_DOWN);
208 pKeySelUp = pKeySelDown = pKeySelUp2 = pKeySelDown2 = pKeyCloseTab =
nullptr;
215 if (pKeyCloseTab)
delete pKeyCloseTab;
216 if (pKeySelDown2)
delete pKeySelDown2;
217 if (pKeySelUp2)
delete pKeySelUp2;
218 if (pKeySelDown)
delete pKeySelDown;
219 if (pKeySelUp)
delete pKeySelUp;
227 if (iNewSel < 0)
return false;
236 if (iNewSel >= iSheetCount)
238 if (!iSheetCount)
return false;
250 if (!pCurrentSheet)
return false;
256 void Tabular::SelectionChanged(
bool fByUser)
260 if (pDlg) pFocusCtrl = pDlg->
GetFocus();
265 if (fByUser)
GUISound(
"UI::Select");
267 pActiveSheet->
OnShown(fByUser);
272 pSheet->SetVisibility(pSheet == pActiveSheet);
278 void Tabular::SheetsChanged()
286 iSheetSpacing = (eTabPos ==
tbLeft) ? -10 : 20;
287 int32_t iSheetNum=0, iTotalHgt=iSheetOff;
288 iCaptionLengthTotal = iSheetOff;
291 int32_t iTabWidth, iTabHeight;
292 pSheet->GetCaptionSize(&iTabWidth, &iTabHeight,
HasLargeCaptions(), pSheet == pActiveSheet, pfctClip, pfctIcons, pSheetCaptionFont);
293 iTabWidth += (eTabPos ==
tbLeft) ? 20 : iSheetSpacing;
294 iMaxTabWidth = std::max(iTabWidth, iMaxTabWidth);
297 iTotalHgt += iTabHeight;
298 if (iSheetNum++) iTotalHgt += iSheetSpacing;
302 iCaptionLengthTotal += iTabWidth;
312 else if (eTabPos ==
tbTop)
322 void Tabular::UpdateScrolling()
327 if (eTabPos !=
tbTop || iCaptionLengthTotal <= iAvailableTabSpace || iAvailableTabSpace <= iScrollPinSize*2)
329 fScrollingLeft = fScrollingRight = fScrollingLeftDown = fScrollingRightDown =
false;
330 iCaptionScrollPos = 0;
335 fScrollingLeft = !!iCaptionScrollPos;
338 fScrollingRight =
true;
339 fScrollingLeftDown =
false;
343 iAvailableTabSpace -= iScrollPinSize;
344 fScrollingRight = (iCaptionLengthTotal - iCaptionScrollPos > iAvailableTabSpace);
346 if (!fScrollingRight)
348 iCaptionScrollPos = iCaptionLengthTotal - iAvailableTabSpace;
349 fScrollingRightDown =
false;
355 void Tabular::DoCaptionScroll(int32_t iDir)
362 iCaptionScrollPos = Clamp<int32_t>(iCaptionScrollPos + iDir*iAvailableTabSpace/2, 0, iCaptionLengthTotal - iAvailableTabSpace + iScrollPinSize);
368 if (!fDrawSelf)
return;
369 bool fGfx = HasGfx();
372 if ((fScrollingLeftDown || fScrollingRightDown) && fCaptionScrollDelayOver)
373 DoCaptionScroll(fScrollingRightDown - fScrollingLeftDown);
390 bool fLeft = (eTabPos ==
tbLeft);
392 int32_t d=(fLeft ? y0 : x0)+iSheetOff;
393 int32_t ad0=0,ad1=0, aCptTxX=0, aCptTxY=0;
396 if (fScrollingLeft) d -= iCaptionScrollPos + iScrollSize;
401 int32_t iTabWidth, iTabHeight;
402 pSheet->GetCaptionSize(&iTabWidth, &iTabHeight,
HasLargeCaptions(), pSheet == pActiveSheet, pfctClip, pfctIcons, pSheetCaptionFont);
404 iTabWidth += fLeft ? 20 : iSheetSpacing;
405 iTabHeight += fLeft ? iSheetSpacing : 10;
412 vtx[0] = x0; vtx[1] = d;
415 vtx[6] = x0; vtx[7] = d+iTabHeight;
419 vtx[0] = d+1; vtx[1] = y0;
421 vtx[4] = d+iTabWidth-4; vtx[5] = y0-
GetTopSize();
422 vtx[6] = d+iTabWidth; vtx[7] = y0;
436 int32_t iCptTextX = fLeft ? (x0-
GetLeftSize()+10) : (d+iTabWidth/2);
437 int32_t iCptTextY = fLeft ? (d+iSheetSpacing/2) : (y0-
GetTopSize()+2);
438 if (pSheet == pActiveSheet)
441 ad0=d; ad1=d+(fLeft ? iTabHeight : iTabWidth);
442 aCptTxX = iCptTextX; aCptTxY = iCptTextY;
444 if (!fGfx) pSheet->DrawCaption(cgo, iCptTextX, iCptTextY, iMaxTabWidth, fLeft,
true,
HasDrawFocus(),
nullptr,
nullptr,
nullptr);
449 pSheet->DrawCaption(cgo, iCptTextX, iCptTextY, iMaxTabWidth, fLeft,
false,
false, pfctClip, pfctIcons, pSheetCaptionFont);
452 d += (fLeft ? iTabHeight : iTabWidth)+2;
455 if (!fGfx)
if (ad0||ad1)
468 pActiveSheet->
DrawCaption(cgo, aCptTxX, aCptTxY, iMaxTabWidth, fLeft,
true,
HasDrawFocus(), pfctClip, pfctIcons, pSheetCaptionFont);
480 bool fLeft = (eTabPos ==
tbLeft);
481 bool fInCaptionArea = ((!fLeft && Inside<int32_t>(iY, 0,
GetTopSize())) || (fLeft && Inside<int32_t>(iX, 0,
GetLeftSize())));
491 bool fProcessed =
false;
492 if (fScrollingLeft || fScrollingRight)
497 fProcessed = fScrollingRightDown =
true;
501 else if (fScrollingLeft)
505 fProcessed = fScrollingLeftDown =
true;
509 d -= iCaptionScrollPos + iScrollSize;
516 pSheet->SetCloseButtonHighlight(
false);
518 int32_t iCaptWidth,iCaptHeight,iTabWidth,iTabHeight;
519 pSheet->GetCaptionSize(&iCaptWidth, &iCaptHeight,
HasLargeCaptions(), pSheet == pActiveSheet, pfctClip, pfctIcons, pSheetCaptionFont);
520 iTabWidth = iCaptWidth + (fLeft ? 20 : iSheetSpacing);
521 iTabHeight = iCaptHeight + (fLeft ? iSheetSpacing : 10);
523 if ((!fLeft &&
Inside(iX, d, d+iTabWidth)) || (fLeft &&
Inside(iY, d, d+iTabHeight)))
526 if (pSheet->IsPosOnCloseButton(iX-d*!fLeft-(iTabWidth-iCaptWidth)/2, iY-d*fLeft, iCaptWidth, iCaptHeight,
HasLargeCaptions()))
535 pSheet->SetCloseButtonHighlight(
true);
540 if (pSheet != pActiveSheet)
542 pActiveSheet = pSheet;
543 SelectionChanged(
true);
549 d += (fLeft ? iTabHeight : iTabWidth)+2;
563 pSheet->SetCloseButtonHighlight(
false);
565 if (fScrollingLeftDown || fScrollingRightDown)
569 fScrollingLeftDown = fScrollingRightDown =
false;
591 if (pChild == pActiveSheet)
595 SelectionChanged(
false);
615 if (!pActiveSheet) pActiveSheet = pAddSheet;
624 while ((pSheet =
GetSheet(0)))
delete pSheet;
631 SelectionChanged(fByUser);
636 pActiveSheet = pSelSheet;
637 SelectionChanged(fByUser);
644 while ((pSheet =
GetSheet(++i)))
if (pSheet == pActiveSheet)
return i;
653 pfctIcons=pafctIcons;
654 pSheetCaptionFont=paSheetCaptionFont;
656 if (pfctBack && fResizeByAspect)
659 if (iEffWdt * pfctBack->
Hgt > pfctBack->
Wdt * iEffHgt)
662 int32_t iOversize = iEffWdt - pfctBack->
Wdt * iEffHgt / pfctBack->
Hgt;
664 rtBounds.
x += iOversize/2;
665 rtBounds.
Wdt -= iOversize;
671 int32_t iOversize = iEffHgt - pfctBack->
Hgt * iEffWdt / pfctBack->
Wdt;
673 rtBounds.
y += iOversize;
674 rtBounds.
Hgt -= iOversize;
685 for (
Sheet *pSheet =
static_cast<Sheet *
>(
GetFirst()); pSheet; pSheet =
static_cast<Sheet *
>(pSheet->GetNext()))
C4GraphicsResource GraphicsResource
#define C4GUI_GfxTabCaptInactiveClr
#define C4GUI_StandardBGColor
#define C4GUI_GfxTabCaptActiveClr
#define C4GUI_TabCaptionScrollTime
#define C4GUI_InactCaptionFontClr
#define C4GUI_BorderColorA1
#define C4GUI_ActiveTabBGColor
#define C4GUI_CaptionFontClr
#define C4GUI_BorderColorA2
const int32_t C4MC_Button_None
const int32_t C4MC_Button_LeftUp
const int32_t C4MC_Button_LeftDown
#define C4GFXBLIT_ADDITIVE
bool Inside(T ival, U lbound, V rbound)
int32_t GamepadGuiControl
C4ConfigControls Controls
std::vector< C4KeyCodeEx > CodeList
void DrawQuadDw(C4Surface *sfcTarget, float *ipVtx, DWORD dwClr1, DWORD dwClr2, DWORD dwClr3, DWORD dwClr4, C4ShaderCall *shader_call)
void SetBlitMode(DWORD dwBlitMode)
void DeactivateBlitModulation()
void DrawBoxDw(C4Surface *sfcDest, int iX1, int iY1, int iX2, int iY2, DWORD dwClr)
void DrawLineDw(C4Surface *sfcTarget, float x1, float y1, float x2, float y2, DWORD dwClr, float width=1.0f)
void ActivateBlitModulation(DWORD dwWithClr)
bool TextOut(const char *szText, CStdFont &rFont, float fZoom, C4Surface *sfcDest, float iTx, float iTy, DWORD dwFCol=0xffffffff, BYTE byForm=ALeft, bool fDoMarkup=true)
void Draw(C4Facet &cgo, bool fAspect=true, int32_t iPhaseX=0, int32_t iPhaseY=0, bool fTransparent=true)
void DrawX(C4Surface *sfcTarget, float iX, float iY, float iWdt, float iHgt, int32_t iPhaseX=0, int32_t iPhaseY=0) const
void AddElement(Element *pChild)
void RemoveElement(Element *pChild) override
void SetVisibility(bool fToValue) override
virtual void OnGetFocus(bool fByMouse)
void MouseInput(CMouse &rMouse, int32_t iButton, int32_t iX, int32_t iY, DWORD dwKeyParam) override
void SetFocus(Control *pCtrl, bool fByMouse)
virtual class Control * GetDefaultControl()
Element * GetNext() const
C4Rect GetContainedClientRect()
virtual void UpdateSize()
void SetBounds(const C4Rect &rcNewBound)
virtual class Dialog * GetDlg()
virtual void MouseLeave(CMouse &rMouse)
void Draw3DFrame(C4TargetFacet &cgo, bool fUp=false, int32_t iIndent=1, BYTE byAlpha=C4GUI_BorderAlpha, bool fDrawTop=true, int32_t iTopOff=0, bool fDrawLeft=true, int32_t iLeftOff=0)
static C4Facet GetIconFacet(Icons icoIconIndex)
bool HasCloseButton() const
void SetTitle(const char *szNewTitle)
bool IsPosOnCloseButton(int32_t x, int32_t y, int32_t iCaptWdt, int32_t iCaptHgt, bool fLarge)
virtual void OnShown(bool fByUser)
Sheet(const char *szTitle, const C4Rect &rcBounds, int32_t icoTitle=Ico_None, bool fHasCloseButton=false, bool fTitleMarkup=true)
void DrawCaption(C4TargetFacet &cgo, int32_t x, int32_t y, int32_t iMaxWdt, bool fLarge, bool fActive, bool fFocus, C4Facet *pfctClip, C4Facet *pfctIcon, CStdFont *pUseFont)
void GetCaptionSize(int32_t *piWdt, int32_t *piHgt, bool fLarge, bool fActive, C4Facet *pfctClip, C4Facet *pfctIcon, CStdFont *pUseFont)
void DrawElement(C4TargetFacet &cgo) override
Tabular(C4Rect &rtBounds, TabPosition eTabPos)
void MouseInput(CMouse &rMouse, int32_t iButton, int32_t iX, int32_t iY, DWORD dwKeyParam) override
Sheet * AddSheet(const char *szTitle, int32_t icoTitle=Ico_None)
void SelectSheet(int32_t iIndex, bool fByUser)
int32_t GetActiveSheetIndex()
void OnGetFocus(bool fByMouse) override
Sheet * GetSheet(int32_t iIndex)
void MouseLeaveCaptionArea()
void RemoveElement(Element *pChild) override
static int32_t GetLeftClipSize(C4Facet *pfctForClip)
void UpdateSize() override
void AddCustomSheet(Sheet *pAddSheet)
int32_t GetMarginBottom() override
void MouseLeave(CMouse &rMouse) override
void SetGfx(C4Facet *pafctBack, C4Facet *pafctClip, C4Facet *pafctIcons, CStdFont *paSheetCaptionFont, bool fResizeByAspect)
void UpdateOwnPos() override
C4FacetID fctButtonHighlightRound
static C4TimeMilliseconds Now()
int GetLineHeight() const
bool GetTextExtent(const char *szText, int32_t &rsx, int32_t &rsy, bool fCheckMarkup=true)
bool ExpandHotkeyMarkup(StdStrBuf &sText, uint32_t &rcHotkey, bool for_tooltip)
void GUISound(const char *szSound)