- wxLog functions are now (more) MT-safe
- wxStopWatch class, timer functions have more chances to return correct
results for your platform (use ANSI functions where available)
-- wxString::ToLong, ToULong, ToDouble methods added
+- wxString::ToLong, ToULong, ToDouble methods and Format() static one added
- buffer overflows in wxString and wxLog classes fixed (if snprintf() function
is available)
- wxArray::RemoveAt() replaces deprectaed wxArray::Remove(index)
wxMSW:
+- implemented setting colours for push buttons
- wxTreeCtrl::IsVisible() bug fixed (thanks to Gary Chessun)
- tooltips work with wxRadioBox
- returning FALSE from OnPrintPage() aborts printing
// returns TRUE if the date is in the given range
inline bool IsBetween(const wxDateTime& t1, const wxDateTime& t2) const;
+ // do these two objects refer to the same date?
+ inline bool IsSameDate(const wxDateTime& dt) const;
+
+ // do these two objects have the same time?
+ inline bool IsSameTime(const wxDateTime& dt) const;
+
+ // are these two objects equal up to given timespan?
+ inline bool IsEqualUpTo(const wxDateTime& dt, const wxTimeSpan& ts) const;
+
// arithmetics with dates (see also below for more operators)
// ------------------------------------------------------------------------
#error "This file is only included by wx/datetime.h, don't include it manually!"
#endif
+#define MILLISECONDS_PER_DAY 86400000l
+
// ----------------------------------------------------------------------------
// wxDateTime construction
// ----------------------------------------------------------------------------
return IsEqualTo(t1) || IsEqualTo(t2) || IsStrictlyBetween(t1, t2);
}
+bool wxDateTime::IsSameDate(const wxDateTime& dt) const
+{
+ return (m_time - dt.m_time).Abs() < MILLISECONDS_PER_DAY;
+}
+
+bool wxDateTime::IsSameTime(const wxDateTime& dt) const
+{
+ // notice that we can't do something like this:
+ //
+ // m_time % MILLISECONDS_PER_DAY == dt.m_time % MILLISECONDS_PER_DAY
+ //
+ // because we have also to deal with (possibly) different DST settings!
+ Tm tm1 = GetTm(),
+ tm2 = dt.GetTm();
+
+ return tm1.hour == tm2.hour &&
+ tm1.min == tm2.min &&
+ tm1.sec == tm2.sec &&
+ tm1.msec == tm2.msec;
+}
+
+bool wxDateTime::IsEqualUpTo(const wxDateTime& dt, const wxTimeSpan& ts) const
+{
+ return IsBetween(dt.Substract(ts), dt.Add(ts));
+}
+
// ----------------------------------------------------------------------------
// wxDateTime arithmetics
// ----------------------------------------------------------------------------
return *this;
}
+#undef MILLISECONDS_PER_DAY
wxDateTime& wxDateTime::SetToYearDay(wxDateTime::wxDateTime_t yday)
{
int year = GetYear();
- wxCHECK_MSG( (0 < yday) && (yday < GetNumberOfDays(year)),
+ wxCHECK_MSG( (0 < yday) && (yday <= GetNumberOfDays(year)),
ms_InvDateTime, _T("invalid year day") );
bool isLeap = IsLeapYear(year);
return (wxChar *)NULL;
}
+ Tm tm = dt.GetTm();
+
+ haveDay = haveMon = haveYear =
+ haveHour = haveMin = haveSec = TRUE;
+
+ hour = tm.hour;
+ min = tm.min;
+ sec = tm.sec;
+
+ year = tm.year;
+ mon = tm.mon;
+ mday = tm.mday;
+
input = result;
}
break;
}
haveMon = TRUE;
- mon = (Month)num;
+ mon = (Month)(num - 1);
break;
case _T('M'): // minute as a decimal number (00-59)
min = tm.min;
sec = tm.sec;
}
+ break;
case _T('w'): // weekday as a number (0-6), Sunday = 0
if ( !GetNumericToken(input, &num) || (wday > 6) )
break;
case _T('Y'): // year with century
- if ( !GetNumericToken(input, &num) || !num || (num > 366) )
+ if ( !GetNumericToken(input, &num) )
{
// no match
return (wxChar *)NULL;
}
- haveYDay = TRUE;
- yday = (wxDateTime_t)num;
+ haveYear = TRUE;
+ year = (wxDateTime_t)num;
break;
case _T('Z'): // timezone name
// take this date as default
tmDef = dateDef.GetTm();
}
- else if ( IsValid() )
+ else if ( m_time != 0 )
{
// if this date is valid, don't change it
tmDef = GetTm();
// also always ignore the week day
if ( haveMon && haveDay )
{
+ if ( mday > GetNumOfDaysInMonth(tm.year, mon) )
+ {
+ wxLogDebug(_T("bad month day in wxDateTime::ParseFormat"));
+
+ return (wxChar *)NULL;
+ }
+
tm.mon = mon;
tm.mday = mday;
}
else if ( haveYDay )
{
+ if ( yday > GetNumberOfDays(tm.year) )
+ {
+ wxLogDebug(_T("bad year day in wxDateTime::ParseFormat"));
+
+ return (wxChar *)NULL;
+ }
+
Tm tm2 = wxDateTime(1, Jan, tm.year).SetToYearDay(yday).GetTm();
tm.mon = tm2.mon;
// don't do it with the owner drawn buttons because it will reset
// BS_OWNERDRAW style bit too (BS_OWNERDRAW & BS_DEFPUSHBUTTON != 0)!
- if ( !(style & BS_OWNERDRAW) )
+ if ( (style & BS_OWNERDRAW) != BS_OWNERDRAW )
{
style &= ~BS_DEFPUSHBUTTON;
SendMessage(GetHwndOf(btnOldDefault), BM_SETSTYLE, style, 1L);
}
+ else
+ {
+ // redraw the button - it will notice itself that it's not the
+ // default one any longer
+ btnOldDefault->Refresh();
+ }
}
// set this button as the default
long style = GetWindowLong(GetHwnd(), GWL_STYLE);
- style |= BS_DEFPUSHBUTTON;
- SendMessage(GetHwnd(), BM_SETSTYLE, style, 1L);
+ if ( (style & BS_OWNERDRAW) != BS_OWNERDRAW )
+ {
+ style |= BS_DEFPUSHBUTTON;
+ SendMessage(GetHwnd(), BM_SETSTYLE, style, 1L);
+ }
}
// ----------------------------------------------------------------------------
long wxButton::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
{
- // make sure that we won't have BS_DEFPUSHBUTTON style any more if the
- // focus is being transfered to another button with the same parent -
- // otherwise, we could finish with 2 default buttons inside one panel
- if ( (nMsg == WM_KILLFOCUS) &&
- (GetWindowLong(GetHwnd(), GWL_STYLE) & BS_DEFPUSHBUTTON) )
+ // when we receive focus, we want to become the default button in our
+ // parent panel
+ if ( nMsg == WM_SETFOCUS )
{
- wxWindow *parent = GetParent();
- wxWindow *win = wxFindWinFromHandle((WXHWND)wParam);
- if ( win && win->GetParent() == parent )
- {
- wxPanel *panel = wxDynamicCast(parent, wxPanel);
- if ( panel )
- {
- panel->SetDefaultItem(this);
- }
- // else: I don't know what to do - we'll still have the problem
- // with multiple default buttons in a dialog...
- }
+ SetDefault();
+
+ // let the default processign take place too
}
// let the base class do all real processing
::DeleteObject(hbrushBackground);
-#if 0
- wxString s = "button state: ";
- if ( selected )
- s += "selected ";
- if ( pushed )
- s += "pushed ";
- if ( state & ODS_FOCUS )
- s += "focused ";
- wxLogStatus(s);
-#endif
-
return TRUE;
}