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