compilation fixes; pruned API

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31496 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2005-01-19 15:57:30 +00:00
parent cad3d9c14c
commit 4b134bb2ce
2 changed files with 67 additions and 33 deletions
include/wx/generic
src/generic

View File

@ -19,13 +19,15 @@ class WXDLLIMPEXP_ADV wxCalendarEvent;
class WXDLLIMPEXP_ADV wxDatePickerCtrl : public wxDatePickerCtrlBase
{
public:
// creating the control
wxDatePickerCtrl() { Init(); }
wxDatePickerCtrl(wxWindow *parent,
wxWindowID id,
const wxDateTime& date = wxDefaultDateTime,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxCAL_SHOW_HOLIDAYS | wxWANTS_CHARS, const wxString& name=wxDatePickerCtrlNameStr);
long style = 0,
const wxString& name = wxDatePickerCtrlNameStr);
bool Create(wxWindow *parent,
wxWindowID id,
@ -35,30 +37,31 @@ public:
long style,
const wxString& name=wxDatePickerCtrlNameStr);
// wxDatePickerCtrl methods
void SetValue(const wxDateTime& date);
wxDateTime GetValue() const;
bool GetRange(wxDateTime *dt1, wxDateTime *dt2) const;
void SetRange(const wxDateTime &dt1, const wxDateTime &dt2);
bool Destroy();
bool SetDateRange(const wxDateTime& lowerdate = wxDefaultDateTime,
const wxDateTime& upperdate = wxDefaultDateTime);
bool SetLowerDateLimit(const wxDateTime& date = wxDefaultDateTime) { return m_cal->SetLowerDateLimit(date); }
const wxDateTime& GetLowerDateLimit() const { return m_cal->GetLowerDateLimit(); }
bool SetUpperDateLimit(const wxDateTime& date = wxDefaultDateTime) { return m_cal->SetUpperDateLimit(date); }
const wxDateTime& GetUpperDateLimit() const { return m_cal->GetUpperDateLimit(); }
bool SetDateRange(const wxDateTime& lowerdate = wxDefaultDateTime, const wxDateTime& upperdate = wxDefaultDateTime)
{ return m_cal->SetDateRange(lowerdate, upperdate); }
wxCalendarDateAttr *GetAttr(size_t day) const { return m_cal->GetAttr(day); }
void SetAttr(size_t day, wxCalendarDateAttr *attr) { m_cal->SetAttr(day, attr); }
void SetHoliday(size_t day) { m_cal->SetHoliday(day); }
void ResetAttr(size_t day) { m_cal->ResetAttr(day); }
// extra methods available only in this (generic) implementation
bool SetFormat(const wxChar *fmt);
wxCalendarCtrl *GetCalendar() const { return m_cal; }
// implementation only from now on
// -------------------------------
// overridden base class methods
virtual bool Destroy();
virtual bool Enable(bool enable = TRUE);
virtual bool Show(bool show = TRUE);
protected:
virtual wxSize DoGetBestSize() const;
virtual void DoMoveWindow(int x, int y, int width, int height);

View File

