Page 1 of 4

New Class: TFolderEx

Posted: Sun Aug 08, 2010 7:04 pm
by Daniel Garcia-Gil
New Class TFolderEx, is a new folder class, fivewin own without Window API

Download Sample

some (custom) features:
* Multiline Tabs
* bitmap support, from file or resource
* Alpha bitmap support
* Separation tabs
Image

* Auto Adjust tabs position
Image

* Data bPopUp, block to evaluate for each tab
Image

* Enable / Disable Tabs
* Show / Hide Tabs

Image

* Alpha Level adjustment

Image

* Colors Tabs and Text

Image

* Tab height and round corner adjustmen

Image

* Bitmap Align
Image

*Tabs Action (ON CHANGE)

Image

Download Sample

Code sample

Code: Select all

function main()
   local oWnd
   local oFld, oFld1
   local aMonths := {"January", "February", "March", ;
                     "April", "May", "June", ;
                     "July", "August", "September", ;
                     "October", "November", "December"}
   
    DEFINE WINDOW oWnd TITLE "TFolderex - Testing -"
     
   @ 3, 3 FOLDEREX oFld PIXEL ADJUST;
          PROMPT  "Social", "OS", "Games", "Movies", "Email", "Months", "Setting", "Exit";
          BITMAPS "facebook.bmp", "windows.bmp", "game.bmp", "viddler.bmp", "mail.bmp", "call.bmp", "settings.bmp", "logout.bmp";
          ON PAINT TAB PaintTab( Self, nOption );
          POPUP MenuTabs( Self, nOption );
          ON CHANGE ( If( nOption == 8, If( MsgYesNo( "Do you want exit??" ), ;
                                           oWnd:End(), ( ::SetOption( nOldOption ), ::Refresh() ) ), ) )
          

   //Dialog Social
   @ 3,10 FOLDEREX OF oFld:aDialogs[ 1 ] PIXEL SIZE 450, 190 ;
         PROMPT "Facebook", "MySpace", "Twitter" ;
         BITMAPS "Facebook.bmp", "myspace.bmp", "Twitter.bmp";
         SEPARATOR 20


   //Dialog OS
   @ 3,10 FOLDEREX OF oFld:aDialogs[ 2 ] PIXEL SIZE 450, 190 ;
         PROMPT "", "", "";
         BITMAPS "windows.bmp", "apple.bmp", "ubuntu.bmp";
         ALIGN AL_LEFT, AL_CENTER, AL_RIGHT
         
   //Dialog Mail
   @ 3,10 FOLDEREX OF oFld:aDialogs[ 5 ] PIXEL SIZE 450, 190 ;
         PROMPT "Gamil", "Outlook", "Yahoo";
         BITMAPS "gmail.bmp", "Outlook.bmp", "yahoo.bmp";
         TAB HEIGHT 45 ROUND 5
         
   //Dialog Months
   // Suport Arrays and list
   @ 3,10 FOLDEREX OF oFld:aDialogs[ 6 ] PIXEL SIZE 450, 190 ;
         PROMPT aMonths ;
         TAB HEIGHT 18 ROUND 0;
         ON PAINT TAB ChangeClr( Self, nOption );
         ON PAINT TEXT ChangeTxtClr( Self, nOption )
         
   ACTIVATE WINDOW oWnd;
            ON INIT oFld:Resize()
   
RETURN NIL

FUNCTION PaintTab( o, nOption )

   IF nOption == o:nOver .OR. nOption == o:nOption
      o:SetAlphaLevel( nOption, 255 )
   ELSE 
      o:SetAlphaLevel( nOption, 50 )
   ENDIF 
   
RETURN o:SetFldColors( o, nOption )      


FUNCTION ChangeClr( o, n )
   
   LOCAL nMonth := Month( Date() )
   LOCAL aGrad1 := { { 0.5, nRGB( 255, 255, 255 ), nRGB( 255, 240, 180 ) },;
                     { 0.5,  nRGB( 255, 240, 180 ), nRGB( 255, 200, 140 ) } }

   LOCAL aGrad2 := { { 0.5, nRGB( 255, 255, 255 ), nRGB( 200, 200, 240 ) },;
                     { 0.5,  nRGB( 200, 200, 240 ), nRGB( 100, 100, 240 ) } }

   LOCAL aGrad3 := { { 0.5, nRGB( 255, 255, 255 ), nRGB( 255, 240, 240 ) },;
                     { 0.5,  nRGB( 255, 240, 240 ), nRGB( 255, 200, 200 ) } }

   LOCAL aGradMonth := { { 0.5, nRGB( 255, 255, 255 ), nRGB( 185, 207, 147 ) },;
                         { 0.5,  nRGB( 185, 207, 147 ), nRGB( 85, 107, 47 ) } }
   
   LOCAL hBrush, aGrad 
   
   IF n == nMonth
      aGrad = aGradMonth
   ELSE 
      IF n > 0 .AND. n < 5
         aGrad = aGrad1 
      ELSEIF n > 4 .AND. n < 9
         aGrad = aGrad2 
      ELSE
         aGrad = aGrad3
      ENDIF
   ENDIF
   o:aGradUnSel = aGrad
   hBrush = o:SetFldColors( o, n )
      
RETURN hBrush 

FUNCTION ChangeTxtClr( o, n )
   
   LOCAL nMonth := Month( Date() )
   LOCAL nClr := CLR_BLACK, ;
         nClr1 := CLR_HRED
   
   IF n > 0 .AND. n < 7
      nClr = nClr1 
   ENDIF
      
