btnbmp captions

btnbmp captions

Postby Silvio.Falconi » Thu Jun 01, 2017 4:36 pm

Image

How I can create a btnbmp with caption on middle and another caption on angle ( left or right) ?
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: 7052
Joined: Thu Oct 18, 2012 7:17 pm

Re: btnbmp captions

Postby Antonio Linares » Thu Jun 01, 2017 4:54 pm

Use oBtn:bPainted
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: btnbmp captions

Postby nageswaragunupudi » Thu Jun 01, 2017 5:02 pm

Please try code similar to this
Code: Select all  Expand view
  @ 50,50 BTNBMP oBtn FILE "\fwh\bitmaps\metro\utilities.bmp" ;
      PROMPT "Comandas" FLAT SIZE 130,100 PIXEL OF oDlg ;
      COLOR CLR_WHITE, RGB( 120,136,85 )

   oBtn:bPainted := { || oBtn:SayText( "F2",  { 8, nil, nil, -8 } , "TR" ) }
 

SayText() parameters

2nd param: 8 and -8 are margin in pixels from top and right
2rd param: "TR" means TOP RIGHT
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10624
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: btnbmp captions

Postby Silvio.Falconi » Thu Jun 01, 2017 5:32 pm

thanks mr Rao
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: 7052
Joined: Thu Oct 18, 2012 7:17 pm

Re: btnbmp captions

Postby Silvio.Falconi » Fri Jun 02, 2017 9:13 am

Mr Rao,
I must build a dialog for the modifiers of each product
the test show 8 btnbmp

the problem are :

1. the little caption at right is not printed
2. the lmOver make error
3. the back color RGB( 120,136,85 ) is not colorized

Image

On my sample test there is only one modifier for that product on picture U can see the first button while the others are disabled
I can see only the word "Prosciutto" on white color


Code: Select all  Expand view

#include "FiveWin.ch"
#include "constant.ch"


Function test()
      Local oDlgVarianti
      Local nBottom   := 12
      Local nRight    := 65
      Local nWidth :=  Max( nRight * DLG_CHARPIX_W, 180 )
      Local nHeight := nBottom * DLG_CHARPIX_H

      Local lSave := .F.
      Local aBtnsVarianti :=array(8)
      Local oBtnVar
      Local aVariantes := {}
      Local nLineaVariantes := 0
      Local aBtnScrollVariantes:=array(2)
      Local  cProducto:="0011"
      Local  nQuantita:=1
      Local oBrowse,nScontrino




//first search there is the modifier of this producto

 *DBSelectArea( "VA" ); OrdSetFocus("VARIANT2")
 use varianti alias VA

  INDEX ON upper(VARIANTE) TAG VARIANT1 TO VARIANTI
  INDEX ON upper(PRODUCTO) TAG VARIANT2 TO VARIANTI

   OrdSetFocus("VARIANT2")
 IF ! VA->(DbSeek( (cProducto),.T. ) )
        llSave := .F.
    msgAlert( i18n(  "Il prodotto non ha varianti in archivio") + CRLF +;
                  i18n("per favore verificare ..." ) )
     RETURN NIL

  ELSE
     lSave := .T.
  ENDIF


IF lSave

