Page 1 of 1

Switches (switchtst.prg)

PostPosted: Tue Jun 06, 2017 11:28 am
by jose_murugosa
Este prg, al compilarlo me da error tanto en xharbour como en harbour.

Application
===========
Path and name: C:\fwh\samples\switchtst.exe (32 bits)
Size: 3,456,000 bytes
Compiler version: xHarbour 1.2.3 Intl. (SimpLex) (Build 20161218)
FiveWin version: FWHX 17.04
C compiler version: Borland/Embarcadero C++ 7.0 (32-bit)
Windows version: 6.1, Build 7601 Service Pack 1

Time from start: 0 hours 0 mins 0 secs
Error occurred at: 06/06/17, 08:04:01
Error description: Error BASE/1066 Argument error: conditional
Args:
[ 1] = U

Stack Calls
===========
Called from: .\source\classes\TSWITCH.PRG => TSWITCH:NEW( 105 )
Called from: switchtst.prg => MAIN( 44 )

Re: Switches (switchtst.prg)

PostPosted: Wed Jun 07, 2017 2:49 pm
by Antonio Linares
José,

Falta hacer un DEFAULT lOval := .F. en el código

gracias

Re: Switches (switchtst.prg)

PostPosted: Wed Jun 07, 2017 4:00 pm
by jose_murugosa
No funcionó, yo lo resolví corrigiendo el encabezado de la clase tswitch en switchtst.prg añadiendo los valores loval y lradstyle.

Así funciona perfectamente, añadí al ejemplo que los switches fueran uno no oval, uno oval y uno radstyle:
Code: Select all  Expand view

#include "fivewin.ch"

#xcommand @ <nRow>, <nCol> SWITCH [ <oSw> VAR ] <lVar> ;
             [ PROMPT <cCaption> ] ;
             [ <of:OF, WINDOW, DIALOG> <oWnd> ] ;
             [ SIZE <nWidth>, <nHeight> ] ;
             [ <help:HELPID, HELP ID> <nHelpId> ] ;
             [ FONT <oFont> ] ;
             [ <change: ON CLICK, ON CHANGE> <uClick> ] ;
             [ VALID   <ValidFunc> ] ;
             [ <color: COLOR, COLORS> <nClrFore> [,<nClrBack>] ] ;
             [ <design: DESIGN> ] ;
             [ <pixel: PIXEL> ] ;
             [ MESSAGE <cMsg> ] ;
             [ <update: UPDATE> ] ;
             [ WHEN <WhenFunc> ] ;
             [ BORDERSIZE <nBorderSize> ] [ BORDERCOLOR <nClrBorder> ] ;
             [ THUMBSIZE  <nThumbSize>  ] [ THUMBCOLOR  <nClrThumb> ] ;
           [ RADSTYLE  <lRadStyle>  ] [ OVAL  <lOval> ];           
      => ;
         [ <oSw> := ] TSwitch():New( <nRow>, <nCol>, <cCaption>,;
             bSETGET(<lVar>), <oWnd>, <nWidth>, <nHeight>, <nHelpId>,;
             [<{uClick}>], <oFont>, <{ValidFunc}>, <nClrFore>, <nClrBack>,;
             <.design.>, <.pixel.>, <cMsg>, <.update.>, <{WhenFunc}>, ;
             <nBorderSize>, <nClrBorder>, <nThumbSize>, <nClrThumb>, <lRadStyle>, <lOval> )

function Main()

   local oWnd, oFont
   local lVar1, lVar2, lVar3
   local oYn1, oYn2, oYn3, oSay1, oSay2, oSay3

   lVar1 := lVar2 := lVar3 := .t.

   

   DEFINE FONT oFont NAME "Segoe UI Light" SIZE 0,-18 BOLD

   DEFINE WINDOW oWnd COLOR CLR_GRAY,CLR_WHITE
   oWnd:SetFont( oFont )
//   oWnd:nOpacity := 140

   @  98, 40 SAY oSay1 PROMPT If( lVar1, 'On', 'Off' ) SIZE 60,30 PIXEL OF oWnd UPDATE

   @ 100,207 SWITCH oYn1 VAR lVar1 OVAL .f. PIXEL OF oWnd UPDATE ;
      COLOR CLR_GREEN, CLR_GRAY ;
      ON CHANGE oWnd:Update()

   @ 128, 40 SAY oSay2 PROMPT If( lVar2, 'On', 'Off' ) SIZE 60,30 PIXEL OF oWnd UPDATE

   @ 130,207 SWITCH oYn2 VAR lVar2 OVAL .t. PIXEL OF oWnd UPDATE ;
      COLOR CLR_GREEN, CLR_GRAY ;
      THUMBSIZE 16 THUMBCOLOR CLR_BLUE ;
      ON CHANGE oWnd:Update()

   @ 158, 40 SAY oSay3 PROMPT If( lVar3, 'On', 'Off' ) SIZE 60,30 PIXEL OF oWnd UPDATE

   @ 160,207 SWITCH oYn3 VAR lVar3 OVAL .f. RADSTYLE .t.PIXEL OF oWnd UPDATE ;
      ON CHANGE oWnd:Update()                                                   //con radstyle oval debe ser .f.
   
   ACTIVATE WINDOW oWnd
   RELEASE FONT oFont

