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
This commit is contained in:
Francesco Montorsi
2009-02-08 01:01:00 +00:00
parent 27721528c4
commit 41f02b9acc
21 changed files with 435 additions and 304 deletions

View File

@@ -44,6 +44,10 @@
#include "wx/fontpicker.h" #include "wx/fontpicker.h"
#include "wx/aboutdlg.h" #include "wx/aboutdlg.h"
#ifndef __WXMSW__
#include "../sample.xpm"
#endif
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// constants // constants
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -57,7 +61,7 @@ enum
PANE_SHOWDLG, PANE_SHOWDLG,
PANE_ABOUT = wxID_ABOUT, PANE_ABOUT = wxID_ABOUT,
PANE_QUIT = wxID_EXIT, PANE_QUIT = wxID_EXIT,
PANE_BUTTON, PANE_BUTTON,
PANE_TEXTCTRL PANE_TEXTCTRL
}; };
@@ -166,6 +170,8 @@ MyFrame::MyFrame()
wxDefaultPosition, wxSize(420, 300), wxDefaultPosition, wxSize(420, 300),
wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE) wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE)
{ {
SetIcon(wxICON(sample));
#if wxUSE_STATUSBAR #if wxUSE_STATUSBAR
CreateStatusBar(2); CreateStatusBar(2);
#endif // wxUSE_STATUSBAR #endif // wxUSE_STATUSBAR
@@ -191,7 +197,7 @@ MyFrame::MyFrame()
m_collPane = new wxCollapsiblePane(this, -1, wxT("test!")); m_collPane = new wxCollapsiblePane(this, -1, wxT("test!"));
wxWindow *win = m_collPane->GetPane(); wxWindow *win = m_collPane->GetPane();
m_paneSizer = new wxBoxSizer( wxVERTICAL ); 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("Static text") ), 0, wxALIGN_LEFT );
m_paneSizer->Add( new wxStaticText(win, -1, wxT("Yet another one!") ), 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 ); wxSizerItem *item = m_paneSizer->GetItem( FindWindow(PANE_TEXTCTRL), true );
item->SetFlag( wxALIGN_RIGHT ); item->SetFlag( wxALIGN_RIGHT );
Layout(); Layout();
} }

View File

