New Rating Class

User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Re: New Rating Class

Post by Silvio.Falconi »

Uwe,
I think it can be good
Before we can create the control and show the bitm for a sample 5 star
we can use 4 status

status 1 EMPTY
status 2 LEFT
status 3 RIGHT
status 4 FULL

in this mode we can use all bitmaps we want ( instead of only stars)
but I not Know how make it
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Re: New Rating Class

Post by Silvio.Falconi »

I made a simply test with bitmaps , It run ok , now I try to converte into a class

I made it for rating a book ( on My biblio application)


With Stars
Image





With Hearts

Image







save the images I used on this test

Full_img.bmp
Image


Empty_img.bmp
Image



test.prg

Code: Select all

#include "Fivewin.ch"
#include "Image.ch"
#include "Constant.ch"

 STATIC count, pressed, aRate, nValue
 STATIC Empty_Img,Full_Img,Half_Img






Function test()

   nValore:= RatingBook("c:\work\fwh\bitmaps\007.bmp")


   Msginfo(nValore)

   return nil





Function RatingBook(cBook)
Local oDlg

Local oCursorBtn :=TCursor():New(,'HAND')
Local img_name, col
Local i
Local oBook
Local oBtnConfirm

       aRate:= {"10%","20%","30%","40%","50%"}
       pressed := 0
       col := 60
       count := 5
       nRow := 140
       Empty_Img:= ".\bitmaps\Empty.bmp"
       Full_Img:= ".\bitmaps\Full.bmp"
       Half_Img:=".\bitmaps\Half.bmp"
       nValue:= 0

       DEFINE FONT oFont NAME "Tahoma" SIZE 0, -12



define Dialog oDlg size 400,300  TITLE "Rating a Book"


         @ 1,5 bitmap oBook filename "c:\work\fwh\bitmaps\007.bmp" size 100,120 Noborder OF oDlg



@ nRow, 3 say "My Rating ("  SIZE 59, 10 OF oDlg  PIXEL
@ nRow, 55 say ")"  SIZE 2, 10 OF oDlg  PIXEL


        oReset := TUrlLink():New( nRow+0.2, 39, oDlg, .T., .F., oFont, "", "Reset" )
        oReset:SetColor(  oReset:nClrText, oDlg:nClrPane )
        oReset:nClrOver = CLR_RED
        oReset:bAction =  { || ( pressed := 5, Reset(pressed) ) }
        nCol:= 62





       @ nRow, nCol IMAGE Image_1 SIZE 9, 9 OF oDlg  FILENAME Empty_Img PIXEL  NOBORDER  CURSOR oCursorBtn    ON CLICK ( pressed :=1,OnSelectRate(pressed,count))
       nCol += 9
       @ nRow, nCol IMAGE Image_2 SIZE 9, 9 OF oDlg  FILENAME Empty_Img PIXEL  NOBORDER  CURSOR oCursorBtn    ON CLICK ( pressed :=2,OnSelectRate(pressed,count))
       nCol += 9
       @ nRow, nCol IMAGE Image_3 SIZE 9, 9 OF oDlg  FILENAME Empty_Img PIXEL  NOBORDER  CURSOR oCursorBtn    ON CLICK ( pressed :=3,OnSelectRate(pressed,count))
       nCol += 9
       @ nRow, nCol IMAGE Image_4 SIZE 9, 9 OF oDlg  FILENAME Empty_Img PIXEL  NOBORDER  CURSOR oCursorBtn    ON CLICK ( pressed :=4,OnSelectRate(pressed,count))
       nCol += 9
       @ nRow, nCol IMAGE Image_5 SIZE 9, 9 OF oDlg  FILENAME Empty_Img PIXEL  NOBORDER  CURSOR oCursorBtn    ON CLICK ( pressed :=5,OnSelectRate(pressed,count))



                      Image_1:bMMoved:= { ||( pressed :=1,OnHoverRate(pressed,count)) }
                      Image_2:bMMoved:= { ||( pressed :=2,OnHoverRate(pressed,count)) }
                      Image_3:bMMoved:= { ||( pressed :=3,OnHoverRate(pressed,count)) }
                      Image_4:bMMoved:= { ||( pressed :=4,OnHoverRate(pressed,count)) }
                      Image_5:bMMoved:= { ||( pressed :=5,OnHoverRate(pressed,count)) }

                      Image_1:bMLeave :={ ||( pressed :=1,OnLeaveRate(pressed,count)) }
                      Image_2:bMLeave :={ ||( pressed :=2,OnLeaveRate(pressed,count)) }
                      Image_3:bMLeave :={ ||( pressed :=3,OnLeaveRate(pressed,count)) }
                      Image_4:bMLeave :={ ||( pressed :=4,OnLeaveRate(pressed,count)) }
                      Image_5:bMLeave :={ ||( pressed :=5,OnLeaveRate(pressed,count)) }


                      @ 138, 150 button oBtnConfirm  Prompt "&Exit" SIZE 30, 10 OF oDlg PIXEL  action oDlg:end()

          Activate Dialog oDlg  center
     RETURN  nValue


