Página 1 de 1

Dica (wvw) substituir os drawlabel por um xcomando @ xx,say

Enviado: 17 Set 2007 10:07
por edmarfrazao
Para quem não sabe fazer retangulos com wvw, vejam o exemplo,

Da um novo visual ao sistem alterando pouca coisa.



outra opção e usar o drawlabel, bem como fica dificil alterar todo o sistema fiz um xcomando que altera em todo o sistema o @ x, say para

o unico problema e onde tem @ x,say get, ainda não criei um @ x,say get


#xcommand @ <x>,<y> SAY <xvar> =>;
wvw_drawlabel(, <x>, <y>, <xvar>,,, ;
RGB( 0, 255, 255 ), RGB( 100, 135, 220 ),;
"Arial",,, 2 )


@ 06,50 say "Valor Unitário"
@ 12,50 say "SubTotal"
@ 23,65 say "Seu Logotipo aqui"

* wvw_drawlabel(, 06, 50, "Valor Unitário",,, RGB( 0, 255, 255 ), RGB( 100, 135, 220 ), "Tahoma",,, 2 )
* wvw_drawlabel(, 12, 50, "Subtotal" ,,, RGB( 0, 255, 255 ), RGB( 100, 135, 220 ), "Tahoma",,, 2 )
* wvw_drawlabel(, 23, 65, "Seu logotipo aqui",,, RGB( 0, 255, 255 ), RGB( 100, 135, 220 ), "Tahoma",,, 2 )


ps. o exemplo em anexo foi postado em https://pctoledo.org/forum/viewto ... a8a367b793,
fiz a adptação.

para mim foi util , talvez seja para vocês tambem.





Código: Selecionar todos

#include "inkey.ch"
#include "common.ch"
#include "setcurs.ch"
#include "winuser.ch"  //from what32

#define COR_DE_FUNDO      setcolor("3/9")
#define COR_WINDOWS_XP    setcolor( 'N/W,N/GR*,,,N/W*' )
#define COR_NORMAL        setcolor("N/W*,GR+/B*,N/N,GR+/N*,W+/N*,R/W*,W/W*,B/W*")
***************
FUNCTION MAIN()
***************
  REQUEST HB_GT_WIN
  REQUEST HB_GT_WVW_DEFAULT
  REQUEST HB_LANG_PT
  REQUEST HB_CODEPAGE_PT850

  HB_LANGSELECT( 'PT' )


//   dbsetdriver("DBFCDX")
   hb_setcodepage("PT850")

   set confirm    on
   set deleted    on
   set bell       off
   set scoreboard off
   set eventmask  to INKEY_ALL
   set date       british
   set epoch      to 1950

   ConfigCores()

   WVW_SetFont(,'Ms Sans Serif', 16, 8,, 'PROOF_QUALITY' )
   wvw_setmaincoord(.F.)
   wvw_noclose()
   //wvw_size_ready(.T.)
   wvw_SetPaintRefresh(0)
   WVW_SetCodePage(,250)
   wvw_SetVertCaret(.F.)
   wvw_enableshortcuts(0,.T.)
   wvw_maximize(0)
   wvw_settitle( , "PDV - Frente de Loja" )
   COR_WINDOWS_XP
   scroll()

   wvw_drawboxraised(,01,01,04,97)
   COR_DE_FUNDO
   @ 01, 01 clear to 04, 97
   COR_WINDOWS_XP

   wvw_drawboxraised(,06,01,28,47)
   COR_NORMAL
   @ 06, 01 clear to 28, 47
   COR_WINDOWS_XP

   wvw_drawboxraised(,30,01,32,97)
   COR_NORMAL
   @ 30, 01 clear to 32, 97
   COR_WINDOWS_XP

   wvw_drawboxraised(,06,49,10,97)
   wvw_drawboxraised(,12,49,16,97)
   wvw_drawboxraised(,18,49,28,97)
   COR_DE_FUNDO
   @ 06, 49 clear to 10, 97
   @ 12, 49 clear to 16, 97
   @ 18, 49 clear to 28, 97

   #xcommand @ <x>,<y> SAY <xvar> =>;
         wvw_drawlabel(, <x>, <y>, <xvar>,,, ;
 		     RGB( 0, 255, 255 ), RGB( 100, 135, 220 ),;
			  "Arial",,, 2 )


   @ 06,50 say "Valor Unitário"
   @ 12,50 say "SubTotal"
   @ 23,65 say "Seu Logotipo aqui"