RETURN nClr
        


FUNCTION MenuTabs( oFld, nOpt )
   LOCAL oMenu

   MENU oMenu POPUP 2007
      MENUITEM oFld:aPrompts[ nOpt ]
      SEPARATOR
      MenuAddItem( "Show", , ;
                    oFld:aVisible[ nOpt ], ,;
                    {|| If( oFld:aVisible[ nOpt ], ;
                            oFld:HideTab( nOpt ), ;
                            oFld:ShowTab( nOpt ) ) } ) 
      MenuAddItem( "Enabled", , ;
                    oFld:aEnable[ nOpt ], ,;
                    {|| If( oFld:aEnable[ nOpt ], ;
                            oFld:DisableTab( nOpt ), ;
                            oFld:EnableTab( nOpt ) ) } ) 
   ENDMENU
   
RETURN oMenu
 
Method redefine is not supported yet

Re: New Class: TFolderEx

Posted: Sun Aug 08, 2010 8:06 pm
by ukoenig
Dear Daniel,

great News.
Just one Question : on Dialogs we had to use a Zero-brush, to get the Folder-tabs transparent.

DEFINE BRUSH oBrush0
DEFINE DIALOG oDlg FROM 50, 50 TO 700, 600 OF oWnd PIXEL BRUSH oBrush0 TRANSPARENT

Do we still need it ???

Best Regards
Uwe :roll:

Re: New Class: TFolderEx

Posted: Sun Aug 08, 2010 8:28 pm
by Daniel Garcia-Gil
Uwe..

do you mean about that?

Image

Re: New Class: TFolderEx

Posted: Sun Aug 08, 2010 9:12 pm
by ukoenig
Daniel,

Yes, that is what I mean ( TRANSPARENT Tab-Area ).
It seems, we don't need to define a Zero-Brush, or the Brush is still needed to define ?

Best Regards
Uwe :lol:

Re: New Class: TFolderEx

Posted: Sun Aug 08, 2010 9:55 pm
by Daniel Garcia-Gil
Uwe

The tab area is transparent
we need remember, the control's tranparences come from parent brush, no only this, all controls
we don't need define null brush to make transparent tabs area

Re: New Class: TFolderEx

Posted: Mon Aug 09, 2010 2:08 am
by RAMESHBABU
Mr.Danial,

Very Good and it looks cool. :D

To go to the next tab in Windows Display Properties Dialog, we press "CTRL+TAB".
Can you add the similar feature to this class also ?

Though it is not shown in the Example, I hope that you must have taken care of
Alt+Short cut key functioning to select a desired tab with Keyboard.

Regards,

- Ramesh Babu P

Re: New Class: TFolderEx

Posted: Mon Aug 09, 2010 2:35 am
by Daniel Garcia-Gil
Ramesh

i'm working in this point now....

it's in TODO list :D

Re: New Class: TFolderEx

Posted: Mon Aug 09, 2010 2:52 am
by nageswaragunupudi
Daniel
Excellent
Very useful

Re: New Class: TFolderEx

Posted: Mon Aug 09, 2010 3:19 am
by richard-service
Hi Daniel,

I found your sample bitmaps into TAB alwayse touch top side when click.

Re: New Class: TFolderEx

Posted: Mon Aug 09, 2010 3:30 am
by Daniel Garcia-Gil
Richard

Sorry.. i dont understand

all feed back is useful, for improve class

thanks all for comments

Re: New Class: TFolderEx

Posted: Mon Aug 09, 2010 3:39 am
by richard-service
Daniel Garcia-Gil wrote:Richard

Sorry.. i dont understand

all feed back is useful, for improve class

thanks all for comments
Very simple. Look Tab bitmap position touch top line( yellow/blue). Maybe you can fix line heigh.
I remember someone share this class( function 70% ).
How about change OneNote 2007/2010 COLOR TAB and style?

Re: New Class: TFolderEx

Posted: Mon Aug 09, 2010 2:05 pm
by MdaSolution
DAniel,
Can you implement it for a Contexual tab in RibbonBar ?

Re: New Class: TFolderEx

Posted: Mon Aug 09, 2010 2:11 pm
by Daniel Garcia-Gil
Richard...

The bitmap position is fine... maybe i should use a more small bitmap, or if you prefer no paint yellow/blue line
Resize bitmap is not acceptable, with windows api method, we lost alpha channel, with own functions:
ResizeImg( hBmp, nWidth, nHeight ) -> hBmp
ResizeImg( hBmp, nPorcent ) -> hBmp
i dont like effect

i did a new data nBmpTopMargin
Image


i thinks, the bitmap used in this samples maybe are so big for you style, my recommendation for you, use more small bitmap or use new data nBmpTopMargin

Re: New Class: TFolderEx

Posted: Mon Aug 09, 2010 2:14 pm
by Daniel Garcia-Gil
Mda..
MdaSolution wrote:Can you implement it for a Contexual tab in RibbonBar ?
i dont thinks so...

Re: New Class: TFolderEx

Posted: Mon Aug 09, 2010 2:27 pm
by Daniel Garcia-Gil
New samples with some adjustment
RAMESHBABU wrote:Though it is not shown in the Example, I hope that you must have taken care of
Alt+Short cut key functioning to select a desired tab with Keyboard.
is working now :D


Download Here

(i like the movie tabs ;-) )