//-------------------------------------------------------------//
Function OnHoverRate(select,count)
   Local j

Reset(count)

FOR j:=1 TO select
      img_name := "Image_"+hb_ntos(j)
     &img_name:LoadBmp(Full_Img)

  NEXT

   nValue:= aRate[ select]

Return Nil

//------------------------------------------------------//
Function OnLeaveRate(pressed,count)

   IF pressed == 0
      Reset(count)
   ELSE
      OnSelectRate(pressed,count)
   ENDIF

   Return Nil

//-------------------------------------------------------//
Function OnSelectRate(pressed,count)
Local k
Local img_name

IF pressed > 0

      Reset(count)

      FOR k:=1 TO pressed
         img_name := "Image_"+hb_ntos(k)
        &img_name:LoadBmp(Full_Img)

      NEXT
   ENDIF

  nValue:= aRate[pressed]

   Return Nil

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

Static Function Reset(count)
   Local x
    Local img_name
  //

   FOR x:=1 TO count
    img_name := "Image_"+hb_ntos(x)
   &img_name:LoadBmp(Empty_Img)
   NEXT

   Return Nil

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







 
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Re: New Rating Class

Post by Silvio.Falconi »

Someone can Help me to create the rating class from this test ?
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: New Rating Class

Post by Antonio Linares »

Silvio,

The half star bitmap is missing, thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Re: New Rating Class

Post by Silvio.Falconi »

U can rem that line
Now I not calc the possibility to insert half bitmap but if you have an idea you'wellcome
I sent you now all test's bitmaps.
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: New Rating Class

Post by Antonio Linares »

Silvio,

When I run your example I get this:

Image

It seems that at the right of "reset" there are bitmaps controls but they do nothing when I click on them
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Re: New Rating Class

Post by Silvio.Falconi »

I pubblish also new the source test and I sent you all also the exe

Code: Select all

#include "Fivewin.ch"
#include "Image.ch"
#include "Constant.ch"

 STATIC count, pressed, aRate, nValue
 STATIC Empty_Img,Full_Img,Half_Img






Function test()

   nValore:= RatingBook("c:\work\fwh\bitmaps\007.bmp")


   Msginfo(nValore)

   return nil





Function RatingBook(cBook)
Local oDlg

Local oCursorBtn :=TCursor():New(,'HAND')
Local img_name, col
Local i
Local oBook
Local oBtnConfirm

       aRate:= {"10%","20%","30%","40%","50%"}
       pressed := 0
       col := 60
       count := 5
       nRow := 140
       Empty_Img:= ".\bitmaps\Emptyh.bmp"
       Full_Img:= ".\bitmaps\Fullh.bmp"
       Half_Img:=".\bitmaps\Half.bmp"
       nValue:= 0

       DEFINE FONT oFont NAME "Tahoma" SIZE 0, -12



define Dialog oDlg size 400,300  TITLE "Rating a Book"


         @ 1,5 bitmap oBook filename "c:\work\fwh\bitmaps\007.bmp" size 100,120 Noborder OF oDlg



