summaryrefslogtreecommitdiffstats
path: root/win/tkWinDraw.c
diff options
context:
space:
mode:
Diffstat (limited to 'win/tkWinDraw.c')
-rw-r--r--win/tkWinDraw.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/win/tkWinDraw.c b/win/tkWinDraw.c
index 1022be4..7f96164 100644
--- a/win/tkWinDraw.c
+++ b/win/tkWinDraw.c
@@ -1488,6 +1488,67 @@ Tk_DrawHighlightBorder(
/*
*----------------------------------------------------------------------
*
+ * 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);
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* TkpDrawFrameEx --
*
* This function draws the rectangular frame area.