initial native implementation of wxCalendarCtrl for MSW
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@53002 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -185,6 +185,32 @@ public:
|
||||
virtual bool SetDate(const wxDateTime& date) = 0;
|
||||
|
||||
|
||||
// restricting the dates shown by the control to the specified range: only
|
||||
// implemented in the generic and MSW versions for now
|
||||
|
||||
// if either date is set, the corresponding limit will be enforced and true
|
||||
// returned; if none are set, the existing restrictions are removed and
|
||||
// false is returned
|
||||
virtual bool
|
||||
SetDateRange(const wxDateTime& WXUNUSED(lowerdate) = wxDefaultDateTime,
|
||||
const wxDateTime& WXUNUSED(upperdate) = wxDefaultDateTime)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// retrieves the limits currently in use (wxDefaultDateTime if none) in the
|
||||
// provided pointers (which may be NULL) and returns true if there are any
|
||||
// limits or false if none
|
||||
virtual bool
|
||||
GetDateRange(wxDateTime *lowerdate, wxDateTime *upperdate) const
|
||||
{
|
||||
if ( lowerdate )
|
||||
*lowerdate = wxDefaultDateTime;
|
||||
if ( upperdate )
|
||||
*upperdate = wxDefaultDateTime;
|
||||
return false;
|
||||
}
|
||||
|
||||
// returns one of wxCAL_HITTEST_XXX constants and fills either date or wd
|
||||
// with the corresponding value (none for NOWHERE, the date for DAY and wd
|
||||
// for HEADER)
|
||||
@@ -285,16 +311,22 @@ public:
|
||||
|
||||
#define wxCalendarNameStr "CalendarCtrl"
|
||||
|
||||
#if defined(__WXGTK20__) && !defined(__WXUNIVERSAL__)
|
||||
#define wxHAS_NATIVE_CALENDARCTRL
|
||||
#include "wx/gtk/calctrl.h"
|
||||
#define wxCalendarCtrl wxGtkCalendarCtrl
|
||||
#else
|
||||
#ifndef __WXUNIVERSAL__
|
||||
#if defined(__WXGTK20__)
|
||||
#define wxHAS_NATIVE_CALENDARCTRL
|
||||
#include "wx/gtk/calctrl.h"
|
||||
#define wxCalendarCtrl wxGtkCalendarCtrl
|
||||
#elif defined(__WXMSW__)
|
||||
#define wxHAS_NATIVE_CALENDARCTRL
|
||||
#include "wx/msw/calctrl.h"
|
||||
#endif
|
||||
#endif // !__WXUNIVERSAL__
|
||||
|
||||
#ifndef wxHAS_NATIVE_CALENDARCTRL
|
||||
#include "wx/generic/calctrlg.h"
|
||||
#define wxCalendarCtrl wxGenericCalendarCtrl
|
||||
#endif
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// calendar event types and macros for handling them
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@@ -58,15 +58,18 @@ public:
|
||||
// set/get the range in which selection can occur
|
||||
// ---------------------------------------------
|
||||
|
||||
// all functions in this section are for generic version only
|
||||
virtual bool SetDateRange(const wxDateTime& lowerdate = wxDefaultDateTime,
|
||||
const wxDateTime& upperdate = wxDefaultDateTime);
|
||||
|
||||
virtual bool GetDateRange(wxDateTime *lowerdate, wxDateTime *upperdate) const;
|
||||
|
||||
// these functions are for generic version only, don't use them but use the
|
||||
// Set/GetDateRange() above instead
|
||||
bool SetLowerDateLimit(const wxDateTime& date = wxDefaultDateTime);
|
||||
const wxDateTime& GetLowerDateLimit() const { return m_lowdate; }
|
||||
bool SetUpperDateLimit(const wxDateTime& date = wxDefaultDateTime);
|
||||
const wxDateTime& GetUpperDateLimit() const { return m_highdate; }
|
||||
|
||||
bool SetDateRange(const wxDateTime& lowerdate = wxDefaultDateTime,
|
||||
const wxDateTime& upperdate = wxDefaultDateTime);
|
||||
|
||||
|
||||
// calendar mode
|
||||
// -------------
|
||||
|
59
include/wx/msw/calctrl.h
Normal file
59
include/wx/msw/calctrl.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/msw/calctrl.h
|
||||
// Purpose: wxCalendarCtrl control implementation for MSW
|
||||
// Author: Vadim Zeitlin
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (C) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_MSW_CALCTRL_H_
|
||||
#define _WX_MSW_CALCTRL_H_
|
||||
|
||||
class WXDLLIMPEXP_ADV wxCalendarCtrl : public wxCalendarCtrlBase
|
||||
{
|
||||
public:
|
||||
wxCalendarCtrl() { }
|
||||
wxCalendarCtrl(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const wxDateTime& date = wxDefaultDateTime,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxCAL_SHOW_HOLIDAYS,
|
||||
const wxString& name = wxCalendarNameStr)
|
||||
{
|
||||
Create(parent, id, date, pos, size, style, name);
|
||||
}
|
||||
|
||||
bool Create(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const wxDateTime& date = wxDefaultDateTime,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxCAL_SHOW_HOLIDAYS,
|
||||
const wxString& name = wxCalendarNameStr);
|
||||
|
||||
virtual bool SetDate(const wxDateTime& date);
|
||||
virtual wxDateTime GetDate() const;
|
||||
|
||||
virtual bool SetDateRange(const wxDateTime& lowerdate = wxDefaultDateTime,
|
||||
const wxDateTime& upperdate = wxDefaultDateTime);
|
||||
virtual bool GetDateRange(wxDateTime *lowerdate, wxDateTime *upperdate) const;
|
||||
|
||||
virtual bool EnableMonthChange(bool enable = true);
|
||||
|
||||
virtual void Mark(size_t day, bool mark);
|
||||
|
||||
protected:
|
||||
virtual wxSize wxCalendarCtrl::DoGetBestSize() const;
|
||||
|
||||
virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const;
|
||||
|
||||
virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
|
||||
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS(wxCalendarCtrl)
|
||||
DECLARE_NO_COPY_CLASS(wxCalendarCtrl)
|
||||
};
|
||||
|
||||
#endif // _WX_MSW_CALCTRL_H_
|
51
include/wx/msw/private/datecontrols.h
Normal file
51
include/wx/msw/private/datecontrols.h
Normal file
@@ -0,0 +1,51 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: msw/private/datecontrols.h
|
||||
// Purpose: implementation helpers for wxDatePickerCtrl and wxCalendarCtrl
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2008-04-04
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _MSW_PRIVATE_DATECONTROLS_H_
|
||||
#define _MSW_PRIVATE_DATECONTROLS_H_
|
||||
|
||||
// namespace for the helper functions related to the date controls
|
||||
namespace wxMSWDateControls
|
||||
{
|
||||
|
||||
// do the one time only initialization of date classes of comctl32.dll, return
|
||||
// true if ok or log an error and return false if we failed (this can only
|
||||
// happen with a very old version of common controls DLL, i.e. before 4.70)
|
||||
extern bool CheckInitialization();
|
||||
|
||||
// convert SYSTEMTIME to wxDateTime
|
||||
inline void FromSystemTime(wxDateTime *dt, const SYSTEMTIME& st)
|
||||
{
|
||||
dt->Set(st.wDay,
|
||||
wx_static_cast(wxDateTime::Month, wxDateTime::Jan + st.wMonth - 1),
|
||||
st.wYear,
|
||||
0, 0, 0);
|
||||
}
|
||||
|
||||
// convert wxDateTime to SYSTEMTIME
|
||||
inline void ToSystemTime(SYSTEMTIME *st, const wxDateTime& dt)
|
||||
{
|
||||
const wxDateTime::Tm tm(dt.GetTm());
|
||||
|
||||
st->wYear = (WXWORD)tm.year;
|
||||
st->wMonth = (WXWORD)(tm.mon - wxDateTime::Jan + 1);
|
||||
st->wDay = tm.mday;
|
||||
|
||||
st->wDayOfWeek =
|
||||
st->wHour =
|
||||
st->wMinute =
|
||||
st->wSecond =
|
||||
st->wMilliseconds = 0;
|
||||
}
|
||||
|
||||
} // namespace wxMSWDateControls
|
||||
|
||||
#endif // _MSW_PRIVATE_DATECONTROLS_H_
|
||||
|
Reference in New Issue
Block a user