1. wxLongLong and wxDateTime compilation fixed for the compilers without native
"long long" type (and some code in timercmn.cpp too) 2. wxDate and wxTime reimplemented using wxDateTime (old versions tagged as OLD_DATE_AND_TIME) 3. wxString::To(U)Long and ToDouble added and documented 4. bug with combobox in toolbar (drop down list wasn't dismissed) fixed 5. several wxDateTime::Parse() functions implemented 6. added support for coloured buttons under MSW (not completely finished) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5043 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1,23 +1,28 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: time.h
|
||||
// Purpose: wxTime class, from NIHCL
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/time.h
|
||||
// Purpose: wxTime class, from NIHCL: this class is deprecated, use
|
||||
// wxDateTime instead
|
||||
// Author: Julian Smart, after K. E. Gorlen
|
||||
// Modified by:
|
||||
// Modified by: 18.12.99 by VZ to use the new wxDateTime class
|
||||
// Created: 01/02/97
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart and Markus Holzem
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_TIMEH__
|
||||
#define _WX_TIMEH__
|
||||
|
||||
#include "wx/object.h"
|
||||
#include "wx/defs.h"
|
||||
|
||||
#if wxUSE_TIMEDATE
|
||||
|
||||
#include "wx/object.h"
|
||||
#include "wx/datetime.h"
|
||||
#include "wx/date.h"
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface "time.h"
|
||||
#pragma interface "time.h"
|
||||
#endif
|
||||
|
||||
class WXDLLEXPORT wxDate;
|
||||
@@ -27,82 +32,124 @@ typedef unsigned short minuteTy;
|
||||
typedef unsigned short secondTy;
|
||||
typedef unsigned long clockTy;
|
||||
|
||||
class WXDLLEXPORT wxTime: public wxObject
|
||||
// seconds from 1/1/01 to 1/1/70
|
||||
#define wxTIME_EPOCH_DIFF 2177452800UL
|
||||
|
||||
class WXDLLEXPORT wxTime : public wxObject
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxTime)
|
||||
|
||||
public: // type definitions
|
||||
public:
|
||||
// type definitions
|
||||
enum tFormat { wx12h, wx24h };
|
||||
enum tPrecision { wxStdMinSec, wxStdMin };
|
||||
private:
|
||||
static tFormat Format;
|
||||
static tPrecision Precision;
|
||||
|
||||
public:
|
||||
// current time
|
||||
wxTime() : m_time(wxDateTime::Now()) { }
|
||||
wxTime(clockTy s) : m_time((time_t)(s - wxTIME_EPOCH_DIFF)) { }
|
||||
void operator=(const wxTime& t) { m_time = t.m_time; }
|
||||
wxTime(const wxTime& t) { *this = t; }
|
||||
wxTime(hourTy h, minuteTy m, secondTy s = 0, bool WXUNUSED(dst) = FALSE)
|
||||
: m_time(h, m, s) { }
|
||||
|
||||
wxTime(const wxDate& d, hourTy h = 0, minuteTy m = 0, secondTy s = 0,
|
||||
bool WXUNUSED(dst) = FALSE)
|
||||
: m_time(d.GetDay(), (wxDateTime::Month)d.GetMonth(), d.GetYear(),
|
||||
h, m, s) { }
|
||||
|
||||
wxTime(const wxDateTime& time) : m_time(time) { }
|
||||
|
||||
// Convert to string
|
||||
#ifndef __SALFORDC__
|
||||
operator wxChar *() const { return FormatTime(); }
|
||||
operator wxDate() const { return wxDate(m_time); }
|
||||
#endif
|
||||
|
||||
bool operator< (const wxTime& t) const { return m_time < t.m_time; }
|
||||
bool operator<=(const wxTime& t) const { return m_time <= t.m_time; }
|
||||
bool operator> (const wxTime& t) const { return m_time > t.m_time; }
|
||||
bool operator>=(const wxTime& t) const { return m_time >= t.m_time; }
|
||||
bool operator==(const wxTime& t) const { return m_time == t.m_time; }
|
||||
bool operator!=(const wxTime& t) const { return m_time != t.m_time; }
|
||||
|
||||
friend wxTime WXDLLEXPORT operator+(const wxTime& t, long s)
|
||||
{ return wxTime(t.m_time + wxTimeSpan::Seconds(s)); }
|
||||
friend wxTime WXDLLEXPORT operator+(long s, const wxTime& t)
|
||||
{ return wxTime(t.m_time + wxTimeSpan::Seconds(s)); }
|
||||
|
||||
long operator-(const wxTime& t) const
|
||||
{ return (m_time - t.m_time).GetValue().ToLong(); }
|
||||
wxTime operator-(long s) const
|
||||
{ return wxTime(m_time - wxTimeSpan::Seconds(s)); }
|
||||
void operator+=(long s) { m_time += wxTimeSpan::Seconds(s); }
|
||||
void operator-=(long s) { m_time -= wxTimeSpan::Seconds(s); }
|
||||
bool IsBetween(const wxTime& a, const wxTime& b) const
|
||||
{ return *this >= a && *this <= b; }
|
||||
|
||||
// Get day
|
||||
int GetDay() const { return m_time.GetDay(); }
|
||||
// Get month
|
||||
int GetMonth() const { return m_time.GetMonth(); }
|
||||
// Get year
|
||||
int GetYear() const { return m_time.GetYear(); }
|
||||
// Get day of week (0=Sunday 6=Saturday)
|
||||
int GetDayOfWeek() const { return m_time.GetWeekDay(); }
|
||||
|
||||
hourTy GetHour() const { return (hourTy)m_time.GetHour(); }
|
||||
hourTy GetHourGMT() const { return (hourTy)m_time.GetHour(wxDateTime::GMT0); }
|
||||
minuteTy GetMinute() const { return (hourTy)m_time.GetMinute(); }
|
||||
minuteTy GetMinuteGMT() const { return (hourTy)m_time.GetMinute(wxDateTime::GMT0); }
|
||||
secondTy GetSecond() const { return (hourTy)m_time.GetSecond(); }
|
||||
secondTy GetSecondGMT() const { return (hourTy)m_time.GetSecond(wxDateTime::GMT0); }
|
||||
|
||||
clockTy GetSeconds() const { return (clockTy)m_time.GetValue().ToLong(); }
|
||||
|
||||
wxTime Max(const wxTime& t) const { return (t < *this) ? *this : t; }
|
||||
wxTime Min(const wxTime& t) const { return (t > *this) ? *this : t; }
|
||||
|
||||
static void SetFormat(const tFormat lFormat = wx12h,
|
||||
const tPrecision lPrecision = wxStdMinSec)
|
||||
{
|
||||
ms_Format = lFormat;
|
||||
ms_Precision = lPrecision;
|
||||
}
|
||||
|
||||
// (VZ: DANGER: returns pointer to static buffer)
|
||||
wxChar *FormatTime() const
|
||||
{
|
||||
static const wxChar *formats[2][2] =
|
||||
{
|
||||
// wxStdMinSec wxStdMin
|
||||
{ _T("%I:%M:%S %p"), _T("%I:%M %p") }, // wx12h
|
||||
{ _T("%H:%M:%S"), _T("%H:%M") } // wx24h
|
||||
};
|
||||
|
||||
static wxChar s_bufTime[128];
|
||||
|
||||
wxStrncpy(s_bufTime, m_time.Format(formats[ms_Format][ms_Precision]),
|
||||
WXSIZEOF(s_bufTime));
|
||||
|
||||
return s_bufTime;
|
||||
}
|
||||
|
||||
private:
|
||||
static tFormat ms_Format;
|
||||
static tPrecision ms_Precision;
|
||||
|
||||
#if 0 // old wxTime members unused any more
|
||||
clockTy sec; /* seconds since 1/1/1901 */
|
||||
|
||||
bool IsDST() const;
|
||||
wxTime GetLocalTime() const;
|
||||
private: // static member functions
|
||||
|
||||
// static member functions
|
||||
static wxTime GetLocalTime(const wxDate& date, hourTy h=0, minuteTy m=0, secondTy s=0);
|
||||
static wxTime GetBeginDST(unsigned year);
|
||||
static wxTime GetEndDST(unsigned year);
|
||||
public:
|
||||
wxTime(); // current time
|
||||
wxTime(clockTy s) { sec = s; }
|
||||
void operator=(const wxTime& t) { sec = t.sec; } // Ordering required for some compilers
|
||||
wxTime(const wxTime& t) { (*this) = t ; }
|
||||
wxTime(hourTy h, minuteTy m, secondTy s =0, bool dst =FALSE);
|
||||
wxTime(const wxDate&, hourTy h =0, minuteTy m =0, secondTy s=0, bool dst =FALSE);
|
||||
#endif // 0
|
||||
|
||||
// Convert to string
|
||||
#ifndef __SALFORDC__
|
||||
operator wxChar * (void);
|
||||
operator wxDate() const;
|
||||
#endif
|
||||
wxDateTime m_time;
|
||||
|
||||
bool operator<(const wxTime& t) const { return sec < t.sec; }
|
||||
bool operator<=(const wxTime& t) const { return sec <= t.sec; }
|
||||
bool operator>(const wxTime& t) const { return sec > t.sec; }
|
||||
bool operator>=(const wxTime& t) const { return sec >= t.sec; }
|
||||
bool operator==(const wxTime& t) const { return sec == t.sec; }
|
||||
bool operator!=(const wxTime& t) const { return sec != t.sec; }
|
||||
friend wxTime operator+(const wxTime& t, long s) { return wxTime(t.sec+s); }
|
||||
friend wxTime operator+(long s, const wxTime& t) { return wxTime(t.sec+s); }
|
||||
long operator-(const wxTime& t) const { return sec - t.sec; }
|
||||
wxTime operator-(long s) const { return wxTime(sec-s); }
|
||||
void operator+=(long s) { sec += s; }
|
||||
void operator-=(long s) { sec -= s; }
|
||||
bool IsBetween(const wxTime& a, const wxTime& b) const;
|
||||
|
||||
/// Get day
|
||||
int GetDay() const;
|
||||
/// Get month
|
||||
int GetMonth() const;
|
||||
/// Get year
|
||||
int GetYear() const;
|
||||
/// Get day of week (0=Sunday 6=Saturday)
|
||||
int GetDayOfWeek() const;
|
||||
|
||||
hourTy GetHour() const; // hour in local time
|
||||
hourTy GetHourGMT() const; // hour in GMT
|
||||
minuteTy GetMinute() const; // minute in local time
|
||||
minuteTy GetMinuteGMT() const; // minute in GMT
|
||||
secondTy GetSecond() const; // second in local time or GMT
|
||||
clockTy GetSeconds() const { return sec; }
|
||||
secondTy GetSecondGMT() const ;
|
||||
wxTime Max(const wxTime&) const;
|
||||
wxTime Min(const wxTime&) const;
|
||||
static void SetFormat(const tFormat lFormat = wx12h,
|
||||
const tPrecision lPrecision = wxStdMinSec);
|
||||
wxChar *FormatTime() const;
|
||||
/*
|
||||
virtual int compare(const Object&) const;
|
||||
virtual void deepenShallowCopy(); // {}
|
||||
virtual unsigned hash() const;
|
||||
virtual bool isEqual(const Object&) const;
|
||||
virtual void printOn(ostream& strm =cout) const;
|
||||
virtual const Class* species() const;
|
||||
*/
|
||||
DECLARE_DYNAMIC_CLASS(wxTime)
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user