Improve multi-line mode for tab interface
This commit is contained in:
parent
82dd554c49
commit
e1125f0bbc
@ -66,7 +66,7 @@ void TabBar::init(HINSTANCE hInst, HWND parent, bool isVertical, bool isTraditio
|
|||||||
icce.dwSize = sizeof(icce);
|
icce.dwSize = sizeof(icce);
|
||||||
icce.dwICC = ICC_TAB_CLASSES;
|
icce.dwICC = ICC_TAB_CLASSES;
|
||||||
InitCommonControlsEx(&icce);
|
InitCommonControlsEx(&icce);
|
||||||
int multiLine = isMultiLine ? (_isTraditional ? TCS_MULTILINE | TCS_BUTTONS : 0) : 0;
|
int multiLine = isMultiLine ? (_isTraditional ? TCS_MULTILINE : 0) : 0;
|
||||||
|
|
||||||
int style = WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VISIBLE |\
|
int style = WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VISIBLE |\
|
||||||
TCS_FOCUSNEVER | TCS_TABS | WS_TABSTOP | vertical | multiLine;
|
TCS_FOCUSNEVER | TCS_TABS | WS_TABSTOP | vertical | multiLine;
|
||||||
@ -221,20 +221,47 @@ void TabBar::reSizeTo(RECT & rc2Ajust)
|
|||||||
}
|
}
|
||||||
else if (_isVertical)
|
else if (_isVertical)
|
||||||
{
|
{
|
||||||
tabsHight = rowCount * (rowRect.right - rowRect.left);
|
LONG_PTR style = ::GetWindowLongPtr(_hSelf, GWL_STYLE);
|
||||||
|
if (rowCount == 1)
|
||||||
|
{
|
||||||
|
style &= ~TCS_BUTTONS;
|
||||||
|
}
|
||||||
|
else // (rowCount >= 2)
|
||||||
|
{
|
||||||
|
style |= TCS_BUTTONS;
|
||||||
|
}
|
||||||
|
::SetWindowLongPtr(_hSelf, GWL_STYLE, style);
|
||||||
|
|
||||||
|
const int marge = 3; // in TCS_BUTTONS mode, each row has few pixels higher
|
||||||
|
tabsHight = rowCount * (rowRect.right - rowRect.left + marge);
|
||||||
tabsHight += GetSystemMetrics(SM_CXEDGE);
|
tabsHight += GetSystemMetrics(SM_CXEDGE);
|
||||||
|
|
||||||
rc2Ajust.left += tabsHight;
|
rc2Ajust.left += tabsHight;
|
||||||
rc2Ajust.right -= tabsHight;
|
rc2Ajust.right -= tabsHight;
|
||||||
}
|
}
|
||||||
else
|
else //if (_isMultiLine)
|
||||||
{
|
{
|
||||||
const int marge = 3; // in TCS_BUTTONS mode, each row has few pixels higher
|
if (rowCount == 1)
|
||||||
tabsHight = rowCount * (rowRect.bottom - rowRect.top + marge);
|
{
|
||||||
tabsHight += GetSystemMetrics(SM_CYEDGE);
|
LONG_PTR style = ::GetWindowLongPtr(_hSelf, GWL_STYLE);
|
||||||
|
style &= ~TCS_BUTTONS;
|
||||||
|
::SetWindowLongPtr(_hSelf, GWL_STYLE, style);
|
||||||
|
|
||||||
rc2Ajust.top += tabsHight;
|
TabCtrl_AdjustRect(_hSelf, FALSE, &rc2Ajust);
|
||||||
rc2Ajust.bottom -= tabsHight;
|
}
|
||||||
|
else // (rowCount >= 2)
|
||||||
|
{
|
||||||
|
LONG_PTR style = ::GetWindowLongPtr(_hSelf, GWL_STYLE);
|
||||||
|
style |= TCS_BUTTONS;
|
||||||
|
::SetWindowLongPtr(_hSelf, GWL_STYLE, style);
|
||||||
|
|
||||||
|
const int marge = 3; // in TCS_BUTTONS mode, each row has few pixels higher
|
||||||
|
tabsHight = rowCount * (rowRect.bottom - rowRect.top + marge);
|
||||||
|
tabsHight += GetSystemMetrics(SM_CYEDGE);
|
||||||
|
|
||||||
|
rc2Ajust.top += tabsHight;
|
||||||
|
rc2Ajust.bottom -= tabsHight;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -259,10 +286,9 @@ void TabBarPlus::init(HINSTANCE hInst, HWND parent, bool isVertical, bool isTrad
|
|||||||
icce.dwSize = sizeof(icce);
|
icce.dwSize = sizeof(icce);
|
||||||
icce.dwICC = ICC_TAB_CLASSES;
|
icce.dwICC = ICC_TAB_CLASSES;
|
||||||
InitCommonControlsEx(&icce);
|
InitCommonControlsEx(&icce);
|
||||||
int multiLine = isMultiLine ? (_isTraditional ? TCS_MULTILINE | TCS_BUTTONS : 0) : 0;
|
int multiLine = isMultiLine ? (_isTraditional ? TCS_MULTILINE : 0) : 0;
|
||||||
|
|
||||||
int style = WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VISIBLE |\
|
int style = WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VISIBLE | TCS_FOCUSNEVER | TCS_TABS | vertical | multiLine;
|
||||||
TCS_FOCUSNEVER | TCS_TABS | vertical | multiLine;
|
|
||||||
|
|
||||||
style |= TCS_OWNERDRAWFIXED;
|
style |= TCS_OWNERDRAWFIXED;
|
||||||
|
|
||||||
@ -415,7 +441,7 @@ void TabBarPlus::doMultiLine()
|
|||||||
for (int i = 0 ; i < _nbCtrl ; ++i)
|
for (int i = 0 ; i < _nbCtrl ; ++i)
|
||||||
{
|
{
|
||||||
if (_hwndArray[i])
|
if (_hwndArray[i])
|
||||||
SendMessage(_hwndArray[i], WM_TABSETSTYLE, isMultiLine(), TCS_MULTILINE | TCS_BUTTONS);
|
SendMessage(_hwndArray[i], WM_TABSETSTYLE, isMultiLine(), TCS_MULTILINE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user