#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
//-----------------------------------------------------//
#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
//-----------------------------------------------------//
// 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
#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
//-----------------------------------------------------//
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Google [Bot] and 83 guests