select VA
  VA->(DbSetOrder(1))
    VA->(DbGoTop())
    DO WHILE ! VA->(EoF())
       IF va->producto==cProducto
         ++nLineaVariantes
         AAdd( aVariantes, {   VA->DESC1 ,VA->precio, VA->variante } )
       ENDIF
      DBSkip()
   ENDDO


  // se ci sono varianti
 DEFINE DIALOG oDlgVarianti      ;
   TITLE"Selezione Varianti"   ;
   SIZE nWidth, nHeight


               @  10, 10 BTNBMP aBtnsVarianti[1]  FLAT SIZE 48,30 PIXEL OF oDlgVarianti
               @  10, 60 BTNBMP aBtnsVarianti[2]  FLAT SIZE 48,30 PIXEL OF oDlgVarianti
               @  10,110 BTNBMP aBtnsVarianti[3]  FLAT SIZE 48,30 PIXEL OF oDlgVarianti
               @  10,160 BTNBMP aBtnsVarianti[4]  FLAT SIZE 48,30 PIXEL OF oDlgVarianti

               @  45, 10 BTNBMP aBtnsVarianti[5]  FLAT SIZE 48,30 PIXEL OF oDlgVarianti
               @  45, 60 BTNBMP aBtnsVarianti[6]  FLAT SIZE 48,30 PIXEL OF oDlgVarianti
               @  45,110 BTNBMP aBtnsVarianti[7]  FLAT SIZE 48,30 PIXEL OF oDlgVarianti
               @  45,160 BTNBMP aBtnsVarianti[8]  FLAT SIZE 48,30 PIXEL OF oDlgVarianti


   FOR EACH oBtnVar IN aBtnsVarianti


        IF hb_EnumIndex() <= Len( aVariantes )
          oBtnVar:cCaption:= aVariantes[ hb_EnumIndex(), 1 ]   // caption
          oBtnVar:SayText( aVariantes[ hb_EnumIndex(), 2 ],  { 8, nil, nil, -8 } , "TR" )

          oBtnVar:nClrText:= CLR_WHITE
        *  oBtnVar:nClrpane:= { |oB| If( oB:lMOver, { RGB( 120,136,85 ), nRgb(255,255,255), 1 }, ;
         *                                                { nRgb(0,174,0), nRgb(255,255,255), 1 } ) }


          oBtnVar:cargo   := { .F., aVariantes[hb_EnumIndex(), 3] }
          oBtnVar:bAction := { || oBtnVar:cargo[1]:= !oBtnVar:cargo[1], ;
                           If( oBtnVar:cargo[1], ;
                             ( oBtnVar:lPressed := .T., ;
                               oBtnVar:nClrpane:= RGB( 180,136,85 ), ;
                               OnActionVariantes( oBtnVar:cargo[2], oBrowse, cProducto, nScontrino ),;
                           IF( oBtnVar:lPressed ,(oBtnVar:lPressed := .F., oBtnVar:cargo[1]:= .F.,;
                                oBtnVar:nClrpane:= RGB( 120,136,85 ),;
                                oBtnVar:refresh() ),)  ), ;
                             ( oBtnVar:lPressed  := .F., ;
                               oBtnVar:nClrpane:= RGB( 120,136,85 ) ) ), ;
                               oBtnVar:refresh() }


          oBtnVar:Refresh()
        ELSE
          oBtnVar:disable()
       ENDIF
    NEXT




   @  10,210  BTNBMP  aBtnScrollVariantes[1] OF  oDlgVarianti SIZE 30, 30 PIXEL   File "BMP_UP_BTN.BMP" NOBORDER  ;
                  ACTION  nil
 @  45,210  BTNBMP aBtnScrollVariantes[2]  OF oDlgVarianti SIZE 30, 30 PIXEL  File "BMP_DOWN_BTN.BMP"   NOBORDER  ;
                   ACTION  nil


















   ACTIVATE DIALOG oDlgVarianti CENTER

 ENDIF


     return nil




     //--------------------------------------------------------------------------------------//

 Function OnActionVariantes( cVariante, oBrowse, cProducto, nScontrino )

    Msginfo(cVariante,cProducto)

    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: 7052
Joined: Thu Oct 18, 2012 7:17 pm

Re: btnbmp captions

Postby nageswaragunupudi » Sun Jun 04, 2017 2:41 am

Try this sample and adopt to your needs:
Code: Select all  Expand view

#include "fivewin.ch"

function Main()

   local oDlg, oFont, aVariantes, oBtnVariante, x, y, n

   aVariantes   := { { "One",   "F2", "First Button" }, ;
                     { "Two",   "F3", "Second Button" }, ;
                     { "Three", "F4", "Third Button" } }

   oBtnVariante := Array( Len( aVariantes ) )

   DEFINE FONT oFont NAME "ARIAL" SIZE 0,-14

   DEFINE DIALOG oDlg SIZE 500,300 PIXEL FONT oFont

   x := 10
   y := 10

   for n := 1 to Len( aVariantes )
      oBtnVariante[ n ] := CreateBtn( x, y, aVariantes[ n ], oDlg, oFont )
      x  += 50
      if x >= 160
         x  := 10
         y  += 35
      endif
   next

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT  oFont

Return nil

function CreateBtn( x, y, aVar, oDlg, oFont )

   local oBtn

   @ y, x BTNBMP oBtn ;
      PROMPT aVar[ 1 ] SIZE 48,30 PIXEL OF oDlg 2007 ;
      COLOR CLR_WHITE,RGB( 120,136,85 ) FONT oFont ;
      ACTION ( ::GoDown(), ;
               OnActionVariantes( aVar[ 3 ] ), ;
               ::GoUp() )

   oBtn:bPainted  := { || oBtn:SayText( aVar[ 2 ],  { 8, nil, nil, -8 } , "TR" ) }
   oBtn:bClrGrad  := { |l,oBtn| If( oBtn:lMOver, {{ 1, RGB( 120,136,85 ), nRgb(255,255,255) }}, ;
                     If( oBtn:lPressed, RGB( 180,136,85 ), RGB( 120,136,85 ) ) ) }

return oBtn

function OnActionVariantes( c )

   MsgInfo ( c )

return nil
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10624
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: btnbmp captions

