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

  1. #include "FiveWin.ch"
  2.  
  3. #define BM_SETCHECK (WM_USER+1)
  4.  
  5. //----------------------------------------------------------------------------//
  6.  
  7. CLASS TCheckBox FROM TControl
  8.  
  9.    DATA   bClick
  10.  
  11.    METHOD New( nRow, nCol, cCaption, bSetGet, oWnd, nWidth, nHeight,;
  12.                nHelpTopic, bClick, oFont, bValid, nClrFore, nClrBack,;
  13.                lDesign, lPixel, cMsg, lUpdate ) CONSTRUCTOR
  14.  
  15.    METHOD ReDefine( nId, bSetGet, oWnd, nHelpId, bClick, bValid,;
  16.                     nClrFore, nClrBack, cMsg, lUpdate ) CONSTRUCTOR
  17.  
  18.    METHOD Click()
  19.  
  20.    METHOD Default()
  21.  
  22.    METHOD cToChar() INLINE Super:cToChar( "BUTTON" )
  23.  
  24.    METHOD Init( hDlg ) INLINE  Super:Init( hDlg ),;
  25.                   ::SendMsg( BM_SETCHECK, If( Eval( ::bSetGet ), 1, 0 ) )
  26.  
  27.    METHOD MouseMove( nRow, nCol, nKeyFlags )
  28.  
  29.    METHOD Refresh() INLINE ;
  30.                     ::SendMsg( BM_SETCHECK, If( Eval( ::bSetGet ), 1, 0 ) )
  31.  
  32. ENDCLASS
  33.  
  34. //----------------------------------------------------------------------------//
  35.  
  36. METHOD New( nRow, nCol, cCaption, bSetGet, oWnd, nWidth, nHeight, nHelpTopic,;
  37.             bClick, oFont, bValid, nClrFore, nClrBack, lDesign, lPixel,;
  38.             cMsg, lUpdate ) CLASS TCheckBox
  39.  
  40.    DEFAULT cCaption   := "&CheckBox",;
  41.            oFont      := TFont():New( "System", 8, 9 ),;
  42.            nWidth     := Len( cCaption ) * oFont:nWidth,;
  43.            nHeight    := oFont:nHeight + Int( oFont:nHeight / 2 ),;
  44.            nHelpTopic := 100,;
  45.            nClrFore   := oWnd:nClrText, nClrBack := oWnd:nClrPane,;
  46.            lPixel     := .f., lDesign := .f., lUpdate := .f.
  47.  
  48.    ::nTop       = nRow * If( lPixel, 1,;
  49.                              ( oFont:nHeight + Int( oFont:nHeight / 2 ) ) )
  50.    ::nLeft      = nCol * If( lPixel, 1, oFont:nWidth ) + If( lPixel, 0, 3 )
  51.    ::nBottom    = ::nTop + nHeight
  52.    ::nRight     = ::nLeft + nWidth - If( lPixel, 0, 24 )
  53.    ::cCaption   = cCaption
  54.    ::nStyle     = nOR( WS_CHILD, WS_VISIBLE, BS_AUTOCHECKBOX,;
  55.                        WS_TABSTOP, If( lDesign, WS_THICKFRAME, 0 ) )
  56.    ::nId        = ::GetNewId()
  57.    ::nHelpId    = nHelpTopic
  58.    ::bSetGet    = bSetGet
  59.    ::bClick     = bClick
  60.    ::oWnd       = oWnd
  61.    ::oFont      = oFont
  62.    ::bValid     = bValid
  63.    ::lDrag      = lDesign
  64.    ::lCaptured  = .f.
  65.    ::cMsg       = cMsg
  66.    ::lUpdate    = lUpdate
  67.  
  68.    ::SetColor( nClrFore, nClrBack )
  69.  
  70.    if ValType( Eval( bSetGet ) ) != "L"
  71.       Eval( bSetGet, .f. )
  72.    endif
  73.  
  74.    if oWnd:lVisible
  75.       ::Create( "BUTTON" )
  76.       ::Default()
  77.       oWnd:AddControl( Self )
  78.    else
  79.       oWnd:DefControl( Self )
  80.    endif
  81.  
  82. return nil
  83.  
  84. //----------------------------------------------------------------------------//
  85.  
  86. METHOD Click() CLASS TCheckBox
  87.  
  88.    if ::bSetGet != nil
  89.       Eval( ::bSetGet, ! Eval( ::bSetGet ) )
  90.    endif
  91.  
  92.    if ::bClick != nil
  93.       Eval( ::bClick, Eval( ::bSetGet ) )
  94.    endif
  95.  
  96. return nil
  97.  
  98. //----------------------------------------------------------------------------//
  99.  
  100. METHOD ReDefine( nId, bSetGet, oWnd, nHelpId, bClick, bValid, nClrFore,;
  101.                  nClrBack, cMsg, lUpdate ) CLASS TCheckBox
  102.  
  103.    DEFAULT nClrFore := oWnd:nClrText, nClrBack := oWnd:nClrPane
  104.  
  105.    ::nId       = nId
  106.    ::bSetGet   = bSetGet
  107.    ::bClick    = bClick
  108.    ::oWnd      = oWnd
  109.    ::nHelpId   = nHelpId
  110.    ::bValid    = bValid
  111.    ::lDrag     = .f.
  112.    ::lCaptured = .f.
  113.    ::cMsg      = cMsg
  114.    ::lUpdate   = lUpdate
  115.  
  116.    ::SetColor( nClrFore, nClrBack )
  117.  
  118.    oWnd:DefControl( Self )
  119.  
  120. return nil
  121.  
  122. //----------------------------------------------------------------------------//
  123.  
  124. METHOD MouseMove( nRow, nCol, nKeyFlags ) CLASS TCheckBox
  125.  
  126.    if ::lDrag
  127.       return Super:MouseMove( nRow, nCol, nKeyFlags )
  128.    else
  129.       Super:MouseMove( nRow, nCol, nKeyFlags )
  130.    endif
  131.  
  132. return nil    //  We want standard behavior  !!!
  133.  
  134. //----------------------------------------------------------------------------//
  135.  
  136. METHOD Default() CLASS TCheckBox
  137.  
  138.    ::SendMsg( BM_SETCHECK, If( Eval( ::bSetGet ), 1, 0 ) )
  139.  
  140.    if ::oFont != nil
  141.       ::SetFont( ::oFont )
  142.    else
  143.       ::SetFont( ::oWnd:oFont )
  144.    endif
  145.  
  146. return nil
  147.  
  148. //----------------------------------------------------------------------------//
  149.