- Implement insert marks.

- Rearrange TOOLBAR_INFO.
This commit is contained in:
Robert Shearman 2004-08-19 19:58:49 +00:00 committed by Alexandre Julliard
parent f625f4a071
commit 4c1438a70e
3 changed files with 133 additions and 13 deletions

View File

@ -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);

View File

@ -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);
}

View File

@ -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 @@ typedef struct
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 @@ typedef struct
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 @@ typedef struct
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 @@ typedef struct
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 @@ typedef enum
#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_Refresh (HWND hwnd, HDC hdc, PAINTSTRUCT* ps)
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_GetDefImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
}
/* << 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_SetIndent (HWND hwnd, WPARAM wParam, LPARAM lParam)
}
/* << 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 @@ TOOLBAR_SetInsertMarkColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
infoPtr->clrInsertMark = (COLORREF)lParam;
/* FIXME : redraw ??*/
/* FIXME: don't need to update entire toolbar */
InvalidateRect(hwnd, NULL, TRUE);
return 0;
}
@ -5136,6 +5197,7 @@ TOOLBAR_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
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 @@ ToolbarWindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
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 @@ ToolbarWindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
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);