home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 16 / CD_ASCQ_16_0994.iso / news / 4611 / fw16d.ins / SOURCE / CLASSES / MDIFRAME.PRG < prev    next >
Text File  |  1994-06-12  |  5KB  |  169 lines

  1. #include "FiveWin.ch"
  2. #include "Constant.ch"
  3.  
  4. #define SC_RESTORE     61728
  5. #define SC_MINIMIZE    61472
  6. #define SC_CLOSE       61536
  7. #define SC_NEXT        61504
  8.  
  9. #define SIZE_MAXIMIZED     2
  10. #define CW_USEDEFAULT  32768
  11.  
  12. static lRegistered := .f.
  13.  
  14. static oWndMain
  15.  
  16. //----------------------------------------------------------------------------//
  17.  
  18. CLASS TMdiFrame FROM TWindow
  19.  
  20.    DATA   oWndClient, oWndActive
  21.  
  22.    METHOD New( nTop, nLeft, nBottom, nRight, cTitle, nStyle, oMenu,;
  23.                oBrush, oIcon, nClrFore, nClrBack, lVScroll,;
  24.                lHScroll, nMenuInfo, cBorder, oWnd ) CONSTRUCTOR
  25.  
  26.    METHOD ChildNew( nTop, nLeft, nBottom, nRight, cTitle, nStyle ) INLINE ;
  27.           ::oWndClient:ChildNew( nTop, nLeft, nBottom, nRight, cTitle, nStyle )
  28.  
  29.    METHOD Cascade()      INLINE ::oWndClient:Cascade()
  30.    METHOD CloseAll()     INLINE ::oWndClient:lCloseAll()
  31.    METHOD IconizeAll()   INLINE ::oWndClient:IconizeAll()
  32.  
  33.    METHOD Tile( lHor )   INLINE ::oWndClient:Tile( lHor )
  34.    METHOD ArrangeIcons() INLINE ::oWndClient:ArrangeIcons()
  35.    METHOD NextWindow()   INLINE ::oWndClient:NextWindow()
  36.  
  37.    METHOD ReSize( nSizeType, nWidth, nHeight )
  38.  
  39.    METHOD Command( nWParam, nLParam )
  40.  
  41.    METHOD End()
  42.  
  43.    METHOD GotFocus() INLINE Super:GotFocus(), ::oWndClient:SetFocus(), 0
  44.  
  45.    METHOD Select( nWindow ) INLINE ::oWndClient:Select( nWindow )
  46.  
  47. ENDCLASS
  48.  
  49. //----------------------------------------------------------------------------//
  50.  
  51. METHOD New( nTop, nLeft, nBottom, nRight, cTitle, nStyle, oMenu, oBrush,;
  52.             oIcon, nClrFore, nClrBack, lVScroll, lHScroll, nMenuInfo,;
  53.             cBorder, oWnd ) CLASS TMdiFrame
  54.  
  55.    DEFAULT nStyle    := nOR( WS_OVERLAPPEDWINDOW, WS_CLIPCHILDREN ),;
  56.            lVScroll  := .f., lHScroll := .f.,;
  57.            nMenuInfo := 2,;
  58.            nClrFore  := CLR_BLACK, nClrBack := CLR_GRAY
  59.  
  60.    ::nTop        = If( nTop    != nil, nTop    * MDIF_CHARPIX_H, CW_USEDEFAULT )            //16
  61.    ::nLeft       = If( nLeft   != nil, nLeft   * MDIF_CHARPIX_W, CW_USEDEFAULT )            // 8
  62.    ::nBottom     = If( nBottom != nil, nBottom * MDIF_CHARPIX_H, CW_USEDEFAULT )        //16
  63.    ::nRight      = If( nRight  != nil, nRight  * MDIF_CHARPIX_W, CW_USEDEFAULT )        //  8
  64.    ::nStyle      = nStyle
  65.    ::cCaption    = cTitle
  66.    ::nId         = 0
  67.    ::oIcon       = oIcon
  68.    ::lValidating = .f.
  69.    ::lVisible    = .t.
  70.    ::oWnd        = oWnd
  71.  
  72.    if oMenu == nil
  73.       MENU oMenu
  74.          MENUITEM "&Childs"
  75.          MENU
  76.             MENUITEM "New..." ACTION ::ChildNew()
  77.             SEPARATOR
  78.             MENUITEM "E&xit"  ACTION ::End()
  79.          ENDMENU
  80.          MENUITEM "&Window"
  81.          MENU
  82.             MENUITEM "&Tile Vertical"   ACTION ::Tile()
  83.             MENUITEM "&Tile Horizontal" ACTION ::Tile( .t. )
  84.             MENUITEM "&Cascade"         ACTION ::Cascade()
  85.             MENUITEM "&Next Window"     ACTION ::NextWindow()
  86.             MENUITEM "&Arrange Icons"   ACTION ::ArrangeIcons()
  87.             MENUITEM "&Iconize All"     ACTION ::IconizeAll()
  88.             MENUITEM "&Close All"       ACTION ::CloseAll()
  89.          ENDMENU
  90.       ENDMENU
  91.    endif
  92.  
  93.    if ! lRegistered
  94.       RegisterClass( ::ClassName(),;
  95.                      nOR( CS_VREDRAW, CS_HREDRAW ),;
  96.                      0, 0, 0, 0, 0, "", GetFrameProc() )
  97.       lRegistered = .t.
  98.    endif
  99.  
  100.    ::Create()
  101.    ::SetColor( nClrFore, nClrBack, oBrush )
  102.    ::SetMenu( oMenu )
  103.                                         // SubMenu, nChild
  104.    ::oWndClient = TMdiClient():New( Self, nMenuInfo, 1,, lVScroll,;
  105.                                     lHScroll )
  106.    ::oWndClient:SetColor( nClrFore, nClrBack, oBrush )
  107.  
  108.    oWndMain = Self
  109.    SetWndDefault( Self )
  110.  
  111. return nil
  112.  
  113. //----------------------------------------------------------------------------//
  114.  
  115. METHOD ReSize( nSizeType, nWidth, nHeight ) CLASS TMdiFrame
  116.  
  117.    local nPos := If( ::oBar != nil, ::oBar:nBtnHeight, 0 )
  118.    local oWnd
  119.  
  120.    Super:ReSize( nSizeType, nWidth, nHeight )
  121.  
  122.    if ::oWndClient != nil
  123.       ::oWndClient:Move( nPos + If( nPos != 0, 1, 0 ),;
  124.                          0, nWidth, nHeight - nPos - ;
  125.                          If( ::oMsgBar != nil, 26, 0 ), .t. )
  126.    endif
  127.  
  128. return 0
  129.  
  130. //----------------------------------------------------------------------------//
  131.  
  132. METHOD Command( nWParam, nLParam ) CLASS TMdiFrame
  133.  
  134.    local oWnd := ::oWndClient:GetActive()
  135.  
  136.    do case
  137.       case nWParam < 100   // MdiChild Menu Selection
  138.            return nil
  139.  
  140.       otherwise
  141.          Super:Command( nWParam, nLParam )
  142.    endcase
  143.  
  144. return nil
  145.  
  146. //----------------------------------------------------------------------------//
  147.  
  148. METHOD End() CLASS TMdiFrame
  149.  
  150.    if ::bValid != nil
  151.       if ! Eval( ::bValid )
  152.          return .f.
  153.       endif
  154.    endif
  155.  
  156.    if ::oWndClient:lCloseAll()
  157.       ::PostMsg( WM_CLOSE )
  158.    else
  159.       return .f.
  160.    endif
  161.  
  162. return .t.
  163.  
  164. //----------------------------------------------------------------------------//
  165.  
  166. function GetWndFrame() ; return oWndMain      // Default Frame Window
  167.  
  168. //----------------------------------------------------------------------------//
  169.