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;
|
||||
//::GetWindowRect(_hSelf, &rect);
|
||||
getClientRect(rect);
|
||||
_tab.init(_hInst, _hSelf, false, false, true);
|
||||
_tab.init(_hInst, _hSelf, false, true);
|
||||
int tabDpiDynamicalHeight = NppParameters::getInstance()->_dpiManager.scaleY(13);
|
||||
_tab.setFont(TEXT("Tahoma"), tabDpiDynamicalHeight);
|
||||
|
||||
|
@ -196,7 +196,7 @@ void PluginsAdminDlg::create(int dialogID, bool isRTL)
|
||||
|
||||
RECT rect;
|
||||
getClientRect(rect);
|
||||
_tab.init(_hInst, _hSelf, false, false, true);
|
||||
_tab.init(_hInst, _hSelf, false, true);
|
||||
int tabDpiDynamicalHeight = NppParameters::getInstance()->_dpiManager.scaleY(13);
|
||||
_tab.setFont(TEXT("Tahoma"), tabDpiDynamicalHeight);
|
||||
|
||||
|
@ -50,10 +50,10 @@ public :
|
||||
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;
|
||||
TabBar::init(hInst, hwnd, false, isTraditional, isMultiLine);
|
||||
TabBar::init(hInst, hwnd, false, isMultiLine);
|
||||
}
|
||||
|
||||
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};
|
||||
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);
|
||||
int vertical = isVertical?(TCS_VERTICAL | TCS_MULTILINE | TCS_RIGHTJUSTIFY):0;
|
||||
_isTraditional = isTraditional;
|
||||
|
||||
_isVertical = isVertical;
|
||||
_isMultiLine = isMultiLine;
|
||||
|
||||
@ -66,7 +66,7 @@ void TabBar::init(HINSTANCE hInst, HWND parent, bool isVertical, bool isTraditio
|
||||
icce.dwSize = sizeof(icce);
|
||||
icce.dwICC = ICC_TAB_CLASSES;
|
||||
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 | WS_TABSTOP | vertical | multiLine;
|
||||
@ -215,34 +215,12 @@ void TabBar::reSizeTo(RECT & rc2Ajust)
|
||||
|
||||
rowCount = TabCtrl_GetRowCount(_hSelf);
|
||||
TabCtrl_GetItemRect(_hSelf, 0, &rowRect);
|
||||
if (_isTraditional)
|
||||
{
|
||||
TabCtrl_AdjustRect(_hSelf, FALSE, &rc2Ajust);
|
||||
}
|
||||
else if (_isVertical)
|
||||
{
|
||||
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);
|
||||
|
||||
rc2Ajust.left += tabsHight;
|
||||
rc2Ajust.right -= tabsHight;
|
||||
}
|
||||
else //if (_isMultiLine)
|
||||
{
|
||||
LONG_PTR style = ::GetWindowLongPtr(_hSelf, GWL_STYLE);
|
||||
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)
|
||||
{
|
||||
style &= ~TCS_BUTTONS;
|
||||
@ -254,9 +232,16 @@ void TabBar::reSizeTo(RECT & rc2Ajust)
|
||||
}
|
||||
|
||||
::SetWindowLongPtr(_hSelf, GWL_STYLE, style);
|
||||
tabsHight = rowCount * (rowRect.bottom - rowRect.top + marge);
|
||||
tabsHight += GetSystemMetrics(SM_CYEDGE);
|
||||
tabsHight = rowCount * (larger - smaller + marge);
|
||||
tabsHight += GetSystemMetrics(_isVertical ? SM_CXEDGE : SM_CYEDGE);
|
||||
|
||||
if (_isVertical)
|
||||
{
|
||||
rc2Ajust.left += tabsHight;
|
||||
rc2Ajust.right -= tabsHight;
|
||||
}
|
||||
else
|
||||
{
|
||||
rc2Ajust.top += 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);
|
||||
int vertical = isVertical?(TCS_VERTICAL | TCS_MULTILINE | TCS_RIGHTJUSTIFY):0;
|
||||
_isTraditional = isTraditional;
|
||||
_isVertical = isVertical;
|
||||
_isMultiLine = isMultiLine;
|
||||
|
||||
@ -283,7 +267,7 @@ void TabBarPlus::init(HINSTANCE hInst, HWND parent, bool isVertical, bool isTrad
|
||||
icce.dwSize = sizeof(icce);
|
||||
icce.dwICC = ICC_TAB_CLASSES;
|
||||
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;
|
||||
|
||||
@ -322,8 +306,6 @@ void TabBarPlus::init(HINSTANCE hInst, HWND parent, bool isVertical, bool isTrad
|
||||
}
|
||||
::SendMessage(_hSelf, TCM_SETTOOLTIPS, reinterpret_cast<WPARAM>(_tooltips), 0);
|
||||
|
||||
if (!_isTraditional)
|
||||
{
|
||||
if (!_hwndArray[_nbCtrl])
|
||||
{
|
||||
_hwndArray[_nbCtrl] = _hSelf;
|
||||
@ -349,7 +331,6 @@ void TabBarPlus::init(HINSTANCE hInst, HWND parent, bool isVertical, bool isTrad
|
||||
|
||||
::SetWindowLongPtr(_hSelf, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this));
|
||||
_tabBarDefaultProc = reinterpret_cast<WNDPROC>(::SetWindowLongPtr(_hSelf, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(TabBarPlus_Proc)));
|
||||
}
|
||||
|
||||
LOGFONT LogFont;
|
||||
|
||||
|
@ -68,7 +68,7 @@ public:
|
||||
TabBar() : Window() {};
|
||||
virtual ~TabBar() {};
|
||||
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);
|
||||
int insertAtEnd(const TCHAR *subTabName);
|
||||
void activateAt(int index) const;
|
||||
@ -115,7 +115,6 @@ protected:
|
||||
HFONT _hVerticalLargeFont = nullptr;
|
||||
|
||||
int _ctrlID = 0;
|
||||
bool _isTraditional = false;
|
||||
|
||||
bool _isVertical = false;
|
||||
bool _isMultiLine = false;
|
||||
@ -150,7 +149,7 @@ public :
|
||||
_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();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user