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