#ifdef __WIN16__
// Win16 doesn't have them
- #undef wxUSE_SPINBUTTON
- #define wxUSE_SPINBUTTON 0
+ #ifdef wxUSE_SPINBTN
+ #undef wxUSE_SPINBTN
+ #endif
+ #define wxUSE_SPINBTN 0
#else
- #if !defined(wxUSE_SPINBUTTON)
- #define wxUSE_SPINBUTTON 1
+ #ifndef wxUSE_SPINBTN
+ #define wxUSE_SPINBTN 1
#endif
#endif // __WIN16__
#include "wx/progdlg.h"
-// VZ: this is a temp. hack, will remove soon
-#define wxUSE_SPINCTRL 1
-
#if wxUSE_SPINCTRL
#include "wx/spinctrl.h"
#endif // wxUSE_SPINCTRL
void OnPageChanging( wxNotebookEvent &event );
void OnSliderUpdate( wxCommandEvent &event );
void OnUpdateLabel( wxCommandEvent &event );
-#if wxUSE_SPINBUTTON
+#if wxUSE_SPINBTN
void OnSpinUp( wxSpinEvent &event );
void OnSpinDown( wxSpinEvent &event );
void OnSpinUpdate( wxSpinEvent &event );
void OnUpdateShowProgress( wxUpdateUIEvent& event );
void OnShowProgress( wxCommandEvent &event );
-#endif // wxUSE_SPINBUTTON
+#endif // wxUSE_SPINBTN
#if wxUSE_SPINCTRL
void OnSpinCtrl(wxSpinEvent& event);
wxButton *m_fontButton;
wxButton *m_lbSelectNum;
wxButton *m_lbSelectThis;
-#if wxUSE_SPINBUTTON
+#if wxUSE_SPINBTN
wxSpinButton *m_spinbutton;
wxButton *m_btnProgress;
-#endif // wxUSE_SPINBUTTON
+#endif // wxUSE_SPINBTN
#if wxUSE_SPINCTRL
wxSpinCtrl *m_spinctrl;
void OnIdle( wxIdleEvent& event );
void OnSize( wxSizeEvent& event );
+ void OnMove( wxMoveEvent& event );
+
+ MyPanel *GetPanel() const { return m_panel; }
private:
- wxPanel *m_panel;
+ void UpdateStatusBar(const wxPoint& pos, const wxSize& size)
+ {
+ wxString msg;
+ msg.Printf(_("pos=(%d, %d), size=%dx%d"),
+ pos.x, pos.y, size.x, size.y);
+ SetStatusText(msg, 1);
+ }
+
+ MyPanel *m_panel;
DECLARE_EVENT_TABLE()
};
bool MyApp::OnInit()
{
+ // parse the cmd line
+ int x = 50,
+ y = 50;
+ if ( argc == 2 )
+ {
+ wxSscanf(argv[1], "%d", &x);
+ wxSscanf(argv[2], "%d", &y);
+ }
+
// Create the main frame window
MyFrame *frame = new MyFrame((wxFrame *) NULL,
"Controls wxWindows App",
- 50, 50, 530, 420);
+ x, y, 540, 430);
+
+ frame->SetSizeHints( 500, 425 );
// Give it an icon
// The wxICON() macros loads an icon from a resource under Windows
frame->SetIcon( wxICON(mondrian) );
- wxMenu *file_menu = new wxMenu("", wxMENU_TEAROFF );
+ wxMenu *file_menu = new wxMenu("", wxMENU_TEAROFF);
+
file_menu->Append(MINIMAL_ABOUT, "&About\tF1");
file_menu->AppendSeparator();
file_menu->Append(MINIMAL_QUIT, "E&xit\tAlt-X", "Quit controls sample");
frame->Show(TRUE);
frame->SetCursor(wxCursor(wxCURSOR_HAND));
+ frame->GetPanel()->m_notebook->SetSelection(3);
+
SetTopWindow(frame);
return TRUE;
EVT_CHECKBOX (ID_RADIOBOX_ENABLE, MyPanel::OnRadioButtons)
EVT_BUTTON (ID_SET_FONT, MyPanel::OnSetFont)
EVT_SLIDER (ID_SLIDER, MyPanel::OnSliderUpdate)
-#if wxUSE_SPINBUTTON
+#if wxUSE_SPINBTN
EVT_SPIN (ID_SPIN, MyPanel::OnSpinUpdate)
EVT_SPIN_UP (ID_SPIN, MyPanel::OnSpinUp)
EVT_SPIN_DOWN (ID_SPIN, MyPanel::OnSpinDown)
EVT_UPDATE_UI (ID_BTNPROGRESS, MyPanel::OnUpdateShowProgress)
EVT_BUTTON (ID_BTNPROGRESS, MyPanel::OnShowProgress)
-#endif // wxUSE_SPINBUTTON
+#endif // wxUSE_SPINBTN
#if wxUSE_SPINCTRL
EVT_SPIN (ID_SPINCTRL, MyPanel::OnSpinCtrl)
#endif // wxUSE_SPINCTRL
m_choiceSorted = new wxChoice( panel, ID_CHOICE_SORTED, wxPoint(10,70), wxSize(120,-1),
5, choices, wxCB_SORT );
+#ifndef __WXMOTIF__
SetControlClientData("choice", m_choice);
SetControlClientData("choice", m_choiceSorted);
+#endif
m_choice->SetSelection(2);
m_choice->SetBackgroundColour( "red" );
m_notebook->AddPage(panel, "wxChoice", FALSE, Image_Choice);
panel = new wxPanel(m_notebook);
- m_combo = new wxComboBox( panel, ID_COMBO, "This", wxPoint(10,10), wxSize(120,-1), 5, choices, wxCB_READONLY );
+ (void)new wxStaticBox( panel, -1, "Box around combobox",
+ wxPoint(5, 5), wxSize(150, 100));
+ m_combo = new wxComboBox( panel, ID_COMBO, "This", wxPoint(20,20), wxSize(120,-1), 5, choices, wxCB_READONLY );
(void)new wxButton( panel, ID_COMBO_SEL_NUM, "Select #2", wxPoint(180,30), wxSize(140,30) );
(void)new wxButton( panel, ID_COMBO_SEL_STR, "Select 'This'", wxPoint(340,30), wxSize(140,30) );
(void)new wxButton( panel, ID_COMBO_CLEAR, "Clear", wxPoint(180,80), wxSize(140,30) );
panel = new wxPanel(m_notebook);
(void)new wxRadioBox( panel, ID_RADIOBOX, "That", wxPoint(10,160), wxSize(-1,-1), WXSIZEOF(choices2), choices2, 1, wxRA_SPECIFY_ROWS );
m_radio = new wxRadioBox( panel, ID_RADIOBOX, "This", wxPoint(10,10), wxSize(-1,-1), WXSIZEOF(choices), choices, 1, wxRA_SPECIFY_COLS );
+
+#if wxUSE_TOOLTIPS
+ m_radio->SetToolTip("Ever seen a radiobox?");
+#endif // wxUSE_TOOLTIPS
+
(void)new wxButton( panel, ID_RADIOBOX_SEL_NUM, "Select #2", wxPoint(180,30), wxSize(140,30) );
(void)new wxButton( panel, ID_RADIOBOX_SEL_STR, "Select 'This'", wxPoint(180,80), wxSize(140,30) );
m_fontButton = new wxButton( panel, ID_SET_FONT, "Set more Italic font", wxPoint(340,30), wxSize(140,30) );
wxString s;
s << initialSpinValue;
m_spintext = new wxTextCtrl( panel, -1, s, wxPoint(20,160), wxSize(80,-1) );
-#if wxUSE_SPINBUTTON
+#if wxUSE_SPINBTN
m_spinbutton = new wxSpinButton( panel, ID_SPIN, wxPoint(103,160), wxSize(80, -1) );
m_spinbutton->SetRange(-10,30);
m_spinbutton->SetValue(initialSpinValue);
m_btnProgress = new wxButton( panel, ID_BTNPROGRESS, "Show progress dialog",
wxPoint(300, 160) );
-#endif // wxUSE_SPINBUTTON
+#endif // wxUSE_SPINBTN
#if wxUSE_SPINCTRL
m_spinctrl = new wxSpinCtrl( panel, ID_SPINCTRL, "", wxPoint(200, 160), wxSize(80, -1) );
#ifndef __WXMOTIF__ // wxStaticBitmap not working under Motif yet. MB
wxIcon icon = wxTheApp->GetStdIcon(wxICON_INFORMATION);
- wxStaticBitmap *bmpStatic = new wxStaticBitmap(panel, -1, icon, wxPoint(10, 10));
+ wxStaticBitmap *bmpStatic = new wxStaticBitmap(panel, -1, icon,
+ wxPoint(10, 10));
bmpStatic = new wxStaticBitmap(panel, -1, wxNullIcon, wxPoint(50, 10));
bmpStatic->SetIcon(wxTheApp->GetStdIcon(wxICON_QUESTION));
wxMemoryDC dc;
dc.SelectObject( bitmap );
dc.SetPen(*wxGREEN_PEN);
+ dc.Clear();
dc.DrawEllipse(5, 5, 90, 90);
- dc.DrawText("Bitmap", 20, 20);
+ dc.DrawText("Bitmap", 30, 40);
dc.SelectObject( wxNullBitmap );
(void)new wxBitmapButton(panel, -1, bitmap, wxPoint(100, 20));
+
+ wxBitmap bmp1(wxTheApp->GetStdIcon(wxICON_INFORMATION)),
+ bmp2(wxTheApp->GetStdIcon(wxICON_WARNING)),
+ bmp3(wxTheApp->GetStdIcon(wxICON_QUESTION));
+ wxBitmapButton *bmpBtn = new wxBitmapButton
+ (
+ panel, -1,
+ bmp1,
+ wxPoint(30, 50)
+ );
+ bmpBtn->SetBitmapSelected(bmp2);
+ bmpBtn->SetBitmapFocus(bmp3);
+
(void)new wxButton(panel, ID_BUTTON_LABEL, "Toggle label", wxPoint(250, 20));
m_label = new wxStaticText(panel, -1, "Label with some long text",
wxPoint(250, 60), wxDefaultSize,
void MyPanel::OnListBox( wxCommandEvent &event )
{
+// GetParent()->Move(100, 100);
+
wxListBox *listbox = event.GetId() == ID_LISTBOX ? m_listbox
: m_listboxSorted;
wxStringClientData *obj = ((wxStringClientData *)event.GetClientObject());
m_text->AppendText( "ListBox event client data string is: '" );
- m_text->AppendText( obj ? obj->GetData() : wxString("none"));
+ if (obj) // BC++ doesn't like use of '? .. : .. ' in this context
+ m_text->AppendText( obj->GetData() );
+ else
+ m_text->AppendText( wxString("none") );
+
m_text->AppendText( "'\n" );
m_text->AppendText( "ListBox control client data string is: '" );
obj = (wxStringClientData *)listbox->GetClientObject(listbox->GetSelection());
- m_text->AppendText( obj ? obj->GetData() : wxString("none"));
+ if (obj)
+ m_text->AppendText( obj->GetData() );
+ else
+ m_text->AppendText( wxString("none") );
m_text->AppendText( "'\n" );
}
wxStringClientData *obj = ((wxStringClientData *)event.GetClientObject());
m_text->AppendText( "Choice event client data string is: '" );
- m_text->AppendText( obj ? obj->GetData() : wxString("none"));
+
+ if (obj)
+ m_text->AppendText( obj->GetData() );
+ else
+ m_text->AppendText( wxString("none") );
+
m_text->AppendText( "'\n" );
m_text->AppendText( "Choice control client data string is: '" );
obj = (wxStringClientData *)choice->GetClientObject(choice->GetSelection());
- m_text->AppendText( obj ? obj->GetData() : wxString("none"));
+
+ if (obj)
+ m_text->AppendText( obj->GetData() );
+ else
+ m_text->AppendText( wxString("none") );
m_text->AppendText( "'\n" );
}
#endif // wxUSE_SPINCTRL
-#if wxUSE_SPINBUTTON
+#if wxUSE_SPINBTN
void MyPanel::OnSpinUp( wxSpinEvent &event )
{
wxString value;
}
}
-#endif // wxUSE_SPINBUTTON
+#endif // wxUSE_SPINBTN
MyPanel::~MyPanel()
{
EVT_MENU(MINIMAL_ENABLE_ALL, MyFrame::OnEnableAll)
EVT_SIZE(MyFrame::OnSize)
+ EVT_MOVE(MyFrame::OnMove)
+
EVT_IDLE(MyFrame::OnIdle)
END_EVENT_TABLE()
m_panel->Enable(s_enable);
}
+void MyFrame::OnMove( wxMoveEvent& event )
+{
+ UpdateStatusBar(event.GetPosition(), GetSize());
+
+ event.Skip();
+}
+
void MyFrame::OnSize( wxSizeEvent& event )
{
- wxString msg;
- msg.Printf( _("%dx%d"), event.GetSize().x, event.GetSize().y);
- SetStatusText(msg, 1);
+ UpdateStatusBar(GetPosition(), event.GetSize());
event.Skip();
}