New Class: TCalendar

New Class: TCalendar

Postby Daniel Garcia-Gil » Sun Apr 18, 2010 10:53 pm

Hello...

New Class to SysMonthCal32 window control, now inside fivewin

we can make calendars and config very easy
3 important features:

1) we can set "BOLD" some days, using MCS_DAYSTATE style (see sample bellow)

2) dobleclik is enable over days, the control nos support this feature but is simulate perfectly

3) Launch action (bAction) with ENTER

http://www.sitasoft.net/fivewin/samples/testcal.zip

Image
Code sample

Code: Select all  Expand view

#include "FiveWin.ch"
#include "dtpicker.ch"
#include "calendar.ch"
#include "wcolors.ch"

FUNCTION Main()
   LOCAL oWnd, oCal, oDtp1, oDtp2, oDtp3, oDtp4, oCbx
   LOCAL oSayClr
   LOCAL nColor
   LOCAL dDate1, dDate2, dDate3, dDate4, dDate5, dDate6
   LOCAL cItemClr
   LOCAL lWeekNumbers   := .F.
   LOCAL lNoTodayCircle := .F.
   LOCAL lNoToday       := .F.
   LOCAL lDayState      := .F.
   LOCAL oRange3, aRanges2 := { , }
   LOCAL oRange4
   LOCAL aColorItems    := { "MCSC_BACKGROUND  " ,;
                             "MCSC_TEXT        " ,;
                             "MCSC_TITLEBK     " ,;
                             "MCSC_TITLETEXT   " ,;
                             "MCSC_MONTHBK     " ,;
                             "MCSC_TRAILINGTEXT" }
   LOCAL oDayOfWeek, cDayOfWeek:="Monday", aDayOfWeek:={"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"}                          
   
   LOCAL oCal2
   LOCAL oRange1, aRanges := { , }
   LOCAL oRange2
   LOCAL oMax, nMax
   LOCAL lSunday   := .T.
   LOCAL lSaturday := .T.



     SET DATE TO BRITISH
     SET EPOCH TO 1980  
   dDate1 = Date()
   dDate2 = Date()
   dDate3 = Date()
   dDate4 = Date() + 7
   dDate5 = Date()
   dDate6 = Date()
 
   DEFINE WINDOW oWnd TITLE "Test Calendar" FROM 0, 0 TO 600, 600 PIXEL
 
   // Start Calendar 1
 
 
  @ 001, 205 CALENDAR oCal VAR dDate1 OF oWnd PIXEL;
              DBLCLICK MsgInfo( oCal:GetDate() );
              ON CHANGE oDtp2:cText := oCal:GetDate() SIZE 200, 170;
              ACTION( MsgInfo( "ok" ) );
              WEEKNUMBER
             
   @ 001, 001 BUTTON "Get Today" OF oWnd PIXEL SIZE 100, 020 ACTION oDtp1:cText := oCal:GetToday()
   @ 025, 001 BUTTON "Set Today" OF oWnd PIXEL SIZE 100, 020 ACTION oCal:SetToday( dDate1 )
   @ 012, 105 DTPICKER oDtp1 VAR dDate1 OF oWnd PIXEL
   @ 050, 001 BUTTON "Get Color" OF oWnd PIXEL SIZE 100, 020 ACTION( oSayClr:SetColor( CLR_BLACK, oCal:GetColors( oCbx:nAt - 1 ) ), oSayClr:Refresh() )
   @ 050, 105 BUTTON "Set Color" OF oWnd PIXEL SIZE 100, 020 ACTION( nColor := ChooseColor(), ;
                                                                     oCal:SetColor( oCbx:nAt - 1, nColor ), ;
                                                                     oSayClr:SetColor( CLR_BLACK, nColor ),;
                                                                     oSayClr:Refresh() )
                                                                     
   @ 075, 001 COMBOBOX oCbx VAR cItemClr PROMPTS aColorItems PIXEL SIZE 205, 200 OF oWnd
   @ 100, 001 SAY oSayClr VAR "        " PIXEL SIZE 100, 020 OF oWnd BORDER
   
   @ 125, 001 BUTTON "Get 1 Day Week" OF oWnd SIZE 100, 20 PIXEL ACTION( cDayofWeek := aDayOfWeek[ oCal:GetFirstDayOfWeek() + 1 ], oDayOfWeek:Refresh() )
   @ 125, 105 BUTTON "Set 1 Day Week" OF oWnd SIZE 100, 20 PIXEL ACTION( oCal:SetFirstDayOfWeek( oDayOfWeek:FindString( cDayOfWeek ) - 1 ) )
   
   @ 150, 001 COMBOBOX oDayOfWeek VAR cDayofWeek ITEMS aDayOfWeek OF oWnd SIZE 205, 200 PIXEL

   @ 175, 001 BUTTON "Get Selected Day" OF oWnd PIXEL SIZE 100, 020 ACTION Msginfo( oCal:GetDate() )
   @ 200, 001 BUTTON "Set Selected Day" OF oWnd PIXEL SIZE 100, 020 ACTION oCal:SetDate( dDate2 )
   @ 186, 105 DTPICKER oDtp2 VAR dDate2 OF oWnd PIXEL  

   @ 175, 210 BUTTON "Get Range" OF oWnd PIXEL SIZE 100, 020 ;
              ACTION( aRanges2 := oCal:GetRange(), oRange3:Refresh(), oRange4:Refresh() )
   @ 175, 310 GET oRange3 VAR aRanges2[ 1 ] OF oWnd SIZE 100, 20 PIXEL
   @ 175, 420 GET oRange4 VAR aRanges2[ 2 ] OF oWnd SIZE 100, 20 PIXEL

   @ 200, 210 BUTTON "Set Range" OF oWnd PIXEL SIZE 100, 020 ACTION oCal:SetRange( dDate5, dDate6 )
   @ 200, 315 DTPICKER oDtp3 VAR dDate5 OF oWnd PIXEL
   @ 200, 420 DTPICKER oDtp4 VAR dDate6 OF oWnd PIXEL
   
   @ 001, 410 CHECKBOX oCal:lWeekNumbers PROMPT "Week Numbers" OF oWnd SIZE 100, 20 PIXEL;
              ON CHANGE  oCal:SetWeekNumbers( oCal:lWeekNumbers )
   
   @ 025, 410 CHECKBOX oCal:lNoTodayCircle PROMPT "No Today Circle" OF oWnd SIZE 100, 20 PIXEL;
              ON CHANGE  oCal:SetNoTodayCircle( oCal:lNoTodayCircle )
             
   @ 050, 410 CHECKBOX oCal:lNoToday PROMPT "No Today" OF oWnd SIZE 100, 20 PIXEL;
              ON CHANGE  oCal:SetNoToday( oCal:lNoToday )

     oCal:bGotFocus  := {|| oCal:SetTitleBk( CLR_YELLOW ) }
     oCal:bLostFocus := {|| oCal:SetTitleBk( GetSysColor( COLOR_ACTIVECAPTION ) ) }
   
   // Start Calendar 2
             
   @ 250, 001 CALENDAR oCal2 VAR dDate3, dDate4 OF oWnd PIXEL MULTISELECT DAYSTATE;
              DBLCLICK MsgInfo( oCal2:GetDate() ) SIZE 550, 170 COLOR CLR_BLACK, CLR_HRED

   @ 230, 001 SAY "MONTHS DISPLAYED: " + StrZero( ocal2:GetVisibleMonths(), 2 )  OF oWnd PIXEL COLOR CLR_WHITE, CLR_BLACK

   @ 430, 001 BUTTON "Get Selected Range" OF oWnd SIZE 100, 20 PIXEL ;
              ACTION( aRanges := oCal2:GetDateRange(), oRange1:Refresh(), oRange2:Refresh() )
   @ 430, 105 GET oRange1 VAR aRanges[ 1 ] OF oWnd SIZE 100, 20 PIXEL
   @ 430, 210 GET oRange2 VAR aRanges[ 2 ] OF oWnd SIZE 100, 20 PIXEL

     oCal2:bGotFocus  := {|| oCal2:SetTitleBk( CLR_YELLOW ) }
     oCal2:bLostFocus := {|| oCal2:SetTitleBk( CLR_HRED ) }

   nMax = oCal2:GetMaxSelCount()
   
   @ 455, 001 BUTTON "Set Max Selected Day" OF oWnd SIZE 150, 20 PIXEL ;
              ACTION( oCal2:SetMaxSelCount( nMax ) )
             
   @ 455, 155 GET oMax VAR nMax OF oWnd SIZE 50, 20 PIXEL SPINNER ;
              MIN 1 MAX 60
             
   @ 480, 001 CHECKBOX oCal2:lDayState PROMPT "Day State" OF oWnd SIZE 100, 20 PIXEL;
              ON CHANGE( oCal2:SetDayStateStyle( oCal2:lDayState ), ;
                        If( oCal2:lDayState, ( OnGetState( oCal2, lSunday, lSaturday ), oCal2:SetDayState() ), ) )

   @ 505, 001 CHECKBOX lSunday PROMPT "Bold Sunday" OF oWnd SIZE 100, 20 PIXEL

   @ 530, 001 CHECKBOX lSaturday PROMPT "Bold Saturday" OF oWnd SIZE 100, 20 PIXEL

    OnGetState( oCal2, lSunday, lSaturday )
    oCal2:SetDayState()
    oCal2:bOnGetState = { | oCal | OnGetState( oCal, lSunday, lSaturday ) }
   
   
   ACTIVATE WINDOW oWnd

 
