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

Last change on this file since 10543 was 10535, checked in by sandervl, 22 years ago

Wine merge + status & rebar fixes

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