Postby Silvio.Falconi » Sun Jun 04, 2017 7:42 am

Nages,

My friend maybe I did not explain well...

I thank you for your example but I want to explain to you that I have a full archive of records and I want to match only 6 buttons at a time in the screen.

The end user by pressing the DOWN button can scroll through the archive forward, but if you press the UP button, you can scroll the archive backwards.

Each record is related to a product.

For a sample : when you go to a restaurant and ask for a meal you can ask if you put some more cheese or a bit more ham and all these changes have to be displayed in the final bill.


To view the categories and products I have always used a system created with the sbutton library.

Image

In the figure you can see under the buttons of the main categories and above 24 product buttons.

So I can see 12 categories per page and 24 products per page

If the user presses the UP (page ->) and DOWN (<- page) buttons, he can scroll through the archive.

If the records for a category were less than 24, the procedure only displays the buttons for those records, and the other buttons are disabled

The system works fine but only with 12 buttons for the categories (blue) and 24 buttons for the products (green) but only with the sbutton class.

Antonio Linares advised me to use FWH classes but I could not convert the system with the btnbmp class

I would like to convert it but I did not succeed
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: 7052
Joined: Thu Oct 18, 2012 7:17 pm

Re: btnbmp captions

Postby nageswaragunupudi » Sun Jun 04, 2017 7:45 am

ok

I will do this part.

The list has a number of rows.
Only 6 buttons at at time should appear
With up and down arrows the buttons should scroll
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10624
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: btnbmp captions

Postby Silvio.Falconi » Sun Jun 04, 2017 8:13 am

see the dbf I sent you thanks
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: 7052
Joined: Thu Oct 18, 2012 7:17 pm

Re: btnbmp captions

Postby nageswaragunupudi » Sun Jun 04, 2017 2:03 pm

Code: Select all  Expand view
#include "fivewin.ch"

REQUEST DBFCDX

static aVariantes    := {}
static nFirstBtn     := 0

function Main()

   local oDlg, oFont, oBtnVariante[ 8 ], x, y, n
   local cProduct := "0011"

   OpenDBF()
   SetProduct( cProduct )

   DEFINE FONT oFont NAME "ARIAL" SIZE 0,-14

   DEFINE DIALOG oDlg SIZE 800,400 PIXEL FONT oFont

   x := 10
   y := 10

   for n := 1 to 8

      oBtnVariante[ n ] := CreateVarBtn( x, y, n, oDlg, oFont )
      x  += 50
      if x > 160
         x  := 10
         y  += 35
      endif
   next

   @ 10, 220 BTNBMP PROMPT "UP" FLAT SIZE 40,30 PIXEL OF oDlg ;
      WHEN nFirstBtn >= 4 ;
      ACTION ( nFirstBtn := Max( 0, nFirstBtn - 8 ), oDlg:Update() )

   @ 45, 220 BTNBMP PROMPT "DOWN" FLAT SIZE 40,30 PIXEL OF oDlg ;
      WHEN nFirstBtn + 8 < Len( aVariantes ) ;
      ACTION ( nFirstBtn := Min( Len( aVariantes ) - 8, nFirstBtn + 8 ), ;
               oDlg:Update() )

   @ 10, 270 BTNBMP PROMPT "Change Product" FLAT SIZE 40,65 PIXEL OF oDlg ;
      ACTION ( cProduct := SelectProduct(), SetProduct( cProduct ), oDlg:Update() )



   // For changing product ACTION ( SetProduct( cNewProduct ), oDlgUpdate() )

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT  oFont


return nil

static function SetProduct( cProduct )

   local nLen

   aVariantes  := VA->( FW_DbfToArray( "ALLTRIM(DESC1),PRECIO,VARIANTE", { || FIELD->PRODUCTO = cProduct } ) )
   nLen        := Len( aVariantes )
   ASize( aVariantes, Max( 8, 4 * Max( 1, Ceiling( nLen / 4 ) ) ) )
   AFill( aVariantes, { "", "", "" }, nLen + 1 )

   nFirstBtn   := 0

return nil


static function OpenDBF()

   USE PRODUC NEW SHARED ALIAS PR VIA "DBFCDX"
   SET ORDER TO TAG PRODUC1
   GO TOP

   USE VARIANTI NEW SHARED ALIAS VA VIA "DBFCDX"
   SET ORDER TO TAG VARIANT1
   GO TOP

return nil


