zamtmn / metadarkstyle

76 stars 24 forks source link

Statusbar, size grip missing #26

Closed klaus101 closed 1 year ago

klaus101 commented 1 year ago

I'd forgotten to mention. If applicable (eg. Form has borderstyle sizeable, or other criteria), then the StatusBar should have a size grip. Some ideas about that here: http://www.devsuperpage.com/Articles/views/Delphi/Art_1-1342.asp

Notepad++ / dark does paint it as shown in this picture: size_grip_npp

Within the following link there is a panel_sizegrip.zip which shows how it can be painted via themeservices (a 3-liner): https://forum.lazarus.freepascal.org/index.php/topic,62435.msg472145.html#msg472145 Example (here on a skyblue panel): size_grip_painted_themservices

klaus101 commented 1 year ago

Cool!

Maybe the right paddinig after the grip could be reduced a bit` //Rect.Left:=Rect.Right-24; Rect.Left:=Rect.Right-18; sizegrip

zamtmn commented 1 year ago

it depends on the dpi, we need a way to calculate size

klaus101 commented 1 year ago

Dont' know much about dpi calculations. The first sample in the initially mentioned link uses GetSystemMetrics. Maybe it could be applied (i let the variable names unchanged here so that you can refind):

        FSizeGripWidth := GetSystemMetrics(SM_CXVSCROLL);
        FSizeGripHeight := GetSystemMetrics(SM_CYHSCROLL);
        // Info, the value is each '17' here.
        // For to apply this (imo, using '16' would look more appropriate here):
        Rect.Left:=Rect.Right-FSizeGripWidth;
        Rect.Top:=Rect.Bottom-FSizeGripHeight;

Notepad++ uses some "GetThemePartSize", (Cannot go deeper here right now, but maybe you know some similar?):

    DWORD style = GetWindowLong(hWnd, GWL_STYLE);
    bool isSizeGrip = style & SBARS_SIZEGRIP;
    ......
        if (isSizeGrip)
    {
        ..............
        SIZE gripSize = {};
        GetThemePartSize(pStatusBarInfo->hTheme, hdc, SP_GRIPPER, 0, &rcClient, TS_DRAW, &gripSize);
        RECT rc = rcClient;
        rc.left = rc.right - gripSize.cx;
        rc.top = rc.bottom - gripSize.cy;
klaus101 commented 1 year ago

After some digging, what could be here the handle for the statusbar theme: this one should do the job. What do you think?

gripSize: TSize;
...
GetThemePartSize(TWin32ThemeServices(ThemeServices).Theme[teStatus],
                 LCanvas.Handle, SP_GRIPPER, 0, @Rect, TS_DRAW, gripSize);
Rect.Left:=Rect.Right - gripSize.cx;
Rect.top:=Rect.Bottom - gripSize.cy;

gripSize.cx and gripSize.cy are '16' here.

klaus101 commented 1 year ago

As it appears to me to be the right solution, i created a pull request.

sizegrip

klaus101 commented 1 year ago

(Merged) .. I thhink this can be closed now

klaus101 commented 1 year ago

Closing

zamtmn commented 1 year ago

Yes, thanks!