#INCLUDE "Fivewin.ch"
#INCLUDE "Ribbon.ch"
#include "constant.ch"
#INCLUDE "XBROWSE.ch"
Function Promo_ListVw()
Local oDlg,oBtn1,oBtn2
Local bClrGrad := { | lPressed | If( ! lPressed,;
{ { 1, nRGB( 253, 254, 255 ), nRGB( 179, 217, 255 ) } },;
{ { 1, nRGB( 179, 217, 255 ), nRGB( 253, 254, 255 ) } } ) }
Local nBottom := 23
Local nRight := 39
Local nWidth := Max( nRight * DLG_CHARPIX_W, 180 )
Local nHeight := nBottom * DLG_CHARPIX_H
Local lGridAll := TRUE
Local lGridRow := FALSE
Local oBtnConferma,oBtnAnnulla
Local oGridPromo,oBtnDown,oListView, oImageList
Local aPromozioni := {}
Local aPromoImages:= {}
CreateTestDbf()
SetDlgGradient( { { 1, RGB( 199, 150, 237 ), RGB( 237, 242, 248 ) } } )
DEFINE DIALOG oDlg SIZE nWidth, nHeight;
TITLE "Selezionare una promozione";
STYLE nOr( DS_MODALFRAME, WS_POPUP, WS_CAPTION, 4 )
@ 40,14 SAY "Riga"+CRLF+"corrente" OF oDlg PIXEL SIZE 40,16
@ 40,49 SAY "Tutto il"+CRLF+"documento" OF oDlg PIXEL SIZE 40,16
@ 15,10 RBBTN oBtn1 BITMAP ".\bitmaps\ONE.BMP" SIZE 25,25 OF oDlg PIXEL ;
ACTION (obtn1:lSelected:=.t.,obtn1:REFRESH(),lGridRow:=FALSE,lGridAll:=TRUE,;
obtn2:lSelected:=.f.,obtn2:REFRESH(),lGridRow:=TRUE,lGridAll:=FALSE)
@ 15,45 RBBTN oBtn2 BITMAP ".\bitmaps\TODO.BMP" SIZE 25,25 OF oDlg PIXEL ;
ACTION (obtn1:lSelected:=.F.,obtn1:REFRESH(),lGridRow:=TRUE,lGridAll:= FALSE,;
obtn2:lSelected:=.t.,obtn2:REFRESH(),lGridRow:=FALSE,lGridAll:=TRUE)
USE PROMO ALIAS PR
DO WHILE ! PR->(EoF())
AAdd( aPromozioni,( TRIM(PR->PRDESC)))
AAdd( aPromoImages,( allTRIM(PR->PRIMAGE)))
PR->(DbSkip())
ENDDO
CLOSE PR
oImageList = TImageList():New( 48, 48 )
@ 5,2 GROUP TO 60,150 OF oDlg LABEL "Ambito della promozione" PIXEL TRASPARENT
@ 63,2 GROUP TO 145,150 OF oDlg LABEL "Elenco promozioni" PIXEL TRASPARENT
@ 150, 50 BTNBMP oBtnConferma PROMPT "&Conferma" OF oDlg FILENAME ".\bitmaps\DLG_OK.bmp" NOBORDER SIZE 50, 20 PIXEL DEFAULT ACTION ( oDlg:end( IDOK ) )
@ 150, 102 BTNBMP oBtnAnnulla PROMPT "&Annulla" OF oDlg FILENAME ".\bitmaps\DLG_NO.bmp" NOBORDER SIZE 50, 20 PIXEL CANCEL ACTION ( oDlg:end( IDCANCEL ) )
oBtnConferma:bClrGrad = bClrGrad
oBtnAnnulla:bClrGrad = bClrGrad
oBtnConferma:nLayout :=2
oBtnAnnulla:nLayout :=2
ACTIVATE DIALOG oDlg ;
ON INIT CreaListview(oImageList,aPromozioni,aPromoImages, oDlg)
IF oDlg:nresult == IDOK
ENDIF
RETURN NIL
FUNCTION CreaListview(oImageList,aPromozioni,aPromoImages, oDlg)
Local oLvw,oBtnUp,oBtnDown
@ 145, 10 LISTVIEW oLvw SIZE 280,130 PIXEL ;
ACTION MsgInfo( nOption )
for i=1 to len(aPromozioni)
oLvw:InsertItem(i-1 , aPromozioni[i] )
oImageList:ReadBitmap( aPromoImages[i], 40,1)
Next i
oLvw:SetImageList( oImageList )
@ 300,5 RBBTN oBtnUp BITMAP ".\bitmaps\Up.BMP" SIZE 40,40 OF oDlg PIXEL ;
BORDER CENTER ROUND ROUNDSIZE 2;
ACTION oLvw:KeyDown(VK_UP, 0)
@ 300,55 RBBTN oBtnDown BITMAP ".\bitmaps\Down.BMP" SIZE 40,40 OF oDlg PIXEL;
BORDER CENTER ROUND ROUNDSIZE 2;
ACTION oLvw:KeyDown(VK_DOWN, 0)
RETU NIL
static function CreateTestDbf()
local aCols := { { "PRCODE", 'C', 4, 0 }, { "PRDESC", 'C', 40, 0 }, ;
{ "PRIMAGE", 'C', 60, 0 } }
if .t. // ! File( "PROMO.DBF" )
DBCREATE( "PROMO", aCols )
USE PROMO EXCLUSIVE
APPEND BLANK
FIELD->PRCODE :="0001"
FIELD->PRDESC :="PROMOZIONE DI NATALE "
FIELD->PRIMAGE:=".\bitmaps\verde.ico "
APPEND BLANK
FIELD->PRCODE :="0002"
FIELD->PRDESC :="PROMOZIONE DI PASQUA "
FIELD->PRIMAGE:=".\bitmaps\ROSSO.ico "
USE
endif
return nil