wined3d: Add a test for fixed function bump mapping.
[wine/multimedia.git] / dlls / comctl32 / rebar.c
blob92c19223d5a1281c0c69a5b7c137b14892c3bdcb
1 /*
2 * Rebar control
4 * Copyright 1998, 1999 Eric Kohl
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 * NOTES
22 * This code was audited for completeness against the documented features
23 * of Comctl32.dll version 6.0 on Oct. 19, 2004, by Robert Shearman.
25 * Unless otherwise noted, we believe this code to be complete, as per
26 * the specification mentioned above.
27 * If you discover missing features or bugs please note them below.
29 * TODO
30 * Styles:
31 * - RBS_DBLCLKTOGGLE
32 * - RBS_FIXEDORDER
33 * - RBS_REGISTERDROP
34 * - RBS_TOOLTIPS
35 * - RBS_AUTOSIZE
36 * Messages:
37 * - RB_BEGINDRAG
38 * - RB_DRAGMOVE
39 * - RB_ENDDRAG
40 * - RB_GETBANDMARGINS
41 * - RB_GETCOLORSCHEME
42 * - RB_GETDROPTARGET
43 * - RB_GETPALETTE
44 * - RB_SETCOLORSCHEME
45 * - RB_SETPALETTE
46 * - RB_SETTOOLTIPS
47 * - WM_CHARTOITEM
48 * - WM_LBUTTONDBLCLK
49 * - WM_MEASUREITEM
50 * - WM_PALETTECHANGED
51 * - WM_QUERYNEWPALETTE
52 * - WM_RBUTTONDOWN
53 * - WM_RBUTTONUP
54 * - WM_SYSCOLORCHANGE
55 * - WM_VKEYTOITEM
56 * - WM_WININICHANGE
57 * Notifications:
58 * - NM_HCHITTEST
59 * - NM_RELEASEDCAPTURE
60 * - RBN_AUTOBREAK
61 * - RBN_GETOBJECT
62 * - RBN_MINMAX
63 * Band styles:
64 * - RBBS_FIXEDBMP
65 * Native uses (on each draw!!) SM_CYBORDER (or SM_CXBORDER for CCS_VERT)
66 * to set the size of the separator width (the value SEP_WIDTH_SIZE
67 * in here). Should be fixed!!
71 * Testing: set to 1 to make background brush *always* green
73 #define GLATESTING 0
76 * 3. REBAR_MoveChildWindows should have a loop because more than
77 * one pass (together with the RBN_CHILDSIZEs) is made on
78 * at least RB_INSERTBAND
81 #include <stdarg.h>
82 #include <stdlib.h>
83 #include <string.h>
85 #include "windef.h"
86 #include "winbase.h"
87 #include "wingdi.h"
88 #include "wine/unicode.h"
89 #include "winuser.h"
90 #include "winnls.h"
91 #include "commctrl.h"
92 #include "comctl32.h"
93 #include "uxtheme.h"
94 #include "tmschema.h"
95 #include "wine/debug.h"
97 WINE_DEFAULT_DEBUG_CHANNEL(rebar);
99 typedef struct
101 UINT fStyle;
102 UINT fMask;
103 COLORREF clrFore;
104 COLORREF clrBack;
105 INT iImage;
106 HWND hwndChild;
107 UINT cxMinChild; /* valid if _CHILDSIZE */
108 UINT cyMinChild; /* valid if _CHILDSIZE */
109 UINT cx; /* valid if _SIZE */
110 HBITMAP hbmBack;
111 UINT wID;
112 UINT cyChild; /* valid if _CHILDSIZE */
113 UINT cyMaxChild; /* valid if _CHILDSIZE */
114 UINT cyIntegral; /* valid if _CHILDSIZE */
115 UINT cxIdeal;
116 LPARAM lParam;
117 UINT cxHeader;
119 INT cxEffective; /* current cx for band */
120 UINT lcx; /* minimum cx for band */
121 UINT lcy; /* minimum cy for band */
123 INT iRow; /* zero-based index of the row this band assigned to */
124 UINT fStatus; /* status flags, reset only by _Validate */
125 UINT fDraw; /* drawing flags, reset only by _Layout */
126 UINT uCDret; /* last return from NM_CUSTOMDRAW */
127 RECT rcBand; /* calculated band rectangle - coordinates swapped for CCS_VERT */
128 RECT rcGripper; /* calculated gripper rectangle */
129 RECT rcCapImage; /* calculated caption image rectangle */
130 RECT rcCapText; /* calculated caption text rectangle */
131 RECT rcChild; /* calculated child rectangle */
132 RECT rcChevron; /* calculated chevron rectangle */
134 LPWSTR lpText;
135 HWND hwndPrevParent;
136 } REBAR_BAND;
138 /* fStatus flags */
139 #define HAS_GRIPPER 0x00000001
140 #define HAS_IMAGE 0x00000002
141 #define HAS_TEXT 0x00000004
143 /* fDraw flags */
144 #define DRAW_GRIPPER 0x00000001
145 #define DRAW_IMAGE 0x00000002
146 #define DRAW_TEXT 0x00000004
147 #define DRAW_CHEVRONHOT 0x00000040
148 #define DRAW_CHEVRONPUSHED 0x00000080
149 #define NTF_INVALIDATE 0x01000000
151 typedef struct
153 COLORREF clrBk; /* background color */
154 COLORREF clrText; /* text color */
155 COLORREF clrBtnText; /* system color for BTNTEXT */
156 COLORREF clrBtnFace; /* system color for BTNFACE */
157 HIMAGELIST himl; /* handle to imagelist */
158 UINT uNumBands; /* # of bands in rebar (first=0, last=uNumBands-1 */
159 UINT uNumRows; /* # of rows of bands (first=1, last=uNumRows */
160 HWND hwndSelf; /* handle of REBAR window itself */
161 HWND hwndToolTip; /* handle to the tool tip control */
162 HWND hwndNotify; /* notification window (parent) */
163 HFONT hDefaultFont;
164 HFONT hFont; /* handle to the rebar's font */
165 SIZE imageSize; /* image size (image list) */
166 DWORD dwStyle; /* window style */
167 DWORD orgStyle; /* original style (dwStyle may change) */
168 SIZE calcSize; /* calculated rebar size - coordinates swapped for CCS_VERT */
169 BOOL bUnicode; /* TRUE if parent wants notify in W format */
170 BOOL DoRedraw; /* TRUE to actually draw bands */
171 UINT fStatus; /* Status flags (see below) */
172 HCURSOR hcurArrow; /* handle to the arrow cursor */
173 HCURSOR hcurHorz; /* handle to the EW cursor */
174 HCURSOR hcurVert; /* handle to the NS cursor */
175 HCURSOR hcurDrag; /* handle to the drag cursor */
176 INT iVersion; /* version number */
177 POINT dragStart; /* x,y of button down */
178 POINT dragNow; /* x,y of this MouseMove */
179 INT iOldBand; /* last band that had the mouse cursor over it */
180 INT ihitoffset; /* offset of hotspot from gripper.left */
181 INT ichevronhotBand; /* last band that had a hot chevron */
182 INT iGrabbedBand;/* band number of band whose gripper was grabbed */
184 REBAR_BAND *bands; /* pointer to the array of rebar bands */
185 } REBAR_INFO;
187 /* fStatus flags */
188 #define BEGIN_DRAG_ISSUED 0x00000001
189 #define AUTO_RESIZE 0x00000002
190 #define BAND_NEEDS_REDRAW 0x00000020
192 /* used by Windows to mark that the header size has been set by the user and shouldn't be changed */
193 #define RBBS_UNDOC_FIXEDHEADER 0x40000000
195 /* ---- REBAR layout constants. Mostly determined by ---- */
196 /* ---- experiment on WIN 98. ---- */
198 /* Width (or height) of separators between bands (either horz. or */
199 /* vert.). True only if RBS_BANDBORDERS is set */
200 #define SEP_WIDTH_SIZE 2
201 #define SEP_WIDTH ((infoPtr->dwStyle & RBS_BANDBORDERS) ? SEP_WIDTH_SIZE : 0)
203 /* Blank (background color) space between Gripper (if present) */
204 /* and next item (image, text, or window). Always present */
205 #define REBAR_ALWAYS_SPACE 4
207 /* Blank (background color) space after Image (if present). */
208 #define REBAR_POST_IMAGE 2
210 /* Blank (background color) space after Text (if present). */
211 #define REBAR_POST_TEXT 4
213 /* Height of vertical gripper in a CCS_VERT rebar. */
214 #define GRIPPER_HEIGHT 16
216 /* Blank (background color) space before Gripper (if present). */
217 #define REBAR_PRE_GRIPPER 2
219 /* Width (of normal vertical gripper) or height (of horz. gripper) */
220 /* if present. */
221 #define GRIPPER_WIDTH 3
223 /* Width of the chevron button if present */
224 #define CHEVRON_WIDTH 10
226 /* the gap between the child and the next band */
227 #define REBAR_POST_CHILD 4
229 /* Height of divider for Rebar if not disabled (CCS_NODIVIDER) */
230 /* either top or bottom */
231 #define REBAR_DIVIDER 2
233 /* height of a rebar without a child */
234 #define REBAR_NO_CHILD_HEIGHT 4
236 /* minimum vertical height of a normal bar */
237 /* or minimum width of a CCS_VERT bar - from experiment on Win2k */
238 #define REBAR_MINSIZE 23
240 /* This is the increment that is used over the band height */
241 #define REBARSPACE(a) ((a->fStyle & RBBS_CHILDEDGE) ? 2*REBAR_DIVIDER : 0)
243 /* ---- End of REBAR layout constants. ---- */
245 #define RB_GETBANDINFO_OLD (WM_USER+5) /* obsoleted after IE3, but we have to support it anyway */
247 /* The following define determines if a given band is hidden */
248 #define HIDDENBAND(a) (((a)->fStyle & RBBS_HIDDEN) || \
249 ((infoPtr->dwStyle & CCS_VERT) && \
250 ((a)->fStyle & RBBS_NOVERT)))
252 #define REBAR_GetInfoPtr(wndPtr) ((REBAR_INFO *)GetWindowLongPtrW (hwnd, 0))
254 static LRESULT REBAR_NotifyFormat(REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam);
257 /* "constant values" retrieved when DLL was initialized */
258 /* FIXME we do this when the classes are registered. */
259 static UINT mindragx = 0;
260 static UINT mindragy = 0;
262 static const char * const band_stylename[] = {
263 "RBBS_BREAK", /* 0001 */
264 "RBBS_FIXEDSIZE", /* 0002 */
265 "RBBS_CHILDEDGE", /* 0004 */
266 "RBBS_HIDDEN", /* 0008 */
267 "RBBS_NOVERT", /* 0010 */
268 "RBBS_FIXEDBMP", /* 0020 */
269 "RBBS_VARIABLEHEIGHT", /* 0040 */
270 "RBBS_GRIPPERALWAYS", /* 0080 */
271 "RBBS_NOGRIPPER", /* 0100 */
272 NULL };
274 static const char * const band_maskname[] = {
275 "RBBIM_STYLE", /* 0x00000001 */
276 "RBBIM_COLORS", /* 0x00000002 */
277 "RBBIM_TEXT", /* 0x00000004 */
278 "RBBIM_IMAGE", /* 0x00000008 */
279 "RBBIM_CHILD", /* 0x00000010 */
280 "RBBIM_CHILDSIZE", /* 0x00000020 */
281 "RBBIM_SIZE", /* 0x00000040 */
282 "RBBIM_BACKGROUND", /* 0x00000080 */
283 "RBBIM_ID", /* 0x00000100 */
284 "RBBIM_IDEALSIZE", /* 0x00000200 */
285 "RBBIM_LPARAM", /* 0x00000400 */
286 "RBBIM_HEADERSIZE", /* 0x00000800 */
287 NULL };
290 static CHAR line[200];
292 static const WCHAR themeClass[] = { 'R','e','b','a','r',0 };
294 static CHAR *
295 REBAR_FmtStyle( UINT style)
297 INT i = 0;
299 *line = 0;
300 while (band_stylename[i]) {
301 if (style & (1<<i)) {
302 if (*line != 0) strcat(line, " | ");
303 strcat(line, band_stylename[i]);
305 i++;
307 return line;
311 static CHAR *
312 REBAR_FmtMask( UINT mask)
314 INT i = 0;
316 *line = 0;
317 while (band_maskname[i]) {
318 if (mask & (1<<i)) {
319 if (*line != 0) strcat(line, " | ");
320 strcat(line, band_maskname[i]);
322 i++;
324 return line;
328 static VOID
329 REBAR_DumpBandInfo(const REBARBANDINFOW *pB)
331 if( !TRACE_ON(rebar) ) return;
332 TRACE("band info: ");
333 if (pB->fMask & RBBIM_ID)
334 TRACE("ID=%u, ", pB->wID);
335 TRACE("size=%u, child=%p", pB->cbSize, pB->hwndChild);
336 if (pB->fMask & RBBIM_COLORS)
337 TRACE(", clrF=0x%06x, clrB=0x%06x", pB->clrFore, pB->clrBack);
338 TRACE("\n");
340 TRACE("band info: mask=0x%08x (%s)\n", pB->fMask, REBAR_FmtMask(pB->fMask));
341 if (pB->fMask & RBBIM_STYLE)
342 TRACE("band info: style=0x%08x (%s)\n", pB->fStyle, REBAR_FmtStyle(pB->fStyle));
343 if (pB->fMask & (RBBIM_SIZE | RBBIM_IDEALSIZE | RBBIM_HEADERSIZE | RBBIM_LPARAM )) {
344 TRACE("band info:");
345 if (pB->fMask & RBBIM_SIZE)
346 TRACE(" cx=%u", pB->cx);
347 if (pB->fMask & RBBIM_IDEALSIZE)
348 TRACE(" xIdeal=%u", pB->cxIdeal);
349 if (pB->fMask & RBBIM_HEADERSIZE)
350 TRACE(" xHeader=%u", pB->cxHeader);
351 if (pB->fMask & RBBIM_LPARAM)
352 TRACE(" lParam=0x%08lx", pB->lParam);
353 TRACE("\n");
355 if (pB->fMask & RBBIM_CHILDSIZE)
356 TRACE("band info: xMin=%u, yMin=%u, yChild=%u, yMax=%u, yIntgl=%u\n",
357 pB->cxMinChild,
358 pB->cyMinChild, pB->cyChild, pB->cyMaxChild, pB->cyIntegral);
361 static VOID
362 REBAR_DumpBand (const REBAR_INFO *iP)
364 REBAR_BAND *pB;
365 UINT i;
367 if(! TRACE_ON(rebar) ) return;
369 TRACE("hwnd=%p: color=%08x/%08x, bands=%u, rows=%u, cSize=%d,%d\n",
370 iP->hwndSelf, iP->clrText, iP->clrBk, iP->uNumBands, iP->uNumRows,
371 iP->calcSize.cx, iP->calcSize.cy);
372 TRACE("hwnd=%p: flags=%08x, dragStart=%d,%d, dragNow=%d,%d, iGrabbedBand=%d\n",
373 iP->hwndSelf, iP->fStatus, iP->dragStart.x, iP->dragStart.y,
374 iP->dragNow.x, iP->dragNow.y,
375 iP->iGrabbedBand);
376 TRACE("hwnd=%p: style=%08x, notify in Unicode=%s, redraw=%s\n",
377 iP->hwndSelf, iP->dwStyle, (iP->bUnicode)?"TRUE":"FALSE",
378 (iP->DoRedraw)?"TRUE":"FALSE");
379 for (i = 0; i < iP->uNumBands; i++) {
380 pB = &iP->bands[i];
381 TRACE("band # %u:", i);
382 if (pB->fMask & RBBIM_ID)
383 TRACE(" ID=%u", pB->wID);
384 if (pB->fMask & RBBIM_CHILD)
385 TRACE(" child=%p", pB->hwndChild);
386 if (pB->fMask & RBBIM_COLORS)
387 TRACE(" clrF=0x%06x clrB=0x%06x", pB->clrFore, pB->clrBack);
388 TRACE("\n");
389 TRACE("band # %u: mask=0x%08x (%s)\n", i, pB->fMask, REBAR_FmtMask(pB->fMask));
390 if (pB->fMask & RBBIM_STYLE)
391 TRACE("band # %u: style=0x%08x (%s)\n",
392 i, pB->fStyle, REBAR_FmtStyle(pB->fStyle));
393 TRACE("band # %u: xHeader=%u",
394 i, pB->cxHeader);
395 if (pB->fMask & (RBBIM_SIZE | RBBIM_IDEALSIZE | RBBIM_LPARAM )) {
396 if (pB->fMask & RBBIM_SIZE)
397 TRACE(" cx=%u", pB->cx);
398 if (pB->fMask & RBBIM_IDEALSIZE)
399 TRACE(" xIdeal=%u", pB->cxIdeal);
400 if (pB->fMask & RBBIM_LPARAM)
401 TRACE(" lParam=0x%08lx", pB->lParam);
403 TRACE("\n");
404 if (RBBIM_CHILDSIZE)
405 TRACE("band # %u: xMin=%u, yMin=%u, yChild=%u, yMax=%u, yIntgl=%u\n",
406 i, pB->cxMinChild, pB->cyMinChild, pB->cyChild, pB->cyMaxChild, pB->cyIntegral);
407 if (pB->fMask & RBBIM_TEXT)
408 TRACE("band # %u: text=%s\n",
409 i, (pB->lpText) ? debugstr_w(pB->lpText) : "(null)");
410 TRACE("band # %u: lcx=%u, cxEffective=%u, lcy=%u\n",
411 i, pB->lcx, pB->cxEffective, pB->lcy);
412 TRACE("band # %u: fStatus=%08x, fDraw=%08x, Band=(%s), Grip=(%s)\n",
413 i, pB->fStatus, pB->fDraw, wine_dbgstr_rect(&pB->rcBand),
414 wine_dbgstr_rect(&pB->rcGripper));
415 TRACE("band # %u: Img=(%s), Txt=(%s), Child=(%s)\n",
416 i, wine_dbgstr_rect(&pB->rcCapImage),
417 wine_dbgstr_rect(&pB->rcCapText), wine_dbgstr_rect(&pB->rcChild));
422 /* dest can be equal to src */
423 static void translate_rect(const REBAR_INFO *infoPtr, RECT *dest, const RECT *src)
425 if (infoPtr->dwStyle & CCS_VERT) {
426 int tmp;
427 tmp = src->left;
428 dest->left = src->top;
429 dest->top = tmp;
431 tmp = src->right;
432 dest->right = src->bottom;
433 dest->bottom = tmp;
434 } else {
435 *dest = *src;
439 static int get_rect_cx(const REBAR_INFO *infoPtr, const RECT *lpRect)
441 if (infoPtr->dwStyle & CCS_VERT)
442 return lpRect->bottom - lpRect->top;
443 return lpRect->right - lpRect->left;
446 static int get_rect_cy(const REBAR_INFO *infoPtr, const RECT *lpRect)
448 if (infoPtr->dwStyle & CCS_VERT)
449 return lpRect->right - lpRect->left;
450 return lpRect->bottom - lpRect->top;
453 static void round_child_height(REBAR_BAND *lpBand, int cyHeight)
455 int cy = 0;
456 if (lpBand->cyIntegral == 0)
457 return;
458 cy = max(cyHeight - (int)lpBand->cyMinChild, 0);
459 cy = lpBand->cyMinChild + (cy/lpBand->cyIntegral) * lpBand->cyIntegral;
460 cy = min(cy, lpBand->cyMaxChild);
461 lpBand->cyChild = cy;
464 static void
465 REBAR_DrawChevron (HDC hdc, INT left, INT top, INT colorRef)
467 INT x, y;
468 HPEN hPen, hOldPen;
470 if (!(hPen = CreatePen( PS_SOLID, 1, GetSysColor( colorRef )))) return;
471 hOldPen = SelectObject ( hdc, hPen );
472 x = left + 2;
473 y = top;
474 MoveToEx (hdc, x, y, NULL);
475 LineTo (hdc, x+5, y++); x++;
476 MoveToEx (hdc, x, y, NULL);
477 LineTo (hdc, x+3, y++); x++;
478 MoveToEx (hdc, x, y, NULL);
479 LineTo (hdc, x+1, y++);
480 SelectObject( hdc, hOldPen );
481 DeleteObject( hPen );
484 static HWND
485 REBAR_GetNotifyParent (const REBAR_INFO *infoPtr)
487 HWND parent, owner;
489 parent = infoPtr->hwndNotify;
490 if (!parent) {
491 parent = GetParent (infoPtr->hwndSelf);
492 owner = GetWindow (infoPtr->hwndSelf, GW_OWNER);
493 if (owner) parent = owner;
495 return parent;
499 static INT
500 REBAR_Notify (NMHDR *nmhdr, const REBAR_INFO *infoPtr, UINT code)
502 HWND parent;
504 parent = REBAR_GetNotifyParent (infoPtr);
505 nmhdr->idFrom = GetDlgCtrlID (infoPtr->hwndSelf);
506 nmhdr->hwndFrom = infoPtr->hwndSelf;
507 nmhdr->code = code;
509 TRACE("window %p, code=%08x, via %s\n", parent, code, (infoPtr->bUnicode)?"Unicode":"ANSI");
511 return SendMessageW(parent, WM_NOTIFY, nmhdr->idFrom, (LPARAM)nmhdr);
514 static INT
515 REBAR_Notify_NMREBAR (const REBAR_INFO *infoPtr, UINT uBand, UINT code)
517 NMREBAR notify_rebar;
518 REBAR_BAND *lpBand;
520 notify_rebar.dwMask = 0;
521 if (uBand!=-1) {
522 lpBand = &infoPtr->bands[uBand];
523 if (lpBand->fMask & RBBIM_ID) {
524 notify_rebar.dwMask |= RBNM_ID;
525 notify_rebar.wID = lpBand->wID;
527 if (lpBand->fMask & RBBIM_LPARAM) {
528 notify_rebar.dwMask |= RBNM_LPARAM;
529 notify_rebar.lParam = lpBand->lParam;
531 if (lpBand->fMask & RBBIM_STYLE) {
532 notify_rebar.dwMask |= RBNM_STYLE;
533 notify_rebar.fStyle = lpBand->fStyle;
536 notify_rebar.uBand = uBand;
537 return REBAR_Notify ((NMHDR *)&notify_rebar, infoPtr, code);
540 static VOID
541 REBAR_DrawBand (HDC hdc, const REBAR_INFO *infoPtr, REBAR_BAND *lpBand)
543 HFONT hOldFont = 0;
544 INT oldBkMode = 0;
545 NMCUSTOMDRAW nmcd;
546 HTHEME theme = GetWindowTheme (infoPtr->hwndSelf);
547 RECT rcBand;
549 translate_rect(infoPtr, &rcBand, &lpBand->rcBand);
551 if (lpBand->fDraw & DRAW_TEXT) {
552 hOldFont = SelectObject (hdc, infoPtr->hFont);
553 oldBkMode = SetBkMode (hdc, TRANSPARENT);
556 /* should test for CDRF_NOTIFYITEMDRAW here */
557 nmcd.dwDrawStage = CDDS_ITEMPREPAINT;
558 nmcd.hdc = hdc;
559 nmcd.rc = rcBand;
560 nmcd.rc.right = lpBand->rcCapText.right;
561 nmcd.rc.bottom = lpBand->rcCapText.bottom;
562 nmcd.dwItemSpec = lpBand->wID;
563 nmcd.uItemState = 0;
564 nmcd.lItemlParam = lpBand->lParam;
565 lpBand->uCDret = REBAR_Notify ((NMHDR *)&nmcd, infoPtr, NM_CUSTOMDRAW);
566 if (lpBand->uCDret == CDRF_SKIPDEFAULT) {
567 if (oldBkMode != TRANSPARENT)
568 SetBkMode (hdc, oldBkMode);
569 SelectObject (hdc, hOldFont);
570 return;
573 /* draw gripper */
574 if (lpBand->fDraw & DRAW_GRIPPER)
576 if (theme)
578 RECT rcGripper = lpBand->rcGripper;
579 int partId = (infoPtr->dwStyle & CCS_VERT) ? RP_GRIPPERVERT : RP_GRIPPER;
580 GetThemeBackgroundExtent (theme, hdc, partId, 0, &rcGripper, &rcGripper);
581 OffsetRect (&rcGripper, lpBand->rcGripper.left - rcGripper.left,
582 lpBand->rcGripper.top - rcGripper.top);
583 DrawThemeBackground (theme, hdc, partId, 0, &rcGripper, NULL);
585 else
586 DrawEdge (hdc, &lpBand->rcGripper, BDR_RAISEDINNER, BF_RECT | BF_MIDDLE);
589 /* draw caption image */
590 if (lpBand->fDraw & DRAW_IMAGE) {
591 POINT pt;
593 /* center image */
594 pt.y = (lpBand->rcCapImage.bottom + lpBand->rcCapImage.top - infoPtr->imageSize.cy)/2;
595 pt.x = (lpBand->rcCapImage.right + lpBand->rcCapImage.left - infoPtr->imageSize.cx)/2;
597 ImageList_Draw (infoPtr->himl, lpBand->iImage, hdc,
598 pt.x, pt.y,
599 ILD_TRANSPARENT);
602 /* draw caption text */
603 if (lpBand->fDraw & DRAW_TEXT) {
604 /* need to handle CDRF_NEWFONT here */
605 INT oldBkMode = SetBkMode (hdc, TRANSPARENT);
606 COLORREF oldcolor = CLR_NONE;
607 COLORREF new;
608 if (lpBand->clrFore != CLR_NONE) {
609 new = (lpBand->clrFore == CLR_DEFAULT) ? infoPtr->clrBtnText :
610 lpBand->clrFore;
611 oldcolor = SetTextColor (hdc, new);
613 DrawTextW (hdc, lpBand->lpText, -1, &lpBand->rcCapText,
614 DT_CENTER | DT_VCENTER | DT_SINGLELINE);
615 if (oldBkMode != TRANSPARENT)
616 SetBkMode (hdc, oldBkMode);
617 if (lpBand->clrFore != CLR_NONE)
618 SetTextColor (hdc, oldcolor);
619 SelectObject (hdc, hOldFont);
622 if (!IsRectEmpty(&lpBand->rcChevron))
624 if (theme)
626 int stateId;
627 if (lpBand->fDraw & DRAW_CHEVRONPUSHED)
628 stateId = CHEVS_PRESSED;
629 else if (lpBand->fDraw & DRAW_CHEVRONHOT)
630 stateId = CHEVS_HOT;
631 else
632 stateId = CHEVS_NORMAL;
633 DrawThemeBackground (theme, hdc, RP_CHEVRON, stateId, &lpBand->rcChevron, NULL);
635 else
637 if (lpBand->fDraw & DRAW_CHEVRONPUSHED)
639 DrawEdge(hdc, &lpBand->rcChevron, BDR_SUNKENOUTER, BF_RECT | BF_MIDDLE);
640 REBAR_DrawChevron(hdc, lpBand->rcChevron.left+1, lpBand->rcChevron.top + 11, COLOR_WINDOWFRAME);
642 else if (lpBand->fDraw & DRAW_CHEVRONHOT)
644 DrawEdge(hdc, &lpBand->rcChevron, BDR_RAISEDINNER, BF_RECT | BF_MIDDLE);
645 REBAR_DrawChevron(hdc, lpBand->rcChevron.left, lpBand->rcChevron.top + 10, COLOR_WINDOWFRAME);
647 else
648 REBAR_DrawChevron(hdc, lpBand->rcChevron.left, lpBand->rcChevron.top + 10, COLOR_WINDOWFRAME);
652 if (lpBand->uCDret == (CDRF_NOTIFYPOSTPAINT | CDRF_NOTIFYITEMDRAW)) {
653 nmcd.dwDrawStage = CDDS_ITEMPOSTPAINT;
654 nmcd.hdc = hdc;
655 nmcd.rc = rcBand;
656 nmcd.rc.right = lpBand->rcCapText.right;
657 nmcd.rc.bottom = lpBand->rcCapText.bottom;
658 nmcd.dwItemSpec = lpBand->wID;
659 nmcd.uItemState = 0;
660 nmcd.lItemlParam = lpBand->lParam;
661 lpBand->uCDret = REBAR_Notify ((NMHDR *)&nmcd, infoPtr, NM_CUSTOMDRAW);
666 static VOID
667 REBAR_Refresh (const REBAR_INFO *infoPtr, HDC hdc)
669 REBAR_BAND *lpBand;
670 UINT i;
672 if (!infoPtr->DoRedraw) return;
674 for (i = 0; i < infoPtr->uNumBands; i++) {
675 lpBand = &infoPtr->bands[i];
677 if (HIDDENBAND(lpBand)) continue;
679 /* now draw the band */
680 TRACE("[%p] drawing band %i, flags=%08x\n",
681 infoPtr->hwndSelf, i, lpBand->fDraw);
682 REBAR_DrawBand (hdc, infoPtr, lpBand);
688 static void
689 REBAR_CalcHorzBand (const REBAR_INFO *infoPtr, UINT rstart, UINT rend)
690 /* Function: this routine initializes all the rectangles in */
691 /* each band in a row to fit in the adjusted rcBand rect. */
692 /* *** Supports only Horizontal bars. *** */
694 REBAR_BAND *lpBand;
695 UINT i, xoff, yoff;
696 RECT work;
698 for(i=rstart; i<rend; i++){
699 lpBand = &infoPtr->bands[i];
700 if (HIDDENBAND(lpBand)) {
701 SetRect (&lpBand->rcChild,
702 lpBand->rcBand.right, lpBand->rcBand.top,
703 lpBand->rcBand.right, lpBand->rcBand.bottom);
704 continue;
707 /* set initial gripper rectangle */
708 SetRect (&lpBand->rcGripper, lpBand->rcBand.left, lpBand->rcBand.top,
709 lpBand->rcBand.left, lpBand->rcBand.bottom);
711 /* calculate gripper rectangle */
712 if ( lpBand->fStatus & HAS_GRIPPER) {
713 lpBand->fDraw |= DRAW_GRIPPER;
714 lpBand->rcGripper.left += REBAR_PRE_GRIPPER;
715 lpBand->rcGripper.right = lpBand->rcGripper.left + GRIPPER_WIDTH;
716 lpBand->rcGripper.top += 2;
717 lpBand->rcGripper.bottom -= 2;
719 SetRect (&lpBand->rcCapImage,
720 lpBand->rcGripper.right+REBAR_ALWAYS_SPACE, lpBand->rcBand.top,
721 lpBand->rcGripper.right+REBAR_ALWAYS_SPACE, lpBand->rcBand.bottom);
723 else { /* no gripper will be drawn */
724 xoff = 0;
725 if (lpBand->fStatus & (HAS_IMAGE | HAS_TEXT))
726 /* if no gripper but either image or text, then leave space */
727 xoff = REBAR_ALWAYS_SPACE;
728 SetRect (&lpBand->rcCapImage,
729 lpBand->rcBand.left+xoff, lpBand->rcBand.top,
730 lpBand->rcBand.left+xoff, lpBand->rcBand.bottom);
733 /* image is visible */
734 if (lpBand->fStatus & HAS_IMAGE) {
735 lpBand->fDraw |= DRAW_IMAGE;
736 lpBand->rcCapImage.right += infoPtr->imageSize.cx;
737 lpBand->rcCapImage.bottom = lpBand->rcCapImage.top + infoPtr->imageSize.cy;
739 /* set initial caption text rectangle */
740 SetRect (&lpBand->rcCapText,
741 lpBand->rcCapImage.right+REBAR_POST_IMAGE, lpBand->rcBand.top+1,
742 lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.bottom-1);
744 else {
745 /* set initial caption text rectangle */
746 SetRect (&lpBand->rcCapText, lpBand->rcCapImage.right, lpBand->rcBand.top+1,
747 lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.bottom-1);
750 /* text is visible */
751 if ((lpBand->fStatus & HAS_TEXT) && !(lpBand->fStyle & RBBS_HIDETITLE)) {
752 lpBand->fDraw |= DRAW_TEXT;
753 lpBand->rcCapText.right = max(lpBand->rcCapText.left,
754 lpBand->rcCapText.right-REBAR_POST_TEXT);
757 /* set initial child window rectangle if there is a child */
758 if (lpBand->hwndChild != NULL) {
759 int cyBand = lpBand->rcBand.bottom - lpBand->rcBand.top;
760 yoff = (cyBand - lpBand->cyChild) / 2;
761 SetRect (&lpBand->rcChild,
762 lpBand->rcBand.left + lpBand->cxHeader, lpBand->rcBand.top + yoff,
763 lpBand->rcBand.right - REBAR_POST_CHILD, lpBand->rcBand.top + yoff + lpBand->cyChild);
764 if ((lpBand->fStyle & RBBS_USECHEVRON) && (lpBand->rcChild.right - lpBand->rcChild.left < lpBand->cxIdeal))
766 lpBand->rcChild.right -= CHEVRON_WIDTH;
767 SetRect(&lpBand->rcChevron, lpBand->rcChild.right,
768 lpBand->rcChild.top, lpBand->rcChild.right + CHEVRON_WIDTH,
769 lpBand->rcChild.bottom);
772 else {
773 SetRect (&lpBand->rcChild,
774 lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.top,
775 lpBand->rcBand.right, lpBand->rcBand.bottom);
778 /* flag if notify required and invalidate rectangle */
779 if (lpBand->fDraw & NTF_INVALIDATE) {
780 TRACE("invalidating (%d,%d)-(%d,%d)\n",
781 lpBand->rcBand.left,
782 lpBand->rcBand.top,
783 lpBand->rcBand.right + SEP_WIDTH,
784 lpBand->rcBand.bottom + SEP_WIDTH);
785 lpBand->fDraw &= ~NTF_INVALIDATE;
786 work = lpBand->rcBand;
787 work.right += SEP_WIDTH;
788 work.bottom += SEP_WIDTH;
789 InvalidateRect(infoPtr->hwndSelf, &work, TRUE);
797 static VOID
798 REBAR_CalcVertBand (const REBAR_INFO *infoPtr, UINT rstart, UINT rend)
799 /* Function: this routine initializes all the rectangles in */
800 /* each band in a row to fit in the adjusted rcBand rect. */
801 /* *** Supports only Vertical bars. *** */
803 REBAR_BAND *lpBand;
804 UINT i, xoff;
805 RECT work;
807 for(i=rstart; i<rend; i++){
808 RECT rcBand;
809 lpBand = &infoPtr->bands[i];
810 if (HIDDENBAND(lpBand)) continue;
812 translate_rect(infoPtr, &rcBand, &lpBand->rcBand);
814 /* set initial gripper rectangle */
815 SetRect (&lpBand->rcGripper, rcBand.left, rcBand.top, rcBand.right, rcBand.top);
817 /* calculate gripper rectangle */
818 if (lpBand->fStatus & HAS_GRIPPER) {
819 lpBand->fDraw |= DRAW_GRIPPER;
821 if (infoPtr->dwStyle & RBS_VERTICALGRIPPER) {
822 /* vertical gripper */
823 lpBand->rcGripper.left += 3;
824 lpBand->rcGripper.right = lpBand->rcGripper.left + GRIPPER_WIDTH;
825 lpBand->rcGripper.top += REBAR_PRE_GRIPPER;
826 lpBand->rcGripper.bottom = lpBand->rcGripper.top + GRIPPER_HEIGHT;
828 /* initialize Caption image rectangle */
829 SetRect (&lpBand->rcCapImage, rcBand.left,
830 lpBand->rcGripper.bottom + REBAR_ALWAYS_SPACE,
831 rcBand.right,
832 lpBand->rcGripper.bottom + REBAR_ALWAYS_SPACE);
834 else {
835 /* horizontal gripper */
836 lpBand->rcGripper.left += 2;
837 lpBand->rcGripper.right -= 2;
838 lpBand->rcGripper.top += REBAR_PRE_GRIPPER;
839 lpBand->rcGripper.bottom = lpBand->rcGripper.top + GRIPPER_WIDTH;
841 /* initialize Caption image rectangle */
842 SetRect (&lpBand->rcCapImage, rcBand.left,
843 lpBand->rcGripper.bottom + REBAR_ALWAYS_SPACE,
844 rcBand.right,
845 lpBand->rcGripper.bottom + REBAR_ALWAYS_SPACE);
848 else { /* no gripper will be drawn */
849 xoff = 0;
850 if (lpBand->fStatus & (HAS_IMAGE | HAS_TEXT))
851 /* if no gripper but either image or text, then leave space */
852 xoff = REBAR_ALWAYS_SPACE;
853 /* initialize Caption image rectangle */
854 SetRect (&lpBand->rcCapImage,
855 rcBand.left, rcBand.top+xoff,
856 rcBand.right, rcBand.top+xoff);
859 /* image is visible */
860 if (lpBand->fStatus & HAS_IMAGE) {
861 lpBand->fDraw |= DRAW_IMAGE;
863 lpBand->rcCapImage.right = lpBand->rcCapImage.left + infoPtr->imageSize.cx;
864 lpBand->rcCapImage.bottom += infoPtr->imageSize.cy;
866 /* set initial caption text rectangle */
867 SetRect (&lpBand->rcCapText,
868 rcBand.left, lpBand->rcCapImage.bottom+REBAR_POST_IMAGE,
869 rcBand.right, rcBand.top+lpBand->cxHeader);
871 else {
872 /* set initial caption text rectangle */
873 SetRect (&lpBand->rcCapText,
874 rcBand.left, lpBand->rcCapImage.bottom,
875 rcBand.right, rcBand.top+lpBand->cxHeader);
878 /* text is visible */
879 if ((lpBand->fStatus & HAS_TEXT) && !(lpBand->fStyle & RBBS_HIDETITLE)) {
880 lpBand->fDraw |= DRAW_TEXT;
881 lpBand->rcCapText.bottom = max(lpBand->rcCapText.top,
882 lpBand->rcCapText.bottom);
885 /* set initial child window rectangle if there is a child */
886 if (lpBand->hwndChild != NULL) {
887 int cxBand = rcBand.right - rcBand.left;
888 xoff = (cxBand - lpBand->cyChild) / 2;
889 SetRect (&lpBand->rcChild,
890 rcBand.left + xoff, rcBand.top + lpBand->cxHeader,
891 rcBand.left + xoff + lpBand->cyChild, rcBand.bottom - REBAR_POST_CHILD);
893 else {
894 SetRect (&lpBand->rcChild,
895 rcBand.left, rcBand.top+lpBand->cxHeader,
896 rcBand.right, rcBand.bottom);
899 if (lpBand->fDraw & NTF_INVALIDATE) {
900 TRACE("invalidating (%d,%d)-(%d,%d)\n",
901 rcBand.left,
902 rcBand.top,
903 rcBand.right + SEP_WIDTH,
904 rcBand.bottom + SEP_WIDTH);
905 lpBand->fDraw &= ~NTF_INVALIDATE;
906 work = rcBand;
907 work.bottom += SEP_WIDTH;
908 work.right += SEP_WIDTH;
909 InvalidateRect(infoPtr->hwndSelf, &work, TRUE);
916 static VOID
917 REBAR_ForceResize (REBAR_INFO *infoPtr)
918 /* Function: This changes the size of the REBAR window to that */
919 /* calculated by REBAR_Layout. */
921 INT x, y, width, height;
922 INT xedge = 0, yedge = 0;
923 RECT rcSelf;
925 TRACE("new size [%d x %d]\n", infoPtr->calcSize.cx, infoPtr->calcSize.cy);
927 if (infoPtr->dwStyle & CCS_NORESIZE)
928 return;
930 if (infoPtr->dwStyle & WS_BORDER)
932 xedge = GetSystemMetrics(SM_CXEDGE);
933 yedge = GetSystemMetrics(SM_CYEDGE);
934 /* swap for CCS_VERT? */
937 /* compute rebar window rect in parent client coordinates */
938 GetWindowRect(infoPtr->hwndSelf, &rcSelf);
939 MapWindowPoints(HWND_DESKTOP, GetParent(infoPtr->hwndSelf), (LPPOINT)&rcSelf, 2);
940 translate_rect(infoPtr, &rcSelf, &rcSelf);
942 height = infoPtr->calcSize.cy + 2*yedge;
943 if (!(infoPtr->dwStyle & CCS_NOPARENTALIGN)) {
944 RECT rcParent;
946 x = -xedge;
947 width = infoPtr->calcSize.cx + 2*xedge;
948 y = 0; /* quiet compiler warning */
949 switch ( infoPtr->dwStyle & CCS_LAYOUT_MASK) {
950 case 0: /* shouldn't happen - see NCCreate */
951 case CCS_TOP:
952 y = ((infoPtr->dwStyle & CCS_NODIVIDER) ? 0 : REBAR_DIVIDER) - yedge;
953 break;
954 case CCS_NOMOVEY:
955 y = rcSelf.top;
956 break;
957 case CCS_BOTTOM:
958 GetClientRect(GetParent(infoPtr->hwndSelf), &rcParent);
959 translate_rect(infoPtr, &rcParent, &rcParent);
960 y = rcParent.bottom - infoPtr->calcSize.cy - yedge;
961 break;
964 else {
965 x = rcSelf.left;
966 /* As on Windows if the CCS_NODIVIDER is not present the control will move
967 * 2 pixel down after every layout */
968 y = rcSelf.top + ((infoPtr->dwStyle & CCS_NODIVIDER) ? 0 : REBAR_DIVIDER);
969 width = rcSelf.right - rcSelf.left;
972 TRACE("hwnd %p, style=%08x, setting at (%d,%d) for (%d,%d)\n",
973 infoPtr->hwndSelf, infoPtr->dwStyle, x, y, width, height);
975 /* Set flag to ignore next WM_SIZE message and resize the window */
976 infoPtr->fStatus |= AUTO_RESIZE;
977 if ((infoPtr->dwStyle & CCS_VERT) == 0)
978 SetWindowPos(infoPtr->hwndSelf, 0, x, y, width, height, SWP_NOZORDER);
979 else
980 SetWindowPos(infoPtr->hwndSelf, 0, y, x, height, width, SWP_NOZORDER);
981 infoPtr->fStatus &= ~AUTO_RESIZE;
985 static VOID
986 REBAR_MoveChildWindows (const REBAR_INFO *infoPtr, UINT start, UINT endplus)
988 static const WCHAR strComboBox[] = { 'C','o','m','b','o','B','o','x',0 };
989 REBAR_BAND *lpBand;
990 WCHAR szClassName[40];
991 UINT i;
992 NMREBARCHILDSIZE rbcz;
993 HDWP deferpos;
995 if (!(deferpos = BeginDeferWindowPos(infoPtr->uNumBands)))
996 ERR("BeginDeferWindowPos returned NULL\n");
998 for (i = start; i < endplus; i++) {
999 lpBand = &infoPtr->bands[i];
1001 if (HIDDENBAND(lpBand)) continue;
1002 if (lpBand->hwndChild) {
1003 TRACE("hwndChild = %p\n", lpBand->hwndChild);
1005 /* Always generate the RBN_CHILDSIZE even if child
1006 did not change */
1007 rbcz.uBand = i;
1008 rbcz.wID = lpBand->wID;
1009 rbcz.rcChild = lpBand->rcChild;
1010 translate_rect(infoPtr, &rbcz.rcBand, &lpBand->rcBand);
1011 if (infoPtr->dwStyle & CCS_VERT)
1012 rbcz.rcBand.top += lpBand->cxHeader;
1013 else
1014 rbcz.rcBand.left += lpBand->cxHeader;
1015 REBAR_Notify ((NMHDR *)&rbcz, infoPtr, RBN_CHILDSIZE);
1016 if (!EqualRect (&lpBand->rcChild, &rbcz.rcChild)) {
1017 TRACE("Child rect changed by NOTIFY for band %u\n", i);
1018 TRACE(" from (%s) to (%s)\n",
1019 wine_dbgstr_rect(&lpBand->rcChild),
1020 wine_dbgstr_rect(&rbcz.rcChild));
1021 lpBand->rcChild = rbcz.rcChild; /* *** ??? */
1024 /* native (IE4 in "Favorites" frame **1) does:
1025 * SetRect (&rc, -1, -1, -1, -1)
1026 * EqualRect (&rc,band->rc???)
1027 * if ret==0
1028 * CopyRect (band->rc????, &rc)
1029 * set flag outside of loop
1032 GetClassNameW (lpBand->hwndChild, szClassName, sizeof(szClassName)/sizeof(szClassName[0]));
1033 if (!lstrcmpW (szClassName, strComboBox) ||
1034 !lstrcmpW (szClassName, WC_COMBOBOXEXW)) {
1035 INT nEditHeight, yPos;
1036 RECT rc;
1038 /* special placement code for combo or comboex box */
1041 /* get size of edit line */
1042 GetWindowRect (lpBand->hwndChild, &rc);
1043 nEditHeight = rc.bottom - rc.top;
1044 yPos = (lpBand->rcChild.bottom + lpBand->rcChild.top - nEditHeight)/2;
1046 /* center combo box inside child area */
1047 TRACE("moving child (Combo(Ex)) %p to (%d,%d) for (%d,%d)\n",
1048 lpBand->hwndChild,
1049 lpBand->rcChild.left, yPos,
1050 lpBand->rcChild.right - lpBand->rcChild.left,
1051 nEditHeight);
1052 deferpos = DeferWindowPos (deferpos, lpBand->hwndChild, HWND_TOP,
1053 lpBand->rcChild.left,
1054 /*lpBand->rcChild.top*/ yPos,
1055 lpBand->rcChild.right - lpBand->rcChild.left,
1056 nEditHeight,
1057 SWP_NOZORDER);
1058 if (!deferpos)
1059 ERR("DeferWindowPos returned NULL\n");
1061 else {
1062 TRACE("moving child (Other) %p to (%d,%d) for (%d,%d)\n",
1063 lpBand->hwndChild,
1064 lpBand->rcChild.left, lpBand->rcChild.top,
1065 lpBand->rcChild.right - lpBand->rcChild.left,
1066 lpBand->rcChild.bottom - lpBand->rcChild.top);
1067 deferpos = DeferWindowPos (deferpos, lpBand->hwndChild, HWND_TOP,
1068 lpBand->rcChild.left,
1069 lpBand->rcChild.top,
1070 lpBand->rcChild.right - lpBand->rcChild.left,
1071 lpBand->rcChild.bottom - lpBand->rcChild.top,
1072 SWP_NOZORDER);
1073 if (!deferpos)
1074 ERR("DeferWindowPos returned NULL\n");
1078 if (!EndDeferWindowPos(deferpos))
1079 ERR("EndDeferWindowPos returned NULL\n");
1081 if (infoPtr->DoRedraw)
1082 UpdateWindow (infoPtr->hwndSelf);
1084 /* native (from **1 above) does:
1085 * UpdateWindow(rebar)
1086 * REBAR_ForceResize
1087 * RBN_HEIGHTCHANGE if necessary
1088 * if ret from any EqualRect was 0
1089 * Goto "BeginDeferWindowPos"
1094 static int next_band(const REBAR_INFO *infoPtr, int i)
1096 int n;
1097 for (n = i + 1; n < infoPtr->uNumBands; n++)
1098 if (!HIDDENBAND(&infoPtr->bands[n]))
1099 break;
1100 return n;
1103 static int prev_band(const REBAR_INFO *infoPtr, int i)
1105 int n;
1106 for (n = i - 1; n >= 0; n--)
1107 if (!HIDDENBAND(&infoPtr->bands[n]))
1108 break;
1109 return n;
1112 static int get_row_begin_for_band(const REBAR_INFO *infoPtr, INT iBand)
1114 int iLastBand = iBand;
1115 int iRow = infoPtr->bands[iBand].iRow;
1116 while ((iBand = prev_band(infoPtr, iBand)) >= 0) {
1117 if (infoPtr->bands[iBand].iRow != iRow)
1118 break;
1119 else
1120 iLastBand = iBand;
1122 return iLastBand;
1125 static int get_row_end_for_band(const REBAR_INFO *infoPtr, INT iBand)
1127 int iRow = infoPtr->bands[iBand].iRow;
1128 while ((iBand = next_band(infoPtr, iBand)) < infoPtr->uNumBands)
1129 if (infoPtr->bands[iBand].iRow != iRow)
1130 break;
1131 return iBand;
1134 static void REBAR_SetRowRectsX(const REBAR_INFO *infoPtr, INT iBeginBand, INT iEndBand)
1136 int xPos = 0, i;
1137 for (i = iBeginBand; i < iEndBand; i = next_band(infoPtr, i))
1139 REBAR_BAND *lpBand = &infoPtr->bands[i];
1141 lpBand = &infoPtr->bands[i];
1142 if (lpBand->rcBand.left != xPos || lpBand->rcBand.right != xPos + lpBand->cxEffective) {
1143 lpBand->fDraw |= NTF_INVALIDATE;
1144 TRACE("Setting rect %d to %d,%d\n", i, xPos, xPos + lpBand->cxEffective);
1145 lpBand->rcBand.left = xPos;
1146 lpBand->rcBand.right = xPos + lpBand->cxEffective;
1148 xPos += lpBand->cxEffective + SEP_WIDTH;
1152 /* The rationale of this function is probably as follows: if we have some space
1153 * to distribute we want to add it to a band on the right. However we don't want
1154 * to unminimize a minimized band so we search for a band that is big enough.
1155 * For some reason "big enough" is defined as bigger than the minimum size of the
1156 * first band in the row
1158 static REBAR_BAND *REBAR_FindBandToGrow(const REBAR_INFO *infoPtr, INT iBeginBand, INT iEndBand)
1160 INT iLcx = 0, i;
1162 iLcx = infoPtr->bands[iBeginBand].lcx;
1164 for (i = prev_band(infoPtr, iEndBand); i >= iBeginBand; i = prev_band(infoPtr, i))
1165 if (infoPtr->bands[i].cxEffective > iLcx && !(infoPtr->bands[i].fStyle&RBBS_FIXEDSIZE))
1166 break;
1168 if (i < iBeginBand)
1169 for (i = prev_band(infoPtr, iEndBand); i >= iBeginBand; i = prev_band(infoPtr, i))
1170 if (infoPtr->bands[i].lcx == iLcx)
1171 break;
1173 TRACE("Extra space for row [%d..%d) should be added to band %d\n", iBeginBand, iEndBand, i);
1174 return &infoPtr->bands[i];
1177 static int REBAR_ShrinkBandsRTL(const REBAR_INFO *infoPtr, INT iBeginBand, INT iEndBand, INT cxShrink, BOOL bEnforce)
1179 REBAR_BAND *lpBand;
1180 INT width, i;
1182 TRACE("Shrinking bands [%d..%d) by %d, right-to-left\n", iBeginBand, iEndBand, cxShrink);
1183 for (i = prev_band(infoPtr, iEndBand); i >= iBeginBand; i = prev_band(infoPtr, i))
1185 lpBand = &infoPtr->bands[i];
1187 width = max(lpBand->cxEffective - cxShrink, (int)lpBand->lcx);
1188 cxShrink -= lpBand->cxEffective - width;
1189 lpBand->cxEffective = width;
1190 if (bEnforce && lpBand->cx > lpBand->cxEffective)
1191 lpBand->cx = lpBand->cxEffective;
1192 if (cxShrink == 0)
1193 break;
1195 return cxShrink;
1199 static int REBAR_ShrinkBandsLTR(const REBAR_INFO *infoPtr, INT iBeginBand, INT iEndBand, INT cxShrink, BOOL bEnforce)
1201 REBAR_BAND *lpBand;
1202 INT width, i;
1204 TRACE("Shrinking bands [%d..%d) by %d, left-to-right\n", iBeginBand, iEndBand, cxShrink);
1205 for (i = iBeginBand; i < iEndBand; i = next_band(infoPtr, i))
1207 lpBand = &infoPtr->bands[i];
1209 width = max(lpBand->cxEffective - cxShrink, (int)lpBand->lcx);
1210 cxShrink -= lpBand->cxEffective - width;
1211 lpBand->cxEffective = width;
1212 if (bEnforce)
1213 lpBand->cx = lpBand->cxEffective;
1214 if (cxShrink == 0)
1215 break;
1217 return cxShrink;
1220 static int REBAR_SetBandsHeight(const REBAR_INFO *infoPtr, INT iBeginBand, INT iEndBand, INT yStart)
1222 REBAR_BAND *lpBand;
1223 int yMaxHeight = 0;
1224 int yPos = yStart;
1225 int row = infoPtr->bands[iBeginBand].iRow;
1226 int i;
1227 for (i = iBeginBand; i < iEndBand; i = next_band(infoPtr, i))
1229 lpBand = &infoPtr->bands[i];
1230 yMaxHeight = max(yMaxHeight, lpBand->lcy);
1232 TRACE("Bands [%d; %d) height: %d\n", iBeginBand, iEndBand, yMaxHeight);
1234 for (i = iBeginBand; i < iEndBand; i = next_band(infoPtr, i))
1236 lpBand = &infoPtr->bands[i];
1237 /* we may be called for multiple rows if RBS_VARHEIGHT not set */
1238 if (lpBand->iRow != row) {
1239 yPos += yMaxHeight + SEP_WIDTH;
1240 row = lpBand->iRow;
1243 if (lpBand->rcBand.top != yPos || lpBand->rcBand.bottom != yPos + yMaxHeight) {
1244 lpBand->fDraw |= NTF_INVALIDATE;
1245 lpBand->rcBand.top = yPos;
1246 lpBand->rcBand.bottom = yPos + yMaxHeight;
1247 TRACE("Band %d: %s\n", i, wine_dbgstr_rect(&lpBand->rcBand));
1250 return yPos + yMaxHeight;
1253 static void REBAR_LayoutRow(const REBAR_INFO *infoPtr, int iBeginBand, int iEndBand, int cx, int *piRow, int *pyPos)
1255 REBAR_BAND *lpBand;
1256 int i, extra;
1257 int width = 0;
1259 TRACE("Adjusting row [%d;%d). Width: %d\n", iBeginBand, iEndBand, cx);
1260 for (i = iBeginBand; i < iEndBand; i++)
1261 infoPtr->bands[i].iRow = *piRow;
1263 /* compute the extra space */
1264 for (i = iBeginBand; i < iEndBand; i = next_band(infoPtr, i))
1266 lpBand = &infoPtr->bands[i];
1267 if (i > iBeginBand)
1268 width += SEP_WIDTH;
1269 lpBand->cxEffective = max(lpBand->lcx, lpBand->cx);
1270 width += lpBand->cxEffective;
1273 extra = cx - width;
1274 TRACE("Extra space: %d\n", extra);
1275 if (extra < 0) {
1276 int ret = REBAR_ShrinkBandsRTL(infoPtr, iBeginBand, iEndBand, -extra, FALSE);
1277 if (ret > 0 && next_band(infoPtr, iBeginBand) != iEndBand) /* one band may be longer than expected... */
1278 ERR("Error layouting row %d - couldn't shrink for %d pixels (%d total shrink)\n", *piRow, ret, -extra);
1279 } else
1280 if (extra > 0) {
1281 lpBand = REBAR_FindBandToGrow(infoPtr, iBeginBand, iEndBand);
1282 lpBand->cxEffective += extra;
1285 REBAR_SetRowRectsX(infoPtr, iBeginBand, iEndBand);
1286 if (infoPtr->dwStyle & RBS_VARHEIGHT)
1288 if (*piRow > 0)
1289 *pyPos += SEP_WIDTH;
1290 *pyPos = REBAR_SetBandsHeight(infoPtr, iBeginBand, iEndBand, *pyPos);
1292 (*piRow)++;
1295 static VOID
1296 REBAR_Layout(REBAR_INFO *infoPtr, const RECT *lpRect)
1298 REBAR_BAND *lpBand;
1299 RECT rcAdj;
1300 SIZE oldSize;
1301 INT adjcx, adjcy, i;
1302 INT rowstart = 0;
1303 INT row = 0;
1304 INT xMin, yPos;
1305 INT cyTarget;
1306 const INT yInit = 0;
1308 cyTarget = 0;
1309 if (lpRect) {
1310 rcAdj = *lpRect;
1311 cyTarget = get_rect_cy(infoPtr, lpRect);
1312 } else if (infoPtr->dwStyle & (CCS_NORESIZE | CCS_NOPARENTALIGN) || GetParent(infoPtr->hwndSelf) == NULL)
1313 GetClientRect(infoPtr->hwndSelf, &rcAdj);
1314 else
1315 GetClientRect(GetParent(infoPtr->hwndSelf), &rcAdj);
1316 TRACE("adjustment rect is (%s)\n", wine_dbgstr_rect(&rcAdj));
1318 adjcx = get_rect_cx(infoPtr, &rcAdj);
1319 adjcy = get_rect_cy(infoPtr, &rcAdj);
1321 if (infoPtr->uNumBands == 0) {
1322 TRACE("No bands - setting size to (0,%d), vert: %lx\n", adjcx, infoPtr->dwStyle & CCS_VERT);
1323 infoPtr->calcSize.cx = adjcx;
1324 /* the calcSize.cy won't change for a 0 band rebar */
1325 infoPtr->uNumRows = 0;
1326 REBAR_ForceResize(infoPtr);
1327 return;
1330 yPos = yInit;
1331 xMin = 0;
1332 /* divide rows */
1333 i = 0;
1334 for (i = 0; i < infoPtr->uNumBands; i++)
1336 lpBand = &infoPtr->bands[i];
1337 if (HIDDENBAND(lpBand)) continue;
1339 if (i > rowstart && (lpBand->fStyle & RBBS_BREAK || xMin + lpBand->lcx > adjcx)) {
1340 TRACE("%s break on band %d\n", (lpBand->fStyle & RBBS_BREAK ? "Hard" : "Soft"), i - 1);
1341 REBAR_LayoutRow(infoPtr, rowstart, i, adjcx, &row, &yPos);
1342 rowstart = i;
1343 xMin = 0;
1345 else
1346 xMin += SEP_WIDTH;
1348 xMin += lpBand->lcx;
1350 REBAR_LayoutRow(infoPtr, rowstart, infoPtr->uNumBands, adjcx, &row, &yPos);
1352 if (!(infoPtr->dwStyle & RBS_VARHEIGHT))
1353 yPos = REBAR_SetBandsHeight(infoPtr, 0, infoPtr->uNumBands, yInit);
1355 infoPtr->uNumRows = row;
1357 if (infoPtr->dwStyle & CCS_VERT)
1358 REBAR_CalcVertBand(infoPtr, 0, infoPtr->uNumBands);
1359 else
1360 REBAR_CalcHorzBand(infoPtr, 0, infoPtr->uNumBands);
1361 /* now compute size of Rebar itself */
1362 oldSize = infoPtr->calcSize;
1364 infoPtr->calcSize.cx = adjcx;
1365 infoPtr->calcSize.cy = yPos;
1366 TRACE("calcsize size=(%d, %d), origheight=(%d,%d)\n",
1367 infoPtr->calcSize.cx, infoPtr->calcSize.cy,
1368 oldSize.cx, oldSize.cy);
1370 REBAR_DumpBand (infoPtr);
1371 REBAR_MoveChildWindows (infoPtr, 0, infoPtr->uNumBands);
1372 REBAR_ForceResize (infoPtr);
1374 /* note: after a RBN_HEIGHTCHANGE native sends once again all the RBN_CHILDSIZE
1375 * and does another ForceResize */
1376 if (oldSize.cy != infoPtr->calcSize.cy)
1378 NMHDR heightchange;
1379 REBAR_Notify(&heightchange, infoPtr, RBN_HEIGHTCHANGE);
1384 static VOID
1385 REBAR_ValidateBand (const REBAR_INFO *infoPtr, REBAR_BAND *lpBand)
1386 /* Function: This routine evaluates the band specs supplied */
1387 /* by the user and updates the following 5 fields in */
1388 /* the internal band structure: cxHeader, lcx, lcy, hcx, hcy*/
1390 UINT header=0;
1391 UINT textheight=0;
1392 UINT i, nonfixed;
1393 REBAR_BAND *tBand;
1395 lpBand->fStatus = 0;
1396 lpBand->lcx = 0;
1397 lpBand->lcy = 0;
1399 /* Data coming in from users into the cx... and cy... fields */
1400 /* may be bad, just garbage, because the user never clears */
1401 /* the fields. RB_{SET|INSERT}BAND{A|W} just passes the data */
1402 /* along if the fields exist in the input area. Here we must */
1403 /* determine if the data is valid. I have no idea how MS does */
1404 /* the validation, but it does because the RB_GETBANDINFO */
1405 /* returns a 0 when I know the sample program passed in an */
1406 /* address. Here I will use the algorithm that if the value */
1407 /* is greater than 65535 then it is bad and replace it with */
1408 /* a zero. Feel free to improve the algorithm. - GA 12/2000 */
1409 if (lpBand->cxMinChild > 65535) lpBand->cxMinChild = 0;
1410 if (lpBand->cyMinChild > 65535) lpBand->cyMinChild = 0;
1411 if (lpBand->cx > 65535) lpBand->cx = 0;
1412 if (lpBand->cyChild > 65535) lpBand->cyChild = 0;
1413 if (lpBand->cyIntegral > 65535) lpBand->cyIntegral = 0;
1414 if (lpBand->cxIdeal > 65535) lpBand->cxIdeal = 0;
1415 if (lpBand->cxHeader > 65535) lpBand->cxHeader = 0;
1417 /* TODO : we could try return to the caller if a value changed so that */
1418 /* a REBAR_Layout is needed. Till now the caller should call it */
1419 /* it always (we should also check what native does) */
1421 /* Header is where the image, text and gripper exist */
1422 /* in the band and precede the child window. */
1424 /* count number of non-FIXEDSIZE and non-Hidden bands */
1425 nonfixed = 0;
1426 for (i=0; i<infoPtr->uNumBands; i++){
1427 tBand = &infoPtr->bands[i];
1428 if (!HIDDENBAND(tBand) && !(tBand->fStyle & RBBS_FIXEDSIZE))
1429 nonfixed++;
1432 /* calculate gripper rectangle */
1433 if ( (!(lpBand->fStyle & RBBS_NOGRIPPER)) &&
1434 ( (lpBand->fStyle & RBBS_GRIPPERALWAYS) ||
1435 ( !(lpBand->fStyle & RBBS_FIXEDSIZE) && (nonfixed > 1)))
1437 lpBand->fStatus |= HAS_GRIPPER;
1438 if (infoPtr->dwStyle & CCS_VERT)
1439 if (infoPtr->dwStyle & RBS_VERTICALGRIPPER)
1440 header += (GRIPPER_HEIGHT + REBAR_PRE_GRIPPER);
1441 else
1442 header += (GRIPPER_WIDTH + REBAR_PRE_GRIPPER);
1443 else
1444 header += (REBAR_PRE_GRIPPER + GRIPPER_WIDTH);
1445 /* Always have 4 pixels before anything else */
1446 header += REBAR_ALWAYS_SPACE;
1449 /* image is visible */
1450 if ((lpBand->fMask & RBBIM_IMAGE) && (infoPtr->himl)) {
1451 lpBand->fStatus |= HAS_IMAGE;
1452 if (infoPtr->dwStyle & CCS_VERT) {
1453 header += (infoPtr->imageSize.cy + REBAR_POST_IMAGE);
1454 lpBand->lcy = infoPtr->imageSize.cx + 2;
1456 else {
1457 header += (infoPtr->imageSize.cx + REBAR_POST_IMAGE);
1458 lpBand->lcy = infoPtr->imageSize.cy + 2;
1462 /* text is visible */
1463 if ((lpBand->fMask & RBBIM_TEXT) && (lpBand->lpText) &&
1464 !(lpBand->fStyle & RBBS_HIDETITLE)) {
1465 HDC hdc = GetDC (0);
1466 HFONT hOldFont = SelectObject (hdc, infoPtr->hFont);
1467 SIZE size;
1469 lpBand->fStatus |= HAS_TEXT;
1470 GetTextExtentPoint32W (hdc, lpBand->lpText,
1471 lstrlenW (lpBand->lpText), &size);
1472 header += ((infoPtr->dwStyle & CCS_VERT) ? (size.cy + REBAR_POST_TEXT) : (size.cx + REBAR_POST_TEXT));
1473 textheight = (infoPtr->dwStyle & CCS_VERT) ? 0 : size.cy;
1475 SelectObject (hdc, hOldFont);
1476 ReleaseDC (0, hdc);
1479 /* if no gripper but either image or text, then leave space */
1480 if ((lpBand->fStatus & (HAS_IMAGE | HAS_TEXT)) &&
1481 !(lpBand->fStatus & HAS_GRIPPER)) {
1482 header += REBAR_ALWAYS_SPACE;
1485 /* check if user overrode the header value */
1486 if (!(lpBand->fStyle & RBBS_UNDOC_FIXEDHEADER))
1487 lpBand->cxHeader = header;
1490 /* Now compute minimum size of child window */
1491 lpBand->lcy = textheight;
1492 if (lpBand->hwndChild != NULL) {
1493 /* Set the .cy values for CHILDSIZE case */
1494 lpBand->lcy = max(lpBand->lcy, lpBand->cyChild + REBARSPACE(lpBand));
1495 TRACE("_CHILDSIZE\n");
1497 else
1498 lpBand->lcy = max(lpBand->lcy, REBAR_NO_CHILD_HEIGHT);
1500 lpBand->lcx = lpBand->cxMinChild + lpBand->cxHeader + REBAR_POST_CHILD;
1501 if (lpBand->fStyle & RBBS_USECHEVRON && lpBand->cxMinChild < lpBand->cxIdeal)
1502 lpBand->lcx += CHEVRON_WIDTH;
1505 static BOOL
1506 REBAR_CommonSetupBand(HWND hwnd, const REBARBANDINFOW *lprbbi, REBAR_BAND *lpBand)
1507 /* Function: This routine copies the supplied values from */
1508 /* user input (lprbbi) to the internal band structure. */
1509 /* It returns true if something changed and false if not. */
1511 BOOL bChanged = FALSE;
1513 lpBand->fMask |= lprbbi->fMask;
1515 if( (lprbbi->fMask & RBBIM_STYLE) &&
1516 (lpBand->fStyle != lprbbi->fStyle ) )
1518 lpBand->fStyle = lprbbi->fStyle;
1519 bChanged = TRUE;
1522 if( (lprbbi->fMask & RBBIM_COLORS) &&
1523 ( ( lpBand->clrFore != lprbbi->clrFore ) ||
1524 ( lpBand->clrBack != lprbbi->clrBack ) ) )
1526 lpBand->clrFore = lprbbi->clrFore;
1527 lpBand->clrBack = lprbbi->clrBack;
1528 bChanged = TRUE;
1531 if( (lprbbi->fMask & RBBIM_IMAGE) &&
1532 ( lpBand->iImage != lprbbi->iImage ) )
1534 lpBand->iImage = lprbbi->iImage;
1535 bChanged = TRUE;
1538 if( (lprbbi->fMask & RBBIM_CHILD) &&
1539 (lprbbi->hwndChild != lpBand->hwndChild ) )
1541 if (lprbbi->hwndChild) {
1542 lpBand->hwndChild = lprbbi->hwndChild;
1543 lpBand->hwndPrevParent =
1544 SetParent (lpBand->hwndChild, hwnd);
1545 /* below in trace from WinRAR */
1546 ShowWindow(lpBand->hwndChild, SW_SHOWNOACTIVATE | SW_SHOWNORMAL);
1547 /* above in trace from WinRAR */
1549 else {
1550 TRACE("child: %p prev parent: %p\n",
1551 lpBand->hwndChild, lpBand->hwndPrevParent);
1552 lpBand->hwndChild = 0;
1553 lpBand->hwndPrevParent = 0;
1555 bChanged = TRUE;
1558 if( (lprbbi->fMask & RBBIM_CHILDSIZE) &&
1559 ( (lpBand->cxMinChild != lprbbi->cxMinChild) ||
1560 (lpBand->cyMinChild != lprbbi->cyMinChild ) ||
1561 ( (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) &&
1562 ( (lpBand->cyChild != lprbbi->cyChild ) ||
1563 (lpBand->cyMaxChild != lprbbi->cyMaxChild ) ||
1564 (lpBand->cyIntegral != lprbbi->cyIntegral ) ) ) ||
1565 ( (lprbbi->cbSize < sizeof (REBARBANDINFOA)) &&
1566 ( (lpBand->cyChild ||
1567 lpBand->cyMaxChild ||
1568 lpBand->cyIntegral ) ) ) ) )
1570 lpBand->cxMinChild = lprbbi->cxMinChild;
1571 lpBand->cyMinChild = lprbbi->cyMinChild;
1572 /* These fields where added in WIN32_IE == 0x400 and are set only for RBBS_VARIABLEHEIGHT bands */
1573 if (lprbbi->cbSize >= sizeof (REBARBANDINFOA) && (lpBand->fStyle & RBBS_VARIABLEHEIGHT)) {
1574 lpBand->cyMaxChild = lprbbi->cyMaxChild;
1575 lpBand->cyIntegral = lprbbi->cyIntegral;
1577 lpBand->cyChild = lpBand->cyMinChild;
1578 round_child_height(lpBand, lprbbi->cyChild); /* try to increase cyChild */
1580 else {
1581 lpBand->cyChild = lpBand->cyMinChild;
1582 lpBand->cyMaxChild = 0x7fffffff;
1583 lpBand->cyIntegral = 0;
1585 bChanged = TRUE;
1588 if( (lprbbi->fMask & RBBIM_SIZE) &&
1589 (lpBand->cx != lprbbi->cx ) )
1591 lpBand->cx = lprbbi->cx;
1592 bChanged = TRUE;
1595 if( (lprbbi->fMask & RBBIM_BACKGROUND) &&
1596 ( lpBand->hbmBack != lprbbi->hbmBack ) )
1598 lpBand->hbmBack = lprbbi->hbmBack;
1599 bChanged = TRUE;
1602 if( (lprbbi->fMask & RBBIM_ID) &&
1603 (lpBand->wID != lprbbi->wID ) )
1605 lpBand->wID = lprbbi->wID;
1606 bChanged = TRUE;
1609 /* check for additional data */
1610 if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
1611 if( (lprbbi->fMask & RBBIM_IDEALSIZE) &&
1612 ( lpBand->cxIdeal != lprbbi->cxIdeal ) )
1614 lpBand->cxIdeal = lprbbi->cxIdeal;
1615 bChanged = TRUE;
1618 if( (lprbbi->fMask & RBBIM_LPARAM) &&
1619 (lpBand->lParam != lprbbi->lParam ) )
1621 lpBand->lParam = lprbbi->lParam;
1622 bChanged = TRUE;
1625 if( (lprbbi->fMask & RBBIM_HEADERSIZE) &&
1626 (lpBand->cxHeader != lprbbi->cxHeader ) )
1628 lpBand->cxHeader = lprbbi->cxHeader;
1629 lpBand->fStyle |= RBBS_UNDOC_FIXEDHEADER;
1630 bChanged = TRUE;
1634 return bChanged;
1637 static LRESULT
1638 REBAR_InternalEraseBkGnd (const REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam, const RECT *clip)
1639 /* Function: This erases the background rectangle by drawing */
1640 /* each band with its background color (or the default) and */
1641 /* draws each bands right separator if necessary. The row */
1642 /* separators are drawn on the first band of the next row. */
1644 REBAR_BAND *lpBand;
1645 UINT i;
1646 INT oldrow;
1647 HDC hdc = (HDC)wParam;
1648 RECT cr;
1649 COLORREF old = CLR_NONE, new;
1650 HTHEME theme = GetWindowTheme (infoPtr->hwndSelf);
1652 GetClientRect (infoPtr->hwndSelf, &cr);
1654 oldrow = -1;
1655 for(i=0; i<infoPtr->uNumBands; i++) {
1656 RECT rcBand;
1657 lpBand = &infoPtr->bands[i];
1658 if (HIDDENBAND(lpBand)) continue;
1659 translate_rect(infoPtr, &rcBand, &lpBand->rcBand);
1661 /* draw band separator between rows */
1662 if (lpBand->iRow != oldrow) {
1663 oldrow = lpBand->iRow;
1664 if (infoPtr->dwStyle & RBS_BANDBORDERS) {
1665 RECT rcRowSep;
1666 rcRowSep = rcBand;
1667 if (infoPtr->dwStyle & CCS_VERT) {
1668 rcRowSep.right += SEP_WIDTH_SIZE;
1669 rcRowSep.bottom = infoPtr->calcSize.cx;
1670 if (theme)
1671 DrawThemeEdge (theme, hdc, RP_BAND, 0, &rcRowSep, EDGE_ETCHED, BF_RIGHT, NULL);
1672 else
1673 DrawEdge (hdc, &rcRowSep, EDGE_ETCHED, BF_RIGHT);
1675 else {
1676 rcRowSep.bottom += SEP_WIDTH_SIZE;
1677 rcRowSep.right = infoPtr->calcSize.cx;
1678 if (theme)
1679 DrawThemeEdge (theme, hdc, RP_BAND, 0, &rcRowSep, EDGE_ETCHED, BF_BOTTOM, NULL);
1680 else
1681 DrawEdge (hdc, &rcRowSep, EDGE_ETCHED, BF_BOTTOM);
1683 TRACE ("drawing band separator bottom (%s)\n",
1684 wine_dbgstr_rect(&rcRowSep));
1688 /* draw band separator between bands in a row */
1689 if (infoPtr->dwStyle & RBS_BANDBORDERS && lpBand->rcBand.left > 0) {
1690 RECT rcSep;
1691 rcSep = rcBand;
1692 if (infoPtr->dwStyle & CCS_VERT) {
1693 rcSep.bottom = rcSep.top;
1694 rcSep.top -= SEP_WIDTH_SIZE;
1695 if (theme)
1696 DrawThemeEdge (theme, hdc, RP_BAND, 0, &rcSep, EDGE_ETCHED, BF_BOTTOM, NULL);
1697 else
1698 DrawEdge (hdc, &rcSep, EDGE_ETCHED, BF_BOTTOM);
1700 else {
1701 rcSep.right = rcSep.left;
1702 rcSep.left -= SEP_WIDTH_SIZE;
1703 if (theme)
1704 DrawThemeEdge (theme, hdc, RP_BAND, 0, &rcSep, EDGE_ETCHED, BF_RIGHT, NULL);
1705 else
1706 DrawEdge (hdc, &rcSep, EDGE_ETCHED, BF_RIGHT);
1708 TRACE("drawing band separator right (%s)\n",
1709 wine_dbgstr_rect(&rcSep));
1712 /* draw the actual background */
1713 if (lpBand->clrBack != CLR_NONE) {
1714 new = (lpBand->clrBack == CLR_DEFAULT) ? infoPtr->clrBtnFace :
1715 lpBand->clrBack;
1716 #if GLATESTING
1717 /* testing only - make background green to see it */
1718 new = RGB(0,128,0);
1719 #endif
1721 else {
1722 /* In the absence of documentation for Rebar vs. CLR_NONE,
1723 * we will use the default BtnFace color. Note documentation
1724 * exists for Listview and Imagelist.
1726 new = infoPtr->clrBtnFace;
1727 #if GLATESTING
1728 /* testing only - make background green to see it */
1729 new = RGB(0,128,0);
1730 #endif
1733 if (theme)
1735 /* When themed, the background color is ignored (but not a
1736 * background bitmap */
1737 DrawThemeBackground (theme, hdc, 0, 0, &cr, &rcBand);
1739 else
1741 old = SetBkColor (hdc, new);
1742 TRACE("%s background color=0x%06x, band (%d,%d)-(%d,%d), clip (%d,%d)-(%d,%d)\n",
1743 (lpBand->clrBack == CLR_NONE) ? "none" :
1744 ((lpBand->clrBack == CLR_DEFAULT) ? "dft" : ""),
1745 GetBkColor(hdc),
1746 rcBand.left,rcBand.top,
1747 rcBand.right,rcBand.bottom,
1748 clip->left, clip->top,
1749 clip->right, clip->bottom);
1750 ExtTextOutW (hdc, 0, 0, ETO_OPAQUE, &rcBand, NULL, 0, 0);
1751 if (lpBand->clrBack != CLR_NONE)
1752 SetBkColor (hdc, old);
1755 return TRUE;
1758 static void
1759 REBAR_InternalHitTest (const REBAR_INFO *infoPtr, const POINT *lpPt, UINT *pFlags, INT *pBand)
1761 REBAR_BAND *lpBand;
1762 RECT rect;
1763 UINT iCount;
1765 GetClientRect (infoPtr->hwndSelf, &rect);
1767 *pFlags = RBHT_NOWHERE;
1768 if (PtInRect (&rect, *lpPt))
1770 if (infoPtr->uNumBands == 0) {
1771 *pFlags = RBHT_NOWHERE;
1772 if (pBand)
1773 *pBand = -1;
1774 TRACE("NOWHERE\n");
1775 return;
1777 else {
1778 /* somewhere inside */
1779 for (iCount = 0; iCount < infoPtr->uNumBands; iCount++) {
1780 RECT rcBand;
1781 lpBand = &infoPtr->bands[iCount];
1782 translate_rect(infoPtr, &rcBand, &lpBand->rcBand);
1783 if (HIDDENBAND(lpBand)) continue;
1784 if (PtInRect (&rcBand, *lpPt)) {
1785 if (pBand)
1786 *pBand = iCount;
1787 if (PtInRect (&lpBand->rcGripper, *lpPt)) {
1788 *pFlags = RBHT_GRABBER;
1789 TRACE("ON GRABBER %d\n", iCount);
1790 return;
1792 else if (PtInRect (&lpBand->rcCapImage, *lpPt)) {
1793 *pFlags = RBHT_CAPTION;
1794 TRACE("ON CAPTION %d\n", iCount);
1795 return;
1797 else if (PtInRect (&lpBand->rcCapText, *lpPt)) {
1798 *pFlags = RBHT_CAPTION;
1799 TRACE("ON CAPTION %d\n", iCount);
1800 return;
1802 else if (PtInRect (&lpBand->rcChild, *lpPt)) {
1803 *pFlags = RBHT_CLIENT;
1804 TRACE("ON CLIENT %d\n", iCount);
1805 return;
1807 else if (PtInRect (&lpBand->rcChevron, *lpPt)) {
1808 *pFlags = RBHT_CHEVRON;
1809 TRACE("ON CHEVRON %d\n", iCount);
1810 return;
1812 else {
1813 *pFlags = RBHT_NOWHERE;
1814 TRACE("NOWHERE %d\n", iCount);
1815 return;
1820 *pFlags = RBHT_NOWHERE;
1821 if (pBand)
1822 *pBand = -1;
1824 TRACE("NOWHERE\n");
1825 return;
1828 else {
1829 *pFlags = RBHT_NOWHERE;
1830 if (pBand)
1831 *pBand = -1;
1832 TRACE("NOWHERE\n");
1833 return;
1837 static void
1838 REBAR_HandleLRDrag (REBAR_INFO *infoPtr, const POINT *ptsmove)
1839 /* Function: This will implement the functionality of a */
1840 /* Gripper drag within a row. It will not implement "out- */
1841 /* of-row" drags. (They are detected and handled in */
1842 /* REBAR_MouseMove.) */
1843 /* **** FIXME Switching order of bands in a row not **** */
1844 /* **** yet implemented. **** */
1846 REBAR_BAND *hitBand;
1847 INT iHitBand, iRowBegin, iRowEnd;
1848 INT movement, xBand;
1850 /* on first significant mouse movement, issue notify */
1851 if (!(infoPtr->fStatus & BEGIN_DRAG_ISSUED)) {
1852 if (REBAR_Notify_NMREBAR (infoPtr, -1, RBN_BEGINDRAG)) {
1853 /* Notify returned TRUE - abort drag */
1854 infoPtr->dragStart.x = 0;
1855 infoPtr->dragStart.y = 0;
1856 infoPtr->dragNow = infoPtr->dragStart;
1857 infoPtr->iGrabbedBand = -1;
1858 ReleaseCapture ();
1859 return ;
1861 infoPtr->fStatus |= BEGIN_DRAG_ISSUED;
1864 iHitBand = infoPtr->iGrabbedBand;
1865 iRowBegin = get_row_begin_for_band(infoPtr, iHitBand);
1866 iRowEnd = get_row_end_for_band(infoPtr, iHitBand);
1867 hitBand = &infoPtr->bands[iHitBand];
1869 xBand = hitBand->rcBand.left;
1870 movement = (infoPtr->dwStyle&CCS_VERT ? ptsmove->y : ptsmove->x)
1871 - (xBand + REBAR_PRE_GRIPPER - infoPtr->ihitoffset);
1873 if (movement < 0) {
1874 int cxLeft = REBAR_ShrinkBandsRTL(infoPtr, iRowBegin, iHitBand, -movement, TRUE);
1875 hitBand->cxEffective += -movement - cxLeft;
1876 hitBand->cx = hitBand->cxEffective;
1877 } else if (movement > 0) {
1878 int cxLeft = REBAR_ShrinkBandsLTR(infoPtr, iHitBand, iRowEnd, movement, TRUE);
1879 REBAR_BAND *lpPrev = &infoPtr->bands[prev_band(infoPtr, iHitBand)];
1880 lpPrev->cxEffective += movement - cxLeft;
1881 lpPrev->cx = lpPrev->cxEffective;
1884 REBAR_SetRowRectsX(infoPtr, iRowBegin, iRowEnd);
1885 if (infoPtr->dwStyle & CCS_VERT)
1886 REBAR_CalcVertBand(infoPtr, 0, infoPtr->uNumBands);
1887 else
1888 REBAR_CalcHorzBand(infoPtr, 0, infoPtr->uNumBands);
1889 REBAR_MoveChildWindows(infoPtr, iRowBegin, iRowEnd);
1894 /* << REBAR_BeginDrag >> */
1897 static LRESULT
1898 REBAR_DeleteBand (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
1900 UINT uBand = (UINT)wParam;
1901 REBAR_BAND *lpBand;
1903 if (uBand >= infoPtr->uNumBands)
1904 return FALSE;
1906 TRACE("deleting band %u!\n", uBand);
1907 lpBand = &infoPtr->bands[uBand];
1908 REBAR_Notify_NMREBAR (infoPtr, uBand, RBN_DELETINGBAND);
1909 /* TODO: a return of 1 should probably cancel the deletion */
1911 if (lpBand->hwndChild)
1912 ShowWindow(lpBand->hwndChild, SW_HIDE);
1913 Free(lpBand->lpText);
1915 infoPtr->uNumBands--;
1916 memmove(&infoPtr->bands[uBand], &infoPtr->bands[uBand+1],
1917 (infoPtr->uNumBands - uBand) * sizeof(REBAR_BAND));
1918 infoPtr->bands = ReAlloc(infoPtr->bands, infoPtr->uNumBands * sizeof(REBAR_BAND));
1920 REBAR_Notify_NMREBAR (infoPtr, -1, RBN_DELETEDBAND);
1922 /* if only 1 band left the re-validate to possible eliminate gripper */
1923 if (infoPtr->uNumBands == 1)
1924 REBAR_ValidateBand (infoPtr, &infoPtr->bands[0]);
1926 REBAR_Layout(infoPtr, NULL);
1928 return TRUE;
1932 /* << REBAR_DragMove >> */
1933 /* << REBAR_EndDrag >> */
1936 static LRESULT
1937 REBAR_GetBandBorders (const REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
1939 LPRECT lpRect = (LPRECT)lParam;
1940 REBAR_BAND *lpBand;
1942 if (!lParam)
1943 return 0;
1944 if ((UINT)wParam >= infoPtr->uNumBands)
1945 return 0;
1947 lpBand = &infoPtr->bands[(UINT)wParam];
1949 /* FIXME - the following values were determined by experimentation */
1950 /* with the REBAR Control Spy. I have guesses as to what the 4 and */
1951 /* 1 are, but I am not sure. There doesn't seem to be any actual */
1952 /* difference in size of the control area with and without the */
1953 /* style. - GA */
1954 if (infoPtr->dwStyle & RBS_BANDBORDERS) {
1955 if (infoPtr->dwStyle & CCS_VERT) {
1956 lpRect->left = 1;
1957 lpRect->top = lpBand->cxHeader + 4;
1958 lpRect->right = 1;
1959 lpRect->bottom = 0;
1961 else {
1962 lpRect->left = lpBand->cxHeader + 4;
1963 lpRect->top = 1;
1964 lpRect->right = 0;
1965 lpRect->bottom = 1;
1968 else {
1969 lpRect->left = lpBand->cxHeader;
1971 return 0;
1975 static inline LRESULT
1976 REBAR_GetBandCount (const REBAR_INFO *infoPtr)
1978 TRACE("band count %u!\n", infoPtr->uNumBands);
1980 return infoPtr->uNumBands;
1984 static LRESULT
1985 REBAR_GetBandInfoT(const REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam, BOOL bUnicode)
1987 LPREBARBANDINFOW lprbbi = (LPREBARBANDINFOW)lParam;
1988 REBAR_BAND *lpBand;
1990 if (lprbbi == NULL)
1991 return FALSE;
1992 if (lprbbi->cbSize < REBARBANDINFOA_V3_SIZE)
1993 return FALSE;
1994 if ((UINT)wParam >= infoPtr->uNumBands)
1995 return FALSE;
1997 TRACE("index %u (bUnicode=%d)\n", (UINT)wParam, bUnicode);
1999 /* copy band information */
2000 lpBand = &infoPtr->bands[(UINT)wParam];
2002 if (lprbbi->fMask & RBBIM_STYLE)
2003 lprbbi->fStyle = lpBand->fStyle;
2005 if (lprbbi->fMask & RBBIM_COLORS) {
2006 lprbbi->clrFore = lpBand->clrFore;
2007 lprbbi->clrBack = lpBand->clrBack;
2008 if (lprbbi->clrBack == CLR_DEFAULT)
2009 lprbbi->clrBack = infoPtr->clrBtnFace;
2012 if (lprbbi->fMask & RBBIM_TEXT) {
2013 if (bUnicode)
2014 Str_GetPtrW(lpBand->lpText, lprbbi->lpText, lprbbi->cch);
2015 else
2016 Str_GetPtrWtoA(lpBand->lpText, (LPSTR)lprbbi->lpText, lprbbi->cch);
2019 if (lprbbi->fMask & RBBIM_IMAGE)
2020 lprbbi->iImage = lpBand->iImage;
2022 if (lprbbi->fMask & RBBIM_CHILD)
2023 lprbbi->hwndChild = lpBand->hwndChild;
2025 if (lprbbi->fMask & RBBIM_CHILDSIZE) {
2026 lprbbi->cxMinChild = lpBand->cxMinChild;
2027 lprbbi->cyMinChild = lpBand->cyMinChild;
2028 /* to make tests pass we follow Windows behaviour and allow to read these fields only
2029 * for RBBS_VARIABLEHEIGHTS bands */
2030 if (lprbbi->cbSize >= sizeof (REBARBANDINFOA) && (lpBand->fStyle & RBBS_VARIABLEHEIGHT)) {
2031 lprbbi->cyChild = lpBand->cyChild;
2032 lprbbi->cyMaxChild = lpBand->cyMaxChild;
2033 lprbbi->cyIntegral = lpBand->cyIntegral;
2037 if (lprbbi->fMask & RBBIM_SIZE)
2038 lprbbi->cx = lpBand->cx;
2040 if (lprbbi->fMask & RBBIM_BACKGROUND)
2041 lprbbi->hbmBack = lpBand->hbmBack;
2043 if (lprbbi->fMask & RBBIM_ID)
2044 lprbbi->wID = lpBand->wID;
2046 /* check for additional data */
2047 if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
2048 if (lprbbi->fMask & RBBIM_IDEALSIZE)
2049 lprbbi->cxIdeal = lpBand->cxIdeal;
2051 if (lprbbi->fMask & RBBIM_LPARAM)
2052 lprbbi->lParam = lpBand->lParam;
2054 if (lprbbi->fMask & RBBIM_HEADERSIZE)
2055 lprbbi->cxHeader = lpBand->cxHeader;
2058 REBAR_DumpBandInfo(lprbbi);
2060 return TRUE;
2064 static LRESULT
2065 REBAR_GetBarHeight (const REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2067 INT nHeight;
2069 nHeight = infoPtr->calcSize.cy;
2071 TRACE("height = %d\n", nHeight);
2073 return nHeight;
2077 static LRESULT
2078 REBAR_GetBarInfo (const REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2080 LPREBARINFO lpInfo = (LPREBARINFO)lParam;
2082 if (lpInfo == NULL)
2083 return FALSE;
2085 if (lpInfo->cbSize < sizeof (REBARINFO))
2086 return FALSE;
2088 TRACE("getting bar info!\n");
2090 if (infoPtr->himl) {
2091 lpInfo->himl = infoPtr->himl;
2092 lpInfo->fMask |= RBIM_IMAGELIST;
2095 return TRUE;
2099 static inline LRESULT
2100 REBAR_GetBkColor (const REBAR_INFO *infoPtr)
2102 COLORREF clr = infoPtr->clrBk;
2104 if (clr == CLR_DEFAULT)
2105 clr = infoPtr->clrBtnFace;
2107 TRACE("background color 0x%06x!\n", clr);
2109 return clr;
2113 /* << REBAR_GetColorScheme >> */
2114 /* << REBAR_GetDropTarget >> */
2117 static LRESULT
2118 REBAR_GetPalette (const REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2120 FIXME("empty stub!\n");
2122 return 0;
2126 static LRESULT
2127 REBAR_GetRect (const REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2129 INT iBand = (INT)wParam;
2130 LPRECT lprc = (LPRECT)lParam;
2131 REBAR_BAND *lpBand;
2133 if ((iBand < 0) || ((UINT)iBand >= infoPtr->uNumBands))
2134 return FALSE;
2135 if (!lprc)
2136 return FALSE;
2138 lpBand = &infoPtr->bands[iBand];
2139 /* For CCS_VERT the coordinates will be swapped - like on Windows */
2140 CopyRect (lprc, &lpBand->rcBand);
2142 TRACE("band %d, (%s)\n", iBand, wine_dbgstr_rect(lprc));
2144 return TRUE;
2148 static inline LRESULT
2149 REBAR_GetRowCount (const REBAR_INFO *infoPtr)
2151 TRACE("%u\n", infoPtr->uNumRows);
2153 return infoPtr->uNumRows;
2157 static LRESULT
2158 REBAR_GetRowHeight (const REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2160 INT iRow = (INT)wParam;
2161 int j = 0, ret = 0;
2162 UINT i;
2163 REBAR_BAND *lpBand;
2165 for (i=0; i<infoPtr->uNumBands; i++) {
2166 lpBand = &infoPtr->bands[i];
2167 if (HIDDENBAND(lpBand)) continue;
2168 if (lpBand->iRow != iRow) continue;
2169 j = lpBand->rcBand.bottom - lpBand->rcBand.top;
2170 if (j > ret) ret = j;
2173 TRACE("row %d, height %d\n", iRow, ret);
2175 return ret;
2179 static inline LRESULT
2180 REBAR_GetTextColor (const REBAR_INFO *infoPtr)
2182 TRACE("text color 0x%06x!\n", infoPtr->clrText);
2184 return infoPtr->clrText;
2188 static inline LRESULT
2189 REBAR_GetToolTips (const REBAR_INFO *infoPtr)
2191 return (LRESULT)infoPtr->hwndToolTip;
2195 static inline LRESULT
2196 REBAR_GetUnicodeFormat (const REBAR_INFO *infoPtr)
2198 TRACE("%s hwnd=%p\n",
2199 infoPtr->bUnicode ? "TRUE" : "FALSE", infoPtr->hwndSelf);
2201 return infoPtr->bUnicode;
2205 static inline LRESULT
2206 REBAR_GetVersion (const REBAR_INFO *infoPtr)
2208 TRACE("version %d\n", infoPtr->iVersion);
2209 return infoPtr->iVersion;
2213 static LRESULT
2214 REBAR_HitTest (const REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2216 LPRBHITTESTINFO lprbht = (LPRBHITTESTINFO)lParam;
2218 if (!lprbht)
2219 return -1;
2221 REBAR_InternalHitTest (infoPtr, &lprbht->pt, &lprbht->flags, &lprbht->iBand);
2223 return lprbht->iBand;
2227 static LRESULT
2228 REBAR_IdToIndex (const REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2230 UINT i;
2232 if (infoPtr == NULL)
2233 return -1;
2235 if (infoPtr->uNumBands < 1)
2236 return -1;
2238 for (i = 0; i < infoPtr->uNumBands; i++) {
2239 if (infoPtr->bands[i].wID == (UINT)wParam) {
2240 TRACE("id %u is band %u found!\n", (UINT)wParam, i);
2241 return i;
2245 TRACE("id %u is not found\n", (UINT)wParam);
2246 return -1;
2250 static LRESULT
2251 REBAR_InsertBandT(REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam, BOOL bUnicode)
2253 LPREBARBANDINFOW lprbbi = (LPREBARBANDINFOW)lParam;
2254 UINT uIndex = (UINT)wParam;
2255 REBAR_BAND *lpBand;
2257 if (infoPtr == NULL)
2258 return FALSE;
2259 if (lprbbi == NULL)
2260 return FALSE;
2261 if (lprbbi->cbSize < REBARBANDINFOA_V3_SIZE)
2262 return FALSE;
2264 /* trace the index as signed to see the -1 */
2265 TRACE("insert band at %d (bUnicode=%d)!\n", (INT)uIndex, bUnicode);
2266 REBAR_DumpBandInfo(lprbbi);
2268 infoPtr->bands = ReAlloc(infoPtr->bands, (infoPtr->uNumBands+1) * sizeof(REBAR_BAND));
2269 if (((INT)uIndex == -1) || (uIndex > infoPtr->uNumBands))
2270 uIndex = infoPtr->uNumBands;
2271 memmove(&infoPtr->bands[uIndex+1], &infoPtr->bands[uIndex],
2272 sizeof(REBAR_BAND) * (infoPtr->uNumBands - uIndex));
2273 infoPtr->uNumBands++;
2275 TRACE("index %u!\n", uIndex);
2277 /* initialize band (infoPtr->bands[uIndex])*/
2278 lpBand = &infoPtr->bands[uIndex];
2279 ZeroMemory(lpBand, sizeof(*lpBand));
2280 lpBand->clrFore = infoPtr->clrText;
2281 lpBand->clrBack = infoPtr->clrBk;
2282 lpBand->iImage = -1;
2284 REBAR_CommonSetupBand(infoPtr->hwndSelf, lprbbi, lpBand);
2285 if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) {
2286 if (bUnicode)
2287 Str_SetPtrW(&lpBand->lpText, lprbbi->lpText);
2288 else
2289 Str_SetPtrAtoW(&lpBand->lpText, (LPSTR)lprbbi->lpText);
2292 REBAR_ValidateBand (infoPtr, lpBand);
2293 /* On insert of second band, revalidate band 1 to possible add gripper */
2294 if (infoPtr->uNumBands == 2)
2295 REBAR_ValidateBand (infoPtr, &infoPtr->bands[0]);
2297 REBAR_DumpBand (infoPtr);
2299 REBAR_Layout(infoPtr, NULL);
2300 InvalidateRect(infoPtr->hwndSelf, 0, TRUE);
2302 return TRUE;
2306 static LRESULT
2307 REBAR_MaximizeBand (const REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2309 REBAR_BAND *lpBand;
2310 UINT uBand = (UINT) wParam;
2311 int iRowBegin, iRowEnd;
2312 int cxDesired, extra, extraOrig;
2313 int cxIdealBand;
2315 /* Validate */
2316 if ((infoPtr->uNumBands == 0) ||
2317 ((INT)uBand < 0) || (uBand >= infoPtr->uNumBands)) {
2318 /* error !!! */
2319 ERR("Illegal MaximizeBand, requested=%d, current band count=%d\n",
2320 (INT)uBand, infoPtr->uNumBands);
2321 return FALSE;
2324 lpBand = &infoPtr->bands[uBand];
2326 cxIdealBand = lpBand->cxIdeal + lpBand->cxHeader + REBAR_POST_CHILD;
2327 if (lParam && (lpBand->cxEffective < cxIdealBand))
2328 cxDesired = cxIdealBand;
2329 else
2330 cxDesired = infoPtr->calcSize.cx;
2332 iRowBegin = get_row_begin_for_band(infoPtr, uBand);
2333 iRowEnd = get_row_end_for_band(infoPtr, uBand);
2334 extraOrig = extra = cxDesired - lpBand->cxEffective;
2335 if (extra > 0)
2336 extra = REBAR_ShrinkBandsRTL(infoPtr, iRowBegin, uBand, extra, TRUE);
2337 if (extra > 0)
2338 extra = REBAR_ShrinkBandsLTR(infoPtr, next_band(infoPtr, uBand), iRowEnd, extra, TRUE);
2339 lpBand->cxEffective += extraOrig - extra;
2340 lpBand->cx = lpBand->cxEffective;
2341 TRACE("(%ld, %ld): Wanted size %d, obtained %d (shrink %d, %d)\n", wParam, lParam, cxDesired, lpBand->cx, extraOrig, extra);
2342 REBAR_SetRowRectsX(infoPtr, iRowBegin, iRowEnd);
2344 if (infoPtr->dwStyle & CCS_VERT)
2345 REBAR_CalcVertBand(infoPtr, iRowBegin, iRowEnd);
2346 else
2347 REBAR_CalcHorzBand(infoPtr, iRowBegin, iRowEnd);
2348 REBAR_MoveChildWindows(infoPtr, iRowBegin, iRowEnd);
2349 return TRUE;
2354 static LRESULT
2355 REBAR_MinimizeBand (const REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2357 REBAR_BAND *lpBand;
2358 UINT uBand = (UINT) wParam;
2359 int iPrev, iRowBegin, iRowEnd;
2361 /* A "minimize" band is equivalent to "dragging" the gripper
2362 * of than band to the right till the band is only the size
2363 * of the cxHeader.
2366 /* Validate */
2367 if ((infoPtr->uNumBands == 0) ||
2368 ((INT)uBand < 0) || (uBand >= infoPtr->uNumBands)) {
2369 /* error !!! */
2370 ERR("Illegal MinimizeBand, requested=%d, current band count=%d\n",
2371 (INT)uBand, infoPtr->uNumBands);
2372 return FALSE;
2375 /* compute amount of movement and validate */
2376 lpBand = &infoPtr->bands[uBand];
2377 iPrev = prev_band(infoPtr, uBand);
2378 /* if first band in row */
2379 if (iPrev < 0 || infoPtr->bands[iPrev].iRow != lpBand->iRow) {
2380 int iNext = next_band(infoPtr, uBand);
2381 if (iNext < infoPtr->uNumBands && infoPtr->bands[iNext].iRow == lpBand->iRow) {
2382 TRACE("(%ld): Minimizing the first band in row is by maximizing the second\n", wParam);
2383 REBAR_MaximizeBand(infoPtr, iNext, FALSE);
2385 else
2386 TRACE("(%ld): Only one band in row - nothing to do\n", wParam);
2387 return TRUE;
2390 infoPtr->bands[iPrev].cxEffective += lpBand->cxEffective - lpBand->lcx;
2391 infoPtr->bands[iPrev].cx = infoPtr->bands[iPrev].cxEffective;
2392 lpBand->cx = lpBand->cxEffective = lpBand->lcx;
2394 iRowBegin = get_row_begin_for_band(infoPtr, uBand);
2395 iRowEnd = get_row_end_for_band(infoPtr, uBand);
2396 REBAR_SetRowRectsX(infoPtr, iRowBegin, iRowEnd);
2398 if (infoPtr->dwStyle & CCS_VERT)
2399 REBAR_CalcVertBand(infoPtr, iRowBegin, iRowEnd);
2400 else
2401 REBAR_CalcHorzBand(infoPtr, iRowBegin, iRowEnd);
2402 REBAR_MoveChildWindows(infoPtr, iRowBegin, iRowEnd);
2403 return FALSE;
2407 static LRESULT
2408 REBAR_MoveBand (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2410 REBAR_BAND *oldBands = infoPtr->bands;
2411 REBAR_BAND holder;
2412 UINT uFrom = (UINT)wParam;
2413 UINT uTo = (UINT)lParam;
2415 /* Validate */
2416 if ((infoPtr->uNumBands == 0) ||
2417 ((INT)uFrom < 0) || (uFrom >= infoPtr->uNumBands) ||
2418 ((INT)uTo < 0) || (uTo >= infoPtr->uNumBands)) {
2419 /* error !!! */
2420 ERR("Illegal MoveBand, from=%d, to=%d, current band count=%d\n",
2421 (INT)uFrom, (INT)uTo, infoPtr->uNumBands);
2422 return FALSE;
2425 /* save one to be moved */
2426 holder = oldBands[uFrom];
2428 /* close up rest of bands (pseudo delete) */
2429 if (uFrom < infoPtr->uNumBands - 1) {
2430 memcpy (&oldBands[uFrom], &oldBands[uFrom+1],
2431 (infoPtr->uNumBands - uFrom - 1) * sizeof(REBAR_BAND));
2434 /* allocate new space and copy rest of bands into it */
2435 infoPtr->bands =
2436 (REBAR_BAND *)Alloc ((infoPtr->uNumBands)*sizeof(REBAR_BAND));
2438 /* pre insert copy */
2439 if (uTo > 0) {
2440 memcpy (&infoPtr->bands[0], &oldBands[0],
2441 uTo * sizeof(REBAR_BAND));
2444 /* set moved band */
2445 infoPtr->bands[uTo] = holder;
2447 /* post copy */
2448 if (uTo < infoPtr->uNumBands - 1) {
2449 memcpy (&infoPtr->bands[uTo+1], &oldBands[uTo],
2450 (infoPtr->uNumBands - uTo - 1) * sizeof(REBAR_BAND));
2453 Free (oldBands);
2455 TRACE("moved band %d to index %d\n", uFrom, uTo);
2456 REBAR_DumpBand (infoPtr);
2458 /* **************************************************** */
2459 /* */
2460 /* We do not do a REBAR_Layout here because the native */
2461 /* control does not do that. The actual layout and */
2462 /* repaint is done by the *next* real action, ex.: */
2463 /* RB_INSERTBAND, RB_DELETEBAND, RB_SIZETORECT, etc. */
2464 /* */
2465 /* **************************************************** */
2467 return TRUE;
2471 /* return TRUE if two strings are different */
2472 static BOOL
2473 REBAR_strdifW( LPCWSTR a, LPCWSTR b )
2475 return ( (a && !b) || (b && !a) || (a && b && lstrcmpW(a, b) ) );
2478 static LRESULT
2479 REBAR_SetBandInfoT(REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam, BOOL bUnicode)
2481 LPREBARBANDINFOW lprbbi = (LPREBARBANDINFOW)lParam;
2482 REBAR_BAND *lpBand;
2483 BOOL bChanged;
2485 if (lprbbi == NULL)
2486 return FALSE;
2487 if (lprbbi->cbSize < REBARBANDINFOA_V3_SIZE)
2488 return FALSE;
2489 if ((UINT)wParam >= infoPtr->uNumBands)
2490 return FALSE;
2492 TRACE("index %u\n", (UINT)wParam);
2493 REBAR_DumpBandInfo (lprbbi);
2495 /* set band information */
2496 lpBand = &infoPtr->bands[(UINT)wParam];
2498 bChanged = REBAR_CommonSetupBand (infoPtr->hwndSelf, lprbbi, lpBand);
2499 if (lprbbi->fMask & RBBIM_TEXT) {
2500 LPWSTR wstr = NULL;
2501 if (bUnicode)
2502 Str_SetPtrW(&wstr, lprbbi->lpText);
2503 else
2504 Str_SetPtrAtoW(&wstr, (LPSTR)lprbbi->lpText);
2506 if (REBAR_strdifW(wstr, lpBand->lpText)) {
2507 Free(lpBand->lpText);
2508 lpBand->lpText = wstr;
2509 bChanged = TRUE;
2511 else
2512 Free(wstr);
2515 REBAR_ValidateBand (infoPtr, lpBand);
2517 REBAR_DumpBand (infoPtr);
2519 if (bChanged && (lprbbi->fMask & (RBBIM_CHILDSIZE | RBBIM_SIZE | RBBIM_STYLE))) {
2520 REBAR_Layout(infoPtr, NULL);
2521 InvalidateRect(infoPtr->hwndSelf, 0, 1);
2524 return TRUE;
2528 static LRESULT
2529 REBAR_SetBarInfo (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2531 LPREBARINFO lpInfo = (LPREBARINFO)lParam;
2532 REBAR_BAND *lpBand;
2533 UINT i;
2535 if (lpInfo == NULL)
2536 return FALSE;
2538 if (lpInfo->cbSize < sizeof (REBARINFO))
2539 return FALSE;
2541 TRACE("setting bar info!\n");
2543 if (lpInfo->fMask & RBIM_IMAGELIST) {
2544 infoPtr->himl = lpInfo->himl;
2545 if (infoPtr->himl) {
2546 INT cx, cy;
2547 ImageList_GetIconSize (infoPtr->himl, &cx, &cy);
2548 infoPtr->imageSize.cx = cx;
2549 infoPtr->imageSize.cy = cy;
2551 else {
2552 infoPtr->imageSize.cx = 0;
2553 infoPtr->imageSize.cy = 0;
2555 TRACE("new image cx=%d, cy=%d\n", infoPtr->imageSize.cx,
2556 infoPtr->imageSize.cy);
2559 /* revalidate all bands to reset flags for images in headers of bands */
2560 for (i=0; i<infoPtr->uNumBands; i++) {
2561 lpBand = &infoPtr->bands[i];
2562 REBAR_ValidateBand (infoPtr, lpBand);
2565 return TRUE;
2569 static LRESULT
2570 REBAR_SetBkColor (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2572 COLORREF clrTemp;
2574 clrTemp = infoPtr->clrBk;
2575 infoPtr->clrBk = (COLORREF)lParam;
2577 TRACE("background color 0x%06x!\n", infoPtr->clrBk);
2579 return clrTemp;
2583 /* << REBAR_SetColorScheme >> */
2584 /* << REBAR_SetPalette >> */
2587 static LRESULT
2588 REBAR_SetParent (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2590 HWND hwndTemp = infoPtr->hwndNotify;
2592 infoPtr->hwndNotify = (HWND)wParam;
2594 return (LRESULT)hwndTemp;
2598 static LRESULT
2599 REBAR_SetTextColor (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2601 COLORREF clrTemp;
2603 clrTemp = infoPtr->clrText;
2604 infoPtr->clrText = (COLORREF)lParam;
2606 TRACE("text color 0x%06x!\n", infoPtr->clrText);
2608 return clrTemp;
2612 /* << REBAR_SetTooltips >> */
2615 static inline LRESULT
2616 REBAR_SetUnicodeFormat (REBAR_INFO *infoPtr, WPARAM wParam)
2618 BOOL bTemp = infoPtr->bUnicode;
2620 TRACE("to %s hwnd=%p, was %s\n",
2621 ((BOOL)wParam) ? "TRUE" : "FALSE", infoPtr->hwndSelf,
2622 (bTemp) ? "TRUE" : "FALSE");
2624 infoPtr->bUnicode = (BOOL)wParam;
2626 return bTemp;
2630 static LRESULT
2631 REBAR_SetVersion (REBAR_INFO *infoPtr, INT iVersion)
2633 INT iOldVersion = infoPtr->iVersion;
2635 if (iVersion > COMCTL32_VERSION)
2636 return -1;
2638 infoPtr->iVersion = iVersion;
2640 TRACE("new version %d\n", iVersion);
2642 return iOldVersion;
2646 static LRESULT
2647 REBAR_ShowBand (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2649 REBAR_BAND *lpBand;
2651 if (((INT)wParam < 0) || ((INT)wParam > infoPtr->uNumBands))
2652 return FALSE;
2654 lpBand = &infoPtr->bands[(INT)wParam];
2656 if ((BOOL)lParam) {
2657 TRACE("show band %d\n", (INT)wParam);
2658 lpBand->fStyle = lpBand->fStyle & ~RBBS_HIDDEN;
2659 if (IsWindow (lpBand->hwndChild))
2660 ShowWindow (lpBand->hwndChild, SW_SHOW);
2662 else {
2663 TRACE("hide band %d\n", (INT)wParam);
2664 lpBand->fStyle = lpBand->fStyle | RBBS_HIDDEN;
2665 if (IsWindow (lpBand->hwndChild))
2666 ShowWindow (lpBand->hwndChild, SW_HIDE);
2669 REBAR_Layout(infoPtr, NULL);
2670 InvalidateRect(infoPtr->hwndSelf, 0, 1);
2672 return TRUE;
2676 static LRESULT
2677 REBAR_SizeToRect (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2679 LPRECT lpRect = (LPRECT)lParam;
2680 RECT t1;
2682 if (lpRect == NULL)
2683 return FALSE;
2685 TRACE("[%s]\n", wine_dbgstr_rect(lpRect));
2687 /* what is going on???? */
2688 GetWindowRect(infoPtr->hwndSelf, &t1);
2689 TRACE("window rect [%s]\n", wine_dbgstr_rect(&t1));
2690 GetClientRect(infoPtr->hwndSelf, &t1);
2691 TRACE("client rect [%s]\n", wine_dbgstr_rect(&t1));
2693 /* force full _Layout processing */
2694 REBAR_Layout(infoPtr, lpRect);
2695 InvalidateRect (infoPtr->hwndSelf, NULL, TRUE);
2696 return TRUE;
2701 static LRESULT
2702 REBAR_Create (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2704 LPCREATESTRUCTW cs = (LPCREATESTRUCTW) lParam;
2705 RECT wnrc1, clrc1;
2706 HTHEME theme;
2708 if (TRACE_ON(rebar)) {
2709 GetWindowRect(infoPtr->hwndSelf, &wnrc1);
2710 GetClientRect(infoPtr->hwndSelf, &clrc1);
2711 TRACE("window=(%s) client=(%s) cs=(%d,%d %dx%d)\n",
2712 wine_dbgstr_rect(&wnrc1), wine_dbgstr_rect(&clrc1),
2713 cs->x, cs->y, cs->cx, cs->cy);
2716 TRACE("created!\n");
2718 if ((theme = OpenThemeData (infoPtr->hwndSelf, themeClass)))
2720 /* native seems to clear WS_BORDER when themed */
2721 infoPtr->dwStyle &= ~WS_BORDER;
2724 return 0;
2728 static LRESULT
2729 REBAR_Destroy (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2731 REBAR_BAND *lpBand;
2732 UINT i;
2735 /* free rebar bands */
2736 if ((infoPtr->uNumBands > 0) && infoPtr->bands) {
2737 /* clean up each band */
2738 for (i = 0; i < infoPtr->uNumBands; i++) {
2739 lpBand = &infoPtr->bands[i];
2741 /* delete text strings */
2742 Free (lpBand->lpText);
2743 lpBand->lpText = NULL;
2744 /* destroy child window */
2745 DestroyWindow (lpBand->hwndChild);
2748 /* free band array */
2749 Free (infoPtr->bands);
2750 infoPtr->bands = NULL;
2753 DestroyCursor (infoPtr->hcurArrow);
2754 DestroyCursor (infoPtr->hcurHorz);
2755 DestroyCursor (infoPtr->hcurVert);
2756 DestroyCursor (infoPtr->hcurDrag);
2757 if(infoPtr->hDefaultFont) DeleteObject (infoPtr->hDefaultFont);
2758 SetWindowLongPtrW (infoPtr->hwndSelf, 0, 0);
2760 CloseThemeData (GetWindowTheme (infoPtr->hwndSelf));
2762 /* free rebar info data */
2763 Free (infoPtr);
2764 TRACE("destroyed!\n");
2765 return 0;
2769 static LRESULT
2770 REBAR_EraseBkGnd (const REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2772 RECT cliprect;
2774 if (GetClipBox ( (HDC)wParam, &cliprect))
2775 return REBAR_InternalEraseBkGnd (infoPtr, wParam, lParam, &cliprect);
2776 return 0;
2780 static LRESULT
2781 REBAR_GetFont (const REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2783 return (LRESULT)infoPtr->hFont;
2786 static LRESULT
2787 REBAR_PushChevron(const REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2789 if ((UINT)wParam < infoPtr->uNumBands)
2791 NMREBARCHEVRON nmrbc;
2792 REBAR_BAND *lpBand = &infoPtr->bands[wParam];
2794 TRACE("Pressed chevron on band %ld\n", wParam);
2796 /* redraw chevron in pushed state */
2797 lpBand->fDraw |= DRAW_CHEVRONPUSHED;
2798 RedrawWindow(infoPtr->hwndSelf, &lpBand->rcChevron,0,
2799 RDW_ERASE|RDW_INVALIDATE|RDW_UPDATENOW);
2801 /* notify app so it can display a popup menu or whatever */
2802 nmrbc.uBand = wParam;
2803 nmrbc.wID = lpBand->wID;
2804 nmrbc.lParam = lpBand->lParam;
2805 nmrbc.rc = lpBand->rcChevron;
2806 nmrbc.lParamNM = lParam;
2807 REBAR_Notify((NMHDR*)&nmrbc, infoPtr, RBN_CHEVRONPUSHED);
2809 /* redraw chevron in previous state */
2810 lpBand->fDraw &= ~DRAW_CHEVRONPUSHED;
2811 InvalidateRect(infoPtr->hwndSelf, &lpBand->rcChevron, TRUE);
2813 return TRUE;
2815 return FALSE;
2818 static LRESULT
2819 REBAR_LButtonDown (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2821 REBAR_BAND *lpBand;
2822 UINT htFlags;
2823 INT iHitBand;
2824 POINT ptMouseDown;
2825 ptMouseDown.x = (short)LOWORD(lParam);
2826 ptMouseDown.y = (short)HIWORD(lParam);
2828 REBAR_InternalHitTest(infoPtr, &ptMouseDown, &htFlags, &iHitBand);
2829 lpBand = &infoPtr->bands[iHitBand];
2831 if (htFlags == RBHT_CHEVRON)
2833 REBAR_PushChevron(infoPtr, iHitBand, 0);
2835 else if (htFlags == RBHT_GRABBER || htFlags == RBHT_CAPTION)
2837 TRACE("Starting drag\n");
2839 SetCapture (infoPtr->hwndSelf);
2840 infoPtr->iGrabbedBand = iHitBand;
2842 /* save off the LOWORD and HIWORD of lParam as initial x,y */
2843 infoPtr->dragStart.x = (short)LOWORD(lParam);
2844 infoPtr->dragStart.y = (short)HIWORD(lParam);
2845 infoPtr->dragNow = infoPtr->dragStart;
2846 if (infoPtr->dwStyle & CCS_VERT)
2847 infoPtr->ihitoffset = infoPtr->dragStart.y - (lpBand->rcBand.left + REBAR_PRE_GRIPPER);
2848 else
2849 infoPtr->ihitoffset = infoPtr->dragStart.x - (lpBand->rcBand.left + REBAR_PRE_GRIPPER);
2851 return 0;
2854 static LRESULT
2855 REBAR_LButtonUp (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2857 if (infoPtr->iGrabbedBand >= 0)
2859 NMHDR layout;
2860 RECT rect;
2862 infoPtr->dragStart.x = 0;
2863 infoPtr->dragStart.y = 0;
2864 infoPtr->dragNow = infoPtr->dragStart;
2866 ReleaseCapture ();
2868 if (infoPtr->fStatus & BEGIN_DRAG_ISSUED) {
2869 REBAR_Notify(&layout, infoPtr, RBN_LAYOUTCHANGED);
2870 REBAR_Notify_NMREBAR (infoPtr, infoPtr->iGrabbedBand, RBN_ENDDRAG);
2871 infoPtr->fStatus &= ~BEGIN_DRAG_ISSUED;
2874 infoPtr->iGrabbedBand = -1;
2876 GetClientRect(infoPtr->hwndSelf, &rect);
2877 InvalidateRect(infoPtr->hwndSelf, NULL, TRUE);
2880 return 0;
2883 static LRESULT
2884 REBAR_MouseLeave (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2886 if (infoPtr->ichevronhotBand >= 0)
2888 REBAR_BAND *lpChevronBand = &infoPtr->bands[infoPtr->ichevronhotBand];
2889 if (lpChevronBand->fDraw & DRAW_CHEVRONHOT)
2891 lpChevronBand->fDraw &= ~DRAW_CHEVRONHOT;
2892 InvalidateRect(infoPtr->hwndSelf, &lpChevronBand->rcChevron, TRUE);
2895 infoPtr->iOldBand = -1;
2896 infoPtr->ichevronhotBand = -2;
2898 return TRUE;
2901 static LRESULT
2902 REBAR_MouseMove (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2904 REBAR_BAND *lpChevronBand;
2905 POINT ptMove;
2907 ptMove.x = (short)LOWORD(lParam);
2908 ptMove.y = (short)HIWORD(lParam);
2910 /* if we are currently dragging a band */
2911 if (infoPtr->iGrabbedBand >= 0)
2913 REBAR_BAND *band1, *band2;
2914 int yPtMove = (infoPtr->dwStyle & CCS_VERT ? ptMove.x : ptMove.y);
2916 if (GetCapture() != infoPtr->hwndSelf)
2917 ERR("We are dragging but haven't got capture?!?\n");
2919 band1 = &infoPtr->bands[infoPtr->iGrabbedBand-1];
2920 band2 = &infoPtr->bands[infoPtr->iGrabbedBand];
2922 /* if mouse did not move much, exit */
2923 if ((abs(ptMove.x - infoPtr->dragNow.x) <= mindragx) &&
2924 (abs(ptMove.y - infoPtr->dragNow.y) <= mindragy)) return 0;
2926 /* Test for valid drag case - must not be first band in row */
2927 if ((yPtMove < band2->rcBand.top) ||
2928 (yPtMove > band2->rcBand.bottom) ||
2929 ((infoPtr->iGrabbedBand > 0) && (band1->iRow != band2->iRow))) {
2930 FIXME("Cannot drag to other rows yet!!\n");
2932 else {
2933 REBAR_HandleLRDrag (infoPtr, &ptMove);
2936 else
2938 INT iHitBand;
2939 UINT htFlags;
2940 TRACKMOUSEEVENT trackinfo;
2942 REBAR_InternalHitTest(infoPtr, &ptMove, &htFlags, &iHitBand);
2944 if (infoPtr->iOldBand >= 0 && infoPtr->iOldBand == infoPtr->ichevronhotBand)
2946 lpChevronBand = &infoPtr->bands[infoPtr->ichevronhotBand];
2947 if (lpChevronBand->fDraw & DRAW_CHEVRONHOT)
2949 lpChevronBand->fDraw &= ~DRAW_CHEVRONHOT;
2950 InvalidateRect(infoPtr->hwndSelf, &lpChevronBand->rcChevron, TRUE);
2952 infoPtr->ichevronhotBand = -2;
2955 if (htFlags == RBHT_CHEVRON)
2957 /* fill in the TRACKMOUSEEVENT struct */
2958 trackinfo.cbSize = sizeof(TRACKMOUSEEVENT);
2959 trackinfo.dwFlags = TME_QUERY;
2960 trackinfo.hwndTrack = infoPtr->hwndSelf;
2961 trackinfo.dwHoverTime = 0;
2963 /* call _TrackMouseEvent to see if we are currently tracking for this hwnd */
2964 _TrackMouseEvent(&trackinfo);
2966 /* Make sure tracking is enabled so we receive a WM_MOUSELEAVE message */
2967 if(!(trackinfo.dwFlags & TME_LEAVE))
2969 trackinfo.dwFlags = TME_LEAVE; /* notify upon leaving */
2971 /* call TRACKMOUSEEVENT so we receive a WM_MOUSELEAVE message */
2972 /* and can properly deactivate the hot chevron */
2973 _TrackMouseEvent(&trackinfo);
2976 lpChevronBand = &infoPtr->bands[iHitBand];
2977 if (!(lpChevronBand->fDraw & DRAW_CHEVRONHOT))
2979 lpChevronBand->fDraw |= DRAW_CHEVRONHOT;
2980 InvalidateRect(infoPtr->hwndSelf, &lpChevronBand->rcChevron, TRUE);
2981 infoPtr->ichevronhotBand = iHitBand;
2984 infoPtr->iOldBand = iHitBand;
2987 return 0;
2991 static inline LRESULT
2992 REBAR_NCCalcSize (const REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2994 HTHEME theme;
2995 RECT *rect = (RECT *)lParam;
2997 if (infoPtr->dwStyle & WS_BORDER) {
2998 rect->left = min(rect->left + GetSystemMetrics(SM_CXEDGE), rect->right);
2999 rect->right = max(rect->right - GetSystemMetrics(SM_CXEDGE), rect->left);
3000 rect->top = min(rect->top + GetSystemMetrics(SM_CYEDGE), rect->bottom);
3001 rect->bottom = max(rect->bottom - GetSystemMetrics(SM_CYEDGE), rect->top);
3003 else if ((theme = GetWindowTheme (infoPtr->hwndSelf)))
3005 /* FIXME: should use GetThemeInt */
3006 rect->top = min(rect->top + 1, rect->bottom);
3008 TRACE("new client=(%s)\n", wine_dbgstr_rect(rect));
3009 return 0;
3013 static LRESULT
3014 REBAR_NCCreate (HWND hwnd, WPARAM wParam, LPARAM lParam)
3016 LPCREATESTRUCTW cs = (LPCREATESTRUCTW) lParam;
3017 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
3018 RECT wnrc1, clrc1;
3019 NONCLIENTMETRICSW ncm;
3020 HFONT tfont;
3022 if (infoPtr != NULL) {
3023 ERR("Strange info structure pointer *not* NULL\n");
3024 return FALSE;
3027 if (TRACE_ON(rebar)) {
3028 GetWindowRect(hwnd, &wnrc1);
3029 GetClientRect(hwnd, &clrc1);
3030 TRACE("window=(%s) client=(%s) cs=(%d,%d %dx%d)\n",
3031 wine_dbgstr_rect(&wnrc1), wine_dbgstr_rect(&clrc1),
3032 cs->x, cs->y, cs->cx, cs->cy);
3035 /* allocate memory for info structure */
3036 infoPtr = (REBAR_INFO *)Alloc (sizeof(REBAR_INFO));
3037 SetWindowLongPtrW (hwnd, 0, (DWORD_PTR)infoPtr);
3039 /* initialize info structure - initial values are 0 */
3040 infoPtr->clrBk = CLR_NONE;
3041 infoPtr->clrText = CLR_NONE;
3042 infoPtr->clrBtnText = GetSysColor (COLOR_BTNTEXT);
3043 infoPtr->clrBtnFace = GetSysColor (COLOR_BTNFACE);
3044 infoPtr->iOldBand = -1;
3045 infoPtr->ichevronhotBand = -2;
3046 infoPtr->iGrabbedBand = -1;
3047 infoPtr->hwndSelf = hwnd;
3048 infoPtr->DoRedraw = TRUE;
3049 infoPtr->hcurArrow = LoadCursorW (0, (LPWSTR)IDC_ARROW);
3050 infoPtr->hcurHorz = LoadCursorW (0, (LPWSTR)IDC_SIZEWE);
3051 infoPtr->hcurVert = LoadCursorW (0, (LPWSTR)IDC_SIZENS);
3052 infoPtr->hcurDrag = LoadCursorW (0, (LPWSTR)IDC_SIZE);
3053 infoPtr->fStatus = 0;
3054 infoPtr->hFont = GetStockObject (SYSTEM_FONT);
3056 /* issue WM_NOTIFYFORMAT to get unicode status of parent */
3057 REBAR_NotifyFormat(infoPtr, 0, NF_REQUERY);
3059 /* Stow away the original style */
3060 infoPtr->orgStyle = cs->style;
3061 /* add necessary styles to the requested styles */
3062 infoPtr->dwStyle = cs->style | WS_VISIBLE;
3063 if ((infoPtr->dwStyle & CCS_LAYOUT_MASK) == 0)
3064 infoPtr->dwStyle |= CCS_TOP;
3065 SetWindowLongW (hwnd, GWL_STYLE, infoPtr->dwStyle);
3067 /* get font handle for Caption Font */
3068 ncm.cbSize = sizeof(ncm);
3069 SystemParametersInfoW (SPI_GETNONCLIENTMETRICS, ncm.cbSize, &ncm, 0);
3070 /* if the font is bold, set to normal */
3071 if (ncm.lfCaptionFont.lfWeight > FW_NORMAL) {
3072 ncm.lfCaptionFont.lfWeight = FW_NORMAL;
3074 tfont = CreateFontIndirectW (&ncm.lfCaptionFont);
3075 if (tfont) {
3076 infoPtr->hFont = infoPtr->hDefaultFont = tfont;
3079 /* native does:
3080 GetSysColor (numerous);
3081 GetSysColorBrush (numerous) (see WM_SYSCOLORCHANGE);
3082 *GetStockObject (SYSTEM_FONT);
3083 *SetWindowLong (hwnd, 0, info ptr);
3084 *WM_NOTIFYFORMAT;
3085 *SetWindowLong (hwnd, GWL_STYLE, style+0x10000001);
3086 WS_VISIBLE = 0x10000000;
3087 CCS_TOP = 0x00000001;
3088 *SystemParametersInfo (SPI_GETNONCLIENTMETRICS...);
3089 *CreateFontIndirect (lfCaptionFont from above);
3090 GetDC ();
3091 SelectObject (hdc, fontabove);
3092 GetTextMetrics (hdc, ); guessing is tmHeight
3093 SelectObject (hdc, oldfont);
3094 ReleaseDC ();
3095 GetWindowRect ();
3096 MapWindowPoints (0, parent, rectabove, 2);
3097 GetWindowRect ();
3098 GetClientRect ();
3099 ClientToScreen (clientrect);
3100 SetWindowPos (hwnd, 0, 0, 0, 0, 0, SWP_NOZORDER);
3102 return TRUE;
3106 static LRESULT
3107 REBAR_NCHitTest (const REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3109 NMMOUSE nmmouse;
3110 POINT clpt;
3111 INT i;
3112 UINT scrap;
3113 LRESULT ret = HTCLIENT;
3116 * Differences from doc at MSDN (as observed with version 4.71 of
3117 * comctl32.dll
3118 * 1. doc says nmmouse.pt is in screen coord, trace shows client coord.
3119 * 2. if band is not identified .dwItemSpec is 0xffffffff.
3120 * 3. native always seems to return HTCLIENT if notify return is 0.
3123 clpt.x = (short)LOWORD(lParam);
3124 clpt.y = (short)HIWORD(lParam);
3125 ScreenToClient (infoPtr->hwndSelf, &clpt);
3126 REBAR_InternalHitTest (infoPtr, &clpt, &scrap,
3127 (INT *)&nmmouse.dwItemSpec);
3128 nmmouse.dwItemData = 0;
3129 nmmouse.pt = clpt;
3130 nmmouse.dwHitInfo = 0;
3131 if ((i = REBAR_Notify((NMHDR *) &nmmouse, infoPtr, NM_NCHITTEST))) {
3132 TRACE("notify changed return value from %ld to %d\n",
3133 ret, i);
3134 ret = (LRESULT) i;
3136 TRACE("returning %ld, client point (%d,%d)\n", ret, clpt.x, clpt.y);
3137 return ret;
3141 static LRESULT
3142 REBAR_NCPaint (const REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3144 RECT rcWindow;
3145 HDC hdc;
3146 HTHEME theme;
3148 if (infoPtr->dwStyle & WS_MINIMIZE)
3149 return 0; /* Nothing to do */
3151 if (infoPtr->dwStyle & WS_BORDER) {
3153 /* adjust rectangle and draw the necessary edge */
3154 if (!(hdc = GetDCEx( infoPtr->hwndSelf, 0, DCX_USESTYLE | DCX_WINDOW )))
3155 return 0;
3156 GetWindowRect (infoPtr->hwndSelf, &rcWindow);
3157 OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
3158 TRACE("rect (%s)\n", wine_dbgstr_rect(&rcWindow));
3159 DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_RECT);
3160 ReleaseDC( infoPtr->hwndSelf, hdc );
3162 else if ((theme = GetWindowTheme (infoPtr->hwndSelf)))
3164 /* adjust rectangle and draw the necessary edge */
3165 if (!(hdc = GetDCEx( infoPtr->hwndSelf, 0, DCX_USESTYLE | DCX_WINDOW )))
3166 return 0;
3167 GetWindowRect (infoPtr->hwndSelf, &rcWindow);
3168 OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
3169 TRACE("rect (%s)\n", wine_dbgstr_rect(&rcWindow));
3170 DrawThemeEdge (theme, hdc, 0, 0, &rcWindow, BDR_RAISEDINNER, BF_TOP, NULL);
3171 ReleaseDC( infoPtr->hwndSelf, hdc );
3174 return 0;
3178 static LRESULT
3179 REBAR_NotifyFormat (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3181 INT i;
3183 if (lParam == NF_REQUERY) {
3184 i = SendMessageW(REBAR_GetNotifyParent (infoPtr),
3185 WM_NOTIFYFORMAT, (WPARAM)infoPtr->hwndSelf, NF_QUERY);
3186 if ((i != NFR_ANSI) && (i != NFR_UNICODE)) {
3187 ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n", i);
3188 i = NFR_ANSI;
3190 infoPtr->bUnicode = (i == NFR_UNICODE) ? 1 : 0;
3191 return (LRESULT)i;
3193 return (LRESULT)((infoPtr->bUnicode) ? NFR_UNICODE : NFR_ANSI);
3197 static LRESULT
3198 REBAR_Paint (const REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3200 HDC hdc;
3201 PAINTSTRUCT ps;
3202 RECT rc;
3204 GetClientRect(infoPtr->hwndSelf, &rc);
3205 hdc = wParam==0 ? BeginPaint (infoPtr->hwndSelf, &ps) : (HDC)wParam;
3207 TRACE("painting (%s) client (%s)\n",
3208 wine_dbgstr_rect(&ps.rcPaint), wine_dbgstr_rect(&rc));
3210 if (ps.fErase) {
3211 /* Erase area of paint if requested */
3212 REBAR_InternalEraseBkGnd (infoPtr, wParam, lParam, &ps.rcPaint);
3215 REBAR_Refresh (infoPtr, hdc);
3216 if (!wParam)
3217 EndPaint (infoPtr->hwndSelf, &ps);
3218 return 0;
3222 static LRESULT
3223 REBAR_SetCursor (const REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3225 POINT pt;
3226 UINT flags;
3228 TRACE("code=0x%X id=0x%X\n", LOWORD(lParam), HIWORD(lParam));
3230 GetCursorPos (&pt);
3231 ScreenToClient (infoPtr->hwndSelf, &pt);
3233 REBAR_InternalHitTest (infoPtr, &pt, &flags, NULL);
3235 if (flags == RBHT_GRABBER) {
3236 if ((infoPtr->dwStyle & CCS_VERT) &&
3237 !(infoPtr->dwStyle & RBS_VERTICALGRIPPER))
3238 SetCursor (infoPtr->hcurVert);
3239 else
3240 SetCursor (infoPtr->hcurHorz);
3242 else if (flags != RBHT_CLIENT)
3243 SetCursor (infoPtr->hcurArrow);
3245 return 0;
3249 static LRESULT
3250 REBAR_SetFont (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3252 REBAR_BAND *lpBand;
3253 UINT i;
3255 infoPtr->hFont = (HFONT)wParam;
3257 /* revalidate all bands to change sizes of text in headers of bands */
3258 for (i=0; i<infoPtr->uNumBands; i++) {
3259 lpBand = &infoPtr->bands[i];
3260 REBAR_ValidateBand (infoPtr, lpBand);
3263 REBAR_Layout(infoPtr, NULL);
3264 return 0;
3268 static inline LRESULT
3269 REBAR_SetRedraw (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3270 /*****************************************************
3272 * Function;
3273 * Handles the WM_SETREDRAW message.
3275 * Documentation:
3276 * According to testing V4.71 of COMCTL32 returns the
3277 * *previous* status of the redraw flag (either 0 or -1)
3278 * instead of the MSDN documented value of 0 if handled
3280 *****************************************************/
3282 BOOL oldredraw = infoPtr->DoRedraw;
3284 TRACE("set to %s, fStatus=%08x\n",
3285 (wParam) ? "TRUE" : "FALSE", infoPtr->fStatus);
3286 infoPtr->DoRedraw = (BOOL) wParam;
3287 if (wParam) {
3288 if (infoPtr->fStatus & BAND_NEEDS_REDRAW) {
3289 REBAR_MoveChildWindows (infoPtr, 0, infoPtr->uNumBands);
3290 REBAR_ForceResize (infoPtr);
3291 InvalidateRect (infoPtr->hwndSelf, 0, TRUE);
3293 infoPtr->fStatus &= ~BAND_NEEDS_REDRAW;
3295 return (oldredraw) ? -1 : 0;
3299 static LRESULT
3300 REBAR_Size (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3302 TRACE("wParam=%lx, lParam=%lx\n", wParam, lParam);
3304 /* avoid auto resize infinite recursion */
3305 if (infoPtr->fStatus & AUTO_RESIZE) {
3306 infoPtr->fStatus &= ~AUTO_RESIZE;
3307 TRACE("AUTO_RESIZE was set, reset, fStatus=%08x lparam=%08lx\n",
3308 infoPtr->fStatus, lParam);
3309 return 0;
3312 /* FIXME: wrong */
3313 if (infoPtr->dwStyle & RBS_AUTOSIZE) {
3314 NMRBAUTOSIZE autosize;
3316 GetClientRect(infoPtr->hwndSelf, &autosize.rcTarget);
3317 autosize.fChanged = 0; /* ??? */
3318 autosize.rcActual = autosize.rcTarget; /* ??? */
3319 REBAR_Notify((NMHDR *) &autosize, infoPtr, RBN_AUTOSIZE);
3320 TRACE("RBN_AUTOSIZE client=(%d,%d), lp=%08lx\n",
3321 autosize.rcTarget.right, autosize.rcTarget.bottom, lParam);
3324 REBAR_Layout(infoPtr, NULL);
3326 return 0;
3330 static LRESULT
3331 REBAR_StyleChanged (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3333 STYLESTRUCT *ss = (STYLESTRUCT *)lParam;
3335 TRACE("current style=%08x, styleOld=%08x, style being set to=%08x\n",
3336 infoPtr->dwStyle, ss->styleOld, ss->styleNew);
3337 infoPtr->orgStyle = infoPtr->dwStyle = ss->styleNew;
3338 if (GetWindowTheme (infoPtr->hwndSelf))
3339 infoPtr->dwStyle &= ~WS_BORDER;
3340 /* maybe it should be COMMON_STYLES like in toolbar */
3341 if ((ss->styleNew ^ ss->styleOld) & CCS_VERT)
3342 REBAR_Layout(infoPtr, NULL);
3344 return FALSE;
3347 /* update theme after a WM_THEMECHANGED message */
3348 static LRESULT theme_changed (REBAR_INFO* infoPtr)
3350 HTHEME theme = GetWindowTheme (infoPtr->hwndSelf);
3351 CloseThemeData (theme);
3352 theme = OpenThemeData (infoPtr->hwndSelf, themeClass);
3353 /* WS_BORDER disappears when theming is enabled and reappears when
3354 * disabled... */
3355 infoPtr->dwStyle &= ~WS_BORDER;
3356 infoPtr->dwStyle |= theme ? 0 : (infoPtr->orgStyle & WS_BORDER);
3357 return 0;
3360 static LRESULT
3361 REBAR_WindowPosChanged (const REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3363 LRESULT ret;
3364 RECT rc;
3366 ret = DefWindowProcW(infoPtr->hwndSelf, WM_WINDOWPOSCHANGED,
3367 wParam, lParam);
3368 GetWindowRect(infoPtr->hwndSelf, &rc);
3369 TRACE("hwnd %p new pos (%s)\n", infoPtr->hwndSelf, wine_dbgstr_rect(&rc));
3370 return ret;
3374 static LRESULT WINAPI
3375 REBAR_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
3377 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
3379 TRACE("hwnd=%p msg=%x wparam=%lx lparam=%lx\n",
3380 hwnd, uMsg, wParam, lParam);
3381 if (!infoPtr && (uMsg != WM_NCCREATE))
3382 return DefWindowProcW (hwnd, uMsg, wParam, lParam);
3383 switch (uMsg)
3385 /* case RB_BEGINDRAG: */
3387 case RB_DELETEBAND:
3388 return REBAR_DeleteBand (infoPtr, wParam, lParam);
3390 /* case RB_DRAGMOVE: */
3391 /* case RB_ENDDRAG: */
3393 case RB_GETBANDBORDERS:
3394 return REBAR_GetBandBorders (infoPtr, wParam, lParam);
3396 case RB_GETBANDCOUNT:
3397 return REBAR_GetBandCount (infoPtr);
3399 case RB_GETBANDINFO_OLD:
3400 case RB_GETBANDINFOA:
3401 return REBAR_GetBandInfoT(infoPtr, wParam, lParam, FALSE);
3403 case RB_GETBANDINFOW:
3404 return REBAR_GetBandInfoT(infoPtr, wParam, lParam, TRUE);
3406 case RB_GETBARHEIGHT:
3407 return REBAR_GetBarHeight (infoPtr, wParam, lParam);
3409 case RB_GETBARINFO:
3410 return REBAR_GetBarInfo (infoPtr, wParam, lParam);
3412 case RB_GETBKCOLOR:
3413 return REBAR_GetBkColor (infoPtr);
3415 /* case RB_GETCOLORSCHEME: */
3416 /* case RB_GETDROPTARGET: */
3418 case RB_GETPALETTE:
3419 return REBAR_GetPalette (infoPtr, wParam, lParam);
3421 case RB_GETRECT:
3422 return REBAR_GetRect (infoPtr, wParam, lParam);
3424 case RB_GETROWCOUNT:
3425 return REBAR_GetRowCount (infoPtr);
3427 case RB_GETROWHEIGHT:
3428 return REBAR_GetRowHeight (infoPtr, wParam, lParam);
3430 case RB_GETTEXTCOLOR:
3431 return REBAR_GetTextColor (infoPtr);
3433 case RB_GETTOOLTIPS:
3434 return REBAR_GetToolTips (infoPtr);
3436 case RB_GETUNICODEFORMAT:
3437 return REBAR_GetUnicodeFormat (infoPtr);
3439 case CCM_GETVERSION:
3440 return REBAR_GetVersion (infoPtr);
3442 case RB_HITTEST:
3443 return REBAR_HitTest (infoPtr, wParam, lParam);
3445 case RB_IDTOINDEX:
3446 return REBAR_IdToIndex (infoPtr, wParam, lParam);
3448 case RB_INSERTBANDA:
3449 return REBAR_InsertBandT(infoPtr, wParam, lParam, FALSE);
3451 case RB_INSERTBANDW:
3452 return REBAR_InsertBandT(infoPtr, wParam, lParam, TRUE);
3454 case RB_MAXIMIZEBAND:
3455 return REBAR_MaximizeBand (infoPtr, wParam, lParam);
3457 case RB_MINIMIZEBAND:
3458 return REBAR_MinimizeBand (infoPtr, wParam, lParam);
3460 case RB_MOVEBAND:
3461 return REBAR_MoveBand (infoPtr, wParam, lParam);
3463 case RB_PUSHCHEVRON:
3464 return REBAR_PushChevron (infoPtr, wParam, lParam);
3466 case RB_SETBANDINFOA:
3467 return REBAR_SetBandInfoT(infoPtr, wParam, lParam, FALSE);
3469 case RB_SETBANDINFOW:
3470 return REBAR_SetBandInfoT(infoPtr, wParam, lParam, TRUE);
3472 case RB_SETBARINFO:
3473 return REBAR_SetBarInfo (infoPtr, wParam, lParam);
3475 case RB_SETBKCOLOR:
3476 return REBAR_SetBkColor (infoPtr, wParam, lParam);
3478 /* case RB_SETCOLORSCHEME: */
3479 /* case RB_SETPALETTE: */
3480 /* return REBAR_GetPalette (infoPtr, wParam, lParam); */
3482 case RB_SETPARENT:
3483 return REBAR_SetParent (infoPtr, wParam, lParam);
3485 case RB_SETTEXTCOLOR:
3486 return REBAR_SetTextColor (infoPtr, wParam, lParam);
3488 /* case RB_SETTOOLTIPS: */
3490 case RB_SETUNICODEFORMAT:
3491 return REBAR_SetUnicodeFormat (infoPtr, wParam);
3493 case CCM_SETVERSION:
3494 return REBAR_SetVersion (infoPtr, (INT)wParam);
3496 case RB_SHOWBAND:
3497 return REBAR_ShowBand (infoPtr, wParam, lParam);
3499 case RB_SIZETORECT:
3500 return REBAR_SizeToRect (infoPtr, wParam, lParam);
3503 /* Messages passed to parent */
3504 case WM_COMMAND:
3505 case WM_DRAWITEM:
3506 case WM_NOTIFY:
3507 return SendMessageW(REBAR_GetNotifyParent (infoPtr), uMsg, wParam, lParam);
3510 /* case WM_CHARTOITEM: supported according to ControlSpy */
3512 case WM_CREATE:
3513 return REBAR_Create (infoPtr, wParam, lParam);
3515 case WM_DESTROY:
3516 return REBAR_Destroy (infoPtr, wParam, lParam);
3518 case WM_ERASEBKGND:
3519 return REBAR_EraseBkGnd (infoPtr, wParam, lParam);
3521 case WM_GETFONT:
3522 return REBAR_GetFont (infoPtr, wParam, lParam);
3524 /* case WM_LBUTTONDBLCLK: supported according to ControlSpy */
3526 case WM_LBUTTONDOWN:
3527 return REBAR_LButtonDown (infoPtr, wParam, lParam);
3529 case WM_LBUTTONUP:
3530 return REBAR_LButtonUp (infoPtr, wParam, lParam);
3532 /* case WM_MEASUREITEM: supported according to ControlSpy */
3534 case WM_MOUSEMOVE:
3535 return REBAR_MouseMove (infoPtr, wParam, lParam);
3537 case WM_MOUSELEAVE:
3538 return REBAR_MouseLeave (infoPtr, wParam, lParam);
3540 case WM_NCCALCSIZE:
3541 return REBAR_NCCalcSize (infoPtr, wParam, lParam);
3543 case WM_NCCREATE:
3544 return REBAR_NCCreate (hwnd, wParam, lParam);
3546 case WM_NCHITTEST:
3547 return REBAR_NCHitTest (infoPtr, wParam, lParam);
3549 case WM_NCPAINT:
3550 return REBAR_NCPaint (infoPtr, wParam, lParam);
3552 case WM_NOTIFYFORMAT:
3553 return REBAR_NotifyFormat (infoPtr, wParam, lParam);
3555 case WM_PRINTCLIENT:
3556 case WM_PAINT:
3557 return REBAR_Paint (infoPtr, wParam, lParam);
3559 /* case WM_PALETTECHANGED: supported according to ControlSpy */
3560 /* case WM_QUERYNEWPALETTE:supported according to ControlSpy */
3561 /* case WM_RBUTTONDOWN: supported according to ControlSpy */
3562 /* case WM_RBUTTONUP: supported according to ControlSpy */
3564 case WM_SETCURSOR:
3565 return REBAR_SetCursor (infoPtr, wParam, lParam);
3567 case WM_SETFONT:
3568 return REBAR_SetFont (infoPtr, wParam, lParam);
3570 case WM_SETREDRAW:
3571 return REBAR_SetRedraw (infoPtr, wParam, lParam);
3573 case WM_SIZE:
3574 return REBAR_Size (infoPtr, wParam, lParam);
3576 case WM_STYLECHANGED:
3577 return REBAR_StyleChanged (infoPtr, wParam, lParam);
3579 case WM_THEMECHANGED:
3580 return theme_changed (infoPtr);
3582 /* case WM_SYSCOLORCHANGE: supported according to ControlSpy */
3583 /* "Applications that have brushes using the existing system colors
3584 should delete those brushes and recreate them using the new
3585 system colors." per MSDN */
3587 /* case WM_VKEYTOITEM: supported according to ControlSpy */
3588 /* case WM_WININICHANGE: */
3590 case WM_WINDOWPOSCHANGED:
3591 return REBAR_WindowPosChanged (infoPtr, wParam, lParam);
3593 default:
3594 if ((uMsg >= WM_USER) && (uMsg < WM_APP))
3595 ERR("unknown msg %04x wp=%08lx lp=%08lx\n",
3596 uMsg, wParam, lParam);
3597 return DefWindowProcW (hwnd, uMsg, wParam, lParam);
3602 VOID
3603 REBAR_Register (void)
3605 WNDCLASSW wndClass;
3607 ZeroMemory (&wndClass, sizeof(WNDCLASSW));
3608 wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS;
3609 wndClass.lpfnWndProc = REBAR_WindowProc;
3610 wndClass.cbClsExtra = 0;
3611 wndClass.cbWndExtra = sizeof(REBAR_INFO *);
3612 wndClass.hCursor = 0;
3613 wndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
3614 #if GLATESTING
3615 wndClass.hbrBackground = CreateSolidBrush(RGB(0,128,0));
3616 #endif
3617 wndClass.lpszClassName = REBARCLASSNAMEW;
3619 RegisterClassW (&wndClass);
3621 mindragx = GetSystemMetrics (SM_CXDRAG);
3622 mindragy = GetSystemMetrics (SM_CYDRAG);
3627 VOID
3628 REBAR_Unregister (void)
3630 UnregisterClassW (REBARCLASSNAMEW, NULL);