Tuesday, May 20, 2014

otCalendar Library

What is otCalendar?

ot stands for OnyToo, the name used by the original contributor of this library inside Foxite.  This library, for those who are not familiar yet with this, has two control class, i.e., _calendar and _datepicker.

I actually preferred this over my own datepicker class as his approach on the dropdown portion has appealed very much to me being not constrained to the boundaries of the parent form where the datepicker will be dragged into.  So I ditched my class and use this instead on my own project.

What is new here?



I tried my best to retain the core designs of OnyToo's calendar library and just added some things that appeals to my taste now.  Here are what has been changed/added:
  • Removed the skin I added before, I also removed the extra shape that comes originally with said library.  I changed the background of the calendar control class to plain white.
  • Change of fonts from Tahoma 8 to Calibri 10 as Calibri appeals more to me these days especially on numbers
  • Made the dropdown form wider adding a portion showing the currently selected day in big number plus the day and month below it.  
  • Added capability to change/add holidays on the ply via utilizing Right-Click of the days.
  • Added capability to also include notes via Right-Click on the days as well
  • Added visual clues to diffirentiate the days

Here is the adjusted look:



Hover - Eye Candy

In addition to showing the big number on the right representing the current day, I made hovering among the days change those as well.  Just play with it by moving the mouse above the days.

New Color Combinations
  • Sundays - colored red (comes with stock calendar library)
  • Holidays - now with orange backcolor and white forecolor
  • Notes - white backcolor, green forecolor, boxed
  • Current day number - white backcolor, blue forecolor, boxed


Holidays/Notes On-the-ply

As mentioned above, right-clicking a day will allow users to change/add a holiday or a note on the ply.

  • Holiday or Note?  An optiongroup to allow users to select whether it is a note or holiday
  • Save - save changes made and hides the note section, showing big numbers again 
  • Abort - Cancel saving and hides the note section
  • Clear - Remove any previous holiday or note on said day
I actually created a torn page with pin on top as a background for the note/holiday encoding and 3 images for the buttons last Sunday.  But it is again going away from the concept of a simplistic look so in the end I have chosen to make things plainer by using shapes and labels as seen above.

Holidays versus Notes
  • Holidays - will be sought by the class disregarding the year.  Meaning what is important with the class is only the month and the day so the class will reuse those that are marked as holiday on every year
  • Notes - will be sought by the class based on the complete date.  Unlike holidays which is being reused, notes will be shown only once which is on the specific date of the note

Additional Table adjustment

If you already have said calendar class before and would want to overwrite it with this new version, then you need to add a 4th  field to holiday.dbf (see highlighted NoteType below)


Caveat:

On-the-ply holiday and notes affect only hDescEn field (for English).  I leave hDesc field which is for other localized language.  Anyway, the codes are included so you can adjust it if you want.

DatePicker on Grid

I also have adjusted the class to change these things when used on grid:
  • Auto acquiring of Column's ControlSource 
  • Auto turning parent's column Sparse into .F. 
  • Auto setting CurrentControl into this class
  • Auto-Resizing Grid's RowHeight to accommodate this class
  • Auto-Resizing Column's Width to accommodate this class
Now, all we need to do is drag and drop this _datepicker class on a column of a grid representing a date field type and let it gain control over said column so it can show itself and acquire the proper dates.



Afterword:

My Special thanks to OnyToo (real name is Riyan Alfa Sonny,  a highly experienced developer from Padang -West Sumatra, Indonesia) for providing us with this wonderful library.  For those who don't know yet, the guy has contributed several cool stuff inside foxite like Drilldown Grid, a Form/Screen Splitter class and FoxGrowl notification libraries to name a few.

Download:

The new version can be downloaded here.

P.S.  If what you have downloaded is looking for a missing file stickpin.png or dropdown is erring, then redownload again.  I forgot to embed the image of the pin inside the class earlier today.


Cheers!

3 comments:

  1. Man, what you did is great, the only thing i need is, to be able to assign how many hours this holiday could be, normally a holiday is the whole day, but in our case we can work 4 hours a day and the other 4 hours will be considered a Holiday of 4 hours, is there anyway to link holidays with hours, so we can pass that holiday hours later to the excel report

    ReplyDelete
  2. Hi, I found a small error in class "otCalendar" when the month has 31 days, and you select the same day is invisible. To test the error, place the _calendar class in a normal form.

    I already have the solution.

    _calendar.Redraw

    lnLastDay = DAY (GOMONTH (CTOD ( "1 /" + TRANSFORM (lnMonth) + "/" + TRANSFORM (lnYear)), 1) -1)

    change to this command.

    I'm sorry for English'm using google translator.

    ReplyDelete
    Replies
    1. Hi, thanks. Someone inside foxite forum has informed me about that and yes the solution is almost similar to what you have shown:

      https://www.foxite.com/archives/0000432293.htm

      I suggest you use DATE() Function instead of CTOD():

      lnLastDay = Day(Gomonth(Date(m.lnYear,m.lnMonth,1), 1) - 1)


      I forgot to mention that problwm and fix here. Again thanks

      Delete