/* * Xailer source code: * * Folder.prg * Clase TFolder() * * Copyright 2003, 2007 Jose F. Gimenez * Copyright 2003, 2007 Xailer.com * All rights reserved * */ #include "Xailer.ch" //-------------------------------------------------------------------------- CLASS XFolder FROM TTabCtrl PUBLIC: PROPERTY lRedraw WRITE METHOD SetRedraw METHOD Create( oParent ) CONSTRUCTOR METHOD InsertItem( nItem, cText, xImage, cTooltip, nClrText, lEnabled ) // --> oFolderPage METHOD ChangeTab( nIndex, nFromTab ) // --> Nil METHOD WMSize() // --> Zero METHOD SetRedraw( lRedraw ) // --> Nil ENDCLASS //-------------------------------------------------------------------------- METHOD Create( oParent ) CLASS XFolder LOCAL nItem ::Super:Create( oParent ) ::SendMsg( WM_SETREDRAW, .F. ) FOR nItem := 1 TO Len( ::aItems ) WITH OBJECT ::aItems[ nItem ] :lVisible := ( nItem == ::nIndex ) :TScrollingWinControl:Create() :SetBounds( -3, -1, ::nClientWidth + 3, ::nClientHeight + 1 ) END NEXT IF ::FlRedraw ::SendMsg( WM_SETREDRAW, .T. ) ENDIF ::Refresh() RETURN Self //-------------------------------------------------------------------------- METHOD InsertItem( nItem, cText, xImage, cTooltip, nClrText, lEnabled ) CLASS XFolder RETURN TFolderPage():Create( Self, nItem, cText, xImage, cTooltip, nClrText, lEnabled ) //-------------------------------------------------------------------------- METHOD ChangeTab( nIndex, nFromTab ) CLASS XFolder LOCAL n IF nIndex != 0 .AND. Len( ::aItems ) >= nIndex WITH OBJECT ::aItems[ nIndex ] :Show() IF :nLeft != -3 .OR. :nTop != -1 .OR. :nWidth != ::nClientWidth + 3 .OR. :nHeight != ::nClientHeight + 1 :SetBounds( -3, -1, ::nClientWidth + 3, ::nClientHeight + 1 ) ENDIF END ENDIF FOR n := 1 TO Len( ::aItems ) IF n != nIndex ::aItems[ n ]:Hide() ENDIF NEXT IF nIndex != 0 .AND. Len( ::aItems ) >= nIndex IF GetFocus() != ::Handle ::aItems[ nIndex ]:SetFocus() ENDIF ENDIF RETURN Nil //-------------------------------------------------------------------------- METHOD WMSize() CLASS XFolder ::UpdateClientRect() IF !Empty( ::Handle ) .AND. ::nIndex > 0 .AND. ::nIndex <= Len( ::aItems ) ::aItems[ ::nIndex ]:SetBounds( -3, -1, ::nClientWidth + 3, ::nClientHeight + 1 ) ENDIF RETURN 0 //-------------------------------------------------------------------------- METHOD SetRedraw( lRedraw ) CLASS XFolder LOCAL nItem ::Super:SetRedraw( lRedraw ) FOR nItem := 1 TO Len( ::aItems ) WITH OBJECT ::aItems[ nItem ] :lVisible := ( nItem == ::nIndex ) :SetBounds( -3, -1, ::nClientWidth + 3, ::nClientHeight + 1 ) END NEXT IF ::FlRedraw ::Refresh() ENDIF RETURN Nil //--------------------------------------------------------------------------