source: trunk/src/comctl32/rebar.c@ 6644

Last change on this file since 6644 was 6644, checked in by bird, 24 years ago

Added $Id:$ keyword.

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