reshuffling of dlls
[reactos.git] / reactos / dll / win32 / comctl32 / rebar.c
1 /*
2 * Rebar control
3 *
4 * Copyright 1998, 1999 Eric Kohl
5 *
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.
10 *
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.
15 *
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 * NOTES
21 *
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.
24 *
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.
28 *
29 * TODO
30 * Styles:
31 * - RBS_DBLCLKTOGGLE
32 * - RBS_FIXEDORDER
33 * - RBS_REGISTERDROP
34 * - RBS_TOOLTIPS
35 * - CCS_NORESIZE
36 * - CCS_NOMOVEX
37 * - CCS_NOMOVEY
38 * Messages:
39 * - RB_BEGINDRAG
40 * - RB_DRAGMOVE
41 * - RB_ENDDRAG
42 * - RB_GETBANDMARGINS
43 * - RB_GETCOLORSCHEME
44 * - RB_GETDROPTARGET
45 * - RB_GETPALETTE
46 * - RB_SETCOLORSCHEME
47 * - RB_SETPALETTE
48 * - RB_SETTOOLTIPS
49 * - WM_CHARTOITEM
50 * - WM_LBUTTONDBLCLK
51 * - WM_MEASUREITEM
52 * - WM_PALETTECHANGED
53 * - WM_QUERYNEWPALETTE
54 * - WM_RBUTTONDOWN
55 * - WM_RBUTTONUP
56 * - WM_SYSCOLORCHANGE
57 * - WM_VKEYTOITEM
58 * - WM_WININICHANGE
59 * Notifications:
60 * - NM_HCHITTEST
61 * - NM_RELEASEDCAPTURE
62 * - RBN_AUTOBREAK
63 * - RBN_GETOBJECT
64 * - RBN_MINMAX
65 * Band styles:
66 * - RBBS_FIXEDBMP
67 * Native uses (on each draw!!) SM_CYBORDER (or SM_CXBORDER for CCS_VERT)
68 * to set the size of the separator width (the value SEP_WIDTH_SIZE
69 * in here). Should be fixed!!
70 */
71
72 /*
73 * Testing: set to 1 to make background brush *always* green
74 */
75 #define GLATESTING 0
76
77 /*
78 *
79 * 2. At "FIXME: problem # 2" WinRAR:
80 * if "#if 1" then last band draws in separate row
81 * if "#if 0" then last band draws in previous row *** just like native ***
82 *
83 */
84 #define PROBLEM2 0
85
86 /*
87 * 3. REBAR_MoveChildWindows should have a loop because more than
88 * one pass is made (together with the RBN_CHILDSIZEs) is made on
89 * at least RB_INSERTBAND
90 */
91
92 #include <stdarg.h>
93 #include <stdlib.h>
94 #include <string.h>
95
96 #include "windef.h"
97 #include "winbase.h"
98 #include "wingdi.h"
99 #include "wine/unicode.h"
100 #include "winuser.h"
101 #include "winnls.h"
102 #include "commctrl.h"
103 #include "comctl32.h"
104 #include "uxtheme.h"
105 #include "tmschema.h"
106 #include "wine/debug.h"
107
108 WINE_DEFAULT_DEBUG_CHANNEL(rebar);
109
110 typedef struct
111 {
112 UINT fStyle;
113 UINT fMask;
114 COLORREF clrFore;
115 COLORREF clrBack;
116 INT iImage;
117 HWND hwndChild;
118 UINT cxMinChild; /* valid if _CHILDSIZE */
119 UINT cyMinChild; /* valid if _CHILDSIZE */
120 UINT cx; /* valid if _SIZE */
121 HBITMAP hbmBack;
122 UINT wID;
123 UINT cyChild; /* valid if _CHILDSIZE */
124 UINT cyMaxChild; /* valid if _CHILDSIZE */
125 UINT cyIntegral; /* valid if _CHILDSIZE */
126 UINT cxIdeal;
127 LPARAM lParam;
128 UINT cxHeader;
129
130 UINT lcx; /* minimum cx for band */
131 UINT ccx; /* current cx for band */
132 UINT hcx; /* maximum cx for band */
133 UINT lcy; /* minimum cy for band */
134 UINT ccy; /* current cy for band */
135 UINT hcy; /* maximum cy for band */
136
137 SIZE offChild; /* x,y offset if child is not FIXEDSIZE */
138 UINT uMinHeight;
139 INT iRow; /* zero-based index of the row this band assigned to */
140 UINT fStatus; /* status flags, reset only by _Validate */
141 UINT fDraw; /* drawing flags, reset only by _Layout */
142 UINT uCDret; /* last return from NM_CUSTOMDRAW */
143 RECT rcoldBand; /* previous calculated band rectangle */
144 RECT rcBand; /* calculated band rectangle */
145 RECT rcGripper; /* calculated gripper rectangle */
146 RECT rcCapImage; /* calculated caption image rectangle */
147 RECT rcCapText; /* calculated caption text rectangle */
148 RECT rcChild; /* calculated child rectangle */
149 RECT rcChevron; /* calculated chevron rectangle */
150
151 LPWSTR lpText;
152 HWND hwndPrevParent;
153 } REBAR_BAND;
154
155 /* fStatus flags */
156 #define HAS_GRIPPER 0x00000001
157 #define HAS_IMAGE 0x00000002
158 #define HAS_TEXT 0x00000004
159
160 /* fDraw flags */
161 #define DRAW_GRIPPER 0x00000001
162 #define DRAW_IMAGE 0x00000002
163 #define DRAW_TEXT 0x00000004
164 #define DRAW_RIGHTSEP 0x00000010
165 #define DRAW_BOTTOMSEP 0x00000020
166 #define DRAW_CHEVRONHOT 0x00000040
167 #define DRAW_CHEVRONPUSHED 0x00000080
168 #define DRAW_LAST_IN_ROW 0x00000100
169 #define DRAW_FIRST_IN_ROW 0x00000200
170 #define NTF_INVALIDATE 0x01000000
171
172 typedef struct
173 {
174 COLORREF clrBk; /* background color */
175 COLORREF clrText; /* text color */
176 COLORREF clrBtnText; /* system color for BTNTEXT */
177 COLORREF clrBtnFace; /* system color for BTNFACE */
178 HIMAGELIST himl; /* handle to imagelist */
179 UINT uNumBands; /* # of bands in rebar (first=0, last=uNumBands-1 */
180 UINT uNumRows; /* # of rows of bands (first=1, last=uNumRows */
181 HWND hwndSelf; /* handle of REBAR window itself */
182 HWND hwndToolTip; /* handle to the tool tip control */
183 HWND hwndNotify; /* notification window (parent) */
184 HFONT hDefaultFont;
185 HFONT hFont; /* handle to the rebar's font */
186 SIZE imageSize; /* image size (image list) */
187 DWORD dwStyle; /* window style */
188 DWORD orgStyle; /* original style (dwStyle may change) */
189 SIZE calcSize; /* calculated rebar size */
190 SIZE oldSize; /* previous calculated rebar size */
191 BOOL bUnicode; /* TRUE if this window is W type */
192 BOOL NtfUnicode; /* TRUE if parent wants notify in W format */
193 BOOL DoRedraw; /* TRUE to acutally draw bands */
194 UINT fStatus; /* Status flags (see below) */
195 HCURSOR hcurArrow; /* handle to the arrow cursor */
196 HCURSOR hcurHorz; /* handle to the EW cursor */
197 HCURSOR hcurVert; /* handle to the NS cursor */
198 HCURSOR hcurDrag; /* handle to the drag cursor */
199 INT iVersion; /* version number */
200 POINT dragStart; /* x,y of button down */
201 POINT dragNow; /* x,y of this MouseMove */
202 INT iOldBand; /* last band that had the mouse cursor over it */
203 INT ihitoffset; /* offset of hotspot from gripper.left */
204 POINT origin; /* left/upper corner of client */
205 INT ichevronhotBand; /* last band that had a hot chevron */
206 INT iGrabbedBand;/* band number of band whose gripper was grabbed */
207
208 REBAR_BAND *bands; /* pointer to the array of rebar bands */
209 } REBAR_INFO;
210
211 /* fStatus flags */
212 #define BEGIN_DRAG_ISSUED 0x00000001
213 #define AUTO_RESIZE 0x00000002
214 #define RESIZE_ANYHOW 0x00000004
215 #define NTF_HGHTCHG 0x00000008
216 #define BAND_NEEDS_LAYOUT 0x00000010
217 #define BAND_NEEDS_REDRAW 0x00000020
218 #define CREATE_RUNNING 0x00000040
219
220 /* ---- REBAR layout constants. Mostly determined by ---- */
221 /* ---- experiment on WIN 98. ---- */
222
223 /* Width (or height) of separators between bands (either horz. or */
224 /* vert.). True only if RBS_BANDBORDERS is set */
225 #define SEP_WIDTH_SIZE 2
226 #define SEP_WIDTH ((infoPtr->dwStyle & RBS_BANDBORDERS) ? SEP_WIDTH_SIZE : 0)
227
228 /* Blank (background color) space between Gripper (if present) */
229 /* and next item (image, text, or window). Always present */
230 #define REBAR_ALWAYS_SPACE 4
231
232 /* Blank (background color) space after Image (if present). */
233 #define REBAR_POST_IMAGE 2
234
235 /* Blank (background color) space after Text (if present). */
236 #define REBAR_POST_TEXT 4
237
238 /* Height of vertical gripper in a CCS_VERT rebar. */
239 #define GRIPPER_HEIGHT 16
240
241 /* Blank (background color) space before Gripper (if present). */
242 #define REBAR_PRE_GRIPPER 2
243
244 /* Width (of normal vertical gripper) or height (of horz. gripper) */
245 /* if present. */
246 #define GRIPPER_WIDTH 3
247
248 /* Width of the chevron button if present */
249 #define CHEVRON_WIDTH 10
250
251 /* Height of divider for Rebar if not disabled (CCS_NODIVIDER) */
252 /* either top or bottom */
253 #define REBAR_DIVIDER 2
254
255 /* minimium vertical height of a normal bar */
256 /* or minimum width of a CCS_VERT bar - from experiment on Win2k */
257 #define REBAR_MINSIZE 23
258
259 /* This is the increment that is used over the band height */
260 #define REBARSPACE(a) ((a->fStyle & RBBS_CHILDEDGE) ? 2*REBAR_DIVIDER : 0)
261
262 /* ---- End of REBAR layout constants. ---- */
263
264 #define RB_GETBANDINFO_OLD (WM_USER+5) /* obsoleted after IE3, but we have to support it anyway */
265
266 /* The following 6 defines return the proper rcBand element */
267 /* depending on whether CCS_VERT was set. */
268 #define rcBlt(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.top : b->rcBand.left)
269 #define rcBrb(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.bottom : b->rcBand.right)
270 #define rcBw(b) ((infoPtr->dwStyle & CCS_VERT) ? (b->rcBand.bottom - b->rcBand.top) : \
271 (b->rcBand.right - b->rcBand.left))
272 #define ircBlt(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.left : b->rcBand.top)
273 #define ircBrb(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.right : b->rcBand.bottom)
274 #define ircBw(b) ((infoPtr->dwStyle & CCS_VERT) ? (b->rcBand.right - b->rcBand.left) : \
275 (b->rcBand.bottom - b->rcBand.top))
276
277 /* The following define determines if a given band is hidden */
278 #define HIDDENBAND(a) (((a)->fStyle & RBBS_HIDDEN) || \
279 ((infoPtr->dwStyle & CCS_VERT) && \
280 ((a)->fStyle & RBBS_NOVERT)))
281
282 /* The following defines adjust the right or left end of a rectangle */
283 #define READJ(b,i) do { if(infoPtr->dwStyle & CCS_VERT) b->rcBand.bottom+=(i); \
284 else b->rcBand.right += (i); } while(0)
285 #define LEADJ(b,i) do { if(infoPtr->dwStyle & CCS_VERT) b->rcBand.top+=(i); \
286 else b->rcBand.left += (i); } while(0)
287
288
289 #define REBAR_GetInfoPtr(wndPtr) ((REBAR_INFO *)GetWindowLongPtrW (hwnd, 0))
290
291
292 /* "constant values" retrieved when DLL was initialized */
293 /* FIXME we do this when the classes are registered. */
294 static UINT mindragx = 0;
295 static UINT mindragy = 0;
296
297 static const char *band_stylename[] = {
298 "RBBS_BREAK", /* 0001 */
299 "RBBS_FIXEDSIZE", /* 0002 */
300 "RBBS_CHILDEDGE", /* 0004 */
301 "RBBS_HIDDEN", /* 0008 */
302 "RBBS_NOVERT", /* 0010 */
303 "RBBS_FIXEDBMP", /* 0020 */
304 "RBBS_VARIABLEHEIGHT", /* 0040 */
305 "RBBS_GRIPPERALWAYS", /* 0080 */
306 "RBBS_NOGRIPPER", /* 0100 */
307 NULL };
308
309 static const char *band_maskname[] = {
310 "RBBIM_STYLE", /* 0x00000001 */
311 "RBBIM_COLORS", /* 0x00000002 */
312 "RBBIM_TEXT", /* 0x00000004 */
313 "RBBIM_IMAGE", /* 0x00000008 */
314 "RBBIM_CHILD", /* 0x00000010 */
315 "RBBIM_CHILDSIZE", /* 0x00000020 */
316 "RBBIM_SIZE", /* 0x00000040 */
317 "RBBIM_BACKGROUND", /* 0x00000080 */
318 "RBBIM_ID", /* 0x00000100 */
319 "RBBIM_IDEALSIZE", /* 0x00000200 */
320 "RBBIM_LPARAM", /* 0x00000400 */
321 "RBBIM_HEADERSIZE", /* 0x00000800 */
322 NULL };
323
324
325 static CHAR line[200];
326
327 static const WCHAR themeClass[] = { 'R','e','b','a','r',0 };
328
329 static CHAR *
330 REBAR_FmtStyle( UINT style)
331 {
332 INT i = 0;
333
334 *line = 0;
335 while (band_stylename[i]) {
336 if (style & (1<<i)) {
337 if (*line != 0) strcat(line, " | ");
338 strcat(line, band_stylename[i]);
339 }
340 i++;
341 }
342 return line;
343 }
344
345
346 static CHAR *
347 REBAR_FmtMask( UINT mask)
348 {
349 INT i = 0;
350
351 *line = 0;
352 while (band_maskname[i]) {
353 if (mask & (1<<i)) {
354 if (*line != 0) strcat(line, " | ");
355 strcat(line, band_maskname[i]);
356 }
357 i++;
358 }
359 return line;
360 }
361
362
363 static VOID
364 REBAR_DumpBandInfo( LPREBARBANDINFOA pB)
365 {
366 if( !TRACE_ON(rebar) ) return;
367 TRACE("band info: ");
368 if (pB->fMask & RBBIM_ID)
369 TRACE("ID=%u, ", pB->wID);
370 TRACE("size=%u, child=%p", pB->cbSize, pB->hwndChild);
371 if (pB->fMask & RBBIM_COLORS)
372 TRACE(", clrF=0x%06lx, clrB=0x%06lx", pB->clrFore, pB->clrBack);
373 TRACE("\n");
374
375 TRACE("band info: mask=0x%08x (%s)\n", pB->fMask, REBAR_FmtMask(pB->fMask));
376 if (pB->fMask & RBBIM_STYLE)
377 TRACE("band info: style=0x%08x (%s)\n", pB->fStyle, REBAR_FmtStyle(pB->fStyle));
378 if (pB->fMask & (RBBIM_SIZE | RBBIM_IDEALSIZE | RBBIM_HEADERSIZE | RBBIM_LPARAM )) {
379 TRACE("band info:");
380 if (pB->fMask & RBBIM_SIZE)
381 TRACE(" cx=%u", pB->cx);
382 if (pB->fMask & RBBIM_IDEALSIZE)
383 TRACE(" xIdeal=%u", pB->cxIdeal);
384 if (pB->fMask & RBBIM_HEADERSIZE)
385 TRACE(" xHeader=%u", pB->cxHeader);
386 if (pB->fMask & RBBIM_LPARAM)
387 TRACE(" lParam=0x%08lx", pB->lParam);
388 TRACE("\n");
389 }
390 if (pB->fMask & RBBIM_CHILDSIZE)
391 TRACE("band info: xMin=%u, yMin=%u, yChild=%u, yMax=%u, yIntgl=%u\n",
392 pB->cxMinChild,
393 pB->cyMinChild, pB->cyChild, pB->cyMaxChild, pB->cyIntegral);
394 }
395
396 static VOID
397 REBAR_DumpBand (REBAR_INFO *iP)
398 {
399 REBAR_BAND *pB;
400 UINT i;
401
402 if(! TRACE_ON(rebar) ) return;
403
404 TRACE("hwnd=%p: color=%08lx/%08lx, bands=%u, rows=%u, cSize=%ld,%ld\n",
405 iP->hwndSelf, iP->clrText, iP->clrBk, iP->uNumBands, iP->uNumRows,
406 iP->calcSize.cx, iP->calcSize.cy);
407 TRACE("hwnd=%p: flags=%08x, dragStart=%ld,%ld, dragNow=%ld,%ld, iGrabbedBand=%d\n",
408 iP->hwndSelf, iP->fStatus, iP->dragStart.x, iP->dragStart.y,
409 iP->dragNow.x, iP->dragNow.y,
410 iP->iGrabbedBand);
411 TRACE("hwnd=%p: style=%08lx, I'm Unicode=%s, notify in Unicode=%s, redraw=%s\n",
412 iP->hwndSelf, iP->dwStyle, (iP->bUnicode)?"TRUE":"FALSE",
413 (iP->NtfUnicode)?"TRUE":"FALSE", (iP->DoRedraw)?"TRUE":"FALSE");
414 for (i = 0; i < iP->uNumBands; i++) {
415 pB = &iP->bands[i];
416 TRACE("band # %u:", i);
417 if (pB->fMask & RBBIM_ID)
418 TRACE(" ID=%u", pB->wID);
419 if (pB->fMask & RBBIM_CHILD)
420 TRACE(" child=%p", pB->hwndChild);
421 if (pB->fMask & RBBIM_COLORS)
422 TRACE(" clrF=0x%06lx clrB=0x%06lx", pB->clrFore, pB->clrBack);
423 TRACE("\n");
424 TRACE("band # %u: mask=0x%08x (%s)\n", i, pB->fMask, REBAR_FmtMask(pB->fMask));
425 if (pB->fMask & RBBIM_STYLE)
426 TRACE("band # %u: style=0x%08x (%s)\n",
427 i, pB->fStyle, REBAR_FmtStyle(pB->fStyle));
428 TRACE("band # %u: uMinH=%u xHeader=%u",
429 i, pB->uMinHeight, pB->cxHeader);
430 if (pB->fMask & (RBBIM_SIZE | RBBIM_IDEALSIZE | RBBIM_LPARAM )) {
431 if (pB->fMask & RBBIM_SIZE)
432 TRACE(" cx=%u", pB->cx);
433 if (pB->fMask & RBBIM_IDEALSIZE)
434 TRACE(" xIdeal=%u", pB->cxIdeal);
435 if (pB->fMask & RBBIM_LPARAM)
436 TRACE(" lParam=0x%08lx", pB->lParam);
437 }
438 TRACE("\n");
439 if (RBBIM_CHILDSIZE)
440 TRACE("band # %u: xMin=%u, yMin=%u, yChild=%u, yMax=%u, yIntgl=%u\n",
441 i, pB->cxMinChild, pB->cyMinChild, pB->cyChild, pB->cyMaxChild, pB->cyIntegral);
442 if (pB->fMask & RBBIM_TEXT)
443 TRACE("band # %u: text=%s\n",
444 i, (pB->lpText) ? debugstr_w(pB->lpText) : "(null)");
445 TRACE("band # %u: lcx=%u, ccx=%u, hcx=%u, lcy=%u, ccy=%u, hcy=%u, offChild=%ld,%ld\n",
446 i, pB->lcx, pB->ccx, pB->hcx, pB->lcy, pB->ccy, pB->hcy, pB->offChild.cx, pB->offChild.cy);
447 TRACE("band # %u: fStatus=%08x, fDraw=%08x, Band=(%ld,%ld)-(%ld,%ld), Grip=(%ld,%ld)-(%ld,%ld)\n",
448 i, pB->fStatus, pB->fDraw,
449 pB->rcBand.left, pB->rcBand.top, pB->rcBand.right, pB->rcBand.bottom,
450 pB->rcGripper.left, pB->rcGripper.top, pB->rcGripper.right, pB->rcGripper.bottom);
451 TRACE("band # %u: Img=(%ld,%ld)-(%ld,%ld), Txt=(%ld,%ld)-(%ld,%ld), Child=(%ld,%ld)-(%ld,%ld)\n",
452 i,
453 pB->rcCapImage.left, pB->rcCapImage.top, pB->rcCapImage.right, pB->rcCapImage.bottom,
454 pB->rcCapText.left, pB->rcCapText.top, pB->rcCapText.right, pB->rcCapText.bottom,
455 pB->rcChild.left, pB->rcChild.top, pB->rcChild.right, pB->rcChild.bottom);
456 }
457
458 }
459
460 static void
461 REBAR_DrawChevron (HDC hdc, INT left, INT top, INT colorRef)
462 {
463 INT x, y;
464 HPEN hPen, hOldPen;
465
466 if (!(hPen = CreatePen( PS_SOLID, 1, GetSysColor( colorRef )))) return;
467 hOldPen = SelectObject ( hdc, hPen );
468 x = left + 2;
469 y = top;
470 MoveToEx (hdc, x, y, NULL);
471 LineTo (hdc, x+5, y++); x++;
472 MoveToEx (hdc, x, y, NULL);
473 LineTo (hdc, x+3, y++); x++;
474 MoveToEx (hdc, x, y, NULL);
475 LineTo (hdc, x+1, y++);
476 SelectObject( hdc, hOldPen );
477 DeleteObject( hPen );
478 }
479
480 static HWND
481 REBAR_GetNotifyParent (REBAR_INFO *infoPtr)
482 {
483 HWND parent, owner;
484
485 parent = infoPtr->hwndNotify;
486 if (!parent) {
487 parent = GetParent (infoPtr->hwndSelf);
488 owner = GetWindow (infoPtr->hwndSelf, GW_OWNER);
489 if (owner) parent = owner;
490 }
491 return parent;
492 }
493
494
495 static INT
496 REBAR_Notify (NMHDR *nmhdr, REBAR_INFO *infoPtr, UINT code)
497 {
498 HWND parent;
499
500 parent = REBAR_GetNotifyParent (infoPtr);
501 nmhdr->idFrom = GetDlgCtrlID (infoPtr->hwndSelf);
502 nmhdr->hwndFrom = infoPtr->hwndSelf;
503 nmhdr->code = code;
504
505 TRACE("window %p, code=%08x, %s\n", parent, code,
506 (infoPtr->NtfUnicode) ? "via Unicode" : "via ANSI");
507
508 if (infoPtr->NtfUnicode)
509 return SendMessageW (parent, WM_NOTIFY, (WPARAM) nmhdr->idFrom,
510 (LPARAM)nmhdr);
511 else
512 return SendMessageA (parent, WM_NOTIFY, (WPARAM) nmhdr->idFrom,
513 (LPARAM)nmhdr);
514 }
515
516 static INT
517 REBAR_Notify_NMREBAR (REBAR_INFO *infoPtr, UINT uBand, UINT code)
518 {
519 NMREBAR notify_rebar;
520 REBAR_BAND *lpBand;
521
522 notify_rebar.dwMask = 0;
523 if (uBand!=-1) {
524 lpBand = &infoPtr->bands[uBand];
525 if (lpBand->fMask & RBBIM_ID) {
526 notify_rebar.dwMask |= RBNM_ID;
527 notify_rebar.wID = lpBand->wID;
528 }
529 if (lpBand->fMask & RBBIM_LPARAM) {
530 notify_rebar.dwMask |= RBNM_LPARAM;
531 notify_rebar.lParam = lpBand->lParam;
532 }
533 if (lpBand->fMask & RBBIM_STYLE) {
534 notify_rebar.dwMask |= RBNM_STYLE;
535 notify_rebar.fStyle = lpBand->fStyle;
536 }
537 }
538 notify_rebar.uBand = uBand;
539 return REBAR_Notify ((NMHDR *)&notify_rebar, infoPtr, code);
540 }
541
542 static VOID
543 REBAR_DrawBand (HDC hdc, REBAR_INFO *infoPtr, REBAR_BAND *lpBand)
544 {
545 HFONT hOldFont = 0;
546 INT oldBkMode = 0;
547 NMCUSTOMDRAW nmcd;
548 HTHEME theme = GetWindowTheme (infoPtr->hwndSelf);
549
550 if (lpBand->fDraw & DRAW_TEXT) {
551 hOldFont = SelectObject (hdc, infoPtr->hFont);
552 oldBkMode = SetBkMode (hdc, TRANSPARENT);
553 }
554
555 /* should test for CDRF_NOTIFYITEMDRAW here */
556 nmcd.dwDrawStage = CDDS_ITEMPREPAINT;
557 nmcd.hdc = hdc;
558 nmcd.rc = lpBand->rcBand;
559 nmcd.rc.right = lpBand->rcCapText.right;
560 nmcd.rc.bottom = lpBand->rcCapText.bottom;
561 nmcd.dwItemSpec = lpBand->wID;
562 nmcd.uItemState = 0;
563 nmcd.lItemlParam = lpBand->lParam;
564 lpBand->uCDret = REBAR_Notify ((NMHDR *)&nmcd, infoPtr, NM_CUSTOMDRAW);
565 if (lpBand->uCDret == CDRF_SKIPDEFAULT) {
566 if (oldBkMode != TRANSPARENT)
567 SetBkMode (hdc, oldBkMode);
568 SelectObject (hdc, hOldFont);
569 return;
570 }
571
572 /* draw gripper */
573 if (lpBand->fDraw & DRAW_GRIPPER)
574 {
575 if (theme)
576 {
577 RECT rcGripper = lpBand->rcGripper;
578 int partId = (infoPtr->dwStyle & CCS_VERT) ? RP_GRIPPERVERT : RP_GRIPPER;
579 GetThemeBackgroundExtent (theme, hdc, partId, 0, &rcGripper, &rcGripper);
580 OffsetRect (&rcGripper, lpBand->rcGripper.left - rcGripper.left,
581 lpBand->rcGripper.top - rcGripper.top);
582 DrawThemeBackground (theme, hdc, partId, 0, &rcGripper, NULL);
583 }
584 else
585 DrawEdge (hdc, &lpBand->rcGripper, BDR_RAISEDINNER, BF_RECT | BF_MIDDLE);
586 }
587
588 /* draw caption image */
589 if (lpBand->fDraw & DRAW_IMAGE) {
590 POINT pt;
591
592 /* center image */
593 pt.y = (lpBand->rcCapImage.bottom + lpBand->rcCapImage.top - infoPtr->imageSize.cy)/2;
594 pt.x = (lpBand->rcCapImage.right + lpBand->rcCapImage.left - infoPtr->imageSize.cx)/2;
595
596 ImageList_Draw (infoPtr->himl, lpBand->iImage, hdc,
597 pt.x, pt.y,
598 ILD_TRANSPARENT);
599 }
600
601 /* draw caption text */
602 if (lpBand->fDraw & DRAW_TEXT) {
603 /* need to handle CDRF_NEWFONT here */
604 INT oldBkMode = SetBkMode (hdc, TRANSPARENT);
605 COLORREF oldcolor = CLR_NONE;
606 COLORREF new;
607 if (lpBand->clrFore != CLR_NONE) {
608 new = (lpBand->clrFore == CLR_DEFAULT) ? infoPtr->clrBtnText :
609 lpBand->clrFore;
610 oldcolor = SetTextColor (hdc, new);
611 }
612 DrawTextW (hdc, lpBand->lpText, -1, &lpBand->rcCapText,
613 DT_CENTER | DT_VCENTER | DT_SINGLELINE);
614 if (oldBkMode != TRANSPARENT)
615 SetBkMode (hdc, oldBkMode);
616 if (lpBand->clrFore != CLR_NONE)
617 SetTextColor (hdc, oldcolor);
618 SelectObject (hdc, hOldFont);
619 }
620
621 if (!IsRectEmpty(&lpBand->rcChevron))
622 {
623 if (theme)
624 {
625 int stateId;
626 if (lpBand->fDraw & DRAW_CHEVRONPUSHED)
627 stateId = CHEVS_PRESSED;
628 else if (lpBand->fDraw & DRAW_CHEVRONHOT)
629 stateId = CHEVS_HOT;
630 else
631 stateId = CHEVS_NORMAL;
632 DrawThemeBackground (theme, hdc, RP_CHEVRON, stateId, &lpBand->rcChevron, NULL);
633 }
634 else
635 {
636 if (lpBand->fDraw & DRAW_CHEVRONPUSHED)
637 {
638 DrawEdge(hdc, &lpBand->rcChevron, BDR_SUNKENOUTER, BF_RECT | BF_MIDDLE);
639 REBAR_DrawChevron(hdc, lpBand->rcChevron.left+1, lpBand->rcChevron.top + 11, COLOR_WINDOWFRAME);
640 }
641 else if (lpBand->fDraw & DRAW_CHEVRONHOT)
642 {
643 DrawEdge(hdc, &lpBand->rcChevron, BDR_RAISEDINNER, BF_RECT | BF_MIDDLE);
644 REBAR_DrawChevron(hdc, lpBand->rcChevron.left, lpBand->rcChevron.top + 10, COLOR_WINDOWFRAME);
645 }
646 else
647 REBAR_DrawChevron(hdc, lpBand->rcChevron.left, lpBand->rcChevron.top + 10, COLOR_WINDOWFRAME);
648 }
649 }
650
651 if (lpBand->uCDret == (CDRF_NOTIFYPOSTPAINT | CDRF_NOTIFYITEMDRAW)) {
652 nmcd.dwDrawStage = CDDS_ITEMPOSTPAINT;
653 nmcd.hdc = hdc;
654 nmcd.rc = lpBand->rcBand;
655 nmcd.rc.right = lpBand->rcCapText.right;
656 nmcd.rc.bottom = lpBand->rcCapText.bottom;
657 nmcd.dwItemSpec = lpBand->wID;
658 nmcd.uItemState = 0;
659 nmcd.lItemlParam = lpBand->lParam;
660 lpBand->uCDret = REBAR_Notify ((NMHDR *)&nmcd, infoPtr, NM_CUSTOMDRAW);
661 }
662 }
663
664
665 static VOID
666 REBAR_Refresh (REBAR_INFO *infoPtr, HDC hdc)
667 {
668 REBAR_BAND *lpBand;
669 UINT i;
670
671 if (!infoPtr->DoRedraw) return;
672
673 for (i = 0; i < infoPtr->uNumBands; i++) {
674 lpBand = &infoPtr->bands[i];
675
676 if (HIDDENBAND(lpBand)) continue;
677
678 /* now draw the band */
679 TRACE("[%p] drawing band %i, flags=%08x\n",
680 infoPtr->hwndSelf, i, lpBand->fDraw);
681 REBAR_DrawBand (hdc, infoPtr, lpBand);
682
683 }
684 }
685
686
687 static void
688 REBAR_FixVert (REBAR_INFO *infoPtr, UINT rowstart, UINT rowend,
689 INT mcy)
690 /* Function: */
691 /* Cycle through bands in row and fix height of each band. */
692 /* Also determine whether each band has changed. */
693 /* On entry: */
694 /* all bands at desired size. */
695 /* start and end bands are *not* hidden */
696 {
697 REBAR_BAND *lpBand;
698 INT i;
699
700 for (i = (INT)rowstart; i<=(INT)rowend; i++) {
701 lpBand = &infoPtr->bands[i];
702 if (HIDDENBAND(lpBand)) continue;
703
704 /* adjust height of bands in row to "mcy" value */
705 if (infoPtr->dwStyle & CCS_VERT) {
706 if (lpBand->rcBand.right != lpBand->rcBand.left + mcy)
707 lpBand->rcBand.right = lpBand->rcBand.left + mcy;
708 }
709 else {
710 if (lpBand->rcBand.bottom != lpBand->rcBand.top + mcy)
711 lpBand->rcBand.bottom = lpBand->rcBand.top + mcy;
712
713 }
714
715 /* mark whether we need to invalidate this band and trace */
716 if ((lpBand->rcoldBand.left !=lpBand->rcBand.left) ||
717 (lpBand->rcoldBand.top !=lpBand->rcBand.top) ||
718 (lpBand->rcoldBand.right !=lpBand->rcBand.right) ||
719 (lpBand->rcoldBand.bottom !=lpBand->rcBand.bottom)) {
720 lpBand->fDraw |= NTF_INVALIDATE;
721 TRACE("band %d row=%d: changed to (%ld,%ld)-(%ld,%ld) from (%ld,%ld)-(%ld,%ld)\n",
722 i, lpBand->iRow,
723 lpBand->rcBand.left, lpBand->rcBand.top,
724 lpBand->rcBand.right, lpBand->rcBand.bottom,
725 lpBand->rcoldBand.left, lpBand->rcoldBand.top,
726 lpBand->rcoldBand.right, lpBand->rcoldBand.bottom);
727 }
728 else
729 TRACE("band %d row=%d: unchanged (%ld,%ld)-(%ld,%ld)\n",
730 i, lpBand->iRow,
731 lpBand->rcBand.left, lpBand->rcBand.top,
732 lpBand->rcBand.right, lpBand->rcBand.bottom);
733 }
734 }
735
736
737 static void
738 REBAR_AdjustBands (REBAR_INFO *infoPtr, UINT rowstart, UINT rowend,
739 INT maxx, INT mcy)
740 /* Function: This routine distributes the extra space in a row. */
741 /* See algorithm below. */
742 /* On entry: */
743 /* all bands @ ->cxHeader size */
744 /* start and end bands are *not* hidden */
745 {
746 REBAR_BAND *lpBand;
747 UINT xsep, extra, curwidth, fudge;
748 INT x, i, last_adjusted;
749
750 TRACE("start=%u, end=%u, max x=%d, max y=%d\n",
751 rowstart, rowend, maxx, mcy);
752
753 /* ******************* Phase 1 ************************ */
754 /* Alg: */
755 /* For each visible band with valid child */
756 /* a. inflate band till either all extra space used */
757 /* or band's ->ccx reached. */
758 /* If any band modified, add any space left to last band */
759 /* adjusted. */
760 /* */
761 /* ****************************************************** */
762 lpBand = &infoPtr->bands[rowend];
763 extra = maxx - rcBrb(lpBand);
764 x = 0;
765 last_adjusted = -1;
766 for (i=(INT)rowstart; i<=(INT)rowend; i++) {
767 lpBand = &infoPtr->bands[i];
768 if (HIDDENBAND(lpBand)) continue;
769 xsep = (x == 0) ? 0 : SEP_WIDTH;
770 curwidth = rcBw(lpBand);
771
772 /* set new left/top point */
773 if (infoPtr->dwStyle & CCS_VERT)
774 lpBand->rcBand.top = x + xsep;
775 else
776 lpBand->rcBand.left = x + xsep;
777
778 /* compute new width */
779 if ((lpBand->hwndChild && extra) && !(lpBand->fStyle & RBBS_FIXEDSIZE)) {
780 /* set to the "current" band size less the header */
781 fudge = lpBand->ccx;
782 last_adjusted = i;
783 if ((lpBand->fMask & RBBIM_SIZE) && (lpBand->cx > 0) &&
784 (fudge > curwidth)) {
785 TRACE("adjusting band %d by %d, fudge=%d, curwidth=%d, extra=%d\n",
786 i, fudge-curwidth, fudge, curwidth, extra);
787 if ((fudge - curwidth) > extra)
788 fudge = curwidth + extra;
789 extra -= (fudge - curwidth);
790 curwidth = fudge;
791 }
792 else {
793 TRACE("adjusting band %d by %d, fudge=%d, curwidth=%d\n",
794 i, extra, fudge, curwidth);
795 curwidth += extra;
796 extra = 0;
797 }
798 }
799
800 /* set new right/bottom point */
801 if (infoPtr->dwStyle & CCS_VERT)
802 lpBand->rcBand.bottom = lpBand->rcBand.top + curwidth;
803 else
804 lpBand->rcBand.right = lpBand->rcBand.left + curwidth;
805 TRACE("Phase 1 band %d, (%ld,%ld)-(%ld,%ld), orig x=%d, xsep=%d\n",
806 i, lpBand->rcBand.left, lpBand->rcBand.top,
807 lpBand->rcBand.right, lpBand->rcBand.bottom, x, xsep);
808 x = rcBrb(lpBand);
809 }
810 if ((x >= maxx) || (last_adjusted != -1)) {
811 if (x > maxx) {
812 ERR("Phase 1 failed, x=%d, maxx=%d, start=%u, end=%u\n",
813 x, maxx, rowstart, rowend);
814 }
815 /* done, so spread extra space */
816 if (x < maxx) {
817 fudge = maxx - x;
818 TRACE("Need to spread %d on last adjusted band %d\n",
819 fudge, last_adjusted);
820 for (i=(INT)last_adjusted; i<=(INT)rowend; i++) {
821 lpBand = &infoPtr->bands[i];
822 if (HIDDENBAND(lpBand)) continue;
823
824 /* set right/bottom point */
825 if (i != last_adjusted) {
826 if (infoPtr->dwStyle & CCS_VERT)
827 lpBand->rcBand.top += fudge;
828 else
829 lpBand->rcBand.left += fudge;
830 }
831
832 /* set left/bottom point */
833 if (infoPtr->dwStyle & CCS_VERT)
834 lpBand->rcBand.bottom += fudge;
835 else
836 lpBand->rcBand.right += fudge;
837 }
838 }
839 TRACE("Phase 1 succeeded, used x=%d\n", x);
840 REBAR_FixVert (infoPtr, rowstart, rowend, mcy);
841 return;
842 }
843
844 /* ******************* Phase 2 ************************ */
845 /* Alg: */
846 /* Find first visible band, put all */
847 /* extra space there. */
848 /* */
849 /* ****************************************************** */
850
851 x = 0;
852 for (i=(INT)rowstart; i<=(INT)rowend; i++) {
853 lpBand = &infoPtr->bands[i];
854 if (HIDDENBAND(lpBand)) continue;
855 xsep = (x == 0) ? 0 : SEP_WIDTH;
856 curwidth = rcBw(lpBand);
857
858 /* set new left/top point */
859 if (infoPtr->dwStyle & CCS_VERT)
860 lpBand->rcBand.top = x + xsep;
861 else
862 lpBand->rcBand.left = x + xsep;
863
864 /* compute new width */
865 if (extra) {
866 curwidth += extra;
867 extra = 0;
868 }
869
870 /* set new right/bottom point */
871 if (infoPtr->dwStyle & CCS_VERT)
872 lpBand->rcBand.bottom = lpBand->rcBand.top + curwidth;
873 else
874 lpBand->rcBand.right = lpBand->rcBand.left + curwidth;
875 TRACE("Phase 2 band %d, (%ld,%ld)-(%ld,%ld), orig x=%d, xsep=%d\n",
876 i, lpBand->rcBand.left, lpBand->rcBand.top,
877 lpBand->rcBand.right, lpBand->rcBand.bottom, x, xsep);
878 x = rcBrb(lpBand);
879 }
880 if (x >= maxx) {
881 if (x > maxx) {
882 ERR("Phase 2 failed, x=%d, maxx=%d, start=%u, end=%u\n",
883 x, maxx, rowstart, rowend);
884 }
885 /* done, so spread extra space */
886 TRACE("Phase 2 succeeded, used x=%d\n", x);
887 REBAR_FixVert (infoPtr, rowstart, rowend, mcy);
888 return;
889 }
890
891 /* ******************* Phase 3 ************************ */
892 /* at this point everything is back to ->cxHeader values */
893 /* and should not have gotten here. */
894 /* ****************************************************** */
895
896 lpBand = &infoPtr->bands[rowstart];
897 ERR("Serious problem adjusting row %d, start band %d, end band %d\n",
898 lpBand->iRow, rowstart, rowend);
899 REBAR_DumpBand (infoPtr);
900 return;
901 }
902
903
904 static void
905 REBAR_CalcHorzBand (REBAR_INFO *infoPtr, UINT rstart, UINT rend, BOOL notify)
906 /* Function: this routine initializes all the rectangles in */
907 /* each band in a row to fit in the adjusted rcBand rect. */
908 /* *** Supports only Horizontal bars. *** */
909 {
910 REBAR_BAND *lpBand;
911 UINT i, xoff, yoff;
912 HWND parenthwnd;
913 RECT oldChild, work;
914
915 /* MS seems to use GetDlgCtrlID() for above GetWindowLong call */
916 parenthwnd = GetParent (infoPtr->hwndSelf);
917
918 for(i=rstart; i<rend; i++){
919 lpBand = &infoPtr->bands[i];
920 if (HIDDENBAND(lpBand)) {
921 SetRect (&lpBand->rcChild,
922 lpBand->rcBand.right, lpBand->rcBand.top,
923 lpBand->rcBand.right, lpBand->rcBand.bottom);
924 continue;
925 }
926
927 oldChild = lpBand->rcChild;
928
929 /* set initial gripper rectangle */
930 SetRect (&lpBand->rcGripper, lpBand->rcBand.left, lpBand->rcBand.top,
931 lpBand->rcBand.left, lpBand->rcBand.bottom);
932
933 /* calculate gripper rectangle */
934 if ( lpBand->fStatus & HAS_GRIPPER) {
935 lpBand->fDraw |= DRAW_GRIPPER;
936 lpBand->rcGripper.left += REBAR_PRE_GRIPPER;
937 lpBand->rcGripper.right = lpBand->rcGripper.left + GRIPPER_WIDTH;
938 lpBand->rcGripper.top += 2;
939 lpBand->rcGripper.bottom -= 2;
940
941 SetRect (&lpBand->rcCapImage,
942 lpBand->rcGripper.right+REBAR_ALWAYS_SPACE, lpBand->rcBand.top,
943 lpBand->rcGripper.right+REBAR_ALWAYS_SPACE, lpBand->rcBand.bottom);
944 }
945 else { /* no gripper will be drawn */
946 xoff = 0;
947 if (lpBand->fStatus & (HAS_IMAGE | HAS_TEXT))
948 /* if no gripper but either image or text, then leave space */
949 xoff = REBAR_ALWAYS_SPACE;
950 SetRect (&lpBand->rcCapImage,
951 lpBand->rcBand.left+xoff, lpBand->rcBand.top,
952 lpBand->rcBand.left+xoff, lpBand->rcBand.bottom);
953 }
954
955 /* image is visible */
956 if (lpBand->fStatus & HAS_IMAGE) {
957 lpBand->fDraw |= DRAW_IMAGE;
958 lpBand->rcCapImage.right += infoPtr->imageSize.cx;
959 lpBand->rcCapImage.bottom = lpBand->rcCapImage.top + infoPtr->imageSize.cy;
960
961 /* set initial caption text rectangle */
962 SetRect (&lpBand->rcCapText,
963 lpBand->rcCapImage.right+REBAR_POST_IMAGE, lpBand->rcBand.top+1,
964 lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.bottom-1);
965 /* update band height
966 if (lpBand->uMinHeight < infoPtr->imageSize.cy + 2) {
967 lpBand->uMinHeight = infoPtr->imageSize.cy + 2;
968 lpBand->rcBand.bottom = lpBand->rcBand.top + lpBand->uMinHeight;
969 } */
970 }
971 else {
972 /* set initial caption text rectangle */
973 SetRect (&lpBand->rcCapText, lpBand->rcCapImage.right, lpBand->rcBand.top+1,
974 lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.bottom-1);
975 }
976
977 /* text is visible */
978 if ((lpBand->fStatus & HAS_TEXT) && !(lpBand->fStyle & RBBS_HIDETITLE)) {
979 lpBand->fDraw |= DRAW_TEXT;
980 lpBand->rcCapText.right = max(lpBand->rcCapText.left,
981 lpBand->rcCapText.right-REBAR_POST_TEXT);
982 }
983
984 /* set initial child window rectangle if there is a child */
985 if (lpBand->fMask & RBBIM_CHILD) {
986 xoff = lpBand->offChild.cx;
987 yoff = lpBand->offChild.cy;
988 SetRect (&lpBand->rcChild,
989 lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.top+yoff,
990 lpBand->rcBand.right-xoff, lpBand->rcBand.bottom-yoff);
991 if ((lpBand->fStyle & RBBS_USECHEVRON) && (lpBand->rcChild.right - lpBand->rcChild.left < lpBand->cxIdeal))
992 {
993 lpBand->rcChild.right -= CHEVRON_WIDTH;
994 SetRect(&lpBand->rcChevron, lpBand->rcChild.right,
995 lpBand->rcChild.top, lpBand->rcChild.right + CHEVRON_WIDTH,
996 lpBand->rcChild.bottom);
997 }
998 }
999 else {
1000 SetRect (&lpBand->rcChild,
1001 lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.top,
1002 lpBand->rcBand.right, lpBand->rcBand.bottom);
1003 }
1004
1005 /* flag if notify required and invalidate rectangle */
1006 if (notify &&
1007 ((oldChild.right-oldChild.left != lpBand->rcChild.right-lpBand->rcChild.left) ||
1008 (oldChild.bottom-oldChild.top != lpBand->rcChild.bottom-lpBand->rcChild.top))) {
1009 TRACE("Child rectangle changed for band %u\n", i);
1010 TRACE(" from (%ld,%ld)-(%ld,%ld) to (%ld,%ld)-(%ld,%ld)\n",
1011 oldChild.left, oldChild.top,
1012 oldChild.right, oldChild.bottom,
1013 lpBand->rcChild.left, lpBand->rcChild.top,
1014 lpBand->rcChild.right, lpBand->rcChild.bottom);
1015 }
1016 if (lpBand->fDraw & NTF_INVALIDATE) {
1017 TRACE("invalidating (%ld,%ld)-(%ld,%ld)\n",
1018 lpBand->rcBand.left,
1019 lpBand->rcBand.top,
1020 lpBand->rcBand.right + ((lpBand->fDraw & DRAW_RIGHTSEP) ? SEP_WIDTH_SIZE : 0),
1021 lpBand->rcBand.bottom + ((lpBand->fDraw & DRAW_BOTTOMSEP) ? SEP_WIDTH_SIZE : 0));
1022 lpBand->fDraw &= ~NTF_INVALIDATE;
1023 work = lpBand->rcBand;
1024 if (lpBand->fDraw & DRAW_RIGHTSEP) work.right += SEP_WIDTH_SIZE;
1025 if (lpBand->fDraw & DRAW_BOTTOMSEP) work.bottom += SEP_WIDTH_SIZE;
1026 InvalidateRect(infoPtr->hwndSelf, &work, TRUE);
1027 }
1028
1029 }
1030
1031 }
1032
1033
1034 static VOID
1035 REBAR_CalcVertBand (REBAR_INFO *infoPtr, UINT rstart, UINT rend, BOOL notify)
1036 /* Function: this routine initializes all the rectangles in */
1037 /* each band in a row to fit in the adjusted rcBand rect. */
1038 /* *** Supports only Vertical bars. *** */
1039 {
1040 REBAR_BAND *lpBand;
1041 UINT i, xoff, yoff;
1042 HWND parenthwnd;
1043 RECT oldChild, work;
1044
1045 /* MS seems to use GetDlgCtrlID() for above GetWindowLong call */
1046 parenthwnd = GetParent (infoPtr->hwndSelf);
1047
1048 for(i=rstart; i<rend; i++){
1049 lpBand = &infoPtr->bands[i];
1050 if (HIDDENBAND(lpBand)) continue;
1051 oldChild = lpBand->rcChild;
1052
1053 /* set initial gripper rectangle */
1054 SetRect (&lpBand->rcGripper, lpBand->rcBand.left, lpBand->rcBand.top,
1055 lpBand->rcBand.right, lpBand->rcBand.top);
1056
1057 /* calculate gripper rectangle */
1058 if (lpBand->fStatus & HAS_GRIPPER) {
1059 lpBand->fDraw |= DRAW_GRIPPER;
1060
1061 if (infoPtr->dwStyle & RBS_VERTICALGRIPPER) {
1062 /* vertical gripper */
1063 lpBand->rcGripper.left += 3;
1064 lpBand->rcGripper.right = lpBand->rcGripper.left + GRIPPER_WIDTH;
1065 lpBand->rcGripper.top += REBAR_PRE_GRIPPER;
1066 lpBand->rcGripper.bottom = lpBand->rcGripper.top + GRIPPER_HEIGHT;
1067
1068 /* initialize Caption image rectangle */
1069 SetRect (&lpBand->rcCapImage, lpBand->rcBand.left,
1070 lpBand->rcGripper.bottom + REBAR_ALWAYS_SPACE,
1071 lpBand->rcBand.right,
1072 lpBand->rcGripper.bottom + REBAR_ALWAYS_SPACE);
1073 }
1074 else {
1075 /* horizontal gripper */
1076 lpBand->rcGripper.left += 2;
1077 lpBand->rcGripper.right -= 2;
1078 lpBand->rcGripper.top += REBAR_PRE_GRIPPER;
1079 lpBand->rcGripper.bottom = lpBand->rcGripper.top + GRIPPER_WIDTH;
1080
1081 /* initialize Caption image rectangle */
1082 SetRect (&lpBand->rcCapImage, lpBand->rcBand.left,
1083 lpBand->rcGripper.bottom + REBAR_ALWAYS_SPACE,
1084 lpBand->rcBand.right,
1085 lpBand->rcGripper.bottom + REBAR_ALWAYS_SPACE);
1086 }
1087 }
1088 else { /* no gripper will be drawn */
1089 xoff = 0;
1090 if (lpBand->fStatus & (HAS_IMAGE | HAS_TEXT))
1091 /* if no gripper but either image or text, then leave space */
1092 xoff = REBAR_ALWAYS_SPACE;
1093 /* initialize Caption image rectangle */
1094 SetRect (&lpBand->rcCapImage,
1095 lpBand->rcBand.left, lpBand->rcBand.top+xoff,
1096 lpBand->rcBand.right, lpBand->rcBand.top+xoff);
1097 }
1098
1099 /* image is visible */
1100 if (lpBand->fStatus & HAS_IMAGE) {
1101 lpBand->fDraw |= DRAW_IMAGE;
1102
1103 lpBand->rcCapImage.right = lpBand->rcCapImage.left + infoPtr->imageSize.cx;
1104 lpBand->rcCapImage.bottom += infoPtr->imageSize.cy;
1105
1106 /* set initial caption text rectangle */
1107 SetRect (&lpBand->rcCapText,
1108 lpBand->rcBand.left, lpBand->rcCapImage.bottom+REBAR_POST_IMAGE,
1109 lpBand->rcBand.right, lpBand->rcBand.top+lpBand->cxHeader);
1110 /* update band height *
1111 if (lpBand->uMinHeight < infoPtr->imageSize.cx + 2) {
1112 lpBand->uMinHeight = infoPtr->imageSize.cx + 2;
1113 lpBand->rcBand.right = lpBand->rcBand.left + lpBand->uMinHeight;
1114 } */
1115 }
1116 else {
1117 /* set initial caption text rectangle */
1118 SetRect (&lpBand->rcCapText,
1119 lpBand->rcBand.left, lpBand->rcCapImage.bottom,
1120 lpBand->rcBand.right, lpBand->rcBand.top+lpBand->cxHeader);
1121 }
1122
1123 /* text is visible */
1124 if ((lpBand->fStatus & HAS_TEXT) && !(lpBand->fStyle & RBBS_HIDETITLE)) {
1125 lpBand->fDraw |= DRAW_TEXT;
1126 lpBand->rcCapText.bottom = max(lpBand->rcCapText.top,
1127 lpBand->rcCapText.bottom);
1128 }
1129
1130 /* set initial child window rectangle if there is a child */
1131 if (lpBand->fMask & RBBIM_CHILD) {
1132 yoff = lpBand->offChild.cx;
1133 xoff = lpBand->offChild.cy;
1134 SetRect (&lpBand->rcChild,
1135 lpBand->rcBand.left+xoff, lpBand->rcBand.top+lpBand->cxHeader,
1136 lpBand->rcBand.right-xoff, lpBand->rcBand.bottom-yoff);
1137 }
1138 else {
1139 SetRect (&lpBand->rcChild,
1140 lpBand->rcBand.left, lpBand->rcBand.top+lpBand->cxHeader,
1141 lpBand->rcBand.right, lpBand->rcBand.bottom);
1142 }
1143
1144 /* flag if notify required and invalidate rectangle */
1145 if (notify &&
1146 ((oldChild.right-oldChild.left != lpBand->rcChild.right-lpBand->rcChild.left) ||
1147 (oldChild.bottom-oldChild.top != lpBand->rcChild.bottom-lpBand->rcChild.top))) {
1148 TRACE("Child rectangle changed for band %u\n", i);
1149 TRACE(" from (%ld,%ld)-(%ld,%ld) to (%ld,%ld)-(%ld,%ld)\n",
1150 oldChild.left, oldChild.top,
1151 oldChild.right, oldChild.bottom,
1152 lpBand->rcChild.left, lpBand->rcChild.top,
1153 lpBand->rcChild.right, lpBand->rcChild.bottom);
1154 }
1155 if (lpBand->fDraw & NTF_INVALIDATE) {
1156 TRACE("invalidating (%ld,%ld)-(%ld,%ld)\n",
1157 lpBand->rcBand.left,
1158 lpBand->rcBand.top,
1159 lpBand->rcBand.right + ((lpBand->fDraw & DRAW_BOTTOMSEP) ? SEP_WIDTH_SIZE : 0),
1160 lpBand->rcBand.bottom + ((lpBand->fDraw & DRAW_RIGHTSEP) ? SEP_WIDTH_SIZE : 0));
1161 lpBand->fDraw &= ~NTF_INVALIDATE;
1162 work = lpBand->rcBand;
1163 if (lpBand->fDraw & DRAW_RIGHTSEP) work.bottom += SEP_WIDTH_SIZE;
1164 if (lpBand->fDraw & DRAW_BOTTOMSEP) work.right += SEP_WIDTH_SIZE;
1165 InvalidateRect(infoPtr->hwndSelf, &work, TRUE);
1166 }
1167
1168 }
1169 }
1170
1171
1172 static VOID
1173 REBAR_ForceResize (REBAR_INFO *infoPtr)
1174 /* Function: This changes the size of the REBAR window to that */
1175 /* calculated by REBAR_Layout. */
1176 {
1177 RECT rc;
1178 INT x, y, width, height;
1179 INT xedge = GetSystemMetrics(SM_CXEDGE);
1180 INT yedge = GetSystemMetrics(SM_CYEDGE);
1181
1182 GetClientRect (infoPtr->hwndSelf, &rc);
1183
1184 TRACE( " old [%ld x %ld], new [%ld x %ld], client [%ld x %ld]\n",
1185 infoPtr->oldSize.cx, infoPtr->oldSize.cy,
1186 infoPtr->calcSize.cx, infoPtr->calcSize.cy,
1187 rc.right, rc.bottom);
1188
1189 /* If we need to shrink client, then skip size test */
1190 if ((infoPtr->calcSize.cy >= rc.bottom) &&
1191 (infoPtr->calcSize.cx >= rc.right)) {
1192
1193 /* if size did not change then skip process */
1194 if ((infoPtr->oldSize.cx == infoPtr->calcSize.cx) &&
1195 (infoPtr->oldSize.cy == infoPtr->calcSize.cy) &&
1196 !(infoPtr->fStatus & RESIZE_ANYHOW))
1197 {
1198 TRACE("skipping reset\n");
1199 return;
1200 }
1201 }
1202
1203 infoPtr->fStatus &= ~RESIZE_ANYHOW;
1204 /* Set flag to ignore next WM_SIZE message */
1205 infoPtr->fStatus |= AUTO_RESIZE;
1206
1207 width = 0;
1208 height = 0;
1209 x = 0;
1210 y = 0;
1211
1212 if (infoPtr->dwStyle & WS_BORDER) {
1213 width = 2 * xedge;
1214 height = 2 * yedge;
1215 }
1216
1217 if (!(infoPtr->dwStyle & CCS_NOPARENTALIGN)) {
1218 INT mode = infoPtr->dwStyle & (CCS_VERT | CCS_TOP | CCS_BOTTOM);
1219 RECT rcPcl;
1220
1221 GetClientRect(GetParent(infoPtr->hwndSelf), &rcPcl);
1222 switch (mode) {
1223 case CCS_TOP:
1224 /* _TOP sets width to parents width */
1225 width += (rcPcl.right - rcPcl.left);
1226 height += infoPtr->calcSize.cy;
1227 x += ((infoPtr->dwStyle & WS_BORDER) ? -xedge : 0);
1228 y += ((infoPtr->dwStyle & WS_BORDER) ? -yedge : 0);
1229 y += ((infoPtr->dwStyle & CCS_NODIVIDER) ? 0 : REBAR_DIVIDER);
1230 break;
1231 case CCS_BOTTOM:
1232 /* FIXME: wrong wrong wrong */
1233 /* _BOTTOM sets width to parents width */
1234 width += (rcPcl.right - rcPcl.left);
1235 height += infoPtr->calcSize.cy;
1236 x += -xedge;
1237 y = rcPcl.bottom - height + 1;
1238 break;
1239 case CCS_LEFT:
1240 /* _LEFT sets height to parents height */
1241 width += infoPtr->calcSize.cx;
1242 height += (rcPcl.bottom - rcPcl.top);
1243 x += ((infoPtr->dwStyle & WS_BORDER) ? -xedge : 0);
1244 x += ((infoPtr->dwStyle & CCS_NODIVIDER) ? 0 : REBAR_DIVIDER);
1245 y += ((infoPtr->dwStyle & WS_BORDER) ? -yedge : 0);
1246 break;
1247 case CCS_RIGHT:
1248 /* FIXME: wrong wrong wrong */
1249 /* _RIGHT sets height to parents height */
1250 width += infoPtr->calcSize.cx;
1251 height += (rcPcl.bottom - rcPcl.top);
1252 x = rcPcl.right - width + 1;
1253 y = -yedge;
1254 break;
1255 default:
1256 width += infoPtr->calcSize.cx;
1257 height += infoPtr->calcSize.cy;
1258 }
1259 }
1260 else {
1261 width += infoPtr->calcSize.cx;
1262 height += infoPtr->calcSize.cy;
1263 x = infoPtr->origin.x;
1264 y = infoPtr->origin.y;
1265 }
1266
1267 TRACE("hwnd %p, style=%08lx, setting at (%d,%d) for (%d,%d)\n",
1268 infoPtr->hwndSelf, infoPtr->dwStyle,
1269 x, y, width, height);
1270 SetWindowPos (infoPtr->hwndSelf, 0, x, y, width, height,
1271 SWP_NOZORDER);
1272 infoPtr->fStatus &= ~AUTO_RESIZE;
1273 }
1274
1275
1276 static VOID
1277 REBAR_MoveChildWindows (REBAR_INFO *infoPtr, UINT start, UINT endplus)
1278 {
1279 static const WCHAR strComboBox[] = { 'C','o','m','b','o','B','o','x',0 };
1280 REBAR_BAND *lpBand;
1281 WCHAR szClassName[40];
1282 UINT i;
1283 NMREBARCHILDSIZE rbcz;
1284 NMHDR heightchange;
1285 HDWP deferpos;
1286
1287 if (!(deferpos = BeginDeferWindowPos(infoPtr->uNumBands)))
1288 ERR("BeginDeferWindowPos returned NULL\n");
1289
1290 for (i = start; i < endplus; i++) {
1291 lpBand = &infoPtr->bands[i];
1292
1293 if (HIDDENBAND(lpBand)) continue;
1294 if (lpBand->hwndChild) {
1295 TRACE("hwndChild = %p\n", lpBand->hwndChild);
1296
1297 /* Always geterate the RBN_CHILDSIZE even it child
1298 did not change */
1299 rbcz.uBand = i;
1300 rbcz.wID = lpBand->wID;
1301 rbcz.rcChild = lpBand->rcChild;
1302 rbcz.rcBand = lpBand->rcBand;
1303 if (infoPtr->dwStyle & CCS_VERT)
1304 rbcz.rcBand.top += lpBand->cxHeader;
1305 else
1306 rbcz.rcBand.left += lpBand->cxHeader;
1307 REBAR_Notify ((NMHDR *)&rbcz, infoPtr, RBN_CHILDSIZE);
1308 if (!EqualRect (&lpBand->rcChild, &rbcz.rcChild)) {
1309 TRACE("Child rect changed by NOTIFY for band %u\n", i);
1310 TRACE(" from (%ld,%ld)-(%ld,%ld) to (%ld,%ld)-(%ld,%ld)\n",
1311 lpBand->rcChild.left, lpBand->rcChild.top,
1312 lpBand->rcChild.right, lpBand->rcChild.bottom,
1313 rbcz.rcChild.left, rbcz.rcChild.top,
1314 rbcz.rcChild.right, rbcz.rcChild.bottom);
1315 lpBand->rcChild = rbcz.rcChild; /* *** ??? */
1316 }
1317
1318 /* native (IE4 in "Favorites" frame **1) does:
1319 * SetRect (&rc, -1, -1, -1, -1)
1320 * EqualRect (&rc,band->rc???)
1321 * if ret==0
1322 * CopyRect (band->rc????, &rc)
1323 * set flag outside of loop
1324 */
1325
1326 GetClassNameW (lpBand->hwndChild, szClassName, sizeof(szClassName)/sizeof(szClassName[0]));
1327 if (!lstrcmpW (szClassName, strComboBox) ||
1328 !lstrcmpW (szClassName, WC_COMBOBOXEXW)) {
1329 INT nEditHeight, yPos;
1330 RECT rc;
1331
1332 /* special placement code for combo or comboex box */
1333
1334
1335 /* get size of edit line */
1336 GetWindowRect (lpBand->hwndChild, &rc);
1337 nEditHeight = rc.bottom - rc.top;
1338 yPos = (lpBand->rcChild.bottom + lpBand->rcChild.top - nEditHeight)/2;
1339
1340 /* center combo box inside child area */
1341 TRACE("moving child (Combo(Ex)) %p to (%ld,%d) for (%ld,%d)\n",
1342 lpBand->hwndChild,
1343 lpBand->rcChild.left, yPos,
1344 lpBand->rcChild.right - lpBand->rcChild.left,
1345 nEditHeight);
1346 deferpos = DeferWindowPos (deferpos, lpBand->hwndChild, HWND_TOP,
1347 lpBand->rcChild.left,
1348 /*lpBand->rcChild.top*/ yPos,
1349 lpBand->rcChild.right - lpBand->rcChild.left,
1350 nEditHeight,
1351 SWP_NOZORDER);
1352 if (!deferpos)
1353 ERR("DeferWindowPos returned NULL\n");
1354 }
1355 else {
1356 TRACE("moving child (Other) %p to (%ld,%ld) for (%ld,%ld)\n",
1357 lpBand->hwndChild,
1358 lpBand->rcChild.left, lpBand->rcChild.top,
1359 lpBand->rcChild.right - lpBand->rcChild.left,
1360 lpBand->rcChild.bottom - lpBand->rcChild.top);
1361 deferpos = DeferWindowPos (deferpos, lpBand->hwndChild, HWND_TOP,
1362 lpBand->rcChild.left,
1363 lpBand->rcChild.top,
1364 lpBand->rcChild.right - lpBand->rcChild.left,
1365 lpBand->rcChild.bottom - lpBand->rcChild.top,
1366 SWP_NOZORDER);
1367 if (!deferpos)
1368 ERR("DeferWindowPos returned NULL\n");
1369 }
1370 }
1371 }
1372 if (!EndDeferWindowPos(deferpos))
1373 ERR("EndDeferWindowPos returned NULL\n");
1374
1375 if (infoPtr->DoRedraw)
1376 UpdateWindow (infoPtr->hwndSelf);
1377
1378 if (infoPtr->fStatus & NTF_HGHTCHG) {
1379 infoPtr->fStatus &= ~NTF_HGHTCHG;
1380 /*
1381 * We need to force a resize here, because some applications
1382 * try to get the rebar size during processing of the
1383 * RBN_HEIGHTCHANGE notification.
1384 */
1385 REBAR_ForceResize (infoPtr);
1386 REBAR_Notify (&heightchange, infoPtr, RBN_HEIGHTCHANGE);
1387 }
1388
1389 /* native (from **1 above) does:
1390 * UpdateWindow(rebar)
1391 * REBAR_ForceResize
1392 * RBN_HEIGHTCHANGE if necessary
1393 * if ret from any EqualRect was 0
1394 * Goto "BeginDeferWindowPos"
1395 */
1396
1397 }
1398
1399
1400 static VOID
1401 REBAR_Layout (REBAR_INFO *infoPtr, LPRECT lpRect, BOOL notify, BOOL resetclient)
1402 /* Function: This routine is resposible for laying out all */
1403 /* the bands in a rebar. It assigns each band to a row and*/
1404 /* determines when to start a new row. */
1405 {
1406 REBAR_BAND *lpBand, *prevBand;
1407 RECT rcClient, rcAdj;
1408 INT initx, inity, x, y, cx, cxsep, mmcy, mcy, clientcx, clientcy;
1409 INT adjcx, adjcy, row, rightx, bottomy, origheight;
1410 UINT i, j, rowstart, origrows, cntonrow;
1411 BOOL dobreak;
1412
1413 if (!(infoPtr->fStatus & BAND_NEEDS_LAYOUT)) {
1414 TRACE("no layout done. No band changed.\n");
1415 REBAR_DumpBand (infoPtr);
1416 return;
1417 }
1418 infoPtr->fStatus &= ~BAND_NEEDS_LAYOUT;
1419 if (!infoPtr->DoRedraw) infoPtr->fStatus |= BAND_NEEDS_REDRAW;
1420
1421 GetClientRect (infoPtr->hwndSelf, &rcClient);
1422 TRACE("Client is (%ld,%ld)-(%ld,%ld)\n",
1423 rcClient.left, rcClient.top, rcClient.right, rcClient.bottom);
1424
1425 if (lpRect) {
1426 rcAdj = *lpRect;
1427 TRACE("adjustment rect is (%ld,%ld)-(%ld,%ld)\n",
1428 rcAdj.left, rcAdj.top, rcAdj.right, rcAdj.bottom);
1429 }
1430 else {
1431 CopyRect (&rcAdj, &rcClient);
1432 }
1433
1434 clientcx = rcClient.right - rcClient.left;
1435 clientcy = rcClient.bottom - rcClient.top;
1436 adjcx = rcAdj.right - rcAdj.left;
1437 adjcy = rcAdj.bottom - rcAdj.top;
1438 if (resetclient) {
1439 TRACE("window client rect will be set to adj rect\n");
1440 clientcx = adjcx;
1441 clientcy = adjcy;
1442 }
1443
1444 if (!infoPtr->DoRedraw && (clientcx == 0) && (clientcy == 0)) {
1445 ERR("no redraw and client is zero, skip layout\n");
1446 infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
1447 return;
1448 }
1449
1450 /* save height of original control */
1451 if (infoPtr->dwStyle & CCS_VERT)
1452 origheight = infoPtr->calcSize.cx;
1453 else
1454 origheight = infoPtr->calcSize.cy;
1455 origrows = infoPtr->uNumRows;
1456
1457 initx = 0;
1458 inity = 0;
1459
1460 /* ******* Start Phase 1 - all bands on row at minimum size ******* */
1461
1462 TRACE("band loop constants, clientcx=%d, clientcy=%d, adjcx=%d, adjcy=%d\n",
1463 clientcx, clientcy, adjcx, adjcy);
1464 x = initx;
1465 y = inity;
1466 row = 0;
1467 cx = 0;
1468 mcy = 0;
1469 rowstart = 0;
1470 prevBand = NULL;
1471 cntonrow = 0;
1472
1473 for (i = 0; i < infoPtr->uNumBands; i++) {
1474 lpBand = &infoPtr->bands[i];
1475 lpBand->fDraw = 0;
1476 lpBand->iRow = row;
1477
1478 SetRectEmpty(&lpBand->rcChevron);
1479
1480 if (HIDDENBAND(lpBand)) continue;
1481
1482 lpBand->rcoldBand = lpBand->rcBand;
1483
1484 /* Set the offset of the child window */
1485 if ((lpBand->fMask & RBBIM_CHILD) &&
1486 !(lpBand->fStyle & RBBS_FIXEDSIZE)) {
1487 lpBand->offChild.cx = ((lpBand->fStyle & RBBS_CHILDEDGE) ? 4 : 0);
1488 }
1489 lpBand->offChild.cy = ((lpBand->fStyle & RBBS_CHILDEDGE) ? 2 : 0);
1490
1491 /* separator from previous band */
1492 cxsep = (cntonrow == 0) ? 0 : SEP_WIDTH;
1493 cx = lpBand->lcx;
1494
1495 if (infoPtr->dwStyle & CCS_VERT)
1496 dobreak = (y + cx + cxsep > adjcy);
1497 else
1498 dobreak = (x + cx + cxsep > adjcx);
1499
1500 /* This is the check for whether we need to start a new row */
1501 if ( ( (lpBand->fStyle & RBBS_BREAK) && (i != 0) ) ||
1502 ( ((infoPtr->dwStyle & CCS_VERT) ? (y != 0) : (x != 0)) && dobreak)) {
1503
1504 for (j = rowstart; j < i; j++) {
1505 REBAR_BAND *lpB;
1506 lpB = &infoPtr->bands[j];
1507 if (infoPtr->dwStyle & CCS_VERT) {
1508 lpB->rcBand.right = lpB->rcBand.left + mcy;
1509 }
1510 else {
1511 lpB->rcBand.bottom = lpB->rcBand.top + mcy;
1512 }
1513 }
1514
1515 TRACE("P1 Spliting to new row %d on band %u\n", row+1, i);
1516 if (infoPtr->dwStyle & CCS_VERT) {
1517 y = inity;
1518 x += (mcy + SEP_WIDTH);
1519 }
1520 else {
1521 x = initx;
1522 y += (mcy + SEP_WIDTH);
1523 }
1524
1525 mcy = 0;
1526 cxsep = 0;
1527 row++;
1528 lpBand->iRow = row;
1529 prevBand = NULL;
1530 rowstart = i;
1531 cntonrow = 0;
1532 }
1533
1534 if (mcy < lpBand->lcy + REBARSPACE(lpBand))
1535 mcy = lpBand->lcy + REBARSPACE(lpBand);
1536
1537 /* if boundary rect specified then limit mcy */
1538 if (lpRect) {
1539 if (infoPtr->dwStyle & CCS_VERT) {
1540 if (x+mcy > adjcx) {
1541 mcy = adjcx - x;
1542 TRACE("P1 row %u limiting mcy=%d, adjcx=%d, x=%d\n",
1543 i, mcy, adjcx, x);
1544 }
1545 }
1546 else {
1547 if (y+mcy > adjcy) {
1548 mcy = adjcy - y;
1549 TRACE("P1 row %u limiting mcy=%d, adjcy=%d, y=%d\n",
1550 i, mcy, adjcy, y);
1551 }
1552 }
1553 }
1554
1555 TRACE("P1 band %u, row %d, x=%d, y=%d, cxsep=%d, cx=%d\n",
1556 i, row,
1557 x, y, cxsep, cx);
1558 if (infoPtr->dwStyle & CCS_VERT) {
1559 /* bound the bottom side if we have a bounding rectangle */
1560 rightx = clientcx;
1561 bottomy = (lpRect) ? min(clientcy, y+cxsep+cx) : y+cxsep+cx;
1562 lpBand->rcBand.left = x;
1563 lpBand->rcBand.right = x + min(mcy,
1564 lpBand->lcy+REBARSPACE(lpBand));
1565 lpBand->rcBand.top = min(bottomy, y + cxsep);
1566 lpBand->rcBand.bottom = bottomy;
1567 lpBand->uMinHeight = lpBand->lcy;
1568 y = bottomy;
1569 }
1570 else {
1571 /* bound the right side if we have a bounding rectangle */
1572 rightx = (lpRect) ? min(clientcx, x+cxsep+cx) : x+cxsep+cx;
1573 bottomy = clientcy;
1574 lpBand->rcBand.left = min(rightx, x + cxsep);
1575 lpBand->rcBand.right = rightx;
1576 lpBand->rcBand.top = y;
1577 lpBand->rcBand.bottom = y + min(mcy,
1578 lpBand->lcy+REBARSPACE(lpBand));
1579 lpBand->uMinHeight = lpBand->lcy;
1580 x = rightx;
1581 }
1582 TRACE("P1 band %u, row %d, (%ld,%ld)-(%ld,%ld)\n",
1583 i, row,
1584 lpBand->rcBand.left, lpBand->rcBand.top,
1585 lpBand->rcBand.right, lpBand->rcBand.bottom);
1586 prevBand = lpBand;
1587 cntonrow++;
1588
1589 } /* for (i = 0; i < infoPtr->uNumBands... */
1590
1591 if (infoPtr->dwStyle & CCS_VERT)
1592 x += mcy;
1593 else
1594 y += mcy;
1595
1596 for (j = rowstart; j < infoPtr->uNumBands; j++) {
1597 lpBand = &infoPtr->bands[j];
1598 if (infoPtr->dwStyle & CCS_VERT) {
1599 lpBand->rcBand.right = lpBand->rcBand.left + mcy;
1600 }
1601 else {
1602 lpBand->rcBand.bottom = lpBand->rcBand.top + mcy;
1603 }
1604 }
1605
1606 if (infoPtr->uNumBands)
1607 infoPtr->uNumRows = row + 1;
1608
1609 /* ******* End Phase 1 - all bands on row at minimum size ******* */
1610
1611
1612 /* ******* Start Phase 1a - Adjust heights for RBS_VARHEIGHT off ******* */
1613
1614 mmcy = 0;
1615 if (!(infoPtr->dwStyle & RBS_VARHEIGHT)) {
1616 INT xy;
1617
1618 /* get the max height of all bands */
1619 for (i=0; i<infoPtr->uNumBands; i++) {
1620 lpBand = &infoPtr->bands[i];
1621 if (HIDDENBAND(lpBand)) continue;
1622 if (infoPtr->dwStyle & CCS_VERT)
1623 mmcy = max(mmcy, lpBand->rcBand.right - lpBand->rcBand.left);
1624 else
1625 mmcy = max(mmcy, lpBand->rcBand.bottom - lpBand->rcBand.top);
1626 }
1627
1628 /* now adjust all rectangles by using the height found above */
1629 xy = 0;
1630 row = 0;
1631 for (i=0; i<infoPtr->uNumBands; i++) {
1632 lpBand = &infoPtr->bands[i];
1633 if (HIDDENBAND(lpBand)) continue;
1634 if (lpBand->iRow != row)
1635 xy += (mmcy + SEP_WIDTH);
1636 if (infoPtr->dwStyle & CCS_VERT) {
1637 lpBand->rcBand.left = xy;
1638 lpBand->rcBand.right = xy + mmcy;
1639 }
1640 else {
1641 lpBand->rcBand.top = xy;
1642 lpBand->rcBand.bottom = xy + mmcy;
1643 }
1644 }
1645
1646 /* set the x/y values to the correct maximum */
1647 if (infoPtr->dwStyle & CCS_VERT)
1648 x = xy + mmcy;
1649 else
1650 y = xy + mmcy;
1651 }
1652
1653 /* ******* End Phase 1a - Adjust heights for RBS_VARHEIGHT off ******* */
1654
1655
1656 /* ******* Start Phase 2 - split rows till adjustment height full ******* */
1657
1658 /* assumes that the following variables contain: */
1659 /* y/x current height/width of all rows */
1660 if (lpRect) {
1661 INT i, prev_rh, new_rh, adj_rh, prev_idx, current_idx;
1662 REBAR_BAND *prev, *current, *walk;
1663 UINT j;
1664
1665 /* FIXME: problem # 2 */
1666 if (((infoPtr->dwStyle & CCS_VERT) ?
1667 #if PROBLEM2
1668 (x < adjcx) : (y < adjcy)
1669 #else
1670 (adjcx - x > 5) : (adjcy - y > 4)
1671 #endif
1672 ) &&
1673 (infoPtr->uNumBands > 1)) {
1674 for (i=(INT)infoPtr->uNumBands-2; i>=0; i--) {
1675 TRACE("P2 adjcx=%d, adjcy=%d, x=%d, y=%d\n",
1676 adjcx, adjcy, x, y);
1677
1678 /* find the current band (starts at i+1) */
1679 current = &infoPtr->bands[i+1];
1680 current_idx = i+1;
1681 while (HIDDENBAND(current)) {
1682 i--;
1683 if (i < 0) break; /* out of bands */
1684 current = &infoPtr->bands[i+1];
1685 current_idx = i+1;
1686 }
1687 if (i < 0) break; /* out of bands */
1688
1689 /* now find the prev band (starts at i) */
1690 prev = &infoPtr->bands[i];
1691 prev_idx = i;
1692 while (HIDDENBAND(prev)) {
1693 i--;
1694 if (i < 0) break; /* out of bands */
1695 prev = &infoPtr->bands[i];
1696 prev_idx = i;
1697 }
1698 if (i < 0) break; /* out of bands */
1699
1700 prev_rh = ircBw(prev);
1701 if (prev->iRow == current->iRow) {
1702 new_rh = (infoPtr->dwStyle & RBS_VARHEIGHT) ?
1703 current->lcy + REBARSPACE(current) :
1704 mmcy;
1705 adj_rh = new_rh + SEP_WIDTH;
1706 infoPtr->uNumRows++;
1707 current->fDraw |= NTF_INVALIDATE;
1708 current->iRow++;
1709 if (infoPtr->dwStyle & CCS_VERT) {
1710 current->rcBand.top = inity;
1711 current->rcBand.bottom = clientcy;
1712 current->rcBand.left += (prev_rh + SEP_WIDTH);
1713 current->rcBand.right = current->rcBand.left + new_rh;
1714 x += adj_rh;
1715 }
1716 else {
1717 current->rcBand.left = initx;
1718 current->rcBand.right = clientcx;
1719 current->rcBand.top += (prev_rh + SEP_WIDTH);
1720 current->rcBand.bottom = current->rcBand.top + new_rh;
1721 y += adj_rh;
1722 }
1723 TRACE("P2 moving band %d to own row at (%ld,%ld)-(%ld,%ld)\n",
1724 current_idx,
1725 current->rcBand.left, current->rcBand.top,
1726 current->rcBand.right, current->rcBand.bottom);
1727 TRACE("P2 prev band %d at (%ld,%ld)-(%ld,%ld)\n",
1728 prev_idx,
1729 prev->rcBand.left, prev->rcBand.top,
1730 prev->rcBand.right, prev->rcBand.bottom);
1731 TRACE("P2 values: prev_rh=%d, new_rh=%d, adj_rh=%d\n",
1732 prev_rh, new_rh, adj_rh);
1733 /* for bands below current adjust row # and top/bottom */
1734 for (j = current_idx+1; j<infoPtr->uNumBands; j++) {
1735 walk = &infoPtr->bands[j];
1736 if (HIDDENBAND(walk)) continue;
1737 walk->fDraw |= NTF_INVALIDATE;
1738 walk->iRow++;
1739 if (infoPtr->dwStyle & CCS_VERT) {
1740 walk->rcBand.left += adj_rh;
1741 walk->rcBand.right += adj_rh;
1742 }
1743 else {
1744 walk->rcBand.top += adj_rh;
1745 walk->rcBand.bottom += adj_rh;
1746 }
1747 }
1748 if ((infoPtr->dwStyle & CCS_VERT) ? (x >= adjcx) : (y >= adjcy))
1749 break; /* all done */
1750 }
1751 }
1752 }
1753 }
1754
1755 /* ******* End Phase 2 - split rows till adjustment height full ******* */
1756
1757
1758 /* ******* Start Phase 2a - mark first and last band in each ******* */
1759
1760 prevBand = NULL;
1761 for (i = 0; i < infoPtr->uNumBands; i++) {
1762 lpBand = &infoPtr->bands[i];
1763 if (HIDDENBAND(lpBand))
1764 continue;
1765 if( !prevBand ) {
1766 lpBand->fDraw |= DRAW_FIRST_IN_ROW;
1767 prevBand = lpBand;
1768 }
1769 else if( prevBand->iRow == lpBand->iRow )
1770 prevBand = lpBand;
1771 else {
1772 prevBand->fDraw |= DRAW_LAST_IN_ROW;
1773 lpBand->fDraw |= DRAW_FIRST_IN_ROW;
1774 prevBand = lpBand;
1775 }
1776 }
1777 if( prevBand )
1778 prevBand->fDraw |= DRAW_LAST_IN_ROW;
1779
1780 /* ******* End Phase 2a - mark first and last band in each ******* */
1781
1782
1783 /* ******* Start Phase 2b - adjust all bands for height full ******* */
1784 /* assumes that the following variables contain: */
1785 /* y/x current height/width of all rows */
1786 /* clientcy/clientcx height/width of client area */
1787
1788 if (((infoPtr->dwStyle & CCS_VERT) ? clientcx > x : clientcy > y) &&
1789 infoPtr->uNumBands) {
1790 INT diff, i;
1791 UINT j;
1792
1793 diff = (infoPtr->dwStyle & CCS_VERT) ? clientcx - x : clientcy - y;
1794
1795 /* iterate backwards thru the rows */
1796 for (i = infoPtr->uNumBands-1; i>=0; i--) {
1797 lpBand = &infoPtr->bands[i];
1798 if(HIDDENBAND(lpBand)) continue;
1799
1800 /* if row has more than 1 band, ignore it */
1801 if( !(lpBand->fDraw&DRAW_FIRST_IN_ROW) )
1802 continue;
1803 if( !(lpBand->fDraw&DRAW_LAST_IN_ROW) )
1804 continue;
1805
1806 /* FIXME: this next line is wrong, but fixing it to be inverted causes IE's sidebars to be the wrong size */
1807 if (lpBand->fMask & RBBS_VARIABLEHEIGHT) continue;
1808 if (((INT)lpBand->cyMaxChild < 1) ||
1809 ((INT)lpBand->cyIntegral < 1)) {
1810 if (lpBand->cyMaxChild + lpBand->cyIntegral == 0) continue;
1811 ERR("P2b band %u RBBS_VARIABLEHEIGHT set but cyMax=%d, cyInt=%d\n",
1812 i, lpBand->cyMaxChild, lpBand->cyIntegral);
1813 continue;
1814 }
1815 /* j is now the maximum height/width in the client area */
1816 j = ((diff / lpBand->cyIntegral) * lpBand->cyIntegral) +
1817 ircBw(lpBand);
1818 if (j > lpBand->cyMaxChild + REBARSPACE(lpBand))
1819 j = lpBand->cyMaxChild + REBARSPACE(lpBand);
1820 diff -= (j - ircBw(lpBand));
1821 if (infoPtr->dwStyle & CCS_VERT)
1822 lpBand->rcBand.right = lpBand->rcBand.left + j;
1823 else
1824 lpBand->rcBand.bottom = lpBand->rcBand.top + j;
1825 TRACE("P2b band %d, row %d changed to (%ld,%ld)-(%ld,%ld)\n",
1826 i, lpBand->iRow,
1827 lpBand->rcBand.left, lpBand->rcBand.top,
1828 lpBand->rcBand.right, lpBand->rcBand.bottom);
1829 if (diff <= 0) break;
1830 }
1831 if (diff < 0) {
1832 ERR("P2b allocated more than available, diff=%d\n", diff);
1833 diff = 0;
1834 }
1835 if (infoPtr->dwStyle & CCS_VERT)
1836 x = clientcx - diff;
1837 else
1838 y = clientcy - diff;
1839 }
1840
1841 /* ******* End Phase 2b - adjust all bands for height full ******* */
1842
1843
1844 /* ******* Start Phase 3 - adjust all bands for width full ******* */
1845
1846 if (infoPtr->uNumBands) {
1847 int startband;
1848
1849 /* If RBS_BANDBORDERS set then indicate to draw bottom separator */
1850 /* on all bands in all rows but last row. */
1851 /* Also indicate to draw the right separator for each band in */
1852 /* each row but the rightmost band. */
1853 if (infoPtr->dwStyle & RBS_BANDBORDERS) {
1854
1855 for (i=0; i<infoPtr->uNumBands; i++) {
1856 lpBand = &infoPtr->bands[i];
1857 if (HIDDENBAND(lpBand))
1858 continue;
1859
1860 /* not righthand bands */
1861 if( !(lpBand->fDraw & DRAW_LAST_IN_ROW) )
1862 lpBand->fDraw |= DRAW_RIGHTSEP;
1863
1864 /* not the last row */
1865 if( lpBand->iRow != infoPtr->uNumRows )
1866 lpBand->fDraw |= DRAW_BOTTOMSEP;
1867 }
1868 }
1869
1870 /* Distribute the extra space on the horizontal and adjust */
1871 /* all bands in row to same height. */
1872 mcy = 0;
1873 startband = -1;
1874 for (i=0; i<infoPtr->uNumBands; i++) {
1875
1876 lpBand = &infoPtr->bands[i];
1877
1878 if( lpBand->fDraw & DRAW_FIRST_IN_ROW )
1879 {
1880 startband = i;
1881 mcy = 0;
1882 }
1883
1884 if ( (mcy < ircBw(lpBand)) && !HIDDENBAND(lpBand) )
1885 mcy = ircBw(lpBand);
1886
1887 if( lpBand->fDraw & DRAW_LAST_IN_ROW )
1888 {
1889 TRACE("P3 processing row %d, starting band %d, ending band %d\n",
1890 lpBand->iRow, startband, i);
1891 if( startband < 0 )
1892 ERR("Last band %d with no first, row %d\n", i, lpBand->iRow);
1893
1894 REBAR_AdjustBands (infoPtr, startband, i,
1895 (infoPtr->dwStyle & CCS_VERT) ?
1896 clientcy : clientcx, mcy);
1897 }
1898 }
1899
1900 /* Calculate the other rectangles in each band */
1901 if (infoPtr->dwStyle & CCS_VERT) {
1902 REBAR_CalcVertBand (infoPtr, 0, infoPtr->uNumBands,
1903 notify);
1904 }
1905 else {
1906 REBAR_CalcHorzBand (infoPtr, 0, infoPtr->uNumBands,
1907 notify);
1908 }
1909 }
1910
1911 /* ******* End Phase 3 - adjust all bands for width full ******* */
1912
1913 /* now compute size of Rebar itself */
1914 infoPtr->oldSize = infoPtr->calcSize;
1915 if (infoPtr->uNumBands == 0) {
1916 /* we have no bands, so make size the size of client */
1917 x = clientcx;
1918 y = clientcy;
1919 }
1920 if (infoPtr->dwStyle & CCS_VERT) {
1921 if( x < REBAR_MINSIZE )
1922 x = REBAR_MINSIZE;
1923 infoPtr->calcSize.cx = x;
1924 infoPtr->calcSize.cy = clientcy;
1925 TRACE("vert, notify=%d, x=%d, origheight=%d\n",
1926 notify, x, origheight);
1927 if (notify && (x != origheight)) infoPtr->fStatus |= NTF_HGHTCHG;
1928 }
1929 else {
1930 if( y < REBAR_MINSIZE )
1931 y = REBAR_MINSIZE;
1932 infoPtr->calcSize.cx = clientcx;
1933 infoPtr->calcSize.cy = y;
1934 TRACE("horz, notify=%d, y=%d, origheight=%d\n",
1935 notify, y, origheight);
1936 if (notify && (y != origheight)) infoPtr->fStatus |= NTF_HGHTCHG;
1937 }
1938
1939 REBAR_DumpBand (infoPtr);
1940
1941 REBAR_MoveChildWindows (infoPtr, 0, infoPtr->uNumBands);
1942
1943 REBAR_ForceResize (infoPtr);
1944 }
1945
1946
1947 static VOID
1948 REBAR_ValidateBand (REBAR_INFO *infoPtr, REBAR_BAND *lpBand)
1949 /* Function: This routine evaluates the band specs supplied */
1950 /* by the user and updates the following 5 fields in */
1951 /* the internal band structure: cxHeader, lcx, lcy, hcx, hcy*/
1952 {
1953 UINT header=0;
1954 UINT textheight=0;
1955 UINT i, nonfixed;
1956 REBAR_BAND *tBand;
1957
1958 lpBand->fStatus = 0;
1959 lpBand->lcx = 0;
1960 lpBand->lcy = 0;
1961 lpBand->ccx = 0;
1962 lpBand->ccy = 0;
1963 lpBand->hcx = 0;
1964 lpBand->hcy = 0;
1965
1966 /* Data comming in from users into the cx... and cy... fields */
1967 /* may be bad, just garbage, because the user never clears */
1968 /* the fields. RB_{SET|INSERT}BAND{A|W} just passes the data */
1969 /* along if the fields exist in the input area. Here we must */
1970 /* determine if the data is valid. I have no idea how MS does */
1971 /* the validation, but it does because the RB_GETBANDINFO */
1972 /* returns a 0 when I know the sample program passed in an */
1973 /* address. Here I will use the algorithim that if the value */
1974 /* is greater than 65535 then it is bad and replace it with */
1975 /* a zero. Feel free to improve the algorithim. - GA 12/2000 */
1976 if (lpBand->cxMinChild > 65535) lpBand->cxMinChild = 0;
1977 if (lpBand->cyMinChild > 65535) lpBand->cyMinChild = 0;
1978 if (lpBand->cx > 65535) lpBand->cx = 0;
1979 if (lpBand->cyChild > 65535) lpBand->cyChild = 0;
1980 if (lpBand->cyMaxChild > 65535) lpBand->cyMaxChild = 0;
1981 if (lpBand->cyIntegral > 65535) lpBand->cyIntegral = 0;
1982 if (lpBand->cxIdeal > 65535) lpBand->cxIdeal = 0;
1983 if (lpBand->cxHeader > 65535) lpBand->cxHeader = 0;
1984
1985 /* FIXME: probably should only set NEEDS_LAYOUT flag when */
1986 /* values change. Till then always set it. */
1987 TRACE("setting NEEDS_LAYOUT\n");
1988 infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
1989
1990 /* Header is where the image, text and gripper exist */
1991 /* in the band and precede the child window. */
1992
1993 /* count number of non-FIXEDSIZE and non-Hidden bands */
1994 nonfixed = 0;
1995 for (i=0; i<infoPtr->uNumBands; i++){
1996 tBand = &infoPtr->bands[i];
1997 if (!HIDDENBAND(tBand) && !(tBand->fStyle & RBBS_FIXEDSIZE))
1998 nonfixed++;
1999 }
2000
2001 /* calculate gripper rectangle */
2002 if ( (!(lpBand->fStyle & RBBS_NOGRIPPER)) &&
2003 ( (lpBand->fStyle & RBBS_GRIPPERALWAYS) ||
2004 ( !(lpBand->fStyle & RBBS_FIXEDSIZE) && (nonfixed > 1)))
2005 ) {
2006 lpBand->fStatus |= HAS_GRIPPER;
2007 if (infoPtr->dwStyle & CCS_VERT)
2008 if (infoPtr->dwStyle & RBS_VERTICALGRIPPER)
2009 header += (GRIPPER_HEIGHT + REBAR_PRE_GRIPPER);
2010 else
2011 header += (GRIPPER_WIDTH + REBAR_PRE_GRIPPER);
2012 else
2013 header += (REBAR_PRE_GRIPPER + GRIPPER_WIDTH);
2014 /* Always have 4 pixels before anything else */
2015 header += REBAR_ALWAYS_SPACE;
2016 }
2017
2018 /* image is visible */
2019 if ((lpBand->fMask & RBBIM_IMAGE) && (infoPtr->himl)) {
2020 lpBand->fStatus |= HAS_IMAGE;
2021 if (infoPtr->dwStyle & CCS_VERT) {
2022 header += (infoPtr->imageSize.cy + REBAR_POST_IMAGE);
2023 lpBand->lcy = infoPtr->imageSize.cx + 2;
2024 }
2025 else {
2026 header += (infoPtr->imageSize.cx + REBAR_POST_IMAGE);
2027 lpBand->lcy = infoPtr->imageSize.cy + 2;
2028 }
2029 }
2030
2031 /* text is visible */
2032 if ((lpBand->fMask & RBBIM_TEXT) && (lpBand->lpText) &&
2033 !(lpBand->fStyle & RBBS_HIDETITLE)) {
2034 HDC hdc = GetDC (0);
2035 HFONT hOldFont = SelectObject (hdc, infoPtr->hFont);
2036 SIZE size;
2037
2038 lpBand->fStatus |= HAS_TEXT;
2039 GetTextExtentPoint32W (hdc, lpBand->lpText,
2040 lstrlenW (lpBand->lpText), &size);
2041 header += ((infoPtr->dwStyle & CCS_VERT) ? (size.cy + REBAR_POST_TEXT) : (size.cx + REBAR_POST_TEXT));
2042 textheight = (infoPtr->dwStyle & CCS_VERT) ? 0 : size.cy;
2043
2044 SelectObject (hdc, hOldFont);
2045 ReleaseDC (0, hdc);
2046 }
2047
2048 /* if no gripper but either image or text, then leave space */
2049 if ((lpBand->fStatus & (HAS_IMAGE | HAS_TEXT)) &&
2050 !(lpBand->fStatus & HAS_GRIPPER)) {
2051 header += REBAR_ALWAYS_SPACE;
2052 }
2053
2054 /* check if user overrode the header value */
2055 if (!(lpBand->fMask & RBBIM_HEADERSIZE))
2056 lpBand->cxHeader = header;
2057
2058
2059 /* Now compute minimum size of child window */
2060 lpBand->offChild.cx = 0;
2061 lpBand->offChild.cy = 0;
2062 lpBand->lcy = textheight;
2063 lpBand->ccy = lpBand->lcy;
2064 if (lpBand->fMask & RBBIM_CHILDSIZE) {
2065 lpBand->lcx = lpBand->cxMinChild;
2066
2067 /* Set the .cy values for CHILDSIZE case */
2068 lpBand->lcy = max(lpBand->lcy, lpBand->cyMinChild);
2069 lpBand->ccy = lpBand->lcy;
2070 lpBand->hcy = lpBand->lcy;
2071 if (lpBand->cyMaxChild != 0xffffffff) {
2072 lpBand->hcy = lpBand->cyMaxChild;
2073 }
2074 if (lpBand->cyChild != 0xffffffff)
2075 lpBand->ccy = max (lpBand->cyChild, lpBand->lcy);
2076
2077 TRACE("_CHILDSIZE\n");
2078 }
2079 if (lpBand->fMask & RBBIM_SIZE) {
2080 lpBand->hcx = max (lpBand->cx-lpBand->cxHeader, lpBand->lcx);
2081 TRACE("_SIZE\n");
2082 }
2083 else
2084 lpBand->hcx = lpBand->lcx;
2085 lpBand->ccx = lpBand->hcx;
2086
2087 /* make ->.cx include header size for _Layout */
2088 lpBand->lcx += lpBand->cxHeader;
2089 lpBand->ccx += lpBand->cxHeader;
2090 lpBand->hcx += lpBand->cxHeader;
2091
2092 }
2093
2094 static BOOL
2095 REBAR_CommonSetupBand (HWND hwnd, LPREBARBANDINFOA lprbbi, REBAR_BAND *lpBand)
2096 /* Function: This routine copies the supplied values from */
2097 /* user input (lprbbi) to the internal band structure. */
2098 /* It returns true if something changed and false if not. */
2099 {
2100 BOOL bChanged = FALSE;
2101
2102 lpBand->fMask |= lprbbi->fMask;
2103
2104 if( (lprbbi->fMask & RBBIM_STYLE) &&
2105 (lpBand->fStyle != lprbbi->fStyle ) )
2106 {
2107 lpBand->fStyle = lprbbi->fStyle;
2108 bChanged = TRUE;
2109 }
2110
2111 if( (lprbbi->fMask & RBBIM_COLORS) &&
2112 ( ( lpBand->clrFore != lprbbi->clrFore ) ||
2113 ( lpBand->clrBack != lprbbi->clrBack ) ) )
2114 {
2115 lpBand->clrFore = lprbbi->clrFore;
2116 lpBand->clrBack = lprbbi->clrBack;
2117 bChanged = TRUE;
2118 }
2119
2120 if( (lprbbi->fMask & RBBIM_IMAGE) &&
2121 ( lpBand->iImage != lprbbi->iImage ) )
2122 {
2123 lpBand->iImage = lprbbi->iImage;
2124 bChanged = TRUE;
2125 }
2126
2127 if( (lprbbi->fMask & RBBIM_CHILD) &&
2128 (lprbbi->hwndChild != lpBand->hwndChild ) )
2129 {
2130 if (lprbbi->hwndChild) {
2131 lpBand->hwndChild = lprbbi->hwndChild;
2132 lpBand->hwndPrevParent =
2133 SetParent (lpBand->hwndChild, hwnd);
2134 /* below in trace from WinRAR */
2135 ShowWindow(lpBand->hwndChild, SW_SHOWNOACTIVATE | SW_SHOWNORMAL);
2136 /* above in trace from WinRAR */
2137 }
2138 else {
2139 TRACE("child: %p prev parent: %p\n",
2140 lpBand->hwndChild, lpBand->hwndPrevParent);
2141 lpBand->hwndChild = 0;
2142 lpBand->hwndPrevParent = 0;
2143 }
2144 bChanged = TRUE;
2145 }
2146
2147 if( (lprbbi->fMask & RBBIM_CHILDSIZE) &&
2148 ( (lpBand->cxMinChild != lprbbi->cxMinChild) ||
2149 (lpBand->cyMinChild != lprbbi->cyMinChild ) ||
2150 ( (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) &&
2151 ( (lpBand->cyChild != lprbbi->cyChild ) ||
2152 (lpBand->cyMaxChild != lprbbi->cyMaxChild ) ||
2153 (lpBand->cyIntegral != lprbbi->cyIntegral ) ) ) ||
2154 ( (lprbbi->cbSize < sizeof (REBARBANDINFOA)) &&
2155 ( (lpBand->cyChild ||
2156 lpBand->cyMaxChild ||
2157 lpBand->cyIntegral ) ) ) ) )
2158 {
2159 lpBand->cxMinChild = lprbbi->cxMinChild;
2160 lpBand->cyMinChild = lprbbi->cyMinChild;
2161 if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
2162 lpBand->cyChild = lprbbi->cyChild;
2163 lpBand->cyMaxChild = lprbbi->cyMaxChild;
2164 lpBand->cyIntegral = lprbbi->cyIntegral;
2165 }
2166 else { /* special case - these should be zeroed out since */
2167 /* RBBIM_CHILDSIZE added these in WIN32_IE >= 0x0400 */
2168 lpBand->cyChild = 0;
2169 lpBand->cyMaxChild = 0;
2170 lpBand->cyIntegral = 0;
2171 }
2172 bChanged = TRUE;
2173 }
2174
2175 if( (lprbbi->fMask & RBBIM_SIZE) &&
2176 (lpBand->cx != lprbbi->cx ) )
2177 {
2178 lpBand->cx = lprbbi->cx;
2179 bChanged = TRUE;
2180 }
2181
2182 if( (lprbbi->fMask & RBBIM_BACKGROUND) &&
2183 ( lpBand->hbmBack != lprbbi->hbmBack ) )
2184 {
2185 lpBand->hbmBack = lprbbi->hbmBack;
2186 bChanged = TRUE;
2187 }
2188
2189 if( (lprbbi->fMask & RBBIM_ID) &&
2190 (lpBand->wID != lprbbi->wID ) )
2191 {
2192 lpBand->wID = lprbbi->wID;
2193 bChanged = TRUE;
2194 }
2195
2196 /* check for additional data */
2197 if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
2198 if( (lprbbi->fMask & RBBIM_IDEALSIZE) &&
2199 ( lpBand->cxIdeal != lprbbi->cxIdeal ) )
2200 {
2201 lpBand->cxIdeal = lprbbi->cxIdeal;
2202 bChanged = TRUE;
2203 }
2204
2205 if( (lprbbi->fMask & RBBIM_LPARAM) &&
2206 (lpBand->lParam != lprbbi->lParam ) )
2207 {
2208 lpBand->lParam = lprbbi->lParam;
2209 bChanged = TRUE;
2210 }
2211
2212 if( (lprbbi->fMask & RBBIM_HEADERSIZE) &&
2213 (lpBand->cxHeader != lprbbi->cxHeader ) )
2214 {
2215 lpBand->cxHeader = lprbbi->cxHeader;
2216 bChanged = TRUE;
2217 }
2218 }
2219
2220 return bChanged;
2221 }
2222
2223 static LRESULT
2224 REBAR_InternalEraseBkGnd (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam, RECT *clip)
2225 /* Function: This erases the background rectangle by drawing */
2226 /* each band with its background color (or the default) and */
2227 /* draws each bands right separator if necessary. The row */
2228 /* separators are drawn on the first band of the next row. */
2229 {
2230 REBAR_BAND *lpBand;
2231 UINT i;
2232 INT oldrow;
2233 HDC hdc = (HDC)wParam;
2234 RECT rect, cr;
2235 COLORREF old = CLR_NONE, new;
2236 HTHEME theme = GetWindowTheme (infoPtr->hwndSelf);
2237
2238 GetClientRect (infoPtr->hwndSelf, &cr);
2239
2240 oldrow = -1;
2241 for(i=0; i<infoPtr->uNumBands; i++) {
2242 lpBand = &infoPtr->bands[i];
2243 if (HIDDENBAND(lpBand)) continue;
2244
2245 /* draw band separator between rows */
2246 if (lpBand->iRow != oldrow) {
2247 oldrow = lpBand->iRow;
2248 if (lpBand->fDraw & DRAW_BOTTOMSEP) {
2249 RECT rcRowSep;
2250 rcRowSep = lpBand->rcBand;
2251 if (infoPtr->dwStyle & CCS_VERT) {
2252 rcRowSep.right += SEP_WIDTH_SIZE;
2253 rcRowSep.bottom = infoPtr->calcSize.cy;
2254 if (theme)
2255 DrawThemeEdge (theme, hdc, RP_BAND, 0, &rcRowSep, EDGE_ETCHED, BF_RIGHT, NULL);
2256 else
2257 DrawEdge (hdc, &rcRowSep, EDGE_ETCHED, BF_RIGHT);
2258 }
2259 else {
2260 rcRowSep.bottom += SEP_WIDTH_SIZE;
2261 rcRowSep.right = infoPtr->calcSize.cx;
2262 if (theme)
2263 DrawThemeEdge (theme, hdc, RP_BAND, 0, &rcRowSep, EDGE_ETCHED, BF_BOTTOM, NULL);
2264 else
2265 DrawEdge (hdc, &rcRowSep, EDGE_ETCHED, BF_BOTTOM);
2266 }
2267 TRACE ("drawing band separator bottom (%ld,%ld)-(%ld,%ld)\n",
2268 rcRowSep.left, rcRowSep.top,
2269 rcRowSep.right, rcRowSep.bottom);
2270 }
2271 }
2272
2273 /* draw band separator between bands in a row */
2274 if (lpBand->fDraw & DRAW_RIGHTSEP) {
2275 RECT rcSep;
2276 rcSep = lpBand->rcBand;
2277 if (infoPtr->dwStyle & CCS_VERT) {
2278 rcSep.bottom += SEP_WIDTH_SIZE;
2279 if (theme)
2280 DrawThemeEdge (theme, hdc, RP_BAND, 0, &rcSep, EDGE_ETCHED, BF_BOTTOM, NULL);
2281 else
2282 DrawEdge (hdc, &rcSep, EDGE_ETCHED, BF_BOTTOM);
2283 }
2284 else {
2285 rcSep.right += SEP_WIDTH_SIZE;
2286 if (theme)
2287 DrawThemeEdge (theme, hdc, RP_BAND, 0, &rcSep, EDGE_ETCHED, BF_RIGHT, NULL);
2288 else
2289 DrawEdge (hdc, &rcSep, EDGE_ETCHED, BF_RIGHT);
2290 }
2291 TRACE("drawing band separator right (%ld,%ld)-(%ld,%ld)\n",
2292 rcSep.left, rcSep.top, rcSep.right, rcSep.bottom);
2293 }
2294
2295 /* draw the actual background */
2296 if (lpBand->clrBack != CLR_NONE) {
2297 new = (lpBand->clrBack == CLR_DEFAULT) ? infoPtr->clrBtnFace :
2298 lpBand->clrBack;
2299 #if GLATESTING
2300 /* testing only - make background green to see it */
2301 new = RGB(0,128,0);
2302 #endif
2303 }
2304 else {
2305 /* In the absence of documentation for Rebar vs. CLR_NONE,
2306 * we will use the default BtnFace color. Note documentation
2307 * exists for Listview and Imagelist.
2308 */
2309 new = infoPtr->clrBtnFace;
2310 #if GLATESTING
2311 /* testing only - make background green to see it */
2312 new = RGB(0,128,0);
2313 #endif
2314 }
2315
2316 rect = lpBand->rcBand;
2317
2318 if (theme)
2319 {
2320 /* When themed, the background color is ignored (but not a
2321 * background bitmap */
2322 DrawThemeBackground (theme, hdc, 0, 0, &cr, &rect);
2323 }
2324 else
2325 {
2326 old = SetBkColor (hdc, new);
2327 TRACE("%s background color=0x%06lx, band (%ld,%ld)-(%ld,%ld), clip (%ld,%ld)-(%ld,%ld)\n",
2328 (lpBand->clrBack == CLR_NONE) ? "none" :
2329 ((lpBand->clrBack == CLR_DEFAULT) ? "dft" : ""),
2330 GetBkColor(hdc),
2331 lpBand->rcBand.left,lpBand->rcBand.top,
2332 lpBand->rcBand.right,lpBand->rcBand.bottom,
2333 clip->left, clip->top,
2334 clip->right, clip->bottom);
2335 ExtTextOutW (hdc, 0, 0, ETO_OPAQUE, &rect, NULL, 0, 0);
2336 if (lpBand->clrBack != CLR_NONE)
2337 SetBkColor (hdc, old);
2338 }
2339 }
2340 return TRUE;
2341 }
2342
2343 static void
2344 REBAR_InternalHitTest (REBAR_INFO *infoPtr, const LPPOINT lpPt, UINT *pFlags, INT *pBand)
2345 {
2346 REBAR_BAND *lpBand;
2347 RECT rect;
2348 UINT iCount;
2349
2350 GetClientRect (infoPtr->hwndSelf, &rect);
2351
2352 *pFlags = RBHT_NOWHERE;
2353 if (PtInRect (&rect, *lpPt))
2354 {
2355 if (infoPtr->uNumBands == 0) {
2356 *pFlags = RBHT_NOWHERE;
2357 if (pBand)
2358 *pBand = -1;
2359 TRACE("NOWHERE\n");
2360 return;
2361 }
2362 else {
2363 /* somewhere inside */
2364 for (iCount = 0; iCount < infoPtr->uNumBands; iCount++) {
2365 lpBand = &infoPtr->bands[iCount];
2366 if (HIDDENBAND(lpBand)) continue;
2367 if (PtInRect (&lpBand->rcBand, *lpPt)) {
2368 if (pBand)
2369 *pBand = iCount;
2370 if (PtInRect (&lpBand->rcGripper, *lpPt)) {
2371 *pFlags = RBHT_GRABBER;
2372 TRACE("ON GRABBER %d\n", iCount);
2373 return;
2374 }
2375 else if (PtInRect (&lpBand->rcCapImage, *lpPt)) {
2376 *pFlags = RBHT_CAPTION;
2377 TRACE("ON CAPTION %d\n", iCount);
2378 return;
2379 }
2380 else if (PtInRect (&lpBand->rcCapText, *lpPt)) {
2381 *pFlags = RBHT_CAPTION;
2382 TRACE("ON CAPTION %d\n", iCount);
2383 return;
2384 }
2385 else if (PtInRect (&lpBand->rcChild, *lpPt)) {
2386 *pFlags = RBHT_CLIENT;
2387 TRACE("ON CLIENT %d\n", iCount);
2388 return;
2389 }
2390 else if (PtInRect (&lpBand->rcChevron, *lpPt)) {
2391 *pFlags = RBHT_CHEVRON;
2392 TRACE("ON CHEVRON %d\n", iCount);
2393 return;
2394 }
2395 else {
2396 *pFlags = RBHT_NOWHERE;
2397 TRACE("NOWHERE %d\n", iCount);
2398 return;
2399 }
2400 }
2401 }
2402
2403 *pFlags = RBHT_NOWHERE;
2404 if (pBand)
2405 *pBand = -1;
2406
2407 TRACE("NOWHERE\n");
2408 return;
2409 }
2410 }
2411 else {
2412 *pFlags = RBHT_NOWHERE;
2413 if (pBand)
2414 *pBand = -1;
2415 TRACE("NOWHERE\n");
2416 return;
2417 }
2418 }
2419
2420
2421 static INT
2422 REBAR_Shrink (REBAR_INFO *infoPtr, REBAR_BAND *band, INT movement, INT i)
2423 /* Function: This attempts to shrink the given band by the */
2424 /* the amount in "movement". A shrink to the left is indi- */
2425 /* cated by "movement" being negative. "i" is merely the */
2426 /* band index for trace messages. */
2427 {
2428 INT Leadjust, Readjust, avail, ret;
2429
2430 /* Note: a left drag is indicated by "movement" being negative. */
2431 /* Similarly, a right drag is indicated by "movement" */
2432 /* being positive. "movement" should never be 0, but if */
2433 /* it is then the band does not move. */
2434
2435 avail = rcBw(band) - band->lcx;
2436
2437 /* now compute the Left End adjustment factor and Right End */
2438 /* adjustment factor. They may be different if shrinking. */
2439 if (avail <= 0) {
2440 /* if this band is not shrinkable, then just move it */
2441 Leadjust = Readjust = movement;
2442 ret = movement;
2443 }
2444 else {
2445 if (movement < 0) {
2446 /* Drag to left */
2447 if (avail <= abs(movement)) {
2448 Readjust = movement;
2449 Leadjust = movement + avail;
2450 ret = Leadjust;
2451 }
2452 else {
2453 Readjust = movement;
2454 Leadjust = 0;
2455 ret = 0;
2456 }
2457 }
2458 else {
2459 /* Drag to right */
2460 if (avail <= abs(movement)) {
2461 Leadjust = movement;
2462 Readjust = movement - avail;
2463 ret = Readjust;
2464 }
2465 else {
2466 Leadjust = movement;
2467 Readjust = 0;
2468 ret = 0;
2469 }
2470 }
2471 }
2472
2473 /* Reasonability Check */
2474 if (rcBlt(band) + Leadjust < 0) {
2475 ERR("adjustment will fail, band %d: left=%d, right=%d, move=%d, rtn=%d\n",
2476 i, Leadjust, Readjust, movement, ret);
2477 }
2478
2479 LEADJ(band, Leadjust);
2480 READJ(band, Readjust);
2481
2482 TRACE("band %d: left=%d, right=%d, move=%d, rtn=%d, rcBand=(%ld,%ld)-(%ld,%ld)\n",
2483 i, Leadjust, Readjust, movement, ret,
2484 band->rcBand.left, band->rcBand.top,
2485 band->rcBand.right, band->rcBand.bottom);
2486 return ret;
2487 }
2488
2489
2490 static void
2491 REBAR_HandleLRDrag (REBAR_INFO *infoPtr, const POINT *ptsmove)
2492 /* Function: This will implement the functionality of a */
2493 /* Gripper drag within a row. It will not implement "out- */
2494 /* of-row" drags. (They are detected and handled in */
2495 /* REBAR_MouseMove.) */
2496 /* **** FIXME Switching order of bands in a row not **** */
2497 /* **** yet implemented. **** */
2498 {
2499 REBAR_BAND *hitBand, *band, *mindBand, *maxdBand;
2500 RECT newrect;
2501 INT imindBand = -1, imaxdBand, ihitBand, i, movement;
2502 INT RHeaderSum = 0, LHeaderSum = 0;
2503 INT compress;
2504
2505 /* on first significant mouse movement, issue notify */
2506
2507 if (!(infoPtr->fStatus & BEGIN_DRAG_ISSUED)) {
2508 if (REBAR_Notify_NMREBAR (infoPtr, -1, RBN_BEGINDRAG)) {
2509 /* Notify returned TRUE - abort drag */
2510 infoPtr->dragStart.x = 0;
2511 infoPtr->dragStart.y = 0;
2512 infoPtr->dragNow = infoPtr->dragStart;
2513 infoPtr->iGrabbedBand = -1;
2514 ReleaseCapture ();
2515 return ;
2516 }
2517 infoPtr->fStatus |= BEGIN_DRAG_ISSUED;
2518 }
2519
2520 ihitBand = infoPtr->iGrabbedBand;
2521 hitBand = &infoPtr->bands[ihitBand];
2522 imaxdBand = ihitBand; /* to suppress warning message */
2523
2524 /* find all the bands in the row of the one whose Gripper was seized */
2525 for (i=0; i<infoPtr->uNumBands; i++) {
2526 band = &infoPtr->bands[i];
2527 if (HIDDENBAND(band)) continue;
2528 if (band->iRow == hitBand->iRow) {
2529 imaxdBand = i;
2530 if (imindBand == -1) imindBand = i;
2531 /* minimum size of each band is size of header plus */
2532 /* size of minimum child plus offset of child from header plus */
2533 /* one to separate each band. */
2534 if (i < ihitBand)
2535 LHeaderSum += (band->lcx + SEP_WIDTH);
2536 else
2537 RHeaderSum += (band->lcx + SEP_WIDTH);
2538
2539 }
2540 }
2541 if (RHeaderSum) RHeaderSum -= SEP_WIDTH; /* no separator after last band */
2542
2543 mindBand = &infoPtr->bands[imindBand];
2544 maxdBand = &infoPtr->bands[imaxdBand];
2545
2546 if (imindBand == imaxdBand) return; /* nothing to drag against */
2547 if (imindBand == ihitBand) return; /* first band in row, can't drag */
2548
2549 /* limit movement to inside adjustable bands - Left */
2550 if ( (ptsmove->x < mindBand->rcBand.left) ||
2551 (ptsmove->x > maxdBand->rcBand.right) ||
2552 (ptsmove->y < mindBand->rcBand.top) ||
2553 (ptsmove->y > maxdBand->rcBand.bottom))
2554 return; /* should swap bands */
2555
2556 if (infoPtr->dwStyle & CCS_VERT)
2557 movement = ptsmove->y - ((hitBand->rcBand.top+REBAR_PRE_GRIPPER) -
2558 infoPtr->ihitoffset);
2559 else
2560 movement = ptsmove->x - ((hitBand->rcBand.left+REBAR_PRE_GRIPPER) -
2561 infoPtr->ihitoffset);
2562 infoPtr->dragNow = *ptsmove;
2563
2564 TRACE("before: movement=%d (%ld,%ld), imindBand=%d, ihitBand=%d, imaxdBand=%d, LSum=%d, RSum=%d\n",
2565 movement, ptsmove->x, ptsmove->y, imindBand, ihitBand,
2566 imaxdBand, LHeaderSum, RHeaderSum);
2567 REBAR_DumpBand (infoPtr);
2568
2569 if (movement < 0) {
2570
2571 /* *** Drag left/up *** */
2572 compress = rcBlt(hitBand) - rcBlt(mindBand) -
2573 LHeaderSum;
2574 if (compress < abs(movement)) {
2575 TRACE("limiting left drag, was %d changed to %d\n",
2576 movement, -compress);
2577 movement = -compress;
2578 }
2579
2580 for (i=ihitBand; i>=imindBand; i--) {
2581 band = &infoPtr->bands[i];
2582 if (HIDDENBAND(band)) continue;
2583 if (i == ihitBand) {
2584 LEADJ(band, movement);
2585 }
2586 else
2587 movement = REBAR_Shrink (infoPtr, band, movement, i);
2588 band->ccx = rcBw(band);
2589 }
2590 }
2591 else {
2592 BOOL first = TRUE;
2593
2594 /* *** Drag right/down *** */
2595 compress = rcBrb(maxdBand) - rcBlt(hitBand) -
2596 RHeaderSum;
2597 if (compress < abs(movement)) {
2598 TRACE("limiting right drag, was %d changed to %d\n",
2599 movement, compress);
2600 movement = compress;
2601 }
2602 for (i=ihitBand-1; i<=imaxdBand; i++) {
2603 band = &infoPtr->bands[i];
2604 if (HIDDENBAND(band)) continue;
2605 if (first) {
2606 first = FALSE;
2607 READJ(band, movement);
2608 }
2609 else
2610 movement = REBAR_Shrink (infoPtr, band, movement, i);
2611 band->ccx = rcBw(band);
2612 }
2613 }
2614
2615 /* recompute all rectangles */
2616 if (infoPtr->dwStyle & CCS_VERT) {
2617 REBAR_CalcVertBand (infoPtr, imindBand, imaxdBand+1,
2618 FALSE);
2619 }
2620 else {
2621 REBAR_CalcHorzBand (infoPtr, imindBand, imaxdBand+1,
2622 FALSE);
2623 }
2624
2625 TRACE("bands after adjustment, see band # %d, %d\n",
2626 imindBand, imaxdBand);
2627 REBAR_DumpBand (infoPtr);
2628
2629 SetRect (&newrect,
2630 mindBand->rcBand.left,
2631 mindBand->rcBand.top,
2632 maxdBand->rcBand.right,
2633 maxdBand->rcBand.bottom);
2634
2635 REBAR_MoveChildWindows (infoPtr, imindBand, imaxdBand+1);
2636
2637 InvalidateRect (infoPtr->hwndSelf, &newrect, TRUE);
2638 UpdateWindow (infoPtr->hwndSelf);
2639
2640 }
2641
2642
2643
2644 /* << REBAR_BeginDrag >> */
2645
2646
2647 static LRESULT
2648 REBAR_DeleteBand (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2649 {
2650 UINT uBand = (UINT)wParam;
2651 HWND childhwnd = 0;
2652 REBAR_BAND *lpBand;
2653
2654 if (uBand >= infoPtr->uNumBands)
2655 return FALSE;
2656
2657 TRACE("deleting band %u!\n", uBand);
2658 lpBand = &infoPtr->bands[uBand];
2659 REBAR_Notify_NMREBAR (infoPtr, uBand, RBN_DELETINGBAND);
2660
2661 if (infoPtr->uNumBands == 1) {
2662 TRACE(" simple delete!\n");
2663 if ((lpBand->fMask & RBBIM_CHILD) && lpBand->hwndChild)
2664 childhwnd = lpBand->hwndChild;
2665 Free (infoPtr->bands);
2666 infoPtr->bands = NULL;
2667 infoPtr->uNumBands = 0;
2668 }
2669 else {
2670 REBAR_BAND *oldBands = infoPtr->bands;
2671 TRACE("complex delete! [uBand=%u]\n", uBand);
2672
2673 if ((lpBand->fMask & RBBIM_CHILD) && lpBand->hwndChild)
2674 childhwnd = lpBand->hwndChild;
2675
2676 infoPtr->uNumBands--;
2677 infoPtr->bands = Alloc (sizeof (REBAR_BAND) * infoPtr->uNumBands);
2678 if (uBand > 0) {
2679 memcpy (&infoPtr->bands[0], &oldBands[0],
2680 uBand * sizeof(REBAR_BAND));
2681 }
2682
2683 if (uBand < infoPtr->uNumBands) {
2684 memcpy (&infoPtr->bands[uBand], &oldBands[uBand+1],
2685 (infoPtr->uNumBands - uBand) * sizeof(REBAR_BAND));
2686 }
2687
2688 Free (oldBands);
2689 }
2690
2691 if (childhwnd)
2692 ShowWindow (childhwnd, SW_HIDE);
2693
2694 REBAR_Notify_NMREBAR (infoPtr, -1, RBN_DELETEDBAND);
2695
2696 /* if only 1 band left the re-validate to possible eliminate gripper */
2697 if (infoPtr->uNumBands == 1)
2698 REBAR_ValidateBand (infoPtr, &infoPtr->bands[0]);
2699
2700 TRACE("setting NEEDS_LAYOUT\n");
2701 infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
2702 infoPtr->fStatus |= RESIZE_ANYHOW;
2703 REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
2704
2705 return TRUE;
2706 }
2707
2708
2709 /* << REBAR_DragMove >> */
2710 /* << REBAR_EndDrag >> */
2711
2712
2713 static LRESULT
2714 REBAR_GetBandBorders (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2715 {
2716 LPRECT lpRect = (LPRECT)lParam;
2717 REBAR_BAND *lpBand;
2718
2719 if (!lParam)
2720 return 0;
2721 if ((UINT)wParam >= infoPtr->uNumBands)
2722 return 0;
2723
2724 lpBand = &infoPtr->bands[(UINT)wParam];
2725
2726 /* FIXME - the following values were determined by experimentation */
2727 /* with the REBAR Control Spy. I have guesses as to what the 4 and */
2728 /* 1 are, but I am not sure. There doesn't seem to be any actual */
2729 /* difference in size of the control area with and without the */
2730 /* style. - GA */
2731 if (infoPtr->dwStyle & RBS_BANDBORDERS) {
2732 if (infoPtr->dwStyle & CCS_VERT) {
2733 lpRect->left = 1;
2734 lpRect->top = lpBand->cxHeader + 4;
2735 lpRect->right = 1;
2736 lpRect->bottom = 0;
2737 }
2738 else {
2739 lpRect->left = lpBand->cxHeader + 4;
2740 lpRect->top = 1;
2741 lpRect->right = 0;
2742 lpRect->bottom = 1;
2743 }
2744 }
2745 else {
2746 lpRect->left = lpBand->cxHeader;
2747 }
2748 return 0;
2749 }
2750
2751
2752 inline static LRESULT
2753 REBAR_GetBandCount (REBAR_INFO *infoPtr)
2754 {
2755 TRACE("band count %u!\n", infoPtr->uNumBands);
2756
2757 return infoPtr->uNumBands;
2758 }
2759
2760
2761 static LRESULT
2762 REBAR_GetBandInfoA (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2763 {
2764 LPREBARBANDINFOA lprbbi = (LPREBARBANDINFOA)lParam;
2765 REBAR_BAND *lpBand;
2766
2767 if (lprbbi == NULL)
2768 return FALSE;
2769 if (lprbbi->cbSize < REBARBANDINFOA_V3_SIZE)
2770 return FALSE;
2771 if ((UINT)wParam >= infoPtr->uNumBands)
2772 return FALSE;
2773
2774 TRACE("index %u\n", (UINT)wParam);
2775
2776 /* copy band information */
2777 lpBand = &infoPtr->bands[(UINT)wParam];
2778
2779 if (lprbbi->fMask & RBBIM_STYLE)
2780 lprbbi->fStyle = lpBand->fStyle;
2781
2782 if (lprbbi->fMask & RBBIM_COLORS) {
2783 lprbbi->clrFore = lpBand->clrFore;
2784 lprbbi->clrBack = lpBand->clrBack;
2785 if (lprbbi->clrBack == CLR_DEFAULT)
2786 lprbbi->clrBack = infoPtr->clrBtnFace;
2787 }
2788
2789 if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) {
2790 if (lpBand->lpText && (lpBand->fMask & RBBIM_TEXT))
2791 {
2792 if (!WideCharToMultiByte( CP_ACP, 0, lpBand->lpText, -1,
2793 lprbbi->lpText, lprbbi->cch, NULL, NULL ))
2794 lprbbi->lpText[lprbbi->cch-1] = 0;
2795 }
2796 else
2797 *lprbbi->lpText = 0;
2798 }
2799
2800 if (lprbbi->fMask & RBBIM_IMAGE) {
2801 if (lpBand->fMask & RBBIM_IMAGE)
2802 lprbbi->iImage = lpBand->iImage;
2803 else
2804 lprbbi->iImage = -1;
2805 }
2806
2807 if (lprbbi->fMask & RBBIM_CHILD)
2808 lprbbi->hwndChild = lpBand->hwndChild;
2809
2810 if (lprbbi->fMask & RBBIM_CHILDSIZE) {
2811 lprbbi->cxMinChild = lpBand->cxMinChild;
2812 lprbbi->cyMinChild = lpBand->cyMinChild;
2813 if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
2814 lprbbi->cyChild = lpBand->cyChild;
2815 lprbbi->cyMaxChild = lpBand->cyMaxChild;
2816 lprbbi->cyIntegral = lpBand->cyIntegral;
2817 }
2818 }
2819
2820 if (lprbbi->fMask & RBBIM_SIZE)
2821 lprbbi->cx = lpBand->cx;
2822
2823 if (lprbbi->fMask & RBBIM_BACKGROUND)
2824 lprbbi->hbmBack = lpBand->hbmBack;
2825
2826 if (lprbbi->fMask & RBBIM_ID)
2827 lprbbi->wID = lpBand->wID;
2828
2829 /* check for additional data */
2830 if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
2831 if (lprbbi->fMask & RBBIM_IDEALSIZE)
2832 lprbbi->cxIdeal = lpBand->cxIdeal;
2833
2834 if (lprbbi->fMask & RBBIM_LPARAM)
2835 lprbbi->lParam = lpBand->lParam;
2836
2837 if (lprbbi->fMask & RBBIM_HEADERSIZE)
2838 lprbbi->cxHeader = lpBand->cxHeader;
2839 }
2840
2841 REBAR_DumpBandInfo (lprbbi);
2842
2843 return TRUE;
2844 }
2845
2846
2847 static LRESULT
2848 REBAR_GetBandInfoW (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2849 {
2850 LPREBARBANDINFOW lprbbi = (LPREBARBANDINFOW)lParam;
2851 REBAR_BAND *lpBand;
2852
2853 if (lprbbi == NULL)
2854 return FALSE;
2855 if (lprbbi->cbSize < REBARBANDINFOW_V3_SIZE)
2856 return FALSE;
2857 if ((UINT)wParam >= infoPtr->uNumBands)
2858 return FALSE;
2859
2860 TRACE("index %u\n", (UINT)wParam);
2861
2862 /* copy band information */
2863 lpBand = &infoPtr->bands[(UINT)wParam];
2864
2865 if (lprbbi->fMask & RBBIM_STYLE)
2866 lprbbi->fStyle = lpBand->fStyle;
2867
2868 if (lprbbi->fMask & RBBIM_COLORS) {
2869 lprbbi->clrFore = lpBand->clrFore;
2870 lprbbi->clrBack = lpBand->clrBack;
2871 if (lprbbi->clrBack == CLR_DEFAULT)
2872 lprbbi->clrBack = infoPtr->clrBtnFace;
2873 }
2874
2875 if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) {
2876 if (lpBand->lpText && (lpBand->fMask & RBBIM_TEXT))
2877 lstrcpynW (lprbbi->lpText, lpBand->lpText, lprbbi->cch);
2878 else
2879 *lprbbi->lpText = 0;
2880 }
2881
2882 if (lprbbi->fMask & RBBIM_IMAGE) {
2883 if (lpBand->fMask & RBBIM_IMAGE)
2884 lprbbi->iImage = lpBand->iImage;
2885 else
2886 lprbbi->iImage = -1;
2887 }
2888
2889 if (lprbbi->fMask & RBBIM_CHILD)
2890 lprbbi->hwndChild = lpBand->hwndChild;
2891
2892 if (lprbbi->fMask & RBBIM_CHILDSIZE) {
2893 lprbbi->cxMinChild = lpBand->cxMinChild;
2894 lprbbi->cyMinChild = lpBand->cyMinChild;
2895 if (lprbbi->cbSize >= sizeof (REBARBANDINFOW)) {
2896 lprbbi->cyChild = lpBand->cyChild;
2897 lprbbi->cyMaxChild = lpBand->cyMaxChild;
2898 lprbbi->cyIntegral = lpBand->cyIntegral;
2899 }
2900 }
2901
2902 if (lprbbi->fMask & RBBIM_SIZE)
2903 lprbbi->cx = lpBand->cx;
2904
2905 if (lprbbi->fMask & RBBIM_BACKGROUND)
2906 lprbbi->hbmBack = lpBand->hbmBack;
2907
2908 if (lprbbi->fMask & RBBIM_ID)
2909 lprbbi->wID = lpBand->wID;
2910
2911 /* check for additional data */
2912 if (lprbbi->cbSize >= sizeof (REBARBANDINFOW)) {
2913 if (lprbbi->fMask & RBBIM_IDEALSIZE)
2914 lprbbi->cxIdeal = lpBand->cxIdeal;
2915
2916 if (lprbbi->fMask & RBBIM_LPARAM)
2917 lprbbi->lParam = lpBand->lParam;
2918
2919 if (lprbbi->fMask & RBBIM_HEADERSIZE)
2920 lprbbi->cxHeader = lpBand->cxHeader;
2921 }
2922
2923 REBAR_DumpBandInfo ((LPREBARBANDINFOA)lprbbi);
2924
2925 return TRUE;
2926 }
2927
2928
2929 static LRESULT
2930 REBAR_GetBarHeight (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2931 {
2932 INT nHeight;
2933
2934 nHeight = (infoPtr->dwStyle & CCS_VERT) ? infoPtr->calcSize.cx : infoPtr->calcSize.cy;
2935
2936 TRACE("height = %d\n", nHeight);
2937
2938 return nHeight;
2939 }
2940
2941
2942 static LRESULT
2943 REBAR_GetBarInfo (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2944 {
2945 LPREBARINFO lpInfo = (LPREBARINFO)lParam;
2946
2947 if (lpInfo == NULL)
2948 return FALSE;
2949
2950 if (lpInfo->cbSize < sizeof (REBARINFO))
2951 return FALSE;
2952
2953 TRACE("getting bar info!\n");
2954
2955 if (infoPtr->himl) {
2956 lpInfo->himl = infoPtr->himl;
2957 lpInfo->fMask |= RBIM_IMAGELIST;
2958 }
2959
2960 return TRUE;
2961 }
2962
2963
2964 inline static LRESULT
2965 REBAR_GetBkColor (REBAR_INFO *infoPtr)
2966 {
2967 COLORREF clr = infoPtr->clrBk;
2968
2969 if (clr == CLR_DEFAULT)
2970 clr = infoPtr->clrBtnFace;
2971
2972 TRACE("background color 0x%06lx!\n", clr);
2973
2974 return clr;
2975 }
2976
2977
2978 /* << REBAR_GetColorScheme >> */
2979 /* << REBAR_GetDropTarget >> */
2980
2981
2982 static LRESULT
2983 REBAR_GetPalette (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2984 {
2985 FIXME("empty stub!\n");
2986
2987 return 0;
2988 }
2989
2990
2991 static LRESULT
2992 REBAR_GetRect (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2993 {
2994 INT iBand = (INT)wParam;
2995 LPRECT lprc = (LPRECT)lParam;
2996 REBAR_BAND *lpBand;
2997
2998 if ((iBand < 0) && ((UINT)iBand >= infoPtr->uNumBands))
2999 return FALSE;
3000 if (!lprc)
3001 return FALSE;
3002
3003 lpBand = &infoPtr->bands[iBand];
3004 CopyRect (lprc, &lpBand->rcBand);
3005
3006 TRACE("band %d, (%ld,%ld)-(%ld,%ld)\n", iBand,
3007 lprc->left, lprc->top, lprc->right, lprc->bottom);
3008
3009 return TRUE;
3010 }
3011
3012
3013 inline static LRESULT
3014 REBAR_GetRowCount (REBAR_INFO *infoPtr)
3015 {
3016 TRACE("%u\n", infoPtr->uNumRows);
3017
3018 return infoPtr->uNumRows;
3019 }
3020
3021
3022 static LRESULT
3023 REBAR_GetRowHeight (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3024 {
3025 INT iRow = (INT)wParam;
3026 int j = 0, ret = 0;
3027 UINT i;
3028 REBAR_BAND *lpBand;
3029
3030 for (i=0; i<infoPtr->uNumBands; i++) {
3031 lpBand = &infoPtr->bands[i];
3032 if (HIDDENBAND(lpBand)) continue;
3033 if (lpBand->iRow != iRow) continue;
3034 if (infoPtr->dwStyle & CCS_VERT)
3035 j = lpBand->rcBand.right - lpBand->rcBand.left;
3036 else
3037 j = lpBand->rcBand.bottom - lpBand->rcBand.top;
3038 if (j > ret) ret = j;
3039 }
3040
3041 TRACE("row %d, height %d\n", iRow, ret);
3042
3043 return ret;
3044 }
3045
3046
3047 inline static LRESULT
3048 REBAR_GetTextColor (REBAR_INFO *infoPtr)
3049 {
3050 TRACE("text color 0x%06lx!\n", infoPtr->clrText);
3051
3052 return infoPtr->clrText;
3053 }
3054
3055
3056 inline static LRESULT
3057 REBAR_GetToolTips (REBAR_INFO *infoPtr)
3058 {
3059 return (LRESULT)infoPtr->hwndToolTip;
3060 }
3061
3062
3063 inline static LRESULT
3064 REBAR_GetUnicodeFormat (REBAR_INFO *infoPtr)
3065 {
3066 TRACE("%s hwnd=%p\n",
3067 infoPtr->bUnicode ? "TRUE" : "FALSE", infoPtr->hwndSelf);
3068
3069 return infoPtr->bUnicode;
3070 }
3071
3072
3073 inline static LRESULT
3074 REBAR_GetVersion (REBAR_INFO *infoPtr)
3075 {
3076 TRACE("version %d\n", infoPtr->iVersion);
3077 return infoPtr->iVersion;
3078 }
3079
3080
3081 static LRESULT
3082 REBAR_HitTest (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3083 {
3084 LPRBHITTESTINFO lprbht = (LPRBHITTESTINFO)lParam;
3085
3086 if (!lprbht)
3087 return -1;
3088
3089 REBAR_InternalHitTest (infoPtr, &lprbht->pt, &lprbht->flags, &lprbht->iBand);
3090
3091 return lprbht->iBand;
3092 }
3093
3094
3095 static LRESULT
3096 REBAR_IdToIndex (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3097 {
3098 UINT i;
3099
3100 if (infoPtr == NULL)
3101 return -1;
3102
3103 if (infoPtr->uNumBands < 1)
3104 return -1;
3105
3106 for (i = 0; i < infoPtr->uNumBands; i++) {
3107 if (infoPtr->bands[i].wID == (UINT)wParam) {
3108 TRACE("id %u is band %u found!\n", (UINT)wParam, i);
3109 return i;
3110 }
3111 }
3112
3113 TRACE("id %u is not found\n", (UINT)wParam);
3114 return -1;
3115 }
3116
3117
3118 static LRESULT
3119 REBAR_InsertBandA (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3120 {
3121 LPREBARBANDINFOA lprbbi = (LPREBARBANDINFOA)lParam;
3122 UINT uIndex = (UINT)wParam;
3123 REBAR_BAND *lpBand;
3124
3125 if (infoPtr == NULL)
3126 return FALSE;
3127 if (lprbbi == NULL)
3128 return FALSE;
3129 if (lprbbi->cbSize < REBARBANDINFOA_V3_SIZE)
3130 return FALSE;
3131
3132 /* trace the index as signed to see the -1 */
3133 TRACE("insert band at %d!\n", (INT)uIndex);
3134 REBAR_DumpBandInfo (lprbbi);
3135
3136 if (infoPtr->uNumBands == 0) {
3137 infoPtr->bands = (REBAR_BAND *)Alloc (sizeof (REBAR_BAND));
3138 uIndex = 0;
3139 }
3140 else {
3141 REBAR_BAND *oldBands = infoPtr->bands;
3142 infoPtr->bands =
3143 (REBAR_BAND *)Alloc ((infoPtr->uNumBands+1)*sizeof(REBAR_BAND));
3144 if (((INT)uIndex == -1) || (uIndex > infoPtr->uNumBands))
3145 uIndex = infoPtr->uNumBands;
3146
3147 /* pre insert copy */
3148 if (uIndex > 0) {
3149 memcpy (&infoPtr->bands[0], &oldBands[0],
3150 uIndex * sizeof(REBAR_BAND));
3151 }
3152
3153 /* post copy */
3154 if (uIndex < infoPtr->uNumBands) {
3155 memcpy (&infoPtr->bands[uIndex+1], &oldBands[uIndex],
3156 (infoPtr->uNumBands - uIndex) * sizeof(REBAR_BAND));
3157 }
3158
3159 Free (oldBands);
3160 }
3161
3162 infoPtr->uNumBands++;
3163
3164 TRACE("index %u!\n", uIndex);
3165
3166 /* initialize band (infoPtr->bands[uIndex])*/
3167 lpBand = &infoPtr->bands[uIndex];
3168 lpBand->fMask = 0;
3169 lpBand->fStatus = 0;
3170 lpBand->clrFore = infoPtr->clrText;
3171 lpBand->clrBack = infoPtr->clrBk;
3172 lpBand->hwndChild = 0;
3173 lpBand->hwndPrevParent = 0;
3174
3175 REBAR_CommonSetupBand (infoPtr->hwndSelf, lprbbi, lpBand);
3176 lpBand->lpText = NULL;
3177 if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) {
3178 INT len = MultiByteToWideChar( CP_ACP, 0, lprbbi->lpText, -1, NULL, 0 );
3179 if (len > 1) {
3180 lpBand->lpText = (LPWSTR)Alloc (len*sizeof(WCHAR));
3181 MultiByteToWideChar( CP_ACP, 0, lprbbi->lpText, -1, lpBand->lpText, len );
3182 }
3183 }
3184
3185 REBAR_ValidateBand (infoPtr, lpBand);
3186 /* On insert of second band, revalidate band 1 to possible add gripper */
3187 if (infoPtr->uNumBands == 2)
3188 REBAR_ValidateBand (infoPtr, &infoPtr->bands[0]);
3189
3190 REBAR_DumpBand (infoPtr);
3191
3192 REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
3193 InvalidateRect(infoPtr->hwndSelf, 0, 1);
3194
3195 return TRUE;
3196 }
3197
3198
3199 static LRESULT
3200 REBAR_InsertBandW (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3201 {
3202 LPREBARBANDINFOW lprbbi = (LPREBARBANDINFOW)lParam;
3203 UINT uIndex = (UINT)wParam;
3204 REBAR_BAND *lpBand;
3205
3206 if (infoPtr == NULL)
3207 return FALSE;
3208 if (lprbbi == NULL)
3209 return FALSE;
3210 if (lprbbi->cbSize < REBARBANDINFOW_V3_SIZE)
3211 return FALSE;
3212
3213 /* trace the index as signed to see the -1 */
3214 TRACE("insert band at %d!\n", (INT)uIndex);
3215 REBAR_DumpBandInfo ((LPREBARBANDINFOA)lprbbi);
3216
3217 if (infoPtr->uNumBands == 0) {
3218 infoPtr->bands = (REBAR_BAND *)Alloc (sizeof (REBAR_BAND));
3219 uIndex = 0;
3220 }
3221 else {
3222 REBAR_BAND *oldBands = infoPtr->bands;
3223 infoPtr->bands =
3224 (REBAR_BAND *)Alloc ((infoPtr->uNumBands+1)*sizeof(REBAR_BAND));
3225 if (((INT)uIndex == -1) || (uIndex > infoPtr->uNumBands))
3226 uIndex = infoPtr->uNumBands;
3227
3228 /* pre insert copy */
3229 if (uIndex > 0) {
3230 memcpy (&infoPtr->bands[0], &oldBands[0],
3231 uIndex * sizeof(REBAR_BAND));
3232 }
3233
3234 /* post copy */
3235 if (uIndex <= infoPtr->uNumBands - 1) {
3236 memcpy (&infoPtr->bands[uIndex+1], &oldBands[uIndex],
3237 (infoPtr->uNumBands - uIndex) * sizeof(REBAR_BAND));
3238 }
3239
3240 Free (oldBands);
3241 }
3242
3243 infoPtr->uNumBands++;
3244
3245 TRACE("index %u!\n", uIndex);
3246
3247 /* initialize band (infoPtr->bands[uIndex])*/
3248 lpBand = &infoPtr->bands[uIndex];
3249 lpBand->fMask = 0;
3250 lpBand->fStatus = 0;
3251 lpBand->clrFore = infoPtr->clrText;
3252 lpBand->clrBack = infoPtr->clrBk;
3253 lpBand->hwndChild = 0;
3254 lpBand->hwndPrevParent = 0;
3255
3256 REBAR_CommonSetupBand (infoPtr->hwndSelf, (LPREBARBANDINFOA)lprbbi, lpBand);
3257 lpBand->lpText = NULL;
3258 if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) {
3259 INT len = lstrlenW (lprbbi->lpText);
3260 if (len > 0) {
3261 lpBand->lpText = (LPWSTR)Alloc ((len + 1)*sizeof(WCHAR));
3262 strcpyW (lpBand->lpText, lprbbi->lpText);
3263 }
3264 }
3265
3266 REBAR_ValidateBand (infoPtr, lpBand);
3267 /* On insert of second band, revalidate band 1 to possible add gripper */
3268 if (infoPtr->uNumBands == 2)
3269 REBAR_ValidateBand (infoPtr, &infoPtr->bands[uIndex ? 0 : 1]);
3270
3271 REBAR_DumpBand (infoPtr);
3272
3273 REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
3274 InvalidateRect(infoPtr->hwndSelf, 0, 1);
3275
3276 return TRUE;
3277 }
3278
3279
3280 static LRESULT
3281 REBAR_MaximizeBand (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3282 {
3283 REBAR_BAND *lpBand;
3284 UINT uBand = (UINT) wParam;
3285
3286 /* Validate */
3287 if ((infoPtr->uNumBands == 0) ||
3288 ((INT)uBand < 0) || (uBand >= infoPtr->uNumBands)) {
3289 /* error !!! */
3290 ERR("Illegal MaximizeBand, requested=%d, current band count=%d\n",
3291 (INT)uBand, infoPtr->uNumBands);
3292 return FALSE;
3293 }
3294
3295 lpBand = &infoPtr->bands[uBand];
3296
3297 if (lParam && (lpBand->fMask & RBBIM_IDEALSIZE)) {
3298 /* handle setting ideal size */
3299 lpBand->ccx = lpBand->cxIdeal;
3300 }
3301 else {
3302 /* handle setting to max */
3303 FIXME("(uBand = %u fIdeal = %s) case not coded\n",
3304 (UINT)wParam, lParam ? "TRUE" : "FALSE");
3305 return FALSE;
3306 }
3307
3308 infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
3309 REBAR_Layout (infoPtr, 0, TRUE, TRUE);
3310 InvalidateRect (infoPtr->hwndSelf, 0, TRUE);
3311
3312 return TRUE;
3313
3314 }
3315
3316
3317 static LRESULT
3318 REBAR_MinimizeBand (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3319 {
3320 REBAR_BAND *band, *lpBand;
3321 UINT uBand = (UINT) wParam;
3322 RECT newrect;
3323 INT imindBand, imaxdBand, iprevBand, startBand, endBand;
3324 INT movement, i;
3325
3326 /* A "minimize" band is equivalent to "dragging" the gripper
3327 * of than band to the right till the band is only the size
3328 * of the cxHeader.
3329 */
3330
3331 /* Validate */
3332 if ((infoPtr->uNumBands == 0) ||
3333 ((INT)uBand < 0) || (uBand >= infoPtr->uNumBands)) {
3334 /* error !!! */
3335 ERR("Illegal MinimizeBand, requested=%d, current band count=%d\n",
3336 (INT)uBand, infoPtr->uNumBands);
3337 return FALSE;
3338 }
3339
3340 /* compute amount of movement and validate */
3341 lpBand = &infoPtr->bands[uBand];
3342
3343 if (infoPtr->dwStyle & CCS_VERT)
3344 movement = lpBand->rcBand.bottom - lpBand->rcBand.top -
3345 lpBand->cxHeader;
3346 else
3347 movement = lpBand->rcBand.right - lpBand->rcBand.left -
3348 lpBand->cxHeader;
3349 if (movement < 0) {
3350 ERR("something is wrong, band=(%ld,%ld)-(%ld,%ld), cxheader=%d\n",
3351 lpBand->rcBand.left, lpBand->rcBand.top,
3352 lpBand->rcBand.right, lpBand->rcBand.bottom,
3353 lpBand->cxHeader);
3354 return FALSE;
3355 }
3356
3357 imindBand = -1;
3358 imaxdBand = -1;
3359 iprevBand = -1; /* to suppress warning message */
3360
3361 /* find the first band in row of the one whose is being minimized */
3362 for (i=0; i<infoPtr->uNumBands; i++) {
3363 band = &infoPtr->bands[i];
3364 if (HIDDENBAND(band)) continue;
3365 if (band->iRow == lpBand->iRow) {
3366 imaxdBand = i;
3367 if (imindBand == -1) imindBand = i;
3368 }
3369 }
3370
3371 /* if the selected band is first in row then need to expand */
3372 /* next visible band */
3373 if (imindBand == uBand) {
3374 band = NULL;
3375 movement = -movement;
3376 /* find the first visible band to the right of the selected band */
3377 for (i=uBand+1; i<=imaxdBand; i++) {
3378 band = &infoPtr->bands[i];
3379 if (!HIDDENBAND(band)) {
3380 iprevBand = i;
3381 LEADJ(band, movement);
3382 band->ccx = rcBw(band);
3383 break;
3384 }
3385 }
3386 /* what case is this */
3387 if (iprevBand == -1) {
3388 ERR("no previous visible band\n");
3389 return FALSE;
3390 }
3391 startBand = uBand;
3392 endBand = iprevBand;
3393 SetRect (&newrect,
3394 lpBand->rcBand.left,
3395 lpBand->rcBand.top,
3396 band->rcBand.right,
3397 band->rcBand.bottom);
3398 }
3399 /* otherwise expand previous visible band */
3400 else {
3401 band = NULL;
3402 /* find the first visible band to the left of the selected band */
3403 for (i=uBand-1; i>=imindBand; i--) {
3404 band = &infoPtr->bands[i];
3405 if (!HIDDENBAND(band)) {
3406 iprevBand = i;
3407 READJ(band, movement);
3408 band->ccx = rcBw(band);
3409 break;
3410 }
3411 }
3412 /* what case is this */
3413 if (iprevBand == -1) {
3414 ERR("no previous visible band\n");
3415 return FALSE;
3416 }
3417 startBand = iprevBand;
3418 endBand = uBand;
3419 SetRect (&newrect,
3420 band->rcBand.left,
3421 band->rcBand.top,
3422 lpBand->rcBand.right,
3423 lpBand->rcBand.bottom);
3424 }
3425
3426 REBAR_Shrink (infoPtr, lpBand, movement, uBand);
3427
3428 /* recompute all rectangles */
3429 if (infoPtr->dwStyle & CCS_VERT) {
3430 REBAR_CalcVertBand (infoPtr, startBand, endBand+1,
3431 FALSE);
3432 }
3433 else {
3434 REBAR_CalcHorzBand (infoPtr, startBand, endBand+1,
3435 FALSE);
3436 }
3437
3438 TRACE("bands after minimize, see band # %d, %d\n",
3439 startBand, endBand);
3440 REBAR_DumpBand (infoPtr);
3441
3442 REBAR_MoveChildWindows (infoPtr, startBand, endBand+1);
3443
3444 InvalidateRect (infoPtr->hwndSelf, &newrect, TRUE);
3445 UpdateWindow (infoPtr->hwndSelf);
3446 return FALSE;
3447 }
3448
3449
3450 static LRESULT
3451 REBAR_MoveBand (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3452 {
3453 REBAR_BAND *oldBands = infoPtr->bands;
3454 REBAR_BAND holder;
3455 UINT uFrom = (UINT)wParam;
3456 UINT uTo = (UINT)lParam;
3457
3458 /* Validate */
3459 if ((infoPtr->uNumBands == 0) ||
3460 ((INT)uFrom < 0) || (uFrom >= infoPtr->uNumBands) ||
3461 ((INT)uTo < 0) || (uTo >= infoPtr->uNumBands)) {
3462 /* error !!! */
3463 ERR("Illegal MoveBand, from=%d, to=%d, current band count=%d\n",
3464 (INT)uFrom, (INT)uTo, infoPtr->uNumBands);
3465 return FALSE;
3466 }
3467
3468 /* save one to be moved */
3469 memcpy (&holder, &oldBands[uFrom], sizeof(REBAR_BAND));
3470
3471 /* close up rest of bands (pseudo delete) */
3472 if (uFrom < infoPtr->uNumBands - 1) {
3473 memcpy (&oldBands[uFrom], &oldBands[uFrom+1],
3474 (infoPtr->uNumBands - uFrom - 1) * sizeof(REBAR_BAND));
3475 }
3476
3477 /* allocate new space and copy rest of bands into it */
3478 infoPtr->bands =
3479 (REBAR_BAND *)Alloc ((infoPtr->uNumBands)*sizeof(REBAR_BAND));
3480
3481 /* pre insert copy */
3482 if (uTo > 0) {
3483 memcpy (&infoPtr->bands[0], &oldBands[0],
3484 uTo * sizeof(REBAR_BAND));
3485 }
3486
3487 /* set moved band */
3488 memcpy (&infoPtr->bands[uTo], &holder, sizeof(REBAR_BAND));
3489
3490 /* post copy */
3491 if (uTo < infoPtr->uNumBands - 1) {
3492 memcpy (&infoPtr->bands[uTo+1], &oldBands[uTo],
3493 (infoPtr->uNumBands - uTo - 1) * sizeof(REBAR_BAND));
3494 }
3495
3496 Free (oldBands);
3497
3498 TRACE("moved band %d to index %d\n", uFrom, uTo);
3499 REBAR_DumpBand (infoPtr);
3500
3501 infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
3502 /* **************************************************** */
3503 /* */
3504 /* We do not do a REBAR_Layout here because the native */
3505 /* control does not do that. The actual layout and */
3506 /* repaint is done by the *next* real action, ex.: */
3507 /* RB_INSERTBAND, RB_DELETEBAND, RB_SIZETORECT, etc. */
3508 /* */
3509 /* **************************************************** */
3510
3511 return TRUE;
3512 }
3513
3514
3515 /* return TRUE if two strings are different */
3516 static BOOL
3517 REBAR_strdifW( LPCWSTR a, LPCWSTR b )
3518 {
3519 return ( (a && !b) || (b && !a) || (a && b && lstrcmpW(a, b) ) );
3520 }
3521
3522 static LRESULT
3523 REBAR_SetBandInfoA (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3524 {
3525 LPREBARBANDINFOA lprbbi = (LPREBARBANDINFOA)lParam;
3526 REBAR_BAND *lpBand;
3527 BOOL bChanged;
3528
3529 if (lprbbi == NULL)
3530 return FALSE;
3531 if (lprbbi->cbSize < REBARBANDINFOA_V3_SIZE)
3532 return FALSE;
3533 if ((UINT)wParam >= infoPtr->uNumBands)
3534 return FALSE;
3535
3536 TRACE("index %u\n", (UINT)wParam);
3537 REBAR_DumpBandInfo (lprbbi);
3538
3539 /* set band information */
3540 lpBand = &infoPtr->bands[(UINT)wParam];
3541
3542 bChanged = REBAR_CommonSetupBand (infoPtr->hwndSelf, lprbbi, lpBand);
3543 if (lprbbi->fMask & RBBIM_TEXT) {
3544 LPWSTR wstr = NULL;
3545
3546 if (lprbbi->lpText)
3547 {
3548 INT len;
3549 len = MultiByteToWideChar( CP_ACP, 0, lprbbi->lpText, -1, NULL, 0 );
3550 if (len > 1)
3551 wstr = (LPWSTR)Alloc (len*sizeof(WCHAR));
3552 if (wstr)
3553 MultiByteToWideChar( CP_ACP, 0, lprbbi->lpText, -1, wstr, len );
3554 }
3555 if (REBAR_strdifW(lpBand->lpText, wstr)) {
3556 if (lpBand->lpText) {
3557 Free (lpBand->lpText);
3558 lpBand->lpText = NULL;
3559 }
3560 if (wstr) {
3561 lpBand->lpText = wstr;
3562 wstr = NULL;
3563 }
3564 bChanged = TRUE;
3565 }
3566 if (wstr)
3567 Free (wstr);
3568 }
3569
3570 REBAR_ValidateBand (infoPtr, lpBand);
3571
3572 REBAR_DumpBand (infoPtr);
3573
3574 if (bChanged && (lprbbi->fMask & (RBBIM_CHILDSIZE | RBBIM_SIZE))) {
3575 REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
3576 InvalidateRect(infoPtr->hwndSelf, 0, 1);
3577 }
3578
3579 return TRUE;
3580 }
3581
3582 static LRESULT
3583 REBAR_SetBandInfoW (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3584 {
3585 LPREBARBANDINFOW lprbbi = (LPREBARBANDINFOW)lParam;
3586 REBAR_BAND *lpBand;
3587 BOOL bChanged;
3588
3589 if (lprbbi == NULL)
3590 return FALSE;
3591 if (lprbbi->cbSize < REBARBANDINFOW_V3_SIZE)
3592 return FALSE;
3593 if ((UINT)wParam >= infoPtr->uNumBands)
3594 return FALSE;
3595
3596 TRACE("index %u\n", (UINT)wParam);
3597 REBAR_DumpBandInfo ((LPREBARBANDINFOA)lprbbi);
3598
3599 /* set band information */
3600 lpBand = &infoPtr->bands[(UINT)wParam];
3601
3602 bChanged = REBAR_CommonSetupBand (infoPtr->hwndSelf, (LPREBARBANDINFOA)lprbbi, lpBand);
3603 if( (lprbbi->fMask & RBBIM_TEXT) &&
3604 REBAR_strdifW( lpBand->lpText, lprbbi->lpText ) ) {
3605 if (lpBand->lpText) {
3606 Free (lpBand->lpText);
3607 lpBand->lpText = NULL;
3608 }
3609 if (lprbbi->lpText) {
3610 INT len = lstrlenW (lprbbi->lpText);
3611 if (len > 0)
3612 {
3613 lpBand->lpText = (LPWSTR)Alloc ((len + 1)*sizeof(WCHAR));
3614 strcpyW (lpBand->lpText, lprbbi->lpText);
3615 }
3616 }
3617 bChanged = TRUE;
3618 }
3619
3620 REBAR_ValidateBand (infoPtr, lpBand);
3621
3622 REBAR_DumpBand (infoPtr);
3623
3624 if ( bChanged && (lprbbi->fMask & (RBBIM_CHILDSIZE | RBBIM_SIZE)) ) {
3625 REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
3626 InvalidateRect(infoPtr->hwndSelf, 0, 1);
3627 }
3628
3629 return TRUE;
3630 }
3631
3632
3633 static LRESULT
3634 REBAR_SetBarInfo (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3635 {
3636 LPREBARINFO lpInfo = (LPREBARINFO)lParam;
3637 REBAR_BAND *lpBand;
3638 UINT i;
3639
3640 if (lpInfo == NULL)
3641 return FALSE;
3642
3643 if (lpInfo->cbSize < sizeof (REBARINFO))
3644 return FALSE;
3645
3646 TRACE("setting bar info!\n");
3647
3648 if (lpInfo->fMask & RBIM_IMAGELIST) {
3649 infoPtr->himl = lpInfo->himl;
3650 if (infoPtr->himl) {
3651 INT cx, cy;
3652 ImageList_GetIconSize (infoPtr->himl, &cx, &cy);
3653 infoPtr->imageSize.cx = cx;
3654 infoPtr->imageSize.cy = cy;
3655 }
3656 else {
3657 infoPtr->imageSize.cx = 0;
3658 infoPtr->imageSize.cy = 0;
3659 }
3660 TRACE("new image cx=%ld, cy=%ld\n", infoPtr->imageSize.cx,
3661 infoPtr->imageSize.cy);
3662 }
3663
3664 /* revalidate all bands to reset flags for images in headers of bands */
3665 for (i=0; i<infoPtr->uNumBands; i++) {
3666 lpBand = &infoPtr->bands[i];
3667 REBAR_ValidateBand (infoPtr, lpBand);
3668 }
3669
3670 return TRUE;
3671 }
3672
3673
3674 static LRESULT
3675 REBAR_SetBkColor (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3676 {
3677 COLORREF clrTemp;
3678
3679 clrTemp = infoPtr->clrBk;
3680 infoPtr->clrBk = (COLORREF)lParam;
3681
3682 TRACE("background color 0x%06lx!\n", infoPtr->clrBk);
3683
3684 return clrTemp;
3685 }
3686
3687
3688 /* << REBAR_SetColorScheme >> */
3689 /* << REBAR_SetPalette >> */
3690
3691
3692 static LRESULT
3693 REBAR_SetParent (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3694 {
3695 HWND hwndTemp = infoPtr->hwndNotify;
3696
3697 infoPtr->hwndNotify = (HWND)wParam;
3698
3699 return (LRESULT)hwndTemp;
3700 }
3701
3702
3703 static LRESULT
3704 REBAR_SetTextColor (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3705 {
3706 COLORREF clrTemp;
3707
3708 clrTemp = infoPtr->clrText;
3709 infoPtr->clrText = (COLORREF)lParam;
3710
3711 TRACE("text color 0x%06lx!\n", infoPtr->clrText);
3712
3713 return clrTemp;
3714 }
3715
3716
3717 /* << REBAR_SetTooltips >> */
3718
3719
3720 inline static LRESULT
3721 REBAR_SetUnicodeFormat (REBAR_INFO *infoPtr, WPARAM wParam)
3722 {
3723 BOOL bTemp = infoPtr->bUnicode;
3724
3725 TRACE("to %s hwnd=%p, was %s\n",
3726 ((BOOL)wParam) ? "TRUE" : "FALSE", infoPtr->hwndSelf,
3727 (bTemp) ? "TRUE" : "FALSE");
3728
3729 infoPtr->bUnicode = (BOOL)wParam;
3730
3731 return bTemp;
3732 }
3733
3734
3735 static LRESULT
3736 REBAR_SetVersion (REBAR_INFO *infoPtr, INT iVersion)
3737 {
3738 INT iOldVersion = infoPtr->iVersion;
3739
3740 if (iVersion > COMCTL32_VERSION)
3741 return -1;
3742
3743 infoPtr->iVersion = iVersion;
3744
3745 TRACE("new version %d\n", iVersion);
3746
3747 return iOldVersion;
3748 }
3749
3750
3751 static LRESULT
3752 REBAR_ShowBand (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3753 {
3754 REBAR_BAND *lpBand;
3755
3756 if (((INT)wParam < 0) || ((INT)wParam > infoPtr->uNumBands))
3757 return FALSE;
3758
3759 lpBand = &infoPtr->bands[(INT)wParam];
3760
3761 if ((BOOL)lParam) {
3762 TRACE("show band %d\n", (INT)wParam);
3763 lpBand->fStyle = lpBand->fStyle & ~RBBS_HIDDEN;
3764 if (IsWindow (lpBand->hwndChild))
3765 ShowWindow (lpBand->hwndChild, SW_SHOW);
3766 }
3767 else {
3768 TRACE("hide band %d\n", (INT)wParam);
3769 lpBand->fStyle = lpBand->fStyle | RBBS_HIDDEN;
3770 if (IsWindow (lpBand->hwndChild))
3771 ShowWindow (lpBand->hwndChild, SW_HIDE);
3772 }
3773
3774 infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
3775 REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
3776 InvalidateRect(infoPtr->hwndSelf, 0, 1);
3777
3778 return TRUE;
3779 }
3780
3781
3782 static LRESULT
3783 REBAR_SizeToRect (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3784 {
3785 LPRECT lpRect = (LPRECT)lParam;
3786 RECT t1;
3787
3788 if (lpRect == NULL)
3789 return FALSE;
3790
3791 TRACE("[%ld %ld %ld %ld]\n",
3792 lpRect->left, lpRect->top, lpRect->right, lpRect->bottom);
3793
3794 /* what is going on???? */
3795 GetWindowRect(infoPtr->hwndSelf, &t1);
3796 TRACE("window rect [%ld %ld %ld %ld]\n",
3797 t1.left, t1.top, t1.right, t1.bottom);
3798 GetClientRect(infoPtr->hwndSelf, &t1);
3799 TRACE("client rect [%ld %ld %ld %ld]\n",
3800 t1.left, t1.top, t1.right, t1.bottom);
3801
3802 /* force full _Layout processing */
3803 TRACE("setting NEEDS_LAYOUT\n");
3804 infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
3805 REBAR_Layout (infoPtr, lpRect, TRUE, FALSE);
3806 InvalidateRect (infoPtr->hwndSelf, NULL, TRUE);
3807 return TRUE;
3808 }
3809
3810
3811
3812 static LRESULT
3813 REBAR_Create (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3814 {
3815 LPCREATESTRUCTW cs = (LPCREATESTRUCTW) lParam;
3816 RECT wnrc1, clrc1;
3817 HTHEME theme;
3818
3819 if (TRACE_ON(rebar)) {
3820 GetWindowRect(infoPtr->hwndSelf, &wnrc1);
3821 GetClientRect(infoPtr->hwndSelf, &clrc1);
3822 TRACE("window=(%ld,%ld)-(%ld,%ld) client=(%ld,%ld)-(%ld,%ld) cs=(%d,%d %dx%d)\n",
3823 wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom,
3824 clrc1.left, clrc1.top, clrc1.right, clrc1.bottom,
3825 cs->x, cs->y, cs->cx, cs->cy);
3826 }
3827
3828 TRACE("created!\n");
3829
3830 if ((theme = OpenThemeData (infoPtr->hwndSelf, themeClass)))
3831 {
3832 /* native seems to clear WS_BORDER when themed */
3833 infoPtr->dwStyle &= ~WS_BORDER;
3834 }
3835
3836 return 0;
3837 }
3838
3839
3840 static LRESULT
3841 REBAR_Destroy (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3842 {
3843 REBAR_BAND *lpBand;
3844 UINT i;
3845
3846
3847 /* free rebar bands */
3848 if ((infoPtr->uNumBands > 0) && infoPtr->bands) {
3849 /* clean up each band */
3850 for (i = 0; i < infoPtr->uNumBands; i++) {
3851 lpBand = &infoPtr->bands[i];
3852
3853 /* delete text strings */
3854 if (lpBand->lpText) {
3855 Free (lpBand->lpText);
3856 lpBand->lpText = NULL;
3857 }
3858 /* destroy child window */
3859 DestroyWindow (lpBand->hwndChild);
3860 }
3861
3862 /* free band array */
3863 Free (infoPtr->bands);
3864 infoPtr->bands = NULL;
3865 }
3866
3867 DestroyCursor (infoPtr->hcurArrow);
3868 DestroyCursor (infoPtr->hcurHorz);
3869 DestroyCursor (infoPtr->hcurVert);
3870 DestroyCursor (infoPtr->hcurDrag);
3871 if(infoPtr->hDefaultFont) DeleteObject (infoPtr->hDefaultFont);
3872 SetWindowLongPtrW (infoPtr->hwndSelf, 0, 0);
3873
3874 CloseThemeData (GetWindowTheme (infoPtr->hwndSelf));
3875
3876 /* free rebar info data */
3877 Free (infoPtr);
3878 TRACE("destroyed!\n");
3879 return 0;
3880 }
3881
3882
3883 static LRESULT
3884 REBAR_EraseBkGnd (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3885 {
3886 RECT cliprect;
3887
3888 if (GetClipBox ( (HDC)wParam, &cliprect))
3889 return REBAR_InternalEraseBkGnd (infoPtr, wParam, lParam, &cliprect);
3890 return 0;
3891 }
3892
3893
3894 static LRESULT
3895 REBAR_GetFont (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3896 {
3897 return (LRESULT)infoPtr->hFont;
3898 }
3899
3900 static LRESULT
3901 REBAR_PushChevron(REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3902 {
3903 if (wParam >= 0 && (UINT)wParam < infoPtr->uNumBands)
3904 {
3905 NMREBARCHEVRON nmrbc;
3906 REBAR_BAND *lpBand = &infoPtr->bands[wParam];
3907
3908 TRACE("Pressed chevron on band %d\n", wParam);
3909
3910 /* redraw chevron in pushed state */
3911 lpBand->fDraw |= DRAW_CHEVRONPUSHED;
3912 RedrawWindow(infoPtr->hwndSelf, &lpBand->rcChevron,0,
3913 RDW_ERASE|RDW_INVALIDATE|RDW_UPDATENOW);
3914
3915 /* notify app so it can display a popup menu or whatever */
3916 nmrbc.uBand = wParam;
3917 nmrbc.wID = lpBand->wID;
3918 nmrbc.lParam = lpBand->lParam;
3919 nmrbc.rc = lpBand->rcChevron;
3920 nmrbc.lParamNM = lParam;
3921 REBAR_Notify((NMHDR*)&nmrbc, infoPtr, RBN_CHEVRONPUSHED);
3922
3923 /* redraw chevron in previous state */
3924 lpBand->fDraw &= ~DRAW_CHEVRONPUSHED;
3925 InvalidateRect(infoPtr->hwndSelf, &lpBand->rcChevron, TRUE);
3926
3927 return TRUE;
3928 }
3929 return FALSE;
3930 }
3931
3932 static LRESULT
3933 REBAR_LButtonDown (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3934 {
3935 REBAR_BAND *lpBand;
3936 UINT htFlags;
3937 INT iHitBand;
3938 POINT ptMouseDown;
3939 ptMouseDown.x = (INT)LOWORD(lParam);
3940 ptMouseDown.y = (INT)HIWORD(lParam);
3941
3942 REBAR_InternalHitTest(infoPtr, &ptMouseDown, &htFlags, &iHitBand);
3943 lpBand = &infoPtr->bands[iHitBand];
3944
3945 if (htFlags == RBHT_CHEVRON)
3946 {
3947 REBAR_PushChevron(infoPtr, iHitBand, 0);
3948 }
3949 else if (htFlags == RBHT_GRABBER || htFlags == RBHT_CAPTION)
3950 {
3951 TRACE("Starting drag\n");
3952
3953 SetCapture (infoPtr->hwndSelf);
3954 infoPtr->iGrabbedBand = iHitBand;
3955
3956 /* save off the LOWORD and HIWORD of lParam as initial x,y */
3957 infoPtr->dragStart.x = (short)LOWORD(lParam);
3958 infoPtr->dragStart.y = (short)HIWORD(lParam);
3959 infoPtr->dragNow = infoPtr->dragStart;
3960 if (infoPtr->dwStyle & CCS_VERT)
3961 infoPtr->ihitoffset = infoPtr->dragStart.y - (lpBand->rcBand.top+REBAR_PRE_GRIPPER);
3962 else
3963 infoPtr->ihitoffset = infoPtr->dragStart.x - (lpBand->rcBand.left+REBAR_PRE_GRIPPER);
3964 }
3965 return 0;
3966 }
3967
3968 static LRESULT
3969 REBAR_LButtonUp (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3970 {
3971 if (infoPtr->iGrabbedBand >= 0)
3972 {
3973 NMHDR layout;
3974 RECT rect;
3975
3976 infoPtr->dragStart.x = 0;
3977 infoPtr->dragStart.y = 0;
3978 infoPtr->dragNow = infoPtr->dragStart;
3979
3980 ReleaseCapture ();
3981
3982 if (infoPtr->fStatus & BEGIN_DRAG_ISSUED) {
3983 REBAR_Notify(&layout, infoPtr, RBN_LAYOUTCHANGED);
3984 REBAR_Notify_NMREBAR (infoPtr, infoPtr->iGrabbedBand, RBN_ENDDRAG);
3985 infoPtr->fStatus &= ~BEGIN_DRAG_ISSUED;
3986 }
3987
3988 infoPtr->iGrabbedBand = -1;
3989
3990 GetClientRect(infoPtr->hwndSelf, &rect);
3991 InvalidateRect(infoPtr->hwndSelf, NULL, TRUE);
3992 }
3993
3994 return 0;
3995 }
3996
3997 static LRESULT
3998 REBAR_MouseLeave (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3999 {
4000 if (infoPtr->ichevronhotBand >= 0)
4001 {
4002 REBAR_BAND *lpChevronBand = &infoPtr->bands[infoPtr->ichevronhotBand];
4003 if (lpChevronBand->fDraw & DRAW_CHEVRONHOT)
4004 {
4005 lpChevronBand->fDraw &= ~DRAW_CHEVRONHOT;
4006 InvalidateRect(infoPtr->hwndSelf, &lpChevronBand->rcChevron, TRUE);
4007 }
4008 }
4009 infoPtr->iOldBand = -1;
4010 infoPtr->ichevronhotBand = -2;
4011
4012 return TRUE;
4013 }
4014
4015 static LRESULT
4016 REBAR_MouseMove (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
4017 {
4018 REBAR_BAND *lpChevronBand;
4019 POINT ptMove;
4020
4021 ptMove.x = (short)LOWORD(lParam);
4022 ptMove.y = (short)HIWORD(lParam);
4023
4024 /* if we are currently dragging a band */
4025 if (infoPtr->iGrabbedBand >= 0)
4026 {
4027 REBAR_BAND *band1, *band2;
4028
4029 if (GetCapture() != infoPtr->hwndSelf)
4030 ERR("We are dragging but haven't got capture?!?\n");
4031
4032 band1 = &infoPtr->bands[infoPtr->iGrabbedBand-1];
4033 band2 = &infoPtr->bands[infoPtr->iGrabbedBand];
4034
4035 /* if mouse did not move much, exit */
4036 if ((abs(ptMove.x - infoPtr->dragNow.x) <= mindragx) &&
4037 (abs(ptMove.y - infoPtr->dragNow.y) <= mindragy)) return 0;
4038
4039 /* Test for valid drag case - must not be first band in row */
4040 if (infoPtr->dwStyle & CCS_VERT) {
4041 if ((ptMove.x < band2->rcBand.left) ||
4042 (ptMove.x > band2->rcBand.right) ||
4043 ((infoPtr->iGrabbedBand > 0) && (band1->iRow != band2->iRow))) {
4044 FIXME("Cannot drag to other rows yet!!\n");
4045 }
4046 else {
4047 REBAR_HandleLRDrag (infoPtr, &ptMove);
4048 }
4049 }
4050 else {
4051 if ((ptMove.y < band2->rcBand.top) ||
4052 (ptMove.y > band2->rcBand.bottom) ||
4053 ((infoPtr->iGrabbedBand > 0) && (band1->iRow != band2->iRow))) {
4054 FIXME("Cannot drag to other rows yet!!\n");
4055 }
4056 else {
4057 REBAR_HandleLRDrag (infoPtr, &ptMove);
4058 }
4059 }
4060 }
4061 else
4062 {
4063 INT iHitBand;
4064 UINT htFlags;
4065 TRACKMOUSEEVENT trackinfo;
4066
4067 REBAR_InternalHitTest(infoPtr, &ptMove, &htFlags, &iHitBand);
4068
4069 if (infoPtr->iOldBand >= 0 && infoPtr->iOldBand == infoPtr->ichevronhotBand)
4070 {
4071 lpChevronBand = &infoPtr->bands[infoPtr->ichevronhotBand];
4072 if (lpChevronBand->fDraw & DRAW_CHEVRONHOT)
4073 {
4074 lpChevronBand->fDraw &= ~DRAW_CHEVRONHOT;
4075 InvalidateRect(infoPtr->hwndSelf, &lpChevronBand->rcChevron, TRUE);
4076 }
4077 infoPtr->ichevronhotBand = -2;
4078 }
4079
4080 if (htFlags == RBHT_CHEVRON)
4081 {
4082 /* fill in the TRACKMOUSEEVENT struct */
4083 trackinfo.cbSize = sizeof(TRACKMOUSEEVENT);
4084 trackinfo.dwFlags = TME_QUERY;
4085 trackinfo.hwndTrack = infoPtr->hwndSelf;
4086 trackinfo.dwHoverTime = 0;
4087
4088 /* call _TrackMouseEvent to see if we are currently tracking for this hwnd */
4089 _TrackMouseEvent(&trackinfo);
4090
4091 /* Make sure tracking is enabled so we receive a WM_MOUSELEAVE message */
4092 if(!(trackinfo.dwFlags & TME_LEAVE))
4093 {
4094 trackinfo.dwFlags = TME_LEAVE; /* notify upon leaving */
4095
4096 /* call TRACKMOUSEEVENT so we receive a WM_MOUSELEAVE message */
4097 /* and can properly deactivate the hot chevron */
4098 _TrackMouseEvent(&trackinfo);
4099 }
4100
4101 lpChevronBand = &infoPtr->bands[iHitBand];
4102 if (!(lpChevronBand->fDraw & DRAW_CHEVRONHOT))
4103 {
4104 lpChevronBand->fDraw |= DRAW_CHEVRONHOT;
4105 InvalidateRect(infoPtr->hwndSelf, &lpChevronBand->rcChevron, TRUE);
4106 infoPtr->ichevronhotBand = iHitBand;
4107 }
4108 }
4109 infoPtr->iOldBand = iHitBand;
4110 }
4111
4112 return 0;
4113 }
4114
4115
4116 inline static LRESULT
4117 REBAR_NCCalcSize (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
4118 {
4119 HTHEME theme;
4120 if (infoPtr->dwStyle & WS_BORDER) {
4121 InflateRect((LPRECT)lParam, -GetSystemMetrics(SM_CXEDGE),
4122 -GetSystemMetrics(SM_CYEDGE));
4123 }
4124 else if ((theme = GetWindowTheme (infoPtr->hwndSelf)))
4125 {
4126 ((LPRECT)lParam)->top++;
4127 }
4128 TRACE("new client=(%ld,%ld)-(%ld,%ld)\n",
4129 ((LPRECT)lParam)->left, ((LPRECT)lParam)->top,
4130 ((LPRECT)lParam)->right, ((LPRECT)lParam)->bottom);
4131 return 0;
4132 }
4133
4134
4135 static LRESULT
4136 REBAR_NCCreate (HWND hwnd, WPARAM wParam, LPARAM lParam)
4137 {
4138 LPCREATESTRUCTW cs = (LPCREATESTRUCTW) lParam;
4139 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
4140 RECT wnrc1, clrc1;
4141 NONCLIENTMETRICSW ncm;
4142 HFONT tfont;
4143 INT i;
4144
4145 if (infoPtr != NULL) {
4146 ERR("Strange info structure pointer *not* NULL\n");
4147 return FALSE;
4148 }
4149
4150 if (TRACE_ON(rebar)) {
4151 GetWindowRect(hwnd, &wnrc1);
4152 GetClientRect(hwnd, &clrc1);
4153 TRACE("window=(%ld,%ld)-(%ld,%ld) client=(%ld,%ld)-(%ld,%ld) cs=(%d,%d %dx%d)\n",
4154 wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom,
4155 clrc1.left, clrc1.top, clrc1.right, clrc1.bottom,
4156 cs->x, cs->y, cs->cx, cs->cy);
4157 }
4158
4159 /* allocate memory for info structure */
4160 infoPtr = (REBAR_INFO *)Alloc (sizeof(REBAR_INFO));
4161 SetWindowLongPtrW (hwnd, 0, (DWORD_PTR)infoPtr);
4162
4163 /* initialize info structure - initial values are 0 */
4164 infoPtr->clrBk = CLR_NONE;
4165 infoPtr->clrText = CLR_NONE;
4166 infoPtr->clrBtnText = GetSysColor (COLOR_BTNTEXT);
4167 infoPtr->clrBtnFace = GetSysColor (COLOR_BTNFACE);
4168 infoPtr->iOldBand = -1;
4169 infoPtr->ichevronhotBand = -2;
4170 infoPtr->iGrabbedBand = -1;
4171 infoPtr->hwndSelf = hwnd;
4172 infoPtr->DoRedraw = TRUE;
4173 infoPtr->hcurArrow = LoadCursorW (0, (LPWSTR)IDC_ARROW);
4174 infoPtr->hcurHorz = LoadCursorW (0, (LPWSTR)IDC_SIZEWE);
4175 infoPtr->hcurVert = LoadCursorW (0, (LPWSTR)IDC_SIZENS);
4176 infoPtr->hcurDrag = LoadCursorW (0, (LPWSTR)IDC_SIZE);
4177 infoPtr->bUnicode = IsWindowUnicode (hwnd);
4178 infoPtr->fStatus = CREATE_RUNNING;
4179 infoPtr->hFont = GetStockObject (SYSTEM_FONT);
4180
4181 /* issue WM_NOTIFYFORMAT to get unicode status of parent */
4182 i = SendMessageW(REBAR_GetNotifyParent (infoPtr),
4183 WM_NOTIFYFORMAT, (WPARAM)hwnd, NF_QUERY);
4184 if ((i < NFR_ANSI) || (i > NFR_UNICODE)) {
4185 ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n", i);
4186 i = NFR_ANSI;
4187 }
4188 infoPtr->NtfUnicode = (i == NFR_UNICODE) ? 1 : 0;
4189
4190 /* Stow away the original style */
4191 infoPtr->orgStyle = cs->style;
4192 /* add necessary styles to the requested styles */
4193 infoPtr->dwStyle = cs->style | WS_VISIBLE | CCS_TOP;
4194 SetWindowLongW (hwnd, GWL_STYLE, infoPtr->dwStyle);
4195
4196 /* get font handle for Caption Font */
4197 ncm.cbSize = sizeof(ncm);
4198 SystemParametersInfoW (SPI_GETNONCLIENTMETRICS, ncm.cbSize, &ncm, 0);
4199 /* if the font is bold, set to normal */
4200 if (ncm.lfCaptionFont.lfWeight > FW_NORMAL) {
4201 ncm.lfCaptionFont.lfWeight = FW_NORMAL;
4202 }
4203 tfont = CreateFontIndirectW (&ncm.lfCaptionFont);
4204 if (tfont) {
4205 infoPtr->hFont = infoPtr->hDefaultFont = tfont;
4206 }
4207
4208 /* native does:
4209 GetSysColor (numerous);
4210 GetSysColorBrush (numerous) (see WM_SYSCOLORCHANGE);
4211 *GetStockObject (SYSTEM_FONT);
4212 *SetWindowLong (hwnd, 0, info ptr);
4213 *WM_NOTIFYFORMAT;
4214 *SetWindowLong (hwnd, GWL_STYLE, style+0x10000001);
4215 WS_VISIBLE = 0x10000000;
4216 CCS_TOP = 0x00000001;
4217 *SystemParametersInfo (SPI_GETNONCLIENTMETRICS...);
4218 *CreateFontIndirect (lfCaptionFont from above);
4219 GetDC ();
4220 SelectObject (hdc, fontabove);
4221 GetTextMetrics (hdc, ); guessing is tmHeight
4222 SelectObject (hdc, oldfont);
4223 ReleaseDC ();
4224 GetWindowRect ();
4225 MapWindowPoints (0, parent, rectabove, 2);
4226 GetWindowRect ();
4227 GetClientRect ();
4228 ClientToScreen (clientrect);
4229 SetWindowPos (hwnd, 0, 0, 0, 0, 0, SWP_NOZORDER);
4230 */
4231 return TRUE;
4232 }
4233
4234
4235 static LRESULT
4236 REBAR_NCHitTest (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
4237 {
4238 NMMOUSE nmmouse;
4239 POINT clpt;
4240 INT i;
4241 UINT scrap;
4242 LRESULT ret = HTCLIENT;
4243
4244 /*
4245 * Differences from doc at MSDN (as observed with version 4.71 of
4246 * comctl32.dll
4247 * 1. doc says nmmouse.pt is in screen coord, trace shows client coord.
4248 * 2. if band is not identified .dwItemSpec is 0xffffffff.
4249 * 3. native always seems to return HTCLIENT if notify return is 0.
4250 */
4251
4252 clpt.x = (short)LOWORD(lParam);
4253 clpt.y = (short)HIWORD(lParam);
4254 ScreenToClient (infoPtr->hwndSelf, &clpt);
4255 REBAR_InternalHitTest (infoPtr, &clpt, &scrap,
4256 (INT *)&nmmouse.dwItemSpec);
4257 nmmouse.dwItemData = 0;
4258 nmmouse.pt = clpt;
4259 nmmouse.dwHitInfo = 0;
4260 if ((i = REBAR_Notify((NMHDR *) &nmmouse, infoPtr, NM_NCHITTEST))) {
4261 TRACE("notify changed return value from %ld to %d\n",
4262 ret, i);
4263 ret = (LRESULT) i;
4264 }
4265 TRACE("returning %ld, client point (%ld,%ld)\n", ret, clpt.x, clpt.y);
4266 return ret;
4267 }
4268
4269
4270 static LRESULT
4271 REBAR_NCPaint (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
4272 {
4273 RECT rcWindow;
4274 HDC hdc;
4275 HTHEME theme;
4276
4277 if (infoPtr->dwStyle & WS_MINIMIZE)
4278 return 0; /* Nothing to do */
4279
4280 if (infoPtr->dwStyle & WS_BORDER) {
4281
4282 /* adjust rectangle and draw the necessary edge */
4283 if (!(hdc = GetDCEx( infoPtr->hwndSelf, 0, DCX_USESTYLE | DCX_WINDOW )))
4284 return 0;
4285 GetWindowRect (infoPtr->hwndSelf, &rcWindow);
4286 OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
4287 TRACE("rect (%ld,%ld)-(%ld,%ld)\n",
4288 rcWindow.left, rcWindow.top,
4289 rcWindow.right, rcWindow.bottom);
4290 DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_RECT);
4291 ReleaseDC( infoPtr->hwndSelf, hdc );
4292 }
4293 else if ((theme = GetWindowTheme (infoPtr->hwndSelf)))
4294 {
4295 /* adjust rectangle and draw the necessary edge */
4296 if (!(hdc = GetDCEx( infoPtr->hwndSelf, 0, DCX_USESTYLE | DCX_WINDOW )))
4297 return 0;
4298 GetWindowRect (infoPtr->hwndSelf, &rcWindow);
4299 OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
4300 TRACE("rect (%ld,%ld)-(%ld,%ld)\n",
4301 rcWindow.left, rcWindow.top,
4302 rcWindow.right, rcWindow.bottom);
4303 DrawThemeEdge (theme, hdc, 0, 0, &rcWindow, BDR_RAISEDINNER, BF_TOP, NULL);
4304 ReleaseDC( infoPtr->hwndSelf, hdc );
4305 }
4306
4307 return 0;
4308 }
4309
4310
4311 static LRESULT
4312 REBAR_NotifyFormat (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
4313 {
4314 INT i;
4315
4316 if (lParam == NF_REQUERY) {
4317 i = SendMessageW(REBAR_GetNotifyParent (infoPtr),
4318 WM_NOTIFYFORMAT, (WPARAM)infoPtr->hwndSelf, NF_QUERY);
4319 if ((i < NFR_ANSI) || (i > NFR_UNICODE)) {
4320 ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n", i);
4321 i = NFR_ANSI;
4322 }
4323 infoPtr->NtfUnicode = (i == NFR_UNICODE) ? 1 : 0;
4324 return (LRESULT)i;
4325 }
4326 return (LRESULT)((infoPtr->bUnicode) ? NFR_UNICODE : NFR_ANSI);
4327 }
4328
4329
4330 static LRESULT
4331 REBAR_Paint (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
4332 {
4333 HDC hdc;
4334 PAINTSTRUCT ps;
4335 RECT rc;
4336
4337 GetClientRect(infoPtr->hwndSelf, &rc);
4338 hdc = wParam==0 ? BeginPaint (infoPtr->hwndSelf, &ps) : (HDC)wParam;
4339
4340 TRACE("painting (%ld,%ld)-(%ld,%ld) client (%ld,%ld)-(%ld,%ld)\n",
4341 ps.rcPaint.left, ps.rcPaint.top,
4342 ps.rcPaint.right, ps.rcPaint.bottom,
4343 rc.left, rc.top, rc.right, rc.bottom);
4344
4345 if (ps.fErase) {
4346 /* Erase area of paint if requested */
4347 REBAR_InternalEraseBkGnd (infoPtr, wParam, lParam, &ps.rcPaint);
4348 }
4349
4350 REBAR_Refresh (infoPtr, hdc);
4351 if (!wParam)
4352 EndPaint (infoPtr->hwndSelf, &ps);
4353 return 0;
4354 }
4355
4356
4357 static LRESULT
4358 REBAR_SetCursor (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
4359 {
4360 POINT pt;
4361 UINT flags;
4362
4363 TRACE("code=0x%X id=0x%X\n", LOWORD(lParam), HIWORD(lParam));
4364
4365 GetCursorPos (&pt);
4366 ScreenToClient (infoPtr->hwndSelf, &pt);
4367
4368 REBAR_InternalHitTest (infoPtr, &pt, &flags, NULL);
4369
4370 if (flags == RBHT_GRABBER) {
4371 if ((infoPtr->dwStyle & CCS_VERT) &&
4372 !(infoPtr->dwStyle & RBS_VERTICALGRIPPER))
4373 SetCursor (infoPtr->hcurVert);
4374 else
4375 SetCursor (infoPtr->hcurHorz);
4376 }
4377 else if (flags != RBHT_CLIENT)
4378 SetCursor (infoPtr->hcurArrow);
4379
4380 return 0;
4381 }
4382
4383
4384 static LRESULT
4385 REBAR_SetFont (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
4386 {
4387 RECT rcClient;
4388 REBAR_BAND *lpBand;
4389 UINT i;
4390
4391 infoPtr->hFont = (HFONT)wParam;
4392
4393 /* revalidate all bands to change sizes of text in headers of bands */
4394 for (i=0; i<infoPtr->uNumBands; i++) {
4395 lpBand = &infoPtr->bands[i];
4396 REBAR_ValidateBand (infoPtr, lpBand);
4397 }
4398
4399
4400 if (LOWORD(lParam)) {
4401 GetClientRect (infoPtr->hwndSelf, &rcClient);
4402 REBAR_Layout (infoPtr, &rcClient, FALSE, TRUE);
4403 }
4404
4405 return 0;
4406 }
4407
4408
4409 inline static LRESULT
4410 REBAR_SetRedraw (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
4411 /*****************************************************
4412 *
4413 * Function;
4414 * Handles the WM_SETREDRAW message.
4415 *
4416 * Documentation:
4417 * According to testing V4.71 of COMCTL32 returns the
4418 * *previous* status of the redraw flag (either 0 or -1)
4419 * instead of the MSDN documented value of 0 if handled
4420 *
4421 *****************************************************/
4422 {
4423 BOOL oldredraw = infoPtr->DoRedraw;
4424
4425 TRACE("set to %s, fStatus=%08x\n",
4426 (wParam) ? "TRUE" : "FALSE", infoPtr->fStatus);
4427 infoPtr->DoRedraw = (BOOL) wParam;
4428 if (wParam) {
4429 if (infoPtr->fStatus & BAND_NEEDS_REDRAW) {
4430 REBAR_MoveChildWindows (infoPtr, 0, infoPtr->uNumBands);
4431 REBAR_ForceResize (infoPtr);
4432 InvalidateRect (infoPtr->hwndSelf, 0, TRUE);
4433 }
4434 infoPtr->fStatus &= ~BAND_NEEDS_REDRAW;
4435 }
4436 return (oldredraw) ? -1 : 0;
4437 }
4438
4439
4440 static LRESULT
4441 REBAR_Size (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
4442 {
4443 RECT rcClient;
4444
4445 /* auto resize deadlock check */
4446 if (infoPtr->fStatus & AUTO_RESIZE) {
4447 infoPtr->fStatus &= ~AUTO_RESIZE;
4448 TRACE("AUTO_RESIZE was set, reset, fStatus=%08x lparam=%08lx\n",
4449 infoPtr->fStatus, lParam);
4450 return 0;
4451 }
4452
4453 if (infoPtr->fStatus & CREATE_RUNNING) {
4454 /* still in CreateWindow */
4455 RECT rcWin;
4456
4457 if ((INT)wParam != SIZE_RESTORED) {
4458 ERR("WM_SIZE in create and flags=%08x, lParam=%08lx\n",
4459 wParam, lParam);
4460 }
4461
4462 TRACE("still in CreateWindow\n");
4463 infoPtr->fStatus &= ~CREATE_RUNNING;
4464 GetWindowRect ( infoPtr->hwndSelf, &rcWin);
4465 TRACE("win rect (%ld,%ld)-(%ld,%ld)\n",
4466 rcWin.left, rcWin.top, rcWin.right, rcWin.bottom);
4467
4468 if ((lParam == 0) && (rcWin.right-rcWin.left == 0) &&
4469 (rcWin.bottom-rcWin.top == 0)) {
4470 /* native control seems to do this */
4471 GetClientRect (GetParent(infoPtr->hwndSelf), &rcClient);
4472 TRACE("sizing rebar, message and client zero, parent client (%ld,%ld)\n",
4473 rcClient.right, rcClient.bottom);
4474 }
4475 else {
4476 INT cx, cy;
4477
4478 cx = rcWin.right - rcWin.left;
4479 cy = rcWin.bottom - rcWin.top;
4480 if ((cx == LOWORD(lParam)) && (cy == HIWORD(lParam))) {
4481 return 0;
4482 }
4483
4484 /* do the actual WM_SIZE request */
4485 GetClientRect (infoPtr->hwndSelf, &rcClient);
4486 TRACE("sizing rebar from (%ld,%ld) to (%d,%d), client (%ld,%ld)\n",
4487 infoPtr->calcSize.cx, infoPtr->calcSize.cy,
4488 LOWORD(lParam), HIWORD(lParam),
4489 rcClient.right, rcClient.bottom);
4490 }
4491 }
4492 else {
4493 if ((INT)wParam != SIZE_RESTORED) {
4494 ERR("WM_SIZE out of create and flags=%08x, lParam=%08lx\n",
4495 wParam, lParam);
4496 }
4497
4498 /* Handle cases when outside of the CreateWindow process */
4499
4500 GetClientRect (infoPtr->hwndSelf, &rcClient);
4501 if ((lParam == 0) && (rcClient.right + rcClient.bottom != 0) &&
4502 (infoPtr->dwStyle & RBS_AUTOSIZE)) {
4503 /* on a WM_SIZE to zero and current client not zero and AUTOSIZE */
4504 /* native seems to use the current client rect for the size */
4505 infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
4506 TRACE("sizing rebar to client (%ld,%ld) size is zero but AUTOSIZE set\n",
4507 rcClient.right, rcClient.bottom);
4508 }
4509 else {
4510 TRACE("sizing rebar from (%ld,%ld) to (%d,%d), client (%ld,%ld)\n",
4511 infoPtr->calcSize.cx, infoPtr->calcSize.cy,
4512 LOWORD(lParam), HIWORD(lParam),
4513 rcClient.right, rcClient.bottom);
4514 }
4515 }
4516
4517 if (infoPtr->dwStyle & RBS_AUTOSIZE) {
4518 NMRBAUTOSIZE autosize;
4519
4520 GetClientRect(infoPtr->hwndSelf, &autosize.rcTarget);
4521 autosize.fChanged = 0; /* ??? */
4522 autosize.rcActual = autosize.rcTarget; /* ??? */
4523 REBAR_Notify((NMHDR *) &autosize, infoPtr, RBN_AUTOSIZE);
4524 TRACE("RBN_AUTOSIZE client=(%ld,%ld), lp=%08lx\n",
4525 autosize.rcTarget.right, autosize.rcTarget.bottom, lParam);
4526 }
4527
4528 if ((infoPtr->calcSize.cx != rcClient.right) ||
4529 (infoPtr->calcSize.cy != rcClient.bottom))
4530 infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
4531
4532 REBAR_Layout (infoPtr, &rcClient, TRUE, TRUE);
4533
4534 return 0;
4535 }
4536
4537
4538 static LRESULT
4539 REBAR_StyleChanged (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
4540 {
4541 STYLESTRUCT *ss = (STYLESTRUCT *)lParam;
4542
4543 TRACE("current style=%08lx, styleOld=%08lx, style being set to=%08lx\n",
4544 infoPtr->dwStyle, ss->styleOld, ss->styleNew);
4545 infoPtr->orgStyle = infoPtr->dwStyle = ss->styleNew;
4546 if (GetWindowTheme (infoPtr->hwndSelf))
4547 infoPtr->dwStyle &= ~WS_BORDER;
4548
4549 return FALSE;
4550 }
4551
4552 /* update theme after a WM_THEMECHANGED message */
4553 static LRESULT theme_changed (REBAR_INFO* infoPtr)
4554 {
4555 HTHEME theme = GetWindowTheme (infoPtr->hwndSelf);
4556 CloseThemeData (theme);
4557 theme = OpenThemeData (infoPtr->hwndSelf, themeClass);
4558 /* WS_BORDER disappears when theming is enabled and reappears when
4559 * disabled... */
4560 infoPtr->dwStyle &= ~WS_BORDER;
4561 infoPtr->dwStyle |= theme ? 0 : (infoPtr->orgStyle & WS_BORDER);
4562 return 0;
4563 }
4564
4565 static LRESULT
4566 REBAR_WindowPosChanged (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
4567 {
4568 WINDOWPOS *lpwp = (WINDOWPOS *)lParam;
4569 LRESULT ret;
4570 RECT rc;
4571
4572 /* Save the new origin of this window - used by _ForceResize */
4573 infoPtr->origin.x = lpwp->x;
4574 infoPtr->origin.y = lpwp->y;
4575 ret = DefWindowProcW(infoPtr->hwndSelf, WM_WINDOWPOSCHANGED,
4576 wParam, lParam);
4577 GetWindowRect(infoPtr->hwndSelf, &rc);
4578 TRACE("hwnd %p new pos (%ld,%ld)-(%ld,%ld)\n",
4579 infoPtr->hwndSelf, rc.left, rc.top, rc.right, rc.bottom);
4580 return ret;
4581 }
4582
4583
4584 static LRESULT WINAPI
4585 REBAR_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
4586 {
4587 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
4588
4589 TRACE("hwnd=%p msg=%x wparam=%x lparam=%lx\n",
4590 hwnd, uMsg, wParam, lParam);
4591 if (!infoPtr && (uMsg != WM_NCCREATE))
4592 return DefWindowProcW (hwnd, uMsg, wParam, lParam);
4593 switch (uMsg)
4594 {
4595 /* case RB_BEGINDRAG: */
4596
4597 case RB_DELETEBAND:
4598 return REBAR_DeleteBand (infoPtr, wParam, lParam);
4599
4600 /* case RB_DRAGMOVE: */
4601 /* case RB_ENDDRAG: */
4602
4603 case RB_GETBANDBORDERS:
4604 return REBAR_GetBandBorders (infoPtr, wParam, lParam);
4605
4606 case RB_GETBANDCOUNT:
4607 return REBAR_GetBandCount (infoPtr);
4608
4609 case RB_GETBANDINFO_OLD:
4610 case RB_GETBANDINFOA:
4611 return REBAR_GetBandInfoA (infoPtr, wParam, lParam);
4612
4613 case RB_GETBANDINFOW:
4614 return REBAR_GetBandInfoW (infoPtr, wParam, lParam);
4615
4616 case RB_GETBARHEIGHT:
4617 return REBAR_GetBarHeight (infoPtr, wParam, lParam);
4618
4619 case RB_GETBARINFO:
4620 return REBAR_GetBarInfo (infoPtr, wParam, lParam);
4621
4622 case RB_GETBKCOLOR:
4623 return REBAR_GetBkColor (infoPtr);
4624
4625 /* case RB_GETCOLORSCHEME: */
4626 /* case RB_GETDROPTARGET: */
4627
4628 case RB_GETPALETTE:
4629 return REBAR_GetPalette (infoPtr, wParam, lParam);
4630
4631 case RB_GETRECT:
4632 return REBAR_GetRect (infoPtr, wParam, lParam);
4633
4634 case RB_GETROWCOUNT:
4635 return REBAR_GetRowCount (infoPtr);
4636
4637 case RB_GETROWHEIGHT:
4638 return REBAR_GetRowHeight (infoPtr, wParam, lParam);
4639
4640 case RB_GETTEXTCOLOR:
4641 return REBAR_GetTextColor (infoPtr);
4642
4643 case RB_GETTOOLTIPS:
4644 return REBAR_GetToolTips (infoPtr);
4645
4646 case RB_GETUNICODEFORMAT:
4647 return REBAR_GetUnicodeFormat (infoPtr);
4648
4649 case CCM_GETVERSION:
4650 return REBAR_GetVersion (infoPtr);
4651
4652 case RB_HITTEST:
4653 return REBAR_HitTest (infoPtr, wParam, lParam);
4654
4655 case RB_IDTOINDEX:
4656 return REBAR_IdToIndex (infoPtr, wParam, lParam);
4657
4658 case RB_INSERTBANDA:
4659 return REBAR_InsertBandA (infoPtr, wParam, lParam);
4660
4661 case RB_INSERTBANDW:
4662 return REBAR_InsertBandW (infoPtr, wParam, lParam);
4663
4664 case RB_MAXIMIZEBAND:
4665 return REBAR_MaximizeBand (infoPtr, wParam, lParam);
4666
4667 case RB_MINIMIZEBAND:
4668 return REBAR_MinimizeBand (infoPtr, wParam, lParam);
4669
4670 case RB_MOVEBAND:
4671 return REBAR_MoveBand (infoPtr, wParam, lParam);
4672
4673 case RB_PUSHCHEVRON:
4674 return REBAR_PushChevron (infoPtr, wParam, lParam);
4675
4676 case RB_SETBANDINFOA:
4677 return REBAR_SetBandInfoA (infoPtr, wParam, lParam);
4678
4679 case RB_SETBANDINFOW:
4680 return REBAR_SetBandInfoW (infoPtr, wParam, lParam);
4681
4682 case RB_SETBARINFO:
4683 return REBAR_SetBarInfo (infoPtr, wParam, lParam);
4684
4685 case RB_SETBKCOLOR:
4686 return REBAR_SetBkColor (infoPtr, wParam, lParam);
4687
4688 /* case RB_SETCOLORSCHEME: */
4689 /* case RB_SETPALETTE: */
4690 /* return REBAR_GetPalette (infoPtr, wParam, lParam); */
4691
4692 case RB_SETPARENT:
4693 return REBAR_SetParent (infoPtr, wParam, lParam);
4694
4695 case RB_SETTEXTCOLOR:
4696 return REBAR_SetTextColor (infoPtr, wParam, lParam);
4697
4698 /* case RB_SETTOOLTIPS: */
4699
4700 case RB_SETUNICODEFORMAT:
4701 return REBAR_SetUnicodeFormat (infoPtr, wParam);
4702
4703 case CCM_SETVERSION:
4704 return REBAR_SetVersion (infoPtr, (INT)wParam);
4705
4706 case RB_SHOWBAND:
4707 return REBAR_ShowBand (infoPtr, wParam, lParam);
4708
4709 case RB_SIZETORECT:
4710 return REBAR_SizeToRect (infoPtr, wParam, lParam);
4711
4712
4713 /* Messages passed to parent */
4714 case WM_COMMAND:
4715 case WM_DRAWITEM:
4716 case WM_NOTIFY:
4717 if (infoPtr->NtfUnicode)
4718 return SendMessageW (REBAR_GetNotifyParent (infoPtr),
4719 uMsg, wParam, lParam);
4720 else
4721 return SendMessageA (REBAR_GetNotifyParent (infoPtr),
4722 uMsg, wParam, lParam);
4723
4724
4725 /* case WM_CHARTOITEM: supported according to ControlSpy */
4726
4727 case WM_CREATE:
4728 return REBAR_Create (infoPtr, wParam, lParam);
4729
4730 case WM_DESTROY:
4731 return REBAR_Destroy (infoPtr, wParam, lParam);
4732
4733 case WM_ERASEBKGND:
4734 return REBAR_EraseBkGnd (infoPtr, wParam, lParam);
4735
4736 case WM_GETFONT:
4737 return REBAR_GetFont (infoPtr, wParam, lParam);
4738
4739 /* case WM_LBUTTONDBLCLK: supported according to ControlSpy */
4740
4741 case WM_LBUTTONDOWN:
4742 return REBAR_LButtonDown (infoPtr, wParam, lParam);
4743
4744 case WM_LBUTTONUP:
4745 return REBAR_LButtonUp (infoPtr, wParam, lParam);
4746
4747 /* case WM_MEASUREITEM: supported according to ControlSpy */
4748
4749 case WM_MOUSEMOVE:
4750 return REBAR_MouseMove (infoPtr, wParam, lParam);
4751
4752 case WM_MOUSELEAVE:
4753 return REBAR_MouseLeave (infoPtr, wParam, lParam);
4754
4755 case WM_NCCALCSIZE:
4756 return REBAR_NCCalcSize (infoPtr, wParam, lParam);
4757
4758 case WM_NCCREATE:
4759 return REBAR_NCCreate (hwnd, wParam, lParam);
4760
4761 case WM_NCHITTEST:
4762 return REBAR_NCHitTest (infoPtr, wParam, lParam);
4763
4764 case WM_NCPAINT:
4765 return REBAR_NCPaint (infoPtr, wParam, lParam);
4766
4767 case WM_NOTIFYFORMAT:
4768 return REBAR_NotifyFormat (infoPtr, wParam, lParam);
4769
4770 case WM_PRINTCLIENT:
4771 case WM_PAINT:
4772 return REBAR_Paint (infoPtr, wParam, lParam);
4773
4774 /* case WM_PALETTECHANGED: supported according to ControlSpy */
4775 /* case WM_QUERYNEWPALETTE:supported according to ControlSpy */
4776 /* case WM_RBUTTONDOWN: supported according to ControlSpy */
4777 /* case WM_RBUTTONUP: supported according to ControlSpy */
4778
4779 case WM_SETCURSOR:
4780 return REBAR_SetCursor (infoPtr, wParam, lParam);
4781
4782 case WM_SETFONT:
4783 return REBAR_SetFont (infoPtr, wParam, lParam);
4784
4785 case WM_SETREDRAW:
4786 return REBAR_SetRedraw (infoPtr, wParam, lParam);
4787
4788 case WM_SIZE:
4789 return REBAR_Size (infoPtr, wParam, lParam);
4790
4791 case WM_STYLECHANGED:
4792 return REBAR_StyleChanged (infoPtr, wParam, lParam);
4793
4794 case WM_THEMECHANGED:
4795 return theme_changed (infoPtr);
4796
4797 /* case WM_SYSCOLORCHANGE: supported according to ControlSpy */
4798 /* "Applications that have brushes using the existing system colors
4799 should delete those brushes and recreate them using the new
4800 system colors." per MSDN */
4801
4802 /* case WM_VKEYTOITEM: supported according to ControlSpy */
4803 /* case WM_WININICHANGE: */
4804
4805 case WM_WINDOWPOSCHANGED:
4806 return REBAR_WindowPosChanged (infoPtr, wParam, lParam);
4807
4808 default:
4809 if ((uMsg >= WM_USER) && (uMsg < WM_APP))
4810 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
4811 uMsg, wParam, lParam);
4812 return DefWindowProcW (hwnd, uMsg, wParam, lParam);
4813 }
4814 }
4815
4816
4817 VOID
4818 REBAR_Register (void)
4819 {
4820 WNDCLASSW wndClass;
4821
4822 ZeroMemory (&wndClass, sizeof(WNDCLASSW));
4823 wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS;
4824 wndClass.lpfnWndProc = REBAR_WindowProc;
4825 wndClass.cbClsExtra = 0;
4826 wndClass.cbWndExtra = sizeof(REBAR_INFO *);
4827 wndClass.hCursor = 0;
4828 wndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
4829 #if GLATESTING
4830 wndClass.hbrBackground = CreateSolidBrush(RGB(0,128,0));
4831 #endif
4832 wndClass.lpszClassName = REBARCLASSNAMEW;
4833
4834 RegisterClassW (&wndClass);
4835
4836 mindragx = GetSystemMetrics (SM_CXDRAG);
4837 mindragy = GetSystemMetrics (SM_CYDRAG);
4838
4839 }
4840
4841
4842 VOID
4843 REBAR_Unregister (void)
4844 {
4845 UnregisterClassW (REBARCLASSNAMEW, NULL);
4846 }