wxCalendar patches

Hi,

attached are 2 patches for wxCalendar one for 2.4.2.4 and
one for 2.5.1.0p7.

The changes are:
# 06/02/2004 - Jörg "Adi" Sieker adi@sieker.info

calendar.py-2.4.2.4-patch (21.1 KB)

calendar.py-2.5.1.0-patch (17.7 KB)

···

#
# o Changed color handling, use dictionary instead of members.
# This causes all color changes to be ignored if they manipluate the
# members directly.
# SetWeekColor and other method color methods were adapted to use the
# new dictionary.
# o Added COLOR_* constants
# o Added SetColor method for Calendar class
# o Added 3D look of week header
# o Added colors for 3D look of header
# o Fixed width calculation.
# Because of rounding difference the total width and height of the
# calendar could be up to 6 pixels to small. The last column and row
# are now wider/taller by the missing amount.
# o Added SetTextAlign method to wxCalendar. This exposes logic
# which was already there.
# o Fixed CalDraw.SetMarg which set set_x_st and set_y_st which don't
# get used anywhere.
# Instead set set_x_mrg and set_y_mrg
# o Changed default X and Y Margin to 0.
# o Added wxCalendar.SetMargin.

Regards
     Adi

Adi Sieker wrote:

Hi,

attached are 2 patches for wxCalendar one for 2.4.2.4 and
one for 2.5.1.0p7.

The changes are:
# 06/02/2004 - Jörg "Adi" Sieker adi@sieker.info
#
# o Changed color handling, use dictionary instead of members.
# This causes all color changes to be ignored if they manipluate the
# members directly.
# SetWeekColor and other method color methods were adapted to use the
# new dictionary.
# o Added COLOR_* constants
# o Added SetColor method for Calendar class
# o Added 3D look of week header
# o Added colors for 3D look of header
# o Fixed width calculation.
# Because of rounding difference the total width and height of the
# calendar could be up to 6 pixels to small. The last column and row
# are now wider/taller by the missing amount.
# o Added SetTextAlign method to wxCalendar. This exposes logic
# which was already there.
# o Fixed CalDraw.SetMarg which set set_x_st and set_y_st which don't
# get used anywhere.
# Instead set set_x_mrg and set_y_mrg
# o Changed default X and Y Margin to 0.
# o Added wxCalendar.SetMargin.

Hi Adi,

Could you please redo these patches to use the unified diff format, preferably diffed with the CVS version of the files? (See the bottom of http://wxpython.org/codeguidelines.php) That makes it much easier for me to see at a glance what is changing and to be sure that the changes are being applied correctly. Also, did you have any changes for the demo?

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Hi Robin,

Robin Dunn wrote:

Hi Adi,

Could you please redo these patches to use the unified diff format, preferably diffed with the CVS version of the files? (See the bottom of http://wxpython.org/codeguidelines.php) That makes it much easier for me to see at a glance what is changing and to be sure that the changes are being applied correctly.

here are the new diff's generated with "diff -u2 " against the CVS versions of calender.py .

Also, did you have any changes for the demo?

The new version runs fine with the demo as is.
I could make some changes to the demo to reflect the current
state of things.

The is one thing (display bug ) in the 2.5 version of calender.py,
but I can't find the source of the problem. :frowning:
The header of the column is drawn 2 to thin, one on the top and one oon the bottom. I think this could have something todo with the 2.5 version
as I can't see any real difference in the 2.4 and 2.5 drawing code of the calendar. Maybe you have an idea, if not could have another go at trying to find the problem.

Regards
     Adi

calendar.py-2.5.1.0-patch (24.6 KB)

calendar.py-2.4.2.4-patch (31 KB)

Adi Sieker wrote:

The is one thing (display bug ) in the 2.5 version of calender.py,
but I can't find the source of the problem. :frowning:
The header of the column is drawn 2 to thin, one on the top and one oon the bottom. I think this could have something todo with the 2.5 version
as I can't see any real difference in the 2.4 and 2.5 drawing code of the calendar. Maybe you have an idea, if not could have another go at trying to find the problem.

I'm seeing the problem in both versions, and in more than just the weekday header. (Just tested on Linux so far.) It looks like a bunch of off-by-one errors. If i select a date that is next to the edge of the calendar then the red selection indicator overdraws the border of the calendar, and when a new day is selected that border is not redrawn. The same thing happens if one of the highlited dates (draw with blue text) is next to the edge.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Robin Dunn wrote:

I'm seeing the problem in both versions, and in more than just the weekday header. (Just tested on Linux so far.) It looks like a bunch of off-by-one errors. If i select a date that is next to the edge of the calendar then the red selection indicator overdraws the border of the calendar, and when a new day is selected that border is not redrawn. The same thing happens if one of the highlited dates (draw with blue text) is next to the edge.

Strange, I have no Problems in the 2.4 Version on XP.
I'll have a closer look at it.
Maybe it's time for VMWare and a Debian install.

Regards
    Adi

Hi,

Robin Dunn wrote:

I'm seeing the problem in both versions, and in more than just the weekday header. (Just tested on Linux so far.) It looks like a bunch of off-by-one errors. If i select a date that is next to the edge of the calendar then the red selection indicator overdraws the border of the calendar, and when a new day is selected that border is not redrawn. The same thing happens if one of the highlited dates (draw with blue text) is next to the edge.

Yep, the drawing stuff was off by one in a few places.
I hope this time around things are better.

New patches attached.

Regards
    Adi

calendar.py-2.4.2.4.patch (33.9 KB)

calendar.py-2.5.1.0.patch (27.2 KB)

Adi Sieker wrote:

Hi,

Robin Dunn wrote:

I'm seeing the problem in both versions, and in more than just the weekday header. (Just tested on Linux so far.) It looks like a bunch of off-by-one errors. If i select a date that is next to the edge of the calendar then the red selection indicator overdraws the border of the calendar, and when a new day is selected that border is not redrawn. The same thing happens if one of the highlited dates (draw with blue text) is next to the edge.

Yep, the drawing stuff was off by one in a few places.
I hope this time around things are better.

New patches attached.

Yes, much better. It looks and runs very nice. I'll check in the changes shortly.

I have a couple requests: It would be nice if the cursor keys allowed you to change the selected day/month like the wxCalendarCtrl does. To do that you'll probably need to change Calendar to derive from wx.PyControl and then override AcceptsFocus to return True. (See wx.lib.buttons for an example.) Then it can get the focus and you can handle EVT_KEY_DOWN events. It should probably also have some sort of focus indicator to show whether or not the Calendar has the focus or not. And next would be checking IsEnabled and disallowing changes if it is disabled, and drawing it differently when in a disabled state too.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Robin Dunn wrote:

Yes, much better. It looks and runs very nice. I'll check in the changes shortly.

Good and nice to hear. :slight_smile:

I have a couple requests:

*g* :))