RETURN NIL


Function OnGetState( oCal, lSun, lSat )
   LOCAL i, imax, j, jmax, nDay, nDayState, nMonth
   LOCAL dStartDate
   LOCAL dCurrentDay := oCal:dDate
 
   oCal:GetMonthRange()
   
   dStartDate = oCal:dDate

   imax   := Len( oCal:aDayState )
   nMonth := Month( dStartDate )


   FOR i:=1 TO imax
      nDayState := 0

      FOR j:=1 TO 31
         nDay := DoW( dStartDate ) - 2
         IF nDay < 0
            nDay += 7
         ENDIF

         IF nDay == 5 .AND. lSat
            oCal:SetArrayDayState( i, j )
         ENDIF

         IF nDay == 6 .AND. lSUN
            oCal:SetArrayDayState( i, j )
         ENDIF
         
         dStartDate ++

         IF Month( dStartDate ) <> nMonth
            EXIT
         ENDIF
      NEXT

      nMonth       := Month( dStartDate )
   NEXT

   oCal:SetDate( dCurrentDay )

return nil
 
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: New Class: TCalendar

Postby driessen » Mon Apr 19, 2010 10:30 am

Daniel,

It looks great. Thanks for your efforts.

But where do we find calendar.ch ?
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Re: New Class: TCalendar

