Calendar Gadget (WIP)

BlitzMax Forums/MaxGUI Module/Calendar Gadget (WIP)

degac(Posted 2009) [#1]
Hi,
I'm working on a 'calendar' gadget (at the moment is tested only on Win32...).







There are some little functions to retrieve the 'leap year' (Anno Bisestile), the Day of the week (0: Sunday, 1: Monday...) and the JulianTime conversion (I found on the Code archives)

I need some help to retrieve the fundamental information: the data choosen by the user!!!

Any suggestions, critics and comments are welcome!


Edited: added a Linux version image

If anyone can test under Linux (FLTK) I found that button 'colored' are 'decoloured' when I move the mouse on them...


Mark Tiffany(Posted 2009) [#2]
Nice...in theory, as I get an error on line 201 (array index issue).

Some thoughts on knowing the date chosen:
- use toggle buttons so they stay down when the day is clicked
- return the date in eventdata on GadgetAction event (string="YYYY-MM-DD" format?) Or a new "date" type might be better?
- return a gadgetitem for selectedgadgetitem (less keen, but might work well with addgadgetitem for setting coloured dates?)


degac(Posted 2009) [#3]
Edited for handling Linux incompatbility

@Mark

Thank for the suggestions; 1 & 2 are interesting solutions


Mark Tiffany(Posted 2009) [#4]
Works here now. A few suggestions:

- to ensure macos and gtk compatibility, you probably need slightly bigger buttons. I find compiling with Brucey gtkmaxgui tends to give an idea of what it will be like on mac
- suggest that you don't let the selected day hang over when you change month / year. i.e. if I pick 13th July 2009 (my birthday), then change month or year, 13 shouldn't be selected, unless I return to July 2009
- suggest you show today in a slightly different style, and maybe consider a "go to today" button
- you have greyed out Sunday...some people might want Sat & Sun greyed out.
- some people might want the calendar to start on a different day of the week (some countries have different conventions)

Obviously, most of those are nice to haves! In terms of how you make these things available to the user, I don't think there's any harm in creating Calendar specific commands if needed...


d-bug(Posted 2009) [#5]
oops, to slow...



just to confirm Marks post :/


degac(Posted 2009) [#6]
Thanks for the suggestions!
As I said in my initial post I'm developing on win32 at the moment (and on Linux just to find out some possible errors - like the one on the returned date...)

- suggest that you don't let the selected day hang over when you change month / year. i.e. if I pick 13th July 2009 (my birthday), then change month or year, 13 shouldn't be selected, unless I return to July 2009


...well I've tried to imitate the same behaviour of the calendar gadget under WindowXP and Ubuntu when you click on the clock/date icon in the desktopbar: the day stays selected while you change month or year.
Maybe I can setup 2 different behaviours


SebHoll(Posted 2009) [#7]
Argh - this CocoaMaxGUI driver could really do with being cleaned up... The offset for the gadgets in the sunken panel is completely wrong and the label text isn't center aligned. Not nice... :-/ I'll post a bug report to remind me to look at this...

Edit: I've been a bit naughty and hot-linked to your images, degac/d-bug. Hope you don't mind...


d-bug(Posted 2009) [#8]
Hey Seb,

if you really plan to clean up the Cocoa driver, please give us button-style-flags instead of size dependency. Or better, make it possible to get access to the BezelStyle flags with an extra method or something.


degac(Posted 2009) [#9]
This is a little update, no changes on the visual aspect and only tested on win32 (for the moment):
+ fixed some minor bugs
+ added some proper function for Set, Get and Remove Appointments
+ on a same date you can have more appointments (they will displayed in a tooltips)
+ EventExtra() will return in string form (at the moment DD MM YYYY) the selected date


PS: after reading the SebHoll post I just realized how many 'bugs' I've discovered (not really all bugs only visual incoherency...the really bug is on Linux the 'decolouring' effect on buttons and label...these are very annoying, while the remain can be fixed via ?mac / ?linux directives). Sorry! :P


SebHoll(Posted 2009) [#10]
the really bug is on Linux the 'decolouring' effect on buttons and label...these are very annoying

Just letting you know that I've already spotted this one...


degac(Posted 2009) [#11]
Yes, I've read your post about the decolouring effect. I didnt' mean to make pression on you to fix it - initially I was thinking I'm made some mess with events handling on my system!
I've you tried to use FLTK under windows to see if the bug is the same or not? (I've made some 'really-messy-things' on my Windows machine, so every time I try to use FLTK I've got a list of bugs....I must 'reinstall' FLTK module)
As I have your attention (:-D) there are some 'fixes'
http://www.blitzbasic.com/Community/posts.php?topic=84981#960607 (about events of labels)
http://www.blitzbasic.com/Community/posts.php?topic=84527#955108 (about Requester)

For the latter I would know if possible to create a command (like SetFolder()) to setup the real desktop name without changing manually the .c source code & rebuild it*...my C skills are not so high (and this is the reason of the mess on my machines of FLTK module!)

* = This of course requires user manually changes it, but unless there is a way to determine the 'user, desktop, documents' folder in secure way (sorry but Brucey's Volume solution doesnt' work correctly on localized linux distribution) is better than nothing.

Thanks!


SebHoll(Posted 2009) [#12]
Hi degac,

Yep - the bug is the same as on Windows, but I've managed to track it down and fix it now... :P

Had a closer look at the calendar code, though, today and thought I'd tidy a few things up. The constant freeing and creation of the button is not very nice for the memory manager (and leaky MaxGUI drivers :P), so I've attempted to implement a system which reuses a grid of already created icons.

Also, I've attempted to improve the positioning of the gadgets when the calendar is resized. Everything appears to be working as it did, but please let me know if it isn't.




degac(Posted 2009) [#13]
Very clever solution!
Nice - simple and efficient, I like it!


degac(Posted 2009) [#14]
I've just fixed some little bugs on displaying correctly all the days and changed GetAppointment/RemoveAppointments to handle a single appointment
Added also description to add it to module.




GaryV(Posted 2009) [#15]
Just curious. Is there any reason you are not using the native calendar gadget on Windows?


Ked(Posted 2009) [#16]
Degac's method is cross-platform.


GaryV(Posted 2009) [#17]
To appease, and still just curious, is there any reason you are not using the native calendar gadget on each platform?


degac(Posted 2009) [#18]

To appease, and still just curious, is there any reason you are not using the native calendar gadget on each platform?


I doubt there is a 'standard' calendar gadget on every platforms. For example look at the FLTK documentation: http://www.fltk.org/doc-1.3/index.html - I didn't find any 'calendar-like' gadget.
And even on MacOS-Cocoa I haven't found anything...I found user-made solutions, bridge via-JScript with Ical and so on...
Maybe I'm blind.
Only on Windows I found the 'Month Calendar Controls' http://msdn.microsoft.com/en-us/library/bb760913(VS.85).aspx
So I think my solution is faster and easy to implement - and multiplatform.

PS: there are some little bugs to correctly display/use the calendar under Mac and Linux: Sebholl is working to fix these bugs (and some bugs are already fixed).
I found that under MacOS the size/shape of the standard buttons depends (in MaxGUI) on the 'widht/height' control: so technically under a determinated (I dont remember actually!) size the button is 'squared', otherwise is 'rounded'...I made a little hack to allow the user to choose to draw a squared (or rounded) button...maybe Sebholl & co can make it as 'standard' in MaxGUI (it doesn't affect the other platforms - as they dont' have rounded buttons).