*   wvw_drawlabel(, 06, 50, "Valor Unitário",,, RGB( 0, 255, 255 ), RGB( 100, 135, 220 ), "Tahoma",,, 2 )
*   wvw_drawlabel(, 12, 50, "Subtotal"      ,,, RGB( 0, 255, 255 ), RGB( 100, 135, 220 ), "Tahoma",,, 2 )
*   wvw_drawlabel(, 23, 65, "Seu logotipo aqui",,, RGB( 0, 255, 255 ), RGB( 100, 135, 220 ), "Tahoma",,, 2 )

   mcodigo := space(13)
   mquant  := 0.0

   COR_NORMAL
   @ 31,03 say "Código"
   @ 31,72 say "QUANTIDADE"
*   wvw_drawlabel(, 31, 03, "CÓDIGO :",,, aPalette[1], aPalette[16], "Tahoma",,, 2 )
*   wvw_drawlabel(, 31, 72, "QUANTIDADE :",,, aPalette[1], aPalette[16], "Tahoma",,, 2 )

   @ 31, 14 get mcodigo picture "9999999999999"
   @ 31, 88 get mquant picture "@E 9999.99"
   read
RETURN NIL


*********************
FUNCTION ConfigCores()
**********************
   Public aPalette     := WvW_GetPalette()
   aPalette[01] := GetSysColor( COLOR_WINDOWTEXT )  // 8
   aPalette[02] := RGB(   0,  51, 153 )
   aPalette[04] := RGB(   0, 255, 255 )
   aPalette[08] := GetSysColor( COLOR_BTNFACE )    // 15
   aPalette[10] := RGB( 100, 135, 220 )
   aPalette[13] := RGB( 227,  92,  47 )
   WvW_SetPalette( aPalette )
RETURN NIL

FUNCTION RGB( red, green, blue )
//****
   RETURN ( red + ( green * 256 ) + ( blue * 256 * 256 ) )



#ifdef __PLATFORM__Windows

#pragma BEGINDUMP

#include "windows.h"
#include "hbapi.h"

   HB_FUNC ( GETSYSCOLOR )
{
    int i = ISNIL(1) ? 0 : hb_parni(1);

  if ( i >= 0 && i < 29 )
  {
    hb_retnl( (LONG) GetSysColor(i) );
  }
}
#pragma ENDDUMP

#endif

Enviado: 17 Set 2007 12:24
por sygecom
Muito Bom Edmar, parabens !!! tudo que veja a contribuir aos Programadores é bem vindo....