Postby Daniel Garcia-Gil » Mon Apr 19, 2010 11:28 am

Driessen,

driessen wrote:But where do we find calendar.ch ?


will come next fivewin version
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: New Class: TCalendar

Postby driessen » Mon Apr 19, 2010 11:31 am

Daniel,

Thanks for the info.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Re: New Class: TCalendar

Postby MdaSolution » Fri Apr 23, 2010 6:52 am

DAniel,
Why not create Tcalendar as OUTLOOK CALENDAR with day, Week, Mounth show header and th epossbility to create an appointment, I think this is not hard for you.
FWH .. BC582.. xharbour
User avatar
MdaSolution
 
Posts: 401
Joined: Tue Jan 05, 2010 2:33 pm

Re: New Class: TCalendar

Postby Otto » Fri Apr 23, 2010 9:00 am

MdaSolution,

Have a look at this thread:

viewtopic.php?f=3&t=12150&p=60535&hilit=pickdate#p60535


http://atzwanger-software.com/fw/wellness/wellness.html


You can change the class. This is what I use it for.
Best regards,
Otto

Image
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6332
Joined: Fri Oct 07, 2005 7:07 pm

Re: New Class: TCalendar

Postby MdaSolution » Fri Apr 23, 2010 12:58 pm

Otto,
I saw your pickdate
But where I can create a test as your picture (http://www.atzwanger-software.com/fw/wellness2.jpg) ?
thanks
FWH .. BC582.. xharbour
User avatar
MdaSolution
 
Posts: 401
Joined: Tue Jan 05, 2010 2:33 pm

Re: New Class: TCalendar

Postby Daniel Garcia-Gil » Fri Apr 23, 2010 1:09 pm

Hello

MdaSolution wrote:DAniel,
Why not create Tcalendar as OUTLOOK CALENDAR with day, Week, Mounth show header and th epossbility to create an appointment, I think this is not hard for you.


always is hard ;)
but, the most difficult job is to have everyone happy and satisfied
I always try to improve or innovate, I expect answers and see the reaction of users to changes
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: New Class: TCalendar