> It would be nice if the cursor keys allowed

you to change the selected day/month like the wxCalendarCtrl does. To do that you'll probably need to change Calendar to derive from wx.PyControl and then override AcceptsFocus to return True. (See wx.lib.buttons for an example.) Then it can get the focus and you can handle EVT_KEY_DOWN events. It should probably also have some sort of focus indicator to show whether or not the Calendar has the focus or not. And next would be checking IsEnabled and disallowing changes if it
is disabled, and drawing it differently when in a disabled state too.

I'll have a go at those requests.
I also want to change the way the curently selected day is drawn.
Not an outlined rectangle but a filled rectangle using the system colors for a selected menu item.

Regards
    Adi

Hi Robin,

Robin Dunn wrote:

I have a couple requests: It would be nice if the cursor keys allowed you to change the selected day/month like the wxCalendarCtrl does. To do that you'll probably need to change Calendar to derive from wx.PyControl and then override AcceptsFocus to return True. (See wx.lib.buttons for an example.) Then it can get the focus and you can handle EVT_KEY_DOWN events. It should probably also have some sort of focus indicator to show whether or not the Calendar has the focus or not.

Attached are two patches for keyboard navigation.
one for 2.5 and one for 2.4.
included changes are:
o Added keyboard navigation to the control.
   Use the cursor keys to navigate through the ages. :slight_smile:
   The Home key function as go to today
o select day is now a filled rect instead of just an outline

> And next would be checking IsEnabled and disallowing changes if it

is disabled, and drawing it differently when in a disabled state too.

This is next to come.

Tschau
    Adi

Adi Sieker wrote:

Attached are two patches for keyboard navigation.

There were no files attached.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Robin Dunn wrote:

Adi Sieker wrote:

Attached are two patches for keyboard navigation.

There were no files attached.

*grumble*
I really have to attach the files before writing the mail
otherwise I always forget.

Here they are now.

Regards
    Adi

calendar-navigation-2.5.1.1.patch (11.1 KB)

calendar-navigation-2.4.2.4.patch (11.2 KB)

Adi Sieker wrote:

Robin Dunn wrote:

Adi Sieker wrote:

Attached are two patches for keyboard navigation.

There were no files attached.

*grumble*
I really have to attach the files before writing the mail
otherwise I always forget.

Here is a new version of both patches which
fix one more little bug where under some corcumstances an uninitialised variable woulc cause an exception.

So you can disregard the previous patches.

Regards
     Adi

calendar-navigation-2.4.2.4.patch (11.4 KB)

calendar-navigation-2.5.1.1.patch (11.4 KB)

Adi Sieker wrote:

Adi Sieker wrote:

Robin Dunn wrote:

Adi Sieker wrote:

Attached are two patches for keyboard navigation.

There were no files attached.

*grumble*
I really have to attach the files before writing the mail
otherwise I always forget.

Here is a new version of both patches which
fix one more little bug where under some corcumstances an uninitialised variable woulc cause an exception.

So you can disregard the previous patches.

Looks good, except for a couple problems:

1. The Python datetime module does not exist in Python 2.2 and we're trying to keep wxPython compatible with Python 2.2. Please try to use wx.DateTime instead.

2. The weekend days are initially painted with a white background and then when one of those days is selected and then the selection moved elsewhere the day is then painted with a grey background.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Hi Robin,

Robin Dunn wrote:

Looks good, except for a couple problems:

1. The Python datetime module does not exist in Python 2.2 and we're trying to keep wxPython compatible with Python 2.2. Please try to use wx.DateTime instead.

OK, I'm using wx.DateTime and consorts now.

2. The weekend days are initially painted with a white background and then when one of those days is selected and then the selection moved elsewhere the day is then painted with a grey background.

I have ShowWeekend set in my little test application.
It works now.

I'll get onto the En/Disabled thing next.

Regards
     Adi

calendar-navigation-2.5.1.1.patch (11.9 KB)

calendar-navigation-2.4.2.4.patch (11.9 KB)

Adi Sieker wrote:

Hi Robin,

Robin Dunn wrote:

Looks good, except for a couple problems:

1. The Python datetime module does not exist in Python 2.2 and we're trying to keep wxPython compatible with Python 2.2. Please try to use wx.DateTime instead.

OK, I'm using wx.DateTime and consorts now.

2. The weekend days are initially painted with a white background and then when one of those days is selected and then the selection moved elsewhere the day is then painted with a grey background.

I have ShowWeekend set in my little test application.
It works now.

Thanks!

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!