Ribbonbar & XbrGetDate
Posted: Fri May 31, 2019 7:17 am
I insert two get on a ribbonbar ( oGr1 )
on this get I need to have a string type " Monday, 3 May 2019" and before converte the date into this string with Convertidata(dTemp) function then I must converte to date with Conv_Textdate( cDate, nLanguage )
If i insert { dDataInizialeStagione},{ dDataFinaleStagione}
instead of {^ 2019/05/15 }, {^ 2019/05/30 } make error
then the calendar is too big and not near on the get
I insert limit of dates on two variable
Local dDataLimite1:={^ 2019/05/15 }
Local dDatalimite2 :={^ 2019/05/30 }
But I not Know how converte "15/05/2019" into {^ 2019/05/15 }
I have the date from Inifile select by user
on this get I need to have a string type " Monday, 3 May 2019" and before converte the date into this string with Convertidata(dTemp) function then I must converte to date with Conv_Textdate( cDate, nLanguage )
If i insert { dDataInizialeStagione},{ dDataFinaleStagione}
instead of {^ 2019/05/15 }, {^ 2019/05/30 } make error
then the calendar is too big and not near on the get
I insert limit of dates on two variable
Local dDataLimite1:={^ 2019/05/15 }
Local dDatalimite2 :={^ 2019/05/30 }
But I not Know how converte "15/05/2019" into {^ 2019/05/15 }
I have the date from Inifile select by user
Code: Select all
#include "fivewin.ch"
#include "ribbon.ch"
STATIC oWnd
STATIC oDlgRB[3]
REQUEST HB_Lang_IT
REQUEST HB_CODEPAGE_ITWIN
function main()
local oRBar
local oMenu, oMenuWnd, oBrush1
local oGr1,oBtn[6]
LOCAL oSay1, oBmp, oFont1,oFont2
LOCAL oCursor
Local cIniFile :=TakeOffExt( GetModuleFileName( GetInstance() ) ) + ".ini"
Local nHeightRib:=125
Local dBassa1 := GetPvProfString("Stagioni", "BASSA1","17.05.", cIniFile)
Local dBassa4 := GetPvProfString("Stagioni", "BASSA4","20.09.", cIniFile)
Local dDataInizialeStagione:= ctod( dBassa1+ltrim(str(year(date()))))
Local dDataFinaleStagione:= ctod( dBassa4+ltrim(str(year(date()))))
Local dDataIniziale:= date(),dDatafinale:=date()
Local dtemp1
Local aBtnfw :={ FW_BmpPlus(), FW_BmpMinus() }
Local dDataLimite1:={^ 2019/05/15 }
Local dDatalimite2 :={^ 2019/05/30 }
Local cCalendarBmp:="c:\work\fwh\bitmaps\32x32\calendar.bmp"
MENU oPopupDate POPUP 2015
MENUITEM "Today" ACTION ( dDataIniziale :=date(),;
dDataFinale :=date(),;
oDate1:cText(Convertidata(dDataIniziale)),;
oDate2:cText(Convertidata(dDataFinale)) ,;
oDate1:refresh(),;
oDate2:refresh())
MENUITEM "Tomorrow" ACTION ( dDataIniziale :=date()+1,;
dDataFinale :=date()+1, ;
oDate1:cText(Convertidata(dDataIniziale)),;
oDate2:cText(Convertidata(dDataFinale)) ,;
oDate1:refresh(),;
oDate2:refresh())
MENUITEM "After tomorrow" ACTION ( dDataIniziale :=date()+2,;
dDataFinale :=date()+2, ;
oDate1:cText(Convertidata(dDataIniziale)),;
oDate2:cText(Convertidata(dDataFinale)) ,;
oDate1:refresh(),;
oDate2:refresh())
ENDMENU
HB_LangSelect("IT")
HB_SetCodePage("ITWIN")
SET DATE FORMAT "dd-mm-yyyy"
SET DELETED ON
SET CENTURY ON
SET EPOCH TO year( date() ) - 20
SET MULTIPLE OFF
dtemp1 := Convertidata(dDataIniziale)
dtemp2 := Convertidata(dDataFinale)
DEFINE FONT oFont1 NAME "Arial" SIZE 0,-30 // BOLD
DEFINE FONT oFont2 NAME "TAHOMA" SIZE 0,-14
DEFINE CURSOR oCursor HAND
DEFINE WINDOW oWnd TITLE "RibbonBar Test " + FWVERSION from 1,1 to 600,600 pixel
DEFINE RIBBONBAR oRBar WINDOW oWnd PROMPT "Prenotazioni","Gestione","Stampe";
HEIGHT nHeightRib TOPMARGIN 25
oRBar:l2016:=.t.
oRBar:nRoundBox := 0
ADD GROUP oGr1 RIBBON oRBar TO OPTION 1 PROMPT "select date" width 680
oGr1:l2013:=.t.
@ 5,0 ADD BUTTON oBtn[1] PROMPT "Calendario" ;
BITMAP cCalendarBmp ;
GROUP oGr1 ROUND SIZE 68,72 SPLITPOPUP MENU oPopupDate
//gets
@ 6,74 GET oDate1 VAR dtemp1 SIZE 260,28 PIXEL OF oGr1 FONT oFont2;
ACTION ( dtemp1:= XbrGetDate(Conv_Textdate(dtemp1,3),;
"Select Date",,,.t.,0.9 ),;
( IIF( dtemp1=ctod("") .or. dtemp1=nil ,;
oDate1:cText( "Selezionare una data") ,;
oDate1:cText(Convertidata(dtemp1)) ),;
dDataIniziale:=dtemp1 ,;
oDate1:refresh() )) ;
BITMAP cCalendarBmp
@ 6,354 GET oDate2 VAR dtemp2 SIZE 260,28 PIXEL OF oGr1 FONT oFont2;
ACTION (dtemp2:= XbrGetDate( Conv_Textdate(dtemp2,3),;
"Select Date",dDataLimite1,dDataLimite2, .t.,0.9 ),;
( IIF( dtemp2=ctod("") .or. dtemp2=nil ,;
oDate2:cText( "Selezionare una data") ,;
oDate2:cText(Convertidata(dtemp2)) ),;
dDatafinale:=dtemp2 ,;
oDate2:refresh() )) ;
BITMAP cCalendarBmp
// buttons
@ 45,72 ADD BUTTON oBtn[2] ;
BITMAP aBtnfw[2] ; //"BTN_PNG_MINUS" ;
GROUP oGr1 SIZE 28,25;// 60,25 ;
ACTION (oDate1:cText(Convertidata(dDataIniziale--)) ,oDate1:REFRESH()) BORDER
@ 45,300 ADD BUTTON oBtn[3] ;
BITMAP aBtnfw[1] ; //"BTN_PNG_PLUS" ;
GROUP oGr1 SIZE 28,25; // 60,25 ;
ACTION (IF( dDataIniziale<dDataFinale,dDataIniziale++,;
(oDate1:cText(Convertidata(dDataIniziale++)), oDate2:cText(Convertidata(dDataFinale++)))),;
oDate1:REFRESH(),;
oDate2:REFRESH()) BORDER
@ 45,356 ADD BUTTON oBtn[4] ;
BITMAP aBtnfw[2] ; //"BTN_PNG_MINUS" ;
GROUP oGr1 SIZE 28,25; // 60,25 ;
ACTION ( IF( dDataFinale=dDataIniziale,,oDate2:cText(Convertidata(dDataFinale--))),;
oDate2:REFRESH()) BORDER
@ 45,586 ADD BUTTON oBtn[5] ;
BITMAP aBtnfw[1] ; //"BTN_PNG_PLUS" ;
GROUP oGr1 SIZE 28,25; // 60,25 ;
ACTION ( oDate2:cText(Convertidata(dDatafinale++)),oDate2:REFRESH()) BORDER
oRBar:nLeftMargin = 40
oRBar:CalcPos()
oRBar:bRClicked := { || .t. }
SET MESSAGE OF oWnd TO "Testing XbrGetDate on RibbonBar" CENTERED CLOCK KEYBOARD
WndCenter(oWnd:hWnd)
ACTIVATE WINDOW oWnd MAXIMIZED
oRBar:End()
return nil
//--------------------------------------------------------------//
// date to string
Function Convertidata(dTemp)
LOCAL f, m, cMese, dFech,dDay,d
Local i,c
local aMesi[ 12 ]
local aWeek[ 7 ]
AEval( aMesi, { |c,i| aMesi[ i ] := NToCMonth( i ) } )
AEval( aWeek, { |c,i| aWeek[ i ] := NToCDOW( i ) } )
f:=DTOS (dTemp)
m:=MONTH(dTemp)
d:=dow(dtemp)
cMese:=IF(m<>0, aMesi[m] ,"" )
dday :=IF(d<>0, oemtoansi(aWeek[d]) ,"")
dFech:=IF(m<>0,dday+", "+ SubStr(f,7,2)+' '+cMese+' '+SubStr(f,1,4),'')
RETURN (dFech)
//--------------------------------------------------------------//
// string to date
FUNCTION Conv_Textdate( cDate, nLanguage ) //Uwe
LOCAL cText := "", I := 2, cMonthName := ""
FOR I := 2 TO 4
IF I < 4
IF I = 2
cText += LTRIM( StrToken( cDate, I, " " ) ) + "." // Day
ELSEIF I = 3
cMonthName := StrToken( cDate, 3, " " )
// MsgAlert(cMonthName, "month-name from string" )
cText += TestoMese( cMonthName, nLanguage ) + "."
ENDIF
ELSE
cText += LTRIM( StrToken( cDate, I, " " ) ) // Year
ENDIF
NEXT
RETURN( cTOD( cText ) )
//--------------------------------------------------------------//
STATIC FUNCTION TestoMese( cMonthName, nLanguage )
LOCAL aMonth :={}, cMonthConv := " "
//english, Germany,Italian,Spagnol
AADD( aMonth, { "January", "Januar", "Gennaio", "Enero", "01" } )
AADD( aMonth, { "February" , "Februar", "Febbraio", "Febrero" , "02" } )
AADD( aMonth, { "March", "März", "Marzo", "Marzo", "03" } )
AADD( aMonth, { "April" , "April", "Aprile", "Abril", "04" } )
AADD( aMonth, { "Mai", "Mai", "Maggio", "Mayo", "05" } )
AADD( aMonth, { "June", "Juni", "Giugno", "Junio", "06" } )
AADD( aMonth, { "July", "Juli", "Luglio", "Julio", "07" } )
AADD( aMonth, { "August", "August", "Agosto", "Agosto", "08" } )
AADD( aMonth, { "September", "September", "Settembre" , "Septiembre", "09" } )
AADD( aMonth, { "October", "Oktober", "Ottobre", "Octubre", "10" } )
AADD( aMonth, { "November", "November", "Novembre", "Noviembre", "11" } )
AADD( aMonth, { "December", "Dezember", "Dicembre", "Diciembre", "12" } )
FOR I := 1 TO 12
IF aMonth[I][nLanguage] = cMonthName
cMonthConv := aMonth[I][5]
ENDIF
NEXT
// MsgAlert(cMonthSel, "converted month" )
RETURN( cMonthConv )
//--------------------------------------------------------------//
FUNCTION TakeOffExt(cFile)
local nAt := At(".", cFile)
if nAt > 0
cFile := Left(cFile, nAt-1)
endif
RETURN cFile
//--------------------------------------------------------------//