Toolbar: Insert Marks
Robert Shearman
rob at codeweavers.com
Thu Aug 19 06:51:49 CDT 2004
Hi,
This patch adds a new shared function, COMCTL32_DrawInsertMark, which is
currently only used by the toolbar control, but could potentially be
used by other controls too. As soon as I put a test case together for
the Treeview control I will convert that over to using this new function.
Rob
Changelog:
- Implement insert marks
- Rearrange TOOLBAR_INFO
-------------- next part --------------
Index: wine/dlls/comctl32/commctrl.c
===================================================================
RCS file: /home/wine/wine/dlls/comctl32/commctrl.c,v
retrieving revision 1.80
diff -u -p -r1.80 commctrl.c
--- wine/dlls/comctl32/commctrl.c 6 Aug 2004 19:17:49 -0000 1.80
+++ wine/dlls/comctl32/commctrl.c 19 Aug 2004 03:27:40 -0000
@@ -1410,3 +1410,56 @@ COMCTL32_RefreshSysColors(void)
comctl32_color.clrInfoBk = GetSysColor (COLOR_INFOBK);
comctl32_color.clrInfoText = GetSysColor (COLOR_INFOTEXT);
}
+
+/***********************************************************************
+ * COMCTL32_DrawInsertMark [NOT AN API]
+ *
+ * Draws an insertion mark (which looks similar to an 'I').
+ *
+ * PARAMS
+ * hDC [I] Device context to draw onto.
+ * lpRect [I] Co-ordinates of insertion mark.
+ * clrInsertMark [I] Colour of the insertion mark.
+ * bHorizontal [I] True if insert mark should be drawn horizontally,
+ * vertical otherwise.
+ *
+ * RETURNS
+ * none
+ *
+ * NOTES
+ * Draws up to but not including the bottom co-ordinate when drawing
+ * vertically or the right co-ordinate when horizontal.
+ */
+void COMCTL32_DrawInsertMark(HDC hDC, const RECT *lpRect, COLORREF clrInsertMark, BOOL bHorizontal)
+{
+ HPEN hPen = CreatePen(PS_SOLID, 1, clrInsertMark);
+ HPEN hOldPen;
+ static const DWORD adwPolyPoints[] = {4,4,4};
+ LONG lCentre = (bHorizontal ?
+ lpRect->top + (lpRect->bottom - lpRect->top)/2 :
+ lpRect->left + (lpRect->right - lpRect->left)/2);
+ LONG l1 = (bHorizontal ? lpRect->left : lpRect->top);
+ LONG l2 = (bHorizontal ? lpRect->right : lpRect->bottom);
+ const POINT aptInsertMark[] =
+ {
+ /* top (V) or left (H) arrow */
+ {lCentre , l1 + 2},
+ {lCentre - 2, l1 },
+ {lCentre + 3, l1 },
+ {lCentre + 1, l1 + 2},
+ /* middle line */
+ {lCentre , l2 - 2},
+ {lCentre , l1 - 1},
+ {lCentre + 1, l1 - 1},
+ {lCentre + 1, l2 - 2},
+ /* bottom (V) or right (H) arrow */
+ {lCentre , l2 - 3},
+ {lCentre - 2, l2 - 1},
+ {lCentre + 3, l2 - 1},
+ {lCentre + 1, l2 - 3},
+ };
+ hOldPen = SelectObject(hDC, hPen);
+ PolyPolyline(hDC, aptInsertMark, adwPolyPoints, sizeof(adwPolyPoints)/sizeof(adwPolyPoints[0]));
+ SelectObject(hDC, hOldPen);
+ DeleteObject(hPen);
+}
Index: wine/dlls/comctl32/comctl32.h
===================================================================
RCS file: /home/wine/wine/dlls/comctl32/comctl32.h,v
retrieving revision 1.29
diff -u -p -r1.29 comctl32.h
--- wine/dlls/comctl32/comctl32.h 17 May 2004 19:48:24 -0000 1.29
+++ wine/dlls/comctl32/comctl32.h 19 Aug 2004 03:27:41 -0000
@@ -137,6 +137,7 @@ extern COMCTL32_SysColor comctl32_color
/* Internal function */
HWND COMCTL32_CreateToolTip (HWND);
VOID COMCTL32_RefreshSysColors(void);
+void COMCTL32_DrawInsertMark(HDC hDC, const RECT *lpRect, COLORREF clrInsertMark, BOOL bHorizontal);
INT Str_GetPtrWtoA (LPCWSTR lpSrc, LPSTR lpDest, INT nMaxLen);
BOOL Str_SetPtrAtoW (LPWSTR *lppDest, LPCSTR lpSrc);
--- wine/dlls/comctl32/toolbar.c.orig 2004-08-19 04:25:36.329456840 +0100
+++ wine/dlls/comctl32/toolbar.c 2004-08-19 04:27:42.453283104 +0100
@@ -42,12 +42,9 @@
* - TBSTYLE_REGISTERDROP
* - TBSTYLE_EX_DOUBLEBUFFER
* - Messages:
- * - TB_GETINSERTMARK
- * - TB_GETINSERTMARKCOLOR
* - TB_GETMETRICS
* - TB_GETOBJECT
* - TB_INSERTMARKHITTEST
- * - TB_SETINSERTMARK
* - TB_SETMETRICS
* - Notifications:
* - NM_CHAR
@@ -126,6 +123,7 @@
INT nHeight; /* height of the toolbar */
INT nWidth; /* width of the toolbar */
RECT client_rect;
+ RECT rcBound; /* bounding rectangle */
INT nButtonHeight;
INT nButtonWidth;
INT nBitmapHeight;
@@ -139,8 +137,6 @@
INT nNumBitmaps; /* number of bitmaps */
INT nNumStrings; /* number of strings */
INT nNumBitmapInfos;
- BOOL bUnicode; /* ASCII (FALSE) or Unicode (TRUE)? */
- BOOL bCaptured; /* mouse captured? */
INT nButtonDown; /* toolbar button being pressed or -1 if none */
INT nButtonDrag; /* toolbar button being dragged or -1 if none */
INT nOldHit;
@@ -168,6 +164,8 @@
BOOL bNtfUnicode; /* TRUE if NOTIFYs use {W} */
BOOL bDoRedraw; /* Redraw status */
BOOL bDragOutSent; /* has TBN_DRAGOUT notification been sent for this drag? */
+ BOOL bUnicode; /* ASCII (FALSE) or Unicode (TRUE)? */
+ BOOL bCaptured; /* mouse captured? */
DWORD dwStyle; /* regular toolbar style */
DWORD dwExStyle; /* extended toolbar style */
DWORD dwDTFlags; /* DrawText flags */
@@ -175,10 +173,10 @@
COLORREF clrInsertMark; /* insert mark color */
COLORREF clrBtnHighlight; /* color for Flat Separator */
COLORREF clrBtnShadow; /* color for Flag Separator */
- RECT rcBound; /* bounding rectangle */
INT iVersion;
LPWSTR pszTooltipText; /* temporary store for a string > 80 characters
* for TTN_GETDISPINFOW notification */
+ TBINSERTMARK tbim; /* info on insertion mark */
TBUTTON_INFO *buttons; /* pointer to button array */
LPWSTR *strings; /* pointer to string array */
TBITMAP_INFO *bitmaps;
@@ -212,6 +210,7 @@
#define BOTTOM_BORDER 2
#define DDARROW_WIDTH 11
#define ARROW_HEIGHT 3
+#define INSERTMARK_WIDTH 2
/* gap between border of button and text/image */
#define OFFSET_X 1
@@ -1097,6 +1096,20 @@
TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
}
+ /* draw insert mark if required */
+ if (infoPtr->tbim.iButton != -1)
+ {
+ RECT rcButton = infoPtr->buttons[infoPtr->tbim.iButton].rect;
+ RECT rcInsertMark;
+ rcInsertMark.top = rcButton.top;
+ rcInsertMark.bottom = rcButton.bottom;
+ if (infoPtr->tbim.dwFlags & TBIMHT_AFTER)
+ rcInsertMark.left = rcInsertMark.right = rcButton.right;
+ else
+ rcInsertMark.left = rcInsertMark.right = rcButton.left - INSERTMARK_WIDTH;
+ COMCTL32_DrawInsertMark(hdc, &rcInsertMark, infoPtr->clrInsertMark, FALSE);
+ }
+
if (infoPtr->bBtnTranspnt && (oldBKmode != TRANSPARENT))
SetBkMode (hdc, oldBKmode);
@@ -3372,8 +3385,29 @@
}
-/* << TOOLBAR_GetInsertMark >> */
-/* << TOOLBAR_GetInsertMarkColor >> */
+static LRESULT
+TOOLBAR_GetInsertMark (HWND hwnd, WPARAM wParam, LPARAM lParam)
+{
+ TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
+ TBINSERTMARK *lptbim = (TBINSERTMARK*)lParam;
+
+ TRACE("hwnd = %p, lptbim = %p\n", hwnd, lptbim);
+
+ *lptbim = infoPtr->tbim;
+
+ return 0;
+}
+
+
+static LRESULT
+TOOLBAR_GetInsertMarkColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
+{
+ TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
+
+ TRACE("hwnd = %p\n", hwnd);
+
+ return (LRESULT)infoPtr->clrInsertMark;
+}
static LRESULT
@@ -4691,7 +4725,33 @@
}
-/* << TOOLBAR_SetInsertMark >> */
+static LRESULT
+TOOLBAR_SetInsertMark (HWND hwnd, WPARAM wParam, LPARAM lParam)
+{
+ TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
+ TBINSERTMARK *lptbim = (TBINSERTMARK*)lParam;
+
+ TRACE("hwnd = %p, lptbim = { %d, 0x%08lx}\n", hwnd, lptbim->iButton, lptbim->dwFlags);
+
+ if ((lptbim->dwFlags & ~TBIMHT_AFTER) != 0)
+ {
+ FIXME("Unrecognized flag(s): 0x%08lx\n", (lptbim->dwFlags & ~TBIMHT_AFTER));
+ return 0;
+ }
+
+ if ((lptbim->iButton == -1) ||
+ ((lptbim->iButton < infoPtr->nNumButtons) &&
+ (lptbim->iButton >= 0)))
+ {
+ infoPtr->tbim = *lptbim;
+ /* FIXME: don't need to update entire toolbar */
+ InvalidateRect(hwnd, NULL, TRUE);
+ }
+ else
+ ERR("Invalid button index %d\n", lptbim->iButton);
+
+ return 0;
+}
static LRESULT
@@ -4701,7 +4761,8 @@
infoPtr->clrInsertMark = (COLORREF)lParam;
- /* FIXME : redraw ??*/
+ /* FIXME: don't need to update entire toolbar */
+ InvalidateRect(hwnd, NULL, TRUE);
return 0;
}
@@ -5136,6 +5197,7 @@
infoPtr->szPadding.cy = 2*(GetSystemMetrics(SM_CYEDGE)+OFFSET_Y);
infoPtr->iListGap = infoPtr->szPadding.cx / 2;
infoPtr->dwStyle = dwStyle;
+ infoPtr->tbim.iButton = -1;
GetClientRect(hwnd, &infoPtr->client_rect);
TOOLBAR_NotifyFormat(infoPtr, (WPARAM)hwnd, (LPARAM)NF_REQUERY);
@@ -6457,8 +6519,11 @@
case TB_GETIMAGELIST:
return TOOLBAR_GetDefImageList (hwnd, wParam, lParam);
-/* case TB_GETINSERTMARK: */ /* 4.71 */
-/* case TB_GETINSERTMARKCOLOR: */ /* 4.71 */
+ case TB_GETINSERTMARK:
+ return TOOLBAR_GetInsertMark (hwnd, wParam, lParam);
+
+ case TB_GETINSERTMARKCOLOR:
+ return TOOLBAR_GetInsertMarkColor (hwnd, wParam, lParam);
case TB_GETITEMRECT:
return TOOLBAR_GetItemRect (hwnd, wParam, lParam);
@@ -6600,7 +6665,8 @@
case TB_SETINDENT:
return TOOLBAR_SetIndent (hwnd, wParam, lParam);
-/* case TB_SETINSERTMARK: */ /* 4.71 */
+ case TB_SETINSERTMARK:
+ return TOOLBAR_SetInsertMark (hwnd, wParam, lParam);
case TB_SETINSERTMARKCOLOR:
return TOOLBAR_SetInsertMarkColor (hwnd, wParam, lParam);
More information about the wine-patches
mailing list