@@ -25,6 +25,10 @@
#include "wx/log.h" #include "wx/log.h"
#include "wx/config.h" #include "wx/config.h"
#ifndef __WXMSW__
#include "../sample.xpm"
#endif
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// classes // classes
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -40,19 +44,19 @@ public:
class MyFrame: public wxFrame class MyFrame: public wxFrame
{ {
public: public:
MyFrame(); MyFrame();
virtual ~MyFrame(); virtual ~MyFrame();
// callbacks // callbacks
void OnQuit(wxCommandEvent& event); void OnQuit(wxCommandEvent& event);
void OnAbout(wxCommandEvent& event); void OnAbout(wxCommandEvent& event);
void OnDelete(wxCommandEvent& event); void OnDelete(wxCommandEvent& event);
private: private:
wxTextCtrl *m_text; wxTextCtrl *m_text;
wxCheckBox *m_check; wxCheckBox *m_check;
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
enum enum
@@ -85,61 +89,61 @@ IMPLEMENT_APP(MyApp)
// `Main program' equivalent, creating windows and returning main app frame // `Main program' equivalent, creating windows and returning main app frame
bool MyApp::OnInit() bool MyApp::OnInit()
{ {
if ( !wxApp::OnInit() ) if ( !wxApp::OnInit() )
return false; return false;
// we're using wxConfig's "create-on-demand" feature: it will create the // 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 // config object when it's used for the first time. It has a number of
// advantages compared with explicitly creating our wxConfig: // advantages compared with explicitly creating our wxConfig:
// 1) we don't pay for it if we don't use it // 1) we don't pay for it if we don't use it
// 2) there is no danger to create it twice // 2) there is no danger to create it twice
// application and vendor name are used by wxConfig to construct the name // 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 // 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 // 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) // name is the name of the executable and the vendor name is the same)
SetVendorName(_T("wxWidgets")); SetVendorName(_T("wxWidgets"));
SetAppName(_T("conftest")); // not needed, it's the default value SetAppName(_T("conftest")); // not needed, it's the default value
wxConfigBase *pConfig = wxConfigBase::Get(); wxConfigBase *pConfig = wxConfigBase::Get();
// uncomment this to force writing back of the defaults for all values // 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 // if they're not present in the config - this can give the user an idea
// of all possible settings for this program // of all possible settings for this program
pConfig->SetRecordDefaults(); pConfig->SetRecordDefaults();
// or you could also write something like this: // or you could also write something like this:
// wxFileConfig *pConfig = new wxFileConfig("conftest"); // wxFileConfig *pConfig = new wxFileConfig("conftest");
// wxConfigBase::Set(pConfig); // wxConfigBase::Set(pConfig);
// where you can also specify the file names explicitly if you wish. // 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 // Of course, calling Set() is optional and you only must do it if
// you want to later retrieve this pointer with Get(). // you want to later retrieve this pointer with Get().
// create the main program window // create the main program window
MyFrame *frame = new MyFrame; MyFrame *frame = new MyFrame;
frame->Show(true); frame->Show(true);
SetTopWindow(frame); SetTopWindow(frame);
// use our config object... // use our config object...
if ( pConfig->Read(_T("/Controls/Check"), 1l) != 0 ) { if ( pConfig->Read(_T("/Controls/Check"), 1l) != 0 ) {
wxMessageBox(_T("You can disable this message box by unchecking\n") wxMessageBox(_T("You can disable this message box by unchecking\n")
_T("the checkbox in the main window (of course, a real\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("program would have a checkbox right here but we\n")
_T("keep it simple)"), _T("Welcome to wxConfig demo"), _T("keep it simple)"), _T("Welcome to wxConfig demo"),
wxICON_INFORMATION | wxOK); wxICON_INFORMATION | wxOK);
} }
return true; return true;
} }
int MyApp::OnExit() int MyApp::OnExit()
{ {
// clean up: Set() returns the active config object as Get() does, but unlike // 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 // Get() it doesn't try to create one if there is none (definitely not what
// we want here!) // we want here!)
delete wxConfigBase::Set((wxConfigBase *) NULL); delete wxConfigBase::Set((wxConfigBase *) NULL);
return 0; return 0;
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -150,77 +154,79 @@ int MyApp::OnExit()
MyFrame::MyFrame() MyFrame::MyFrame()
: wxFrame((wxFrame *) NULL, wxID_ANY, _T("wxConfig Demo")) : wxFrame((wxFrame *) NULL, wxID_ANY, _T("wxConfig Demo"))
{ {
// menu SetIcon(wxICON(sample));
wxMenu *file_menu = new wxMenu;
file_menu->Append(ConfTest_Delete, _T("&Delete"), _T("Delete config file")); // menu
file_menu->AppendSeparator(); wxMenu *file_menu = new wxMenu;
file_menu->Append(ConfTest_About, _T("&About\tF1"), _T("About this sample"));
file_menu->AppendSeparator(); file_menu->Append(ConfTest_Delete, _T("&Delete"), _T("Delete config file"));
file_menu->Append(ConfTest_Quit, _T("E&xit\tAlt-X"), _T("Exit the program")); file_menu->AppendSeparator();
wxMenuBar *menu_bar = new wxMenuBar; file_menu->Append(ConfTest_About, _T("&About\tF1"), _T("About this sample"));
menu_bar->Append(file_menu, _T("&File")); file_menu->AppendSeparator();
SetMenuBar(menu_bar); 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 #if wxUSE_STATUSBAR
CreateStatusBar(); CreateStatusBar();
#endif // wxUSE_STATUSBAR #endif // wxUSE_STATUSBAR
// child controls // child controls
wxPanel *panel = new wxPanel(this); wxPanel *panel = new wxPanel(this);
(void)new wxStaticText(panel, wxID_ANY, _T("These controls remember their values!"), (void)new wxStaticText(panel, wxID_ANY, _T("These controls remember their values!"),
wxPoint(10, 10), wxSize(300, 20)); wxPoint(10, 10), wxSize(300, 20));
m_text = new wxTextCtrl(panel, wxID_ANY, _T(""), wxPoint(10, 40), 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"), m_check = new wxCheckBox(panel, wxID_ANY, _T("show welcome message box at startup"),
wxPoint(10, 70), wxSize(300, 20)); wxPoint(10, 70), wxSize(300, 20));
// restore the control's values from the config // restore the control's values from the config
// NB: in this program, the config object is already created at this moment // 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 // 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 // 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() // 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!). // or in any other way (then you must be sure to create it before using it!).
wxConfigBase *pConfig = wxConfigBase::Get(); wxConfigBase *pConfig = wxConfigBase::Get();
// we could write Read("/Controls/Text") as well, it's just to show SetPath() // we could write Read("/Controls/Text") as well, it's just to show SetPath()
pConfig->SetPath(_T("/Controls")); pConfig->SetPath(_T("/Controls"));
m_text->SetValue(pConfig->Read(_T("Text"), _T(""))); m_text->SetValue(pConfig->Read(_T("Text"), _T("")));
m_check->SetValue(pConfig->Read(_T("Check"), 1l) != 0); m_check->SetValue(pConfig->Read(_T("Check"), 1l) != 0);
// SetPath() understands ".." // SetPath() understands ".."
pConfig->SetPath(_T("../MainFrame")); pConfig->SetPath(_T("../MainFrame"));
// restore frame position and size // restore frame position and size
int x = pConfig->Read(_T("x"), 50), int x = pConfig->Read(_T("x"), 50),
y = pConfig->Read(_T("y"), 50), y = pConfig->Read(_T("y"), 50),
w = pConfig->Read(_T("w"), 350), w = pConfig->Read(_T("w"), 350),
h = pConfig->Read(_T("h"), 200); h = pConfig->Read(_T("h"), 200);
Move(x, y); Move(x, y);
SetClientSize(w, h); SetClientSize(w, h);
pConfig->SetPath(_T("/")); pConfig->SetPath(_T("/"));
wxString s; wxString s;
if ( pConfig->Read(_T("TestValue"), &s) ) if ( pConfig->Read(_T("TestValue"), &s) )
{ {
wxLogStatus(this, wxT("TestValue from config is '%s'"), s.c_str()); wxLogStatus(this, wxT("TestValue from config is '%s'"), s.c_str());
} }
else else
{ {
wxLogStatus(this, wxT("TestValue not found in the config")); wxLogStatus(this, wxT("TestValue not found in the config"));
} }
} }
void MyFrame::OnQuit(wxCommandEvent&) void MyFrame::OnQuit(wxCommandEvent&)
{ {
Close(true); Close(true);
} }
void MyFrame::OnAbout(wxCommandEvent&) void MyFrame::OnAbout(wxCommandEvent&)
{ {
wxMessageBox(_T("wxConfig demo\n(c) 1998-2001 Vadim Zeitlin"), _T("About"), wxMessageBox(_T("wxConfig demo\n(c) 1998-2001 Vadim Zeitlin"), _T("About"),
wxICON_INFORMATION | wxOK); wxICON_INFORMATION | wxOK);
} }
void MyFrame::OnDelete(wxCommandEvent&) void MyFrame::OnDelete(wxCommandEvent&)
@@ -247,23 +253,23 @@ void MyFrame::OnDelete(wxCommandEvent&)
MyFrame::~MyFrame() MyFrame::~MyFrame()
{ {
wxConfigBase *pConfig = wxConfigBase::Get(); wxConfigBase *pConfig = wxConfigBase::Get();
if ( pConfig == NULL ) if ( pConfig == NULL )
return; return;
// save the control's values to the config // save the control's values to the config
pConfig->Write(_T("/Controls/Text"), m_text->GetValue()); pConfig->Write(_T("/Controls/Text"), m_text->GetValue());
pConfig->Write(_T("/Controls/Check"), m_check->GetValue()); pConfig->Write(_T("/Controls/Check"), m_check->GetValue());
// save the frame position // save the frame position
int x, y, w, h; int x, y, w, h;
GetClientSize(&w, &h); GetClientSize(&w, &h);
GetPosition(&x, &y); GetPosition(&x, &y);
pConfig->Write(_T("/MainFrame/x"), (long) x); pConfig->Write(_T("/MainFrame/x"), (long) x);
pConfig->Write(_T("/MainFrame/y"), (long) y); pConfig->Write(_T("/MainFrame/y"), (long) y);
pConfig->Write(_T("/MainFrame/w"), (long) w); pConfig->Write(_T("/MainFrame/w"), (long) w);
pConfig->Write(_T("/MainFrame/h"), (long) h); pConfig->Write(_T("/MainFrame/h"), (long) h);
pConfig->Write(_T("/TestValue"), wxT("A test value")); pConfig->Write(_T("/TestValue"), wxT("A test value"));
} }

View File

@@ -36,6 +36,10 @@
#include "wx/dialup.h" #include "wx/dialup.h"
#ifndef __WXMSW__
#include "../sample.xpm"
#endif
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// private classes // private classes
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -220,6 +224,8 @@ void MyApp::OnConnected(wxDialUpEvent& event)
MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size) MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
: wxFrame((wxFrame *)NULL, wxID_ANY, title, pos, size) : wxFrame((wxFrame *)NULL, wxID_ANY, title, pos, size)
{ {
SetIcon(wxICON(sample));
// create a menu bar // create a menu bar
wxMenu *menuFile = new wxMenu; wxMenu *menuFile = new wxMenu;

View File

@@ -30,6 +30,10 @@
#include "wx/wx.h" #include "wx/wx.h"
#endif #endif
#ifndef __WXMSW__
#include "../sample.xpm"
#endif
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// event constants // event constants
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -214,6 +218,8 @@ bool MyApp::OnInit()
MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size) MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
: wxFrame((wxFrame *)NULL, wxID_ANY, title, pos, size) : wxFrame((wxFrame *)NULL, wxID_ANY, title, pos, size)
{ {
SetIcon(wxICON(sample));
// init members // init members
m_nPush = 0; m_nPush = 0;

View File

@@ -39,6 +39,10 @@
#include "griddemo.h" #include "griddemo.h"
#ifndef __WXMSW__
#include "../sample.xpm"
#endif
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxWin macros // wxWin macros
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -148,6 +152,8 @@ GridFrame::GridFrame()
wxDefaultPosition, wxDefaultPosition,
wxDefaultSize ) wxDefaultSize )
{ {
SetIcon(wxICON(sample));
wxMenu *fileMenu = new wxMenu; wxMenu *fileMenu = new wxMenu;
fileMenu->Append( ID_VTABLE, _T("&Virtual table test\tCtrl-V")); fileMenu->Append( ID_VTABLE, _T("&Virtual table test\tCtrl-V"));
fileMenu->Append( ID_BUGS_TABLE, _T("&Bugs table test\tCtrl-B")); fileMenu->Append( ID_BUGS_TABLE, _T("&Bugs table test\tCtrl-B"));

View File

@@ -46,6 +46,9 @@
#include "canvas.h" #include "canvas.h"
#ifndef __WXMSW__
#include "../sample.xpm"
#endif
// ============================================================================ // ============================================================================
// declarations // declarations
@@ -575,6 +578,8 @@ MyFrame::MyFrame()
: wxFrame( (wxFrame *)NULL, wxID_ANY, _T("wxImage sample"), : wxFrame( (wxFrame *)NULL, wxID_ANY, _T("wxImage sample"),
wxPoint(20, 20), wxSize(950, 700) ) wxPoint(20, 20), wxSize(950, 700) )
{ {
SetIcon(wxICON(sample));
wxMenuBar *menu_bar = new wxMenuBar(); wxMenuBar *menu_bar = new wxMenuBar();
wxMenu *menuImage = new wxMenu; wxMenu *menuImage = new wxMenu;

View File

@@ -18,6 +18,9 @@
#include "wx/wx.h" #include "wx/wx.h"
#endif #endif
#ifndef __WXMSW__
#include "../sample.xpm"
#endif
// Define a new frame type: this is going to be our main frame // Define a new frame type: this is going to be our main frame
class MyFrame : public wxFrame class MyFrame : public wxFrame
@@ -77,6 +80,8 @@ MyFrame::MyFrame(const wxString& title)
m_inputWin(NULL), m_inputWin(NULL),
m_skip(true) m_skip(true)
{ {
SetIcon(wxICON(sample));
// IDs for menu items // IDs for menu items
enum enum
{ {
@@ -121,12 +126,12 @@ MyFrame::MyFrame(const wxString& title)
" RawKeyCode RawKeyFlags"); " RawKeyCode RawKeyFlags");
m_logText = new wxTextCtrl(this, wxID_ANY, "", m_logText = new wxTextCtrl(this, wxID_ANY, "",
wxDefaultPosition, wxDefaultSize, wxDefaultPosition, wxDefaultSize,
wxTE_MULTILINE|wxTE_READONLY|wxHSCROLL); wxTE_MULTILINE|wxTE_READONLY|wxHSCROLL);
// set monospace font to have output in nice columns // set monospace font to have output in nice columns
wxFont font(10, wxFONTFAMILY_TELETYPE, wxFont font(10, wxFONTFAMILY_TELETYPE,
wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
headerText->SetFont(font); headerText->SetFont(font);
m_logText->SetFont(font); m_logText->SetFont(font);
@@ -156,14 +161,14 @@ MyFrame::MyFrame(const wxString& title)
Connect(SkipID, wxEVT_COMMAND_MENU_SELECTED, Connect(SkipID, wxEVT_COMMAND_MENU_SELECTED,
wxCommandEventHandler(MyFrame::OnSkip)); 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), m_inputWin->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(MyFrame::OnKeyDown),
NULL, this); NULL, this);
m_inputWin->Connect(wxEVT_KEY_UP, wxKeyEventHandler(MyFrame::OnKeyUp), m_inputWin->Connect(wxEVT_KEY_UP, wxKeyEventHandler(MyFrame::OnKeyUp),
NULL, this); NULL, this);
m_inputWin->Connect(wxEVT_CHAR, wxKeyEventHandler(MyFrame::OnChar), m_inputWin->Connect(wxEVT_CHAR, wxKeyEventHandler(MyFrame::OnChar),
NULL, this); NULL, this);
m_inputWin->Connect(wxEVT_PAINT, m_inputWin->Connect(wxEVT_PAINT,
wxPaintEventHandler(MyFrame::OnPaintInputWin), wxPaintEventHandler(MyFrame::OnPaintInputWin),
NULL, this); NULL, this);
@@ -192,7 +197,7 @@ void MyFrame::OnPaintInputWin(wxPaintEvent& WXUNUSED(event))
font.SetPointSize(font.GetPointSize() + 2); font.SetPointSize(font.GetPointSize() + 2);
dc.SetFont(font); dc.SetFont(font);
dc.DrawLabel("Press keys here", dc.DrawLabel("Press keys here",
m_inputWin->GetClientRect(), wxALIGN_CENTER); m_inputWin->GetClientRect(), wxALIGN_CENTER);
} }
@@ -203,7 +208,7 @@ const char* GetVirtualKeyCodeName(int keycode)
switch ( keycode ) switch ( keycode )
{ {
#define WXK_(x) \ #define WXK_(x) \
case WXK_##x: return #x; case WXK_##x: return #x;
WXK_(BACK) WXK_(BACK)
WXK_(TAB) WXK_(TAB)
@@ -305,8 +310,8 @@ const char* GetVirtualKeyCodeName(int keycode)
WXK_(NUMPAD_DECIMAL) WXK_(NUMPAD_DECIMAL)
WXK_(NUMPAD_DIVIDE) WXK_(NUMPAD_DIVIDE)
#undef WXK_ #undef WXK_
default: default:
return NULL; return NULL;
} }
} }
@@ -332,7 +337,7 @@ wxString GetKeyName(const wxKeyEvent &event)
void MyFrame::LogEvent(const wxString& name, wxKeyEvent& event) void MyFrame::LogEvent(const wxString& name, wxKeyEvent& event)
{ {
wxString msg; 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" msg.Printf("%7s %15s %5d %c%c%c%c"
#if wxUSE_UNICODE #if wxUSE_UNICODE
"%5d (U+%04x)" "%5d (U+%04x)"

View File

@@ -34,6 +34,11 @@
#include "layout.h" #include "layout.h"
#ifndef __WXMSW__
#include "../sample.xpm"
#endif
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// MyApp // MyApp
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -76,113 +81,115 @@ MyFrame::MyFrame()
wxPoint(30,30), wxDefaultSize, wxPoint(30,30), wxDefaultSize,
wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE) wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE)
{ {
// Make a menubar SetIcon(wxICON(sample));
wxMenu *file_menu = new wxMenu;
file_menu->Append(LAYOUT_TEST_PROPORTIONS, _T("&Proportions demo...\tF1")); // Make a menubar
file_menu->Append(LAYOUT_TEST_SIZER, _T("Test wx&FlexSizer...\tF2")); wxMenu *file_menu = new wxMenu;
file_menu->Append(LAYOUT_TEST_NB_SIZER, _T("Test &notebook 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"));
file_menu->AppendSeparator(); file_menu->Append(LAYOUT_TEST_PROPORTIONS, _T("&Proportions demo...\tF1"));
file_menu->Append(LAYOUT_QUIT, _T("E&xit"), _T("Quit program")); file_menu->Append(LAYOUT_TEST_SIZER, _T("Test wx&FlexSizer...\tF2"));
file_menu->Append(LAYOUT_TEST_NB_SIZER, _T("Test &notebook 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; file_menu->AppendSeparator();
help_menu->Append(LAYOUT_ABOUT, _T("&About"), _T("About layout demo...")); 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")); wxMenuBar *menu_bar = new wxMenuBar;
menu_bar->Append(help_menu, _T("&Help"));
// Associate the menu bar with the frame menu_bar->Append(file_menu, _T("&File"));
SetMenuBar(menu_bar); menu_bar->Append(help_menu, _T("&Help"));
// Associate the menu bar with the frame
SetMenuBar(menu_bar);
#if wxUSE_STATUSBAR #if wxUSE_STATUSBAR
CreateStatusBar(2); CreateStatusBar(2);
SetStatusText(_T("wxWidgets layout demo")); SetStatusText(_T("wxWidgets layout demo"));
#endif // wxUSE_STATUSBAR #endif // wxUSE_STATUSBAR
wxPanel* p = new wxPanel(this, wxID_ANY); wxPanel* p = new wxPanel(this, wxID_ANY);
// we want to get a dialog that is stretchable because it // we want to get a dialog that is stretchable because it
// has a text ctrl in the middle. at the bottom, we have // has a text ctrl in the middle. at the bottom, we have
// two buttons which. // two buttons which.
wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL ); wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL );
// 1) top: create wxStaticText with minimum size equal to its default size // 1) top: create wxStaticText with minimum size equal to its default size
topsizer->Add( topsizer->Add(
new wxStaticText( p, wxID_ANY, _T("An explanation (wxALIGN_RIGHT).") ), new wxStaticText( p, wxID_ANY, _T("An explanation (wxALIGN_RIGHT).") ),
wxSizerFlags().Align(wxALIGN_RIGHT).Border(wxALL & ~wxBOTTOM, 5)); wxSizerFlags().Align(wxALIGN_RIGHT).Border(wxALL & ~wxBOTTOM, 5));
topsizer->Add( topsizer->Add(
new wxStaticText( p, wxID_ANY, _T("An explanation (wxALIGN_LEFT).") ), new wxStaticText( p, wxID_ANY, _T("An explanation (wxALIGN_LEFT).") ),
wxSizerFlags().Align(wxALIGN_LEFT).Border(wxALL & ~wxBOTTOM, 5)); wxSizerFlags().Align(wxALIGN_LEFT).Border(wxALL & ~wxBOTTOM, 5));
topsizer->Add( topsizer->Add(
new wxStaticText( p, wxID_ANY, _T("An explanation (wxALIGN_CENTRE_HORIZONTAL).") ), new wxStaticText( p, wxID_ANY, _T("An explanation (wxALIGN_CENTRE_HORIZONTAL).") ),
wxSizerFlags().Align(wxALIGN_CENTRE_HORIZONTAL).Border(wxALL & ~wxBOTTOM, 5)); wxSizerFlags().Align(wxALIGN_CENTRE_HORIZONTAL).Border(wxALL & ~wxBOTTOM, 5));
// 2) top: create wxTextCtrl with minimum size (100x60) // 2) top: create wxTextCtrl with minimum size (100x60)
topsizer->Add( topsizer->Add(
new wxTextCtrl( p, wxID_ANY, _T("My text (wxEXPAND)."), wxDefaultPosition, wxSize(100,60), wxTE_MULTILINE), new wxTextCtrl( p, wxID_ANY, _T("My text (wxEXPAND)."), wxDefaultPosition, wxSize(100,60), wxTE_MULTILINE),
wxSizerFlags(1).Expand().Border(wxALL, 5)); wxSizerFlags(1).Expand().Border(wxALL, 5));
// 2.5) Gratuitous test of wxStaticBoxSizers // 2.5) Gratuitous test of wxStaticBoxSizers
wxBoxSizer *statsizer = new wxStaticBoxSizer( wxBoxSizer *statsizer = new wxStaticBoxSizer(
new wxStaticBox(p, wxID_ANY, _T("A wxStaticBoxSizer")), wxVERTICAL ); new wxStaticBox(p, wxID_ANY, _T("A wxStaticBoxSizer")), wxVERTICAL );
statsizer->Add( statsizer->Add(
new wxStaticText(p, wxID_ANY, _T("And some TEXT inside it")), new wxStaticText(p, wxID_ANY, _T("And some TEXT inside it")),
wxSizerFlags().Border(wxALL, 30)); wxSizerFlags().Border(wxALL, 30));
topsizer->Add( topsizer->Add(
statsizer, statsizer,
wxSizerFlags(1).Expand().Border(wxALL, 10)); wxSizerFlags(1).Expand().Border(wxALL, 10));
// 2.7) And a test of wxGridSizer // 2.7) And a test of wxGridSizer
wxGridSizer *gridsizer = new wxGridSizer(2, 5, 5); wxGridSizer *gridsizer = new wxGridSizer(2, 5, 5);
gridsizer->Add(new wxStaticText(p, wxID_ANY, _T("Label")), 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")), 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")), 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")), 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")), 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")), 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( topsizer->Add(
gridsizer, gridsizer,
wxSizerFlags().Proportion(1).Expand().Border(wxALL, 10)); wxSizerFlags().Proportion(1).Expand().Border(wxALL, 10));
#if wxUSE_STATLINE #if wxUSE_STATLINE
// 3) middle: create wxStaticLine with minimum size (3x3) // 3) middle: create wxStaticLine with minimum size (3x3)
topsizer->Add( topsizer->Add(
new wxStaticLine( p, wxID_ANY, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), new wxStaticLine( p, wxID_ANY, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL),
wxSizerFlags().Expand()); wxSizerFlags().Expand());
#endif // wxUSE_STATLINE #endif // wxUSE_STATLINE
// 4) bottom: create two centred wxButtons // 4) bottom: create two centred wxButtons
wxBoxSizer *button_box = new wxBoxSizer( wxHORIZONTAL ); wxBoxSizer *button_box = new wxBoxSizer( wxHORIZONTAL );
button_box->Add( button_box->Add(
new wxButton( p, wxID_ANY, _T("Two buttons in a box") ), new wxButton( p, wxID_ANY, _T("Two buttons in a box") ),
wxSizerFlags().Border(wxALL, 7)); wxSizerFlags().Border(wxALL, 7));
button_box->Add( button_box->Add(
new wxButton( p, wxID_ANY, _T("(wxCENTER)") ), new wxButton( p, wxID_ANY, _T("(wxCENTER)") ),
wxSizerFlags().Border(wxALL, 7)); 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 // don't allow frame to get smaller than what the sizers tell it and also set
// the initial size as calculated by the sizers // the initial size as calculated by the sizers
topsizer->SetSizeHints( this ); topsizer->SetSizeHints( this );
} }
void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) 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 );
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 ); wxTAB_TRAVERSAL | wxSUNKEN_BORDER );
main_sizer->Add( panel, 0, wxALIGN_CENTER ); main_sizer->Add( panel, 0, wxALIGN_CENTER );
wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL ); 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") ) ); 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 ); 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 ) ); 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++) for (i = 0; i < 4; i++)
row->Add( new wxButton( this, -1, "Hello" ), 0, wxALL, 10 ); row->Add( new wxButton( this, -1, "Hello" ), 0, wxALL, 10 );
root->Add( row, 0, wxGROW ); root->Add( row, 0, wxGROW );
row = new wxWrapSizer; row = new wxWrapSizer;
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
row->Add( new wxButton( this, -1, "Hello" ) ); row->Add( new wxButton( this, -1, "Hello" ) );
root->Add( row, 0, wxGROW ); root->Add( row, 0, wxGROW );
#else #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 = new wxStaticBoxSizer( wxVERTICAL, this, "Wrapping check-boxes" );
wxSizer *ps_mid_wrap = new wxWrapSizer(wxHORIZONTAL); wxSizer *ps_mid_wrap = new wxWrapSizer(wxHORIZONTAL);
ps_mid->Add( ps_mid_wrap, 100, wxEXPAND ); 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( new wxListBox(this,wxID_ANY,wxPoint(0,0),wxSize(70,70)), 0, wxEXPAND|wxSHAPED );
ps_bottom_box->Add( 10,10 ); ps_bottom_box->Add( 10,10 );
ps_bottom_box->Add( new wxCheckBox(this,wxID_ANY,"A much longer option..."), 100, 0, 5 ); ps_bottom_box->Add( new wxCheckBox(this,wxID_ANY,"A much longer option..."), 100, 0, 5 );
root->Add( ps_bottom, 1, wxEXPAND | wxALL, 5 ); root->Add( ps_bottom, 1, wxEXPAND | wxALL, 5 );
#endif #endif
// Set sizer for window // Set sizer for window
SetSizerAndFit( root ); SetSizerAndFit( root );
} }

