New Class TMeterEx

New Class TMeterEx

Postby Daniel Garcia-Gil » Wed Mar 24, 2010 7:34 pm

New Class to FiveWin, new style to TMeter class

Image

http://www.sitasoft.net/fivewin/samples/meterex.rar

Code: Select all  Expand view

#include "FiveWin.ch"

function Main()

   LOCAL oWnd, nActual, nActual2, nActual3, nActual4
   LOCAL oMeter, oMeter2, oMeter3, oMeter4

   DEFINE WINDOW oWnd

   nActual := nActual2 := nActual3 := nActual4 := 0
   
   //   meter 1
   @ 10, 50 METEREX oMeter VAR nActual SIZE 310, 40 BITMAP ".\meterex.bmp" TOTAL 50 PIXEL
   @ 60,  50 BUTTON "+" ACTION ( nActual := oMeter:Set( nActual += 1 ) ) SIZE 25, 20 PIXEL
   @ 60,  80 BUTTON "-" ACTION ( nActual := oMeter:Set( nActual -= 1 ) ) SIZE 25, 20 PIXEL
   @ 60, 110 BUTTON "Rst" ACTION ( nActual := oMeter:Set( 0 ), oMeter:Refresh() ) SIZE 25, 20 PIXEL
   @ 60, 140 BUTTON "Auto" ACTION ( Automatic( oMeter, @nActual ) ) SIZE 70, 20 PIXEL
   @ 60, 215 CHECKBOX oMeter:lInverted PROMPT "inverted" PIXEL SIZE 70, 12
   @ 60, 290 CHECKBOX oMeter:lVertical PROMPT "Vertical" PIXEL SIZE 70, 12
   
   // meter 2
   @ 100, 50 METEREX oMeter2 VAR nActual2 SIZE 310, 20 TOTAL 50 PIXEL;
             GRADIENT TRACK { { 1/2, nRGB( 198, 203, 213 ), nRGB( 219, 224, 233 ) },;
                                { 1/2, nRGB( 224, 238,237 ), nRGB( 224, 238,237 ) } } ;
             LINECOLORS nRGB( 110, 151,204 ), CLR_WHITE;
             ROUND INVERTED;
             ON PAINT( If( nActual2 == oMeter2:nTotal, Msginfo( "Finished" ), ) )
   
   @ 130,  50 BUTTON "+" ACTION ( nActual2 := oMeter2:Set( nActual2 += 1 ) ) SIZE 25, 20 PIXEL
   @ 130,  80 BUTTON "-" ACTION ( nActual2 := oMeter2:Set( nActual2 -= 1 ) ) SIZE 25, 20 PIXEL
   @ 130, 110 BUTTON "Rst" ACTION ( nActual2 := 0, oMeter2:Set( 0 ), oMeter2:Refresh() ) SIZE 25, 20 PIXEL
   @ 130, 140 BUTTON "Auto" ACTION ( Automatic( oMeter2, @nActual2 ) ) SIZE 70, 20 PIXEL
   @ 130, 215 CHECKBOX oMeter2:lInverted PROMPT "inverted" PIXEL SIZE 70, 12
   @ 130, 290 CHECKBOX oMeter2:lVertical PROMPT "Vertical" PIXEL SIZE 70, 12


   // meter 3
   @ 180, 50 METEREX oMeter3 VAR nActual3 SIZE 310, 20 TOTAL 50 PIXEL;
             GRADIENT CHUNK { { 1/2, nRGB( 255, 251, 229 ), nRGB( 250, 223, 143 ) } , ;
                              { 1/2, nRGB( 244, 194,  51 ), nRGB( 252, 235,  173 ) } };
             GRADIENT TRACK { { 1/2, nRGB( 198, 203, 213 ), nRGB( 219, 224, 233 ) },;
                                { 1/2, nRGB( 224, 238,237 ), nRGB( 224, 238,237 ) } };
             ROUND LINECOLORS CLR_BLACK, CLR_WHITE
             
               
   @ 210,  50 BUTTON "+" ACTION ( nActual3 := oMeter3:Set( nActual3 += 1 ) ) SIZE 25, 20 PIXEL
   @ 210,  80 BUTTON "-" ACTION ( nActual3 := oMeter3:Set( nActual3 -= 1 ) ) SIZE 25, 20 PIXEL
   @ 210, 110 BUTTON "Rst" ACTION ( nActual3 := oMeter3:Set( 0 ), oMeter3:Refresh() ) SIZE 25, 20 PIXEL
   @ 210, 140 BUTTON "Auto" ACTION ( Automatic( oMeter3, @nActual3 ) ) SIZE 70, 20 PIXEL
   @ 210, 215 CHECKBOX oMeter3:lInverted PROMPT "inverted" PIXEL SIZE 70, 12
   @ 210, 290 CHECKBOX oMeter3:lVertical PROMPT "Vertical" PIXEL SIZE 70, 12
   
   // meter 4 vertical
   @ 10, 380 METEREX oMeter4 VAR nActual4 SIZE 20, 200 TOTAL 50 PIXEL;
             GRADIENT TRACK { { 1/2, nRGB( 198, 203, 213 ), nRGB( 219, 224, 233 ) },;
                                { 1/2, nRGB( 224, 238,237 ), nRGB( 224, 238,237 ) } } ;
             LINECOLORS nRGB( 110, 151,204 ), CLR_WHITE;
             VERTICAL INVERTED
   
   @  10, 415 BUTTON "+" ACTION ( nActual4 := oMeter4:Set( nActual4 += 1 ) ) SIZE 25, 20 PIXEL
   @  40, 415 BUTTON "-" ACTION ( nActual4 := oMeter4:Set( nActual4 -= 1 ) ) SIZE 25, 20 PIXEL
   @  70, 415 BUTTON "Rst" ACTION ( nActual4 := oMeter4:Set( 0 ), oMeter4:Refresh() ) SIZE 25, 20 PIXEL
   @ 100, 415 BUTTON "Automatic" ACTION ( Automatic( oMeter4, @nActual4 ) ) SIZE 70, 20 PIXEL
   @ 130, 415 CHECKBOX oMeter4:lInverted PROMPT "inverted" PIXEL SIZE 70, 12
   @ 160, 415 CHECKBOX oMeter4:lVertical PROMPT "Vertical" PIXEL SIZE 70, 12    
   
   ACTIVATE WINDOW oWnd

