Changeset 1429 for trunk/src/user32/win32wmdiclient.cpp
- Timestamp:
- Oct 24, 1999, 2:30:29 PM (26 years ago)
- 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:08sandervl Exp $ */1 /* $Id: win32wmdiclient.cpp,v 1.9 1999-10-24 12:30:29 sandervl Exp $ */ 2 2 /* 3 3 * Win32 MDI Client Window Class for OS/2 … … 42 42 Win32MDIClientWindow::Win32MDIClientWindow(CREATESTRUCTA *lpCreateStructA, ATOM classAtom, BOOL isUnicode) 43 43 : 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), 45 45 sbRecalc(0), 46 46 Win32BaseWindow(OBJTYPE_WINDOW) … … 110 110 111 111 case WM_DESTROY: 112 // if( maximizedChild ) MDI_RestoreFrameMenu(w, frameWnd->hwndSelf);112 if( maximizedChild ) restoreFrameMenu(getParent()); 113 113 114 114 if((nItems = GetMenuItemCount(hWindowMenu)) > 0) … … 124 124 case WM_MDIACTIVATE: 125 125 if( activeChild && activeChild->getWindowHandle() != (HWND)wParam ) 126 127 128 129 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 } 132 132 retvalue = 0; 133 133 goto END; … … 154 154 155 155 case WM_MDIGETACTIVE: 156 dprintf(("WM_MDIGETACTIVE: %x %x", this, (activeChild) ? activeChild->getWindowHandle() : 0)); 156 157 if (lParam) 157 158 *(BOOL *)lParam = (maximizedChild != 0); … … 182 183 break; 183 184 184 185 185 case WM_MDIRESTORE: 186 186 ::SendMessageA( (HWND)wParam, WM_SYSCOMMAND, SC_RESTORE, 0); 187 187 retvalue = 0; 188 188 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 189 197 #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 198 198 case WM_MDITILE: 199 199 mdiFlags |= MDIF_NEEDUPDATE; … … 294 294 } 295 295 /********************************************************************** 296 * 296 * MDI_GetWindow 297 297 * 298 298 * returns "activateable" child different from the current or zero … … 316 316 if (!curchild->getOwner() && (curchild->getStyle() & dwStyleMask) == WS_VISIBLE ) 317 317 { 318 319 318 lastchild = curchild; 319 if ( bNext ) break; 320 320 } 321 321 } … … 366 366 } 367 367 368 dprintf(("childActivate: %x %x", this, child->getWindowHandle())); 368 369 activeChild = child; 369 370 … … 448 449 if( child == getMaximizedChild() ) 449 450 { 450 // MDI_RestoreFrameMenu(w_parent->parent,child);451 restoreFrameMenu(child); 451 452 setMaximizedChild(NULL); 452 453 updateFrameText(TRUE,NULL); … … 531 532 getParent()->SetWindowPos(0,0,0,0,0, SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER ); 532 533 } 534 /********************************************************************** 535 * MDISetMenu 536 */ 537 LRESULT 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); 533 584 #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 */ 596 LRESULT 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 */ 607 BOOL 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 536 656 */ 537 657 LONG Win32MDIClientWindow::cascade() 538 658 { 539 WND** 540 UINT 659 WND** ppWnd; 660 UINT total; 541 661 542 662 if (getMaximizedChild()) … … 546 666 547 667 if ((ppWnd = WIN_BuildWinArray(clientWnd, BWA_SKIPHIDDEN | BWA_SKIPOWNED | 548 549 { 550 WND**heapPtr = ppWnd;551 552 553 INTdelta = 0, n = 0;554 POINTpos[2];555 556 557 558 559 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 */ 560 680 while (*ppWnd) ppWnd++; 561 562 681 while (ppWnd != heapPtr) 682 { 563 683 ppWnd--; 564 684 565 566 685 MDI_CalcDefaultChildPos(clientWnd, n++, pos, delta); 686 SetWindowPos( (*ppWnd)->hwndSelf, 0, pos[0].x, pos[0].y, 567 687 pos[1].x, pos[1].y, 568 688 SWP_DRAWFRAME | SWP_NOACTIVATE | SWP_NOZORDER); 569 570 571 689 } 690 } 691 WIN_ReleaseWinArray(heapPtr); 572 692 } 573 693 … … 579 699 580 700 /********************************************************************** 581 * 701 * MDITile 582 702 */ 583 703 void Win32MDIClientWindow::MDITile(WPARAM wParam ) 584 704 { 585 WND** 586 UINT 705 WND** ppWnd; 706 UINT total = 0; 587 707 588 708 if (getMaximizedChild()) … … 592 712 593 713 ppWnd = WIN_BuildWinArray(wndClient, BWA_SKIPHIDDEN | BWA_SKIPOWNED | BWA_SKIPICONIC | 594 714 ((wParam & MDITILE_SKIPDISABLED)? BWA_SKIPDISABLED : 0), &total ); 595 715 596 716 TRACE("%u windows to tile\n", total); … … 598 718 if( ppWnd ) 599 719 { 600 WND**heapPtr = ppWnd;601 602 603 604 RECTrect;605 intx, y, xsize, ysize;606 introws, columns, r, c, i;607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 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); 641 761 y += ysize; 642 643 644 645 646 647 762 ppWnd++; 763 } 764 x += xsize; 765 } 766 } 767 WIN_ReleaseWinArray(heapPtr); 648 768 } 649 769 … … 654 774 655 775 /********************************************************************** 656 * 776 * MDI_AugmentFrameMenu 657 777 */ 658 778 BOOL Win32MDIClientWindow::augmentFrameMenu(HWND hChild ) 659 779 { 660 WND* 661 HMENU 780 WND* child = WIN_FindWndPtr(hChild); 781 HMENU hSysPopup = 0; 662 782 HBITMAP hSysMenuBitmap = 0; 663 783 … … 672 792 673 793 if (!(hSysPopup = LoadMenuA(GetModuleHandleA("USER32"), "SYSMENU"))) 674 794 return 0; 675 795 676 796 TRACE("\tgot popup %04x in sysmenu %04x\n", 677 797 hSysPopup, child->hSysMenu); 678 798 679 799 AppendMenuA(frame->wIDmenu,MF_HELP | MF_BITMAP, … … 722 842 { 723 843 TRACE("not inserted\n"); 724 725 844 DestroyMenu(hSysPopup); 845 return 0; 726 846 } 727 847 … … 745 865 746 866 /********************************************************************** 747 * 867 * MDI_RestoreFrameMenu 748 868 */ 749 869 static BOOL MDI_RestoreFrameMenu( WND *frameWnd, HWND hChild ) … … 756 876 757 877 if(!(iId == SC_RESTORE || iId == SC_CLOSE) ) 758 878 return 0; 759 879 760 880 /* … … 766 886 767 887 GetMenuItemInfoA(frameWnd->wIDmenu, 768 769 770 888 0, 889 TRUE, 890 &menuInfo); 771 891 772 892 RemoveMenu(frameWnd->wIDmenu,0,MF_BYPOSITION); 773 893 774 894 if ( (menuInfo.fType & MFT_BITMAP) && 775 776 895 (LOWORD(menuInfo.dwTypeData)!=0) && 896 (LOWORD(menuInfo.dwTypeData)!=hBmpClose) ) 777 897 { 778 898 DeleteObject((HBITMAP)LOWORD(menuInfo.dwTypeData));
Note:
See TracChangeset
for help on using the changeset viewer.