stefankueng / BowPad

A simple and fast text editor with a ribbon UI
http://tools.stefankueng.com/BowPad.html
GNU General Public License v3.0
630 stars 84 forks source link

Tabs Beyond View Enhancement Request #235

Closed PaltryProgrammer closed 2 years ago

PaltryProgrammer commented 2 years ago

Greetings and Kind Regards I would find it helpful if means were such as to permit knowing by glance if tabs beyond view are available . Perhaps by coloring the left/right tab buttons . Thank You Kindly PS I am looking forward to again buying you a cup of coffee more likely several such upon keyboard macros being provided in BowPad as I utilize such with some regularity and which make my work much easier on those occassions - Best - Cheerio PPS I am currently utilizing the macro function of Notepad++ but would prefer to utilize BowPad

stefankueng commented 2 years ago

this would require to drop the tabbar control and implement a fully custom control. this might take a while...

PaltryProgrammer commented 2 years ago

I do not know which TabBar control you are utilizing , however my modest knowledge of Windows MFC controls informs me the coloring of said controls can perhaps be accomplished via sub-classing - Best

kitepad commented 2 years ago

I found a demo to owner draw spin button of tab control. Maybe we can leverage this approach. https://www.codeproject.com/articles/278/fully-owner-drawn-tab-control.

kitepad commented 2 years ago

Based on this article, I trying to owner draw spin button successful. Below is my modification prototype for TabBar:

  1. Add HWND m_spin; and static LRESULT CALLBACK TabBarSpin_Proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); to CTabBar in tabbar.h.
  2. Implement TabBarSpin_Proc as below:

    
    {
    CTabBar *m_pTab = reinterpret_cast<CTabBar *>(::GetWindowLongPtr(hwnd, GWLP_USERDATA));
    switch (message) 
    {
        case WM_PAINT:
        {
            PAINTSTRUCT ps;
            BeginPaint(hwnd, &ps);
            HDC hdc = ps.hdc;
            RECT rcPaint;
            GetClientRect(hwnd, &rcPaint);
            bool   isDark = CTheme::Instance().IsDarkTheme();
            HBRUSH hbr    = CreateSolidBrush(isDark ? RGB(0x32, 0x32, 0x32) : RGB(0xFF, 0xFF, 0xFF));
            FillRect(hdc, &rcPaint, hbr);
            DeleteObject(hbr);
            int xPos = rcPaint.left;
            int mPos = (rcPaint.bottom - rcPaint.top) / 2;
            int size = 5;
            POINT leftArrow[] = {{xPos + size * 3, mPos + size}, {xPos + size * 3, mPos - size}, {xPos, mPos}};
            xPos = rcPaint.right - (rcPaint.right - rcPaint.left) / 2;
            POINT rightArrow[] = {{xPos + 3, mPos + size}, {xPos + 3, mPos - size}, {xPos + size * 3, mPos}};
            Polygon(hdc,rightArrow, sizeof(rightArrow) / sizeof(rightArrow[0]));
            Polygon(hdc,leftArrow, sizeof(leftArrow) / sizeof(leftArrow[0]));
    
            EndPaint(hwnd, &ps);
        }
        return FALSE;
    }
    return CallWindowProc(m_pTab->m_tabBarSpinDefaultProc, hwnd,message, wParam, lParam);
    }
kitepad commented 2 years ago
  1. Modified InsertAtEnd method to insert below code before return index statement:

    
    while (pWnd != 0)
    {
        WCHAR buf[] = L"msctls_updown32";
        int   nRet  = ::GetClassName(pWnd, buf, sizeof(buf) / sizeof(buf[0]));
        if (nRet && lstrcmp(buf, L"msctls_updown32"))
        {
            pWnd = GetWindow(pWnd, GW_HWNDNEXT);
        }
        else
        {
            RECT winrc;
            GetClientRect(*this, &winrc);
            MoveWindow(pWnd, winrc.right - 45, winrc.top, 45, winrc.bottom - winrc.top - 1, TRUE);
    
            if (m_spin == 0)
            {
                // MessageBox(NULL, L"Found", L"Found", MB_OK);
                SetWindowLongPtr(pWnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this));
    
                m_tabBarSpinDefaultProc = reinterpret_cast<WNDPROC>(::SetWindowLongPtr(pWnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(TabBarSpin_Proc)));
                m_spin            = pWnd;
            }
    
            pWnd = 0;
        }
    }