// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
-// ============================================================================
-// declarations
-// ============================================================================
-
-// ----------------------------------------------------------------------------
-// headers
-// ----------------------------------------------------------------------------
-
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#if wxUSE_TOOLBOOK
#include "wx/imaglist.h"
+#include "wx/icon.h"
#include "wx/toolbar.h"
#include "wx/toolbook.h"
#include "wx/settings.h"
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 (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)
{
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 )
{
// change wasn't allowed, return to previous state
if (m_selection != selNew)
- {
GetToolBar()->ToggleTool(m_selection, false);
- }
}
#endif // wxUSE_TOOLBOOK