View File

@@ -67,6 +67,10 @@
#include "wx/filename.h" //For wxFileName::GetName() #include "wx/filename.h" //For wxFileName::GetName()
#include "wx/config.h" //for native wxConfig #include "wx/config.h" //for native wxConfig
#ifndef __WXMSW__
#include "../sample.xpm"
#endif
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Bail out if the user doesn't want one of the // Bail out if the user doesn't want one of the
// things we need // things we need
@@ -481,6 +485,8 @@ void wxMediaPlayerApp::MacOpenFile(const wxString & fileName )
wxMediaPlayerFrame::wxMediaPlayerFrame(const wxString& title) wxMediaPlayerFrame::wxMediaPlayerFrame(const wxString& title)
: wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(600,600)) : wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(600,600))
{ {
SetIcon(wxICON(sample));
// //
// Create Menus // Create Menus
// //
@@ -685,7 +691,7 @@ wxMediaPlayerFrame::wxMediaPlayerFrame(const wxString& title)
// Create an initial notebook page so the user has something // Create an initial notebook page so the user has something
// to work with without having to go file->open every time :). // to work with without having to go file->open every time :).
// //
wxMediaPlayerNotebookPage* page = wxMediaPlayerNotebookPage* page =
new wxMediaPlayerNotebookPage(this, m_notebook); new wxMediaPlayerNotebookPage(this, m_notebook);
m_notebook->AddPage(page, m_notebook->AddPage(page,
wxT(""), wxT(""),
@@ -859,7 +865,7 @@ void wxMediaPlayerFrame::OnShowInterface(wxCommandEvent& event)
wxMenuItem* pSIItem = GetMenuBar()->FindItem(wxID_SHOWINTERFACE); wxMenuItem* pSIItem = GetMenuBar()->FindItem(wxID_SHOWINTERFACE);
wxASSERT(pSIItem); wxASSERT(pSIItem);
pSIItem->Check(!event.IsChecked()); pSIItem->Check(!event.IsChecked());
if(event.IsChecked()) if(event.IsChecked())
wxMessageBox(wxT("Could not show player controls")); wxMessageBox(wxT("Could not show player controls"));
else else
@@ -921,11 +927,11 @@ void wxMediaPlayerFrame::DoOpenFile(const wxString& path, bool bNewPage)
true); true);
} }
wxMediaPlayerNotebookPage* currentpage = wxMediaPlayerNotebookPage* currentpage =
(wxMediaPlayerNotebookPage*) m_notebook->GetCurrentPage(); (wxMediaPlayerNotebookPage*) m_notebook->GetCurrentPage();
if(currentpage->m_nLastFileId != -1) if(currentpage->m_nLastFileId != -1)
currentpage->m_playlist->SetItemState(currentpage->m_nLastFileId, currentpage->m_playlist->SetItemState(currentpage->m_nLastFileId,
0, wxLIST_STATE_SELECTED); 0, wxLIST_STATE_SELECTED);
wxListItem newlistitem; wxListItem newlistitem;
@@ -959,7 +965,7 @@ void wxMediaPlayerFrame::DoOpenFile(const wxString& path, bool bNewPage)
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void wxMediaPlayerFrame::DoPlayFile(const wxString& path) void wxMediaPlayerFrame::DoPlayFile(const wxString& path)
{ {
wxMediaPlayerNotebookPage* currentpage = wxMediaPlayerNotebookPage* currentpage =
(wxMediaPlayerNotebookPage*) m_notebook->GetCurrentPage(); (wxMediaPlayerNotebookPage*) m_notebook->GetCurrentPage();
wxListItem listitem; wxListItem listitem;
@@ -986,7 +992,7 @@ void wxMediaPlayerFrame::DoPlayFile(const wxString& path)
} }
else else
{ {
int nNewId = listitem.GetData() ? listitem.GetId() : int nNewId = listitem.GetData() ? listitem.GetId() :
currentpage->m_playlist->GetItemCount()-1; currentpage->m_playlist->GetItemCount()-1;
m_notebook->SetPageText(m_notebook->GetSelection(), m_notebook->SetPageText(m_notebook->GetSelection(),
wxFileName(path).GetName()); wxFileName(path).GetName());
@@ -1023,9 +1029,9 @@ void wxMediaPlayerFrame::DoPlayFile(const wxString& path)
currentpage->m_nLastFileId = nNewId; currentpage->m_nLastFileId = nNewId;
currentpage->m_szFile = path; currentpage->m_szFile = path;
currentpage->m_playlist->SetItem(currentpage->m_nLastFileId, currentpage->m_playlist->SetItem(currentpage->m_nLastFileId,
1, wxFileName(path).GetName()); 1, wxFileName(path).GetName());
currentpage->m_playlist->SetItem(currentpage->m_nLastFileId, currentpage->m_playlist->SetItem(currentpage->m_nLastFileId,
2, wxT("")); 2, wxT(""));
} }
} }
@@ -1038,7 +1044,7 @@ void wxMediaPlayerFrame::DoPlayFile(const wxString& path)
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void wxMediaPlayerFrame::OnMediaLoaded(wxMediaEvent& WXUNUSED(evt)) void wxMediaPlayerFrame::OnMediaLoaded(wxMediaEvent& WXUNUSED(evt))
{ {
wxMediaPlayerNotebookPage* currentpage = wxMediaPlayerNotebookPage* currentpage =
(wxMediaPlayerNotebookPage*) m_notebook->GetCurrentPage(); (wxMediaPlayerNotebookPage*) m_notebook->GetCurrentPage();
if( !currentpage->m_mediactrl->Play() ) if( !currentpage->m_mediactrl->Play() )
@@ -1079,7 +1085,7 @@ void wxMediaPlayerFrame::OnSelectBackend(wxCommandEvent& WXUNUSED(evt))
), wxT(""), true); ), wxT(""), true);
DoOpenFile( DoOpenFile(
((wxMediaPlayerNotebookPage*) m_notebook->GetCurrentPage())->m_szFile, ((wxMediaPlayerNotebookPage*) m_notebook->GetCurrentPage())->m_szFile,
false); false);
} }
} }
@@ -1158,7 +1164,7 @@ void wxMediaPlayerFrame::OnCloseCurrentPage(wxCommandEvent& WXUNUSED(event))
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void wxMediaPlayerFrame::OnPlay(wxCommandEvent& WXUNUSED(event)) void wxMediaPlayerFrame::OnPlay(wxCommandEvent& WXUNUSED(event))
{ {
wxMediaPlayerNotebookPage* currentpage = wxMediaPlayerNotebookPage* currentpage =
(wxMediaPlayerNotebookPage*) m_notebook->GetCurrentPage(); (wxMediaPlayerNotebookPage*) m_notebook->GetCurrentPage();
wxListItem listitem; wxListItem listitem;
@@ -1181,7 +1187,7 @@ void wxMediaPlayerFrame::OnPlay(wxCommandEvent& WXUNUSED(event))
listitem.SetState(listitem.GetState() | wxLIST_STATE_SELECTED); listitem.SetState(listitem.GetState() | wxLIST_STATE_SELECTED);
currentpage->m_playlist->SetItem(listitem); currentpage->m_playlist->SetItem(listitem);
wxASSERT(listitem.GetData()); wxASSERT(listitem.GetData());
DoPlayFile((*((wxString*) listitem.GetData()))); DoPlayFile((*((wxString*) listitem.GetData())));
} }
} }
else else
@@ -1200,7 +1206,7 @@ void wxMediaPlayerFrame::OnKeyDown(wxKeyEvent& event)
{ {
if(event.GetKeyCode() == WXK_BACK/*DELETE*/) if(event.GetKeyCode() == WXK_BACK/*DELETE*/)
{ {
wxMediaPlayerNotebookPage* currentpage = wxMediaPlayerNotebookPage* currentpage =
(wxMediaPlayerNotebookPage*) m_notebook->GetCurrentPage(); (wxMediaPlayerNotebookPage*) m_notebook->GetCurrentPage();
//delete all selected items //delete all selected items
while(true) while(true)
@@ -1235,7 +1241,7 @@ void wxMediaPlayerFrame::OnKeyDown(wxKeyEvent& event)
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void wxMediaPlayerFrame::OnStop(wxCommandEvent& WXUNUSED(evt)) void wxMediaPlayerFrame::OnStop(wxCommandEvent& WXUNUSED(evt))
{ {
wxMediaPlayerNotebookPage* currentpage = wxMediaPlayerNotebookPage* currentpage =
(wxMediaPlayerNotebookPage*) m_notebook->GetCurrentPage(); (wxMediaPlayerNotebookPage*) m_notebook->GetCurrentPage();
if( !currentpage->m_mediactrl->Stop() ) if( !currentpage->m_mediactrl->Stop() )
@@ -1255,7 +1261,7 @@ void wxMediaPlayerFrame::OnStop(wxCommandEvent& WXUNUSED(evt))
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void wxMediaPlayerFrame::OnChangeSong(wxListEvent& WXUNUSED(evt)) void wxMediaPlayerFrame::OnChangeSong(wxListEvent& WXUNUSED(evt))
{ {
wxMediaPlayerNotebookPage* currentpage = wxMediaPlayerNotebookPage* currentpage =
(wxMediaPlayerNotebookPage*) m_notebook->GetCurrentPage(); (wxMediaPlayerNotebookPage*) m_notebook->GetCurrentPage();
wxListItem listitem; wxListItem listitem;
@@ -1274,7 +1280,7 @@ void wxMediaPlayerFrame::OnChangeSong(wxListEvent& WXUNUSED(evt))
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void wxMediaPlayerFrame::OnPrev(wxCommandEvent& WXUNUSED(event)) void wxMediaPlayerFrame::OnPrev(wxCommandEvent& WXUNUSED(event))
{ {
wxMediaPlayerNotebookPage* currentpage = wxMediaPlayerNotebookPage* currentpage =
(wxMediaPlayerNotebookPage*) m_notebook->GetCurrentPage(); (wxMediaPlayerNotebookPage*) m_notebook->GetCurrentPage();
if (currentpage->m_playlist->GetItemCount() == 0) 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); 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 //nothing selected, default to the file before the currently playing one
if(currentpage->m_nLastFileId == 0) if(currentpage->m_nLastFileId == 0)
@@ -1299,7 +1305,7 @@ void wxMediaPlayerFrame::OnPrev(wxCommandEvent& WXUNUSED(event))
else else
nLastSelectedItem = currentpage->m_nLastFileId - 1; nLastSelectedItem = currentpage->m_nLastFileId - 1;
} }
else if (nLastSelectedItem == 0) else if (nLastSelectedItem == 0)
nLastSelectedItem = currentpage->m_playlist->GetItemCount() - 1; nLastSelectedItem = currentpage->m_playlist->GetItemCount() - 1;
else else
nLastSelectedItem -= 1; nLastSelectedItem -= 1;
@@ -1327,7 +1333,7 @@ void wxMediaPlayerFrame::OnPrev(wxCommandEvent& WXUNUSED(event))
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void wxMediaPlayerFrame::OnNext(wxCommandEvent& WXUNUSED(event)) void wxMediaPlayerFrame::OnNext(wxCommandEvent& WXUNUSED(event))
{ {
wxMediaPlayerNotebookPage* currentpage = wxMediaPlayerNotebookPage* currentpage =
(wxMediaPlayerNotebookPage*) m_notebook->GetCurrentPage(); (wxMediaPlayerNotebookPage*) m_notebook->GetCurrentPage();
if (currentpage->m_playlist->GetItemCount() == 0) 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) if(currentpage->m_nLastFileId == currentpage->m_playlist->GetItemCount() - 1)
nLastSelectedItem = 0; nLastSelectedItem = 0;
else else
nLastSelectedItem = currentpage->m_nLastFileId + 1; nLastSelectedItem = currentpage->m_nLastFileId + 1;
} }
else if (nLastSelectedItem == currentpage->m_playlist->GetItemCount() - 1) else if (nLastSelectedItem == currentpage->m_playlist->GetItemCount() - 1)
nLastSelectedItem = 0; nLastSelectedItem = 0;
@@ -1379,7 +1385,7 @@ void wxMediaPlayerFrame::OnNext(wxCommandEvent& WXUNUSED(event))
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void wxMediaPlayerFrame::OnVolumeDown(wxCommandEvent& WXUNUSED(event)) void wxMediaPlayerFrame::OnVolumeDown(wxCommandEvent& WXUNUSED(event))
{ {
wxMediaPlayerNotebookPage* currentpage = wxMediaPlayerNotebookPage* currentpage =
(wxMediaPlayerNotebookPage*) m_notebook->GetCurrentPage(); (wxMediaPlayerNotebookPage*) m_notebook->GetCurrentPage();
double dVolume = currentpage->m_mediactrl->GetVolume(); double dVolume = currentpage->m_mediactrl->GetVolume();
@@ -1393,7 +1399,7 @@ void wxMediaPlayerFrame::OnVolumeDown(wxCommandEvent& WXUNUSED(event))
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void wxMediaPlayerFrame::OnVolumeUp(wxCommandEvent& WXUNUSED(event)) void wxMediaPlayerFrame::OnVolumeUp(wxCommandEvent& WXUNUSED(event))
{ {
wxMediaPlayerNotebookPage* currentpage = wxMediaPlayerNotebookPage* currentpage =
(wxMediaPlayerNotebookPage*) m_notebook->GetCurrentPage(); (wxMediaPlayerNotebookPage*) m_notebook->GetCurrentPage();
double dVolume = currentpage->m_mediactrl->GetVolume(); double dVolume = currentpage->m_mediactrl->GetVolume();
@@ -1419,7 +1425,7 @@ void wxMediaPlayerFrame::OnVolumeUp(wxCommandEvent& WXUNUSED(event))
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void wxMediaPlayerTimer::Notify() void wxMediaPlayerTimer::Notify()
{ {
wxMediaPlayerNotebookPage* currentpage = wxMediaPlayerNotebookPage* currentpage =
(wxMediaPlayerNotebookPage*) m_frame->m_notebook->GetCurrentPage(); (wxMediaPlayerNotebookPage*) m_frame->m_notebook->GetCurrentPage();
wxMediaCtrl* currentMediaCtrl = currentpage->m_mediactrl; wxMediaCtrl* currentMediaCtrl = currentpage->m_mediactrl;
@@ -1642,7 +1648,7 @@ wxMediaPlayerNotebookPage::wxMediaPlayerNotebookPage(wxMediaPlayerFrame* parentF
m_gauge->Create(this, wxID_GAUGE, 0, wxDefaultPosition, wxDefaultSize, m_gauge->Create(this, wxID_GAUGE, 0, wxDefaultPosition, wxDefaultSize,
wxGA_HORIZONTAL | wxGA_SMOOTH); wxGA_HORIZONTAL | wxGA_SMOOTH);
sizer->Add(m_gauge, 0, wxALIGN_CENTER_HORIZONTAL|wxALL|wxEXPAND , 5); sizer->Add(m_gauge, 0, wxALIGN_CENTER_HORIZONTAL|wxALL|wxEXPAND , 5);
// //
// Create the speed/volume sliders // Create the speed/volume sliders

View File

@@ -59,6 +59,10 @@
#include "copy.xpm" #include "copy.xpm"
#endif #endif
#ifndef __WXMSW__
#include "../sample.xpm"
#endif
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// classes // classes
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -371,6 +375,8 @@ bool MyApp::OnInit()
MyFrame::MyFrame() MyFrame::MyFrame()
: wxFrame((wxFrame *)NULL, wxID_ANY, _T("wxWidgets menu sample")) : wxFrame((wxFrame *)NULL, wxID_ANY, _T("wxWidgets menu sample"))
{ {
SetIcon(wxICON(sample));
#if USE_LOG_WINDOW #if USE_LOG_WINDOW
m_textctrl = NULL; m_textctrl = NULL;
#endif #endif

View File

@@ -24,10 +24,17 @@
#error Sorry, this sample is only appropriate under Windows. #error Sorry, this sample is only appropriate under Windows.
#endif #endif
#ifndef __WXMSW__
#include "../sample.xpm"
#endif
#include <ctype.h> #include <ctype.h>
#include "nativdlg.h" #include "nativdlg.h"
#include "resource.h" #include "resource.h"
IMPLEMENT_APP(MyApp) IMPLEMENT_APP(MyApp)
bool MyApp::OnInit(void) 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): MyFrame::MyFrame(wxWindow *parent, const wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size):
wxFrame(parent, id, title, pos, size) wxFrame(parent, id, title, pos, size)
{ {
panel = NULL; SetIcon(wxICON(sample));
panel = NULL;
} }
void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
@@ -104,10 +113,10 @@ END_EVENT_TABLE()
void MyDialog::OnOk(wxCommandEvent& WXUNUSED(event)) void MyDialog::OnOk(wxCommandEvent& WXUNUSED(event))
{ {
EndModal(wxID_OK); EndModal(wxID_OK);
} }
void MyDialog::OnCancel(wxCommandEvent& WXUNUSED(event)) void MyDialog::OnCancel(wxCommandEvent& WXUNUSED(event))
{ {
EndModal(wxID_CANCEL); EndModal(wxID_CANCEL);
} }

View File

@@ -68,6 +68,9 @@
#include <wx/artprov.h> #include <wx/artprov.h>
#ifndef __WXMSW__
#include "../sample.xpm"
#endif
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// wxSampleMultiButtonEditor // 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| (wxMINIMIZE_BOX|wxMAXIMIZE_BOX|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCAPTION|
wxTAB_TRAVERSAL|wxCLOSE_BOX|wxNO_FULL_REPAINT_ON_RESIZE) ) wxTAB_TRAVERSAL|wxCLOSE_BOX|wxNO_FULL_REPAINT_ON_RESIZE) )
{ {
SetIcon(wxICON(sample));
m_propGrid = NULL; m_propGrid = NULL;
m_panel = NULL; m_panel = NULL;

View File

@@ -72,12 +72,12 @@ class wxVectorProperty : public wxPGProperty
public: public:
wxVectorProperty( const wxString& label = wxPG_LABEL, wxVectorProperty( const wxString& label = wxPG_LABEL,
const wxString& name = wxPG_LABEL, const wxString& name = wxPG_LABEL,
const wxVector3f& value = wxVector3f() ); const wxVector3f& value = wxVector3f() );
virtual ~wxVectorProperty(); virtual ~wxVectorProperty();
virtual void ChildChanged( wxVariant& thisValue, virtual void ChildChanged( wxVariant& thisValue,
int childIndex, wxVariant& childValue ) const; int childIndex, wxVariant& childValue ) const;
virtual void RefreshChildren(); virtual void RefreshChildren();
protected: protected:
@@ -109,7 +109,7 @@ public:
virtual ~wxTriangleProperty(); virtual ~wxTriangleProperty();
virtual void ChildChanged( wxVariant& thisValue, virtual void ChildChanged( wxVariant& thisValue,
int childIndex, wxVariant& childValue ) const; int childIndex, wxVariant& childValue ) const;
virtual void RefreshChildren(); virtual void RefreshChildren();
protected: protected:
@@ -128,7 +128,7 @@ class FormMain : public wxFrame
{ {
public: public:
FormMain(const wxString& title, const wxPoint& pos, const wxSize& size ); FormMain(const wxString& title, const wxPoint& pos, const wxSize& size );
~FormMain(); ~FormMain();
wxPropertyGridManager* m_pPropGridManager; wxPropertyGridManager* m_pPropGridManager;
wxPropertyGrid* m_propGrid; wxPropertyGrid* m_propGrid;

View File

@@ -22,6 +22,10 @@
#include "wx/log.h" #include "wx/log.h"
#include "wx/tglbtn.h" #include "wx/tglbtn.h"
#ifndef __WXMSW__
#include "../sample.xpm"
#endif
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// a trivial example // a trivial example
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -854,6 +858,8 @@ END_EVENT_TABLE()
MyFrame::MyFrame() MyFrame::MyFrame()
: wxFrame(NULL, wxID_ANY, "wxWidgets scroll sample") : wxFrame(NULL, wxID_ANY, "wxWidgets scroll sample")
{ {
SetIcon(wxICON(sample));
wxMenu *menuFile = new wxMenu; wxMenu *menuFile = new wxMenu;
menuFile->Append(wxID_ABOUT, "&About.."); menuFile->Append(wxID_ABOUT, "&About..");
menuFile->AppendSeparator(); menuFile->AppendSeparator();

View File

@@ -40,6 +40,9 @@
#include "wx/dcclient.h" #include "wx/dcclient.h"
#include "wx/image.h" #include "wx/image.h"
#ifndef __WXMSW__
#include "../sample.xpm"
#endif
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// constants // constants
@@ -246,6 +249,8 @@ MainFrame::MainFrame()
: wxFrame(NULL, wxID_ANY, "wxWidgets Shaped Sample", : wxFrame(NULL, wxID_ANY, "wxWidgets Shaped Sample",
wxDefaultPosition, wxSize(200, 100)) wxDefaultPosition, wxSize(200, 100))
{ {
SetIcon(wxICON(sample));
wxMenuBar * const mbar = new wxMenuBar; wxMenuBar * const mbar = new wxMenuBar;
wxMenu * const menuFrames = new wxMenu; wxMenu * const menuFrames = new wxMenu;
menuFrames->Append(Show_Shaped, "Show &shaped window\tCtrl-S"); menuFrames->Append(Show_Shaped, "Show &shaped window\tCtrl-S");

View File

@@ -39,6 +39,10 @@
#include "wx/splitter.h" #include "wx/splitter.h"
#include "wx/dcmirror.h" #include "wx/dcmirror.h"
#ifndef __WXMSW__
#include "../sample.xpm"
#endif
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// constants // constants
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -197,6 +201,8 @@ MyFrame::MyFrame()
wxDefaultPosition, wxSize(420, 300), wxDefaultPosition, wxSize(420, 300),
wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE) wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE)
{ {
SetIcon(wxICON(sample));
#if wxUSE_STATUSBAR #if wxUSE_STATUSBAR
CreateStatusBar(2); CreateStatusBar(2);
#endif // wxUSE_STATUSBAR #endif // wxUSE_STATUSBAR

View File

@@ -49,6 +49,10 @@
#include "wx/datetime.h" #include "wx/datetime.h"
#include "wx/numdlg.h" #include "wx/numdlg.h"
#ifndef __WXMSW__
#include "../sample.xpm"
#endif
// define this for the platforms which don't support wxBitmapButton (such as // define this for the platforms which don't support wxBitmapButton (such as
// Motif), else a wxBitmapButton will be used // 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) : wxFrame((wxWindow *)NULL, wxID_ANY, title, pos, size)
#endif #endif
{ {
SetIcon(wxICON(sample));
m_statbarDefault = NULL; m_statbarDefault = NULL;
m_statbarCustom = NULL; m_statbarCustom = NULL;

View File

@@ -39,6 +39,9 @@
#include "edit.h" // Edit module #include "edit.h" // Edit module
#include "prefs.h" // Prefs #include "prefs.h" // Prefs
#ifndef __WXMSW__
#include "../sample.xpm"
#endif
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// resources // resources
@@ -300,7 +303,9 @@ END_EVENT_TABLE ()
AppFrame::AppFrame (const wxString &title) AppFrame::AppFrame (const wxString &title)
: wxFrame ((wxFrame *)NULL, wxID_ANY, title, wxDefaultPosition, wxSize(750,550), : 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 // intitialize important variables
m_edit = NULL; m_edit = NULL;

View File

@@ -39,6 +39,11 @@
#include "wx/notebook.h" #include "wx/notebook.h"
#ifndef __WXMSW__
#include "../sample.xpm"
#endif
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// constants // constants
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -189,6 +194,8 @@ MyFrame::MyFrame()
: wxFrame(NULL, wxID_ANY, _T("TabOrder wxWidgets Sample"), : wxFrame(NULL, wxID_ANY, _T("TabOrder wxWidgets Sample"),
wxDefaultPosition, wxSize(700, 450)) wxDefaultPosition, wxSize(700, 450))
{ {
SetIcon(wxICON(sample));
wxMenu *menuFile = new wxMenu; wxMenu *menuFile = new wxMenu;
menuFile->Append(TabOrder_About); menuFile->Append(TabOrder_About);
menuFile->AppendSeparator(); menuFile->AppendSeparator();

View File

@@ -45,6 +45,10 @@
#include "wx/numdlg.h" #include "wx/numdlg.h"
#include "wx/tokenzr.h" #include "wx/tokenzr.h"
#ifndef __WXMSW__
#include "../sample.xpm"
#endif
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// class definitions // class definitions
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@@ -1369,6 +1373,8 @@ END_EVENT_TABLE()
MyFrame::MyFrame(wxFrame *frame, const wxChar *title, int x, int y, int w, int h) 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) ) : wxFrame(frame, wxID_ANY, title, wxPoint(x, y), wxSize(w, h) )
{ {
SetIcon(wxICON(sample));
#if wxUSE_STATUSBAR #if wxUSE_STATUSBAR
CreateStatusBar(2); CreateStatusBar(2);
#endif // wxUSE_STATUSBAR #endif // wxUSE_STATUSBAR

View File

@@ -3,7 +3,7 @@
// Purpose: wxWidgets sample demonstrating wxWrapSizer use // Purpose: wxWidgets sample demonstrating wxWrapSizer use
// Author: Arne Steinarson // Author: Arne Steinarson
// Created: 21.01.2008 // Created: 21.01.2008
// RCS-ID: $Id:$ // RCS-ID: $Id$
// Copyright: (c) Arne Steinarson // Copyright: (c) Arne Steinarson
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@@ -21,70 +21,19 @@
#include "wx/wrapsizer.h" #include "wx/wrapsizer.h"
#include "wx/artprov.h" #include "wx/artprov.h"
#ifndef __WXMSW__
#include "../sample.xpm"
#endif
// ----------------------------------------------------------------------------
// definitions
// ----------------------------------------------------------------------------
class WrapSizerFrame : public wxFrame class WrapSizerFrame : public wxFrame
{ {
public: public:
WrapSizerFrame() 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();
}
private: private:
void OnButton(wxCommandEvent& WXUNUSED(event)) void OnButton(wxCommandEvent& WXUNUSED(event))
@@ -116,10 +65,8 @@ private:
tb->Realize( ); tb->Realize( );
return tb; return tb;
} }
}; };
class WrapSizerApp : public wxApp class WrapSizerApp : public wxApp
{ {
public: public:
@@ -133,3 +80,73 @@ public:
}; };
IMPLEMENT_APP(WrapSizerApp); 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();
}