:)) :)) :{ :{

Enviado: 17 Set 2007 13:37
por edmarfrazao
O exemplo esta com um problema


se apertar o botão do windows mostrar area de trabalho e depois voltar para o exemplo os say não são repintados.


no exemplo da wvw (a.prg) funciona mais tem que implentar umas funções.

Alguem sabe outra maneira mais facil de resolver o problema?

function ResetMiscObjects( nWinNum )
do while len(s_amiscobjlist) < nWinNum+1
aadd( s_amiscobjlist, {} )
enddo
s_amiscobjlist[ nWinNum+1 ] := {}
return .t.

function AddMiscObjects( nWinNum, bAction )
aadd( s_amiscobjlist[ nWinNum+1 ], bAction )
return .t.

Enviado: 17 Set 2007 20:49
por edmarfrazao
criei um exemplo pratico com o uso da wvw com drawlabel
segue codigo



Código: Selecionar todos



#include "inkey.ch"
#include "common.ch"
#include "setcurs.ch"
#include "winuser.ch"  //from what32

#xcommand @ <x>,<y> SAY <cLabel> =>;
    AddMiscObjects( nCurWindow, {|nWindow| ;            
         wvw_drawlabel(nWindow, <x>, <y>, <cLabel>,,, ;
 		     RGB( 255, 255, 255 ), RGB( 100, 135, 220 ),;
			  "Courier New",,, 2 )})




#define COR_DE_FUNDO      setcolor("3/9")
#define COR_WINDOWS_XP    setcolor( 'N/W,N/GR*,,,N/W*' )
#define COR_NORMAL        setcolor("N/W*,GR+/B*,N/N,GR+/N*,W+/N*,R/W*,W/W*,B/W*")
static s_amiscobjlist := {}      //x misc object list (actually: list of codeblocks)


***************
FUNCTION MAIN()
  Local vTela:=[]
  Private nCurWindow:=0
***************

  Wvw_Conf_Ambiente()


  While .t.
    
    ResetMiscObjects( 0 )
    
   wvw_Quadro(,01,01,04,78)

   COR_DE_FUNDO
   @ 01, 01 clear to 04, 78
   COR_WINDOWS_XP
   wvw_Quadro(,06,01,28,78)
   COR_NORMAL
   @ 06, 01 clear to 28, 78

    @ 01,01 SAY [Exemplo de Texto]
    @ 02,01 SAY [Exemplo de Texto]

    @ 24,01 SAY [Exemplo de Texto]
   WVW_Paint( 0 )
   

    @ 10,10 PROMPT [1-PDV]
    @ 12,10 PROMPT [2-CLI]
    @ 14,10 PROMPT [3-FIM]
	 MENU TO nOP
    
    vTela:=Salva_Tela()
    if nOp=1
     PDV()
    ELSEIF nOP=2
      CLI()
    ELSEIF nOP=3
      exit
    ENDIF
    Rest_Tela(vTela)
  end
RETURN NIL  
   

FUNCTION PDV()
   Local nJanela:= wvw_CriaJanela(0,0,24,79,'PDV')
   wvw_Quadro(,01,01,04,97)
   
        
   COR_DE_FUNDO
   @ 01, 01 clear to 04, 97
   COR_WINDOWS_XP

    
   wvw_Quadro(,06,01,28,47)
   COR_NORMAL
   @ 06, 01 clear to 28, 47
   COR_WINDOWS_XP

 
   wvw_Quadro(,30,01,32,97)
   COR_NORMAL
   @ 30, 01 clear to 32, 97
   COR_WINDOWS_XP
 
   wvw_Quadro(,06,49,10,97)

    
   wvw_Quadro(,12,49,16,97)

         
   wvw_Quadro(,18,49,28,97)
   COR_DE_FUNDO
   @ 06, 49 clear to 10, 97
   @ 12, 49 clear to 16, 97
   @ 18, 49 clear to 28, 97


   @ 06,50 say "Valor Unitário"
   @ 12,50 say "SubTotal"
   @ 23,65 say "Seu Logotipo aqui"

*   wvw_drawlabel(, 06, 50, "Valor Unitário",,, RGB( 0, 255, 255 ), RGB( 100, 135, 220 ), "Tahoma",,, 2 )
*   wvw_drawlabel(, 12, 50, "Subtotal"      ,,, RGB( 0, 255, 255 ), RGB( 100, 135, 220 ), "Tahoma",,, 2 )
*   wvw_drawlabel(, 23, 65, "Seu logotipo aqui",,, RGB( 0, 255, 255 ), RGB( 100, 135, 220 ), "Tahoma",,, 2 )

   mcodigo := space(13)
   mquant  := 0.0

   COR_NORMAL
   @ 24,03 say "Código"
   @ 24,30 say "QUANTIDADE"
*   wvw_drawlabel(, 31, 03, "CÓDIGO :",,, aPalette[1], aPalette[16], "Tahoma",,, 2 )
*   wvw_drawlabel(, 31, 72, "QUANTIDADE :",,, aPalette[1], aPalette[16], "Tahoma",,, 2 )

   @ 24, 14 get mcodigo picture "9999999999999"
   @ 24, 50 get mquant picture "@E 9999.99"
   read
   FechaJanela(nJanela)
RETURN NIL


*********************
FUNCTION ConfigCores()
**********************
   Public aPalette     := WvW_GetPalette()
   aPalette[01] := GetSysColor( COLOR_WINDOWTEXT )  // 8
   aPalette[02] := RGB(   0,  51, 153 )
   aPalette[04] := RGB(   0, 255, 255 )
   aPalette[08] := GetSysColor( COLOR_BTNFACE )    // 15
   aPalette[10] := RGB( 100, 135, 220 )
   aPalette[13] := RGB( 227,  92,  47 )
   WvW_SetPalette( aPalette )
RETURN NIL
Function WVW_SETFOCUS(nWinNum, hWnd)
   if nWinNum==0
      win_setfocus(wvw_getwindowhandle(wvw_nnumwindows()-1))
   endif
return NIL 


FUNCTION WVW_Paint( nWinNum )
   if len(s_amiscobjlist) >= nWinNum+1
      aeval( s_amiscobjlist[nWinNum+1], {|e| eval( e, nWinNum )} )
   endif

RETURN 0

function ResetMiscObjects( nWinNum )
   default nWinNum to WVW_nNumWindows()-1

   do while len(s_amiscobjlist) < nWinNum+1
      aadd( s_amiscobjlist, {} )
   enddo
   
   s_amiscobjlist[ nWinNum+1 ] := {}
return .t.

function AddMiscObjects( nWinNum, bAction )
   aadd( s_amiscobjlist[ nWinNum+1 ], bAction )
return .t.

FUNCTION RGB( red, green, blue )
//****
   RETURN ( red + ( green * 256 ) + ( blue * 256 * 256 ) )


Function wvw_Quadro(nCurWindow,LS,CL,LI,CI)
    if nCurWindow=nil
	    nCurWindow:= WVW_nNumWindows()-1 //Janela atual
	 endif    
    AddMiscObjects( nCurWindow, {|nWindow| ;
        wvw_drawboxraised(nWindow,LS,CL,LI,CI)})
RETURN NIL

FUNCTION SALVA_TELA(LS,CS,LI,CI)  &&F010
    Local vRet:=[]
    #ifdef xHarbour
       LS:=IF (LS=NIL,01,LS)
    #ELSE
       LS:=IF (LS=NIL,00,LS)
    #endif
    CS:=IF (CS=NIL,00,CS)
    LI:=IF (LI=NIL,24,LI)
    CI:=IF (CI=NIL,79,CI)
       vRet :=STRZERO(LS,2)+STRZERO(CS,2)+STRZERO(LI,2)+STRZERO(CI,2);
	    +SAVESCREEN(LS,CS,LI,CI)
    
Return vRet	

FUNCTION REST_TELA(TELA)
     RESTSCREEN(VAL(SUBS(TELA,1,2)),VAL(SUBS(TELA,3,2)),VAL(SUBS(TELA,5,2)),;
		VAL(SUBS(TELA,7,2)),SUBS(TELA,9))
RETURN NIL

function wvw_CriaJanela(LS,CS,LI,CI,vTitulo)
     nCurWindow:=wvw_nOpenWindow(,LS,CS,LI,CI)
     wvw_SetTitle(,hb_oemTOansI(vTitulo))

	  ResetMiscObjects( nCurWindow)
     AddMiscObjects( nCurWindow, {|nWindow|;
	                wvw_drawboxraised(nWindow,LS+1,CS+1,LI-1,CI-1)})

     SETCOLOR(COR_DE_FUNDO)
     @ LS+1, CS+1 clear to LI-1, CI-1
return nCurWindow

function FechaJanela(xJanela)
   Local vRetorno:=.t.
   #ifdef xHarbour
     if xJanela#0
        WVW_lCloseWindow(xJanela)
        nCurWindow := WVW_nNumWindows()-1 // == 0, Main Window
        ResetMiscObjects( nCurWindow)
        vRetorno:=.f.
     endif
   #endif

return vRetorno


#ifdef __PLATFORM__Windows

#pragma BEGINDUMP

#include "windows.h"
#include "hbapi.h"

   HB_FUNC ( GETSYSCOLOR )
{
    int i = ISNIL(1) ? 0 : hb_parni(1);

  if ( i >= 0 && i < 29 )
  {
    hb_retnl( (LONG) GetSysColor(i) );
  }
}
#pragma ENDDUMP

#endif


function Wvw_Conf_Ambiente()  
  REQUEST HB_GT_WIN
  REQUEST HB_GT_WVW_DEFAULT
  REQUEST HB_LANG_PT
  REQUEST HB_CODEPAGE_PT850
  REQUEST WvW_GetScreenWidth
  REQUEST WVw_SetFont
  REQUEST WVw_SetCodePage
  SET(_SET_EVENTMASK,159)  // habilita o mouse

  HB_LANGSELECT( 'PT' )
  hb_setcodepage("PT850")
 
  setmode(25, 80)

   set confirm    on
   set deleted    on
   set bell       off
   set scoreboard off
   set eventmask  to INKEY_ALL
   set date       british
   set epoch      to 1950

   ConfigCores()

   WVW_SetFont(,'Ms Sans Serif', 16, 8,, 2 )
   wvw_SetPaintRefresh(0)
   wvw_SetVertCaret(.F.)
   wvw_enableshortcuts(0,.T.)
   wvw_maximize(0)
   wvw_settitle( , "PDV - Frente de Loja" )
   wvw_seticon(,2 /*id do icone */)
   WVW_SetMainCoord( .t. )  // for&#135;a o maxrow ser a 1a linha da janela
   wvw_setcodepage(,255)
   wvw_noclose()
   wvw_enablemaximize(0, .t.)
   wvw_maximize(0)
return nil

function cli()
  Local Nome:=[Jose da silva]
  Local vnome2:=space(20)
  Local nJanela:= wvw_CriaJanela(4,4,20,70,'PDV')
   
   
  @ 10,10 say [Nome]
  @ 12,10 say nome
  
//  @ 14,10 say [Informe outro nome] get vNome2 pict [@!]
  @ 15,10 get vNome2

  read
  FechaJanela(nJanela)
  

return nil