function TabletCalc( nNumber, oControl)
Local oDialogo,lSalida
Local aBtnCalc[30]
Local oCursor :=TCursor():New(,'HAND')
Local cNumber
Local oNumber
Local nValue := 0
Local cOperacion := ""
Local n,nRow:=18,nCol:=2
Local nValueMemory:=0
Local nBtnSizeW:=30
Local nBtnSizeH:=20
Local oFontGet := TFont():New( "Segoe UI", 0, ( 18 ), .f., .t. )
Local oFontDlg := TFont():New( "Segoe UI", 0, ( 18 ), .f., .t. )
Local cTitle := "Tablet Calc"
Local nBottom := 19
Local nRight := 5
Local nWidth := Max( nRight * DLG_CHARPIX_W, 155 )
Local nHeight := nBottom * DLG_CHARPIX_H
local nMINWidth := 328
local nMINHeight := 370
local nMAXWidth := GETSYSMETRICS( 0 ) //risoluzione orizzontale
local nMAXHeight := GETSYSMETRICS( 1 ) //risoluzione verticale
local cPastMsg := fwstring("&Copia") //"&Paste"
local cAbortMsg := fwstring("&Annulla") //"&Cancel"
CurrentHeight := 0 //not modify
FV := 1 //not modify
lSalida := FALSE
DEFAULT nNumber := 0
cNumber := Ltrim( Str( nNumber, 20 ) )
DEFINE DIALOG oDialogo SIZE nWidth, nHeight;
TRANSPARENT PIXEL;
TITLE cTitle FONT oFontDlg
oDialogo:nStyle := nOr( WS_OVERLAPPED,WS_THICKFRAME,WS_SYSMENU,WS_MAXIMIZEBOX, 0 )
@ nRow,nCol BTNBMP aBtnCalc[26] PROMPT "MC" SIZE nBtnSizeW,nBtnSizeH OF oDialogo PIXEL ACTION (KeyCal("MC", @cNumber, oNumber, @cOperacion, @nValue,@nValueMemory )) NOBORDER
nCol+=nBtnSizeW+1
@ nRow,nCol BTNBMP aBtnCalc[27] PROMPT "MR" SIZE nBtnSizeW,nBtnSizeH OF oDialogo PIXEL ACTION (KeyCal("MR", @cNumber, oNumber, @cOperacion, @nValue,@nValueMemory )) NOBORDER
nCol+=nBtnSizeW+1
@ nRow,nCol BTNBMP aBtnCalc[28] PROMPT "MS" SIZE nBtnSizeW,nBtnSizeH OF oDialogo PIXEL ACTION (KeyCal("MS", @cNumber, oNumber, @cOperacion, @nValue,@nValueMemory )) NOBORDER
nCol+=nBtnSizeW+1
@ nRow,nCol BTNBMP aBtnCalc[29] PROMPT "M+" SIZE nBtnSizeW,nBtnSizeH OF oDialogo PIXEL ACTION (KeyCal("M+", @cNumber, oNumber, @cOperacion, @nValue,@nValueMemory )) NOBORDER
nCol+=nBtnSizeW+1
@ nRow,nCol BTNBMP aBtnCalc[30] PROMPT "M-" SIZE nBtnSizeW,nBtnSizeH OF oDialogo PIXEL ACTION (KeyCal("M-", @cNumber, oNumber, @cOperacion, @nValue,@nValueMemory )) NOBORDER
nRow+=nBtnSizeH+1
nCol:=2
@ nRow,nCol BTNBMP aBtnCalc[1] PROMPT "Back" SIZE nBtnSizeW,nBtnSizeH OF oDialogo PIXEL ACTION (KeyCal("<", @cNumber, oNumber, @cOperacion, @nValue,@nValueMemory )) NOBORDER
nCol+=nBtnSizeW+1
@ nRow,nCol BTNBMP aBtnCalc[2] PROMPT "CE" SIZE nBtnSizeW,nBtnSizeH OF oDialogo PIXEL ACTION (KeyCal("CE", @cNumber, oNumber, @cOperacion, @nValue,@nValueMemory )) NOBORDER
nCol+=nBtnSizeW+1
@ nRow,nCol BTNBMP aBtnCalc[3] PROMPT "C" SIZE nBtnSizeW,nBtnSizeH OF oDialogo PIXEL ACTION (KeyCal("C", @cNumber, oNumber, @cOperacion, @nValue,@nValueMemory )) NOBORDER
nCol+=nBtnSizeW+1
@ nRow,nCol BTNBMP aBtnCalc[4] PROMPT "+/-" SIZE nBtnSizeW,nBtnSizeH OF oDialogo PIXEL ACTION (KeyCal("S", @cNumber, oNumber, @cOperacion, @nValue,@nValueMemory )) NOBORDER
nCol+=nBtnSizeW+1
@ nRow,nCol BTNBMP aBtnCalc[5] PROMPT "Sqrt" SIZE nBtnSizeW,nBtnSizeH OF oDialogo PIXEL ACTION (KeyCal("R", @cNumber, oNumber, @cOperacion, @nValue,@nValueMemory )) NOBORDER
nRow+=nBtnSizeH+1
nCol:=2
@ nRow,nCol BTNBMP aBtnCalc[6] PROMPT "7" SIZE nBtnSizeW,nBtnSizeH OF oDialogo PIXEL ACTION (KeyCal("7", @cNumber, oNumber, @cOperacion, @nValue,@nValueMemory )) NOBORDER
nCol+=nBtnSizeW+1
@ nRow,nCol BTNBMP aBtnCalc[7] PROMPT "8" SIZE nBtnSizeW,nBtnSizeH OF oDialogo PIXEL ACTION (KeyCal("8", @cNumber, oNumber, @cOperacion, @nValue,@nValueMemory )) NOBORDER
nCol+=nBtnSizeW+1
@ nRow,nCol BTNBMP aBtnCalc[8] PROMPT "9" SIZE nBtnSizeW,nBtnSizeH OF oDialogo PIXEL ACTION (KeyCal("9", @cNumber, oNumber, @cOperacion, @nValue,@nValueMemory )) NOBORDER
nCol+=nBtnSizeW+1
@ nRow,nCol BTNBMP aBtnCalc[9] PROMPT "/" SIZE nBtnSizeW,nBtnSizeH OF oDialogo PIXEL ACTION KeyCal("/", @cNumber, oNumber, @cOperacion, @nValue,@nValueMemory ) NOBORDER
nCol+=nBtnSizeW+1
@ nRow,nCol BTNBMP aBtnCalc[10] PROMPT "%" SIZE nBtnSizeW,nBtnSizeH OF oDialogo PIXEL ACTION KeyCal("%", @cNumber, oNumber, @cOperacion, @nValue,@nValueMemory ) NOBORDER
nRow+=nBtnSizeH+1
nCol:=2
@ nRow,nCol BTNBMP aBtnCalc[11] PROMPT "4" SIZE nBtnSizeW,nBtnSizeH OF oDialogo PIXEL ACTION (KeyCal("4", @cNumber, oNumber, @cOperacion, @nValue,@nValueMemory )) NOBORDER
nCol+=nBtnSizeW+1
@ nRow,nCol BTNBMP aBtnCalc[12] PROMPT "5" SIZE nBtnSizeW,nBtnSizeH OF oDialogo PIXEL ACTION (KeyCal("5", @cNumber, oNumber, @cOperacion, @nValue,@nValueMemory )) NOBORDER
nCol+=nBtnSizeW+1
@ nRow,nCol BTNBMP aBtnCalc[13] PROMPT "6" SIZE nBtnSizeW,nBtnSizeH OF oDialogo PIXEL ACTION (KeyCal("6", @cNumber, oNumber, @cOperacion, @nValue,@nValueMemory )) NOBORDER
nCol+=nBtnSizeW+1
@ nRow,nCol BTNBMP aBtnCalc[14] PROMPT "*" SIZE nBtnSizeW,nBtnSizeH OF oDialogo PIXEL ACTION KeyCal("*", @cNumber, oNumber, @cOperacion, @nValue,@nValueMemory ) NOBORDER
nCol+=nBtnSizeW+1
@ nRow,nCol BTNBMP aBtnCalc[15] PROMPT "1/x" SIZE nBtnSizeW,nBtnSizeH OF oDialogo PIXEL ACTION KeyCal("X", @cNumber, oNumber, @cOperacion, @nValue,@nValueMemory ) NOBORDER
nRow+=nBtnSizeH+1
nCol:=2
@ nRow,nCol BTNBMP aBtnCalc[16] PROMPT "1" SIZE nBtnSizeW,nBtnSizeH OF oDialogo PIXEL ACTION (KeyCal("1", @cNumber, oNumber, @cOperacion, @nValue,@nValueMemory )) NOBORDER
nCol+=nBtnSizeW+1
@ nRow,nCol BTNBMP aBtnCalc[17] PROMPT "2" SIZE nBtnSizeW,nBtnSizeH OF oDialogo PIXEL ACTION (KeyCal("2", @cNumber, oNumber, @cOperacion, @nValue,@nValueMemory )) NOBORDER
nCol+=nBtnSizeW+1
@ nRow,nCol BTNBMP aBtnCalc[18] PROMPT "3" SIZE nBtnSizeW,nBtnSizeH OF oDialogo PIXEL ACTION (KeyCal("3", @cNumber, oNumber, @cOperacion, @nValue,@nValueMemory )) NOBORDER
nCol+=nBtnSizeW+1
@ nRow,nCol BTNBMP aBtnCalc[19] PROMPT "-" SIZE nBtnSizeW,nBtnSizeH OF oDialogo PIXEL ACTION (KeyCal("-", @cNumber, oNumber, @cOperacion, @nValue,@nValueMemory )) NOBORDER
nCol+=nBtnSizeW+1
@ nRow,nCol BTNBMP aBtnCalc[20] PROMPT "=" SIZE nBtnSizeW,nBtnSizeH+nBtnSizeH+1 OF oDialogo PIXEL ACTION (KeyCal("=", @cNumber, oNumber, @cOperacion, @nValue,@nValueMemory )) NOBORDER
nRow+=nBtnSizeH+1
nCol:=2
@ nRow,nCol BTNBMP aBtnCalc[21] PROMPT "0" SIZE nBtnSizeW+nBtnSizeW+1,nBtnSizeH OF oDialogo PIXEL ACTION (KeyCal("0", @cNumber, oNumber, @cOperacion,@nValue,@nValueMemory )) NOBORDER
nCol+=nBtnSizeW+nBtnSizeW+2
@ nRow,nCol BTNBMP aBtnCalc[22] PROMPT "," SIZE nBtnSizeW,nBtnSizeH OF oDialogo PIXEL ACTION (KeyCal(".", @cNumber, oNumber, @cOperacion, @nValue,@nValueMemory )) NOBORDER
nCol+=nBtnSizeW+1
@ nRow,nCol BTNBMP aBtnCalc[23] PROMPT "+" SIZE nBtnSizeW,nBtnSizeH OF oDialogo PIXEL ACTION (KeyCal("+", @cNumber, oNumber, @cOperacion, @nValue,@nValueMemory)) NOBORDER
nRow+=nBtnSizeH+1
nCol:=2
@ nRow,nCol BTNBMP aBtnCalc[24] PROMPT cPastMsg SIZE (nBtnSizeW+nBtnSizeW+nBtnSizeW-16),nBtnSizeH OF oDialogo PIXEL ACTION (lSalida:=TRUE,oDialogo:End(IDOK)) NOBORDER
nCol+=nBtnSizeW+nBtnSizeW+nBtnSizeW-10
@ nRow,nCol BTNBMP aBtnCalc[25] PROMPT cAbortMsg SIZE (nBtnSizeW+nBtnSizeW+nBtnSizeW-16),nBtnSizeH OF oDialogo PIXEL ACTION (lSalida:=TRUE,oDialogo:End(IDCANCEL )) NOBORDER
@ 0.4,0 GET oNumber VAR cNumber SIZE oDialogo:nWidth-30,15 PIXEL OF oDialogo FONT oFontGet RIGHT
@ 2.5,oNumber:nWidth+10 SAY oSayMemory PROMPT space(6) SIZE 50,15 PIXEL OF oDialogo FONT oFontGet COLOR CLR_HBLUE
oDialogo:aMinMaxInfo = { GETSYSMETRICS( 0 ), GETSYSMETRICS( 1 ),; // xMaxSize, yMaxSize
0, 0,; // xMaxPosition, yMaxPosition
nMINWidth, nMINHeight,; // xMinTrackSize, yMinTrackSize
nMAXWidth, nMAXHeight }
oDialogo:bKeydown := { | nKey | KeyCal( nKey, @cNumber, oNumber, @cOperacion, @nValue,@nValueMemory ) }
* Rgb(219,225,32)
AEVAL( aBtnCalc, {| oBtn |oBtn:nClrText:= CLR_WHITE } )
AEVAL( aBtnCalc, {| oBtn |oBtn:nClrPane:=CLR_HGRAY } )
AEVAL( aBtnCalc, {| oBtn |oBtn:nLayOut:= 0 } )
AEVAL( aBtnCalc, {| oBtn |oBtn:oCursor:= oCursor } )
aBtnCalc[2]:nClrPane:= CLR_HRED
aBtnCalc[3]:nClrPane:= CLR_HRED
aBtnCalc[24]:nClrPane:= CLR_HGREEN
oDialogo:lHelpIcon:= .F.
oDialogo:bResized := {|| ( ResizeControlsKey(oDialogo , @aCoordinates ,;
@FV , @StartWidth , @StartHeight , @CurrentHeight), ;
AEVAL( aBtnCalc, {| oBtn | oBtn:refresh() } ) )}
ACTIVATE DIALOG oDialogo CENTERED ;
ON PAINT oNumber:SetFocus() ;
ON INIT (oNumber:SelectAll(), ;
ResizeControlsKey(oDialogo , @aCoordinates ,;
@FV , @StartWidth , @StartHeight , @CurrentHeight), ;
AEVAL( aBtnCalc, {| oBtn | oBtn:refresh() } ) ) ;
VALID lSalida
IF lSalida
IF oDialogo:nresult == IDOK
IF oControl:CLASSNAME()="TGET"
TIPVAR:=oControl:VarGet()
IF VALTYPE(TIPVAR)="N"
oControl:VarPut(Val( cNumber ) )
ELSEIF ValType(TIPVAR)="C"
oControl:VarPut( str(Val( cNumber),10,2) )
ENDIF
oControl:Refresh()
ENDIF
ELSE
ENDIF
AEVAL( aBtnCalc, {| oBtn | oBtn:End() } )
aBtnCalc:= NIL
oCursor:End()
RELEASE oFontDlg
RELEASE oFontGet
ENDIF
RETURN NIL
//--------------------------------------------------------------------------------------------------------------//
FUNCTION KeyCal( cKey, cNumber, oNumber, cOperacion, nValue,nValueMemory )
RETURN NIL
//--------------------------------------------------------------------------------------------------------------//