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