diff options
author | csaba <csaba> | 2024-07-28 11:19:38 (GMT) |
---|---|---|
committer | csaba <csaba> | 2024-07-28 11:19:38 (GMT) |
commit | abd2b62e940a7cee9d3f598d73298b9131b0f431 (patch) | |
tree | 4ee2980afa5bdd70ddd31b87e42124b4bb74d99e /win | |
parent | d68f02fce179fa48c0a7fef7359b6ea08b63e631 (diff) | |
download | tk-abd2b62e940a7cee9d3f598d73298b9131b0f431.zip tk-abd2b62e940a7cee9d3f598d73298b9131b0f431.tar.gz tk-abd2b62e940a7cee9d3f598d73298b9131b0f431.tar.bz2 |
Proposed fix for ticket [0d48797195]: Ugly and inconsistent look of the focus element and active listbox item.
Diffstat (limited to 'win')
-rw-r--r-- | win/tkWinDraw.c | 61 | ||||
-rw-r--r-- | win/tkWinInt.h | 28 |
2 files changed, 79 insertions, 10 deletions
diff --git a/win/tkWinDraw.c b/win/tkWinDraw.c index d0df3ec..e72352c 100644 --- a/win/tkWinDraw.c +++ b/win/tkWinDraw.c @@ -1485,6 +1485,67 @@ TkpDrawHighlightBorder( /* *---------------------------------------------------------------------- * + * TkWinDrawDottedRect -- + * + * This function draws a dotted rectangle, used as focus ring of Ttk + * widgets and for rendering the active element of a listbox. + * + * Results: + * None. + * + * Side effects: + * A dotted rectangle is drawn in the specified Drawable. + * + *---------------------------------------------------------------------- + */ + +void +TkWinDrawDottedRect( + Display *disp, /* Display containing the dotted rectangle. */ + Drawable d, /* Where to draw the rectangle (typically a + * pixmap for double buffering). */ + unsigned long pixel, /* color to use for drawing the rectangle. */ + int x, int y, /* Coordinates of the top-left corner. */ + int width, int height) /* Width & height, _including the border_. */ +{ + TkWinDCState state; + HDC dc; + LOGBRUSH lb; + HPEN pen; + int widthMod2 = width % 2, heightMod2 = height % 2; + int x2 = x + width - 1, y2 = y + height - 1; + + dc = TkWinGetDrawableDC(disp, d, &state); + + lb.lbStyle = BS_SOLID; + lb.lbColor = (COLORREF)pixel; + lb.lbHatch = 0; + + pen = ExtCreatePen(PS_COSMETIC | PS_ALTERNATE, 1, &lb, 0, NULL); + SelectObject(dc, pen); + SelectObject(dc, GetStockObject(NULL_BRUSH)); + + if (widthMod2 == 0 && heightMod2 == 0) { + MoveToEx(dc, x+1, y, NULL); LineTo(dc, x2, y); /* N */ + MoveToEx(dc, x+2, y2, NULL); LineTo(dc, x2, y2+1); /* S */ + MoveToEx(dc, x, y+2, NULL); LineTo(dc, x, y2+1); /* W */ + MoveToEx(dc, x2, y+1, NULL); LineTo(dc, x2, y2); /* E */ + } else { + int dx = widthMod2, dy = heightMod2; + + MoveToEx(dc, x+1, y, NULL); LineTo(dc, x2+dx, y); /* N */ + MoveToEx(dc, x+1, y2, NULL); LineTo(dc, x2+dx, y2); /* S */ + MoveToEx(dc, x, y+1, NULL); LineTo(dc, x, y2+dy); /* W */ + MoveToEx(dc, x2, y+1, NULL); LineTo(dc, x2, y2+dy); /* E */ + } + + DeleteObject(pen); + TkWinReleaseDrawableDC(d, dc, &state); +} + +/* + *---------------------------------------------------------------------- + * * TkpDrawFrame -- * * This function draws the rectangular frame area. diff --git a/win/tkWinInt.h b/win/tkWinInt.h index 892d9c6..c2e4715 100644 --- a/win/tkWinInt.h +++ b/win/tkWinInt.h @@ -191,26 +191,34 @@ MODULE_SCOPE void TkWinSetupSystemFonts(TkMainInfo *mainPtr); * The following is implemented in tkWinWm and used by tkWinEmbed.c */ -MODULE_SCOPE void TkpWinToplevelWithDraw(TkWindow *winPtr); -MODULE_SCOPE void TkpWinToplevelIconify(TkWindow *winPtr); -MODULE_SCOPE void TkpWinToplevelDeiconify(TkWindow *winPtr); -MODULE_SCOPE long TkpWinToplevelIsControlledByWm(TkWindow *winPtr); -MODULE_SCOPE long TkpWinToplevelMove(TkWindow *winPtr, int x, int y); -MODULE_SCOPE long TkpWinToplevelOverrideRedirect(TkWindow *winPtr, +MODULE_SCOPE void TkpWinToplevelWithDraw(TkWindow *winPtr); +MODULE_SCOPE void TkpWinToplevelIconify(TkWindow *winPtr); +MODULE_SCOPE void TkpWinToplevelDeiconify(TkWindow *winPtr); +MODULE_SCOPE long TkpWinToplevelIsControlledByWm(TkWindow *winPtr); +MODULE_SCOPE long TkpWinToplevelMove(TkWindow *winPtr, int x, int y); +MODULE_SCOPE long TkpWinToplevelOverrideRedirect(TkWindow *winPtr, int reqValue); -MODULE_SCOPE void TkpWinToplevelDetachWindow(TkWindow *winPtr); -MODULE_SCOPE int TkpWmGetState(TkWindow *winPtr); +MODULE_SCOPE void TkpWinToplevelDetachWindow(TkWindow *winPtr); +MODULE_SCOPE int TkpWmGetState(TkWindow *winPtr); /* * The following is implemented in tkWinPointer.c and also used in tkWinWindow.c */ -MODULE_SCOPE void TkSetCursorPos(int x, int y); +MODULE_SCOPE void TkSetCursorPos(int x, int y); + +/* + * The following is implemented in tkWinDraw.c and used in tkUtil.c + */ + +MODULE_SCOPE void TkWinDrawDottedRect (Display *disp, Drawable d, + unsigned long pixel, int x, int y, + int width, int height); /* * Common routines used in Windows implementation */ -MODULE_SCOPE Tcl_Obj * TkWin32ErrorObj(HRESULT hrError); +MODULE_SCOPE Tcl_Obj * TkWin32ErrorObj(HRESULT hrError); /* |