// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
-// ============================================================================
-// declarations
-// ============================================================================
-
-// ----------------------------------------------------------------------------
-// headers
-// ----------------------------------------------------------------------------
-
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#if wxUSE_TOOLBOOK
+#ifndef WX_PRECOMP
+ #include "wx/icon.h"
+ #include "wx/settings.h"
+ #include "wx/toolbar.h"
+#endif
+
#include "wx/imaglist.h"
-#include "wx/toolbar.h"
-#include "wx/toolbook.h"
-#include "wx/settings.h"
#include "wx/sysopt.h"
+#include "wx/toolbook.h"
+
+#if defined(__WXMAC__) && wxUSE_TOOLBAR && wxUSE_BMPBUTTON
+#include "wx/generic/buttonbar.h"
+#endif
// ----------------------------------------------------------------------------
// various wxWidgets macros
IMPLEMENT_DYNAMIC_CLASS(wxToolbook, wxBookCtrlBase)
IMPLEMENT_DYNAMIC_CLASS(wxToolbookEvent, wxNotifyEvent)
+#if !WXWIN_COMPATIBILITY_EVENT_TYPES
const wxEventType wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGING = wxNewEventType();
const wxEventType wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGED = wxNewEventType();
+#endif
const int wxID_TOOLBOOKTOOLBAR = wxNewId();
BEGIN_EVENT_TABLE(wxToolbook, wxBookCtrlBase)
m_needsRealizing = false;
}
-bool
-wxToolbook::Create(wxWindow *parent,
+bool wxToolbook::Create(wxWindow *parent,
wxWindowID id,
const wxPoint& pos,
const wxSize& size,
const wxString& name)
{
if ( (style & wxBK_ALIGN_MASK) == wxBK_DEFAULT )
- {
style |= wxBK_TOP;
- }
// no border for this control
style &= ~wxBORDER_MASK;
wxDefaultValidator, name) )
return false;
-
int orient = wxTB_HORIZONTAL;
if ( (style & (wxBK_LEFT | wxBK_RIGHT)) != 0)
orient = wxTB_VERTICAL;
-
+
// TODO: make more configurable
- m_bookctrl = new wxToolBar
+
+#if defined(__WXMAC__) && wxUSE_TOOLBAR && wxUSE_BMPBUTTON
+ if (style & wxBK_BUTTONBAR)
+ {
+ m_bookctrl = new wxButtonToolBar
+ (
+ this,
+ wxID_TOOLBOOKTOOLBAR,
+ wxDefaultPosition,
+ wxDefaultSize,
+ orient|wxTB_TEXT|wxTB_FLAT|wxNO_BORDER
+ );
+ }
+ else
+#endif
+ {
+ m_bookctrl = new wxToolBar
(
this,
wxID_TOOLBOOKTOOLBAR,
wxDefaultPosition,
wxDefaultSize,
- orient | wxTB_TEXT|wxTB_FLAT|wxTB_NODIVIDER
+ orient|wxTB_TEXT|wxTB_FLAT|wxTB_NODIVIDER|wxNO_BORDER
);
+ }
return true;
}
{
if (m_needsRealizing)
Realize();
-
+
wxBookCtrlBase::OnSize(event);
}
return size;
}
-
// ----------------------------------------------------------------------------
// accessing the pages
// ----------------------------------------------------------------------------
bool wxToolbook::SetPageText(size_t n, const wxString& strText)
{
// Assume tool ids start from 1
- wxToolBarToolBase* tool = GetToolBar()->FindById(n+1);
+ wxToolBarToolBase* tool = GetToolBar()->FindById(n + 1);
if (tool)
{
tool->SetLabel(strText);
wxString wxToolbook::GetPageText(size_t n) const
{
- wxToolBarToolBase* tool = GetToolBar()->FindById(n+1);
+ wxToolBarToolBase* tool = GetToolBar()->FindById(n + 1);
if (tool)
- {
return tool->GetLabel();
- }
else
return wxEmptyString;
}
wxASSERT( GetImageList() != NULL );
if (!GetImageList())
return false;
-
- wxToolBarToolBase* tool = GetToolBar()->FindById(n+1);
+
+ wxToolBarToolBase* tool = GetToolBar()->FindById(n + 1);
if (tool)
{
// Find the image list index for this tool
// change m_selection now to ignore the selection change event
m_selection = n;
- GetToolBar()->ToggleTool(n+1, true);
+ GetToolBar()->ToggleTool(n + 1, true);
// program allows the page change
event.SetEventType(wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGED);
GetToolBar()->Realize();
wxSystemOptions::SetOption(wxT("msw.remap"), remap);
}
-
+
m_needsRealizing = false;
-
+
if (m_selection == -1)
m_selection = 0;
m_selection = -1;
SetSelection(sel);
}
-
+
DoSize();
}
// adding/removing the pages
// ----------------------------------------------------------------------------
-bool
-wxToolbook::InsertPage(size_t n,
+bool wxToolbook::InsertPage(size_t n,
wxWindow *page,
const wxString& text,
bool bSelect,
return false;
m_needsRealizing = true;
-
+
wxASSERT(GetImageList() != NULL);
-
+
if (!GetImageList())
return false;
wxBitmap bitmap;
bitmap.CopyFromIcon(icon);
#endif
-
+
m_maxBitmapSize.x = wxMax(bitmap.GetWidth(), m_maxBitmapSize.x);
m_maxBitmapSize.y = wxMax(bitmap.GetHeight(), m_maxBitmapSize.y);
-
+
GetToolBar()->SetToolBitmapSize(m_maxBitmapSize);
- GetToolBar()->AddRadioTool(n+1, text, bitmap, wxNullBitmap, text);
+ GetToolBar()->AddRadioTool(n + 1, text, bitmap, wxNullBitmap, text);
if (bSelect)
{
- // GetToolBar()->ToggleTool(n, true);
+ GetToolBar()->ToggleTool(n, true);
m_selection = n;
}
else
if ( win )
{
- GetToolBar()->DeleteTool(page+1);
+ GetToolBar()->DeleteTool(page + 1);
if (m_selection >= (int)page)
{
void wxToolbook::OnToolSelected(wxCommandEvent& event)
{
- const int selNew = event.GetId() -1;
+ const int selNew = event.GetId() - 1;
if ( selNew == m_selection )
{