Postby Richard Chidiak » Fri Apr 23, 2010 1:25 pm

Daniel

You have done an excellent job, it is very useful

Though i agree with Mdasolution, a fivewin control like outlook calendar will be excellent

Codejock has the best calendar (appointment) control i have seen, it is pretty much like outlook

it is a dream having the same control in fivewin,

Hopefully we get it one day

Richard
http://www.cbati.com

Uestudio
Fwh 13.05 Harbour 3.2 MSVC 2013
User avatar
Richard Chidiak
 
Posts: 946
Joined: Thu Oct 06, 2005 7:05 pm
Location: France

Re: New Class: TCalendar

Postby richard-service » Fri Apr 23, 2010 2:18 pm

Richard Chidiak wrote:Daniel

You have done an excellent job, it is very useful

Though i agree with Mdasolution, a fivewin control like outlook calendar will be excellent

Codejock has the best calendar (appointment) control i have seen, it is pretty much like outlook

it is a dream having the same control in fivewin,

Hopefully we get it one day

Richard


Richard,

Now, I finished Codejock's Ribbonbar, MenuBar, OutLookBar ActiveX.
Calendar ActiveX need more time to know EVEN and xml be connect.

http://www.fivetech.com.tw/products/miscurtain/screens_shot/codejock.html
Best Regards,

Richard

Harbour 3.2.0dev (r2402101027) => Borland C++ v7.7 32bit
MySQL v8.0 /ADS v10
Harbour 3.2.0dev (r2011030937) => Borland C++ v7.4 64bit
User avatar
richard-service
 
Posts: 803
Joined: Tue Oct 16, 2007 8:57 am
Location: New Taipei City, Taiwan

Re: New Class: TCalendar

Postby mgsoft » Sat Apr 24, 2010 5:38 pm

Me too;)

And also I am waiting that Buttons in 2007 clause look like I explained.

Thanks!!!
Saludos,

Eduardo
User avatar
mgsoft
 
Posts: 422
Joined: Mon Aug 17, 2009 12:18 pm
Location: España

Re: New Class: TCalendar

Postby Otto » Sat Apr 24, 2010 7:21 pm

Buttons in 2007 clause


mgsoft,

I reread the thread and for me it seems as your problem was solved with Mr. NageswaraRao's answer to use SkinButtons().
Would you be so kind to repost what is missing?
Best regards,
Otto

viewtopic.php?f=3&t=18527&p=97166&hilit=Buttons+in+2007#p97166
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6332
Joined: Fri Oct 07, 2005 7:07 pm

Re: New Class: TCalendar

Postby mgsoft » Sun Apr 25, 2010 11:15 am

Otto,

The use of SkinButtons() do not paint the buttons as: http://img51.imageshack.us/i/botonesx.png/

Regards :D
Saludos,

Eduardo
User avatar
mgsoft
 
Posts: 422
Joined: Mon Aug 17, 2009 12:18 pm
Location: España

Re: New Class: TCalendar

Postby MdaSolution » Thu Apr 29, 2010 4:39 pm

Daniel,

For create calendar as Outlook 2003 I thinked to create a double array xbrowse

with hours and days

why we cannot use xbrowse or a class from xbrowse ?

we can inseert mouse method to select row and column

I think i not know how make it but perhaps all together we can create it
FWH .. BC582.. xharbour
User avatar
MdaSolution
 
Posts: 401
Joined: Tue Jan 05, 2010 2:33 pm

Re: New Class: TCalendar

Postby Daniel Garcia-Gil » Thu Apr 29, 2010 5:38 pm

Mda...

i'm working about your suggestion ;)

but i need more time

i hope can make that

tcalendar is a window api control, but outlook calendar not

there are many calendar class, did you tried?
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 34 guests