RETURN NIL

FUNCTION Automatic( oMeter, nActual )

   LOCAL n
   LOCAL nFrom := nActual

   FOR n = nFrom TO oMeter:nTotal step 0.001
      nActual = n
      oMeter:Set( nActual )
   NEXT
   nActual = oMeter:nTotal
   oMeter:Set( nActual )
   
RETURN NIL
 
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: New Class TMeterEx

Postby Ruben Fernandez » Wed Mar 24, 2010 8:32 pm

Excelente...
Espero que funcione tambien desde recursos...
En que version sale.

Gracias y saludos

Ruben Fernandez
Ruben Fernandez
 
Posts: 366
Joined: Wed Aug 30, 2006 5:25 pm
Location: Uruguay

Re: New Class TMeterEx

Postby Daniel Garcia-Gil » Wed Mar 24, 2010 10:24 pm

Hello Ruben

yes, very soon i 'll post a sample with resource

This class will be available in the next build
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: New Class TMeterEx

Postby Daniel Garcia-Gil » Thu Mar 25, 2010 12:13 am

Working from resources :D

Image

http://www.sitasoft.net/fivewin/samples/meterex2.zip
Code: Select all  Expand view

#include "fivewin.ch"



FUNCTION MAIN
   
   LOCAL oDlg
   LOCAL oMeter, oMeter2
   LOCAL nActual := nActual2 := 0
   
   
   DEFINE DIALOG oDlg RESOURCE "METEREX"

   REDEFINE METEREX oMeter VAR nActual ID 100 TOTAL 50 ROUND ROUNDSIZE 6
   REDEFINE BUTTON ID 101 ACTION ( nActual := oMeter:Set( nActual += 1 ) )
   REDEFINE BUTTON ID 102 ACTION ( nActual := oMeter:Set( nActual -= 1 ) )
   REDEFINE BUTTON ID 103 ACTION ( nActual := 0, oMeter:Set( 0 ) )
   REDEFINE BUTTON ID 104 ACTION ( Automatic( oMeter, @nActual ) )
   REDEFINE CHECKBOX oMeter:lInverted ID 105
   REDEFINE CHECKBOX oMeter:lVertical ID 106
   

   REDEFINE METEREX oMeter2 VAR nActual2 ID 199 TOTAL 50 VERTICAL INVERTED ;
             GRADIENT CHUNK { { 1/2, nRGB( 255, 251, 229 ), nRGB( 250, 223, 143 ) } , ;
                              { 1/2, nRGB( 244, 194,  51 ), nRGB( 252, 235,  173 ) } }
   REDEFINE BUTTON ID 200 ACTION ( nActual2 := oMeter2:Set( nActual2 += 1 ) )
   REDEFINE BUTTON ID 201 ACTION ( nActual2 := oMeter2:Set( nActual2 -= 1 ) )
   REDEFINE BUTTON ID 202 ACTION ( nActual2 := 0, oMeter2:Set( 0 ) )
   REDEFINE BUTTON ID 203 ACTION ( Automatic( oMeter2, @nActual2 ) )
   REDEFINE CHECKBOX oMeter2:lInverted ID 204
   REDEFINE CHECKBOX oMeter2:lVertical ID 205


   ACTIVATE DIALOG oDlg
   
