design n 1
conten n 1
global n 1
the values are from 0 to 9
I wish show on xbrowse until 5 stars on each columns (or also a graph)
how I must make it ?
if you hear about last year I published a small test to show 5 stars to show enhancement in a dialog. I wanted to create the class but no one then helped me
the test want 3 bmps
Empty_Img:= ".\bitmaps\Empty.bmp"
Full_Img:= ".\bitmaps\Full.bmp"
Half_Img:=".\bitmaps\Half.bmp"
test.prg
- Code: Select all Expand view
#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\Empty.bmp"
Full_Img:= ".\bitmaps\Full.bmp"
Half_Img:=".\bitmaps\Half.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)) }
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 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 )
IF select >1
nValue:= select-1
endif
nValuePressed:= val(aRate[select])-5
cRate := str(nValuePressed,2)+"%"
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)
FOR k:=1 TO pressed
img_name := "Image_"+hb_ntos(k)
&img_name:LoadBmp(Full_Img)
NEXT
SetHalf(count, pressed, aClicked )
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
//-----------------------------------------------------//
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
someone can help me to show the stars into xbrowse ?