#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 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__
+#ifndef wxUSE_SPINBUTTON
wxSpinButton *m_spinbutton;
+ wxButton *m_btnProgress;
#endif
wxTextCtrl *m_spintext;
MyTextCtrl *m_multitext;
frame->SetIcon( wxICON(mondrian) );
wxMenu *file_menu = new wxMenu;
- file_menu->Append(MINIMAL_ABOUT, "&About");
- file_menu->Append(MINIMAL_QUIT, "E&xit");
+ file_menu->Append(MINIMAL_ABOUT, "&About\tF1");
+ file_menu->Append(MINIMAL_QUIT, "E&xit\tAlt-X", "Quit controls sample");
wxMenuBar *menu_bar = new wxMenuBar( wxMB_DOCKABLE );
menu_bar->Append(file_menu, "&File");
#if wxUSE_TOOLTIPS
wxMenu *tooltip_menu = new wxMenu;
- tooltip_menu->Append(MINIMAL_SET_TOOLTIP_DELAY, "Set &delay");
+ tooltip_menu->Append(MINIMAL_SET_TOOLTIP_DELAY, "Set &delay\tCtrl-D");
tooltip_menu->AppendSeparator();
- tooltip_menu->Append(MINIMAL_ENABLE_TOOLTIPS, "&Toggle tooltips",
+ tooltip_menu->Append(MINIMAL_ENABLE_TOOLTIPS, "&Toggle tooltips\tCrtl-T",
"enable/disable tooltips", TRUE);
tooltip_menu->Check(MINIMAL_ENABLE_TOOLTIPS, TRUE);
menu_bar->Append(tooltip_menu, "&Tooltips");
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) );
);
#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";
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()
{