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