// define this to use XPMs everywhere (by default, BMPs are used under Win)
// BMPs use less space, but aren't compiled into the executable on other platforms
-#ifdef __WXMSW__
+#ifdef __WINDOWS__
#define USE_XPM_BITMAPS 0
#else
#define USE_XPM_BITMAPS 1
// resources
// ----------------------------------------------------------------------------
-#if !defined(__WXMSW__) && !defined(__WXPM__)
- #include "mondrian.xpm"
+#ifndef wxHAS_IMAGES_IN_RESOURCES
+ #include "../sample.xpm"
#endif
#if USE_XPM_BITMAPS
wxInitAllImageHandlers();
- SetTopWindow(frame);
-
return true;
}
{
// create a tool with a custom bitmap for testing
wxImage img(m_pathBmp);
- if ( img.Ok() )
+ if ( img.IsOk() )
{
if ( img.GetWidth() > w && img.GetHeight() > h )
img = img.GetSubImage(wxRect(0, 0, w, h));
// the changes
toolBar->Realize();
- toolBar->SetRows(!(toolBar->IsVertical()) ? m_rows : 10 / m_rows);
+ toolBar->SetRows(toolBar->IsVertical() ? toolBar->GetToolsCount() / m_rows
+ : m_rows);
}
// ----------------------------------------------------------------------------
#endif
// Give it an icon
- SetIcon(wxICON(mondrian));
+ SetIcon(wxICON(sample));
// Make a menubar
wxMenu *tbarMenu = new wxMenu;
// Associate the menu bar with the frame
SetMenuBar(menuBar);
+ menuBar->Check(IDM_TOOLBAR_TOGGLE_TOOLBAR, true);
menuBar->Check(IDM_TOOLBAR_SHOW_BOTH, true);
menuBar->Check(IDM_TOOLBAR_TOGGLETOOLTIPS, true);
m_extraToolBar = new wxToolBar(m_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTB_TEXT|wxTB_FLAT|wxTB_TOP);
PopulateToolbar(m_extraToolBar);
#endif
-
+
m_textWindow = new wxTextCtrl(m_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE);
wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
}
else
{
+ // notice that there is no need to call SetToolBar(NULL) here (although
+ // this it is harmless to do and it must be called if you do not delete
+ // the toolbar but keep it for later reuse), just delete the toolbar
+ // directly and it will reset the associated frame toolbar pointer
delete tbar;
-
- SetToolBar(NULL);
}
}
{
if ( m_tbar )
{
- delete m_tbar;
- m_tbar = NULL;
+ wxDELETE(m_tbar);
}
else
{
// m_rows may be only 1 or 2
m_rows = 3 - m_rows;
- GetToolBar()->SetRows(!(GetToolBar()->IsVertical()) ? m_rows : 10 / m_rows);
+ wxToolBar* const toolBar = GetToolBar();
+ toolBar->SetRows(toolBar->IsVertical() ? toolBar->GetToolsCount() / m_rows
+ : m_rows);
//RecreateToolbar(); -- this is unneeded
}
void MyFrame::OnToolbarStyle(wxCommandEvent& event)
{
long style = GetToolBar()->GetWindowStyle();
- style &= ~(wxTB_NOICONS | wxTB_TEXT);
+ style &= ~(wxTB_NOICONS | wxTB_HORZ_TEXT);
switch ( event.GetId() )
{
case IDM_TOOLBAR_SHOW_TEXT:
- style |= wxTB_NOICONS | wxTB_TEXT;
+ style |= wxTB_NOICONS | (m_horzText ? wxTB_HORZ_TEXT : wxTB_TEXT);
break;
case IDM_TOOLBAR_SHOW_ICONS:
break;
case IDM_TOOLBAR_SHOW_BOTH:
- style |= wxTB_TEXT;
+ style |= (m_horzText ? wxTB_HORZ_TEXT : wxTB_TEXT);
}
GetToolBar()->SetWindowStyle(style);