]> git.saurik.com Git - wxWidgets.git/blame - src/generic/datectlg.cpp
Added assert (WinCE doesn't report checked status correctly)
[wxWidgets.git] / src / generic / datectlg.cpp
CommitLineData
39df3acd 1/////////////////////////////////////////////////////////////////////////////
d5ae99f5 2// Name: generic/datectlg.cpp
7ae712f5 3// Purpose: generic wxDatePickerCtrlGeneric implementation
39df3acd
VZ
4// Author: Andreas Pflug
5// Modified by:
6// Created: 2005-01-19
7// RCS-ID: $Id$
8// Copyright: (c) 2005 Andreas Pflug <pgadmin@pse-consulting.de>
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12// ============================================================================
13// declarations
14// ============================================================================
15
16// ----------------------------------------------------------------------------
17// headers
18// ----------------------------------------------------------------------------
19
20#include "wx/wxprec.h"
21
22#ifdef __BORLANDC__
23 #pragma hdrstop
24#endif
25
7ae712f5
VZ
26#if wxUSE_DATEPICKCTRL
27
15c86b39 28#include "wx/datectrl.h"
7ae712f5
VZ
29
30// use this version if we're explicitly requested to do it or if it's the only
31// one we have
15c86b39 32#if wxUSE_DATEPICKCTRL_GENERIC || !defined(wxHAS_NATIVE_DATEPICKCTRL)
7ae712f5 33
a962d4e0
KH
34#ifndef WX_PRECOMP
35 #include "wx/bmpbuttn.h"
36 #include "wx/dialog.h"
37 #include "wx/dcmemory.h"
38 #include "wx/panel.h"
39 #include "wx/textctrl.h"
40 #include "wx/valtext.h"
41#endif
42
1721a8c0
VZ
43#ifdef wxHAS_NATIVE_DATEPICKCTRL
44 // this header is not included from wx/datectrl.h if we have a native
45 // version, but we do need it here
46 #include "wx/generic/datectrl.h"
47#endif
48
49// we need to define _WX_DEFINE_DATE_EVENTS_ before including wx/dateevt.h to
50// define the event types we use if we're the only date picker control version
51// being compiled -- otherwise it's defined in the native version implementation
15c86b39 52#ifndef wxHAS_NATIVE_DATEPICKCTRL
7ae712f5
VZ
53 #define _WX_DEFINE_DATE_EVENTS_
54#endif
55
91edf16c
VZ
56#include "wx/dateevt.h"
57
4b134bb2 58#include "wx/calctrl.h"
4221a0e5 59#include "wx/renderer.h"
39df3acd
VZ
60
61// ----------------------------------------------------------------------------
62// constants
63// ----------------------------------------------------------------------------
64
65enum
66{
67 CTRLID_TXT = 101,
4b134bb2
VZ
68 CTRLID_CAL,
69 CTRLID_BTN,
39df3acd
VZ
70 CTRLID_PAN
71};
72
73#ifndef DEFAULT_ITEM_WIDTH
74 #define DEFAULT_ITEM_WIDTH 100
75#endif
76
1721a8c0
VZ
77// ----------------------------------------------------------------------------
78// local classes
79// ----------------------------------------------------------------------------
80
81#if wxUSE_POPUPWIN
82
83#include "wx/popupwin.h"
84
85class wxDatePopupInternal : public wxPopupTransientWindow
86{
87public:
88 wxDatePopupInternal(wxWindow *parent) : wxPopupTransientWindow(parent) { }
89
90 void ShowAt(int x, int y)
91 {
92 Position(wxPoint(x, y), wxSize(0, 0));
93 Popup();
94 }
95
96 void Hide()
97 {
98 Dismiss();
99 }
100};
101
102#else // !wxUSE_POPUPWIN
103
104class wxDatePopupInternal : public wxDialog
105{
106public:
107 wxDatePopupInternal(wxWindow *parent)
108 : wxDialog(parent,
109 wxID_ANY,
110 wxEmptyString,
111 wxDefaultPosition,
112 wxDefaultSize,
113 wxSIMPLE_BORDER)
114 {
115 }
116
117 void ShowAt(int x, int y)
118 {
119 Show();
120 Move(x, y);
121 }
122
123 void Hide()
124 {
125 wxDialog::Hide();
126 }
127};
128
129#endif // wxUSE_POPUPWIN/!wxUSE_POPUPWIN
130
39df3acd 131// ============================================================================
7ae712f5 132// wxDatePickerCtrlGeneric implementation
39df3acd
VZ
133// ============================================================================
134
7ae712f5
VZ
135BEGIN_EVENT_TABLE(wxDatePickerCtrlGeneric, wxDatePickerCtrlBase)
136 EVT_BUTTON(CTRLID_BTN, wxDatePickerCtrlGeneric::OnClick)
137 EVT_TEXT(CTRLID_TXT, wxDatePickerCtrlGeneric::OnText)
138 EVT_CHILD_FOCUS(wxDatePickerCtrlGeneric::OnChildSetFocus)
39df3acd
VZ
139END_EVENT_TABLE()
140
b6292ff0
VZ
141#ifndef wxHAS_NATIVE_DATEPICKCTRL
142 IMPLEMENT_DYNAMIC_CLASS(wxDatePickerCtrl, wxDatePickerCtrlBase)
143#endif
39df3acd
VZ
144
145// ----------------------------------------------------------------------------
146// creation
147// ----------------------------------------------------------------------------
148
7ae712f5
VZ
149bool wxDatePickerCtrlGeneric::Create(wxWindow *parent,
150 wxWindowID id,
151 const wxDateTime& date,
152 const wxPoint& pos,
153 const wxSize& size,
154 long style,
807f5038 155 const wxValidator& validator,
7ae712f5 156 const wxString& name)
39df3acd 157{
29c86948
VZ
158 wxASSERT_MSG( !(style & wxDP_SPIN),
159 _T("wxDP_SPIN style not supported, use wxDP_DEFAULT") );
160
39df3acd
VZ
161 if ( !wxControl::Create(parent, id, pos, size,
162 style | wxCLIP_CHILDREN | wxWANTS_CHARS,
807f5038 163 validator, name) )
39df3acd
VZ
164
165 {
166 return false;
167 }
168
39df3acd
VZ
169 InheritAttributes();
170
4221a0e5 171 m_txt = new wxTextCtrl(this, CTRLID_TXT);
b6261304
VZ
172 m_txt->Connect(wxEVT_KEY_DOWN,
173 wxKeyEventHandler(wxDatePickerCtrlGeneric::OnEditKey),
174 NULL, this);
175 m_txt->Connect(wxEVT_KILL_FOCUS,
176 wxFocusEventHandler(wxDatePickerCtrlGeneric::OnKillFocus),
177 NULL, this);
39df3acd 178
4221a0e5
VZ
179 const int height = m_txt->GetBestSize().y - 4; // FIXME: fudge
180 wxBitmap bmp(height, height);
181 {
182 wxMemoryDC dc;
183 dc.SelectObject(bmp);
184 wxRendererNative::Get().DrawComboBoxDropButton
185 (
186 this,
187 dc,
188 wxRect(0, 0, height, height)
189 );
190 }
191
192 wxBitmapButton *btn = new wxBitmapButton(this, CTRLID_BTN, bmp);
193 btn->SetMargins(0, 0);
194 m_btn = btn;
39df3acd 195
1721a8c0 196 m_popup = new wxDatePopupInternal(this);
d5ae99f5 197 m_popup->SetFont(GetFont());
39df3acd 198
d5ae99f5 199 wxPanel *panel=new wxPanel(m_popup, CTRLID_PAN,
1721a8c0 200 wxPoint(0, 0), wxDefaultSize,
4b134bb2
VZ
201 wxSUNKEN_BORDER);
202 m_cal = new wxCalendarCtrl(panel, CTRLID_CAL, wxDefaultDateTime,
1721a8c0 203 wxPoint(0, 0), wxDefaultSize,
4b134bb2 204 wxCAL_SHOW_HOLIDAYS | wxSUNKEN_BORDER);
b6261304
VZ
205 m_cal->Connect(wxEVT_CALENDAR_SEL_CHANGED,
206 wxCalendarEventHandler(wxDatePickerCtrlGeneric::OnSelChange),
207 NULL, this);
208 m_cal->Connect(wxEVT_KEY_DOWN,
209 wxKeyEventHandler(wxDatePickerCtrlGeneric::OnCalKey),
210 NULL, this);
211 m_cal->Connect(wxEVT_CALENDAR_DOUBLECLICKED,
212 wxCalendarEventHandler(wxDatePickerCtrlGeneric::OnSelChange),
213 NULL, this);
214 m_cal->Connect(wxEVT_CALENDAR_DAY_CHANGED,
215 wxCalendarEventHandler(wxDatePickerCtrlGeneric::OnSelChange),
216 NULL, this);
217 m_cal->Connect(wxEVT_CALENDAR_MONTH_CHANGED,
218 wxCalendarEventHandler(wxDatePickerCtrlGeneric::OnSelChange),
219 NULL, this);
220 m_cal->Connect(wxEVT_CALENDAR_YEAR_CHANGED,
221 wxCalendarEventHandler(wxDatePickerCtrlGeneric::OnSelChange),
222 NULL, this);
39df3acd
VZ
223
224 wxWindow *yearControl = m_cal->GetYearControl();
225
b6261304
VZ
226 Connect(wxEVT_SET_FOCUS,
227 wxFocusEventHandler(wxDatePickerCtrlGeneric::OnSetFocus));
39df3acd
VZ
228
229 wxClientDC dc(yearControl);
230 dc.SetFont(m_font);
231 wxCoord width, dummy;
232 dc.GetTextExtent(wxT("2000"), &width, &dummy);
1721a8c0 233 width += ConvertDialogToPixels(wxSize(20, 0)).x;
39df3acd
VZ
234
235 wxSize calSize = m_cal->GetBestSize();
236 wxSize yearSize = yearControl->GetSize();
237 yearSize.x = width;
238
239 wxPoint yearPosition = yearControl->GetPosition();
240
d5ae99f5
VZ
241 SetFormat(wxT("%x"));
242
d5ae99f5 243
39df3acd 244#ifdef __WXMSW__
1721a8c0
VZ
245 #define CALBORDER 0
246 #define RIGHTBUTTONBORDER 2
247 #define TOPBUTTONBORDER 1
39df3acd 248#else
1721a8c0
VZ
249 #define CALBORDER 4
250 #define RIGHTBUTTONBORDER 0
251 #define TOPBUTTONBORDER 0
39df3acd
VZ
252#endif
253
254 width = yearPosition.x + yearSize.x+2+CALBORDER/2;
255 if (width < calSize.x-4)
256 width = calSize.x-4;
257
258 int calPos = (width-calSize.x)/2;
259 if (calPos == -1)
260 {
261 calPos = 0;
262 width += 2;
263 }
264 m_cal->SetSize(calPos, 0, calSize.x, calSize.y);
4b134bb2
VZ
265 yearControl->SetSize(width-yearSize.x-CALBORDER/2, yearPosition.y,
266 yearSize.x, yearSize.y);
39df3acd
VZ
267 m_cal->GetMonthControl()->Move(0, 0);
268
269
270
271 panel->SetClientSize(width+CALBORDER/2, calSize.y-2+CALBORDER);
d5ae99f5
VZ
272 m_popup->SetClientSize(panel->GetSize());
273 m_popup->Hide();
39df3acd 274
1721a8c0
VZ
275 if (!date.IsValid())
276 date.Today();
277
278 SetValue(date);
279
3a0c6181 280 return true;
39df3acd
VZ
281}
282
283
7ae712f5 284void wxDatePickerCtrlGeneric::Init()
39df3acd 285{
d5ae99f5 286 m_popup = NULL;
39df3acd
VZ
287 m_txt = NULL;
288 m_cal = NULL;
289 m_btn = NULL;
290
291 m_dropped = false;
292 m_ignoreDrop = false;
293}
294
295
7ae712f5 296bool wxDatePickerCtrlGeneric::Destroy()
39df3acd
VZ
297{
298 if (m_cal)
299 m_cal->Destroy();
d5ae99f5
VZ
300 if (m_popup)
301 m_popup->Destroy();
39df3acd
VZ
302 if (m_txt)
303 m_txt->Destroy();
304 if (m_btn)
305 m_btn->Destroy();
306
d5ae99f5 307 m_popup = NULL;
39df3acd
VZ
308 m_txt = NULL;
309 m_cal = NULL;
310 m_btn = NULL;
311
312 return wxControl::Destroy();
313}
314
315// ----------------------------------------------------------------------------
316// overridden base class methods
317// ----------------------------------------------------------------------------
318
7ae712f5 319void wxDatePickerCtrlGeneric::DoMoveWindow(int x, int y, int w, int h)
39df3acd
VZ
320{
321 wxControl::DoMoveWindow(x, y, w, h);
322 wxSize bs=m_btn->GetBestSize();
323 int eh=m_txt->GetBestSize().y;
324
325 m_txt->SetSize(0, 0, w-bs.x-1, h > eh ? eh : h);
1721a8c0 326 m_btn->SetSize(w - bs.x-RIGHTBUTTONBORDER, TOPBUTTONBORDER, bs.x, h > bs.y ? bs.y : h);
39df3acd
VZ
327
328 if (m_dropped)
1721a8c0 329 DropDown(true);
39df3acd
VZ
330}
331
7ae712f5 332wxSize wxDatePickerCtrlGeneric::DoGetBestSize() const
39df3acd
VZ
333{
334 int bh=m_btn->GetBestSize().y;
335 int eh=m_txt->GetBestSize().y;
336 return wxSize(DEFAULT_ITEM_WIDTH, bh > eh ? bh : eh);
337}
338
339
7ae712f5 340bool wxDatePickerCtrlGeneric::Show(bool show)
39df3acd
VZ
341{
342 if ( !wxControl::Show(show) )
343 {
3a0c6181 344 return false;
39df3acd
VZ
345 }
346
1721a8c0 347 if ( !show )
39df3acd 348 {
1721a8c0 349 if ( m_popup )
39df3acd 350 {
d5ae99f5 351 m_popup->Hide();
39df3acd
VZ
352 m_dropped = false;
353 }
354 }
355
3a0c6181 356 return true;
39df3acd
VZ
357}
358
359
7ae712f5 360bool wxDatePickerCtrlGeneric::Enable(bool enable)
39df3acd
VZ
361{
362 if ( !wxControl::Enable(enable) )
363 {
3a0c6181 364 return false;
39df3acd
VZ
365 }
366
1721a8c0 367 if ( !enable )
39df3acd 368 {
1721a8c0 369 if ( m_cal )
39df3acd
VZ
370 m_cal->Hide();
371 }
1721a8c0
VZ
372
373 if ( m_btn )
39df3acd 374 m_btn->Enable(enable);
1721a8c0 375
3a0c6181 376 return true;
39df3acd
VZ
377}
378
379// ----------------------------------------------------------------------------
7ae712f5 380// wxDatePickerCtrlGeneric API
39df3acd
VZ
381// ----------------------------------------------------------------------------
382
4b134bb2 383bool
7ae712f5
VZ
384wxDatePickerCtrlGeneric::SetDateRange(const wxDateTime& lowerdate,
385 const wxDateTime& upperdate)
4b134bb2
VZ
386{
387 return m_cal->SetDateRange(lowerdate, upperdate);
388}
389
7ae712f5 390bool wxDatePickerCtrlGeneric::SetFormat(const wxChar *fmt)
39df3acd
VZ
391{
392 wxDateTime dt;
393 dt.ParseFormat(wxT("2003-10-13"), wxT("%Y-%m-%d"));
394 wxString str=dt.Format(fmt);
395 wxChar *p=(wxChar*)str.c_str();
396
397 m_format=wxEmptyString;
398
399 while (*p)
400 {
401 int n=wxAtoi(p);
402 if (n == dt.GetDay())
403 {
404 m_format.Append(wxT("%d"));
405 p += 2;
406 }
407 else if (n == (int)dt.GetMonth()+1)
408 {
409 m_format.Append(wxT("%m"));
410 p += 2;
411 }
412 else if (n == dt.GetYear())
413 {
414 m_format.Append(wxT("%Y"));
415 p += 4;
416 }
d5ae99f5
VZ
417 else if (n == (dt.GetYear() % 100))
418 {
1721a8c0
VZ
419 if (GetWindowStyle() & wxDP_SHOWCENTURY)
420 m_format.Append(wxT("%Y"));
421 else
422 m_format.Append(wxT("%y"));
d5ae99f5
VZ
423 p += 2;
424 }
39df3acd
VZ
425 else
426 m_format.Append(*p++);
427 }
428
429 if (m_txt)
430 {
1721a8c0
VZ
431 wxArrayString allowedChars;
432 for ( wxChar c = _T('0'); c <= _T('9'); c++ )
433 allowedChars.Add(wxString(c, 1));
434
435 const wxChar *p = m_format.c_str();
39df3acd
VZ
436 while (*p)
437 {
438 if (*p == '%')
439 p += 2;
440 else
1721a8c0 441 allowedChars.Add(wxString(*p++, 1));
39df3acd 442 }
1721a8c0 443
39df3acd 444 wxTextValidator tv(wxFILTER_INCLUDE_CHAR_LIST);
1721a8c0 445 tv.SetIncludes(allowedChars);
39df3acd
VZ
446
447 m_txt->SetValidator(tv);
d5ae99f5 448
1721a8c0
VZ
449 if (m_currentDate.IsValid())
450 m_txt->SetValue(m_currentDate.Format(m_format));
39df3acd 451 }
1721a8c0 452
39df3acd
VZ
453 return true;
454}
455
456
7ae712f5 457wxDateTime wxDatePickerCtrlGeneric::GetValue() const
39df3acd 458{
1721a8c0 459 return m_currentDate;
39df3acd
VZ
460}
461
462
7ae712f5 463void wxDatePickerCtrlGeneric::SetValue(const wxDateTime& date)
39df3acd
VZ
464{
465 if (m_cal)
466 {
467 if (date.IsValid())
d5ae99f5 468 m_txt->SetValue(date.Format(m_format));
39df3acd 469 else
1721a8c0
VZ
470 {
471 wxASSERT_MSG( HasFlag(wxDP_ALLOWNONE),
472 _T("this control must have a valid date") );
473
39df3acd 474 m_txt->SetValue(wxEmptyString);
1721a8c0
VZ
475 }
476
477 m_currentDate = date;
39df3acd
VZ
478 }
479}
480
481
7ae712f5 482bool wxDatePickerCtrlGeneric::GetRange(wxDateTime *dt1, wxDateTime *dt2) const
39df3acd
VZ
483{
484 if (dt1)
4b134bb2 485 *dt1 = m_cal->GetLowerDateLimit();
39df3acd 486 if (dt1)
4b134bb2 487 *dt2 = m_cal->GetUpperDateLimit();
39df3acd
VZ
488 return true;
489}
490
491
7ae712f5
VZ
492void
493wxDatePickerCtrlGeneric::SetRange(const wxDateTime &dt1, const wxDateTime &dt2)
39df3acd 494{
4b134bb2 495 m_cal->SetDateRange(dt1, dt2);
39df3acd
VZ
496}
497
498// ----------------------------------------------------------------------------
499// event handlers
500// ----------------------------------------------------------------------------
501
7ae712f5 502void wxDatePickerCtrlGeneric::DropDown(bool down)
39df3acd 503{
d5ae99f5 504 if (m_popup)
39df3acd
VZ
505 {
506 if (down)
507 {
d5ae99f5 508 wxDateTime dt;
a7c58211 509 if (!m_txt->GetValue().empty())
39df3acd 510 dt.ParseFormat(m_txt->GetValue(), m_format);
d5ae99f5
VZ
511
512 if (dt.IsValid())
39df3acd 513 m_cal->SetDate(dt);
d5ae99f5
VZ
514 else
515 m_cal->SetDate(wxDateTime::Today());
39df3acd 516
d5ae99f5 517 wxPoint pos=GetParent()->ClientToScreen(GetPosition());
1721a8c0 518 m_popup->ShowAt(pos.x, pos.y + GetSize().y);
39df3acd 519 m_dropped = true;
1721a8c0 520 m_cal->SetFocus();
39df3acd
VZ
521 }
522 else
523 {
524 if (m_dropped)
d5ae99f5 525 m_popup->Hide();
39df3acd
VZ
526 m_dropped = false;
527 }
528 }
529}
530
531
7ae712f5 532void wxDatePickerCtrlGeneric::OnChildSetFocus(wxChildFocusEvent &ev)
39df3acd
VZ
533{
534 ev.Skip();
535 m_ignoreDrop = false;
536
537 wxWindow *w=(wxWindow*)ev.GetEventObject();
538 while (w)
539 {
d5ae99f5 540 if (w == m_popup)
39df3acd
VZ
541 return;
542 w = w->GetParent();
543 }
544
545 if (m_dropped)
546 {
547 DropDown(false);
548 if (ev.GetEventObject() == m_btn)
549 m_ignoreDrop = true;
550 }
551}
552
553
b6292ff0 554void wxDatePickerCtrlGeneric::OnClick(wxCommandEvent& WXUNUSED(event))
39df3acd
VZ
555{
556 if (m_ignoreDrop)
557 {
558 m_ignoreDrop = false;
559 m_txt->SetFocus();
560 }
561 else
562 {
563 DropDown();
564 m_cal->SetFocus();
565 }
566}
567
568
b6292ff0 569void wxDatePickerCtrlGeneric::OnSetFocus(wxFocusEvent& WXUNUSED(ev))
39df3acd
VZ
570{
571 if (m_txt)
572 {
573 m_txt->SetFocus();
1721a8c0 574 m_txt->SetSelection(-1, -1); // select everything
39df3acd
VZ
575 }
576}
577
578
7ae712f5 579void wxDatePickerCtrlGeneric::OnKillFocus(wxFocusEvent &ev)
39df3acd
VZ
580{
581 ev.Skip();
582
583 wxDateTime dt;
584 dt.ParseFormat(m_txt->GetValue(), m_format);
2436cac7 585 if ( !dt.IsValid() )
1721a8c0
VZ
586 {
587 if ( !HasFlag(wxDP_ALLOWNONE) )
588 dt = m_currentDate;
589 }
590
a7c58211
WS
591 if(dt.IsValid())
592 m_txt->SetValue(dt.Format(m_format));
593 else
594 m_txt->SetValue(wxEmptyString);
1721a8c0
VZ
595
596 // notify that we had to change the date after validation
2436cac7
VZ
597 if ( (dt.IsValid() && m_currentDate != dt) ||
598 (!dt.IsValid() && m_currentDate.IsValid()) )
1721a8c0
VZ
599 {
600 m_currentDate = dt;
601 wxDateEvent event(this, dt, wxEVT_DATE_CHANGED);
602 GetEventHandler()->ProcessEvent(event);
603 }
39df3acd
VZ
604}
605
606
7ae712f5 607void wxDatePickerCtrlGeneric::OnSelChange(wxCalendarEvent &ev)
39df3acd
VZ
608{
609 if (m_cal)
610 {
1721a8c0
VZ
611 m_currentDate = m_cal->GetDate();
612 m_txt->SetValue(m_currentDate.Format(m_format));
39df3acd
VZ
613 if (ev.GetEventType() == wxEVT_CALENDAR_DOUBLECLICKED)
614 {
615 DropDown(false);
616 m_txt->SetFocus();
617 }
618 }
619 ev.SetEventObject(this);
620 ev.SetId(GetId());
621 GetParent()->ProcessEvent(ev);
1721a8c0
VZ
622
623 wxDateEvent dev(this, ev.GetDate(), wxEVT_DATE_CHANGED);
624 GetParent()->ProcessEvent(dev);
39df3acd
VZ
625}
626
627
7ae712f5 628void wxDatePickerCtrlGeneric::OnText(wxCommandEvent &ev)
39df3acd
VZ
629{
630 ev.SetEventObject(this);
631 ev.SetId(GetId());
632 GetParent()->ProcessEvent(ev);
633
634 // We'll create an additional event if the date is valid.
1721a8c0 635 // If the date isn't valid, the user's probably in the middle of typing
a7c58211 636 wxString txt = m_txt->GetValue();
39df3acd 637 wxDateTime dt;
a7c58211 638 if (!txt.empty())
39df3acd
VZ
639 {
640 dt.ParseFormat(txt, m_format);
641 if (!dt.IsValid())
642 return;
643 }
644
645 wxCalendarEvent cev(m_cal, wxEVT_CALENDAR_SEL_CHANGED);
646 cev.SetEventObject(this);
647 cev.SetId(GetId());
648 cev.SetDate(dt);
649
650 GetParent()->ProcessEvent(cev);
1721a8c0
VZ
651
652 wxDateEvent dev(this, dt, wxEVT_DATE_CHANGED);
653 GetParent()->ProcessEvent(dev);
39df3acd
VZ
654}
655
656
7ae712f5 657void wxDatePickerCtrlGeneric::OnEditKey(wxKeyEvent & ev)
39df3acd
VZ
658{
659 if (ev.GetKeyCode() == WXK_DOWN && !ev.HasModifiers())
1721a8c0 660 DropDown(true);
39df3acd
VZ
661 else
662 ev.Skip();
663}
664
665
7ae712f5 666void wxDatePickerCtrlGeneric::OnCalKey(wxKeyEvent & ev)
39df3acd
VZ
667{
668 if (ev.GetKeyCode() == WXK_ESCAPE && !ev.HasModifiers())
669 DropDown(false);
670 else
671 ev.Skip();
672}
673
7ae712f5
VZ
674#endif // wxUSE_DATEPICKCTRL_GENERIC
675
676#endif // wxUSE_DATEPICKCTRL
677