Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
rebar.c
Package: shell.rar [view]
Upload User: xhy777
Upload Date: 2007-02-14
Package Size: 24088k
Code Size: 134k
Category:
Windows Kernel
Development Platform:
Visual C++
- return fRecalcFirst;
- }
- case RBC_SET: // set
- {
- PRBB prbb1, prbb2;
- prbb1 = RBEnumBand(prb, 0, RBBS_HIDDEN);
- if ((prbb1->fStyle & RBBS_FIXEDSIZE)
- && (prbb2 = RBEnumBand(prb, 1, RBBS_HIDDEN)) <= RB_GETLASTBAND(prb)) {
- // get rid of line break on NEW first item
- prbb2->fStyle &= ~RBBS_BREAK;
- }
- if (prb->ci.style & RBS_FIXEDORDER) {
- // BUGBUG not sure what this does...
- // this is because the min width is now based on it's movability --
- // and since we are deleting (or hiding) the first item,
- // the new first item becomes immovable
- RBBCalcMinWidth(prb, prbb1);
- }
- return TRUE;
- }
- default:
- ASSERT(0);
- }
- return FALSE;
- }
- // ----------------------------------------------------------------------------
- //
- // RBShowBand
- //
- // updates show/hide state for the indicated band in the rebar's band array
- // (rbbList).
- //
- // ----------------------------------------------------------------------------
- BOOL RBShowBand(PRB prb, UINT uBand, BOOL fShow)
- {
- PRBB prbb;
- BOOL fRecalcFirst;
- if (!prb || (!RB_ISVALIDINDEX(prb, uBand)))
- return(FALSE);
- prbb = RBGETBAND(prb, uBand);
- // if we're nuking the 1st visible guy,
- // then we need to recompute stuff
- fRecalcFirst = RBRecalcFirst(RBC_QUERY, prb, prbb);
- if (fShow)
- {
- prbb->fStyle &= ~RBBS_HIDDEN;
- if (!RBBCalcTextExtent(prb, prbb, NULL))
- RBBCalcMinWidth(prb, prbb);
- if (prbb->hwndChild)
- ShowWindow(prbb->hwndChild, SW_SHOW);
- }
- else
- {
- prbb->fStyle |= RBBS_HIDDEN;
- if (prbb->hwndChild)
- ShowWindow(prbb->hwndChild, SW_HIDE);
- }
- if (fRecalcFirst)
- RBRecalcFirst(RBC_SET, prb, NULL);
- RBInvalidateRect(prb, NULL);
- RBResize(prb, FALSE);
- RBAutoSize(prb);
- return(TRUE);
- }
- // ----------------------------------------------------------------------------
- //
- // RBDeleteBand
- //
- // deletes the indicated band from the rebar's band array (rbbList) and
- // decrements the rebar's band count (cBands)
- //
- // ----------------------------------------------------------------------------
- BOOL RBDeleteBand(PRB prb, UINT uBand)
- {
- PRBB prbb;
- PRBB prbbStop;
- BOOL fRecalcFirst;
- NMREBAR nm = {0};
- ASSERT(prb);
- // we need to clean up
- //
- // a) captured band and
- // b) hottracked band
- //
- // before we delete this band
- if (prb->iCapture != -1) {
- RBSendNotify(prb, prb->iCapture, RBN_ENDDRAG);
- RBOnBeginDrag(prb, (UINT)-1);
- }
- if (!RB_ISVALIDINDEX(prb, uBand))
- return FALSE;
- prbb = RBGETBAND(prb, uBand);
- // Notify the client of the delete
- RBSendNotify(prb, uBand, RBN_DELETINGBAND);
- nm.dwMask = RBNM_ID;
- nm.wID = RBGETBAND(prb, uBand)->wID; // Save this
- Str_Set(&prbb->lpText, NULL);
- // don't destroy the hbmBack 'cause it's given to us by app
- // if we're nuking the 1st visible guy,
- // then we need to recompute stuff
- // if this is the first visible guy and there are other visible bands after it, fRecalcFirst = TRUE
- fRecalcFirst = RBRecalcFirst(RBC_QUERY, prb, prbb);
- if (IsWindow(prbb->hwndChild))
- ShowWindow(prbb->hwndChild, SW_HIDE);
- // prbbStop gets the address of the last band
- prbbStop = RB_GETLASTBAND(prb);
- for ( ; prbb < prbbStop; prbb++)
- *prbb = *(prbb + 1);
- prb->cBands--;
- if (prb->uResizeNext >= uBand && prb->uResizeNext > 0) {
- // (defer RBBS_HIDDEN stuff to use of uResizeNext)
- prb->uResizeNext--;
- }
- // Notify the client of the delete
- CCSendNotify(&prb->ci, RBN_DELETEDBAND, &nm.hdr);
- if (fRecalcFirst)
- RBRecalcFirst(RBC_SET, prb, NULL);
- RBReallocBands(prb, prb->cBands);
- RBInvalidateRect(prb, NULL);
- RBResize(prb, FALSE);
- RBAutoSize(prb);
- return(TRUE);
- }
- // ----------------------------------------------------------------------------
- //
- // RBInsertBand
- //
- // inserts a new band at the given position in the rebar's band array (rbbList),
- // increments the rebar's band count (cBands), and sets the band's structure
- // based on the given REBARBANDINFO structure.
- //
- // ----------------------------------------------------------------------------
- BOOL RBInsertBand(PRB prb, UINT uBand, LPREBARBANDINFO lprbbi)
- {
- PRBB prbb;
- REBARBANDINFO rbbi = {0};
- if (!prb || !RBValidateBandInfo(&lprbbi, &rbbi))
- return(FALSE);
- if (uBand == -1)
- uBand = prb->cBands;
- else if (uBand > prb->cBands)
- return(FALSE);
- if (!RBReallocBands(prb, prb->cBands + 1))
- return(FALSE);
- ++prb->cBands;
- MoveMemory(RBGETBAND(prb, uBand + 1), RBGETBAND(prb, uBand), (prb->cBands-1-uBand) * sizeof(prb->rbbList[0]));
- prbb = RBGETBAND(prb, uBand);
- // movememory does not zero init for us...
- ZeroMemory(prbb, SIZEOF(RBB));
- // Init text color
- if (prb->clrText == CLR_NONE)
- {
- // Default to system text color
- prbb->clrFore = CLR_DEFAULT;
- }
- else
- {
- // Default to rebar's custom text color
- prbb->clrFore = CLR_NONE;
- }
- // Init background color
- if (prb->clrBk == CLR_NONE)
- {
- // Default to system background color
- prbb->clrBack = CLR_DEFAULT;
- }
- else
- {
- // Default to rebar's custom background color
- prbb->clrBack = CLR_NONE;
- }
- prbb->iImage = -1;
- prbb->cyMaxChild = MAXINT;
- prbb->wChevState = DCHF_INACTIVE;
- ASSERT(prbb->fStyle == 0);
- ASSERT(prbb->lpText == NULL);
- ASSERT(prbb->cxText == 0);
- ASSERT(prbb->hwndChild == NULL);
- ASSERT(prbb->cxMinChild == 0);
- ASSERT(prbb->cyMinChild == 0);
- ASSERT(prbb->hbmBack == 0);
- ASSERT(prbb->x == 0);
- ASSERT(prbb->y == 0);
- ASSERT(prbb->cx == 0);
- ASSERT(prbb->cy == 0);
- if (!RBSetBandInfo(prb, uBand, lprbbi, FALSE))
- {
- RBDeleteBand(prb, uBand);
- return(FALSE);
- }
- if (!(prbb->fStyle & RBBS_HIDDEN)) {
- PRBB prbbFirst = RBEnumBand(prb, 0, RBBS_HIDDEN);
- if (!prbb->cxMin)
- RBBCalcMinWidth(prb, prbb);
- if (prbbFirst != prbb) {
- int cxMin = prbbFirst->cxMin;
- RBBCalcMinWidth(prb, prbbFirst);
- }
- RBResize(prb, FALSE);
- }
- RBSizeBandToRowHeight(prb, uBand, (UINT)-1);
- if (RBCountBands(prb, RBBS_HIDDEN) == 1) {
- // typcially, when you insert a band, we put it in a row with another band.
- // thus the total bounding rect doesn't change. however, on the addition of the first band,
- // the bound rect does change, so we need to autosize as necessary.
- RBAutoSize(prb);
- }
- return(TRUE);
- }
- #pragma code_seg(CODESEG_INIT)
- LRESULT CALLBACK ReBarWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
- BOOL InitReBarClass(HINSTANCE hInstance)
- {
- WNDCLASS wc;
- if (!GetClassInfo(hInstance, c_szReBarClass, &wc))
- {
- #ifndef WIN32
- extern LRESULT CALLBACK _ReBarWndProc(HWND, UINT, WPARAM, LPARAM);
- wc.lpfnWndProc = _ReBarWndProc;
- #else
- wc.lpfnWndProc = (WNDPROC) ReBarWndProc;
- #endif
- wc.lpszClassName= c_szReBarClass;
- wc.style = CS_GLOBALCLASS | CS_DBLCLKS;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = sizeof(PRB);
- wc.hInstance = hInstance; // use DLL instance if in DLL
- wc.hIcon = NULL;
- wc.hCursor = NULL;
- wc.hbrBackground= (HBRUSH)(COLOR_BTNFACE + 1);
- wc.lpszMenuName = NULL;
- if (!RegisterClass(&wc))
- return(FALSE);
- }
- return(TRUE);
- }
- #pragma code_seg()
- // get the first band in the same row as rbbRow
- // n.b. we may return an RBBS_HIDDEN band!
- PRBB RBGetFirstInRow(PRB prb, PRBB prbbRow)
- {
- // n.b. we don't pay attention to hidden here, that's up to caller.
- // in fact we *can't*, since there might be no non-hidden guys left
- // (e.g. when RBDestroy is deleting all the bands), in which case
- // we'd loop forever.
- while (prbbRow > RBGETBAND(prb, 0) && !RBISBANDSTARTOFROW(prbbRow)) {
- RBCheckRangePtr(prb, prbbRow);
- prbbRow--;
- }
- return prbbRow;
- }
- // get the last band in the same row as rbbRow.
- // fStopAtFixed says whether to continue over fixed bands or
- // stop at them
- // n.b. we may return an RBBS_HIDDEN band!
- PRBB RBGetLastInRow(PRB prb, PRBB prbbRow, BOOL fStopAtFixed)
- {
- do {
- prbbRow++;
- } while (prbbRow <= RB_GETLASTBAND(prb) && !RBISBANDSTARTOFROW(prbbRow) &&
- (!fStopAtFixed || (prbbRow->fStyle & (RBBS_FIXEDSIZE|RBBS_HIDDEN)) == RBBS_FIXEDSIZE));
- // loop steps to the start of the NEXT line
- prbbRow--;
- return prbbRow;
- }
- #ifdef DEBUG
- BOOL RBCheckRangePtr(PRB prb, PRBB prbb)
- {
- if (prbb < RBGETBAND(prb, 0)) {
- ASSERT(0);
- return FALSE;
- }
- if (RB_GETLASTBAND(prb) + 1 < prbb) {
- // +1 to allow for "p = first; p < last+1; p++" kinds of loops
- ASSERT(0);
- return FALSE;
- }
- return TRUE;
- }
- BOOL RBCheckRangeInd(PRB prb, INT_PTR i)
- {
- if (i < 0) {
- ASSERT(0);
- return FALSE;
- }
- if ((int) prb->cBands < i) {
- // +1 to allow for "p = first; p < last+1; p++" kinds of loops
- ASSERT(0);
- return FALSE;
- }
- return TRUE;
- }
- #endif
- //*** RBGetPrev, RBGetNext -- get prev (next) band, skipping guys
- // of style uStyleSkip (e.g. RBBS_HIDDEN)
- PRBB RBGetPrev(PRB prb, PRBB prbb, UINT uStyleSkip)
- {
- while (--prbb >= RBGETBAND(prb, 0)) {
- if (prbb->fStyle & uStyleSkip)
- continue;
- break;
- }
- return prbb;
- }
- // when called with prbb=lastband, returns prbb++
- // which is one past the end...
- PRBB RBGetNext(PRB prb, PRBB prbb, UINT uStyleSkip)
- {
- while (++prbb <= RB_GETLASTBAND(prb)) {
- if (prbb->fStyle & uStyleSkip)
- continue;
- break;
- }
- return prbb;
- }
- // this returns NULL when it hits the end
- PRBB RBBNextVisible(PRB prb, PRBB prbb)
- {
- prbb = RBGetNextVisible(prb, prbb);
- if (prbb > RB_GETLASTBAND(prb))
- return NULL;
- return prbb;
- }
- // this returns null when it hits the end
- PRBB RBBPrevVisible(PRB prb, PRBB prbb)
- {
- prbb = RBGetPrevVisible(prb, prbb);
- if (prbb < prb->rbbList)
- return NULL;
- return prbb;
- }
- //*** RBCountBands -- get count of bands, skipping guys
- // of style uStyleSkip (e.g. RBBS_HIDDEN)
- int RBCountBands(PRB prb, UINT uStyleSkip)
- {
- int i;
- PRBB prbb;
- if (prb->cBands == 0)
- return 0;
- i = 0;
- for (prbb = RBGETBAND(prb, 0); prbb <= RB_GETLASTBAND(prb); prbb++) {
- if (prbb->fStyle & uStyleSkip)
- continue;
- i++;
- }
- return i;
- }
- //*** RBEnumBand -- get Nth band, skipping guys
- // of style uStyleSkip (e.g. RBBS_HIDDEN)
- // 'skipping' means don't include in count
- PRBB RBEnumBand(PRB prb, int i, UINT uStyleSkip)
- {
- PRBB prbb;
- for (prbb = RBGETBAND(prb, 0); prbb <= RB_GETLASTBAND(prb); prbb++) {
- if (prbb->fStyle & uStyleSkip)
- continue;
- if (i-- == 0)
- break;
- }
- // if we found it, this is the band;
- // if we ran out of bands, this is 1 past the end
- return prbb;
- }
- // returns the minimum x position prbb can be
- int RBMinX(PRB prb, PRBB prbb)
- {
- int xLimit = 0;
- ASSERT(!(prbb->fStyle & RBBS_HIDDEN)); // o.w. might loop forever
- while (!RBISBANDSTARTOFROW(prbb))
- {
- prbb--;
- if (!(prbb->fStyle & RBBS_HIDDEN))
- xLimit += _RBBandWidth(prb, prbb->cxMin);
- }
- return xLimit;
- }
- int RBMaxX(PRB prb, PRBB prbb)
- {
- PRBB prbbLast = prb->rbbList + prb->cBands;
- int xLimit = 0;
- PRBB prbbWalk;
- for (prbbWalk = prbb; prbbWalk < prbbLast; prbbWalk++) {
- if (prbbWalk->fStyle & RBBS_HIDDEN)
- continue;
- if (RBISBANDSTARTOFROW(prbbWalk))
- break;
- if (prbbWalk != prbb)
- xLimit += _RBBandWidth(prb, prbbWalk->cxMin);
- else
- xLimit += prbbWalk->cxMin;
- }
- prbbWalk = RBGetPrevVisible(prb, prbbWalk); // prbbWalk--;
- xLimit = prbbWalk->x + prbbWalk->cx - xLimit;
- return xLimit;
- }
- PRBB RBGetPrevVisible(PRB prb, PRBB prbb)
- {
- return RBGetPrev(prb, prbb, RBBS_HIDDEN);
- }
- PRBB RBGetNextVisible(PRB prb, PRBB prbb)
- {
- return RBGetNext(prb, prbb, RBBS_HIDDEN);
- }
- BOOL RBMinimizeBand(PRB prb, UINT uBand, BOOL fAnim)
- {
- PRBB prbb;
- if (!RB_ISVALIDINDEX(prb, uBand))
- return FALSE;
- prbb=RBGETBAND(prb,uBand);
- if (prbb->fStyle & RBBS_FIXEDSIZE)
- return FALSE;
- ASSERT(!(prbb->fStyle & RBBS_HIDDEN));
- if (RBISBANDSTARTOFROW(prbb)) {
- // if it's the start of a row, the way to minimize it is to maximize the next guy
- // if it's on the same row
- prbb = RBGetNextVisible(prb, prbb);
- if (prbb > RB_GETLASTBAND(prb) || RBISBANDSTARTOFROW(prbb))
- return FALSE;
- return RBMaximizeBand(prb, RBBANDTOINDEX(prb,prbb), FALSE, fAnim);
- }
- if (fAnim)
- return RBSetBandPosAnim(prb, prbb, prbb->x + (prbb->cx - prbb->cxMin));
- else
- return RBSetBandPos(prb, prbb, prbb->x + (prbb->cx - prbb->cxMin));
- }
- // fIdeal - FALSE == full maximization...
- // TRUE == go to cxIdeal
- // fAnim - TRUE means we were called due to UI action (via RBToggleBand), so animate
- BOOL RBMaximizeBand(PRB prb, UINT uBand, BOOL fIdeal, BOOL fAnim)
- {
- int x, dx;
- BOOL fChanged = FALSE;
- PRBB prbbMaximize;
- if (!RB_ISVALIDINDEX(prb, uBand))
- return FALSE;
- prbbMaximize = RBGETBAND(prb,uBand);
- if (prbbMaximize->fStyle & RBBS_FIXEDSIZE)
- return FALSE;
- dx = prbbMaximize->cxIdeal + RBBHEADERWIDTH(prbbMaximize) - prbbMaximize->cx;
- if (fIdeal && dx > 0)
- {
- PRBB prbb;
- // first move the next guy over if possible.
- prbb = RBBNextVisible(prb, prbbMaximize);
- if (prbb && (!RBISBANDSTARTOFROW(prbb)))
- {
- int dxRbb;
- x = RBMaxX(prb, prbb);
- // dxRbb is the maximum that prbb can move
- dxRbb = x - prbb->x;
- if (dxRbb > dx) {
- // if that's more than enough space, then limit dx
- dxRbb = dx;
- }
- x = prbb->x + dxRbb;
- fChanged |= (fAnim)?RBSetBandPosAnim(prb, prbb, x):RBSetBandPos(prb,prbb,x);
- dx -= dxRbb;
- }
- if (dx) {
- int dxRbb;
- // the one on the right didn't move enough.
- // now move us back
- x = RBMinX(prb, prbbMaximize);
- dxRbb = prbbMaximize->x - x;
- if (dxRbb > dx) {
- x = prbbMaximize->x - dx;
- }
- fChanged |= (fAnim)?RBSetBandPosAnim(prb, prbbMaximize, x):RBSetBandPos(prb, prbbMaximize, x);
- }
- } else {
- x = RBMinX(prb, prbbMaximize);
- fChanged |= (fAnim)?RBSetBandPosAnim(prb, prbbMaximize, x):RBSetBandPos(prb, prbbMaximize, x);
- prbbMaximize = RBBNextVisible(prb, prbbMaximize);
- if (prbbMaximize && !RBISBANDSTARTOFROW(prbbMaximize)) {
- x = RBMaxX(prb, prbbMaximize);
- fChanged |= (fAnim)?RBSetBandPosAnim(prb, prbbMaximize, x):RBSetBandPos(prb, prbbMaximize, x);
- }
- }
- return fChanged;
- }
- // ----------------------------------------------------------------------------
- //
- // RBToggleBand
- //
- // switches a band between it's maximized and minimized state, based on where
- // the user clicked
- //
- // ----------------------------------------------------------------------------
- void RBToggleBand(PRB prb, BOOL fAnim)
- {
- BOOL fDidSomething = FALSE;
- // try to maximize this band. if failed (meaning already maximize)
- // then minimize
- if (CCSendNotify(&prb->ci, RBN_MINMAX, NULL))
- return;
- fDidSomething = RBMaximizeBand(prb, prb->iCapture, TRUE,fAnim);
- if (!fDidSomething)
- fDidSomething = RBMinimizeBand(prb, prb->iCapture,fAnim);
- if (fDidSomething)
- CCPlaySound(TEXT("ShowBand"));
- }
- // ----------------------------------------------------------------------------
- //
- // RBSetCursor
- //
- // sets the cursor to either the move cursor or the arrow cursor, depending
- // on whether or not the cursor is on a band's caption
- //
- // ----------------------------------------------------------------------------
- void RBSetCursor(PRB prb, int x, int y, BOOL fMouseDown)
- {
- int iBand;
- RBHITTESTINFO rbht;
- rbht.pt.x = x;
- rbht.pt.y = y;
- iBand = RBHitTest(prb, &rbht);
- if (rbht.flags == RBHT_GRABBER)
- {
- if (fMouseDown)
- SetCursor(LoadCursor(HINST_THISDLL, (prb->ci.style & CCS_VERT) ? MAKEINTRESOURCE(IDC_DIVOPENV) : MAKEINTRESOURCE(IDC_DIVOPEN) ));
- else
- SetCursor(LoadCursor(NULL, (prb->ci.style & CCS_VERT) ? IDC_SIZENS : IDC_SIZEWE));
- return;
- }
- if ((fMouseDown) && ((rbht.flags == RBHT_GRABBER) || (rbht.flags == RBHT_CAPTION) && RBShouldDrawGripper(prb, RBGETBAND(prb, iBand))))
- {
- // No longer IE3 compatible, per RichSt
- SetCursor(LoadCursor(NULL, IDC_SIZEALL));
- return;
- }
- SetCursor(LoadCursor(NULL, IDC_ARROW));
- }
- // adjust's a band's (prbb) starting location to the given location
- BOOL RBSetBandPos(PRB prb, PRBB prbb, int xLeft)
- {
- RECT rc;
- PRBB prbbPrev;
- int xRight;
- BOOL fBandBorders = (prb->ci.style & RBS_BANDBORDERS);
- BOOL fRight;
- ASSERT(!(prbb->fStyle & RBBS_HIDDEN));
- ASSERT((xLeft >= 0)); // We've got problems if someone is trying to set us negative
- if (prbb->x == xLeft)
- return(FALSE);
- prbbPrev = RBGetPrevVisible(prb, prbb);
- // band has moved within valid range -- adjust band sizes and redraw
- // window
- fRight = (prbb->x < xLeft);
- SetRect(&rc, prbb->x, prbb->y, prbb->x + prbb->cxMin, prbb->y + prbb->cy);
- xRight = prbb->x + prbb->cx;
- prbb->x = xLeft;
- prbb->cx = xRight - xLeft;
- prbb->cxRequest = prbb->cx;
- if (fRight)
- {
- //moving right
- prbbPrev->cx = prbb->x - prbbPrev->x;
- if (fBandBorders)
- {
- prbbPrev->cx -= g_cxEdge;
- rc.left -= g_cxEdge;
- }
- prbbPrev->cxRequest = prbbPrev->cx;
- //check for compacting of following bands
- while (prbb->cx < prbb->cxMin)
- {
- prbb->cx = prbb->cxMin;
- prbb->cxRequest = prbb->cx;
- xLeft += RBBANDWIDTH(prb, prbb);
- prbb = RBGetNextVisible(prb, prbb); // prbb++;
- xRight = prbb->x + prbb->cx;
- prbb->x = xLeft;
- prbb->cx = xRight - xLeft;
- prbb->cxRequest = prbb->cx;
- }
- rc.right = xLeft + prbb->cxMin;
- }
- else
- {
- //moving left
- //check for compacting of preceding bands
- CompactPrevious:
- if (fBandBorders)
- xLeft -= g_cxEdge;
- prbbPrev->cx = xLeft - prbbPrev->x;
- prbbPrev->cxRequest = prbbPrev->cx;
- if (prbbPrev->cx < prbbPrev->cxMin)
- {
- prbbPrev->x = xLeft - prbbPrev->cxMin;
- prbbPrev->cx = prbbPrev->cxMin;
- prbbPrev->cxRequest = prbbPrev->cx;
- xLeft = prbbPrev->x;
- prbbPrev = RBGetPrevVisible(prb, prbbPrev); // prbbPrev--
- goto CompactPrevious;
- }
- rc.left = xLeft;
- }
- if (fBandBorders)
- rc.bottom += g_cyEdge / 2;
- RBResizeChildren(prb);
- if (RBInvalidateRect(prb, &rc))
- UpdateWindow(prb->ci.hwnd);
- return(TRUE);
- }
- BOOL RBSetBandPosAnim(PRB prb, PRBB prbb, int xLeft)
- {
- int ctr=0,dx, xCur = prbb->x;
- DWORD dwStartTime;
- if (xCur == xLeft)
- return FALSE;
- dwStartTime=GetTickCount();
- dx = (xLeft - xCur)/RB_ANIMSTEPS;
- if (dx != 0)
- {
- if (xCur < xLeft) {
- // move right
- for (; xCur < (xLeft-dx); ctr++,xCur += dx) {
- RBSetBandPos(prb, prbb, xCur);
- // If something caused us to take more than 10 times the time we
- // should be, break out, and let the final RBSetBandPos finish
- if (GetTickCount() > (dwStartTime + 10*RB_ANIMSTEPS*RB_ANIMSTEPTIME))
- break;
- Sleep(RB_ANIMSTEPTIME);
- // Start slowing us down 80% of the way through
- // Cut speed by 2/3 each time, but never move less than 4 pixels
- if ((ctr >= 4*RB_ANIMSTEPS/5) && (dx >= 4))
- dx = 2*dx/3;
- }
- }
- else {
- // move left
- for (; xCur > (xLeft-dx); ctr++, xCur += dx) {
- RBSetBandPos(prb, prbb, xCur);
- if (GetTickCount() > (dwStartTime + 10*RB_ANIMSTEPS*RB_ANIMSTEPTIME))
- break;
- Sleep(RB_ANIMSTEPTIME);
- if ((ctr >= 4*RB_ANIMSTEPS/5) && (dx <= -4))
- dx = 2*dx/3;
- }
- }
- }
- RBSetBandPos(prb, prbb, xLeft);
- return TRUE;
- }
- // ----------------------------------------------------------------------------
- //
- // RBDragSize
- //
- // adjust the captured band's starting location to the given location and
- // redraw
- //
- // ----------------------------------------------------------------------------
- BOOL RBDragSize(PRB prb, int xLeft)
- {
- return RBSetBandPos(prb, RBGETBAND(prb, prb->iCapture), xLeft);
- }
- void RBOnBeginDrag(PRB prb, UINT uBand)
- {
- prb->iCapture = (int)uBand;
- prb->ptLastDragPos.x = -1;
- prb->ptLastDragPos.y = -1;
- if (prb->iCapture == -1) {
- // aborting drag
- prb->fParentDrag = FALSE;
- prb->fFullOnDrag = FALSE;
- // we could have unwrapped rows, in which case, we need to grow bands (but not wrap)
- // to fill the empty space.
- if (prb->ci.style & RBS_AUTOSIZE) {
- RBSizeBandsToRect(prb, NULL);
- RBSizeBandsToRowHeight(prb);
- }
- } else {
- prb->fParentDrag = TRUE;
- prb->fFullOnDrag = TRUE;
- }
- }
- int minmax(int x, int min, int max)
- {
- x = max(x, min);
- x = min(x, max);
- return x;
- }
- // pass the break bit along
- void RBPassBreak(PRB prb, PRBB prbbSrc, PRBB prbbDest)
- {
- if (prbbSrc->fStyle & RBBS_BREAK) {
- prbbSrc->fStyle &= ~RBBS_BREAK;
- if (prbbDest)
- prbbDest->fStyle |= RBBS_BREAK;
- }
- }
- void RBGetClientRect(PRB prb, LPRECT prc)
- {
- GetClientRect(prb->ci.hwnd, prc);
- if (prb->ci.style & CCS_VERT)
- FlipRect(prc);
- }
- //tells if prbb is the first band and the next band is fixed.
- // if this is true then we need to do a recalc if we move prbb
- BOOL RBRecalcIfMove(PRB prb, PRBB prbb)
- {
- if (RBEnumBand(prb, 0, RBBS_HIDDEN) == prbb) {
- PRBB prbbNext = RBBNextVisible(prb, prbb);
- if (prbbNext && prbbNext->fStyle & RBBS_FIXEDSIZE)
- return TRUE;
- }
- return FALSE;
- }
- // find out if the prbb at it's min height could fit within the current window
- // if all the others shrunk as much as they could
- BOOL RBRoomForBandVert(PRB prb, PRBB prbbSkip)
- {
- int yExtra = 0;
- int cBands = prb->cBands;
- int iNewRowHeight = prbbSkip->cyMinChild;
- PRBB prbb = RBGETBAND(prb, 0);
- if (prb->ci.style & RBS_BANDBORDERS)
- iNewRowHeight += g_cyEdge;
- while (prbb) {
- if (RBISBANDVISIBLE(prbb)) {
- if (RBISBANDSTARTOFROW(prbb)) {
- yExtra += RBGetRowHeightExtra(prb, &prbb, prbbSkip);
- if (yExtra >= iNewRowHeight)
- return TRUE;
- continue;
- }
- }
- prbb = RBBNextVisible(prb, prbb);
- }
- return FALSE;
- }
- // we should make a new row if prbb isn't the start of the row already
- // and we're off the end of the control
- //
- // poweruser hack of holding the control down will make a new row if you hit the border between lines
- BOOL RBMakeNewRow(PRB prb, PRBB prbb, int y)
- {
- BOOL fRet = FALSE;
- RECT rc;
- // if we're off the top of the control, move this band to the end (or beginning)
- RBGetClientRect(prb, &rc);
- InflateRect(&rc, 0, -g_cyEdge);
- if (!(prb->ci.style & RBS_FIXEDORDER)) {
- int iOutsideLimit = g_cyEdge * 4; // how far do you have to move outside the bounds of the window to force a new row
- if (RBRoomForBandVert(prb, prbb)) {
- iOutsideLimit = -g_cyEdge;
- }
- if (y < rc.top - iOutsideLimit) { // top of control
- PRBB prbbNext = RBEnumBand(prb, 0, RBBS_HIDDEN);
- if (prbbNext == prbb)
- prbbNext = RBBNextVisible(prb, prbb);
- fRet |= RBMoveBand(prb, RBBANDTOINDEX(prb, prbb), 0);
- ASSERT(prbbNext <= RB_GETLASTBAND(prb));
- if (prbbNext && !(prbbNext->fStyle & RBBS_BREAK)) {
- prbbNext->fStyle |= RBBS_BREAK;
- fRet = TRUE;
- }
- } else if (y >= rc.bottom + iOutsideLimit) { // move to the end
- if (!(prbb->fStyle & RBBS_BREAK)) {
- prbb->fStyle |= RBBS_BREAK;
- fRet = TRUE;
- }
- fRet |= RBMoveBand(prb, RBBANDTOINDEX(prb, prbb), prb->cBands-1);
- } else {
- // create a new row in the middle
- if (!RBISBANDSTARTOFROW(prbb) && GetAsyncKeyState(VK_CONTROL) < 0) {
- // make sure they're on different rows and on the border
- if (y > prbb->y + prbb->cy && (y < prbb->y + prbb->cy + g_cyEdge)) {
- PRBB prbbLast = RBGetLastInRow(prb, prbb, FALSE); // move it right before the first in this row
- prbb->fStyle |= RBBS_BREAK;
- RBMoveBand(prb, RBBANDTOINDEX(prb, prbb), RBBANDTOINDEX(prb, prbbLast));
- fRet = TRUE;
- }
- }
- }
- } else {
- // fixed guys can't move, they can only make a new row
- if (!RBISBANDSTARTOFROW(prbb)) {
- if (y > prbb->y + prbb->cy) {
- prbb->fStyle |= RBBS_BREAK;
- fRet = TRUE;
- }
- }
- }
- if (fRet)
- RBResize(prb, FALSE);
- return fRet;
- }
- // ----------------------------------------------------------------------------
- //
- // RBDragBand
- //
- // resizes the currently tracked band based on the user's mouse movement as
- // indicated in the given point (x, y)
- //
- // ----------------------------------------------------------------------------
- void RBDragBand(PRB prb, int x, int y)
- {
- PRBB prbb = RBGETBAND(prb, prb->iCapture);
- int iHit;
- // Do nothing if the mouse didn't actually move
- // otherwise, multiple WM_MOUSEMOVE messages will be generated by resizing windows
- if (x==prb->ptLastDragPos.x && y==prb->ptLastDragPos.y)
- return;
- else
- {
- prb->ptLastDragPos.x = x;
- prb->ptLastDragPos.y = y;
- }
- if (prb->ci.style & CCS_VERT)
- SWAP(x,y, int);
- if (!prb->fFullOnDrag)
- {
- // don't begin dragging until mouse is moved outside of an edge-thick
- // tolerance border
- if ((y < (prb->ptCapture.y - g_cyEdge)) || (y > (prb->ptCapture.y + g_cyEdge)) ||
- (x < (prb->ptCapture.x - g_cxEdge)) || (x > (prb->ptCapture.x + g_cxEdge))) {
- // did parent abort?
- if (RBSendNotify(prb, prb->iCapture, RBN_BEGINDRAG))
- return;
- if (!RB_ISVALIDBAND(prb, prbb)) {
- // somebody responded to RBN_BEGINDRAG by nuking bands; bail
- return;
- }
- prb->fFullOnDrag = TRUE;
- } else
- return;
- }
- // bail for right now on fRecalcIfMoved (ie3 did the same thing). nice feature for later
- if (!RBCanBandMove(prb, prbb))
- return;
- /* what type of drag operation depends on what we drag hit on.
- if we hit on the band before us, or ourself
- and it's the same row
- and we're not the first band of the row
- then we just to a size move
- otherwise if we hit on a band then we do a move
- if we hit outside of any band, we grow to meet the cursor
- in all of the above, a band that's hit must be NOT fixed and not hidden
- */
- iHit = _RBHitTest(prb, NULL, x, y);
- if (iHit != -1) {
- BOOL fResize = FALSE;
- PRBB prbbPrev = RBBPrevVisible(prb, prbb);
- PRBB prbbHit = RBGETBAND(prb, iHit);
- prbbHit = RBGetPrev(prb, ++prbbHit, RBBS_FIXEDSIZE); // skip over fixed guys
- ASSERT(prbbHit >= prb->rbbList);
- // this should never happen.
- if (prbbHit < prb->rbbList)
- return;
- iHit = RBBANDTOINDEX(prb, prbbHit);
- // if we're on the same row ... and it's us or the previous one
- if (prbbHit->y == prbb->y && (prbbHit == prbb || prbbHit == prbbPrev)) {
- if (x < RB_GRABWIDTH && !(prb->ci.style & RBS_FIXEDORDER)) {
- // special case dragging to the far left. there's no other way to move to first in row
- RBPassBreak(prb, prbbHit, prbb);
- if (RBMoveBand(prb, prb->iCapture, iHit))
- fResize = TRUE;
- } else if (!RBISBANDSTARTOFROW(prbb)) {
- // and we're not the first band of the row
- // then just size it
- int xLeft = prb->xStart + (x - prb->ptCapture.x);
- xLeft = minmax(xLeft, RBMinX(prb, prbb), RBMaxX(prb, prbb));
- RBDragSize(prb, xLeft);
- }
- } else if (RBMakeNewRow(prb, prbb, y)) {
- } else { // otherwise do a move if we're not in a fixed order
- if (!(prb->ci.style & RBS_FIXEDORDER)) {
- if (iHit < RBBANDTOINDEX(prb, prbb))
- iHit++; // +1 because if you hit a band, you're moving to the right of him
- // if one with a break is moving, the next one inherits the break
- RBPassBreak(prb, prbb, RBBNextVisible(prb, prbb));
- RBMoveBand(prb, prb->iCapture, iHit);
- } else {
- if (iHit < RBBANDTOINDEX(prb, prbb))
- RBPassBreak(prb, prbb, RBBNextVisible(prb, prbb));
- }
- fResize = TRUE;
- }
- if (fResize)
- RBResize(prb, FALSE);
- } else
- RBMakeNewRow(prb, prbb, y);
- }
- HPALETTE RBSetPalette(PRB prb, HPALETTE hpal)
- {
- HPALETTE hpalOld = prb->hpal;
- if (hpal != hpalOld) {
- if (!prb->fUserPalette) {
- if (prb->hpal) {
- DeleteObject(prb->hpal);
- prb->hpal = NULL;
- }
- }
- if (hpal) {
- prb->fUserPalette = TRUE;
- prb->hpal = hpal;
- }
- RBInvalidateRect(prb, NULL);
- }
- return hpalOld;
- }
- // ----------------------------------------------------------------------------
- //
- // RBDestroy
- //
- // frees all memory allocated by rebar, including rebar structure
- //
- // ----------------------------------------------------------------------------
- BOOL RBDestroy(PRB prb)
- {
- UINT c = prb->cBands;
- RBSetRedraw(prb, FALSE);
- RBSetRecalc(prb, FALSE);
- while (c--)
- RBDeleteBand(prb, c);
- // so that we don't keep trying to autosize
- prb->ci.style &= ~RBS_AUTOSIZE;
- ASSERT(!prb->rbbList);
- RBSetPalette(prb, NULL);
- if (prb->hFont && prb->fFontCreated) {
- DeleteObject(prb->hFont);
- }
- if ((prb->ci.style & RBS_TOOLTIPS) && IsWindow(prb->hwndToolTips))
- {
- DestroyWindow (prb->hwndToolTips);
- prb->hwndToolTips = NULL;
- }
- // don't destroy the himl 'cause it's given to us by app
- SetWindowPtr(prb->ci.hwnd, 0, 0);
- if (prb->hDragProxy)
- DestroyDragProxy(prb->hDragProxy);
- LocalFree((HLOCAL) prb);
- return(TRUE);
- }
- // ----------------------------------------------------------------------------
- //
- // RBInitPaletteHack
- //
- // this is a hack to use the halftone palette until we have a way of asking
- // the client what palette they are using
- //
- // ----------------------------------------------------------------------------
- void RBInitPaletteHack(PRB prb)
- {
- if (!prb->fUserPalette) {
- HDC hdc = CreateCompatibleDC(NULL);
- if (hdc) {
- if (GetDeviceCaps(hdc, BITSPIXEL) <= 8) {
- if (prb->hpal)
- DeleteObject(prb->hpal);
- prb->hpal = CreateHalftonePalette(hdc); // this is a hack
- }
- DeleteDC(hdc);
- }
- }
- }
- LRESULT RBIDToIndex(PRB prb, UINT id)
- {
- UINT i;
- REBARBANDINFO rbbi;
- rbbi.cbSize = sizeof(REBARBANDINFO);
- rbbi.fMask = RBBIM_ID;
- for (i = 0; i < prb->cBands; i++) {
- if (RBGetBandInfo(prb, i, &rbbi)) {
- if (rbbi.wID == (WORD)id)
- return i;
- }
- }
- return -1;
- }
- LRESULT RBGetRowHeight(PRB prb, UINT uRow)
- {
- if (uRow < prb->cBands)
- {
- // move back to start of line
- PRBB prbbFirst = RBGetFirstInRow(prb, RBGETBAND(prb, uRow));
- PRBB prbbLast = RBGetLastInRow(prb, RBGETBAND(prb, uRow), FALSE);
- return RBGetLineHeight(prb, RBBANDTOINDEX(prb, prbbFirst), RBBANDTOINDEX(prb, prbbLast));
- }
- return (LRESULT)-1;
- }
- // fOneStep == whether to allow only one cyIntegral or as many as will fit to
- // fill dy
- int RBGrowBand(PRB prb, PRBB prbb, int dy, BOOL fOneStep)
- {
- int iDirection = dy / ABS(dy);
- int dyBand = 0; // how much the band changes
- int cyNewHeight;
- if (prbb->cyIntegral &&
- prbb->cyIntegral <= (UINT)ABS(dy)) {
- // get the proposed new size
- if (fOneStep)
- dyBand = (prbb->cyIntegral * iDirection);
- else {
- int iNumOfIntegrals;
- // don't let it grow more than the max allowed
- if (dy >= 0) {
- if ((int)(prbb->cyMaxChild - prbb->cyChild) < dy) {
- dy = (int)(prbb->cyMaxChild - prbb->cyChild);
- }
- } else {
- if ((int)(prbb->cyMinChild - prbb->cyChild) > dy) {
- dy = (int)(prbb->cyMinChild - prbb->cyChild);
- }
- }
- iNumOfIntegrals = (dy / (int) prbb->cyIntegral);
- dyBand = (prbb->cyIntegral * iNumOfIntegrals);
- }
- cyNewHeight = ((int)prbb->cyChild) + dyBand;
- // make sure the new size is legal
- if ((int)prbb->cyMinChild <= cyNewHeight && ((UINT)cyNewHeight) <= prbb->cyMaxChild) {
- prbb->cyChild = cyNewHeight;
- RBResize(prb, TRUE);
- } else
- dyBand = 0;
- }
- return dyBand;
- }
- // returns the delta in size that the rebar is from prc.
- // taking into account vertical mode
- int RBSizeDifference(PRB prb, LPRECT prc)
- {
- int d;
- d = (RB_ISVERT(prb) ? RECTWIDTH(*prc) : RECTHEIGHT(*prc))
- - prb->cy;
- return d;
- }
- // returns how much this row could shrink
- int RBGetRowHeightExtra(PRB prb, PRBB *pprbb, PRBB prbbSkip)
- {
- // this is the largest minimum child size for the row.
- // even if something is not at it's min size, if it's smaller than this
- // then it doesn't matter because someone else on that row can't be sized
- int yLimit = 0;
- int yExtra = 0;
- PRBB prbb = *pprbb;
- while (prbb) {
- if (prbb != prbbSkip) {
- int yMin;
- int yExtraBand = 0;
- // the min height is the cyChild if it's not variable height
- yMin = prbb->cyChild;
- if (prbb->fStyle & RBBS_VARIABLEHEIGHT)
- {
- // if it is variable height, and there's still room to shrink, then cyMinChild is
- // the minimum.
- if (prbb->cyChild > prbb->cyMinChild + prbb->cyIntegral) {
- yMin = prbb->cyMinChild;
- yExtraBand = prbb->cyChild - prbb->cyMinChild;
- }
- }
- if (yMin == yLimit) {
- if (yExtraBand > yExtra)
- yExtra = yExtraBand;
- } else if (yMin > yLimit) {
- yExtra = yExtraBand;
- }
- }
- prbb = RBBNextVisible(prb, prbb);
- }
- *pprbb = prbb;
- return yExtra;
- }
- // are allt he bands at the minimum size?
- BOOL RBBandsAtMinHeight(PRB prb)
- {
- BOOL fRet = TRUE;
- int cBands = prb->cBands;
- PRBB prbb = RBGETBAND(prb, 0);
- while (prbb) {
- if (RBISBANDVISIBLE(prbb)) {
- if (RBISBANDSTARTOFROW(prbb)) {
- fRet = RBROWATMINHEIGHT(prb, &prbb);
- if (!fRet)
- break;
- continue;
- }
- }
- prbb = RBBNextVisible(prb, prbb);
- }
- return fRet;
- }
- // this is like RBSizeBarToRect except that it resizes theactual bands if they
- // are VARIABLEHEIGHT
- BOOL RBSizeBandsToRect(PRB prb, LPRECT prc)
- {
- int dy;
- int iDirection = 0;
- BOOL fChanged = FALSE;
- BOOL fChangedThisLoop;
- UINT cBands;
- RECT rc;
- BOOL fRedrawOld;
- if (prc)
- rc = *prc;
- else {
- GetClientRect(prb->ci.hwnd, &rc);
- }
- fRedrawOld = RBSetRedraw(prb, FALSE);
- // this is the amount we need to grow by
- do {
- BOOL fOneStep = TRUE;
- cBands = prb->cBands;
- fChangedThisLoop = FALSE;
- // if there's only one row, we don't need to iterate through all the rows slowly
- if (RBGetRowCount(prb) == 1)
- fOneStep = FALSE;
- dy = RBSizeDifference(prb, &rc);
- // ensure that we alway size in the same direction.
- // it's possible to get on the border and flip flop in an infinite
- // loop. this happens when we size both horizontally and vertically down
- // beyond the minimum.
- if (iDirection == 0)
- iDirection = dy;
- else if (dy * iDirection < 0)
- break;
- while (cBands-- && dy) {
- // when we're resizing the entire rebar, we want to divvy up
- // the growth among all the bands (rather than give it all to
- // a single guy). uResizeNext goes round-robin thru the bands.
- PRBB prbb = RBGETBAND(prb, prb->uResizeNext);
- if (prb->uResizeNext == 0)
- prb->uResizeNext = prb->cBands -1;
- else
- prb->uResizeNext--;
- if (prbb->fStyle & RBBS_HIDDEN)
- continue;
- if (prbb->fStyle & RBBS_VARIABLEHEIGHT) {
- int d;
- // if it's a variable height kind of guy, grow/shrink it
- d = RBGrowBand(prb, prbb, dy, fOneStep);
- dy -= d;
- if (d) {
- fChanged = TRUE;
- fChangedThisLoop = TRUE;
- break;
- }
- }
- }
- // if we're shrinking
- // and we didn't get completely satisfied. we need to overshoot
- // so that no bands hang off the end and get cut off
- if (dy < 0 && !fChangedThisLoop && !RBBandsAtMinHeight(prb)) {
- if (rc.bottom > rc.top) {
- rc.bottom -= 1;
- fChangedThisLoop = TRUE;
- }
- }
- } while (fChangedThisLoop);
- RBSetRedraw(prb, fRedrawOld);
- return fChanged;
- }
- void RBSizeBandToRowHeight(PRB prb, int i, UINT uRowHeight)
- {
- PRBB prbb = RBGETBAND(prb, i);
- if (prbb && prbb->fStyle & RBBS_VARIABLEHEIGHT) {
- if (uRowHeight == (UINT)-1)
- uRowHeight = (UINT) RBGetRowHeight(prb, i);
- if (uRowHeight > prbb->cyChild) {
- RBGrowBand(prb, prbb, (uRowHeight - prbb->cyChild),
- FALSE);
- }
- }
- }
- // in the process of sizing, one band in a row of several bands might have
- // grow pretty large. we need to let the other bands have a chance to fill
- // the extra space as well
- void RBSizeBandsToRowHeight(PRB prb)
- {
- UINT i;
- UINT iRowHeight = (UINT)-1;
- for (i = 0; i < prb->cBands; i++) {
- PRBB prbb = RBGETBAND(prb, i);
- if (prbb->fStyle & RBBS_HIDDEN)
- continue;
- if (RBISBANDSTARTOFROW(prbb))
- iRowHeight = (UINT) RBGetRowHeight(prb, i);
- RBSizeBandToRowHeight(prb, i, iRowHeight);
- }
- }
- // this will add/remove rebar band breaks to get to the requested size.
- // it returns TRUE/FALSE whether something was done or not.
- LRESULT RBSizeBarToRect(PRB prb, LPRECT prc)
- {
- BOOL fChanged = FALSE;
- RECT rc;
- BOOL fRedrawOld = RBSetRedraw(prb, FALSE);
- if (!prc) {
- GetClientRect(prb->ci.hwnd, &rc);
- prc = &rc;
- }
- if (prb->cBands) {
- int c;
- UINT cBands = prb->cBands;
- BOOL fChangedThisLoop = TRUE;
- BOOL fGrowing = TRUE;
- // if we're shrinking the rebar, we first want to shrink the bands before we start
- // removing breaks
- c = RBSizeDifference(prb, prc);
- if (c < 0)
- fGrowing = FALSE;
- if (!fGrowing) {
- fChanged = RBSizeBandsToRect(prb, prc);
- if (!RBBandsAtMinHeight(prb)) {
- // if we're shrinking and all the bands are not down to
- // the minimum height, don't try doing any of the breaking stuff
- goto Bail;
- }
- } else if (RB_ISVERT(prb)) {
- // if we're in vertical mode, give preference to
- // sizing bands before breaking
- fChanged = RBSizeBandsToRect(prb, prc);
- }
- while (fChangedThisLoop && prb->cBands) {
- int cyRowHalf = (int) RBGetRowHeight(prb, prb->cBands-1) / 2 ;
- REBARBANDINFO rbbi;
- PRBB prbb;
- fChangedThisLoop = FALSE;
- rbbi.cbSize = sizeof(REBARBANDINFO);
- rbbi.fMask = RBBIM_STYLE;
- c = RBSizeDifference(prb, prc);
- if (c < -cyRowHalf) {
- // we've shrunk the rebar, try to remove breaks
- while (--cBands)
- {
- prbb = RBGETBAND(prb, cBands);
- if (prbb->fStyle & RBBS_HIDDEN)
- continue;
- if (prbb->fStyle & RBBS_BREAK)
- {
- fChanged = TRUE;
- fChangedThisLoop = TRUE;
- rbbi.fStyle = prbb->fStyle & ~RBBS_BREAK;
- RBSetBandInfo(prb, cBands, &rbbi, TRUE);
- break;
- }
- }
- } else if (c > cyRowHalf) {
- // we're enlarging the rebar
- while (--cBands)
- {
- prbb = RBGETBAND(prb, cBands);
- if (prbb->fStyle & RBBS_HIDDEN)
- continue;
- if (!(prbb->fStyle & (RBBS_BREAK | RBBS_FIXEDSIZE)))
- {
- // no break here, add it
- fChanged = TRUE;
- fChangedThisLoop = TRUE;
- rbbi.fStyle = (prbb->fStyle | RBBS_BREAK);
- RBSetBandInfo(prb, cBands, &rbbi, TRUE);
- break;
- }
- }
- }
- };
- // if we did as much breaking as we could
- // and we walked all the way down to the 0th band (we start at the Nth band)
- // then we try to grow the bands that are VARIABLEHEIGHT
- // for fGrowing, see comment at top of function
- //
- // wedo the % because cBands == prb->cBands if we didn't go through
- // any of the breaking loops at all
- if (!(cBands % prb->cBands) && fGrowing)
- fChanged |= RBSizeBandsToRect(prb, prc);
- }
- Bail:
- RBSizeBandsToRowHeight(prb);
- RBSetRedraw(prb, fRedrawOld);
- return (LRESULT)fChanged;
- }
- void RBAutoSize(PRB prb)
- {
- NMRBAUTOSIZE nm;
- // if this is an internal autosize call, but we're not in autosize mode
- // do nothing
- if (!(prb->ci.style & RBS_AUTOSIZE))
- return;
- GetClientRect(prb->ci.hwnd, &nm.rcTarget);
- nm.fChanged = (BOOL) RBSizeBarToRect(prb, &nm.rcTarget);
- GetClientRect(prb->ci.hwnd, &nm.rcActual);
- CCSendNotify(&prb->ci, RBN_AUTOSIZE, &nm.hdr);
- }
- LRESULT RBGetBandBorders(PRB prb, int wParam, LPRECT prc)
- {
- BOOL fBandBorders = (prb->ci.style & RBS_BANDBORDERS);
- PRBB prbb = &prb->rbbList[wParam];
- prc->left = RBBHEADERWIDTH(prbb);
- if (fBandBorders) {
- prc->left += 2*g_cxEdge;
- prc->right = 0;
- prc->top = g_cyEdge/2;
- prc->bottom = g_cyEdge /2;
- }
- if (prb->ci.style & CCS_VERT)
- FlipRect(prc);
- return 0;
- }
- void RBOnStyleChanged(PRB prb, WPARAM wParam, LPSTYLESTRUCT lpss)
- {
- if (wParam == GWL_STYLE)
- {
- DWORD dwChanged;
- prb->ci.style = lpss->styleNew;
- dwChanged = (lpss->styleOld ^ lpss->styleNew);
- // update to reflect style change
- #ifndef WINNT
- TraceMsg(TF_REBAR, "rebar window style changed %x", prb->ci.style);
- #endif
- if (dwChanged & CCS_VERT)
- {
- UINT i;
- for (i = 0; i < prb->cBands; i++) {
- if (RBGETBAND(prb, i)->fStyle & RBBS_HIDDEN)
- continue;
- RBBCalcMinWidth(prb, RBGETBAND(prb, i));
- }
- RBResize(prb, TRUE);
- RBInvalidateRect(prb, NULL);
- }
- if (dwChanged & RBS_REGISTERDROP) {
- if (prb->ci.style & RBS_REGISTERDROP) {
- ASSERT(!prb->hDragProxy);
- prb->hDragProxy = CreateDragProxy(prb->ci.hwnd, RebarDragCallback, TRUE);
- } else {
- ASSERT(prb->hDragProxy);
- DestroyDragProxy(prb->hDragProxy);
- }
- }
- } else if (wParam == GWL_EXSTYLE) {
- //
- // If the RTL_MIRROR extended style bit had changed, let's
- // repaint the control window
- //
- if ((prb->ci.dwExStyle&RTL_MIRRORED_WINDOW) != (lpss->styleNew&RTL_MIRRORED_WINDOW)) {
- RBInvalidateRect(prb, NULL);
- }
- //
- // Save the new ex-style bits
- //
- prb->ci.dwExStyle = lpss->styleNew;
- }
- }
- void RBOnMouseMove(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, PRB prb)
- {
- RelayToToolTips(prb->hwndToolTips, hwnd, uMsg, wParam, lParam);
- if (prb->iCapture != -1)
- {
- // captured band -- mouse is down
- if (hwnd != GetCapture() && !prb->fParentDrag)
- {
- RBSendNotify(prb, prb->iCapture, RBN_ENDDRAG);
- RBOnBeginDrag(prb, (UINT)-1);
- }
- else
- RBDragBand(prb, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
- }
- else
- {
- // hottracking
- int iBand;
- PRBB prbb = NULL;
- PRBB prbbHotOld = prb->prbbHot;
- RBHITTESTINFO rbht;
- rbht.pt.x = GET_X_LPARAM(lParam);
- rbht.pt.y = GET_Y_LPARAM(lParam);
- iBand = RBHitTest(prb, &rbht);
- if (iBand != -1)
- prbb = RBGETBAND(prb, iBand);
- if (prbbHotOld && (prbbHotOld->wChevState & DCHF_PUSHED))
- return;
- if (prbb && (rbht.flags & RBHT_CHEVRON))
- {
- SetCapture(hwnd);
- RBUpdateChevronState(prb, prbb, DCHF_HOT);
- if (prbb == prbbHotOld)
- prbbHotOld = NULL;
- }
- if (prbbHotOld)
- {
- CCReleaseCapture(&prb->ci);
- RBUpdateChevronState(prb, prbbHotOld, DCHF_INACTIVE);
- }
- }
- }
- void RBOnPushChevron(HWND hwnd, PRB prb, PRBB prbb, LPARAM lParamNM)
- {
- NMREBARCHEVRON nm;
- nm.uBand = RBBANDTOINDEX(prb, prbb);
- nm.wID = prbb->wID;
- nm.lParam = prbb->lParam;
- nm.lParamNM = lParamNM;
- CopyRect(&nm.rc, &prbb->rcChevron);
- if (RB_ISVERT(prb))
- FlipRect(&nm.rc);
- RBUpdateChevronState(prb, prbb, DCHF_PUSHED);
- CCReleaseCapture(&prb->ci);
- CCSendNotify(&prb->ci, RBN_CHEVRONPUSHED, &nm.hdr);
- RBUpdateChevronState(prb, prb->prbbHot, DCHF_INACTIVE);
- }
- LRESULT CALLBACK ReBarWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
- {
- PRB prb = (PRB) GetWindowPtr(hwnd, 0);
- int iBand;
- // bail if no prb unless at creation time
- if (!prb && !(uMsg == WM_NCCREATE))
- goto CallDWP;
- switch (uMsg)
- {
- case WM_SETREDRAW:
- if (prb->ci.iVersion >= 5)
- RBSetRecalc(prb, BOOLFROMPTR(wParam));
- return RBSetRedraw(prb, BOOLFROMPTR(wParam));
- case WM_NCCREATE:
- #define lpcs ((LPCREATESTRUCT) lParam)
- InitGlobalColors();
- if (!(prb = (PRB) LocalAlloc(LPTR, sizeof(RB))))
- return(0L);
- SetWindowPtr(hwnd, 0, prb);
- prb->iCapture = -1;
- prb->clrBk = CLR_NONE;
- prb->clrText = CLR_NONE;
- // Init the dwSize because we block-copy it back to the app
- prb->clrsc.dwSize = sizeof(COLORSCHEME);
- prb->clrsc.clrBtnHighlight = prb->clrsc.clrBtnShadow = CLR_DEFAULT;
- prb->fRedraw = TRUE;
- prb->fRecalc = TRUE;
- // note, zero init memory from above
- CIInitialize(&prb->ci, hwnd, lpcs);
- if (!(prb->ci.style & (CCS_TOP | CCS_NOMOVEY | CCS_BOTTOM)))
- {
- prb->ci.style |= CCS_TOP;
- SetWindowLong(hwnd, GWL_STYLE, prb->ci.style);
- }
- RBSetFont(prb, 0);
- if (lpcs->lpCreateParams)
- RBSetBarInfo(prb, (LPREBARINFO) (lpcs->lpCreateParams));
- #undef lpcs
- return TRUE;
- case WM_DESTROY:
- RBDestroy(prb);
- SetWindowPtr(hwnd, 0, 0);
- break;
- case WM_CREATE:
- // Do delayed stuff for speed.
- PostMessage(hwnd, RB_PRIV_DODELAYEDSTUFF, 0, 0);
- goto CallDWP;
- case RB_PRIV_DODELAYEDSTUFF:
- // Delay done stuff for speed:
- if (prb->ci.style & RBS_REGISTERDROP)
- prb->hDragProxy = CreateDragProxy(prb->ci.hwnd, RebarDragCallback, TRUE);
- if (prb->ci.style & RBS_TOOLTIPS)
- {
- TOOLINFO ti;
- // don't bother setting the rect because we'll do it below
- // in FlushToolTipsMgr;
- ti.cbSize = sizeof(ti);
- ti.uFlags = TTF_IDISHWND;
- ti.hwnd = hwnd;
- ti.uId = (UINT_PTR)hwnd;
- ti.lpszText = 0;
- prb->hwndToolTips = CreateWindow(c_szSToolTipsClass, NULL,
- WS_POPUP, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
- hwnd, NULL, (HINSTANCE)GetWindowLongPtr(hwnd, GWLP_HINSTANCE), NULL);
- SendMessage(prb->hwndToolTips, TTM_ADDTOOL, 0, (LPARAM)(LPTOOLINFO) &ti);
- }
- RBInitPaletteHack(prb);
- break;
- case WM_NCHITTEST:
- {
- RBHITTESTINFO rbht;
- int iBand;
- rbht.pt.x = GET_X_LPARAM(lParam);
- rbht.pt.y = GET_Y_LPARAM(lParam);
- ScreenToClient(prb->ci.hwnd, &rbht.pt);
- iBand = RBHitTest(prb, &rbht);
- {
- NMMOUSE nm;
- LRESULT lres;
- nm.dwItemSpec = iBand;
- nm.pt = rbht.pt;
- nm.dwHitInfo = rbht.flags;
- // send to the parent to give them a chance to override
- lres = CCSendNotify(&prb->ci, NM_NCHITTEST, &nm.hdr);
- if (lres)
- return lres;
- }
- }
- return HTCLIENT;
- case WM_NCCALCSIZE:
- if (prb->ci.style & WS_BORDER)
- {
- InflateRect((LPRECT) lParam, -g_cxEdge, -g_cyEdge);
- break;
- }
- goto CallDWP;
- case WM_NCPAINT:
- if (prb->ci.style & WS_BORDER)
- {
- RECT rc;
- HDC hdc;
- GetWindowRect(hwnd, &rc);
- OffsetRect(&rc, -rc.left, -rc.top);
- hdc = GetWindowDC(hwnd);
- CCDrawEdge(hdc, &rc, EDGE_ETCHED, BF_RECT, &(prb->clrsc));
- ReleaseDC(hwnd, hdc);
- break;
- }
- goto CallDWP;
- case WM_PALETTECHANGED:
- if ((HWND)wParam == hwnd)
- break;
- case WM_QUERYNEWPALETTE:
- // Want to pass FALSE if WM_QUERYNEWPALETTE...
- RBRealize(prb, NULL, uMsg == WM_PALETTECHANGED, uMsg == WM_PALETTECHANGED);
- return TRUE;
- case WM_PAINT:
- case WM_PRINTCLIENT:
- RBPaint(prb, (HDC)wParam);
- break;
- case WM_ERASEBKGND:
- if (RBEraseBkgnd(prb, (HDC) wParam, -1))
- return(TRUE);
- goto CallDWP;
- case WM_SYSCOLORCHANGE:
- RBInitPaletteHack(prb);
- if (prb->hwndToolTips)
- SendMessage(prb->hwndToolTips, uMsg, wParam, lParam);
- InitGlobalColors();
- InvalidateRect(prb->ci.hwnd, NULL, TRUE);
- break;
- case RB_SETPALETTE:
- return (LRESULT)RBSetPalette(prb, (HPALETTE)lParam);
- case RB_GETPALETTE:
- return (LRESULT)prb->hpal;
- case WM_SIZE:
- RBAutoSize(prb);
- RBResize(prb, FALSE);
- break;
- case WM_GETFONT:
- return((LRESULT) (prb ? prb->hFont : NULL));
- case WM_COMMAND:
- case WM_DRAWITEM:
- case WM_MEASUREITEM:
- case WM_VKEYTOITEM:
- case WM_CHARTOITEM:
- SendMessage(prb->ci.hwndParent, uMsg, wParam, lParam);
- break;
- case WM_LBUTTONDBLCLK: // DBLCLK sent in place of LBUTTONDOWN
- case WM_RBUTTONDOWN: // right button drags too
- case WM_LBUTTONDOWN:
- {
- RBHITTESTINFO rbht;
- PRBB prbb = NULL;
- rbht.pt.x = GET_X_LPARAM(lParam);
- rbht.pt.y = GET_Y_LPARAM(lParam);
- RelayToToolTips(prb->hwndToolTips, hwnd, uMsg, wParam, lParam);
- iBand = RBHitTest(prb, &rbht);
- if (iBand != -1)
- prbb = RBGETBAND(prb, iBand);
- if (!prbb)
- /* nothing */ ;
- else if (rbht.flags & RBHT_CHEVRON)
- {
- RBOnPushChevron(hwnd, prb, prbb, 0);
- }
- else if (rbht.flags != RBHT_CLIENT && RBShouldDrawGripper(prb, prbb))
- {
- prb->iCapture = iBand;
- prb->ptCapture = rbht.pt;
- if (prb->ci.style & CCS_VERT)
- SWAP(prb->ptCapture.x, prb->ptCapture.y, int);
- prb->xStart = prbb->x;
- SetCapture(hwnd);
- prb->fFullOnDrag = FALSE;
- if (uMsg == WM_LBUTTONDBLCLK && (prb->ci.style & RBS_DBLCLKTOGGLE))
- RBToggleBand(prb,TRUE);
- }
- }
- break;
- case WM_SETCURSOR:
- // Give the parent first crack, if it sets the cursor then
- // leave it at that. Otherwise if the cursor is over our
- // window then set it to what we want it to be.
- if (!DefWindowProc(hwnd, uMsg, wParam, lParam) && (hwnd == (HWND)wParam))
- {
- POINT pt;
- GetMessagePosClient(prb->ci.hwnd, &pt);
- RBSetCursor(prb, pt.x, pt.y, (HIWORD(lParam) == WM_LBUTTONDOWN || HIWORD(lParam) == WM_RBUTTONDOWN));
- }
- return TRUE;
- case WM_MOUSEMOVE:
- RBOnMouseMove(hwnd, uMsg, wParam, lParam, prb);
- break;
- case WM_RBUTTONUP:
- if (!prb->fFullOnDrag && !prb->fParentDrag) {
- CCReleaseCapture(&prb->ci);
- // if we're not doing drag drop, go to def window proc so that
- // wm_contextmenu gets propagated
- RBOnBeginDrag(prb, (UINT)-1);
- goto CallDWP;
- }
- // fall through
- case WM_LBUTTONUP:
- RelayToToolTips(prb->hwndToolTips, hwnd, uMsg, wParam, lParam);
- if (prb->iCapture != -1)
- {
- UINT uiIndex;
- if (!prb->fParentDrag)
- CCReleaseCapture(&prb->ci);
- // if there was no significant mouse motion, treat as a click
- if (!(prb->ci.style & RBS_DBLCLKTOGGLE) && !prb->fFullOnDrag)
- RBToggleBand(prb,TRUE);
- RBGETBAND(prb, prb->iCapture)->fStyle &= ~RBBS_DRAGBREAK;
- CCSendNotify(&prb->ci, RBN_LAYOUTCHANGED, NULL);
- RBSendNotify(prb, prb->iCapture, RBN_ENDDRAG);
- RBOnBeginDrag(prb, (UINT)-1);
- for (uiIndex = 0; uiIndex < prb->cBands; uiIndex++) {
- if (RBGETBAND(prb, uiIndex)->fStyle & RBBS_HIDDEN)
- continue;
- RBBCalcMinWidth(prb, RBGETBAND(prb, uiIndex));
- }
- RBSizeBandsToRect(prb, NULL);
- RBInvalidateRect(prb, NULL);
- }
- break;
- case WM_WININICHANGE:
- InitGlobalMetrics(wParam);
- if (prb->fFontCreated)
- RBSetFont(prb, wParam);
- if (prb->hwndToolTips)
- SendMessage(prb->hwndToolTips, uMsg, wParam, lParam);
- break;
- case WM_SETFONT:
- RBOnSetFont(prb, (HFONT)wParam);
- break;
- case WM_NOTIFYFORMAT:
- return(CIHandleNotifyFormat(&prb->ci, lParam));
- case WM_NOTIFY:
- // We are just going to pass this on to the real parent
- // Note that -1 is used as the hwndFrom. This prevents SendNotifyEx
- // from updating the NMHDR structure.
- return(SendNotifyEx(prb->ci.hwndParent, (HWND) -1,
- ((LPNMHDR) lParam)->code, (LPNMHDR) lParam, prb->ci.bUnicode));
- case WM_STYLECHANGED:
- RBOnStyleChanged(prb, wParam, (LPSTYLESTRUCT)lParam);
- break;
- #ifdef KEYBOARDCUES
- case WM_UPDATEUISTATE:
- if (CCOnUIState(&(prb->ci), WM_UPDATEUISTATE, wParam, lParam))
- {
- InvalidateRect(hwnd, NULL, TRUE);
- }
- goto CallDWP;
- #endif
- #ifdef UNICODE
- case RB_SETBANDINFOA:
- case RB_INSERTBANDA:
- if (EVAL(lParam))
- {
- LPWSTR lpStrings = NULL;
- LPSTR lpAnsiString;
- int iResult;
- // lParam starts out pointing to a REBARBANDINFOA, and
- // we secretly change it into a REBARBANDINFOW, and then
- // change it back.
- LPREBARBANDINFOW prbiW = (LPREBARBANDINFOW)lParam;
- LPREBARBANDINFOA prbiA = (LPREBARBANDINFOA)lParam;
- COMPILETIME_ASSERT(sizeof(REBARBANDINFOW) == sizeof(REBARBANDINFOA));
- // BUGBUG - raymondc - Is it safe to modify the incoming
- // REBARBANDINFOA structure?
- lpAnsiString = prbiA->lpText;
- if ((prbiA->fMask & RBBIM_TEXT) && prbiA->lpText) {
- lpStrings = ProduceWFromA(prb->ci.uiCodePage, lpAnsiString);
- if (!lpStrings)
- return -1;
- // Presto! Now it's a REBARBANDINFOW!
- prbiW->lpText = lpStrings;
- }
- if (uMsg == RB_INSERTBANDA)
- iResult = RBInsertBand(prb, (UINT) wParam, prbiW);
- else
- iResult = RBSetBandInfo(prb, (UINT) wParam, prbiW, TRUE);
- // Change-o! Now it's a REBARBANDINFOA!
- prbiA->lpText = lpAnsiString;
- if (lpStrings)
- FreeProducedString(lpStrings);
- return iResult;
- }
- #endif
- case RB_INSERTBAND:
- return(RBInsertBand(prb, (UINT) wParam, (LPREBARBANDINFO) lParam));
- case RB_DELETEBAND:
- return(RBDeleteBand(prb, (UINT) wParam));
- case RB_SHOWBAND:
- return(RBShowBand(prb, (UINT) wParam, BOOLFROMPTR(lParam)));
- #ifdef UNICODE
- case RB_GETBANDINFOA:
- {
- LPREBARBANDINFOA prbbi = (LPREBARBANDINFOA)lParam;
- LPWSTR pszW = NULL;
- LPSTR lpAnsiString = prbbi->lpText;
- int iResult;
- if (prbbi->fMask & RBBIM_TEXT) {
- pszW = LocalAlloc(LPTR, prbbi->cch * sizeof(WCHAR));
- if (!pszW)
- return 0;
- prbbi->lpText = (LPSTR)pszW;
- }
- iResult = RBGetBandInfo(prb, (UINT)wParam, (LPREBARBANDINFO)lParam);
- if (pszW) {
- ConvertWToAN(prb->ci.uiCodePage, lpAnsiString, prbbi->cch, (LPWSTR)prbbi->lpText, -1);
- prbbi->lpText = lpAnsiString;
- LocalFree(pszW);
- }
- return iResult;
- }
- #endif
- // we have getbandinfoold because in ie3, we did not thunk
- // and getbandinfo always return OS native string (dumb)
- case RB_GETBANDINFOOLD:
- case RB_GETBANDINFO:
- return(RBGetBandInfo(prb, (UINT) wParam, (LPREBARBANDINFO) lParam));
- case RB_GETTOOLTIPS:
- return (LPARAM)prb->hwndToolTips;
- case RB_SETTOOLTIPS:
- prb->hwndToolTips = (HWND)wParam;
- break;
- case RB_SETBKCOLOR:
- {
- COLORREF clr = prb->clrBk;
- prb->clrBk = (COLORREF)lParam;
- if (clr != prb->clrBk)
- InvalidateRect(prb->ci.hwnd, NULL, TRUE);
- return clr;
- }
- case RB_GETBKCOLOR:
- return prb->clrBk;
- case RB_SETTEXTCOLOR:
- {
- COLORREF clr = prb->clrText;
- prb->clrText = (COLORREF)lParam;
- return clr;
- }
- case RB_GETTEXTCOLOR:
- return prb->clrText;
- case RB_IDTOINDEX:
- return RBIDToIndex(prb, (UINT) wParam);
- case RB_GETROWCOUNT:
- return(RBGetRowCount(prb));
- case RB_GETROWHEIGHT:
- return RBGetRowHeight(prb, (UINT)wParam);
- case RB_GETBANDBORDERS:
- return RBGetBandBorders(prb, (UINT)wParam, (LPRECT)lParam);
- case RB_GETBANDCOUNT:
- return(prb->cBands);
- case RB_SETBANDINFO:
- return(RBSetBandInfo(prb, (UINT) wParam, (LPREBARBANDINFO) lParam, TRUE));
- case RB_GETBARINFO:
- return(RBGetBarInfo(prb, (LPREBARINFO) lParam));
- case RB_SETBARINFO:
- return(RBSetBarInfo(prb, (LPREBARINFO) lParam));
- case RB_SETPARENT:
- {
- HWND hwndOld = prb->ci.hwndParent;
- prb->ci.hwndParent = (HWND) wParam;
- return (LRESULT)hwndOld;
- }
- break;
- case RB_GETRECT:
- if (RB_ISVALIDINDEX(prb, wParam))
- {
- PRBB prbb = RBGETBAND(prb, (int) wParam);
- LPRECT lprc = (LPRECT) lParam;
- lprc->left = prbb->x;
- lprc->top = prbb->y;
- lprc->right = prbb->x + prbb->cx;
- lprc->bottom = prbb->y + prbb->cy;
- return(TRUE);
- }
- break;
- case RB_HITTEST:
- return(RBHitTest(prb, (LPRBHITTESTINFO) lParam));
- case RB_SIZETORECT:
- return RBSizeBarToRect(prb, (LPRECT)lParam);
- case RB_BEGINDRAG:
- if (RB_ISVALIDINDEX(prb, wParam)) {
- // -1 means do it yourself.
- // -2 means use what you had saved before
- if (lParam != (LPARAM)-2) {
- if (lParam == (LPARAM)-1) {
- GetMessagePosClient(prb->ci.hwnd, &prb->ptCapture);
- } else {
- prb->ptCapture.x = GET_X_LPARAM(lParam);
- prb->ptCapture.y = GET_Y_LPARAM(lParam);
- }
- if (prb->ci.style & CCS_VERT)
- SWAP(prb->ptCapture.x, prb->ptCapture.y, int);
- }
- prb->xStart = RBGETBAND(prb, (UINT)wParam)->x;
- RBOnBeginDrag(prb, (UINT)wParam);
- }
- break;
- case RB_GETBARHEIGHT:
- return RBGETBARHEIGHT(prb);
- case RB_ENDDRAG:
- RBOnBeginDrag(prb, (UINT)-1);
- break;
- case RB_DRAGMOVE:
- if (prb->iCapture != -1) {
- if (lParam == (LPARAM)-1) {
- lParam = GetMessagePosClient(prb->ci.hwnd, NULL);
- }
- RBDragBand(prb, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
- }
- break;
- case RB_MINIMIZEBAND:
- RBMinimizeBand(prb, (UINT) wParam,FALSE);
- break;
- case RB_MAXIMIZEBAND:
- RBMaximizeBand(prb, (UINT)wParam, BOOLFROMPTR(lParam),FALSE);
- break;
- case RB_MOVEBAND:
- if (!RB_ISVALIDINDEX(prb,wParam) || !RB_ISVALIDINDEX(prb,lParam))
- break;
- return RBMoveBand(prb, (UINT) wParam, (UINT) lParam);
- case RB_GETDROPTARGET:
- if (!prb->hDragProxy)
- prb->hDragProxy = CreateDragProxy(prb->ci.hwnd, RebarDragCallback, FALSE);
- GetDragProxyTarget(prb->hDragProxy, (IDropTarget**)lParam);
- break;
- case RB_GETCOLORSCHEME:
- {
- LPCOLORSCHEME lpclrsc = (LPCOLORSCHEME) lParam;
- if (lpclrsc) {
- if (lpclrsc->dwSize == sizeof(COLORSCHEME))
- *lpclrsc = prb->clrsc;
- }
- return (LRESULT) lpclrsc;
- }
- case RB_SETCOLORSCHEME:
- if (lParam) {
- if (((LPCOLORSCHEME) lParam)->dwSize == sizeof(COLORSCHEME)) {
- prb->clrsc.clrBtnHighlight = ((LPCOLORSCHEME) lParam)->clrBtnHighlight;
- prb->clrsc.clrBtnShadow = ((LPCOLORSCHEME) lParam)->clrBtnShadow;
- InvalidateRect(hwnd, NULL, FALSE);
- if (prb->ci.style & WS_BORDER)
- CCInvalidateFrame(hwnd);
- }
- }
- break;
- case RB_PUSHCHEVRON:
- if (RB_ISVALIDINDEX(prb, wParam)) {
- PRBB prbb = RBGETBAND(prb, wParam);
- RBOnPushChevron(hwnd, prb, prbb, lParam);
- }
- break;
- default:
- {
- LRESULT lres;
- if (CCWndProc(&prb->ci, uMsg, wParam, lParam, &lres))
- return lres;
- }
- CallDWP:
- return(DefWindowProc(hwnd, uMsg, wParam, lParam));
- }
- return(0L);
- }