From 41f02b9acc01217e918fa422298840df7cf6de25 Mon Sep 17 00:00:00 2001 From: Francesco Montorsi Date: Sun, 8 Feb 2009 01:01:00 +0000 Subject: [PATCH] always call SetIcon() on the main frame of the sample; some small cleanup git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58744 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- samples/collpane/collpane.cpp | 12 +- samples/config/conftest.cpp | 276 ++++++++++++++-------------- samples/dialup/nettest.cpp | 6 + samples/event/event.cpp | 6 + samples/grid/griddemo.cpp | 6 + samples/image/image.cpp | 5 + samples/keyboard/keyboard.cpp | 23 ++- samples/layout/layout.cpp | 173 ++++++++--------- samples/mediaplayer/mediaplayer.cpp | 54 +++--- samples/menu/menu.cpp | 6 + samples/nativdlg/nativdlg.cpp | 15 +- samples/propgrid/propgrid.cpp | 5 + samples/propgrid/propgrid.h | 10 +- samples/scroll/scroll.cpp | 6 + samples/shaped/shaped.cpp | 5 + samples/splitter/splitter.cpp | 6 + samples/statbar/statbar.cpp | 6 + samples/stc/stctest.cpp | 7 +- samples/taborder/taborder.cpp | 7 + samples/text/text.cpp | 6 + samples/wrapsizer/wrapsizer.cpp | 145 ++++++++------- 21 files changed, 458 insertions(+), 327 deletions(-) diff --git a/samples/collpane/collpane.cpp b/samples/collpane/collpane.cpp index a48444f4fe..0e3d76e487 100644 --- a/samples/collpane/collpane.cpp +++ b/samples/collpane/collpane.cpp @@ -44,6 +44,10 @@ #include "wx/fontpicker.h" #include "wx/aboutdlg.h" +#ifndef __WXMSW__ + #include "../sample.xpm" +#endif + // ---------------------------------------------------------------------------- // constants // ---------------------------------------------------------------------------- @@ -57,7 +61,7 @@ enum PANE_SHOWDLG, PANE_ABOUT = wxID_ABOUT, PANE_QUIT = wxID_EXIT, - + PANE_BUTTON, PANE_TEXTCTRL }; @@ -166,6 +170,8 @@ MyFrame::MyFrame() wxDefaultPosition, wxSize(420, 300), wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE) { + SetIcon(wxICON(sample)); + #if wxUSE_STATUSBAR CreateStatusBar(2); #endif // wxUSE_STATUSBAR @@ -191,7 +197,7 @@ MyFrame::MyFrame() m_collPane = new wxCollapsiblePane(this, -1, wxT("test!")); wxWindow *win = m_collPane->GetPane(); - + m_paneSizer = new wxBoxSizer( wxVERTICAL ); m_paneSizer->Add( new wxStaticText(win, -1, wxT("Static text") ), 0, wxALIGN_LEFT ); m_paneSizer->Add( new wxStaticText(win, -1, wxT("Yet another one!") ), 0, wxALIGN_LEFT ); @@ -318,7 +324,7 @@ void MyDialog::OnAlignButton(wxCommandEvent& WXUNUSED(ev)) { wxSizerItem *item = m_paneSizer->GetItem( FindWindow(PANE_TEXTCTRL), true ); item->SetFlag( wxALIGN_RIGHT ); - + Layout(); } diff --git a/samples/config/conftest.cpp b/samples/config/conftest.cpp index aea01ea493..5f8fb436a6 100644 --- a/samples/config/conftest.cpp +++ b/samples/config/conftest.cpp @@ -25,6 +25,10 @@ #include "wx/log.h" #include "wx/config.h" +#ifndef __WXMSW__ + #include "../sample.xpm" +#endif + // ---------------------------------------------------------------------------- // classes // ---------------------------------------------------------------------------- @@ -40,19 +44,19 @@ public: class MyFrame: public wxFrame { public: - MyFrame(); - virtual ~MyFrame(); + MyFrame(); + virtual ~MyFrame(); - // callbacks - void OnQuit(wxCommandEvent& event); - void OnAbout(wxCommandEvent& event); - void OnDelete(wxCommandEvent& event); + // callbacks + void OnQuit(wxCommandEvent& event); + void OnAbout(wxCommandEvent& event); + void OnDelete(wxCommandEvent& event); private: - wxTextCtrl *m_text; - wxCheckBox *m_check; + wxTextCtrl *m_text; + wxCheckBox *m_check; - DECLARE_EVENT_TABLE() + DECLARE_EVENT_TABLE() }; enum @@ -85,61 +89,61 @@ IMPLEMENT_APP(MyApp) // `Main program' equivalent, creating windows and returning main app frame bool MyApp::OnInit() { - if ( !wxApp::OnInit() ) - return false; - - // we're using wxConfig's "create-on-demand" feature: it will create the - // config object when it's used for the first time. It has a number of - // advantages compared with explicitly creating our wxConfig: - // 1) we don't pay for it if we don't use it - // 2) there is no danger to create it twice - - // application and vendor name are used by wxConfig to construct the name - // of the config file/registry key and must be set before the first call - // to Get() if you want to override the default values (the application - // name is the name of the executable and the vendor name is the same) - SetVendorName(_T("wxWidgets")); - SetAppName(_T("conftest")); // not needed, it's the default value - - wxConfigBase *pConfig = wxConfigBase::Get(); - - // uncomment this to force writing back of the defaults for all values - // if they're not present in the config - this can give the user an idea - // of all possible settings for this program - pConfig->SetRecordDefaults(); - - // or you could also write something like this: - // wxFileConfig *pConfig = new wxFileConfig("conftest"); - // wxConfigBase::Set(pConfig); - // where you can also specify the file names explicitly if you wish. - // Of course, calling Set() is optional and you only must do it if - // you want to later retrieve this pointer with Get(). - - // create the main program window - MyFrame *frame = new MyFrame; - frame->Show(true); - SetTopWindow(frame); - - // use our config object... - if ( pConfig->Read(_T("/Controls/Check"), 1l) != 0 ) { - wxMessageBox(_T("You can disable this message box by unchecking\n") - _T("the checkbox in the main window (of course, a real\n") - _T("program would have a checkbox right here but we\n") - _T("keep it simple)"), _T("Welcome to wxConfig demo"), - wxICON_INFORMATION | wxOK); - } + if ( !wxApp::OnInit() ) + return false; + + // we're using wxConfig's "create-on-demand" feature: it will create the + // config object when it's used for the first time. It has a number of + // advantages compared with explicitly creating our wxConfig: + // 1) we don't pay for it if we don't use it + // 2) there is no danger to create it twice + + // application and vendor name are used by wxConfig to construct the name + // of the config file/registry key and must be set before the first call + // to Get() if you want to override the default values (the application + // name is the name of the executable and the vendor name is the same) + SetVendorName(_T("wxWidgets")); + SetAppName(_T("conftest")); // not needed, it's the default value + + wxConfigBase *pConfig = wxConfigBase::Get(); - return true; + // uncomment this to force writing back of the defaults for all values + // if they're not present in the config - this can give the user an idea + // of all possible settings for this program + pConfig->SetRecordDefaults(); + + // or you could also write something like this: + // wxFileConfig *pConfig = new wxFileConfig("conftest"); + // wxConfigBase::Set(pConfig); + // where you can also specify the file names explicitly if you wish. + // Of course, calling Set() is optional and you only must do it if + // you want to later retrieve this pointer with Get(). + + // create the main program window + MyFrame *frame = new MyFrame; + frame->Show(true); + SetTopWindow(frame); + + // use our config object... + if ( pConfig->Read(_T("/Controls/Check"), 1l) != 0 ) { + wxMessageBox(_T("You can disable this message box by unchecking\n") + _T("the checkbox in the main window (of course, a real\n") + _T("program would have a checkbox right here but we\n") + _T("keep it simple)"), _T("Welcome to wxConfig demo"), + wxICON_INFORMATION | wxOK); + } + + return true; } int MyApp::OnExit() { - // clean up: Set() returns the active config object as Get() does, but unlike - // Get() it doesn't try to create one if there is none (definitely not what - // we want here!) - delete wxConfigBase::Set((wxConfigBase *) NULL); + // clean up: Set() returns the active config object as Get() does, but unlike + // Get() it doesn't try to create one if there is none (definitely not what + // we want here!) + delete wxConfigBase::Set((wxConfigBase *) NULL); - return 0; + return 0; } // ---------------------------------------------------------------------------- @@ -150,77 +154,79 @@ int MyApp::OnExit() MyFrame::MyFrame() : wxFrame((wxFrame *) NULL, wxID_ANY, _T("wxConfig Demo")) { - // menu - wxMenu *file_menu = new wxMenu; - - file_menu->Append(ConfTest_Delete, _T("&Delete"), _T("Delete config file")); - file_menu->AppendSeparator(); - file_menu->Append(ConfTest_About, _T("&About\tF1"), _T("About this sample")); - file_menu->AppendSeparator(); - file_menu->Append(ConfTest_Quit, _T("E&xit\tAlt-X"), _T("Exit the program")); - wxMenuBar *menu_bar = new wxMenuBar; - menu_bar->Append(file_menu, _T("&File")); - SetMenuBar(menu_bar); + SetIcon(wxICON(sample)); + + // menu + wxMenu *file_menu = new wxMenu; + + file_menu->Append(ConfTest_Delete, _T("&Delete"), _T("Delete config file")); + file_menu->AppendSeparator(); + file_menu->Append(ConfTest_About, _T("&About\tF1"), _T("About this sample")); + file_menu->AppendSeparator(); + file_menu->Append(ConfTest_Quit, _T("E&xit\tAlt-X"), _T("Exit the program")); + wxMenuBar *menu_bar = new wxMenuBar; + menu_bar->Append(file_menu, _T("&File")); + SetMenuBar(menu_bar); #if wxUSE_STATUSBAR - CreateStatusBar(); + CreateStatusBar(); #endif // wxUSE_STATUSBAR - // child controls - wxPanel *panel = new wxPanel(this); - (void)new wxStaticText(panel, wxID_ANY, _T("These controls remember their values!"), - wxPoint(10, 10), wxSize(300, 20)); - m_text = new wxTextCtrl(panel, wxID_ANY, _T(""), wxPoint(10, 40), wxSize(300, 20)); - m_check = new wxCheckBox(panel, wxID_ANY, _T("show welcome message box at startup"), - wxPoint(10, 70), wxSize(300, 20)); - - // restore the control's values from the config - - // NB: in this program, the config object is already created at this moment - // because we had called Get() from MyApp::OnInit(). However, if you later - // change the code and don't create it before this line, it won't break - // anything - unlike if you manually create wxConfig object with Create() - // or in any other way (then you must be sure to create it before using it!). - wxConfigBase *pConfig = wxConfigBase::Get(); - - // we could write Read("/Controls/Text") as well, it's just to show SetPath() - pConfig->SetPath(_T("/Controls")); - - m_text->SetValue(pConfig->Read(_T("Text"), _T(""))); - m_check->SetValue(pConfig->Read(_T("Check"), 1l) != 0); - - // SetPath() understands ".." - pConfig->SetPath(_T("../MainFrame")); - - // restore frame position and size - int x = pConfig->Read(_T("x"), 50), - y = pConfig->Read(_T("y"), 50), - w = pConfig->Read(_T("w"), 350), - h = pConfig->Read(_T("h"), 200); - Move(x, y); - SetClientSize(w, h); - - pConfig->SetPath(_T("/")); - wxString s; - if ( pConfig->Read(_T("TestValue"), &s) ) - { - wxLogStatus(this, wxT("TestValue from config is '%s'"), s.c_str()); - } - else - { - wxLogStatus(this, wxT("TestValue not found in the config")); - } + // child controls + wxPanel *panel = new wxPanel(this); + (void)new wxStaticText(panel, wxID_ANY, _T("These controls remember their values!"), + wxPoint(10, 10), wxSize(300, 20)); + m_text = new wxTextCtrl(panel, wxID_ANY, _T(""), wxPoint(10, 40), wxSize(300, 20)); + m_check = new wxCheckBox(panel, wxID_ANY, _T("show welcome message box at startup"), + wxPoint(10, 70), wxSize(300, 20)); + + // restore the control's values from the config + + // NB: in this program, the config object is already created at this moment + // because we had called Get() from MyApp::OnInit(). However, if you later + // change the code and don't create it before this line, it won't break + // anything - unlike if you manually create wxConfig object with Create() + // or in any other way (then you must be sure to create it before using it!). + wxConfigBase *pConfig = wxConfigBase::Get(); + + // we could write Read("/Controls/Text") as well, it's just to show SetPath() + pConfig->SetPath(_T("/Controls")); + + m_text->SetValue(pConfig->Read(_T("Text"), _T(""))); + m_check->SetValue(pConfig->Read(_T("Check"), 1l) != 0); + + // SetPath() understands ".." + pConfig->SetPath(_T("../MainFrame")); + + // restore frame position and size + int x = pConfig->Read(_T("x"), 50), + y = pConfig->Read(_T("y"), 50), + w = pConfig->Read(_T("w"), 350), + h = pConfig->Read(_T("h"), 200); + Move(x, y); + SetClientSize(w, h); + + pConfig->SetPath(_T("/")); + wxString s; + if ( pConfig->Read(_T("TestValue"), &s) ) + { + wxLogStatus(this, wxT("TestValue from config is '%s'"), s.c_str()); + } + else + { + wxLogStatus(this, wxT("TestValue not found in the config")); + } } void MyFrame::OnQuit(wxCommandEvent&) { - Close(true); + Close(true); } void MyFrame::OnAbout(wxCommandEvent&) { - wxMessageBox(_T("wxConfig demo\n(c) 1998-2001 Vadim Zeitlin"), _T("About"), - wxICON_INFORMATION | wxOK); + wxMessageBox(_T("wxConfig demo\n(c) 1998-2001 Vadim Zeitlin"), _T("About"), + wxICON_INFORMATION | wxOK); } void MyFrame::OnDelete(wxCommandEvent&) @@ -247,23 +253,23 @@ void MyFrame::OnDelete(wxCommandEvent&) MyFrame::~MyFrame() { - wxConfigBase *pConfig = wxConfigBase::Get(); - if ( pConfig == NULL ) - return; - - // save the control's values to the config - pConfig->Write(_T("/Controls/Text"), m_text->GetValue()); - pConfig->Write(_T("/Controls/Check"), m_check->GetValue()); - - // save the frame position - int x, y, w, h; - GetClientSize(&w, &h); - GetPosition(&x, &y); - pConfig->Write(_T("/MainFrame/x"), (long) x); - pConfig->Write(_T("/MainFrame/y"), (long) y); - pConfig->Write(_T("/MainFrame/w"), (long) w); - pConfig->Write(_T("/MainFrame/h"), (long) h); - - pConfig->Write(_T("/TestValue"), wxT("A test value")); + wxConfigBase *pConfig = wxConfigBase::Get(); + if ( pConfig == NULL ) + return; + + // save the control's values to the config + pConfig->Write(_T("/Controls/Text"), m_text->GetValue()); + pConfig->Write(_T("/Controls/Check"), m_check->GetValue()); + + // save the frame position + int x, y, w, h; + GetClientSize(&w, &h); + GetPosition(&x, &y); + pConfig->Write(_T("/MainFrame/x"), (long) x); + pConfig->Write(_T("/MainFrame/y"), (long) y); + pConfig->Write(_T("/MainFrame/w"), (long) w); + pConfig->Write(_T("/MainFrame/h"), (long) h); + + pConfig->Write(_T("/TestValue"), wxT("A test value")); } diff --git a/samples/dialup/nettest.cpp b/samples/dialup/nettest.cpp index 0ad2bd4330..1221ea4705 100644 --- a/samples/dialup/nettest.cpp +++ b/samples/dialup/nettest.cpp @@ -36,6 +36,10 @@ #include "wx/dialup.h" +#ifndef __WXMSW__ + #include "../sample.xpm" +#endif + // ---------------------------------------------------------------------------- // private classes // ---------------------------------------------------------------------------- @@ -220,6 +224,8 @@ void MyApp::OnConnected(wxDialUpEvent& event) MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size) : wxFrame((wxFrame *)NULL, wxID_ANY, title, pos, size) { + SetIcon(wxICON(sample)); + // create a menu bar wxMenu *menuFile = new wxMenu; diff --git a/samples/event/event.cpp b/samples/event/event.cpp index febf5ab031..4b07cd06e4 100644 --- a/samples/event/event.cpp +++ b/samples/event/event.cpp @@ -30,6 +30,10 @@ #include "wx/wx.h" #endif +#ifndef __WXMSW__ + #include "../sample.xpm" +#endif + // ---------------------------------------------------------------------------- // event constants // ---------------------------------------------------------------------------- @@ -214,6 +218,8 @@ bool MyApp::OnInit() MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size) : wxFrame((wxFrame *)NULL, wxID_ANY, title, pos, size) { + SetIcon(wxICON(sample)); + // init members m_nPush = 0; diff --git a/samples/grid/griddemo.cpp b/samples/grid/griddemo.cpp index e3cd8a30b4..5472db618d 100644 --- a/samples/grid/griddemo.cpp +++ b/samples/grid/griddemo.cpp @@ -39,6 +39,10 @@ #include "griddemo.h" +#ifndef __WXMSW__ + #include "../sample.xpm" +#endif + // ---------------------------------------------------------------------------- // wxWin macros // ---------------------------------------------------------------------------- @@ -148,6 +152,8 @@ GridFrame::GridFrame() wxDefaultPosition, wxDefaultSize ) { + SetIcon(wxICON(sample)); + wxMenu *fileMenu = new wxMenu; fileMenu->Append( ID_VTABLE, _T("&Virtual table test\tCtrl-V")); fileMenu->Append( ID_BUGS_TABLE, _T("&Bugs table test\tCtrl-B")); diff --git a/samples/image/image.cpp b/samples/image/image.cpp index 63b414cd6e..9d1d42a7f2 100644 --- a/samples/image/image.cpp +++ b/samples/image/image.cpp @@ -46,6 +46,9 @@ #include "canvas.h" +#ifndef __WXMSW__ + #include "../sample.xpm" +#endif // ============================================================================ // declarations @@ -575,6 +578,8 @@ MyFrame::MyFrame() : wxFrame( (wxFrame *)NULL, wxID_ANY, _T("wxImage sample"), wxPoint(20, 20), wxSize(950, 700) ) { + SetIcon(wxICON(sample)); + wxMenuBar *menu_bar = new wxMenuBar(); wxMenu *menuImage = new wxMenu; diff --git a/samples/keyboard/keyboard.cpp b/samples/keyboard/keyboard.cpp index 5ea78192a1..eb45da0907 100644 --- a/samples/keyboard/keyboard.cpp +++ b/samples/keyboard/keyboard.cpp @@ -18,6 +18,9 @@ #include "wx/wx.h" #endif +#ifndef __WXMSW__ + #include "../sample.xpm" +#endif // Define a new frame type: this is going to be our main frame class MyFrame : public wxFrame @@ -77,6 +80,8 @@ MyFrame::MyFrame(const wxString& title) m_inputWin(NULL), m_skip(true) { + SetIcon(wxICON(sample)); + // IDs for menu items enum { @@ -121,12 +126,12 @@ MyFrame::MyFrame(const wxString& title) " RawKeyCode RawKeyFlags"); - m_logText = new wxTextCtrl(this, wxID_ANY, "", + m_logText = new wxTextCtrl(this, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY|wxHSCROLL); // set monospace font to have output in nice columns - wxFont font(10, wxFONTFAMILY_TELETYPE, + wxFont font(10, wxFONTFAMILY_TELETYPE, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); headerText->SetFont(font); m_logText->SetFont(font); @@ -156,14 +161,14 @@ MyFrame::MyFrame(const wxString& title) Connect(SkipID, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MyFrame::OnSkip)); - // connect event handlers for the blue input window + // connect event handlers for the blue input window m_inputWin->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(MyFrame::OnKeyDown), NULL, this); m_inputWin->Connect(wxEVT_KEY_UP, wxKeyEventHandler(MyFrame::OnKeyUp), NULL, this); m_inputWin->Connect(wxEVT_CHAR, wxKeyEventHandler(MyFrame::OnChar), NULL, this); - m_inputWin->Connect(wxEVT_PAINT, + m_inputWin->Connect(wxEVT_PAINT, wxPaintEventHandler(MyFrame::OnPaintInputWin), NULL, this); @@ -192,7 +197,7 @@ void MyFrame::OnPaintInputWin(wxPaintEvent& WXUNUSED(event)) font.SetPointSize(font.GetPointSize() + 2); dc.SetFont(font); - dc.DrawLabel("Press keys here", + dc.DrawLabel("Press keys here", m_inputWin->GetClientRect(), wxALIGN_CENTER); } @@ -203,7 +208,7 @@ const char* GetVirtualKeyCodeName(int keycode) switch ( keycode ) { #define WXK_(x) \ - case WXK_##x: return #x; + case WXK_##x: return #x; WXK_(BACK) WXK_(TAB) @@ -305,8 +310,8 @@ const char* GetVirtualKeyCodeName(int keycode) WXK_(NUMPAD_DECIMAL) WXK_(NUMPAD_DIVIDE) #undef WXK_ - default: - return NULL; + default: + return NULL; } } @@ -332,7 +337,7 @@ wxString GetKeyName(const wxKeyEvent &event) void MyFrame::LogEvent(const wxString& name, wxKeyEvent& event) { wxString msg; - // event key_name KeyCode modifiers Unicode raw_code raw_flags + // event key_name KeyCode modifiers Unicode raw_code raw_flags msg.Printf("%7s %15s %5d %c%c%c%c" #if wxUSE_UNICODE "%5d (U+%04x)" diff --git a/samples/layout/layout.cpp b/samples/layout/layout.cpp index 08192688a8..c7d56a3360 100644 --- a/samples/layout/layout.cpp +++ b/samples/layout/layout.cpp @@ -34,6 +34,11 @@ #include "layout.h" +#ifndef __WXMSW__ + #include "../sample.xpm" +#endif + + // ---------------------------------------------------------------------------- // MyApp // ---------------------------------------------------------------------------- @@ -76,113 +81,115 @@ MyFrame::MyFrame() wxPoint(30,30), wxDefaultSize, wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE) { - // Make a menubar - wxMenu *file_menu = new wxMenu; + SetIcon(wxICON(sample)); - file_menu->Append(LAYOUT_TEST_PROPORTIONS, _T("&Proportions demo...\tF1")); - file_menu->Append(LAYOUT_TEST_SIZER, _T("Test wx&FlexSizer...\tF2")); - file_menu->Append(LAYOUT_TEST_NB_SIZER, _T("Test ¬ebook sizers...\tF3")); - file_menu->Append(LAYOUT_TEST_GB_SIZER, _T("Test &gridbag sizer...\tF4")); - file_menu->Append(LAYOUT_TEST_SET_MINIMAL, _T("Test Set&ItemMinSize...\tF5")); - file_menu->Append(LAYOUT_TEST_NESTED, _T("Test nested sizer in a wxPanel...\tF6")); - file_menu->Append(LAYOUT_TEST_WRAP, _T("Test wrap sizers...\tF7")); + // Make a menubar + wxMenu *file_menu = new wxMenu; - file_menu->AppendSeparator(); - file_menu->Append(LAYOUT_QUIT, _T("E&xit"), _T("Quit program")); + file_menu->Append(LAYOUT_TEST_PROPORTIONS, _T("&Proportions demo...\tF1")); + file_menu->Append(LAYOUT_TEST_SIZER, _T("Test wx&FlexSizer...\tF2")); + file_menu->Append(LAYOUT_TEST_NB_SIZER, _T("Test ¬ebook sizers...\tF3")); + file_menu->Append(LAYOUT_TEST_GB_SIZER, _T("Test &gridbag sizer...\tF4")); + file_menu->Append(LAYOUT_TEST_SET_MINIMAL, _T("Test Set&ItemMinSize...\tF5")); + file_menu->Append(LAYOUT_TEST_NESTED, _T("Test nested sizer in a wxPanel...\tF6")); + file_menu->Append(LAYOUT_TEST_WRAP, _T("Test wrap sizers...\tF7")); - wxMenu *help_menu = new wxMenu; - help_menu->Append(LAYOUT_ABOUT, _T("&About"), _T("About layout demo...")); + file_menu->AppendSeparator(); + file_menu->Append(LAYOUT_QUIT, _T("E&xit"), _T("Quit program")); - wxMenuBar *menu_bar = new wxMenuBar; + wxMenu *help_menu = new wxMenu; + help_menu->Append(LAYOUT_ABOUT, _T("&About"), _T("About layout demo...")); - menu_bar->Append(file_menu, _T("&File")); - menu_bar->Append(help_menu, _T("&Help")); + wxMenuBar *menu_bar = new wxMenuBar; + + menu_bar->Append(file_menu, _T("&File")); + menu_bar->Append(help_menu, _T("&Help")); - // Associate the menu bar with the frame - SetMenuBar(menu_bar); + // Associate the menu bar with the frame + SetMenuBar(menu_bar); #if wxUSE_STATUSBAR - CreateStatusBar(2); - SetStatusText(_T("wxWidgets layout demo")); + CreateStatusBar(2); + SetStatusText(_T("wxWidgets layout demo")); #endif // wxUSE_STATUSBAR - wxPanel* p = new wxPanel(this, wxID_ANY); - - // we want to get a dialog that is stretchable because it - // has a text ctrl in the middle. at the bottom, we have - // two buttons which. - - wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL ); - - // 1) top: create wxStaticText with minimum size equal to its default size - topsizer->Add( - new wxStaticText( p, wxID_ANY, _T("An explanation (wxALIGN_RIGHT).") ), - wxSizerFlags().Align(wxALIGN_RIGHT).Border(wxALL & ~wxBOTTOM, 5)); - topsizer->Add( - new wxStaticText( p, wxID_ANY, _T("An explanation (wxALIGN_LEFT).") ), - wxSizerFlags().Align(wxALIGN_LEFT).Border(wxALL & ~wxBOTTOM, 5)); - topsizer->Add( - new wxStaticText( p, wxID_ANY, _T("An explanation (wxALIGN_CENTRE_HORIZONTAL).") ), - wxSizerFlags().Align(wxALIGN_CENTRE_HORIZONTAL).Border(wxALL & ~wxBOTTOM, 5)); - - // 2) top: create wxTextCtrl with minimum size (100x60) - topsizer->Add( - new wxTextCtrl( p, wxID_ANY, _T("My text (wxEXPAND)."), wxDefaultPosition, wxSize(100,60), wxTE_MULTILINE), - wxSizerFlags(1).Expand().Border(wxALL, 5)); - - // 2.5) Gratuitous test of wxStaticBoxSizers - wxBoxSizer *statsizer = new wxStaticBoxSizer( - new wxStaticBox(p, wxID_ANY, _T("A wxStaticBoxSizer")), wxVERTICAL ); - statsizer->Add( - new wxStaticText(p, wxID_ANY, _T("And some TEXT inside it")), - wxSizerFlags().Border(wxALL, 30)); - topsizer->Add( - statsizer, - wxSizerFlags(1).Expand().Border(wxALL, 10)); + wxPanel* p = new wxPanel(this, wxID_ANY); + + // we want to get a dialog that is stretchable because it + // has a text ctrl in the middle. at the bottom, we have + // two buttons which. + + wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL ); + + // 1) top: create wxStaticText with minimum size equal to its default size + topsizer->Add( + new wxStaticText( p, wxID_ANY, _T("An explanation (wxALIGN_RIGHT).") ), + wxSizerFlags().Align(wxALIGN_RIGHT).Border(wxALL & ~wxBOTTOM, 5)); + topsizer->Add( + new wxStaticText( p, wxID_ANY, _T("An explanation (wxALIGN_LEFT).") ), + wxSizerFlags().Align(wxALIGN_LEFT).Border(wxALL & ~wxBOTTOM, 5)); + topsizer->Add( + new wxStaticText( p, wxID_ANY, _T("An explanation (wxALIGN_CENTRE_HORIZONTAL).") ), + wxSizerFlags().Align(wxALIGN_CENTRE_HORIZONTAL).Border(wxALL & ~wxBOTTOM, 5)); + + // 2) top: create wxTextCtrl with minimum size (100x60) + topsizer->Add( + new wxTextCtrl( p, wxID_ANY, _T("My text (wxEXPAND)."), wxDefaultPosition, wxSize(100,60), wxTE_MULTILINE), + wxSizerFlags(1).Expand().Border(wxALL, 5)); + + // 2.5) Gratuitous test of wxStaticBoxSizers + wxBoxSizer *statsizer = new wxStaticBoxSizer( + new wxStaticBox(p, wxID_ANY, _T("A wxStaticBoxSizer")), wxVERTICAL ); + statsizer->Add( + new wxStaticText(p, wxID_ANY, _T("And some TEXT inside it")), + wxSizerFlags().Border(wxALL, 30)); + topsizer->Add( + statsizer, + wxSizerFlags(1).Expand().Border(wxALL, 10)); // 2.7) And a test of wxGridSizer wxGridSizer *gridsizer = new wxGridSizer(2, 5, 5); gridsizer->Add(new wxStaticText(p, wxID_ANY, _T("Label")), - wxSizerFlags().Align(wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL)); + wxSizerFlags().Align(wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL)); gridsizer->Add(new wxTextCtrl(p, wxID_ANY, _T("Grid sizer demo")), - wxSizerFlags(1).Align(wxGROW | wxALIGN_CENTER_VERTICAL)); + wxSizerFlags(1).Align(wxGROW | wxALIGN_CENTER_VERTICAL)); gridsizer->Add(new wxStaticText(p, wxID_ANY, _T("Another label")), - wxSizerFlags().Align(wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL)); + wxSizerFlags().Align(wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL)); gridsizer->Add(new wxTextCtrl(p, wxID_ANY, _T("More text")), - wxSizerFlags(1).Align(wxGROW | wxALIGN_CENTER_VERTICAL)); + wxSizerFlags(1).Align(wxGROW | wxALIGN_CENTER_VERTICAL)); gridsizer->Add(new wxStaticText(p, wxID_ANY, _T("Final label")), - wxSizerFlags().Align(wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL)); + wxSizerFlags().Align(wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL)); gridsizer->Add(new wxTextCtrl(p, wxID_ANY, _T("And yet more text")), - wxSizerFlags().Align(wxGROW | wxALIGN_CENTER_VERTICAL)); + wxSizerFlags().Align(wxGROW | wxALIGN_CENTER_VERTICAL)); topsizer->Add( gridsizer, wxSizerFlags().Proportion(1).Expand().Border(wxALL, 10)); #if wxUSE_STATLINE - // 3) middle: create wxStaticLine with minimum size (3x3) - topsizer->Add( - new wxStaticLine( p, wxID_ANY, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), - wxSizerFlags().Expand()); + // 3) middle: create wxStaticLine with minimum size (3x3) + topsizer->Add( + new wxStaticLine( p, wxID_ANY, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), + wxSizerFlags().Expand()); #endif // wxUSE_STATLINE - // 4) bottom: create two centred wxButtons - wxBoxSizer *button_box = new wxBoxSizer( wxHORIZONTAL ); - button_box->Add( - new wxButton( p, wxID_ANY, _T("Two buttons in a box") ), - wxSizerFlags().Border(wxALL, 7)); - button_box->Add( - new wxButton( p, wxID_ANY, _T("(wxCENTER)") ), - wxSizerFlags().Border(wxALL, 7)); + // 4) bottom: create two centred wxButtons + wxBoxSizer *button_box = new wxBoxSizer( wxHORIZONTAL ); + button_box->Add( + new wxButton( p, wxID_ANY, _T("Two buttons in a box") ), + wxSizerFlags().Border(wxALL, 7)); + button_box->Add( + new wxButton( p, wxID_ANY, _T("(wxCENTER)") ), + wxSizerFlags().Border(wxALL, 7)); - topsizer->Add(button_box, wxSizerFlags().Center()); + topsizer->Add(button_box, wxSizerFlags().Center()); - p->SetSizer( topsizer ); + p->SetSizer( topsizer ); - // don't allow frame to get smaller than what the sizers tell it and also set - // the initial size as calculated by the sizers - topsizer->SetSizeHints( this ); + // don't allow frame to get smaller than what the sizers tell it and also set + // the initial size as calculated by the sizers + topsizer->SetSizeHints( this ); } void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) @@ -653,7 +660,7 @@ MyNestedSizerFrame::MyNestedSizerFrame(const wxString &title, int x, int y ) main_sizer->Add( new wxStaticText( this, -1, wxT("Hello outside") ), 0, wxALIGN_CENTER ); main_sizer->Add( new wxStaticText( this, -1, wxT("Hello outside") ), 0, wxALIGN_CENTER ); - wxPanel *panel = new wxPanel( this, -1, wxDefaultPosition, wxDefaultSize, + wxPanel *panel = new wxPanel( this, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL | wxSUNKEN_BORDER ); main_sizer->Add( panel, 0, wxALIGN_CENTER ); wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL ); @@ -661,7 +668,7 @@ MyNestedSizerFrame::MyNestedSizerFrame(const wxString &title, int x, int y ) panel_sizer->Add( new wxStaticText( panel, -1, wxT("Hello inside") ) ); panel_sizer->Add( new wxStaticText( panel, -1, wxT("Hello inside") ) ); panel_sizer->Add( new wxStaticText( panel, -1, wxT("Hello inside") ) ); - + main_sizer->Add( new wxStaticText( this, -1, wxT("Hello outside") ), 0, wxALIGN_CENTER ); m_target = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 80, wxDefaultCoord ) ); @@ -696,14 +703,14 @@ MyWrapSizerFrame::MyWrapSizerFrame(const wxString &title, int x, int y ) for (i = 0; i < 4; i++) row->Add( new wxButton( this, -1, "Hello" ), 0, wxALL, 10 ); root->Add( row, 0, wxGROW ); - + row = new wxWrapSizer; for (i = 0; i < 4; i++) row->Add( new wxButton( this, -1, "Hello" ) ); root->Add( row, 0, wxGROW ); - + #else - // A number of checkboxes inside a wrap sizer + // A number of checkboxes inside a wrap sizer wxSizer *ps_mid = new wxStaticBoxSizer( wxVERTICAL, this, "Wrapping check-boxes" ); wxSizer *ps_mid_wrap = new wxWrapSizer(wxHORIZONTAL); ps_mid->Add( ps_mid_wrap, 100, wxEXPAND ); @@ -718,10 +725,10 @@ MyWrapSizerFrame::MyWrapSizerFrame(const wxString &title, int x, int y ) ps_bottom_box->Add( new wxListBox(this,wxID_ANY,wxPoint(0,0),wxSize(70,70)), 0, wxEXPAND|wxSHAPED ); ps_bottom_box->Add( 10,10 ); ps_bottom_box->Add( new wxCheckBox(this,wxID_ANY,"A much longer option..."), 100, 0, 5 ); - + root->Add( ps_bottom, 1, wxEXPAND | wxALL, 5 ); #endif - + // Set sizer for window SetSizerAndFit( root ); } diff --git a/samples/mediaplayer/mediaplayer.cpp b/samples/mediaplayer/mediaplayer.cpp index eca12874a4..3506174b54 100644 --- a/samples/mediaplayer/mediaplayer.cpp +++ b/samples/mediaplayer/mediaplayer.cpp @@ -67,6 +67,10 @@ #include "wx/filename.h" //For wxFileName::GetName() #include "wx/config.h" //for native wxConfig +#ifndef __WXMSW__ + #include "../sample.xpm" +#endif + // ---------------------------------------------------------------------------- // Bail out if the user doesn't want one of the // things we need @@ -481,6 +485,8 @@ void wxMediaPlayerApp::MacOpenFile(const wxString & fileName ) wxMediaPlayerFrame::wxMediaPlayerFrame(const wxString& title) : wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(600,600)) { + SetIcon(wxICON(sample)); + // // Create Menus // @@ -685,7 +691,7 @@ wxMediaPlayerFrame::wxMediaPlayerFrame(const wxString& title) // Create an initial notebook page so the user has something // to work with without having to go file->open every time :). // - wxMediaPlayerNotebookPage* page = + wxMediaPlayerNotebookPage* page = new wxMediaPlayerNotebookPage(this, m_notebook); m_notebook->AddPage(page, wxT(""), @@ -859,7 +865,7 @@ void wxMediaPlayerFrame::OnShowInterface(wxCommandEvent& event) wxMenuItem* pSIItem = GetMenuBar()->FindItem(wxID_SHOWINTERFACE); wxASSERT(pSIItem); pSIItem->Check(!event.IsChecked()); - + if(event.IsChecked()) wxMessageBox(wxT("Could not show player controls")); else @@ -921,11 +927,11 @@ void wxMediaPlayerFrame::DoOpenFile(const wxString& path, bool bNewPage) true); } - wxMediaPlayerNotebookPage* currentpage = + wxMediaPlayerNotebookPage* currentpage = (wxMediaPlayerNotebookPage*) m_notebook->GetCurrentPage(); if(currentpage->m_nLastFileId != -1) - currentpage->m_playlist->SetItemState(currentpage->m_nLastFileId, + currentpage->m_playlist->SetItemState(currentpage->m_nLastFileId, 0, wxLIST_STATE_SELECTED); wxListItem newlistitem; @@ -959,7 +965,7 @@ void wxMediaPlayerFrame::DoOpenFile(const wxString& path, bool bNewPage) // ---------------------------------------------------------------------------- void wxMediaPlayerFrame::DoPlayFile(const wxString& path) { - wxMediaPlayerNotebookPage* currentpage = + wxMediaPlayerNotebookPage* currentpage = (wxMediaPlayerNotebookPage*) m_notebook->GetCurrentPage(); wxListItem listitem; @@ -986,7 +992,7 @@ void wxMediaPlayerFrame::DoPlayFile(const wxString& path) } else { - int nNewId = listitem.GetData() ? listitem.GetId() : + int nNewId = listitem.GetData() ? listitem.GetId() : currentpage->m_playlist->GetItemCount()-1; m_notebook->SetPageText(m_notebook->GetSelection(), wxFileName(path).GetName()); @@ -1023,9 +1029,9 @@ void wxMediaPlayerFrame::DoPlayFile(const wxString& path) currentpage->m_nLastFileId = nNewId; currentpage->m_szFile = path; - currentpage->m_playlist->SetItem(currentpage->m_nLastFileId, + currentpage->m_playlist->SetItem(currentpage->m_nLastFileId, 1, wxFileName(path).GetName()); - currentpage->m_playlist->SetItem(currentpage->m_nLastFileId, + currentpage->m_playlist->SetItem(currentpage->m_nLastFileId, 2, wxT("")); } } @@ -1038,7 +1044,7 @@ void wxMediaPlayerFrame::DoPlayFile(const wxString& path) // ---------------------------------------------------------------------------- void wxMediaPlayerFrame::OnMediaLoaded(wxMediaEvent& WXUNUSED(evt)) { - wxMediaPlayerNotebookPage* currentpage = + wxMediaPlayerNotebookPage* currentpage = (wxMediaPlayerNotebookPage*) m_notebook->GetCurrentPage(); if( !currentpage->m_mediactrl->Play() ) @@ -1079,7 +1085,7 @@ void wxMediaPlayerFrame::OnSelectBackend(wxCommandEvent& WXUNUSED(evt)) ), wxT(""), true); DoOpenFile( - ((wxMediaPlayerNotebookPage*) m_notebook->GetCurrentPage())->m_szFile, + ((wxMediaPlayerNotebookPage*) m_notebook->GetCurrentPage())->m_szFile, false); } } @@ -1158,7 +1164,7 @@ void wxMediaPlayerFrame::OnCloseCurrentPage(wxCommandEvent& WXUNUSED(event)) // ---------------------------------------------------------------------------- void wxMediaPlayerFrame::OnPlay(wxCommandEvent& WXUNUSED(event)) { - wxMediaPlayerNotebookPage* currentpage = + wxMediaPlayerNotebookPage* currentpage = (wxMediaPlayerNotebookPage*) m_notebook->GetCurrentPage(); wxListItem listitem; @@ -1181,7 +1187,7 @@ void wxMediaPlayerFrame::OnPlay(wxCommandEvent& WXUNUSED(event)) listitem.SetState(listitem.GetState() | wxLIST_STATE_SELECTED); currentpage->m_playlist->SetItem(listitem); wxASSERT(listitem.GetData()); - DoPlayFile((*((wxString*) listitem.GetData()))); + DoPlayFile((*((wxString*) listitem.GetData()))); } } else @@ -1200,7 +1206,7 @@ void wxMediaPlayerFrame::OnKeyDown(wxKeyEvent& event) { if(event.GetKeyCode() == WXK_BACK/*DELETE*/) { - wxMediaPlayerNotebookPage* currentpage = + wxMediaPlayerNotebookPage* currentpage = (wxMediaPlayerNotebookPage*) m_notebook->GetCurrentPage(); //delete all selected items while(true) @@ -1235,7 +1241,7 @@ void wxMediaPlayerFrame::OnKeyDown(wxKeyEvent& event) // ---------------------------------------------------------------------------- void wxMediaPlayerFrame::OnStop(wxCommandEvent& WXUNUSED(evt)) { - wxMediaPlayerNotebookPage* currentpage = + wxMediaPlayerNotebookPage* currentpage = (wxMediaPlayerNotebookPage*) m_notebook->GetCurrentPage(); if( !currentpage->m_mediactrl->Stop() ) @@ -1255,7 +1261,7 @@ void wxMediaPlayerFrame::OnStop(wxCommandEvent& WXUNUSED(evt)) // ---------------------------------------------------------------------------- void wxMediaPlayerFrame::OnChangeSong(wxListEvent& WXUNUSED(evt)) { - wxMediaPlayerNotebookPage* currentpage = + wxMediaPlayerNotebookPage* currentpage = (wxMediaPlayerNotebookPage*) m_notebook->GetCurrentPage(); wxListItem listitem; @@ -1274,7 +1280,7 @@ void wxMediaPlayerFrame::OnChangeSong(wxListEvent& WXUNUSED(evt)) // ---------------------------------------------------------------------------- void wxMediaPlayerFrame::OnPrev(wxCommandEvent& WXUNUSED(event)) { - wxMediaPlayerNotebookPage* currentpage = + wxMediaPlayerNotebookPage* currentpage = (wxMediaPlayerNotebookPage*) m_notebook->GetCurrentPage(); if (currentpage->m_playlist->GetItemCount() == 0) @@ -1291,7 +1297,7 @@ void wxMediaPlayerFrame::OnPrev(wxCommandEvent& WXUNUSED(event)) currentpage->m_playlist->SetItemState(nSelectedItem, 0, wxLIST_STATE_SELECTED); } - if (nLastSelectedItem == -1) + if (nLastSelectedItem == -1) { //nothing selected, default to the file before the currently playing one if(currentpage->m_nLastFileId == 0) @@ -1299,7 +1305,7 @@ void wxMediaPlayerFrame::OnPrev(wxCommandEvent& WXUNUSED(event)) else nLastSelectedItem = currentpage->m_nLastFileId - 1; } - else if (nLastSelectedItem == 0) + else if (nLastSelectedItem == 0) nLastSelectedItem = currentpage->m_playlist->GetItemCount() - 1; else nLastSelectedItem -= 1; @@ -1327,7 +1333,7 @@ void wxMediaPlayerFrame::OnPrev(wxCommandEvent& WXUNUSED(event)) // ---------------------------------------------------------------------------- void wxMediaPlayerFrame::OnNext(wxCommandEvent& WXUNUSED(event)) { - wxMediaPlayerNotebookPage* currentpage = + wxMediaPlayerNotebookPage* currentpage = (wxMediaPlayerNotebookPage*) m_notebook->GetCurrentPage(); if (currentpage->m_playlist->GetItemCount() == 0) @@ -1349,7 +1355,7 @@ void wxMediaPlayerFrame::OnNext(wxCommandEvent& WXUNUSED(event)) if(currentpage->m_nLastFileId == currentpage->m_playlist->GetItemCount() - 1) nLastSelectedItem = 0; else - nLastSelectedItem = currentpage->m_nLastFileId + 1; + nLastSelectedItem = currentpage->m_nLastFileId + 1; } else if (nLastSelectedItem == currentpage->m_playlist->GetItemCount() - 1) nLastSelectedItem = 0; @@ -1379,7 +1385,7 @@ void wxMediaPlayerFrame::OnNext(wxCommandEvent& WXUNUSED(event)) // ---------------------------------------------------------------------------- void wxMediaPlayerFrame::OnVolumeDown(wxCommandEvent& WXUNUSED(event)) { - wxMediaPlayerNotebookPage* currentpage = + wxMediaPlayerNotebookPage* currentpage = (wxMediaPlayerNotebookPage*) m_notebook->GetCurrentPage(); double dVolume = currentpage->m_mediactrl->GetVolume(); @@ -1393,7 +1399,7 @@ void wxMediaPlayerFrame::OnVolumeDown(wxCommandEvent& WXUNUSED(event)) // ---------------------------------------------------------------------------- void wxMediaPlayerFrame::OnVolumeUp(wxCommandEvent& WXUNUSED(event)) { - wxMediaPlayerNotebookPage* currentpage = + wxMediaPlayerNotebookPage* currentpage = (wxMediaPlayerNotebookPage*) m_notebook->GetCurrentPage(); double dVolume = currentpage->m_mediactrl->GetVolume(); @@ -1419,7 +1425,7 @@ void wxMediaPlayerFrame::OnVolumeUp(wxCommandEvent& WXUNUSED(event)) // ---------------------------------------------------------------------------- void wxMediaPlayerTimer::Notify() { - wxMediaPlayerNotebookPage* currentpage = + wxMediaPlayerNotebookPage* currentpage = (wxMediaPlayerNotebookPage*) m_frame->m_notebook->GetCurrentPage(); wxMediaCtrl* currentMediaCtrl = currentpage->m_mediactrl; @@ -1642,7 +1648,7 @@ wxMediaPlayerNotebookPage::wxMediaPlayerNotebookPage(wxMediaPlayerFrame* parentF m_gauge->Create(this, wxID_GAUGE, 0, wxDefaultPosition, wxDefaultSize, wxGA_HORIZONTAL | wxGA_SMOOTH); sizer->Add(m_gauge, 0, wxALIGN_CENTER_HORIZONTAL|wxALL|wxEXPAND , 5); - + // // Create the speed/volume sliders diff --git a/samples/menu/menu.cpp b/samples/menu/menu.cpp index fd01886676..9003f351d8 100644 --- a/samples/menu/menu.cpp +++ b/samples/menu/menu.cpp @@ -59,6 +59,10 @@ #include "copy.xpm" #endif +#ifndef __WXMSW__ + #include "../sample.xpm" +#endif + // ---------------------------------------------------------------------------- // classes // ---------------------------------------------------------------------------- @@ -371,6 +375,8 @@ bool MyApp::OnInit() MyFrame::MyFrame() : wxFrame((wxFrame *)NULL, wxID_ANY, _T("wxWidgets menu sample")) { + SetIcon(wxICON(sample)); + #if USE_LOG_WINDOW m_textctrl = NULL; #endif diff --git a/samples/nativdlg/nativdlg.cpp b/samples/nativdlg/nativdlg.cpp index dce90cc97d..ef9b9f06b4 100644 --- a/samples/nativdlg/nativdlg.cpp +++ b/samples/nativdlg/nativdlg.cpp @@ -24,10 +24,17 @@ #error Sorry, this sample is only appropriate under Windows. #endif +#ifndef __WXMSW__ + #include "../sample.xpm" +#endif + #include #include "nativdlg.h" #include "resource.h" + + + IMPLEMENT_APP(MyApp) bool MyApp::OnInit(void) @@ -75,7 +82,9 @@ END_EVENT_TABLE() MyFrame::MyFrame(wxWindow *parent, const wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size): wxFrame(parent, id, title, pos, size) { - panel = NULL; + SetIcon(wxICON(sample)); + + panel = NULL; } void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) @@ -104,10 +113,10 @@ END_EVENT_TABLE() void MyDialog::OnOk(wxCommandEvent& WXUNUSED(event)) { - EndModal(wxID_OK); + EndModal(wxID_OK); } void MyDialog::OnCancel(wxCommandEvent& WXUNUSED(event)) { - EndModal(wxID_CANCEL); + EndModal(wxID_CANCEL); } diff --git a/samples/propgrid/propgrid.cpp b/samples/propgrid/propgrid.cpp index 3df4fcd879..594c87e51e 100644 --- a/samples/propgrid/propgrid.cpp +++ b/samples/propgrid/propgrid.cpp @@ -68,6 +68,9 @@ #include +#ifndef __WXMSW__ + #include "../sample.xpm" +#endif // ----------------------------------------------------------------------- // wxSampleMultiButtonEditor @@ -2062,6 +2065,8 @@ FormMain::FormMain(const wxString& title, const wxPoint& pos, const wxSize& size (wxMINIMIZE_BOX|wxMAXIMIZE_BOX|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCAPTION| wxTAB_TRAVERSAL|wxCLOSE_BOX|wxNO_FULL_REPAINT_ON_RESIZE) ) { + SetIcon(wxICON(sample)); + m_propGrid = NULL; m_panel = NULL; diff --git a/samples/propgrid/propgrid.h b/samples/propgrid/propgrid.h index c8a6574f34..a4c1ff613e 100644 --- a/samples/propgrid/propgrid.h +++ b/samples/propgrid/propgrid.h @@ -72,12 +72,12 @@ class wxVectorProperty : public wxPGProperty public: wxVectorProperty( const wxString& label = wxPG_LABEL, - const wxString& name = wxPG_LABEL, - const wxVector3f& value = wxVector3f() ); + const wxString& name = wxPG_LABEL, + const wxVector3f& value = wxVector3f() ); virtual ~wxVectorProperty(); virtual void ChildChanged( wxVariant& thisValue, - int childIndex, wxVariant& childValue ) const; + int childIndex, wxVariant& childValue ) const; virtual void RefreshChildren(); protected: @@ -109,7 +109,7 @@ public: virtual ~wxTriangleProperty(); virtual void ChildChanged( wxVariant& thisValue, - int childIndex, wxVariant& childValue ) const; + int childIndex, wxVariant& childValue ) const; virtual void RefreshChildren(); protected: @@ -128,7 +128,7 @@ class FormMain : public wxFrame { public: FormMain(const wxString& title, const wxPoint& pos, const wxSize& size ); - ~FormMain(); + ~FormMain(); wxPropertyGridManager* m_pPropGridManager; wxPropertyGrid* m_propGrid; diff --git a/samples/scroll/scroll.cpp b/samples/scroll/scroll.cpp index 98a9d01dad..7c94906b62 100644 --- a/samples/scroll/scroll.cpp +++ b/samples/scroll/scroll.cpp @@ -22,6 +22,10 @@ #include "wx/log.h" #include "wx/tglbtn.h" +#ifndef __WXMSW__ + #include "../sample.xpm" +#endif + // ---------------------------------------------------------------------------- // a trivial example // ---------------------------------------------------------------------------- @@ -854,6 +858,8 @@ END_EVENT_TABLE() MyFrame::MyFrame() : wxFrame(NULL, wxID_ANY, "wxWidgets scroll sample") { + SetIcon(wxICON(sample)); + wxMenu *menuFile = new wxMenu; menuFile->Append(wxID_ABOUT, "&About.."); menuFile->AppendSeparator(); diff --git a/samples/shaped/shaped.cpp b/samples/shaped/shaped.cpp index 9ebf3e697c..4e828a41f8 100644 --- a/samples/shaped/shaped.cpp +++ b/samples/shaped/shaped.cpp @@ -40,6 +40,9 @@ #include "wx/dcclient.h" #include "wx/image.h" +#ifndef __WXMSW__ + #include "../sample.xpm" +#endif // ---------------------------------------------------------------------------- // constants @@ -246,6 +249,8 @@ MainFrame::MainFrame() : wxFrame(NULL, wxID_ANY, "wxWidgets Shaped Sample", wxDefaultPosition, wxSize(200, 100)) { + SetIcon(wxICON(sample)); + wxMenuBar * const mbar = new wxMenuBar; wxMenu * const menuFrames = new wxMenu; menuFrames->Append(Show_Shaped, "Show &shaped window\tCtrl-S"); diff --git a/samples/splitter/splitter.cpp b/samples/splitter/splitter.cpp index b95e2e75ed..b57cb61979 100644 --- a/samples/splitter/splitter.cpp +++ b/samples/splitter/splitter.cpp @@ -39,6 +39,10 @@ #include "wx/splitter.h" #include "wx/dcmirror.h" +#ifndef __WXMSW__ + #include "../sample.xpm" +#endif + // ---------------------------------------------------------------------------- // constants // ---------------------------------------------------------------------------- @@ -197,6 +201,8 @@ MyFrame::MyFrame() wxDefaultPosition, wxSize(420, 300), wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE) { + SetIcon(wxICON(sample)); + #if wxUSE_STATUSBAR CreateStatusBar(2); #endif // wxUSE_STATUSBAR diff --git a/samples/statbar/statbar.cpp b/samples/statbar/statbar.cpp index 8e4573a778..ff9113fb19 100644 --- a/samples/statbar/statbar.cpp +++ b/samples/statbar/statbar.cpp @@ -49,6 +49,10 @@ #include "wx/datetime.h" #include "wx/numdlg.h" +#ifndef __WXMSW__ + #include "../sample.xpm" +#endif + // define this for the platforms which don't support wxBitmapButton (such as // Motif), else a wxBitmapButton will be used @@ -312,6 +316,8 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size) : wxFrame((wxWindow *)NULL, wxID_ANY, title, pos, size) #endif { + SetIcon(wxICON(sample)); + m_statbarDefault = NULL; m_statbarCustom = NULL; diff --git a/samples/stc/stctest.cpp b/samples/stc/stctest.cpp index 14db821fc5..06889c1c71 100644 --- a/samples/stc/stctest.cpp +++ b/samples/stc/stctest.cpp @@ -39,6 +39,9 @@ #include "edit.h" // Edit module #include "prefs.h" // Prefs +#ifndef __WXMSW__ + #include "../sample.xpm" +#endif //---------------------------------------------------------------------------- // resources @@ -300,7 +303,9 @@ END_EVENT_TABLE () AppFrame::AppFrame (const wxString &title) : wxFrame ((wxFrame *)NULL, wxID_ANY, title, wxDefaultPosition, wxSize(750,550), - wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE) { + wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE) +{ + SetIcon(wxICON(sample)); // intitialize important variables m_edit = NULL; diff --git a/samples/taborder/taborder.cpp b/samples/taborder/taborder.cpp index 820db7fc0b..72e99a0fce 100644 --- a/samples/taborder/taborder.cpp +++ b/samples/taborder/taborder.cpp @@ -39,6 +39,11 @@ #include "wx/notebook.h" +#ifndef __WXMSW__ + #include "../sample.xpm" +#endif + + // ---------------------------------------------------------------------------- // constants // ---------------------------------------------------------------------------- @@ -189,6 +194,8 @@ MyFrame::MyFrame() : wxFrame(NULL, wxID_ANY, _T("TabOrder wxWidgets Sample"), wxDefaultPosition, wxSize(700, 450)) { + SetIcon(wxICON(sample)); + wxMenu *menuFile = new wxMenu; menuFile->Append(TabOrder_About); menuFile->AppendSeparator(); diff --git a/samples/text/text.cpp b/samples/text/text.cpp index f8ed400e59..0e4629e22a 100644 --- a/samples/text/text.cpp +++ b/samples/text/text.cpp @@ -45,6 +45,10 @@ #include "wx/numdlg.h" #include "wx/tokenzr.h" +#ifndef __WXMSW__ + #include "../sample.xpm" +#endif + //---------------------------------------------------------------------- // class definitions //---------------------------------------------------------------------- @@ -1369,6 +1373,8 @@ END_EVENT_TABLE() MyFrame::MyFrame(wxFrame *frame, const wxChar *title, int x, int y, int w, int h) : wxFrame(frame, wxID_ANY, title, wxPoint(x, y), wxSize(w, h) ) { + SetIcon(wxICON(sample)); + #if wxUSE_STATUSBAR CreateStatusBar(2); #endif // wxUSE_STATUSBAR diff --git a/samples/wrapsizer/wrapsizer.cpp b/samples/wrapsizer/wrapsizer.cpp index 19a66de76e..b65694e3b9 100644 --- a/samples/wrapsizer/wrapsizer.cpp +++ b/samples/wrapsizer/wrapsizer.cpp @@ -3,7 +3,7 @@ // Purpose: wxWidgets sample demonstrating wxWrapSizer use // Author: Arne Steinarson // Created: 21.01.2008 -// RCS-ID: $Id:$ +// RCS-ID: $Id$ // Copyright: (c) Arne Steinarson // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -21,70 +21,19 @@ #include "wx/wrapsizer.h" #include "wx/artprov.h" +#ifndef __WXMSW__ + #include "../sample.xpm" +#endif + + +// ---------------------------------------------------------------------------- +// definitions +// ---------------------------------------------------------------------------- + class WrapSizerFrame : public wxFrame { public: - WrapSizerFrame() - : wxFrame(NULL, wxID_ANY, "wxWrapSizer Sample") - { - // Root sizer, vertical - wxSizer * const sizerRoot = new wxBoxSizer(wxVERTICAL); - - // Some toolbars in a wrap sizer - wxSizer * const sizerTop = new wxWrapSizer( wxHORIZONTAL ); - sizerTop->Add(MakeToolBar()); - sizerTop->Add(20, 1); - sizerTop->Add(MakeToolBar()); - sizerTop->Add(20, 1); - sizerTop->Add(MakeToolBar()); - sizerRoot->Add(sizerTop, wxSizerFlags().Expand().Border()); - - // A number of checkboxes inside a wrap sizer - wxSizer *sizerMid = new wxStaticBoxSizer(wxVERTICAL, this, - "With check-boxes"); - wxSizer * const sizerMidWrap = new wxWrapSizer(wxHORIZONTAL); - for ( int nCheck = 0; nCheck < 6; nCheck++ ) - { - wxCheckBox *chk = new wxCheckBox - ( - this, - wxID_ANY, - wxString::Format("Option %d", nCheck) - ); - - sizerMidWrap->Add(chk, wxSizerFlags().Centre().Border()); - } - - sizerMid->Add(sizerMidWrap, wxSizerFlags(100).Expand()); - sizerRoot->Add(sizerMid, wxSizerFlags(100).Expand().Border()); - - - // A shaped item inside a box sizer - wxSizer *sizerBottom = new wxStaticBoxSizer(wxVERTICAL, this, - "With wxSHAPED item"); - wxSizer *sizerBottomBox = new wxBoxSizer(wxHORIZONTAL); - sizerBottom->Add(sizerBottomBox, wxSizerFlags(100).Expand()); - - sizerBottomBox->Add(new wxListBox(this, wxID_ANY, - wxPoint(0, 0), wxSize(70, 70)), - wxSizerFlags().Expand().Shaped()); - sizerBottomBox->AddSpacer(10); - sizerBottomBox->Add(new wxCheckBox(this, wxID_ANY, - "A much longer option..."), - wxSizerFlags(100).Border()); - sizerRoot->Add(sizerBottom, wxSizerFlags(100).Expand().Border()); - - // OK Button - sizerRoot->Add(new wxButton(this, wxID_OK), - wxSizerFlags().Centre().DoubleBorder()); - Connect(wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, - wxCommandEventHandler(WrapSizerFrame::OnButton)); - - // Set sizer for window - SetSizerAndFit(sizerRoot); - - Show(); - } + WrapSizerFrame(); private: void OnButton(wxCommandEvent& WXUNUSED(event)) @@ -116,10 +65,8 @@ private: tb->Realize( ); return tb; } - }; - class WrapSizerApp : public wxApp { public: @@ -133,3 +80,73 @@ public: }; IMPLEMENT_APP(WrapSizerApp); + + +// ---------------------------------------------------------------------------- +// WrapSizerFrame +// ---------------------------------------------------------------------------- + +WrapSizerFrame::WrapSizerFrame() + : wxFrame(NULL, wxID_ANY, "wxWrapSizer Sample") +{ + SetIcon(wxICON(sample)); + + // Root sizer, vertical + wxSizer * const sizerRoot = new wxBoxSizer(wxVERTICAL); + + // Some toolbars in a wrap sizer + wxSizer * const sizerTop = new wxWrapSizer( wxHORIZONTAL ); + sizerTop->Add(MakeToolBar()); + sizerTop->Add(20, 1); + sizerTop->Add(MakeToolBar()); + sizerTop->Add(20, 1); + sizerTop->Add(MakeToolBar()); + sizerRoot->Add(sizerTop, wxSizerFlags().Expand().Border()); + + // A number of checkboxes inside a wrap sizer + wxSizer *sizerMid = new wxStaticBoxSizer(wxVERTICAL, this, + "With check-boxes"); + wxSizer * const sizerMidWrap = new wxWrapSizer(wxHORIZONTAL); + for ( int nCheck = 0; nCheck < 6; nCheck++ ) + { + wxCheckBox *chk = new wxCheckBox + ( + this, + wxID_ANY, + wxString::Format("Option %d", nCheck) + ); + + sizerMidWrap->Add(chk, wxSizerFlags().Centre().Border()); + } + + sizerMid->Add(sizerMidWrap, wxSizerFlags(100).Expand()); + sizerRoot->Add(sizerMid, wxSizerFlags(100).Expand().Border()); + + + // A shaped item inside a box sizer + wxSizer *sizerBottom = new wxStaticBoxSizer(wxVERTICAL, this, + "With wxSHAPED item"); + wxSizer *sizerBottomBox = new wxBoxSizer(wxHORIZONTAL); + sizerBottom->Add(sizerBottomBox, wxSizerFlags(100).Expand()); + + sizerBottomBox->Add(new wxListBox(this, wxID_ANY, + wxPoint(0, 0), wxSize(70, 70)), + wxSizerFlags().Expand().Shaped()); + sizerBottomBox->AddSpacer(10); + sizerBottomBox->Add(new wxCheckBox(this, wxID_ANY, + "A much longer option..."), + wxSizerFlags(100).Border()); + sizerRoot->Add(sizerBottom, wxSizerFlags(100).Expand().Border()); + + // OK Button + sizerRoot->Add(new wxButton(this, wxID_OK), + wxSizerFlags().Centre().DoubleBorder()); + Connect(wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, + wxCommandEventHandler(WrapSizerFrame::OnButton)); + + // Set sizer for window + SetSizerAndFit(sizerRoot); + + Show(); +} + -- 2.45.2