noreply at rubyforge.org
2009-May-01 19:46 UTC
[wxruby-development] [ wxruby-Bugs-25749 ] DateTimePicker#get_range badly swiged - General DateTime support
Bugs item #25749, was opened at 01/05/2009 21:46 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=218&aid=25749&group_id=35 Category: Incorrect behavior Group: None Status: Open Resolution: None Priority: 3 Submitted By: Pascal Hurni (phi) Assigned to: Nobody (None) Summary: DateTimePicker#get_range badly swiged - General DateTime support Initial Comment: DateTimePicker#get_range badly swig''ed - General DateTime support I recently had to use a DatePickerCtrl in my project, everything seemed to be okay, but it was not. There were some problems: 1. Invalid objects. In WxWidgets a wxDateTime may be invalid (containing no valid date). This is used throughout the API. For DatePickerCtrl it is used to set the date to "none" (only possible with the style DP_ALLOWNONE) and by the way, to get back this value. In Ruby Time objects may not be invalid, they are always valid. So we miss a feature here. I changed the typemap for the wxDateTime type. It now accepts a nil value and converts it to an invalid wxDateTime object. The opposite is also done, an invalid wxDateTime will be converted to nil. 2. Date ranges. Currently the typemap can convert from a Ruby Time-like object to wxDateTime but not the opposite, so when we have a date outside the range 1970-2038 (on the majority of platforms), we get an exception. I changed the typemap to construct a Ruby DateTime object when it is out of range. 3. DatePickerCtrl#get_range Looking at the DatePickerCtrl methods faced another problem: the #get_range method. It should be able to get the min and max date accepted by the control (if previously set by #set_range). But the method signature was bad, even swig''ed it still was: Boolean get_range(dt1, dt2) dt1 and dt2 were supposed to be out values (in C++ they are pointers) but swig handles them as input references. So i re-implemented the get_range method to return an two cells array containing the range (note that I didn''t used Ruby Ranges because one or both range ends may be nil). That''s it. Please review the patch, I''ve included patches for swig files, doc files and I also updated the calender sample to show usage of DatePickerCtrl (I''ve done a ''blind'' transcript of the C++ sample) Regards, Pascal ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=218&aid=25749&group_id=35
Apparently Analagous Threads
- [1072] trunk/wxruby2/swig/shared/datetime.i: Add typemap for DateTime::WeekDay; plug mem leak with wxDateTime arg
- [961] branches/wxruby2/wxwidgets_282/swig: Move wxDateTime typemap into shared file, map to core Time class instead
- Whoo Hoo! I got a working Windows Build of wxRuby
- DatePickerCtrl uninitialized constant
- [795] trunk/wxruby2/swig/classes/include/parents.rb: Added missing DatePickerCtrl and TextUrlEvent classes