Project : Calc for Tablet

Project : Calc for Tablet

Postby Silvio.Falconi » Fri Jun 08, 2018 4:29 pm

I'm trying to create a calc for tablet But I not Know How resize buttons ( btnbmp) and fonts when I resize the dialog


Image



Someone can help me to found the solution ?
I use a dialog with WS_OVERLAPPED style

this is the test source

there are :

30 btnbmps
1 get
1 say for show the M of memory number

and the solution for resize buttons must be insert on DlgResize() function but I not found a solution ( for the landscape and the portrait)

Code: Select all  Expand view



//Project Calc for Tablet



#include "fivewin.ch"
#include "Constant.ch"

#DEFINE TRUE   .T.
#DEFINE FALSE  .F.


STATIC oSayMemory

Function test()
   Local oDlg,oGet
    Local nGet:= 0
   define dialog oDlg
   @10,2 get oGet var  nGet SIZE 100,18 PIXEL;
          PICTURE "999,999,999,999" RIGHT  ACTION  TabletCalc( nGet, oGet)
   activate dialog oDlg CENTER
   return nil
//------------------------------------------------------//
//------------------------------------------------------//


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"



    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 ) }

  AEVAL(  aBtnCalc, {| oBtn |oBtn:nClrText:= CLR_WHITE } )
  AEVAL(  aBtnCalc, {| oBtn |oBtn:nClrPane:= CLR_GRAY } )
  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 := {|| (DlgResize(aBtnCalc),  AEVAL(  aBtnCalc, {| oBtn | oBtn:refresh() } )    )}


      ACTIVATE DIALOG oDialogo CENTERED ;
      ON PAINT oNumber:SetFocus()     ;
      ON INIT (oNumber:SelectAll(),    DlgResize(aBtnCalc)  , ;
                                 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 DlgResize(aBtnCalc)

  RETURN NIL

//------------------------------------------------------------------------------//
FUNCTION KeyCal( cKey, cNumber, oNumber, cOperacion, nValue,nValueMemory )

RETURN NIL
//-----------------------------------------------------------------//

 
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 6897
Joined: Thu Oct 18, 2012 7:17 pm

Re: Project : Calc for Tablet

Postby Silvio.Falconi » Fri Jun 08, 2018 4:54 pm

I try with this code but not run ok

Code: Select all  Expand view
STATIC function DlgResize( oDlg, aBtn )

   local i, j, n, r, c, w, h

   WITH OBJECT oDlg
      :nWidth     := Int( ScreenWidth()  * 0.85 )
      :nHeight    := Int( ScreenHeight() * 0.85 )

      w           := ( :nWidth  - 60 ) / 5
      h           := ( :nHeight - 80 ) / 9

   END

   r     := 20
   n     := 1
   for i := 1 to 6
      c     := 30
      for j := 1 to 5
         WITH OBJECT aBtn[ n ]
            :nTop    := r
            :nLeft   := c
            :nWidth  := w - 10
            :nHeight := h - 10
         END
         n++
         c     += w
      next j
      r  += h
   next i

   oDlg:Center()
   oDlg:Refresh()

   return nil


  static function WaitRefresh( ownd, w, l )

   static n := 0

   if oTimer == nil
      DEFINE TIMER oTimer OF oWnd INTERVAL 400 ;
         ACTION ( n++, oWnd:Refresh(), If( n > 4, (oTimer:End(), oTimer := nil, n := 0), nil ) )
      ACTIVATE TIMER oTimer
   endif

return nil



this is the result

Image
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 6897
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Jimmy, JoséQuintas and 49 guests