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

  1. #include "FiveWin.ch"
  2.  
  3. #define BM_SETSTYLE  WM_USER + 4
  4.  
  5. //----------------------------------------------------------------------------//
  6.  
  7. CLASS TButton FROM TControl
  8.  
  9.    DATA   bAction
  10.  
  11.    METHOD New( nRow, nCol, cCaption, oWnd, bAction, nWidth, nHeight,;
  12.                nHelpId, oFont, lDefault, lPixel, lDesign, cMsg,;
  13.                lUpdate ) CONSTRUCTOR
  14.  
  15.    METHOD ReDefine( nId, bAction, oWnd, nHelpId, cMsg, lUpdate ) CONSTRUCTOR
  16.  
  17.    METHOD Click() INLINE If( ::bAction != nil, Eval( ::bAction ),)
  18.  
  19.    METHOD cGenPRG()
  20.  
  21.    METHOD GotFocus() INLINE Super:GotFocus(),;
  22.                             If( ::oWnd:ChildLevel( TDialog() ) == 0,;
  23.                             ::SendMsg( BM_SETSTYLE, BS_DEFPUSHBUTTON, 1 ),)
  24.  
  25.    METHOD LostFocus() INLINE Super:LostFocus(),;
  26.                              If( ::oWnd:ChildLevel( TDialog() ) == 0,;
  27.                              ::SendMsg( BM_SETSTYLE, BS_PUSHBUTTON, 1 ),)
  28.  
  29.    METHOD MouseMove( nRow, nCol, nKeyFlags ) INLINE ;  // Standard Behavior
  30.                      Super:MouseMove( nRow, nCol, nKeyFlags ), nil
  31.  
  32.    METHOD cToChar() INLINE Super:cToChar( "BUTTON" )
  33.  
  34.    METHOD Colors( hDC ) INLINE  0
  35.  
  36. ENDCLASS
  37.  
  38. //----------------------------------------------------------------------------//
  39.  
  40. METHOD New( nRow, nCol, cCaption, oWnd, bAction, nWidth, nHeight, ;
  41.             nHelpId, oFont, lDefault, lPixel, lDesign, cMsg, lUpdate ) CLASS TButton
  42.  
  43.    DEFAULT cCaption := "&Button",;
  44.            oFont    := TFont():New( "System", 7, 10 ),;
  45.            nWidth   := ( Len( cCaption ) + 2 ) * oFont:nWidth,;
  46.            nHeight  := oFont:nHeight + Int( oFont:nHeight / 4 ),;
  47.            nHelpId  := 100,;
  48.            lDefault := .f., lPixel := .f., lDesign := .f., lUpdate := .f.
  49.  
  50.    ::cCaption  = cCaption
  51.    ::nTop      = nRow * If( ! lPixel, ( oFont:nHeight + Int( oFont:nHeight / 4 ) ), 1 )
  52.    ::nLeft     = nCol * If( ! lPixel, oFont:nWidth, 1 )
  53.    ::nBottom   = ::nTop  + nHeight
  54.    ::nRight    = ::nLeft + nWidth
  55.    ::nHelpId   = nHelpId
  56.    ::bAction   = bAction
  57.    ::oWnd      = oWnd
  58.    ::oFont     = oFont
  59.    ::nStyle    = nOR( WS_CHILD, WS_VISIBLE, WS_TABSTOP,;
  60.                      If( lDefault, BS_DEFPUSHBUTTON, 0 ),;
  61.                      If( lDesign, WS_THICKFRAME, 0 ) )
  62.    ::nId       = ::GetNewId()
  63.    ::lDrag     = lDesign
  64.    ::lCaptured = .f.
  65.    ::cMsg      = cMsg
  66.    ::lUpdate   = lUpdate
  67.  
  68.    if oWnd:lVisible
  69.       ::Create( "BUTTON" )
  70.       oWnd:AddControl( Self )
  71.    else
  72.       oWnd:DefControl( Self )
  73.    endif
  74.  
  75. return nil
  76.  
  77. //----------------------------------------------------------------------------//
  78.  
  79. METHOD ReDefine( nId, bAction, oWnd, nHelpId, cMsg, lUpdate ) CLASS TButton
  80.  
  81.    ::nId       = nId
  82.    ::bAction   = bAction
  83.    ::hWnd      = 0
  84.    ::nHelpId   = nHelpId
  85.    ::oWnd      = oWnd
  86.    ::lCaptured = .f.
  87.    ::lDrag     = .f.
  88.    ::cMsg      = cMsg
  89.    ::lUpdate   = lUpdate
  90.  
  91.    oWnd:DefControl( Self )
  92.  
  93. return nil
  94.  
  95. //----------------------------------------------------------------------------//
  96.  
  97. METHOD cGenPRG() CLASS TButton
  98.  
  99.    local cPrg := ""
  100.  
  101.    ::CoorsUpdate()
  102.  
  103.    cPrg += CRLF + ;
  104.            "   @ " + Str( ::nTop, 3 ) + ", " + Str( ::nLeft, 3 ) + ;
  105.            ' BUTTON "' + ::cCaption + '" SIZE ' + ;
  106.            Str( ::nRight - ::nLeft + 1, 3 ) + ", " + ;
  107.            Str( ::nBottom - ::nTop + 1, 3 ) + ;
  108.            " PIXEL OF oWnd ;" + CRLF + ;
  109.            '      ACTION MsgInfo( "Not defined yet!" )' + CRLF
  110.  
  111. return cPrg
  112.  
  113. //----------------------------------------------------------------------------//
  114.