#include "icons/gauge.xpm"
#endif
+#ifdef __WIN16__
+ // Win16 doesn't have them
+ #undef wxUSE_SPINBUTTON
+ #define wxUSE_SPINBUTTON 0
+#endif // __WIN16__
+
+#include "wx/progdlg.h"
+
//----------------------------------------------------------------------
// class definitions
//----------------------------------------------------------------------
void OnChar(wxKeyEvent& event);
private:
- static inline char GetChar(bool on, char c) { return on ? c : '-'; }
- void LogEvent(const char *name, wxKeyEvent& event) const;
+ static inline wxChar GetChar(bool on, wxChar c) { return on ? c : _T('-'); }
+ void LogEvent(const wxChar *name, wxKeyEvent& event) const;
DECLARE_EVENT_TABLE()
};
void OnRadioButtons( wxCommandEvent &event );
void OnSetFont( wxCommandEvent &event );
void OnPageChanged( wxNotebookEvent &event );
+ void OnPageChanging( wxNotebookEvent &event );
void OnSliderUpdate( wxCommandEvent &event );
-#ifndef __WIN16__
+#ifndef wxUSE_SPINBUTTON
void OnSpinUpdate( wxSpinEvent &event );
-#endif
+ void OnUpdateShowProgress( wxUpdateUIEvent& event );
+ void OnShowProgress( wxCommandEvent &event );
+#endif // wxUSE_SPINBUTTON
void OnPasteFromClipboard( wxCommandEvent &event );
void OnCopyToClipboard( wxCommandEvent &event );
void OnMoveToEndOfText( wxCommandEvent &event );
wxGauge *m_gauge;
wxSlider *m_slider;
wxButton *m_fontButton;
-#ifndef __WIN16__
+ wxButton *m_lbSelectNum;
+ wxButton *m_lbSelectThis;
+#ifndef wxUSE_SPINBUTTON
wxSpinButton *m_spinbutton;
+ wxButton *m_btnProgress;
#endif
wxTextCtrl *m_spintext;
MyTextCtrl *m_multitext;
EVT_CHAR(MyTextCtrl::OnChar)
END_EVENT_TABLE()
-void MyTextCtrl::LogEvent(const char *name, wxKeyEvent& event) const
+void MyTextCtrl::LogEvent(const wxChar *name, wxKeyEvent& event) const
{
wxString key;
long keycode = event.KeyCode();
- if ( isprint((int)keycode) )
- key.Printf("'%c'", (char)keycode);
+ if ( wxIsprint((int)keycode) )
+ key.Printf( _T("'%c'") , (char)keycode);
else
{
switch ( keycode )
case WXK_MBUTTON: key = "MBUTTON"; break;
case WXK_CLEAR: key = "CLEAR"; break;
case WXK_SHIFT: key = "SHIFT"; break;
+ case WXK_ALT: key = "ALT"; break;
case WXK_CONTROL: key = "CONTROL"; break;
case WXK_MENU: key = "MENU"; break;
case WXK_PAUSE: key = "PAUSE"; break;
case WXK_NUMPAD_DECIMAL: key = "NUMPAD_DECIMAL"; break;
default:
- key.Printf("unknown (%ld)", keycode);
+ key.Printf( _T("unknown (%ld)"), keycode);
}
}
wxLogMessage( _T("%s event: %s (flags = %c%c%c%c)"),
name,
key.c_str(),
- GetChar(event.ControlDown(), 'C'),
- GetChar(event.AltDown(), 'A'),
- GetChar(event.ShiftDown(), 'S'),
- GetChar(event.MetaDown(), 'M'));
+ GetChar( event.ControlDown(), _T('C') ),
+ GetChar( event.AltDown(), _T('A') ),
+ GetChar( event.ShiftDown(), _T('S') ),
+ GetChar( event.MetaDown(), _T('M') ) );
}
void MyTextCtrl::OnChar(wxKeyEvent& event)
{
- LogEvent("Char", event);
+ LogEvent( _T("Char"), event);
event.Skip();
}
void MyTextCtrl::OnKeyUp(wxKeyEvent& event)
{
- LogEvent("Key up", event);
+ LogEvent( _("Key up"), event);
event.Skip();
}
break;
}
- LogEvent("Key down", event);
+ LogEvent( _("Key down"), event);
event.Skip();
}
const int ID_SLIDER = 181;
const int ID_SPIN = 182;
+const int ID_BTNPROGRESS = 183;
BEGIN_EVENT_TABLE(MyPanel, wxPanel)
EVT_SIZE ( MyPanel::OnSize)
+EVT_NOTEBOOK_PAGE_CHANGING(ID_NOTEBOOK, MyPanel::OnPageChanging)
EVT_NOTEBOOK_PAGE_CHANGED(ID_NOTEBOOK, MyPanel::OnPageChanged)
EVT_LISTBOX (ID_LISTBOX, MyPanel::OnListBox)
EVT_LISTBOX_DCLICK(ID_LISTBOX, MyPanel::OnListBoxDoubleClick)
EVT_CHECKBOX (ID_RADIOBOX_ENABLE, MyPanel::OnRadioButtons)
EVT_BUTTON (ID_SET_FONT, MyPanel::OnSetFont)
EVT_SLIDER (ID_SLIDER, MyPanel::OnSliderUpdate)
-#ifndef __WIN16__
+#ifndef wxUSE_SPINBUTTON
EVT_SPIN (ID_SPIN, MyPanel::OnSpinUpdate)
+EVT_UPDATE_UI (ID_BTNPROGRESS, MyPanel::OnUpdateShowProgress)
+EVT_BUTTON (ID_BTNPROGRESS, MyPanel::OnShowProgress)
#endif
EVT_BUTTON (ID_PASTE_TEXT, MyPanel::OnPasteFromClipboard)
EVT_BUTTON (ID_COPY_TEXT, MyPanel::OnCopyToClipboard)
m_text = new wxTextCtrl( this, -1, "This is the log window.\n", wxPoint(0,50), wxSize(100,50), wxTE_MULTILINE );
// m_text->SetBackgroundColour("wheat");
- delete wxLog::SetActiveTarget(new wxLogTextCtrl(m_text));
+ delete wxLog::SetActiveTarget(new wxLogStderr);
m_notebook = new wxNotebook( this, ID_NOTEBOOK, wxPoint(0,0), wxSize(200,150) );
m_listbox->SetToolTip( "This is a list box" );
#endif // wxUSE_TOOLTIPS
- (void)new wxButton( panel, ID_LISTBOX_SEL_NUM, "Select #2", wxPoint(180,30), wxSize(140,30) );
- (void)new wxButton( panel, ID_LISTBOX_SEL_STR, "Select 'This'", wxPoint(340,30), wxSize(140,30) );
+ m_lbSelectNum = new wxButton( panel, ID_LISTBOX_SEL_NUM, "Select #2", wxPoint(180,30), wxSize(140,30) );
+ m_lbSelectThis = new wxButton( panel, ID_LISTBOX_SEL_STR, "Select 'This'", wxPoint(340,30), wxSize(140,30) );
(void)new wxButton( panel, ID_LISTBOX_CLEAR, "Clear", wxPoint(180,80), wxSize(140,30) );
(void)new wxButton( panel, ID_LISTBOX_APPEND, "Append 'Hi!'", wxPoint(340,80), wxSize(140,30) );
(void)new wxButton( panel, ID_LISTBOX_DELETE, "Delete selected item", wxPoint(180,130), wxSize(140,30) );
);
#endif
m_spintext = new wxTextCtrl( panel, -1, "0", wxPoint(20,160), wxSize(80,-1) );
-#ifndef __WIN16__
+#ifndef wxUSE_SPINBUTTON
m_spinbutton = new wxSpinButton( panel, ID_SPIN, wxPoint(103,159), wxSize(-1,-1) );
m_spinbutton->SetRange(-10,30);
m_spinbutton->SetValue(-5);
+
+ m_btnProgress = new wxButton( panel, ID_BTNPROGRESS, "Show progress dialog",
+ wxPoint(208, 159) );
#endif
m_notebook->AddPage(panel, "wxGauge", FALSE, Image_Gauge);
}
if (m_text) m_text->SetSize( 2, y*2/3+2, x-4, y/3-4 );
}
+void MyPanel::OnPageChanging( wxNotebookEvent &event )
+{
+ int selNew = event.GetSelection(),
+ selOld = event.GetOldSelection();
+ if ( selOld == 2 && selNew == 4 )
+ {
+ wxMessageBox("This demonstrates how a program may prevent the "
+ "page change from taking place - the current page will "
+ "stay the third one", "Conntrol sample",
+ wxICON_INFORMATION | wxOK);
+
+ event.Veto();
+ }
+ else
+ {
+ *m_text << "Notebook selection is being changed from "
+ << selOld << " to " << selNew << "\n";
+ }
+}
+
void MyPanel::OnPageChanged( wxNotebookEvent &event )
{
*m_text << "Notebook selection is " << event.GetSelection() << "\n";
case ID_LISTBOX_SEL_NUM:
{
m_listbox->SetSelection( 2 );
+ m_lbSelectThis->WarpPointer( 40, 14 );
break;
}
case ID_LISTBOX_SEL_STR:
{
m_listbox->SetStringSelection( "This" );
+ m_lbSelectNum->WarpPointer( 40, 14 );
break;
}
case ID_LISTBOX_CLEAR:
m_gauge->SetValue( m_slider->GetValue() );
}
-#ifndef __WIN16__
+#ifndef wxUSE_SPINBUTTON
void MyPanel::OnSpinUpdate( wxSpinEvent &event )
{
wxString value;
m_text->AppendText(value);
}
-#endif
+
+void MyPanel::OnUpdateShowProgress( wxUpdateUIEvent& event )
+{
+ event.Enable( m_spinbutton->GetValue() > 0 );
+}
+
+void MyPanel::OnShowProgress( wxCommandEvent& WXUNUSED(event) )
+{
+ int max = m_spinbutton->GetValue();
+ wxProgressDialog dialog("Progress dialog example",
+ "An informative message",
+ max, // range
+ this, // parent
+ wxPD_CAN_ABORT | wxPD_APP_MODAL);
+
+
+ bool cont = TRUE;
+ for ( int i = 0; i < max && cont; i++ )
+ {
+ wxSleep(1);
+ if ( i == max - 1 )
+ {
+ cont = dialog.Update(i, "That's all, folks!");
+ }
+ else if ( i == max / 2 )
+ {
+ cont = dialog.Update(i, "Only a half left!");
+ }
+ else
+ {
+ cont = dialog.Update(i);
+ }
+ }
+
+ if ( !cont )
+ {
+ *m_text << "Progress dialog aborted!\n";
+ }
+ else
+ {
+ *m_text << "Countdown from " << max << " finished.\n";
+ }
+}
+
+#endif // wxUSE_SPINBUTTON
MyPanel::~MyPanel()
{