RETURN NIL
   
FUNCTION Automatic( oMeter, nActual )

   LOCAL n
   LOCAL nFrom := nActual

   FOR n = nFrom TO oMeter:nTotal step 0.001
      nActual = n
      oMeter:Set( nActual )
   NEXT
   nActual = oMeter:nTotal
   oMeter:Set( nActual )
   
RETURN NIL  
 


RC...
Code: Select all  Expand view

METEREX DIALOG MOVEABLE PURE LOADONCALL DISCARDABLE 18, 18, 299, 169
STYLE DS_SETFONT |DS_MODALFRAME |WS_POPUP |WS_SYSMENU |WS_CAPTION
CAPTION "Test Resource TMeterEx"
FONT 8, "Arial"
LANGUAGE LANG_NEUTRAL, 0
{
  CONTROL "",100,"TMETEREX",WS_CHILD |WS_VISIBLE ,17,14,265,14
  CONTROL "+",101,"BUTTON",BS_DEFPUSHBUTTON |BS_VCENTER |BS_CENTER |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,17,32,25,20
  CONTROL "-",102,"BUTTON",BS_DEFPUSHBUTTON |BS_VCENTER |BS_CENTER |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,48,32,25,20
  CONTROL "Rst",103,"BUTTON",BS_DEFPUSHBUTTON |BS_VCENTER |BS_CENTER |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,80,32,25,20
  CONTROL "Auto",104,"BUTTON",BS_DEFPUSHBUTTON |BS_VCENTER |BS_CENTER |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,109,37,50,14
  CONTROL "Inverted",105,"BUTTON",BS_CHECKBOX |BS_LEFT |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,167,29,70,10
  CONTROL "Vertical",106,"BUTTON",BS_CHECKBOX |BS_LEFT |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,167,42,70,10
  CONTROL "UserDefined",199,"TMETEREX",WS_CHILD |WS_VISIBLE ,17,62,19,102
  CONTROL "+",200,"BUTTON",BS_DEFPUSHBUTTON |BS_VCENTER |BS_CENTER |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,45,63,25,20
  CONTROL "-",201,"BUTTON",BS_DEFPUSHBUTTON |BS_VCENTER |BS_CENTER |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,45,85,25,20
  CONTROL "Rst",202,"BUTTON",BS_DEFPUSHBUTTON |BS_VCENTER |BS_CENTER |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,45,107,25,20
  CONTROL "Auto",203,"BUTTON",BS_DEFPUSHBUTTON |BS_VCENTER |BS_CENTER |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,45,129,50,14
  CONTROL "Inverted",204,"BUTTON",BS_CHECKBOX |BS_LEFT |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,83,68,70,10
  CONTROL "Vertical",205,"BUTTON",BS_CHECKBOX |BS_LEFT |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,84,81,70,10
}
 
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 95 guests