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