Refactoring and clean up for tab interface
This commit is contained in:
parent
9faa97a6f9
commit
3ba1b100f2
@ -257,7 +257,7 @@ void FindReplaceDlg::create(int dialogID, bool isRTL)
|
|||||||
RECT rect;
|
RECT rect;
|
||||||
//::GetWindowRect(_hSelf, &rect);
|
//::GetWindowRect(_hSelf, &rect);
|
||||||
getClientRect(rect);
|
getClientRect(rect);
|
||||||
_tab.init(_hInst, _hSelf, false, false, true);
|
_tab.init(_hInst, _hSelf, false, true);
|
||||||
int tabDpiDynamicalHeight = NppParameters::getInstance()->_dpiManager.scaleY(13);
|
int tabDpiDynamicalHeight = NppParameters::getInstance()->_dpiManager.scaleY(13);
|
||||||
_tab.setFont(TEXT("Tahoma"), tabDpiDynamicalHeight);
|
_tab.setFont(TEXT("Tahoma"), tabDpiDynamicalHeight);
|
||||||
|
|
||||||
|
@ -196,7 +196,7 @@ void PluginsAdminDlg::create(int dialogID, bool isRTL)
|
|||||||
|
|
||||||
RECT rect;
|
RECT rect;
|
||||||
getClientRect(rect);
|
getClientRect(rect);
|
||||||
_tab.init(_hInst, _hSelf, false, false, true);
|
_tab.init(_hInst, _hSelf, false, true);
|
||||||
int tabDpiDynamicalHeight = NppParameters::getInstance()->_dpiManager.scaleY(13);
|
int tabDpiDynamicalHeight = NppParameters::getInstance()->_dpiManager.scaleY(13);
|
||||||
_tab.setFont(TEXT("Tahoma"), tabDpiDynamicalHeight);
|
_tab.setFont(TEXT("Tahoma"), tabDpiDynamicalHeight);
|
||||||
|
|
||||||
|
@ -50,10 +50,10 @@ public :
|
|||||||
ControlsTab() = default;
|
ControlsTab() = default;
|
||||||
virtual ~ControlsTab() = default;
|
virtual ~ControlsTab() = default;
|
||||||
|
|
||||||
virtual void init(HINSTANCE hInst, HWND hwnd, bool isVertical = false, bool isTraditional = false, bool isMultiLine = false)
|
virtual void init(HINSTANCE hInst, HWND hwnd, bool isVertical = false, bool isMultiLine = false)
|
||||||
{
|
{
|
||||||
_isVertical = isVertical;
|
_isVertical = isVertical;
|
||||||
TabBar::init(hInst, hwnd, false, isTraditional, isMultiLine);
|
TabBar::init(hInst, hwnd, false, isMultiLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
void createTabs(WindowVector & winVector);
|
void createTabs(WindowVector & winVector);
|
||||||
|
@ -54,11 +54,11 @@ COLORREF TabBarPlus::_inactiveBgColour = RGB(192, 192, 192);
|
|||||||
HWND TabBarPlus::_hwndArray[nbCtrlMax] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
|
HWND TabBarPlus::_hwndArray[nbCtrlMax] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
|
||||||
int TabBarPlus::_nbCtrl = 0;
|
int TabBarPlus::_nbCtrl = 0;
|
||||||
|
|
||||||
void TabBar::init(HINSTANCE hInst, HWND parent, bool isVertical, bool isTraditional, bool isMultiLine)
|
void TabBar::init(HINSTANCE hInst, HWND parent, bool isVertical, bool isMultiLine)
|
||||||
{
|
{
|
||||||
Window::init(hInst, parent);
|
Window::init(hInst, parent);
|
||||||
int vertical = isVertical?(TCS_VERTICAL | TCS_MULTILINE | TCS_RIGHTJUSTIFY):0;
|
int vertical = isVertical?(TCS_VERTICAL | TCS_MULTILINE | TCS_RIGHTJUSTIFY):0;
|
||||||
_isTraditional = isTraditional;
|
|
||||||
_isVertical = isVertical;
|
_isVertical = isVertical;
|
||||||
_isMultiLine = isMultiLine;
|
_isMultiLine = isMultiLine;
|
||||||
|
|
||||||
@ -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 : 0) : 0;
|
int multiLine = isMultiLine ? TCS_MULTILINE : 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;
|
||||||
@ -215,48 +215,33 @@ void TabBar::reSizeTo(RECT & rc2Ajust)
|
|||||||
|
|
||||||
rowCount = TabCtrl_GetRowCount(_hSelf);
|
rowCount = TabCtrl_GetRowCount(_hSelf);
|
||||||
TabCtrl_GetItemRect(_hSelf, 0, &rowRect);
|
TabCtrl_GetItemRect(_hSelf, 0, &rowRect);
|
||||||
if (_isTraditional)
|
|
||||||
|
int larger = _isVertical ? rowRect.right : rowRect.bottom;
|
||||||
|
int smaller = _isVertical ? rowRect.left : rowRect.top;
|
||||||
|
int marge = 0;
|
||||||
|
|
||||||
|
LONG_PTR style = ::GetWindowLongPtr(_hSelf, GWL_STYLE);
|
||||||
|
if (rowCount == 1)
|
||||||
{
|
{
|
||||||
TabCtrl_AdjustRect(_hSelf, FALSE, &rc2Ajust);
|
style &= ~TCS_BUTTONS;
|
||||||
}
|
}
|
||||||
else if (_isVertical)
|
else // (rowCount >= 2)
|
||||||
{
|
{
|
||||||
LONG_PTR style = ::GetWindowLongPtr(_hSelf, GWL_STYLE);
|
style |= TCS_BUTTONS;
|
||||||
if (rowCount == 1)
|
marge = 3; // in TCS_BUTTONS mode, each row has few pixels higher
|
||||||
{
|
|
||||||
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);
|
|
||||||
|
|
||||||
rc2Ajust.left += tabsHight;
|
|
||||||
rc2Ajust.right -= tabsHight;
|
|
||||||
}
|
}
|
||||||
else //if (_isMultiLine)
|
|
||||||
|
::SetWindowLongPtr(_hSelf, GWL_STYLE, style);
|
||||||
|
tabsHight = rowCount * (larger - smaller + marge);
|
||||||
|
tabsHight += GetSystemMetrics(_isVertical ? SM_CXEDGE : SM_CYEDGE);
|
||||||
|
|
||||||
|
if (_isVertical)
|
||||||
|
{
|
||||||
|
rc2Ajust.left += tabsHight;
|
||||||
|
rc2Ajust.right -= tabsHight;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
LONG_PTR style = ::GetWindowLongPtr(_hSelf, GWL_STYLE);
|
|
||||||
int marge = 0;
|
|
||||||
if (rowCount == 1)
|
|
||||||
{
|
|
||||||
style &= ~TCS_BUTTONS;
|
|
||||||
}
|
|
||||||
else // (rowCount >= 2)
|
|
||||||
{
|
|
||||||
style |= TCS_BUTTONS;
|
|
||||||
marge = 3; // in TCS_BUTTONS mode, each row has few pixels higher
|
|
||||||
}
|
|
||||||
|
|
||||||
::SetWindowLongPtr(_hSelf, GWL_STYLE, style);
|
|
||||||
tabsHight = rowCount * (rowRect.bottom - rowRect.top + marge);
|
|
||||||
tabsHight += GetSystemMetrics(SM_CYEDGE);
|
|
||||||
|
|
||||||
rc2Ajust.top += tabsHight;
|
rc2Ajust.top += tabsHight;
|
||||||
rc2Ajust.bottom -= tabsHight;
|
rc2Ajust.bottom -= tabsHight;
|
||||||
}
|
}
|
||||||
@ -271,11 +256,10 @@ void TabBarPlus::destroy()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TabBarPlus::init(HINSTANCE hInst, HWND parent, bool isVertical, bool isTraditional, bool isMultiLine)
|
void TabBarPlus::init(HINSTANCE hInst, HWND parent, bool isVertical, bool isMultiLine)
|
||||||
{
|
{
|
||||||
Window::init(hInst, parent);
|
Window::init(hInst, parent);
|
||||||
int vertical = isVertical?(TCS_VERTICAL | TCS_MULTILINE | TCS_RIGHTJUSTIFY):0;
|
int vertical = isVertical?(TCS_VERTICAL | TCS_MULTILINE | TCS_RIGHTJUSTIFY):0;
|
||||||
_isTraditional = isTraditional;
|
|
||||||
_isVertical = isVertical;
|
_isVertical = isVertical;
|
||||||
_isMultiLine = isMultiLine;
|
_isMultiLine = isMultiLine;
|
||||||
|
|
||||||
@ -283,7 +267,7 @@ 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 : 0) : 0;
|
int multiLine = isMultiLine ? TCS_MULTILINE : 0;
|
||||||
|
|
||||||
int style = WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VISIBLE | TCS_FOCUSNEVER | TCS_TABS | vertical | multiLine;
|
int style = WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VISIBLE | TCS_FOCUSNEVER | TCS_TABS | vertical | multiLine;
|
||||||
|
|
||||||
@ -322,34 +306,31 @@ void TabBarPlus::init(HINSTANCE hInst, HWND parent, bool isVertical, bool isTrad
|
|||||||
}
|
}
|
||||||
::SendMessage(_hSelf, TCM_SETTOOLTIPS, reinterpret_cast<WPARAM>(_tooltips), 0);
|
::SendMessage(_hSelf, TCM_SETTOOLTIPS, reinterpret_cast<WPARAM>(_tooltips), 0);
|
||||||
|
|
||||||
if (!_isTraditional)
|
if (!_hwndArray[_nbCtrl])
|
||||||
{
|
{
|
||||||
if (!_hwndArray[_nbCtrl])
|
_hwndArray[_nbCtrl] = _hSelf;
|
||||||
|
_ctrlID = _nbCtrl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
bool found = false;
|
||||||
|
for ( ; i < nbCtrlMax && !found ; ++i)
|
||||||
|
if (!_hwndArray[i])
|
||||||
|
found = true;
|
||||||
|
if (!found)
|
||||||
{
|
{
|
||||||
_hwndArray[_nbCtrl] = _hSelf;
|
_ctrlID = -1;
|
||||||
_ctrlID = _nbCtrl;
|
destroy();
|
||||||
|
throw std::runtime_error("TabBarPlus::init : Tab Control error - Tab Control # is over its limit");
|
||||||
}
|
}
|
||||||
else
|
_hwndArray[i] = _hSelf;
|
||||||
{
|
_ctrlID = i;
|
||||||
int i = 0;
|
}
|
||||||
bool found = false;
|
++_nbCtrl;
|
||||||
for ( ; i < nbCtrlMax && !found ; ++i)
|
|
||||||
if (!_hwndArray[i])
|
|
||||||
found = true;
|
|
||||||
if (!found)
|
|
||||||
{
|
|
||||||
_ctrlID = -1;
|
|
||||||
destroy();
|
|
||||||
throw std::runtime_error("TabBarPlus::init : Tab Control error - Tab Control # is over its limit");
|
|
||||||
}
|
|
||||||
_hwndArray[i] = _hSelf;
|
|
||||||
_ctrlID = i;
|
|
||||||
}
|
|
||||||
++_nbCtrl;
|
|
||||||
|
|
||||||
::SetWindowLongPtr(_hSelf, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this));
|
::SetWindowLongPtr(_hSelf, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this));
|
||||||
_tabBarDefaultProc = reinterpret_cast<WNDPROC>(::SetWindowLongPtr(_hSelf, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(TabBarPlus_Proc)));
|
_tabBarDefaultProc = reinterpret_cast<WNDPROC>(::SetWindowLongPtr(_hSelf, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(TabBarPlus_Proc)));
|
||||||
}
|
|
||||||
|
|
||||||
LOGFONT LogFont;
|
LOGFONT LogFont;
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ public:
|
|||||||
TabBar() : Window() {};
|
TabBar() : Window() {};
|
||||||
virtual ~TabBar() {};
|
virtual ~TabBar() {};
|
||||||
virtual void destroy();
|
virtual void destroy();
|
||||||
virtual void init(HINSTANCE hInst, HWND hwnd, bool isVertical = false, bool isTraditional = false, bool isMultiLine = false);
|
virtual void init(HINSTANCE hInst, HWND hwnd, bool isVertical = false, bool isMultiLine = false);
|
||||||
virtual void reSizeTo(RECT & rc2Ajust);
|
virtual void reSizeTo(RECT & rc2Ajust);
|
||||||
int insertAtEnd(const TCHAR *subTabName);
|
int insertAtEnd(const TCHAR *subTabName);
|
||||||
void activateAt(int index) const;
|
void activateAt(int index) const;
|
||||||
@ -115,7 +115,6 @@ protected:
|
|||||||
HFONT _hVerticalLargeFont = nullptr;
|
HFONT _hVerticalLargeFont = nullptr;
|
||||||
|
|
||||||
int _ctrlID = 0;
|
int _ctrlID = 0;
|
||||||
bool _isTraditional = false;
|
|
||||||
|
|
||||||
bool _isVertical = false;
|
bool _isVertical = false;
|
||||||
bool _isMultiLine = false;
|
bool _isMultiLine = false;
|
||||||
@ -150,7 +149,7 @@ public :
|
|||||||
_doDragNDrop = justDoIt;
|
_doDragNDrop = justDoIt;
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual void init(HINSTANCE hInst, HWND hwnd, bool isVertical = false, bool isTraditional = false, bool isMultiLine = false);
|
virtual void init(HINSTANCE hInst, HWND hwnd, bool isVertical = false, bool isMultiLine = false);
|
||||||
|
|
||||||
virtual void destroy();
|
virtual void destroy();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user