@ -24,6 +24,7 @@
#endif
#include "wx/datectrl.h"
#include "wx/calctrl.h"
// ----------------------------------------------------------------------------
// constants
@ -32,8 +33,8 @@
enum
{
CTRLID_TXT = 101,
CTRLID_CAL
CTRLID_BTN
CTRLID_CAL,
CTRLID_BTN,
CTRLID_PAN
};
@ -110,27 +111,50 @@ bool wxDatePickerCtrl::Create(wxWindow *parent,
}
m_txt=new wxTextCtrl(this, CTRLID_TXT, txt);
m_txt->Connect(wxID_ANY, wxID_ANY, wxEVT_KEY_DOWN, (wxObjectEventFunction)&wxDatePickerCtrl::OnEditKey, 0, this);
m_txt->Connect(wxID_ANY, wxID_ANY, wxEVT_KILL_FOCUS, (wxObjectEventFunction)&wxDatePickerCtrl::OnKillFocus, 0, this);
m_txt->Connect(wxID_ANY, wxID_ANY, wxEVT_KEY_DOWN,
(wxObjectEventFunction)&wxDatePickerCtrl::OnEditKey,
0, this);
m_txt->Connect(wxID_ANY, wxID_ANY, wxEVT_KILL_FOCUS,
(wxObjectEventFunction)&wxDatePickerCtrl::OnKillFocus,
0, this);
SetFormat(wxT("%x"));
m_btn = new wxBitmapButton(this, CTRLID_BTN, bmp);
m_dlg = new wxDialog(this, CTRLID_CAL, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSIMPLE_BORDER);
m_dlg = new wxDialog(this, CTRLID_CAL, wxEmptyString,
wxDefaultPosition, wxDefaultSize,
wxSIMPLE_BORDER);
m_dlg->SetFont(GetFont());
wxPanel *panel=new wxPanel(m_dlg, CTRLID_PAN, wxPoint(0, 0), wxDefaultSize, wxSUNKEN_BORDER|wxCLIP_CHILDREN);
m_cal = new wxCalendarCtrl(panel, CTRLID_CAL, wxDefaultDateTime, wxPoint(0,0), wxDefaultSize, wxSUNKEN_BORDER);
m_cal->Connect(CTRLID_CAL, CTRLID_CAL, wxEVT_CALENDAR_SEL_CHANGED, (wxObjectEventFunction)&wxDatePickerCtrl::OnSelChange, 0, this);
m_cal->Connect(wxID_ANY, wxID_ANY, wxEVT_KEY_DOWN, (wxObjectEventFunction)&wxDatePickerCtrl::OnCalKey, 0, this);
m_cal->Connect(CTRLID_CAL, CTRLID_CAL, wxEVT_CALENDAR_DOUBLECLICKED, (wxObjectEventFunction)&wxDatePickerCtrl::OnSelChange, 0, this);
m_cal->Connect(CTRLID_CAL, CTRLID_CAL, wxEVT_CALENDAR_DAY_CHANGED, (wxObjectEventFunction)&wxDatePickerCtrl::OnSelChange, 0, this);
m_cal->Connect(CTRLID_CAL, CTRLID_CAL, wxEVT_CALENDAR_MONTH_CHANGED, (wxObjectEventFunction)&wxDatePickerCtrl::OnSelChange, 0, this);
m_cal->Connect(CTRLID_CAL, CTRLID_CAL, wxEVT_CALENDAR_YEAR_CHANGED, (wxObjectEventFunction)&wxDatePickerCtrl::OnSelChange, 0, this);
wxPanel *panel=new wxPanel(m_dlg, CTRLID_PAN,
wxPoint(0, 0), wxDefaultSize,
wxSUNKEN_BORDER);
m_cal = new wxCalendarCtrl(panel, CTRLID_CAL, wxDefaultDateTime,
wxPoint(0,0), wxDefaultSize,
wxCAL_SHOW_HOLIDAYS | wxSUNKEN_BORDER);
m_cal->Connect(CTRLID_CAL, CTRLID_CAL, wxEVT_CALENDAR_SEL_CHANGED,
(wxObjectEventFunction)&wxDatePickerCtrl::OnSelChange,
0, this);
m_cal->Connect(wxID_ANY, wxID_ANY, wxEVT_KEY_DOWN,
(wxObjectEventFunction)&wxDatePickerCtrl::OnCalKey,
0, this);
m_cal->Connect(CTRLID_CAL, CTRLID_CAL, wxEVT_CALENDAR_DOUBLECLICKED,
(wxObjectEventFunction)&wxDatePickerCtrl::OnSelChange,
0, this);
m_cal->Connect(CTRLID_CAL, CTRLID_CAL, wxEVT_CALENDAR_DAY_CHANGED,
(wxObjectEventFunction)&wxDatePickerCtrl::OnSelChange,
0, this);
m_cal->Connect(CTRLID_CAL, CTRLID_CAL, wxEVT_CALENDAR_MONTH_CHANGED,
(wxObjectEventFunction)&wxDatePickerCtrl::OnSelChange,
0, this);
m_cal->Connect(CTRLID_CAL, CTRLID_CAL, wxEVT_CALENDAR_YEAR_CHANGED,
(wxObjectEventFunction)&wxDatePickerCtrl::OnSelChange,
0, this);
wxWindow *yearControl = m_cal->GetYearControl();
Connect(wxID_ANY, wxID_ANY, wxEVT_SET_FOCUS, (wxObjectEventFunction)&wxDatePickerCtrl::OnSetFocus);
Connect(wxID_ANY, wxID_ANY, wxEVT_SET_FOCUS,
(wxObjectEventFunction)&wxDatePickerCtrl::OnSetFocus);
wxClientDC dc(yearControl);
dc.SetFont(m_font);
@ -161,7 +185,8 @@ bool wxDatePickerCtrl::Create(wxWindow *parent,
width += 2;
}
m_cal->SetSize(calPos, 0, calSize.x, calSize.y);
yearControl->SetSize(width-yearSize.x-CALBORDER/2, yearPosition.y, yearSize.x, yearSize.y);
yearControl->SetSize(width-yearSize.x-CALBORDER/2, yearPosition.y,
yearSize.x, yearSize.y);
m_cal->GetMonthControl()->Move(0, 0);
@ -270,6 +295,13 @@ bool wxDatePickerCtrl::Enable(bool enable)
// wxDatePickerCtrl API
// ----------------------------------------------------------------------------
bool
wxDatePickerCtrl::SetDateRange(const wxDateTime& lowerdate,
const wxDateTime& upperdate)
{
return m_cal->SetDateRange(lowerdate, upperdate);
}
bool wxDatePickerCtrl::SetFormat(const wxChar *fmt)
{
wxDateTime dt;
@ -351,17 +383,16 @@ void wxDatePickerCtrl::SetValue(const wxDateTime& date)
bool wxDatePickerCtrl::GetRange(wxDateTime *dt1, wxDateTime *dt2) const
{
if (dt1)
*dt1 = GetLowerDateLimit();
*dt1 = m_cal->GetLowerDateLimit();
if (dt1)
*dt2 = GetUpperDateLimit();
*dt2 = m_cal->GetUpperDateLimit();
return true;
}
void wxDatePickerCtrl::SetRange(const wxDateTime &dt1, const wxDateTime &dt2)
{
SetLowerDateLimit(dt1);
SetUpperDateLimit(dt2);
m_cal->SetDateRange(dt1, dt2);
}
// ----------------------------------------------------------------------------