@ nRow, 3 say "My Rating ("  SIZE 59, 10 OF oDlg  PIXEL
@ nRow, 55 say ")"  SIZE 2, 10 OF oDlg  PIXEL


        oReset := TUrlLink():New( nRow+0.2, 39, oDlg, .T., .F., oFont, "", "Reset" )
        oReset:SetColor(  oReset:nClrText, oDlg:nClrPane )
        oReset:nClrOver = CLR_RED
        oReset:bAction =  { || ( pressed := 5, Reset(pressed) ) }
        nCol:= 62





       @ nRow, nCol IMAGE Image_1 SIZE 9, 9 OF oDlg  FILENAME Empty_Img PIXEL  NOBORDER  CURSOR oCursorBtn    ON CLICK ( pressed :=1,OnSelectRate(pressed,count))
       nCol += 9
       @ nRow, nCol IMAGE Image_2 SIZE 9, 9 OF oDlg  FILENAME Empty_Img PIXEL  NOBORDER  CURSOR oCursorBtn    ON CLICK ( pressed :=2,OnSelectRate(pressed,count))
       nCol += 9
       @ nRow, nCol IMAGE Image_3 SIZE 9, 9 OF oDlg  FILENAME Empty_Img PIXEL  NOBORDER  CURSOR oCursorBtn    ON CLICK ( pressed :=3,OnSelectRate(pressed,count))
       nCol += 9
       @ nRow, nCol IMAGE Image_4 SIZE 9, 9 OF oDlg  FILENAME Empty_Img PIXEL  NOBORDER  CURSOR oCursorBtn    ON CLICK ( pressed :=4,OnSelectRate(pressed,count))
       nCol += 9
       @ nRow, nCol IMAGE Image_5 SIZE 9, 9 OF oDlg  FILENAME Empty_Img PIXEL  NOBORDER  CURSOR oCursorBtn    ON CLICK ( pressed :=5,OnSelectRate(pressed,count))



                      Image_1:bMMoved:= { ||( pressed :=1,OnHoverRate(pressed,count)) }
                      Image_2:bMMoved:= { ||( pressed :=2,OnHoverRate(pressed,count)) }
                      Image_3:bMMoved:= { ||( pressed :=3,OnHoverRate(pressed,count)) }
                      Image_4:bMMoved:= { ||( pressed :=4,OnHoverRate(pressed,count)) }
                      Image_5:bMMoved:= { ||( pressed :=5,OnHoverRate(pressed,count)) }

                      Image_1:bMLeave :={ ||( pressed :=1,OnLeaveRate(pressed,count)) }
                      Image_2:bMLeave :={ ||( pressed :=2,OnLeaveRate(pressed,count)) }
                      Image_3:bMLeave :={ ||( pressed :=3,OnLeaveRate(pressed,count)) }
                      Image_4:bMLeave :={ ||( pressed :=4,OnLeaveRate(pressed,count)) }
                      Image_5:bMLeave :={ ||( pressed :=5,OnLeaveRate(pressed,count)) }


                      @ 138, 150 button oBtnConfirm  Prompt "&Exit" SIZE 30, 10 OF oDlg PIXEL  action oDlg:end()

          Activate Dialog oDlg  center
     RETURN  nValue


//-------------------------------------------------------------//
Function OnHoverRate(select,count)
   Local j

Reset(count)

FOR j:=1 TO select
      img_name := "Image_"+hb_ntos(j)
     &img_name:LoadBmp(Full_Img)

  NEXT

   nValue:= aRate[ select]

Return Nil

//------------------------------------------------------//
Function OnLeaveRate(pressed,count)

   IF pressed == 0
      Reset(count)
   ELSE
      OnSelectRate(pressed,count)
   ENDIF

   Return Nil

//-------------------------------------------------------//
Function OnSelectRate(pressed,count)
Local k
Local img_name

IF pressed > 0

      Reset(count)

      FOR k:=1 TO pressed
         img_name := "Image_"+hb_ntos(k)
        &img_name:LoadBmp(Full_Img)

      NEXT
   ENDIF

  nValue:= aRate[pressed]

   Return Nil

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