function CreateVarBtn( x, y, nBtn, oDlg, oFont )

   local oBtn

   @ y, x BTNBMP oBtn ;
      PROMPT { || aVariantes[ nFirstBtn + nBtn, 1 ] } SIZE 48,30 PIXEL OF oDlg 2007 UPDATE ;
      COLOR CLR_WHITE,RGB( 120,136,85 ) FONT oFont ;
      WHEN !Empty( aVariantes[ nFirstBtn + nBtn, 1 ] ) ;
      ACTION ( ::GoDown(), ;
               OnActionVariantes( aVariantes[ nFirstBtn + nBtn, 3 ] ), ;
               ::GoUp() )

   oBtn:bPainted  := { || oBtn:SayText( cValToChar(aVariantes[ nFirstBtn + nBtn, 2 ]),  { 8, nil, nil, -8 } , "TR" ) }
   oBtn:bClrGrad  := { |l,oBtn| If( oBtn:lMOver, {{ 1, RGB( 120,136,85 ), nRgb(255,255,255) }}, ;
                     If( oBtn:lPressed, RGB( 180,136,85 ), RGB( 120,136,85 ) ) ) }

   oBtn:bClrGrad  := { |l,oBtn| If( oBtn:lActive, If( oBtn:lMOver, {{ 1, RGB( 120,136,85 ), nRgb(255,255,255) }}, ;
                     If( oBtn:lPressed, RGB( 180,136,85 ), RGB( 120,136,85 ) ) ), CLR_GRAY ) }

   oBtn:bClrGrad  := < |u,oBtn|
         local clr      := CLR_GRAY
         if oBtn:lActive
            if oBtn:lMOver
               clr   := {{ 1, RGB( 120,136,85 ), nRgb(255,255,255) }}
            elseif oBtn:lPressed
               clr   := RGB( 180,136,85 )
            else
               clr   := RGB( 120,136,85 )
            endif
         endif
         return clr
         >


return oBtn

function OnActionVariantes( c )

   MsgInfo ( c )

return nil

function SelectProduct()

   local cRet  := PR->PRODUCTO

   XBROWSER "PR" SELECT cRet := PR->PRODUCTO

return cRet
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10624
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: btnbmp captions

Postby Silvio.Falconi » Sun Jun 04, 2017 4:27 pm

Nages,
Run ok . it was that I mean, you're Fantastic . thank you

why there is 3 times oBtn:bClrGrad ?
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: 7052
Joined: Thu Oct 18, 2012 7:17 pm

Re: btnbmp captions

Postby Silvio.Falconi » Sun Jun 04, 2017 4:57 pm

Nages,
I tried with my archive of variantes
and It make errors

Code: Select all  Expand view
Application
===========
   Path and name: C:\Work\Errori\varianti_nages\nages.Exe (32 bits)
   Size: 3,600,896 bytes
   Compiler version: Harbour 3.2.0dev (r1406271520)
   FiveWin  version: FWH 17.02
   C compiler version: Borland C++ 5.8.2 (32-bit)
   Windows version: 6.1, Build 7600

   Time from start: 0 hours 0 mins 0 secs
   Error occurred at: 06/04/17, 18:56:03
   Error description: Error BASE/1132  Bound error: array access
   Args:
     [   1] = A   { ... } length: 4
     [   2] = N   5

Stack Calls
===========
   Called from: nages.prg => (b)CREATEVARBTN( 82 )
   Called from: .\source\classes\WINDOW.PRG => TDIALOG:AEVALWHEN( 2837 )
   Called from: .\source\classes\DIALOG.PRG => TDIALOG:INITIATE( 714 )
   Called from: .\source\classes\DIALOG.PRG => TDIALOG:HANDLEEVENT( 898 )
   Called from:  => DIALOGBOXINDIRECT( 0 )
   Called from: .\source\classes\DIALOG.PRG => TDIALOG:ACTIVATE( 296 )
   Called from: nages.prg => MAIN( 43 )
 
Last edited by Silvio.Falconi on Sun Jun 04, 2017 5:07 pm, edited 2 times in total.
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: 7052
Joined: Thu Oct 18, 2012 7:17 pm

Re: btnbmp captions

Postby ukoenig » Sun Jun 04, 2017 4:58 pm

Silvio,

can You send me the dbf-structure with maybe some values ?
I want to add ( replace ) the sample inside the section of my sample-collector.
It will be changed to english and with maybe some visual adjustments.
Most of the last posted solutions are included already.
There is still space enaugh to include many other tests.

Image

regards
Uwe :?:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: btnbmp captions

Postby nageswaragunupudi » Sun Jun 04, 2017 7:14 pm

Mr Silvio

I modified the above program
Try the modified program
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10624
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: btnbmp captions

Postby Silvio.Falconi » Mon Jun 05, 2017 8:32 am

yes I saw
nor run ok
it was only error on

ASize( aVariantes, Max( 8, 4 * Max( 1, Ceiling( nLen / 4 ) ) ) )
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: 7052
Joined: Thu Oct 18, 2012 7:17 pm

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot], Rick Lipkin and 60 guests