return nil

 


Quizá sería conveniente corregir este cabezal para próximas versiones y añadirlo a fivewin.ch o a un "switch.ch", eso lo dejo a vuestro criterio :).

Re: Switches (switchtst.prg)

PostPosted: Wed Jun 07, 2017 4:21 pm
by joseluisysturiz
Saludos, disculpa mi ignorancia, podrias dar una idea de su utilidad.? gracias, saludos... :shock:

Re: Switches (switchtst.prg)

PostPosted: Wed Jun 07, 2017 5:28 pm
by jose_murugosa
Image

Son los switches tipo Android :)
El primero es en formato rectangular (no oval) en off, el segundo es de tipo oval en on, y el tercero es tipo Radio en on en la imagen, es el resultado del código que está más arriba.

Re: Switches (switchtst.prg)

PostPosted: Wed Jun 07, 2017 5:31 pm
by karinha
En que momento se podrá usar?

Image

??????????

Re: Switches (switchtst.prg)

PostPosted: Thu Jun 08, 2017 9:56 am
by jose_murugosa
Karinha,

No entendí tu pregunta..

Es una opción de diferente estética a los checkboxes, disponible en las últimas versiones de fivewin.

Re: Switches (switchtst.prg)

PostPosted: Thu Jun 08, 2017 12:54 pm
by karinha
Gracias José. Me parece, que este modelo sigue siendo un poco primitivo. No me gustó. Creo que tiene que ser mejorado.

Re: Switches (switchtst.prg)

PostPosted: Thu Jun 08, 2017 2:57 pm
by joseluisysturiz
Jose, gracias por tu explicacion e idea, "entre gustos y colores", siempre es bueno salir de la rutina y tener opciones y asi no existe monopolio, pero de verdad crei seria para algo "diferente", igual de mi parte te felicito y agradezco tu aporte, pero para mi es como mezclar naranjas con cebollas, me gusta mas el stylo original de los checkbox, para que inventar la rueda.?, gracias, saludos... :shock:

Re: Switches (switchtst.prg)

PostPosted: Thu Jun 08, 2017 3:06 pm
by jose_murugosa
Totalmente valido estimado. :-)

Re: Switches (switchtst.prg)

PostPosted: Fri Jun 09, 2017 10:41 am
by nageswaragunupudi
The command translate in fivewin.ch is the correct one.
Just remove the xcommand inside the sample program.

This is the revised sample switchtst.prg
Code: Select all  Expand view
#include "fivewin.ch"

function Main()

   local oWnd, oFont
   local lVar1, lVar2, lVar3
   local oYn1, oYn2, oYn3, oSay1, oSay2, oSay3

   lVar1 := lVar2 := lVar3 := .t.

   DEFINE FONT oFont NAME "Segoe UI Light" SIZE 0,-18 BOLD

   DEFINE WINDOW oWnd COLOR CLR_GRAY,CLR_WHITE
   oWnd:SetFont( oFont )
//   oWnd:nOpacity := 140

   @  98, 40 SAY oSay1 PROMPT If( lVar1, 'On', 'Off' ) SIZE 60,30 PIXEL OF oWnd UPDATE

   @ 100,207 SWITCH oYn1 VAR lVar1 PIXEL OF oWnd UPDATE ;
      COLOR CLR_GREEN, CLR_GRAY ;
      ON CHANGE oWnd:Update()

   @ 128, 40 SAY oSay2 PROMPT If( lVar2, 'On', 'Off' ) SIZE 60,30 PIXEL OF oWnd UPDATE

   @ 130,207 SWITCH oYn2 VAR lVar2 PIXEL OF oWnd UPDATE OVALSTYLE ;
      COLOR CLR_GREEN, CLR_GRAY ;
      THUMBSIZE 16 THUMBCOLOR CLR_BLUE ;
      ON CHANGE oWnd:Update()

   @ 158, 40 SAY oSay3 PROMPT If( lVar3, 'On', 'Off' ) SIZE 60,30 PIXEL OF oWnd UPDATE

   @ 160,207 SWITCH oYn3 VAR lVar3  PIXEL OF oWnd UPDATE RADIOSTYLE ;
      ON CHANGE oWnd:Update()

   ACTIVATE WINDOW oWnd
   RELEASE FONT oFont

return nil
 

Rectangular and Oval styles are used in Windows 8.1 and 10.
Not only in Android.

Re: Switches (switchtst.prg)

PostPosted: Fri Jun 09, 2017 1:49 pm
by karinha
Very good mister Nages, thanks.

Image

Regards, saludos.