Static Function Reset(count)
   Local x
    Local img_name
  //

   FOR x:=1 TO count
    img_name := "Image_"+hb_ntos(x)
   &img_name:LoadBmp(Empty_Img)
   NEXT

   Return Nil

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





 
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
User avatar
ukoenig
Posts: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Re: New Rating Class

Post by ukoenig »

Silvio,

it works fine here.
I added a HALF-star option and a percent-display.
( star-size adjusted to 12 pixel )
A possible solution ?

Image

Code: Select all

// sample for the 1. star

// aRate := {"10%","20%","30%","40%","50%", "60%","70%","80%","90%","100%"}

@ nRow, nCol IMAGE Image_1 SIZE 12, 12 OF oDlg  FILENAME Empty_Img PIXEL  NOBORDER  ;
CURSOR oCursorBtn  ADJUST  ON CLICK ( pressed :=1, OnSelectRate(pressed,count) )
Image_1:lTransparent := .T.
Image_1:bRClicked := { || cRate := aRate[1], oSay1:Refresh(), SetHalf(count, 1, aClicked ) }

Image_1:bMMoved:= { ||( pressed :=1,OnHoverRate(pressed,count, aClicked)), ;
cRate := aRate[2], oSay1:Refresh() }

@ nRow + 2, 135 SAY oSay1 PROMPT cRate OF oDlg SIZE 30, 12 COLOR CLR_RED PIXEL FONT oFont 
oSay1:lTransparent := .T.

// ---

Function SetHalf(select, nPos, aClicked)
Local j

FOR j:=1 TO select
   img_name := "Image_" + hb_ntos(j)
   IF j = nPos // the number of the RIGHT clicked FULL star
      aClicked[nPos] := 2 // saved clicked-status for the half star, 1 = full
      &img_name:LoadBmp( Half_Img )
   ENDIF
NEXT

Return Nil
 
best regards
Uwe :?:
Last edited by ukoenig on Mon Dec 29, 2014 12:02 pm, edited 6 times in total.
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
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Re: New Rating Class

Post by Silvio.Falconi »

yes, can be a solution
can see the function sethalf ?
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
User avatar
ukoenig
Posts: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Re: New Rating Class

Post by ukoenig »

Silvio,

the function added in source ( UP to message )

best regards
Uwe :lol:
Last edited by ukoenig on Sun Dec 28, 2014 12:19 pm, edited 1 time in total.
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
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Re: New Rating Class

Post by Silvio.Falconi »

Uwe,
aClicked not found!!

