FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour New Class TGIF to Fivewin
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM
New Class TGIF to Fivewin
Posted: Sun Dec 13, 2009 02:09 PM
Greetings to the entire community, I am still working in korea until later this year, I've been a little absent, but here I leave a new tool, I hope to finish this new class to the "build" of December, I leave an example of it:

The class is small but with enough force
Inherited from TControl (-> TWindow) so we can make use of all control Codeblock events: D

I've used only 3 for this example
GIF LClicked = Changes for another (GetFile)
RClicked = Stop / Play Gif
Mouse Move = Show in Window title bar the GIF name where the event is generated

I've only tested in windows 7
http://www.sitasoft.com/fivewin/test/giftest.zip
Code (fw): Select all Collapse
#include "fivewin.ch"
        
function Main()

   local oWnd, oGif, n
   
   oGif = Array( 13 )
   DEFINE WINDOW oWnd TITLE "TEST GIF CLASS"
   
      oGif[ 1 ] := TGif():New( ".\gif\006.gif", 0, 22, 345, 240, oWnd )
      oGif[ 2 ] := TGif():New( ".\gif\015.gif", 0, oGif[ 1 ]:nRight + 5, 345, 240, oWnd )
      oGif[ 3 ] := TGif():New( ".\gif\bigled.gif", 0, oGif[ 2 ]:nRight + 5, 90, 532, oWnd )
      oGif[ 4 ] := TGif():New( ".\gif\forGif.gif", oGif[ 3 ]:nBottom + 5, oGif[ 3 ]:nLeft, 120, 120, oWnd )
      oGif[ 5 ] := TGif():New( ".\gif\forGif3.gif", oGif[ 3 ]:nBottom + 5, oGif[ 4 ]:nRight + 5, 120, 120, oWnd )
      oGif[ 6 ] := TGif():New( ".\gif\Funny.gif", oGif[ 1 ]:nBottom + 5, 22, 345, 240, oWnd )
      oGif[ 7 ] := TGif():New( ".\gif\gif01.gif",  oGif[ 3 ]:nBottom + 5, oGif[ 5 ]:nRight + 5, 120, 120, oWnd )
      oGif[ 8 ] := TGif():New( ".\gif\gif02.gif",  oGif[ 3 ]:nBottom + 5, oGif[ 7 ]:nRight + 5, 120, 120, oWnd )
      oGif[ 9 ] := TGif():New( ".\gif\gif03.gif",  oGif[ 3 ]:nBottom + 5, oGif[ 8 ]:nRight + 5, 120, 120, oWnd )
      oGif[ 10 ] := TGif():New( ".\gif\gif04.gif",  oGif[ 6 ]:nTop, oGif[ 6 ]:nRight + 5, 345, 240, oWnd )      
      oGif[ 11 ] := TGif():New( ".\gif\gif05.gif",  oGif[ 6 ]:nTop, oGif[ 10 ]:nRight + 5, 345, 240, oWnd )    
      oGif[ 12 ] := TGif():New( ".\gif\gif08.gif",  oGif[ 6 ]:nTop, oGif[ 11 ]:nRight + 5, 345, 240, oWnd )    
      oGif[ 13 ] := TGif():New( ".\gif\mail056.gif",  oGif[ 4 ]:nBottom + 5, oGif[ 3 ]:nLeft, 345, 240, oWnd )
      
      
      for n = 1 to Len( oGif )
         oGif[ n ]:bLClicked := MakeLClick( oGif[ n ] )
         oGif[ n ]:bMMoved   := MakeMMove( oGif[ n ] ) 
         oGif[ n ]:bRClicked := MakeRClick( oGif[ n ] ) 
      next
      
      

   ACTIVATE WINDOW oWnd MAXIMIZED
   
   
return nil   

function MakeLClick( oGif )
return {| | ReloadGif( oGif ) } 

function MakeMMove( oGif )
return {| | oGif:oWnd:cTitle := oGif:cFileName } 

function MakeRClick( oGif )
return {| | If( oGif:IsRunning(), oGif:Stop(), oGif:Play() ) } 


function ReloadGif( oGif )
   local cFile
   cFile := cGetFile( "*.Gif" )
   if ! Empty( cFile )
   
      oGif:SetFile( cFile ) 

   endif
   
return nil
      


//-----------------------------------------------------------
// Class TGif
// Gif Info ==>  lLopping
//               nCurrentLoop
//               nImages
//               nWidth
//               nHeight
//-----------------------------------------------------------

