Changeset 808 for trunk/src/user32/new/win32wmdiclient.cpp
- Timestamp:
- Sep 3, 1999, 5:09:46 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/new/win32wmdiclient.cpp
r760 r808 1 /* $Id: win32wmdiclient.cpp,v 1. 3 1999-08-31 17:14:52sandervl Exp $ */1 /* $Id: win32wmdiclient.cpp,v 1.4 1999-09-03 15:09:46 sandervl Exp $ */ 2 2 /* 3 3 * Win32 MDI Client Window Class for OS/2 … … 51 51 idFirstChild = 0; 52 52 hWindowMenu = 0; 53 sbRecalc = 0; 53 54 } 54 55 //****************************************************************************** … … 56 57 Win32MDIClientWindow::~Win32MDIClientWindow() 57 58 { 59 if(frameTitle) 60 HeapFree(GetProcessHeap(), 0, frameTitle); 58 61 } 59 62 //****************************************************************************** … … 92 95 setStyle(getStyle() | WS_CLIPCHILDREN); 93 96 94 // MDI_UpdateFrameText(frameWnd, hwnd, MDI_NOFRAMEREPAINT,frameWnd->text);97 updateFrameText(MDI_NOFRAMEREPAINT, getParent()->getWindowNameA()); 95 98 96 99 AppendMenuA( hWindowMenu, MF_SEPARATOR, 0, NULL ); … … 140 143 141 144 case WM_MDIDESTROY: 142 // retvalue = MDIDestroyChild( w, ci, hwnd, (HWND)wParam, TRUE ); 145 mdichild = (Win32MDIChildWindow *)GetWindowFromHandle((HWND)wParam); 146 if(mdichild) { 147 retvalue = destroyChild(mdichild, TRUE ); 148 } 143 149 goto END; 144 150 … … 166 172 167 173 case WM_MDINEXT: /* lParam != 0 means previous window */ 168 // MDI_SwitchActiveChild(hwnd, (HWND)wParam, (lParam)? FALSE : TRUE ); 174 mdichild = (Win32MDIChildWindow *)GetWindowFromHandle((HWND)wParam); 175 if(mdichild) { 176 switchActiveChild(mdichild, (lParam)? FALSE : TRUE ); 177 } 169 178 break; 179 170 180 171 181 case WM_MDIRESTORE: … … 243 253 ::MoveWindow(maximizedChild->getWindowHandle(), rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, 1); 244 254 } 245 #if 0 246 else 247 MDI_PostUpdate(hwnd, ci, SB_BOTH+1); 248 #endif 255 else postUpdate(SB_BOTH+1); 249 256 break; 250 257 … … 281 288 } 282 289 return window->MDIClientWndProc(message, wParam, lParam); 290 } 291 /********************************************************************** 292 * MDI_GetWindow 293 * 294 * returns "activateable" child different from the current or zero 295 */ 296 Win32MDIChildWindow *Win32MDIClientWindow::getWindow(Win32MDIChildWindow *actchild, BOOL bNext, 297 DWORD dwStyleMask) 298 { 299 Win32MDIChildWindow *lastchild = 0, *curchild; 300 301 dwStyleMask |= WS_DISABLED | WS_VISIBLE; 302 303 if( !actchild ) actchild = getActiveChild(); 304 if( !actchild) return 0; 305 306 for ( curchild = (Win32MDIChildWindow *)actchild->getNextChild(); ; curchild = (Win32MDIChildWindow *)curchild->getNextChild()) 307 { 308 if (!curchild ) curchild = (Win32MDIChildWindow *)getFirstChild(); 309 310 if ( curchild == actchild ) break; /* went full circle */ 311 312 if (!curchild->getOwner() && (curchild->getStyle() & dwStyleMask) == WS_VISIBLE ) 313 { 314 lastchild = curchild; 315 if ( bNext ) break; 316 } 317 } 318 return lastchild; 283 319 } 284 320 /********************************************************************** … … 406 442 { 407 443 // MDI_RestoreFrameMenu(w_parent->parent, child); 408 409 // MDI_UpdateFrameText(w_parent->parent,parent,TRUE,NULL);444 setMaximizedChild(NULL); 445 updateFrameText(TRUE,NULL); 410 446 } 411 447 childActivate(0); … … 426 462 return 0; 427 463 } 464 /********************************************************************** 465 * MDI_UpdateFrameText 466 * 467 * used when child window is maximized/restored 468 * 469 * Note: lpTitle can be NULL 470 */ 471 void Win32MDIClientWindow::updateFrameText(BOOL repaint, LPCSTR lpTitle ) 472 { 473 char lpBuffer[MDI_MAXTITLELENGTH+1]; 474 475 /* store new "default" title if lpTitle is not NULL */ 476 if (lpTitle) 477 { 478 if (frameTitle) HeapFree( GetProcessHeap(), 0, frameTitle ); 479 frameTitle = HEAP_strdupA( GetProcessHeap(), 0, lpTitle ); 480 } 481 482 if (frameTitle) 483 { 484 Win32MDIChildWindow *childWnd = getMaximizedChild(); 485 486 if( childWnd && childWnd->getWindowNameA() ) 487 { 488 /* combine frame title and child title if possible */ 489 490 LPCSTR lpBracket = " - ["; 491 int i_frame_text_length = strlen(frameTitle); 492 int i_child_text_length = strlen(childWnd->getWindowNameA()); 493 494 lstrcpynA( lpBuffer, frameTitle, MDI_MAXTITLELENGTH); 495 496 if( i_frame_text_length + 6 < MDI_MAXTITLELENGTH ) 497 { 498 strcat( lpBuffer, lpBracket ); 499 500 if( i_frame_text_length + i_child_text_length + 6 < MDI_MAXTITLELENGTH ) 501 { 502 strcat( lpBuffer, childWnd->getWindowNameA()); 503 strcat( lpBuffer, "]" ); 504 } 505 else 506 { 507 lstrcpynA(lpBuffer + i_frame_text_length + 4, 508 childWnd->getWindowNameA(), MDI_MAXTITLELENGTH - i_frame_text_length - 5 ); 509 strcat( lpBuffer, "]" ); 510 } 511 } 512 } 513 else 514 { 515 strncpy(lpBuffer, frameTitle, MDI_MAXTITLELENGTH ); 516 lpBuffer[MDI_MAXTITLELENGTH]='\0'; 517 } 518 } 519 else 520 lpBuffer[0] = '\0'; 521 522 getParent()->SetWindowText(lpBuffer); 523 if( repaint == MDI_REPAINTFRAME) 524 getParent()->SetWindowPos(0,0,0,0,0, SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER ); 525 } 526 #if 0 527 /********************************************************************** 528 * MDICascade 529 */ 530 LONG Win32MDIClientWindow::cascade() 531 { 532 WND** ppWnd; 533 UINT total; 534 535 if (getMaximizedChild()) 536 SendMessageA(WM_MDIRESTORE, (WPARAM)getMaximizedChild()->getWindowHandle(), 0); 537 538 if (nActiveChildren == 0) return 0; 539 540 if ((ppWnd = WIN_BuildWinArray(clientWnd, BWA_SKIPHIDDEN | BWA_SKIPOWNED | 541 BWA_SKIPICONIC, &total))) 542 { 543 WND** heapPtr = ppWnd; 544 if( total ) 545 { 546 INT delta = 0, n = 0; 547 POINT pos[2]; 548 if( total < ci->nActiveChildren ) 549 delta = GetSystemMetrics(SM_CYICONSPACING) + 550 GetSystemMetrics(SM_CYICON); 551 552 /* walk the list (backwards) and move windows */ 553 while (*ppWnd) ppWnd++; 554 while (ppWnd != heapPtr) 555 { 556 ppWnd--; 557 558 MDI_CalcDefaultChildPos(clientWnd, n++, pos, delta); 559 SetWindowPos( (*ppWnd)->hwndSelf, 0, pos[0].x, pos[0].y, 560 pos[1].x, pos[1].y, 561 SWP_DRAWFRAME | SWP_NOACTIVATE | SWP_NOZORDER); 562 } 563 } 564 WIN_ReleaseWinArray(heapPtr); 565 } 566 567 if( total < ci->nActiveChildren ) 568 ArrangeIconicWindows( clientWnd->hwndSelf ); 569 570 return 0; 571 } 572 573 /********************************************************************** 574 * MDITile 575 */ 576 void Win32MDIClientWindow::MDITile(WPARAM wParam ) 577 { 578 WND** ppWnd; 579 UINT total = 0; 580 581 if (getMaximizedChild()) 582 SendMessageA(WM_MDIRESTORE, (WPARAM)getMaximizedChild()->getWindowHandle(), 0); 583 584 if (nActiveChildren == 0) return; 585 586 ppWnd = WIN_BuildWinArray(wndClient, BWA_SKIPHIDDEN | BWA_SKIPOWNED | BWA_SKIPICONIC | 587 ((wParam & MDITILE_SKIPDISABLED)? BWA_SKIPDISABLED : 0), &total ); 588 589 TRACE("%u windows to tile\n", total); 590 591 if( ppWnd ) 592 { 593 WND** heapPtr = ppWnd; 594 595 if( total ) 596 { 597 RECT rect; 598 int x, y, xsize, ysize; 599 int rows, columns, r, c, i; 600 601 GetClientRect(wndClient->hwndSelf,&rect); 602 rows = (int) sqrt((double)total); 603 columns = total / rows; 604 605 if( wParam & MDITILE_HORIZONTAL ) /* version >= 3.1 */ 606 { 607 i = rows; 608 rows = columns; /* exchange r and c */ 609 columns = i; 610 } 611 612 if( total != ci->nActiveChildren) 613 { 614 y = rect.bottom - 2 * GetSystemMetrics(SM_CYICONSPACING) - GetSystemMetrics(SM_CYICON); 615 rect.bottom = ( y - GetSystemMetrics(SM_CYICON) < rect.top )? rect.bottom: y; 616 } 617 618 ysize = rect.bottom / rows; 619 xsize = rect.right / columns; 620 621 for (x = i = 0, c = 1; c <= columns && *ppWnd; c++) 622 { 623 if (c == columns) 624 { 625 rows = total - i; 626 ysize = rect.bottom / rows; 627 } 628 629 y = 0; 630 for (r = 1; r <= rows && *ppWnd; r++, i++) 631 { 632 SetWindowPos((*ppWnd)->hwndSelf, 0, x, y, xsize, ysize, 633 SWP_DRAWFRAME | SWP_NOACTIVATE | SWP_NOZORDER); 634 y += ysize; 635 ppWnd++; 636 } 637 x += xsize; 638 } 639 } 640 WIN_ReleaseWinArray(heapPtr); 641 } 642 643 if( total < ci->nActiveChildren ) ArrangeIconicWindows( wndClient->hwndSelf ); 644 } 645 646 /* ----------------------- Frame window ---------------------------- */ 647 648 /********************************************************************** 649 * MDI_AugmentFrameMenu 650 */ 651 BOOL Win32MDIClientWindow::augmentFrameMenu(HWND hChild ) 652 { 653 WND* child = WIN_FindWndPtr(hChild); 654 HMENU hSysPopup = 0; 655 HBITMAP hSysMenuBitmap = 0; 656 657 if( !frame->wIDmenu || !child->hSysMenu ) 658 { 659 WIN_ReleaseWndPtr(child); 660 return 0; 661 } 662 WIN_ReleaseWndPtr(child); 663 664 /* create a copy of sysmenu popup and insert it into frame menu bar */ 665 666 if (!(hSysPopup = LoadMenuA(GetModuleHandleA("USER32"), "SYSMENU"))) 667 return 0; 668 669 TRACE("\tgot popup %04x in sysmenu %04x\n", 670 hSysPopup, child->hSysMenu); 671 672 AppendMenuA(frame->wIDmenu,MF_HELP | MF_BITMAP, 673 SC_MINIMIZE, (LPSTR)(DWORD)HBMMENU_MBAR_MINIMIZE ) ; 674 AppendMenuA(frame->wIDmenu,MF_HELP | MF_BITMAP, 675 SC_RESTORE, (LPSTR)(DWORD)HBMMENU_MBAR_RESTORE ); 676 677 /* In Win 95 look, the system menu is replaced by the child icon */ 678 679 if(TWEAK_WineLook > WIN31_LOOK) 680 { 681 HICON hIcon = GetClassLongA(hChild, GCL_HICONSM); 682 if (!hIcon) 683 hIcon = GetClassLongA(hChild, GCL_HICON); 684 if (hIcon) 685 { 686 HDC hMemDC; 687 HBITMAP hBitmap, hOldBitmap; 688 HBRUSH hBrush; 689 HDC hdc = GetDC(hChild); 690 691 if (hdc) 692 { 693 int cx, cy; 694 cx = GetSystemMetrics(SM_CXSMICON); 695 cy = GetSystemMetrics(SM_CYSMICON); 696 hMemDC = CreateCompatibleDC(hdc); 697 hBitmap = CreateCompatibleBitmap(hdc, cx, cy); 698 hOldBitmap = SelectObject(hMemDC, hBitmap); 699 SetMapMode(hMemDC, MM_TEXT); 700 hBrush = CreateSolidBrush(GetSysColor(COLOR_MENU)); 701 DrawIconEx(hMemDC, 0, 0, hIcon, cx, cy, 0, hBrush, DI_NORMAL); 702 SelectObject (hMemDC, hOldBitmap); 703 DeleteObject(hBrush); 704 DeleteDC(hMemDC); 705 ReleaseDC(hChild, hdc); 706 hSysMenuBitmap = hBitmap; 707 } 708 } 709 } 710 else 711 hSysMenuBitmap = hBmpClose; 712 713 if( !InsertMenuA(frame->wIDmenu,0,MF_BYPOSITION | MF_BITMAP | MF_POPUP, 714 hSysPopup, (LPSTR)(DWORD)hSysMenuBitmap)) 715 { 716 TRACE("not inserted\n"); 717 DestroyMenu(hSysPopup); 718 return 0; 719 } 720 721 /* The close button is only present in Win 95 look */ 722 if(TWEAK_WineLook > WIN31_LOOK) 723 { 724 AppendMenuA(frame->wIDmenu,MF_HELP | MF_BITMAP, 725 SC_CLOSE, (LPSTR)(DWORD)HBMMENU_MBAR_CLOSE ); 726 } 727 728 EnableMenuItem(hSysPopup, SC_SIZE, MF_BYCOMMAND | MF_GRAYED); 729 EnableMenuItem(hSysPopup, SC_MOVE, MF_BYCOMMAND | MF_GRAYED); 730 EnableMenuItem(hSysPopup, SC_MAXIMIZE, MF_BYCOMMAND | MF_GRAYED); 731 SetMenuDefaultItem(hSysPopup, SC_CLOSE, FALSE); 732 733 /* redraw menu */ 734 DrawMenuBar(frame->hwndSelf); 735 736 return 1; 737 } 738 739 /********************************************************************** 740 * MDI_RestoreFrameMenu 741 */ 742 static BOOL MDI_RestoreFrameMenu( WND *frameWnd, HWND hChild ) 743 { 744 MENUITEMINFOA menuInfo; 745 INT nItems = GetMenuItemCount(frameWnd->wIDmenu) - 1; 746 UINT iId = GetMenuItemID(frameWnd->wIDmenu,nItems) ; 747 748 TRACE("frameWnd %p,child %04x\n",frameWnd,hChild); 749 750 if(!(iId == SC_RESTORE || iId == SC_CLOSE) ) 751 return 0; 752 753 /* 754 * Remove the system menu, If that menu is the icon of the window 755 * as it is in win95, we have to delete the bitmap. 756 */ 757 menuInfo.cbSize = sizeof(MENUITEMINFOA); 758 menuInfo.fMask = MIIM_DATA | MIIM_TYPE; 759 760 GetMenuItemInfoA(frameWnd->wIDmenu, 761 0, 762 TRUE, 763 &menuInfo); 764 765 RemoveMenu(frameWnd->wIDmenu,0,MF_BYPOSITION); 766 767 if ( (menuInfo.fType & MFT_BITMAP) && 768 (LOWORD(menuInfo.dwTypeData)!=0) && 769 (LOWORD(menuInfo.dwTypeData)!=hBmpClose) ) 770 { 771 DeleteObject((HBITMAP)LOWORD(menuInfo.dwTypeData)); 772 } 773 774 if(TWEAK_WineLook > WIN31_LOOK) 775 { 776 /* close */ 777 DeleteMenu(frameWnd->wIDmenu,GetMenuItemCount(frameWnd->wIDmenu) - 1,MF_BYPOSITION); 778 } 779 /* restore */ 780 DeleteMenu(frameWnd->wIDmenu,GetMenuItemCount(frameWnd->wIDmenu) - 1,MF_BYPOSITION); 781 /* minimize */ 782 DeleteMenu(frameWnd->wIDmenu,GetMenuItemCount(frameWnd->wIDmenu) - 1,MF_BYPOSITION); 783 784 DrawMenuBar(frameWnd->hwndSelf); 785 786 return 1; 787 } 788 #endif 428 789 /* -------- Miscellaneous service functions ---------- 429 790 * 430 * 791 * MDI_GetChildByID 431 792 */ 432 793 Win32MDIChildWindow *Win32MDIClientWindow::getChildByID(INT id) … … 438 799 439 800 return 0; 801 } 802 803 void Win32MDIClientWindow::postUpdate(WORD recalc) 804 { 805 if( !(mdiFlags & MDIF_NEEDUPDATE) ) 806 { 807 mdiFlags |= MDIF_NEEDUPDATE; 808 PostMessageA(WM_MDICALCCHILDSCROLL, 0, 0); 809 } 810 sbRecalc = recalc; 440 811 } 441 812 //******************************************************************************
Note:
See TracChangeset
for help on using the changeset viewer.