Ignore:
Timestamp:
Oct 24, 1999, 2:30:29 PM (26 years ago)
Author:
sandervl
Message:

MDI changes & fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/user32/win32wmdiclient.cpp

    r1361 r1429  
    1 /* $Id: win32wmdiclient.cpp,v 1.8 1999-10-19 18:02:08 sandervl Exp $ */
     1/* $Id: win32wmdiclient.cpp,v 1.9 1999-10-24 12:30:29 sandervl Exp $ */
    22/*
    33 * Win32 MDI Client Window Class for OS/2
     
    4242Win32MDIClientWindow::Win32MDIClientWindow(CREATESTRUCTA *lpCreateStructA, ATOM classAtom, BOOL isUnicode)
    4343                : maximizedChild(0), activeChild(0), nActiveChildren(0), nTotalCreated(0),
    44                   frameTitle(NULL), mdiFlags(0), idFirstChild(0), hWindowMenu(0), 
     44                  frameTitle(NULL), mdiFlags(0), idFirstChild(0), hWindowMenu(0),
    4545                  sbRecalc(0),
    4646                  Win32BaseWindow(OBJTYPE_WINDOW)
     
    110110
    111111    case WM_DESTROY:
    112 //        if( maximizedChild ) MDI_RestoreFrameMenu(w, frameWnd->hwndSelf);
     112        if( maximizedChild ) restoreFrameMenu(getParent());
    113113
    114114        if((nItems = GetMenuItemCount(hWindowMenu)) > 0)
     
    124124    case WM_MDIACTIVATE:
    125125        if( activeChild && activeChild->getWindowHandle() != (HWND)wParam )
    126         {
    127                 mdichild = (Win32MDIChildWindow *)GetWindowFromHandle((HWND)wParam);
    128                 if(mdichild) {
    129                     mdichild->SetWindowPos(0,0,0,0,0, SWP_NOSIZE | SWP_NOMOVE);
    130                 }
    131         }
     126        {
     127            mdichild = (Win32MDIChildWindow *)GetWindowFromHandle((HWND)wParam);
     128            if(mdichild) {
     129                mdichild->SetWindowPos(0,0,0,0,0, SWP_NOSIZE | SWP_NOMOVE);
     130            }
     131        }
    132132        retvalue = 0;
    133133        goto END;
     
    154154
    155155    case WM_MDIGETACTIVE:
     156        dprintf(("WM_MDIGETACTIVE: %x %x", this, (activeChild) ? activeChild->getWindowHandle() : 0));
    156157        if (lParam)
    157158            *(BOOL *)lParam = (maximizedChild != 0);
     
    182183        break;
    183184
    184 
    185185    case WM_MDIRESTORE:
    186186        ::SendMessageA( (HWND)wParam, WM_SYSCOMMAND, SC_RESTORE, 0);
    187187        retvalue = 0;
    188188        goto END;
     189    case WM_MDISETMENU:
     190        retvalue = setMDIMenu((HMENU)wParam, (HMENU)lParam );
     191        goto END;
     192
     193    case WM_MDIREFRESHMENU:
     194        retvalue = refreshMDIMenu((HMENU)wParam, (HMENU)lParam );
     195        goto END;
     196
    189197#if 0
    190     case WM_MDISETMENU:
    191         retvalue = MDISetMenu( hwnd, (HMENU)wParam, (HMENU)lParam );
    192         goto END;
    193 
    194     case WM_MDIREFRESHMENU:
    195         retvalue = MDIRefreshMenu( hwnd, (HMENU)wParam, (HMENU)lParam );
    196         goto END;
    197 
    198198    case WM_MDITILE:
    199199        mdiFlags |= MDIF_NEEDUPDATE;
     
    294294}
    295295/**********************************************************************
    296  *                      MDI_GetWindow
     296 *          MDI_GetWindow
    297297 *
    298298 * returns "activateable" child different from the current or zero
     
    316316        if (!curchild->getOwner() && (curchild->getStyle() & dwStyleMask) == WS_VISIBLE )
    317317        {
    318                 lastchild = curchild;
    319                 if ( bNext ) break;
     318            lastchild = curchild;
     319            if ( bNext ) break;
    320320        }
    321321    }
     
    366366    }
    367367
     368    dprintf(("childActivate: %x %x", this, child->getWindowHandle()));
    368369    activeChild = child;
    369370
     
    448449            if( child == getMaximizedChild() )
    449450            {
    450 //                MDI_RestoreFrameMenu(w_parent->parent, child);
     451                restoreFrameMenu(child);
    451452                setMaximizedChild(NULL);
    452453                updateFrameText(TRUE,NULL);
     
    531532        getParent()->SetWindowPos(0,0,0,0,0, SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER );
    532533}
     534/**********************************************************************
     535 *            MDISetMenu
     536 */
     537LRESULT Win32MDIClientWindow::setMDIMenu(HMENU hmenuFrame, HMENU hmenuWindow)
     538{
     539    HWND hwndFrame = ::GetParent(getWindowHandle());
     540    HMENU oldFrameMenu = ::GetMenu(hwndFrame);
     541
     542    if( maximizedChild && hmenuFrame && hmenuFrame!=oldFrameMenu )
     543        restoreFrameMenu(maximizedChild);
     544
     545    if( hmenuWindow && hmenuWindow != hWindowMenu )
     546    {
     547        /* delete menu items from ci->hWindowMenu
     548         * and add them to hmenuWindow */
     549
     550        INT i = GetMenuItemCount(hWindowMenu) - 1;
     551        INT pos = GetMenuItemCount(hmenuWindow) + 1;
     552
     553        AppendMenuA( hmenuWindow, MF_SEPARATOR, 0, NULL);
     554
     555        if( nActiveChildren )
     556        {
     557            INT j = i - nActiveChildren + 1;
     558            char buffer[100];
     559            UINT id,state;
     560
     561            for( ; i >= j ; i-- )
     562            {
     563                id = GetMenuItemID(hWindowMenu,i );
     564                state = GetMenuState(hWindowMenu,i,MF_BYPOSITION);
     565
     566                GetMenuStringA(hWindowMenu, i, buffer, 100, MF_BYPOSITION);
     567
     568                DeleteMenu(hWindowMenu, i , MF_BYPOSITION);
     569                InsertMenuA(hmenuWindow, pos, MF_BYPOSITION | MF_STRING,
     570                              id, buffer);
     571                CheckMenuItem(hmenuWindow ,pos , MF_BYPOSITION | (state & MF_CHECKED));
     572            }
     573        }
     574
     575        /* remove separator */
     576        DeleteMenu(hWindowMenu, i, MF_BYPOSITION);
     577
     578        hWindowMenu = hmenuWindow;
     579    }
     580
     581    if( hmenuFrame && hmenuFrame!=oldFrameMenu)
     582    {
     583        ::SetMenu(hwndFrame, hmenuFrame);
    533584#if 0
    534 /**********************************************************************
    535  *                              MDICascade
     585        if( ci->hwndChildMaximized )
     586            MDI_AugmentFrameMenu(ci, w->parent, ci->hwndChildMaximized );
     587#endif
     588        return oldFrameMenu;
     589    }
     590    return 0;
     591}
     592
     593/**********************************************************************
     594 *            MDIRefreshMenu
     595 */
     596LRESULT Win32MDIClientWindow::refreshMDIMenu(HMENU hmenuFrame, HMENU hmenuWindow)
     597{
     598    HMENU oldFrameMenu = getParent()->GetMenu();
     599
     600//    FIXME("partially function stub\n");
     601
     602    return oldFrameMenu;
     603}
     604/**********************************************************************
     605 *                                      MDI_RestoreFrameMenu
     606 */
     607BOOL Win32MDIClientWindow::restoreFrameMenu(Win32BaseWindow *child)
     608{
     609    MENUITEMINFOA menuInfo;
     610    INT nItems = GetMenuItemCount(getParent()->GetMenu()) - 1;
     611    UINT iId = GetMenuItemID(getParent()->GetMenu(),nItems) ;
     612
     613    if(!(iId == SC_RESTORE || iId == SC_CLOSE) )
     614            return 0;
     615
     616    /*
     617     * Remove the system menu, If that menu is the icon of the window
     618     * as it is in win95, we have to delete the bitmap.
     619     */
     620    menuInfo.cbSize = sizeof(MENUITEMINFOA);
     621    menuInfo.fMask  = MIIM_DATA | MIIM_TYPE;
     622
     623    GetMenuItemInfoA(getParent()->GetMenu(),
     624                             0,
     625                             TRUE,
     626                             &menuInfo);
     627
     628    RemoveMenu(getParent()->GetMenu(),0,MF_BYPOSITION);
     629
     630//TODO: See augmentframemenu
     631#if 0
     632    if ((menuInfo.fType & MFT_BITMAP)           &&
     633            (LOWORD(menuInfo.dwTypeData)!=0)        &&
     634            (LOWORD(menuInfo.dwTypeData)!=hBmpClose) )
     635    {
     636        DeleteObject((HBITMAP)LOWORD(menuInfo.dwTypeData));
     637    }
     638#endif
     639
     640    /* close */
     641    DeleteMenu(getParent()->GetMenu(),GetMenuItemCount(getParent()->GetMenu()) - 1,MF_BYPOSITION);
     642
     643    /* restore */
     644    DeleteMenu(getParent()->GetMenu(),GetMenuItemCount(getParent()->GetMenu()) - 1,MF_BYPOSITION);
     645    /* minimize */
     646    DeleteMenu(getParent()->GetMenu(),GetMenuItemCount(getParent()->GetMenu()) - 1,MF_BYPOSITION);
     647
     648    DrawMenuBar(getParent()->getWindowHandle());
     649
     650    return 1;
     651}
     652
     653#if 0
     654/**********************************************************************
     655 *              MDICascade
    536656 */
    537657LONG Win32MDIClientWindow::cascade()
    538658{
    539     WND**       ppWnd;
    540     UINT        total;
     659    WND**   ppWnd;
     660    UINT    total;
    541661
    542662    if (getMaximizedChild())
     
    546666
    547667    if ((ppWnd = WIN_BuildWinArray(clientWnd, BWA_SKIPHIDDEN | BWA_SKIPOWNED |
    548                                               BWA_SKIPICONIC, &total)))
    549     {
    550             WND**       heapPtr = ppWnd;
    551             if( total )
    552             {
    553             INT delta = 0, n = 0;
    554             POINT       pos[2];
    555             if( total < ci->nActiveChildren )
    556                 delta = GetSystemMetrics(SM_CYICONSPACING) +
    557                 GetSystemMetrics(SM_CYICON);
    558 
    559                 /* walk the list (backwards) and move windows */
     668                          BWA_SKIPICONIC, &total)))
     669    {
     670        WND**   heapPtr = ppWnd;
     671        if( total )
     672        {
     673            INT delta = 0, n = 0;
     674            POINT   pos[2];
     675            if( total < ci->nActiveChildren )
     676                delta = GetSystemMetrics(SM_CYICONSPACING) +
     677            GetSystemMetrics(SM_CYICON);
     678
     679            /* walk the list (backwards) and move windows */
    560680            while (*ppWnd) ppWnd++;
    561                     while (ppWnd != heapPtr)
    562                     {
     681                while (ppWnd != heapPtr)
     682                {
    563683                    ppWnd--;
    564684
    565                         MDI_CalcDefaultChildPos(clientWnd, n++, pos, delta);
    566                             SetWindowPos( (*ppWnd)->hwndSelf, 0, pos[0].x, pos[0].y,
     685                    MDI_CalcDefaultChildPos(clientWnd, n++, pos, delta);
     686                    SetWindowPos( (*ppWnd)->hwndSelf, 0, pos[0].x, pos[0].y,
    567687                                pos[1].x, pos[1].y,
    568688                                SWP_DRAWFRAME | SWP_NOACTIVATE | SWP_NOZORDER);
    569                     }
    570             }
    571             WIN_ReleaseWinArray(heapPtr);
     689                }
     690        }
     691        WIN_ReleaseWinArray(heapPtr);
    572692    }
    573693
     
    579699
    580700/**********************************************************************
    581  *                                      MDITile
     701 *                  MDITile
    582702 */
    583703void Win32MDIClientWindow::MDITile(WPARAM wParam )
    584704{
    585     WND**       ppWnd;
    586     UINT        total = 0;
     705    WND**   ppWnd;
     706    UINT    total = 0;
    587707
    588708    if (getMaximizedChild())
     
    592712
    593713    ppWnd = WIN_BuildWinArray(wndClient, BWA_SKIPHIDDEN | BWA_SKIPOWNED | BWA_SKIPICONIC |
    594                 ((wParam & MDITILE_SKIPDISABLED)? BWA_SKIPDISABLED : 0), &total );
     714            ((wParam & MDITILE_SKIPDISABLED)? BWA_SKIPDISABLED : 0), &total );
    595715
    596716    TRACE("%u windows to tile\n", total);
     
    598718    if( ppWnd )
    599719    {
    600         WND**   heapPtr = ppWnd;
    601 
    602             if( total )
    603             {
    604             RECT        rect;
    605             int         x, y, xsize, ysize;
    606             int         rows, columns, r, c, i;
    607 
    608             GetClientRect(wndClient->hwndSelf,&rect);
    609             rows    = (int) sqrt((double)total);
    610             columns = total / rows;
    611 
    612             if( wParam & MDITILE_HORIZONTAL )  /* version >= 3.1 */
    613             {
    614                 i = rows;
    615                 rows = columns;  /* exchange r and c */
    616                 columns = i;
    617             }
    618 
    619             if( total != ci->nActiveChildren)
    620             {
    621                 y = rect.bottom - 2 * GetSystemMetrics(SM_CYICONSPACING) - GetSystemMetrics(SM_CYICON);
    622                 rect.bottom = ( y - GetSystemMetrics(SM_CYICON) < rect.top )? rect.bottom: y;
    623             }
    624 
    625                 ysize   = rect.bottom / rows;
    626             xsize   = rect.right  / columns;
    627 
    628             for (x = i = 0, c = 1; c <= columns && *ppWnd; c++)
    629             {
    630                 if (c == columns)
    631                         {
    632                         rows  = total - i;
    633                             ysize = rect.bottom / rows;
    634                         }
    635 
    636                         y = 0;
    637                         for (r = 1; r <= rows && *ppWnd; r++, i++)
    638                         {
    639                             SetWindowPos((*ppWnd)->hwndSelf, 0, x, y, xsize, ysize,
    640                                         SWP_DRAWFRAME | SWP_NOACTIVATE | SWP_NOZORDER);
     720        WND**   heapPtr = ppWnd;
     721
     722        if( total )
     723        {
     724            RECT    rect;
     725            int     x, y, xsize, ysize;
     726            int     rows, columns, r, c, i;
     727
     728            GetClientRect(wndClient->hwndSelf,&rect);
     729            rows    = (int) sqrt((double)total);
     730            columns = total / rows;
     731
     732            if( wParam & MDITILE_HORIZONTAL )  /* version >= 3.1 */
     733            {
     734                i = rows;
     735                rows = columns;  /* exchange r and c */
     736                columns = i;
     737            }
     738
     739            if( total != ci->nActiveChildren)
     740            {
     741                y = rect.bottom - 2 * GetSystemMetrics(SM_CYICONSPACING) - GetSystemMetrics(SM_CYICON);
     742                rect.bottom = ( y - GetSystemMetrics(SM_CYICON) < rect.top )? rect.bottom: y;
     743            }
     744
     745            ysize   = rect.bottom / rows;
     746            xsize   = rect.right  / columns;
     747
     748            for (x = i = 0, c = 1; c <= columns && *ppWnd; c++)
     749            {
     750                if (c == columns)
     751                {
     752                    rows  = total - i;
     753                    ysize = rect.bottom / rows;
     754                }
     755
     756                y = 0;
     757                for (r = 1; r <= rows && *ppWnd; r++, i++)
     758                {
     759                    SetWindowPos((*ppWnd)->hwndSelf, 0, x, y, xsize, ysize,
     760                        SWP_DRAWFRAME | SWP_NOACTIVATE | SWP_NOZORDER);
    641761                            y += ysize;
    642                             ppWnd++;
    643                         }
    644                         x += xsize;
    645                 }
    646         }
    647         WIN_ReleaseWinArray(heapPtr);
     762                    ppWnd++;
     763                }
     764                x += xsize;
     765            }
     766    }
     767    WIN_ReleaseWinArray(heapPtr);
    648768    }
    649769
     
    654774
    655775/**********************************************************************
    656  *                                      MDI_AugmentFrameMenu
     776 *                  MDI_AugmentFrameMenu
    657777 */
    658778BOOL Win32MDIClientWindow::augmentFrameMenu(HWND hChild )
    659779{
    660     WND*        child = WIN_FindWndPtr(hChild);
    661     HMENU       hSysPopup = 0;
     780    WND*    child = WIN_FindWndPtr(hChild);
     781    HMENU   hSysPopup = 0;
    662782    HBITMAP hSysMenuBitmap = 0;
    663783
     
    672792
    673793    if (!(hSysPopup = LoadMenuA(GetModuleHandleA("USER32"), "SYSMENU")))
    674         return 0;
     794    return 0;
    675795
    676796    TRACE("\tgot popup %04x in sysmenu %04x\n",
    677                 hSysPopup, child->hSysMenu);
     797        hSysPopup, child->hSysMenu);
    678798
    679799    AppendMenuA(frame->wIDmenu,MF_HELP | MF_BITMAP,
     
    722842    {
    723843        TRACE("not inserted\n");
    724         DestroyMenu(hSysPopup);
    725         return 0;
     844    DestroyMenu(hSysPopup);
     845    return 0;
    726846    }
    727847
     
    745865
    746866/**********************************************************************
    747  *                                      MDI_RestoreFrameMenu
     867 *                  MDI_RestoreFrameMenu
    748868 */
    749869static BOOL MDI_RestoreFrameMenu( WND *frameWnd, HWND hChild )
     
    756876
    757877    if(!(iId == SC_RESTORE || iId == SC_CLOSE) )
    758         return 0;
     878    return 0;
    759879
    760880    /*
     
    766886
    767887    GetMenuItemInfoA(frameWnd->wIDmenu,
    768                      0,
    769                      TRUE,
    770                      &menuInfo);
     888             0,
     889             TRUE,
     890             &menuInfo);
    771891
    772892    RemoveMenu(frameWnd->wIDmenu,0,MF_BYPOSITION);
    773893
    774894    if ( (menuInfo.fType & MFT_BITMAP)           &&
    775         (LOWORD(menuInfo.dwTypeData)!=0)        &&
    776         (LOWORD(menuInfo.dwTypeData)!=hBmpClose) )
     895    (LOWORD(menuInfo.dwTypeData)!=0)        &&
     896    (LOWORD(menuInfo.dwTypeData)!=hBmpClose) )
    777897    {
    778898      DeleteObject((HBITMAP)LOWORD(menuInfo.dwTypeData));
Note: See TracChangeset for help on using the changeset viewer.