CLASS TGif FROM TControl

   DATA  hGif
   DATA  lRegGif
   DATA  cFilename
   
   CLASSDATA lRegistered
   
   METHOD New( oWnd, cFileName, nTop, nLeft )
    
   METHOD GetData() INLINE GetGifInfo( ::hGif )
   
   METHOD Play() INLINE FWGifPlay( ::hGif )
   METHOD Stop() INLINE FWGifStop( ::hGif )
   
   METHOD Restart() INLINE FWGifRestart( ::hGif )
   
   METHOD IsRunning() INLINE FWGifIsRunning( ::hGif )
   
   METHOD Destroy() INLINE FWGifEnd()
   
   METHOD SetFile( cFile ) INLINE ::cFileName := cFile, SetWindowText( ::hGif, cFile )
   
ENDCLASS

//----------------------------------------------------------------//

METHOD New( cFileName, nTop, nLeft, nBottom, nRight, oWnd ) CLASS TGif

    local aData

    default oWnd    := GetWndDefault(),;
            nTop    := 0,;
            nLeft   := 0,;
            nBottom := 100,;
            nRight  := 100


           
   ::nTop    = nTop
   ::nLeft   = nLeft
   ::nBottom = nBottom + nTop
   ::nRight  = nRight + nLeft         
   ::oWnd    = oWnd
   ::nStyle  = nOR( WS_VISIBLE, WS_CHILD )
   
   
   ::cFileName = cFileName

   if ! Empty( cFileName ) .And. ! File( cFileName )
      return nil
   endif
   
   ::Register( )

   if ! Empty( oWnd:hWnd )
      ::Create()
      ::lVisible = .t.
      oWnd:AddControl( Self )
   else
      oWnd:DefControl( Self )
      ::lVisible  = .f.
   endif
   
   FWGIFClass( 0, GetInstance() ) 
   
   ::hGif    := FWGifWindow( cFileName, nOR( WS_CHILD, WS_VISIBLE ), 0, 0, ::nWidth, ::nHeight, ::hWnd, 1 )
   
return self
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM
Re: New Class TGIF to Fivewin
Posted: Mon Dec 14, 2009 08:25 AM
Hello...

TGIF The new class is completed, will be available for 9.12, you can try the following example, let the sample source code

Accepts resize and adjust to any size

uses three types of Resize

1. Adjustable (ADJUST)
2. Assigned to size
3. Image size

http://www.sitasoft.com/fivewin/test/testgif2.zip

Code (fw): Select all Collapse
#include "fivewin.ch"
#include "gif.ch"

        
function Main()

   local oWnd, oGif
   local oCursor
   
   oGif = Array( 13 )
   
   DEFINE CURSOR oCursor HAND
   
   DEFINE WINDOW oWnd TITLE "TEST GIF CLASS" 
   
     @ 0, 0                                 GIF oGif[ 1 ] FILE "..\gifs\006.gif"     size 100, 100 ADJUST 
     @ oGif[ 1 ]:nTop, oGif[ 1 ]:nRight + 5 GIF oGif[ 2 ] FILE "..\gifs\015.gif"     size 100, 100 ADJUST      
     @ oGif[ 1 ]:nTop, oGif[ 2 ]:nRight + 5 GIF oGif[ 3 ] FILE "..\gifs\bigled.gif"  size 100, 100 ADJUST
     @ oGif[ 1 ]:nTop, oGif[ 3 ]:nRight + 5 GIF oGif[ 4 ] FILE "..\gifs\forGif.gif"  size 100, 100 ADJUST
     @ oGif[ 1 ]:nTop, oGif[ 4 ]:nRight + 5 GIF oGif[ 5 ] FILE "..\gifs\forGif3.gif" size 100, 100 ADJUST
     @ oGif[ 1 ]:nTop, oGif[ 5 ]:nRight + 5 GIF oGif[ 6 ] FILE "..\gifs\Funny.gif"   size 100, 100 ADJUST
     @ oGif[ 1 ]:nTop, oGif[ 6 ]:nRight + 5 GIF oGif[ 7 ] FILE "..\gifs\gif01.gif"   size 100, 100 ADJUST
     @ oGif[ 1 ]:nTop, oGif[ 7 ]:nRight + 5 GIF oGif[ 8 ] FILE "..\gifs\gif02.gif"   size 100, 100 ADJUST
     @ oGif[ 1 ]:nTop, oGif[ 8 ]:nRight + 5 GIF oGif[ 9 ] FILE "..\gifs\gif03.gif"   size 100, 100 ADJUST     
     @ oGif[ 1 ]:nBottom + 5, 0             GIF oGif[ 10 ] FILE "..\gifs\mail056.gif" ADJUST;
       ACTION( oGif[ 10 ]:lAdjust := .F.,;
               oGif[ 10 ]:Refresh(), ;
               oWnd:bResized := NIL ) CURSOR oCursor
     
     oWnd:bResized = {| | oGif[ 10 ]:ReSize( , oWnd:nWidth, oWnd:nHeight - 150 ) } 

   ACTIVATE WINDOW oWnd MAXIMIZED 
   
return nil

Continue the discussion