--- /dev/null
+/* XPM */
+static const char *timepick_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"32 32 169 2",
+" c None",
+". c #067706",
+"X c #0F750E",
+"o c #0D7E09",
+"O c #117611",
+"+ c #167616",
+"@ c #1A7A16",
+"# c #1A7A19",
+"$ c #217D1F",
+"% c #267C23",
+"& c #2B712A",
+"* c #5E795F",
+"= c #69696A",
+"- c #6E6E6F",
+"; c #6E6E70",
+": c #6F6F70",
+"> c #717172",
+", c #727273",
+"< c #737373",
+"1 c #737374",
+"2 c #747475",
+"3 c #797979",
+"4 c #FF0000",
+"5 c #FF4800",
+"6 c #FF7400",
+"7 c #FF0048",
+"8 c #FF0074",
+"9 c #018700",
+"0 c #018901",
+"q c #018D00",
+"w c #0D8109",
+"e c #029902",
+"r c #029B02",
+"t c #069905",
+"y c #059A05",
+"u c #198219",
+"i c #1F821A",
+"p c #1A8719",
+"a c #179716",
+"s c #00A900",
+"d c #01A901",
+"f c #00AA01",
+"g c #00AB01",
+"h c #03AB03",
+"j c #00AC01",
+"k c #00AD01",
+"l c #06AB06",
+"z c #16B116",
+"x c #278427",
+"c c #218B20",
+"v c #288428",
+"b c #2A8E29",
+"n c #319231",
+"m c #349632",
+"M c #389635",
+"N c #3F923C",
+"B c #22B422",
+"V c #31A130",
+"C c #32BC32",
+"Z c #37BB37",
+"A c #3EBD3E",
+"S c #40AB40",
+"D c #5FA25F",
+"F c #639064",
+"G c #659A65",
+"H c #68A868",
+"J c #70AB70",
+"K c #77A876",
+"L c #75BC74",
+"P c #52C152",
+"I c #52C353",
+"U c #5CC15C",
+"Y c #6BCB6C",
+"T c #7ECE7E",
+"R c #7FD27F",
+"E c #FF9C48",
+"W c #FF9C74",
+"Q c #FFBF74",
+"! c #FF489C",
+"~ c #FF749C",
+"^ c #FF74BF",
+"/ c #808080",
+"( c #818181",
+") c #838384",
+"_ c #878788",
+"` c #8E8E90",
+"' c #8F8F90",
+"] c #909091",
+"[ c #909092",
+"{ c #919192",
+"} c #939395",
+"| c #989899",
+" . c #80B080",
+".. c #8AB88A",
+"X. c #8DBC8D",
+"o. c #95B795",
+"O. c #92BD92",
+"+. c #9ABC9A",
+"@. c #AFAFAF",
+"#. c #B0B0B0",
+"$. c #B1B1B1",
+"%. c #B0B0B2",
+"&. c #BABABC",
+"*. c #BCBCBC",
+"=. c #BDBDBD",
+"-. c #BEBEBE",
+";. c #BFBFBF",
+":. c #FF9C9C",
+">. c #FF9CBF",
+",. c #9ECB9E",
+"<. c #93D893",
+"1. c #A5C8A5",
+"2. c #ACCAAB",
+"3. c #A5DAA5",
+"4. c #AAD4A9",
+"5. c #ABDDAB",
+"6. c #BBC9BC",
+"7. c #B7D1B7",
+"8. c #BFD2BF",
+"9. c #A9E0A9",
+"0. c #B4E3B4",
+"q. c #FFDF9C",
+"w. c #FFFFBF",
+"e. c #FF9CDF",
+"r. c #FFBFFF",
+"t. c #C0C0C0",
+"y. c #C1C1C1",
+"u. c #C0C0C3",
+"i. c #C5C5C8",
+"p. c #C8C8C8",
+"a. c #C8C8CB",
+"s. c #CBCBCB",
+"d. c #CCCCCC",
+"f. c #CECECF",
+"g. c #C8D8C8",
+"h. c #CBDCCB",
+"j. c #CFCFD1",
+"k. c #D0D0D2",
+"l. c #D1D1D2",
+"z. c #D0D0D3",
+"x. c #D1D1D3",
+"c. c #D2D2D3",
+"v. c #D2D2D4",
+"b. c #D3D3D4",
+"n. c #D3D3D5",
+"m. c #D3D3D6",
+"M. c #D4D4D5",
+"N. c #D4D4D6",
+"B. c #D4D4D7",
+"V. c #D5D5D8",
+"C. c #D8D8DA",
+"Z. c #D9D9DB",
+"A. c #DADADA",
+"S. c #DADADB",
+"D. c #DADEDA",
+"F. c #D9D9DC",
+"G. c #DADADC",
+"H. c #DBDBDD",
+"J. c #DDDDDF",
+"K. c #DDF3DD",
+"L. c #FFFFDF",
+"P. c #FFDFFF",
+"I. c #E2E2E3",
+"U. c #E3E3E3",
+"Y. c #E3E3E4",
+"T. c #E4E4E4",
+"R. c #E5E5E5",
+"E. c #E3E8E3",
+"W. c #FFFFFF",
+/* pixels */
+" h.D u x .. ",
+" 1.c 5.K.P 9 .",
+" 7.n 0.9.A f j v ",
+" O.. U Y B f j z # ",
+" H 0 y h h j j Z S K ",
+" J q C <.r f f P T X E.",
+" p o m y y a R 3.O 8. ",
+" ;.F b N @ V L ,.+ g. ",
+" *.] m.6.M 2.i 4.$ +. ",
+" ;.] z.H.b.D.X.w % G ",
+" ;.] m.G.b.U.b.* & o. ",
+" / ;.' m.G.b.I.B.2 @. ",
+" ;.' m.G.m.U.b.1 #. ",
+" y.' m.C.z.U.b.1 #. ",
+" y.{ m.C.b.T.z.< #. ",
+" y.{ B.C.b.T.z.< #. ",
+" d.' B.C.b.T.z.- #. ",
+" | B.z.b.T.z.- #. ",
+" d._ J.p.C.z.- #. ",
+" / i.s.u.&.- #. ",
+" ) } #.= 3 C. ",
+" W.W.W.W.W.W.W.W.W.;.: < p.W.W.W.W.W.W.W.W.W.W.W.W.W. ",
+" W.W.W.W.W.W.W.W.W.W.W.W.W.W.W.W.W.W.W.W.W.W.W.W.W.W. ",
+" W.W.W.W.W.W.W.W.W.W.W.W.W.W.W.W.W.W.W.W.W.W.W.W.W.W. ",
+" W.W.W.W.6 e.W.E 4 7 P.W.W.Q 4 7 P.W.q.8 W.W.W.W.W.W. ",
+" W.W.W.Q :.e.W.W.W.Q r.Q e.W.W.Q r.L.~ :.W.W.W.W.W.W. ",
+" W.W.W.W.q.e.W.W.w.! W.W.W.w.4 ! W.W P.:.W.W.W.W.W.W. ",
+" W.W.W.W.q.e.W.w.8 W.W.W.W.W.W.q.>.5 4 4 ! W.W.W.W.W. ",
+" W.W.W.Q 4 4 e.E 4 4 ^ Q e.E 4 7 P.W.W.:.W.W.W.W.W.W. ",
+" W.W.W.W.W.W.W.W.W.W.W.W.W.W.W.W.W.W.W.W.W.W.W.W.W.W. ",
+" W.W.W.W.W.W.W.W.W.W.W.W.W.W.W.W.W.W.W.W.W.W.W.W.W.W. ",
+" "
+};
--- /dev/null
+/////////////////////////////////////////////////////////////////////////////
+// Program: wxWidgets Widgets Sample
+// Name: timepick.cpp
+// Purpose: Part of the widgets sample showing time picker
+// Author: Vadim Zeitlin
+// Created: 2011-12-20
+// Id: $Id$
+// Copyright: (c) 2011 wxWindows team
+// Licence: wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+// ============================================================================
+// declarations
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// headers
+// ----------------------------------------------------------------------------
+
+// for compilers that support precompilation, includes "wx/wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+
+#if wxUSE_TIMEPICKCTRL
+
+// for all others, include the necessary headers
+#ifndef WX_PRECOMP
+ #include "wx/app.h"
+ #include "wx/log.h"
+
+ #include "wx/button.h"
+ #include "wx/textctrl.h"
+
+ #include "wx/sizer.h"
+#endif
+
+#include "wx/timectrl.h"
+#include "wx/dateevt.h"
+
+#include "widgets.h"
+
+#include "icons/timepick.xpm"
+
+// ----------------------------------------------------------------------------
+// constants
+// ----------------------------------------------------------------------------
+
+// control ids
+enum
+{
+ TimePickerPage_Reset = wxID_HIGHEST,
+ TimePickerPage_Set,
+ TimePickerPage_Picker
+};
+
+// ----------------------------------------------------------------------------
+// CheckBoxWidgetsPage
+// ----------------------------------------------------------------------------
+
+class TimePickerWidgetsPage : public WidgetsPage
+{
+public:
+ TimePickerWidgetsPage(WidgetsBookCtrl *book, wxImageList *imaglist);
+ virtual ~TimePickerWidgetsPage(){};
+
+ virtual wxControl *GetWidget() const { return m_timePicker; }
+ virtual void RecreateWidget() { CreateTimePicker(); }
+
+ // lazy creation of the content
+ virtual void CreateContent();
+
+protected:
+ // event handlers
+ void OnTimeChanged(wxDateEvent& event);
+
+ void OnButtonSet(wxCommandEvent& event);
+ void OnButtonReset(wxCommandEvent& event);
+
+ // reset the time picker parameters
+ void Reset();
+
+ // (re)create the time picker
+ void CreateTimePicker();
+
+ // the controls
+ // ------------
+
+ // the checkbox itself and the sizer it is in
+ wxTimePickerCtrl *m_timePicker;
+ wxSizer *m_sizerTimePicker;
+
+ wxTextCtrl *m_textCur;
+
+private:
+ DECLARE_EVENT_TABLE()
+ DECLARE_WIDGETS_PAGE(TimePickerWidgetsPage)
+};
+
+// ----------------------------------------------------------------------------
+// event tables
+// ----------------------------------------------------------------------------
+
+BEGIN_EVENT_TABLE(TimePickerWidgetsPage, WidgetsPage)
+ EVT_BUTTON(TimePickerPage_Reset, TimePickerWidgetsPage::OnButtonReset)
+ EVT_BUTTON(TimePickerPage_Set, TimePickerWidgetsPage::OnButtonSet)
+
+ EVT_TIME_CHANGED(wxID_ANY, TimePickerWidgetsPage::OnTimeChanged)
+END_EVENT_TABLE()
+
+// ============================================================================
+// implementation
+// ============================================================================
+
+#if defined(__WXMSW__)
+ #define FAMILY_CTRLS NATIVE_CTRLS
+#else
+ #define FAMILY_CTRLS GENERIC_CTRLS
+#endif
+
+IMPLEMENT_WIDGETS_PAGE(TimePickerWidgetsPage, wxT("TimePicker"),
+ FAMILY_CTRLS | PICKER_CTRLS
+ );
+
+TimePickerWidgetsPage::TimePickerWidgetsPage(WidgetsBookCtrl *book,
+ wxImageList *imaglist)
+ : WidgetsPage(book, imaglist, timepick_xpm)
+{
+}
+
+void TimePickerWidgetsPage::CreateContent()
+{
+ wxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
+
+ // left pane
+ wxSizer* const sizerLeft = new wxBoxSizer(wxVERTICAL);
+
+ sizerLeft->Add(new wxButton(this, TimePickerPage_Reset, "&Reset"),
+ wxSizerFlags().Centre().Border());
+
+
+ // middle pane: operations
+ wxSizer* const sizerMiddle = new wxBoxSizer(wxVERTICAL);
+ sizerMiddle->Add(CreateSizerWithTextAndButton
+ (
+ TimePickerPage_Set,
+ "&Set time",
+ wxID_ANY,
+ &m_textCur
+ ),
+ wxSizerFlags().Expand().Border());
+
+ m_textCur->SetMinSize(wxSize(GetTextExtent(" 99:99:99 ").x, -1));
+
+
+ // right pane: control itself
+ wxSizer *sizerRight = new wxBoxSizer(wxHORIZONTAL);
+
+ m_timePicker = new wxTimePickerCtrl(this, TimePickerPage_Picker);
+
+ sizerRight->Add(0, 0, 1, wxCENTRE);
+ sizerRight->Add(m_timePicker, 1, wxCENTRE);
+ sizerRight->Add(0, 0, 1, wxCENTRE);
+ m_sizerTimePicker = sizerRight; // save it to modify it later
+
+ // the 3 panes panes compose the window
+ sizerTop->Add(sizerLeft, 0, (wxALL & ~wxLEFT), 10);
+ sizerTop->Add(sizerMiddle, 0, (wxTOP | wxBOTTOM), 10);
+ sizerTop->Add(sizerRight, 1, wxGROW | (wxALL & ~wxRIGHT), 10);
+
+ // final initializations
+ Reset();
+
+ SetSizer(sizerTop);
+}
+
+void TimePickerWidgetsPage::Reset()
+{
+ const wxDateTime today = wxDateTime::Today();
+
+ m_timePicker->SetValue(today);
+ m_textCur->SetValue(today.FormatISOTime());
+}
+
+void TimePickerWidgetsPage::CreateTimePicker()
+{
+ const wxDateTime value = m_timePicker->GetValue();
+
+ size_t count = m_sizerTimePicker->GetChildren().GetCount();
+ for ( size_t n = 0; n < count; n++ )
+ {
+ m_sizerTimePicker->Remove(0);
+ }
+
+ delete m_timePicker;
+
+ m_timePicker = new wxTimePickerCtrl(this, TimePickerPage_Picker, value);
+
+ m_sizerTimePicker->Add(0, 0, 1, wxCENTRE);
+ m_sizerTimePicker->Add(m_timePicker, 1, wxCENTRE);
+ m_sizerTimePicker->Add(0, 0, 1, wxCENTRE);
+ m_sizerTimePicker->Layout();
+}
+
+// ----------------------------------------------------------------------------
+// event handlers
+// ----------------------------------------------------------------------------
+
+void TimePickerWidgetsPage::OnButtonReset(wxCommandEvent& WXUNUSED(event))
+{
+ Reset();
+
+ CreateTimePicker();
+}
+
+void TimePickerWidgetsPage::OnButtonSet(wxCommandEvent& WXUNUSED(event))
+{
+ wxDateTime dt;
+ if ( !dt.ParseISOTime(m_textCur->GetValue()) )
+ {
+ wxLogError("Invalid time, please use HH:MM:SS format.");
+ return;
+ }
+
+ m_timePicker->SetValue(dt);
+}
+
+void TimePickerWidgetsPage::OnTimeChanged(wxDateEvent& event)
+{
+ wxLogMessage("Time changed, now is %s (control value is %s).",
+ event.GetDate().FormatISOTime(),
+ m_timePicker->GetValue().FormatISOTime());
+}
+
+#endif // wxUSE_TIMEPICKCTRL