and I think we must change the OnHoverRate function
and not insert another click or Brclicked
when Mouse move on a star before it must draw half then full then half(2) then full(2(..... I hope you understood me !!!
Last edited by Silvio.Falconi on Sun Dec 28, 2014 12:24 pm, edited 1 time in total.
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
User avatar
ukoenig
Posts: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Re: New Rating Class

Post by ukoenig »

Silvio,

the Array is added to locals

Local i, aClicked[5]

best regards
Uwe :lol:
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: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Re: New Rating Class

Post by ukoenig »

Silvio,

I think it is possible.
Maybe using a half star-left and a half star-right ( 10 images instead of 5, NO full star is used )
Would be a minimum on change.

best regards
Uwe :?:
Last edited by ukoenig on Sun Dec 28, 2014 12:35 pm, edited 1 time in total.
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
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Re: New Rating Class

Post by Silvio.Falconi »

Uwe Look this now I add also yours features

Code: Select all

#include "Fivewin.ch"
#include "Image.ch"
#include "Constant.ch"

 STATIC count, pressed, aRate, nValue ,cRate
 STATIC Empty_Img,Full_Img,Half_Img,oSay1

  STATIC aClicked[5]




Function test()

   nValore:= RatingBook("c:\work\fwh\bitmaps\007.bmp")


   Msginfo(nValore)

   return nil





Function RatingBook(cBook)
Local oDlg

Local oCursorBtn :=TCursor():New(,'HAND')
Local img_name, col
Local i
Local oBook
Local oBtnConfirm


       aRate:= {"10%","20%","30%","40%","50%"}
       pressed := 0
       col := 60
       count := 5
       nRow := 140
       Empty_Img:= ".\bitmaps\Emptyh.bmp"
       Full_Img:= ".\bitmaps\Fullh.bmp"
       Half_Img:=".\bitmaps\Halfh.bmp"
       nValue:= 0
       cRate := "0%"

       DEFINE FONT oFont NAME "Tahoma" SIZE 0, -12



define Dialog oDlg size 400,300  TITLE "Rating a Book"


         @ 1,5 bitmap oBook filename "c:\work\fwh\bitmaps\007.bmp" size 100,120 Noborder OF oDlg



@ nRow, 3 say "My Rating ("  SIZE 59, 10 OF oDlg  PIXEL
@ nRow, 55 say ")"  SIZE 2, 10 OF oDlg  PIXEL


        oReset := TUrlLink():New( nRow+0.2, 39, oDlg, .T., .F., oFont, "", "Reset" )
        oReset:SetColor(  oReset:nClrText, oDlg:nClrPane )
        oReset:nClrOver = CLR_RED
        oReset:bAction =  { || ( pressed := 5, Reset(pressed) ) }
        nCol:= 62





       @ nRow, nCol IMAGE Image_1 SIZE 12, 12 OF oDlg  FILENAME Empty_Img PIXEL  NOBORDER  CURSOR oCursorBtn    ON CLICK ( pressed :=1,OnSelectRate(pressed,count,oSay1))
       nCol += 12
       @ nRow, nCol IMAGE Image_2 SIZE 12, 12 OF oDlg  FILENAME Empty_Img PIXEL  NOBORDER  CURSOR oCursorBtn    ON CLICK ( pressed :=2,OnSelectRate(pressed,count,oSay1))
       nCol += 12
       @ nRow, nCol IMAGE Image_3 SIZE 12, 12 OF oDlg  FILENAME Empty_Img PIXEL  NOBORDER  CURSOR oCursorBtn    ON CLICK ( pressed :=3,OnSelectRate(pressed,count,oSay1))
       nCol += 12
       @ nRow, nCol IMAGE Image_4 SIZE 12, 12 OF oDlg  FILENAME Empty_Img PIXEL  NOBORDER  CURSOR oCursorBtn    ON CLICK ( pressed :=4,OnSelectRate(pressed,count,oSay1))
       nCol += 12
       @ nRow, nCol IMAGE Image_5 SIZE 12, 12 OF oDlg  FILENAME Empty_Img PIXEL  NOBORDER  CURSOR oCursorBtn    ON CLICK ( pressed :=5,OnSelectRate(pressed,count,oSay1))


       @ nRow + 2, 135 SAY oSay1 PROMPT cRate OF oDlg SIZE 30, 12 COLOR CLR_RED PIXEL FONT oFont
                  oSay1:lTransparent := .T.




                      Image_1:bMMoved:= { ||( pressed :=1,OnHoverRate(pressed,count)) }
                      Image_2:bMMoved:= { ||( pressed :=2,OnHoverRate(pressed,count)) }
                      Image_3:bMMoved:= { ||( pressed :=3,OnHoverRate(pressed,count)) }
                      Image_4:bMMoved:= { ||( pressed :=4,OnHoverRate(pressed,count)) }
                      Image_5:bMMoved:= { ||( pressed :=5,OnHoverRate(pressed,count)) }

                      Image_1:bMLeave :={ ||( pressed :=1,OnLeaveRate(pressed,count)) }
                      Image_2:bMLeave :={ ||( pressed :=2,OnLeaveRate(pressed,count)) }
                      Image_3:bMLeave :={ ||( pressed :=3,OnLeaveRate(pressed,count)) }
                      Image_4:bMLeave :={ ||( pressed :=4,OnLeaveRate(pressed,count)) }
                      Image_5:bMLeave :={ ||( pressed :=5,OnLeaveRate(pressed,count)) }


                   /*    Image_1:bRClicked := { || cRate := aRate[1], oSay1:Refresh(), SetHalf(count, 1, aClicked ) }
                       Image_2:bRClicked := { || cRate := aRate[2], oSay1:Refresh(), SetHalf(count, 2, aClicked ) }
                       Image_3:bRClicked := { || cRate := aRate[3], oSay1:Refresh(), SetHalf(count, 3, aClicked ) }
                       Image_4:bRClicked := { || cRate := aRate[4], oSay1:Refresh(), SetHalf(count, 4, aClicked ) }
                       Image_5:bRClicked := { || cRate := aRate[5], oSay1:Refresh(), SetHalf(count, 5, aClicked ) }
                       */




      FOR k:=1 TO count
          img_name := "Image_"+hb_ntos(k)
          &img_name:lTransparent := .T.
      NEXT







                      @ 138, 160 button oBtnConfirm  Prompt "&Exit" SIZE 30, 10 OF oDlg PIXEL  action oDlg:end()








          Activate Dialog oDlg  center
     RETURN  nValue




Function SetHalf(select, nPos, aClicked)
Local j

FOR j:=1 TO select
   img_name := "Image_" + hb_ntos(j)
   IF j = nPos // the RIGHT clicked full star
      aClicked[nPos] := 2 // clicked-status for the half star, 1 = full
      &img_name:LoadBmp( Half_Img )
   ENDIF
NEXT

Return Nil








//-------------------------------------------------------------//
Function OnHoverRate(select,count)
   Local j

Reset(count)

FOR j:=1 TO select
      img_name := "Image_"+hb_ntos(j)
     &img_name:LoadBmp(Full_Img)

  NEXT
     SetHalf(count,  select, aClicked )
   nValue:= aRate[ select]

        cRate := aRate[ select]
   oSay1:Refresh()


Return Nil

//------------------------------------------------------//
Function OnLeaveRate(pressed,count)

   IF pressed == 0
      Reset(count)
   ELSE
      OnSelectRate(pressed,count)
   ENDIF

   Return Nil

//-------------------------------------------------------//
Function OnSelectRate(pressed,count,oSay1)
Local k
Local img_name

IF pressed > 0

      Reset(count)
      SetHalf(count, pressed, aClicked )

    /*  FOR k:=1 TO pressed
         img_name := "Image_"+hb_ntos(k)
        &img_name:LoadBmp(Full_Img)

     NEXT */

     cRate := aRate[pressed]
   oSay1:Refresh()


   ENDIF




  nValue:= aRate[pressed]

   Return Nil

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

Static Function Reset(count)
   Local x
    Local img_name
  //

   FOR x:=1 TO count
    img_name := "Image_"+hb_ntos(x)
   &img_name:LoadBmp(Empty_Img)
   NEXT

   Return Nil

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






 

Now when we move the mouse on a star before it draw half then full and change also the osay1
only the last one error is the osay not change of half value but only when the value is a INTER


sorry I made a mistake ..

you must change this line s

Empty_Img:= ".\bitmaps\Empty.bmp"
Full_Img:= ".\bitmaps\Full.bmp"
Half_Img:=".\bitmaps\Half.bmp"


instead of

Empty_Img:= ".\bitmaps\Emptyh.bmp"
Full_Img:= ".\bitmaps\Fullh.bmp"
Half_Img:=".\bitmaps\Halfh.bmp"
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Re: New Rating Class

Post by Silvio.Falconi »

I tried to change sethalf function inserting the half value but it not run ok

Function SetHalf(select, nPos, aClicked)
Local j

FOR j:=1 TO select
img_name := "Image_" + hb_ntos(j)
IF j = nPos // the RIGHT clicked full star
aClicked[nPos] := 2 // clicked-status for the half star, 1 = full
&img_name:LoadBmp( Half_Img )
ENDIF
NEXT

value:= val(aRate[ select])/2
cRate :=str( value,2)+"%"


oSay1:Refresh()




Return Nil


Image


it must be 35 % and not 40%
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
Post Reply