Ignore:
Timestamp:
Mar 17, 2004, 5:38:52 PM (22 years ago)
Author:
sandervl
Message:

Wine merge + status & rebar fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/comctl32/status.c

    r8526 r10535  
    2020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    2121 *
    22  * FIXME:
    23  * 1) Implement all CCS_* styles.
    24  * 2) Should we hide grip if the parent window is maximized?
     22 * NOTE
     23 *
     24 * This code was audited for completeness against the documented features
     25 * of Comctl32.dll version 6.0 on Sep. 24, 2002, by Dimitrie O. Paun.
     26 *
     27 * Unless otherwise noted, we believe this code to be complete, as per
     28 * the specification mentioned above.
     29 * If you discover missing features, or bugs, please note them below.
     30 *
     31 * TODO:
     32 *      -- CCS_BOTTOM (default)
     33 *      -- CCS_LEFT
     34 *      -- CCS_NODEVIDER
     35 *      -- CCS_NOMOVEX
     36 *      -- CCS_NOMOVEY
     37 *      -- CCS_NOPARENTALIGN
     38 *      -- CCS_RIGHT
     39 *      -- CCS_TOP
     40 *      -- CCS_VERT (defaults to RIGHT)
    2541 */
    2642
     43#include <stdarg.h>
    2744#include <string.h>
    2845
     46#include "windef.h"
    2947#include "winbase.h"
    3048#include "wine/unicode.h"
     49#include "wingdi.h"
     50#include "winuser.h"
     51#include "winnls.h"
    3152#include "commctrl.h"
     53#include "comctl32.h"
    3254#include "wine/debug.h"
    3355
     
    4668{
    4769    HWND              Self;
     70    HWND              Notify;
    4871    WORD              numParts;
    4972    UINT              height;
     
    87110    INT i;
    88111
    89     TRACE("draw size grip %d,%d - %d,%d\n", lpRect->left, lpRect->top, lpRect->right, lpRect->bottom);
     112    TRACE("draw size grip %ld,%ld - %ld,%ld\n", lpRect->left, lpRect->top, lpRect->right, lpRect->bottom);
    90113
    91114    pt.x = lpRect->right - 1;
     
    125148
    126149
    127 static void 
     150static void
    128151STATUSBAR_DrawPart (HDC hdc, const STATUSWINDOWPART *part, const STATUSWINDOWINFO *infoPtr, int itemID)
    129152{
     
    131154    UINT border = BDR_SUNKENOUTER;
    132155
    133     TRACE("part bound %d,%d - %d,%d\n", r.left, r.top, r.right, r.bottom);
     156    TRACE("part bound %ld,%ld - %ld,%ld\n", r.left, r.top, r.right, r.bottom);
    134157    if (part->style & SBT_POPOUT)
    135158        border = BDR_RAISEDOUTER;
     
    138161
    139162    DrawEdge(hdc, &r, border, BF_RECT|BF_ADJUST);
    140        
     163
    141164    if (part->style & SBT_OWNERDRAW)
    142165        {
     
    149172            dis.rcItem = r;
    150173            dis.itemData = (INT)part->text;
    151             SendMessageW (GetParent (infoPtr->Self), WM_DRAWITEM,
    152                     (WPARAM)dis.CtlID, (LPARAM)&dis);
    153     }
     174            SendMessageW (infoPtr->Notify, WM_DRAWITEM, (WPARAM)dis.CtlID, (LPARAM)&dis);
     175    }
    154176    else
    155177        {
     
    158180                INT cy = r.bottom - r.top;
    159181
    160                 r.left += 2; 
     182                r.left += 2;
    161183                DrawIconEx (hdc, r.left, r.top, part->hIcon, cy, cy, 0, 0, DI_NORMAL);
    162184                r.left += cy;
     
    257279    /* get our window size */
    258280    GetClientRect (infoPtr->Self, &rect);
    259     TRACE("client wnd size is %d,%d - %d,%d\n", rect.left, rect.top, rect.right, rect.bottom);
     281    TRACE("client wnd size is %ld,%ld - %ld,%ld\n", rect.left, rect.top, rect.right, rect.bottom);
    260282
    261283    rect.top += VERT_BORDER;
     
    540562        RECT parent_rect;
    541563
    542         GetClientRect (GetParent (infoPtr->Self), &parent_rect);
     564        GetClientRect (infoPtr->Notify, &parent_rect);
    543565        infoPtr->height = height + VERT_BORDER;
    544566        width = parent_rect.right - parent_rect.left;
     
    568590        for (i = infoPtr->numParts ; i < oldNumParts; i++) {
    569591            if (infoPtr->parts[i].text && !(infoPtr->parts[i].style & SBT_OWNERDRAW))
    570                 COMCTL32_Free (infoPtr->parts[i].text);
     592                Free (infoPtr->parts[i].text);
    571593        }
    572594    } else if (oldNumParts < infoPtr->numParts) {
    573         tmp = COMCTL32_Alloc (sizeof(STATUSWINDOWPART) * infoPtr->numParts);
     595        tmp = Alloc (sizeof(STATUSWINDOWPART) * infoPtr->numParts);
    574596        if (!tmp) return FALSE;
    575597        for (i = 0; i < oldNumParts; i++) {
     
    577599        }
    578600        if (infoPtr->parts)
    579             COMCTL32_Free (infoPtr->parts);
     601            Free (infoPtr->parts);
    580602        infoPtr->parts = tmp;
    581603    }
     
    587609            return TRUE;
    588610    }
    589    
     611
    590612    for (i = 0; i < infoPtr->numParts; i++)
    591613        infoPtr->parts[i].x = parts[i];
     
    626648
    627649static BOOL
    628 STATUSBAR_SetTextT (STATUSWINDOWINFO *infoPtr, INT nPart, WORD style, 
     650STATUSBAR_SetTextT (STATUSWINDOWINFO *infoPtr, INT nPart, WORD style,
    629651                    LPCWSTR text, BOOL isW)
    630652{
     
    632654    BOOL changed = FALSE;
    633655
    634     if (style & SBT_OWNERDRAW) {   
    635          TRACE("part %d, text %x\n",nPart,text);
     656    if (style & SBT_OWNERDRAW) {
     657         TRACE("part %d, text %p\n",nPart,text);
    636658    }
    637659    else TRACE("part %d, text %s\n", nPart, debugstr_t(text, isW));
     
    663685            LPCSTR atxt = (LPCSTR)text;
    664686            DWORD len = MultiByteToWideChar( CP_ACP, 0, atxt, -1, NULL, 0 );
    665             ntext = COMCTL32_Alloc( (len + 1)*sizeof(WCHAR) );
     687            ntext = Alloc( (len + 1)*sizeof(WCHAR) );
    666688            if (!ntext) return FALSE;
    667689            MultiByteToWideChar( CP_ACP, 0, atxt, -1, ntext, len );
    668690        } else if (text) {
    669             ntext = COMCTL32_Alloc( (strlenW(text) + 1)*sizeof(WCHAR) );
     691            ntext = Alloc( (strlenW(text) + 1)*sizeof(WCHAR) );
    670692            if (!ntext) return FALSE;
    671693            strcpyW (ntext, text);
     
    675697        if (text) {
    676698            if (!changed && part->text && !lstrcmpW(ntext, part->text)) {
    677                 if (!isW) COMCTL32_Free(ntext);
     699                if (!isW) Free(ntext);
    678700                return TRUE;
    679701            }
    680702        } else {
    681             if (!changed && !part->text) 
     703            if (!changed && !part->text)
    682704                return TRUE;
    683705        }
    684706
    685707        if (part->text)
    686             COMCTL32_Free (part->text);
     708            Free (part->text);
    687709        part->text = ntext;
    688710    }
     
    758780    nmhdr.idFrom = GetWindowLongW (infoPtr->Self, GWL_ID);
    759781    nmhdr.code = SBN_SIMPLEMODECHANGE;
    760     SendMessageW (GetParent (infoPtr->Self), WM_NOTIFY, 0, (LPARAM)&nmhdr);
     782    SendMessageW (infoPtr->Notify, WM_NOTIFY, 0, (LPARAM)&nmhdr);
    761783    InvalidateRect(infoPtr->Self, NULL, FALSE);
    762784    return TRUE;
     
    772794    for (i = 0; i < infoPtr->numParts; i++) {
    773795        if (infoPtr->parts[i].text && !(infoPtr->parts[i].style & SBT_OWNERDRAW))
    774             COMCTL32_Free (infoPtr->parts[i].text);
     796            Free (infoPtr->parts[i].text);
    775797    }
    776798    if (infoPtr->part0.text && !(infoPtr->part0.style & SBT_OWNERDRAW))
    777         COMCTL32_Free (infoPtr->part0.text);
    778     COMCTL32_Free (infoPtr->parts);
     799        Free (infoPtr->part0.text);
     800    Free (infoPtr->parts);
    779801
    780802    /* delete default font */
     
    786808        DestroyWindow (infoPtr->hwndToolTip);
    787809
    788     COMCTL32_Free (infoPtr);
    789810    SetWindowLongW(infoPtr->Self, 0, 0);
     811    Free (infoPtr);
    790812    return 0;
    791813}
     
    803825
    804826    TRACE("\n");
    805     infoPtr = (STATUSWINDOWINFO*)COMCTL32_Alloc (sizeof(STATUSWINDOWINFO));
     827    infoPtr = (STATUSWINDOWINFO*)Alloc (sizeof(STATUSWINDOWINFO));
    806828    if (!infoPtr) goto create_fail;
    807829    SetWindowLongW (hwnd, 0, (DWORD)infoPtr);
    808830
    809831    infoPtr->Self = hwnd;
     832    infoPtr->Notify = lpCreate->hwndParent;
    810833    infoPtr->numParts = 1;
    811834    infoPtr->parts = 0;
     
    814837    infoPtr->hFont = 0;
    815838
    816     i = SendMessageW(GetParent (hwnd), WM_NOTIFYFORMAT, hwnd, NF_QUERY);
     839    i = SendMessageW(infoPtr->Notify, WM_NOTIFYFORMAT, (WPARAM)hwnd, NF_QUERY);
    817840    infoPtr->NtfUnicode = (i == NFR_UNICODE);
    818841
     
    834857
    835858    /* initialize first part */
    836     infoPtr->parts = COMCTL32_Alloc (sizeof(STATUSWINDOWPART));
     859    infoPtr->parts = Alloc (sizeof(STATUSWINDOWPART));
    837860    if (!infoPtr->parts) goto create_fail;
    838861    infoPtr->parts[0].bound = rect;
     
    846869        if (lpCreate->lpszName &&
    847870            (len = strlenW ((LPCWSTR)lpCreate->lpszName))) {
    848             infoPtr->parts[0].text = COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
     871            infoPtr->parts[0].text = Alloc ((len + 1)*sizeof(WCHAR));
    849872            if (!infoPtr->parts[0].text) goto create_fail;
    850873            strcpyW (infoPtr->parts[0].text, (LPCWSTR)lpCreate->lpszName);
     
    855878            (len = strlen((LPCSTR)lpCreate->lpszName))) {
    856879            DWORD lenW = MultiByteToWideChar( CP_ACP, 0, (LPCSTR)lpCreate->lpszName, -1, NULL, 0 );
    857             infoPtr->parts[0].text = COMCTL32_Alloc (lenW*sizeof(WCHAR));
     880            infoPtr->parts[0].text = Alloc (lenW*sizeof(WCHAR));
    858881            if (!infoPtr->parts[0].text) goto create_fail;
    859882            MultiByteToWideChar( CP_ACP, 0, (LPCSTR)lpCreate->lpszName, -1,
     
    871894#endif
    872895
    873     if ((hdc = GetDC (0))) {
     896    if ((hdc = GetDC (hwnd))) {
    874897        TEXTMETRICW tm;
    875898        HFONT hOldFont;
     
    879902        textHeight = tm.tmHeight;
    880903        SelectObject (hdc, hOldFont);
    881         ReleaseDC (0, hdc);
     904        ReleaseDC (hwnd, hdc);
    882905    }
    883906    TRACE("    textHeight=%d\n", textHeight);
     
    886909        infoPtr->hwndToolTip =
    887910            CreateWindowExW (0, TOOLTIPS_CLASSW, NULL, 0,
    888                                CW_USEDEFAULT, CW_USEDEFAULT,
    889                                CW_USEDEFAULT, CW_USEDEFAULT,
    890                              hwnd, 0,
    891                              GetWindowLongW (hwnd, GWL_HINSTANCE), NULL);
     911                             CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
     912                             CW_USEDEFAULT, hwnd, 0,
     913                             (HINSTANCE)GetWindowLongW(hwnd, GWL_HINSTANCE), NULL);
    892914
    893915        if (infoPtr->hwndToolTip) {
     
    901923            SendMessageW (lpCreate->hwndParent, WM_NOTIFY,
    902924                            (WPARAM)nmttc.hdr.idFrom, (LPARAM)&nmttc);
    903         } 
     925        }
    904926    }
    905927
    906928    if (!(dwStyle & CCS_NORESIZE)) { /* don't resize wnd if it doesn't want it ! */
    907         GetClientRect (GetParent (hwnd), &rect);
     929        GetClientRect (infoPtr->Notify, &rect);
    908930        width = rect.right - rect.left;
    909931        infoPtr->height = textHeight + 4 + VERT_BORDER;
     
    914936
    915937    return 0;
    916    
     938
    917939create_fail:
    918940    TRACE("    failed!\n");
     
    9931015{
    9941016    infoPtr->hFont = font;
    995     TRACE("%04x\n", infoPtr->hFont);
     1017    TRACE("%p\n", infoPtr->hFont);
    9961018    if (redraw)
    9971019        InvalidateRect(infoPtr->Self, NULL, FALSE);
     
    10141036    /* duplicate string */
    10151037    if (part->text)
    1016         COMCTL32_Free (part->text);
     1038        Free (part->text);
    10171039    part->text = 0;
    10181040    if (infoPtr->bUnicode) {
    10191041        if (text && (len = strlenW((LPCWSTR)text))) {
    1020             part->text = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
     1042            part->text = Alloc ((len+1)*sizeof(WCHAR));
    10211043            if (!part->text) return FALSE;
    10221044            strcpyW (part->text, (LPCWSTR)text);
     
    10261048        if (text && (len = lstrlenA(text))) {
    10271049            DWORD lenW = MultiByteToWideChar( CP_ACP, 0, text, -1, NULL, 0 );
    1028             part->text = COMCTL32_Alloc (lenW*sizeof(WCHAR));
     1050            part->text = Alloc (lenW*sizeof(WCHAR));
    10291051            if (!part->text) return FALSE;
    10301052            MultiByteToWideChar( CP_ACP, 0, text, -1, part->text, lenW );
     
    10391061
    10401062static BOOL
     1063#ifdef __WIN32OS2__
     1064STATUSBAR_WMSize (STATUSWINDOWINFO *infoPtr, WORD flags, LPARAM lParam)
     1065#else
    10411066STATUSBAR_WMSize (STATUSWINDOWINFO *infoPtr, WORD flags)
     1067#endif
    10421068{
    10431069    INT  width, x, y;
     
    10471073    TRACE("flags %04x\n", flags);
    10481074
    1049     if (flags != SIZE_RESTORED) {
    1050         WARN("flags MUST be SIZE_RESTORED\n");
     1075    if (flags != SIZE_RESTORED && flags != SIZE_MAXIMIZED)
     1076    {
     1077        WARN("flags MUST be SIZE_RESTORED or SIZE_MAXIMIZED\n");
    10511078        return FALSE;
    10521079    }
     1080
    10531081#ifdef __WIN32OS2__
    10541082    if (GetWindowLongW(infoPtr->Self, GWL_STYLE) & CCS_NORESIZE) {
     
    10571085        return FALSE;
    10581086    }
     1087
     1088    /* Invalidate the window if we need to draw a size grip */
     1089    /* TODO: The size grip area would be sufficient though */
     1090    if (GetWindowLongW (infoPtr->Self, GWL_STYLE) & SBARS_SIZEGRIP)
     1091    {
     1092        RECT rcWin;
     1093
     1094        GetClientRect(infoPtr->Self, &rcWin);
     1095        if(HIWORD(lParam) != (rcWin.bottom - rcWin.top) ||
     1096           LOWORD(lParam) != (rcWin.right  - rcWin.left))
     1097        {
     1098            TRACE("SBARS_SIZEGRIP && height/width changed -> invalidate window");
     1099            InvalidateRect(infoPtr->Self,NULL,TRUE);
     1100        }
     1101    }
    10591102#else
    10601103    if (GetWindowLongW(infoPtr->Self, GWL_STYLE) & CCS_NORESIZE) return FALSE;
     
    10621105
    10631106    /* width and height don't apply */
    1064     GetClientRect (GetParent(infoPtr->Self), &parent_rect);
     1107    GetClientRect (infoPtr->Notify, &parent_rect);
    10651108    width = parent_rect.right - parent_rect.left;
    10661109    x = parent_rect.left;
    10671110    y = parent_rect.bottom - infoPtr->height;
    1068     MoveWindow (infoPtr->Self, parent_rect.left, 
     1111    MoveWindow (infoPtr->Self, parent_rect.left,
    10691112                parent_rect.bottom - infoPtr->height,
    10701113                width, infoPtr->height, TRUE);
     
    10741117
    10751118
    1076 static LRESULT 
     1119static LRESULT
    10771120STATUSBAR_NotifyFormat (STATUSWINDOWINFO *infoPtr, HWND from, INT cmd)
    10781121{
    10791122    if (cmd == NF_REQUERY) {
    1080         INT i = SendMessageW(from, WM_NOTIFYFORMAT, infoPtr->Self, NF_QUERY);
     1123        INT i = SendMessageW(from, WM_NOTIFYFORMAT, (WPARAM)infoPtr->Self, NF_QUERY);
    10811124        infoPtr->NtfUnicode = (i == NFR_UNICODE);
    10821125    }
     
    10881131STATUSBAR_SendNotify (HWND hwnd, UINT code)
    10891132{
     1133    STATUSWINDOWINFO *infoPtr = STATUSBAR_GetInfoPtr(hwnd);
    10901134    NMHDR  nmhdr;
    10911135
     
    10941138    nmhdr.idFrom = GetWindowLongW (hwnd, GWL_ID);
    10951139    nmhdr.code = code;
    1096     SendMessageW (GetParent (hwnd), WM_NOTIFY, 0, (LPARAM)&nmhdr);
     1140    SendMessageW (infoPtr->Notify, WM_NOTIFY, 0, (LPARAM)&nmhdr);
    10971141    return 0;
    10981142}
     
    11071151    LRESULT res;
    11081152
    1109     TRACE("hwnd=%x msg=%x wparam=%x lparam=%lx\n", hwnd, msg, wParam, lParam);
     1153    TRACE("hwnd=%p msg=%x wparam=%x lparam=%lx\n", hwnd, msg, wParam, lParam);
    11101154    if (!infoPtr && msg != WM_CREATE)
    11111155        return DefWindowProcW (hwnd, msg, wParam, lParam);
     
    11161160
    11171161        case SB_GETICON:
    1118             return STATUSBAR_GetIcon (infoPtr, nPart);
     1162            return (LRESULT)STATUSBAR_GetIcon (infoPtr, nPart);
    11191163
    11201164        case SB_GETPARTS:
     
    11551199            return STATUSBAR_SetMinHeight (infoPtr, (INT)wParam);
    11561200
    1157         case SB_SETPARTS:       
     1201        case SB_SETPARTS:
    11581202            return STATUSBAR_SetParts (infoPtr, (INT)wParam, (LPINT)lParam);
    11591203
     
    11831227
    11841228        case WM_GETFONT:
    1185             return infoPtr->hFont? infoPtr->hFont : infoPtr->hDefaultFont;
     1229            return (LRESULT)(infoPtr->hFont? infoPtr->hFont : infoPtr->hDefaultFont);
    11861230
    11871231        case WM_GETTEXT:
     
    12081252        case WM_NCLBUTTONUP:
    12091253        case WM_NCLBUTTONDOWN:
    1210             PostMessageW (GetParent (hwnd), msg, wParam, lParam);
     1254            PostMessageW (infoPtr->Notify, msg, wParam, lParam);
    12111255            return 0;
    12121256
    12131257        case WM_NOTIFYFORMAT:
    12141258            return STATUSBAR_NotifyFormat(infoPtr, (HWND)wParam, (INT)lParam);
    1215            
     1259
    12161260        case WM_PAINT:
    12171261            return STATUSBAR_WMPaint (infoPtr, (HDC)wParam);
     
    12301274
    12311275        case WM_SIZE:
     1276#ifdef __WIN32OS2__
     1277            if (STATUSBAR_WMSize (infoPtr, (WORD)wParam, lParam)) return 0;
     1278#else
    12321279            if (STATUSBAR_WMSize (infoPtr, (WORD)wParam)) return 0;
     1280#endif
    12331281            return DefWindowProcW (hwnd, msg, wParam, lParam);
    12341282
    12351283        default:
    1236             if (msg >= WM_USER)
     1284            if ((msg >= WM_USER) && (msg < WM_APP))
    12371285                ERR("unknown msg %04x wp=%04x lp=%08lx\n",
    12381286                     msg, wParam, lParam);
     
    12591307    wndClass.cbClsExtra    = 0;
    12601308    wndClass.cbWndExtra    = sizeof(STATUSWINDOWINFO *);
    1261     wndClass.hCursor       = LoadCursorW (0, IDC_ARROWW);
     1309    wndClass.hCursor       = LoadCursorW (0, (LPWSTR)IDC_ARROWW);
    12621310    wndClass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
    12631311    wndClass.lpszClassName = STATUSCLASSNAMEW;
    1264  
     1312
    12651313    RegisterClassW (&wndClass);
    12661314}
     
    12761324STATUS_Unregister (void)
    12771325{
    1278     UnregisterClassW (STATUSCLASSNAMEW, (HINSTANCE)NULL);
    1279 }
    1280 
     1326    UnregisterClassW (STATUSCLASSNAMEW, NULL);
     1327}
Note: See TracChangeset for help on using the changeset viewer.