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

  1. #include "FiveWin.ch"
  2. #include "Constant.ch"
  3.  
  4. #define WM_MDICREATE        544   // 0x0220
  5. #define WM_MDIDESTROY       545   // 0x0221
  6. #define WM_MDIACTIVATE      546   // 0x0222
  7. #define WM_MDIRESTORE       547   // 0x0223
  8. #define WM_MDINEXT          548   // 0x0224
  9. #define WM_MDIMAXIMIZE      549   // 0x0225
  10. #define WM_MDITILE          550   // 0x0226
  11. #define WM_MDICASCADE       551   // 0x0227
  12. #define WM_MDIICONARRANGE   552   // 0x0228
  13. #define WM_MDIGETACTIVE     553   // 0x0229
  14. #define WM_MDISETMENU       554   // 0x0230
  15.  
  16. #define WM_CHILDACTIVATE     34   // 0x22
  17. #define WM_GETFONT           49   // 0x0031
  18.  
  19. #define SC_RESTORE        61728
  20. #define SC_CLOSE          61536   // 0xF060
  21. #define SC_MINIMIZE       61472
  22. #define SC_NEXT           61504
  23. #define SC_MAXIMIZE       61488   // 0xF030
  24.  
  25. #define IDC_ARROW         32512
  26. #define WM_SYSCOMMAND       274   // 0x0112
  27. #define CW_USEDEFAULT     32768
  28.  
  29. static lRegistered := .f.
  30.  
  31. //----------------------------------------------------------------------------//
  32.  
  33. CLASS TMdiChild FROM TWindow
  34.  
  35.    DATA   oWndClient, oControl
  36.  
  37.    METHOD New( nTop, nLeft, nBottom, nRight, cTitle, nStyle, oMenu,;
  38.                oWnd, oIcon, lVScroll, nClrText, nClrBack, oCursor,;
  39.                oBrush, lPixel, lHScroll ) CONSTRUCTOR
  40.  
  41.    METHOD Maximize() INLINE ::oWndClient:ChildMaximize( Self )
  42.  
  43.    METHOD Restore()  INLINE ::oWndClient:ChildRestore( Self )
  44.  
  45.    METHOD Activate( cShow, bLClicked, bRClicked, bMoved, bResized, bPainted,;
  46.                     bKeyDown, bInit,;
  47.                     bUp, bDown, bPgUp, bPgDn,;
  48.                     bLeft, bRight, bPgLeft, bPgRight, bValid ) INLINE ;
  49.                     ;
  50.                     ::oWndClient:ChildActivate( Self ),;
  51.                     Super:Activate( cShow, bLClicked, bRClicked, bMoved,;
  52.                     bResized, bPainted, bKeyDown, bInit,;
  53.                     bUp, bDown, bPgUp, bPgDn,;
  54.                     bLeft, bRight, bPgLeft, bPgRight, bValid ),;
  55.                     ::lVisible := .t.,;
  56.                     If( ::oControl != nil, ::oControl:SetFocus(),)
  57.  
  58.    METHOD End()
  59.  
  60.    METHOD GotFocus() INLINE If( ::oControl != nil, ::oControl:SetFocus(),)
  61.  
  62.    METHOD Next() INLINE ::oWndClient:ChildNext( Self )
  63.    METHOD Prev() INLINE ::oWndClient:ChildNext( Self, .t. )
  64.  
  65.    METHOD ReSize() BLOCK { | Self, oRect | ;     // It has to be BLOCK
  66.                    Super:ReSize(),;
  67.                    oRect := ::GetCliRect(),;
  68.                    oRect:nTop += If( ::oBar != nil, ::oBar:nBtnHeight, 0 ),;
  69.                    oRect:nLeft--,;
  70.                    If( ::oControl != nil, ::oControl:SetCoors( oRect ),), nil }
  71.  
  72.    METHOD KeyDown( nKey, nFlags )
  73.  
  74.    METHOD SetControl( oCtrl ) INLINE ::oControl := oCtrl, ::ReSize()
  75.  
  76. ENDCLASS
  77.  
  78. //----------------------------------------------------------------------------//
  79.  
  80. METHOD New( nTop, nLeft, nBottom, nRight, cTitle, nStyle, oMenu, oWnd,;
  81.             oIcon, lVScroll, nClrFore, nClrBack, oCursor, oBrush,;
  82.             lPixel, lHScroll ) CLASS TMdiChild
  83.  
  84.    DEFAULT cTitle   := "MDI Child", lVScroll := .f., lHScroll := .f.,;
  85.            oWnd     := GetWndFrame(),;
  86.            nClrFore := oWnd:oWndClient:nClrText,;
  87.            nClrBack := oWnd:oWndClient:nClrPane,;
  88.            lPixel   := .f.
  89.  
  90.    ::nTop       = If( nTop    != nil, nTop * If( ! lPixel, MDIC_CHARPIX_H, 1 ), CW_USEDEFAULT )                  // 16
  91.    ::nLeft      = If( nLeft   != nil, nLeft * If( ! lPixel,  MDIC_CHARPIX_W, 1 ), CW_USEDEFAULT )       // 8
  92.    ::nBottom    = If( nBottom != nil, nBottom * If( ! lPixel, MDIC_CHARPIX_H, 1 ), CW_USEDEFAULT )          // 16
  93.    ::nRight     = If( nRight  != nil, nRight  * If( ! lPixel,  MDIC_CHARPIX_W, 1 ), CW_USEDEFAULT )        // 8
  94.    ::oWndClient = oWnd:oWndClient
  95.    ::oWnd       = oWnd
  96.    ::nStyle     = nStyle
  97.    ::oIcon      = oIcon
  98.    ::lVisible   = .t.
  99.    ::aControls  = {}
  100.  
  101.    ::oCursor    = oCursor
  102.  
  103.    ::SetColor( nClrFore, nClrBack, oBrush )
  104.  
  105.    if ! lRegistered
  106.       RegisterClass( "TMDICHILD",;
  107.                      nOR( CS_VREDRAW, CS_HREDRAW ),;
  108.                      0, 0, 0, 0, 0, "", GetMDIChlProc() )
  109.       lRegistered = .t.
  110.    endif
  111.  
  112.    ::hWnd = ::oWndClient:SendMsg( WM_MDICREATE, 0,;
  113.         cMdiStruct( "TMDICHILD", cTitle,;
  114.                     ::nTop, ::nLeft, ::nBottom, ::nRight,;
  115.                     ::nStyle ) )
  116.    ::Link()
  117.  
  118.    if oMenu != nil
  119.       ::SetMenu( oMenu )
  120.    endif
  121.  
  122.    if lVScroll
  123.       DEFINE SCROLLBAR ::oVScroll VERTICAL OF Self
  124.    endif
  125.    if lHScroll
  126.       DEFINE SCROLLBAR ::oHScroll HORIZONTAL OF Self
  127.    endif
  128.  
  129.    if ::oFont == nil
  130.       ::oFont = TFont()
  131.       ::oFont:hFont = ::SendMsg( WM_GETFONT )
  132.    endif
  133.  
  134.    ::oWndClient:Add( Self )
  135.  
  136.    SetWndDefault( Self )              // Set Default DEFINEd Window
  137.  
  138. return nil
  139.  
  140. //----------------------------------------------------------------------------//
  141.  
  142. METHOD End() CLASS TMdiChild
  143.  
  144.    local lEnd := .t.
  145.  
  146.    if ::bValid != nil
  147.       if Eval( ::bValid )
  148.          ::oWndClient:ChildClose( Self )
  149.       else
  150.          lEnd = .f.
  151.       endif
  152.    else
  153.       ::oWndClient:ChildClose( Self )
  154.    endif
  155.  
  156. return lEnd
  157.  
  158. //----------------------------------------------------------------------------//
  159.  
  160. METHOD KeyDown( nKey, nFlags ) CLASS TMdiChild
  161.  
  162.    // There is no a standard behavior for WM_KEYDOWN messages so we have
  163.    // to process them !
  164.  
  165.    if nKey == VK_F4 .and. GetKeyState( VK_CONTROL )
  166.       ::SendMsg( WM_SYSCOMMAND, SC_CLOSE )
  167.       return 0
  168.    endif
  169.  
  170.    if nKey == VK_F6 .and. GetKeyState( VK_CONTROL )
  171.       ::SendMsg( WM_SYSCOMMAND, SC_NEXT )
  172.       return 0
  173.    endif
  174.  
  175. return Super:KeyDown( nKey, nFlags )
  176.  
  177. //----------------------------------------------------------------------------//
  178.