git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37300
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
-// ============================================================================
-// declarations
-// ============================================================================
-
-// ----------------------------------------------------------------------------
-// headers
-// ----------------------------------------------------------------------------
-
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#if wxUSE_TOOLBOOK
#include "wx/imaglist.h"
#if wxUSE_TOOLBOOK
#include "wx/imaglist.h"
#include "wx/toolbar.h"
#include "wx/toolbook.h"
#include "wx/settings.h"
#include "wx/toolbar.h"
#include "wx/toolbook.h"
#include "wx/settings.h"
m_needsRealizing = false;
}
m_needsRealizing = false;
}
-bool
-wxToolbook::Create(wxWindow *parent,
+bool wxToolbook::Create(wxWindow *parent,
wxWindowID id,
const wxPoint& pos,
const wxSize& size,
wxWindowID id,
const wxPoint& pos,
const wxSize& size,
const wxString& name)
{
if ( (style & wxBK_ALIGN_MASK) == wxBK_DEFAULT )
const wxString& name)
{
if ( (style & wxBK_ALIGN_MASK) == wxBK_DEFAULT )
// no border for this control
style &= ~wxBORDER_MASK;
// no border for this control
style &= ~wxBORDER_MASK;
wxDefaultValidator, name) )
return false;
wxDefaultValidator, name) )
return false;
int orient = wxTB_HORIZONTAL;
if ( (style & (wxBK_LEFT | wxBK_RIGHT)) != 0)
orient = wxTB_VERTICAL;
int orient = wxTB_HORIZONTAL;
if ( (style & (wxBK_LEFT | wxBK_RIGHT)) != 0)
orient = wxTB_VERTICAL;
// TODO: make more configurable
m_bookctrl = new wxToolBar
(
// TODO: make more configurable
m_bookctrl = new wxToolBar
(
{
if (m_needsRealizing)
Realize();
{
if (m_needsRealizing)
Realize();
wxBookCtrlBase::OnSize(event);
}
wxBookCtrlBase::OnSize(event);
}
// ----------------------------------------------------------------------------
// accessing the pages
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// accessing the pages
// ----------------------------------------------------------------------------
bool wxToolbook::SetPageText(size_t n, const wxString& strText)
{
// Assume tool ids start from 1
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);
if (tool)
{
tool->SetLabel(strText);
wxString wxToolbook::GetPageText(size_t n) const
{
wxString wxToolbook::GetPageText(size_t n) const
{
- wxToolBarToolBase* tool = GetToolBar()->FindById(n+1);
+ wxToolBarToolBase* tool = GetToolBar()->FindById(n + 1);
else
return wxEmptyString;
}
else
return wxEmptyString;
}
wxASSERT( GetImageList() != NULL );
if (!GetImageList())
return false;
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
if (tool)
{
// Find the image list index for this tool
// change m_selection now to ignore the selection change event
m_selection = n;
// 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);
// program allows the page change
event.SetEventType(wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGED);
GetToolBar()->Realize();
wxSystemOptions::SetOption(wxT("msw.remap"), remap);
}
GetToolBar()->Realize();
wxSystemOptions::SetOption(wxT("msw.remap"), remap);
}
m_needsRealizing = false;
m_needsRealizing = false;
if (m_selection == -1)
m_selection = 0;
if (m_selection == -1)
m_selection = 0;
m_selection = -1;
SetSelection(sel);
}
m_selection = -1;
SetSelection(sel);
}
// adding/removing the pages
// ----------------------------------------------------------------------------
// adding/removing the pages
// ----------------------------------------------------------------------------
-bool
-wxToolbook::InsertPage(size_t n,
+bool wxToolbook::InsertPage(size_t n,
wxWindow *page,
const wxString& text,
bool bSelect,
wxWindow *page,
const wxString& text,
bool bSelect,
return false;
m_needsRealizing = true;
return false;
m_needsRealizing = true;
wxASSERT(GetImageList() != NULL);
wxASSERT(GetImageList() != NULL);
if (!GetImageList())
return false;
if (!GetImageList())
return false;
wxBitmap bitmap;
bitmap.CopyFromIcon(icon);
#endif
wxBitmap bitmap;
bitmap.CopyFromIcon(icon);
#endif
m_maxBitmapSize.x = wxMax(bitmap.GetWidth(), m_maxBitmapSize.x);
m_maxBitmapSize.y = wxMax(bitmap.GetHeight(), m_maxBitmapSize.y);
m_maxBitmapSize.x = wxMax(bitmap.GetWidth(), m_maxBitmapSize.x);
m_maxBitmapSize.y = wxMax(bitmap.GetHeight(), m_maxBitmapSize.y);
GetToolBar()->SetToolBitmapSize(m_maxBitmapSize);
GetToolBar()->SetToolBitmapSize(m_maxBitmapSize);
- GetToolBar()->AddRadioTool(n+1, text, bitmap, wxNullBitmap, text);
+ GetToolBar()->AddRadioTool(n + 1, text, bitmap, wxNullBitmap, text);
- GetToolBar()->DeleteTool(page+1);
+ GetToolBar()->DeleteTool(page + 1);
if (m_selection >= (int)page)
{
if (m_selection >= (int)page)
{
void wxToolbook::OnToolSelected(wxCommandEvent& event)
{
void wxToolbook::OnToolSelected(wxCommandEvent& event)
{
- const int selNew = event.GetId() -1;
+ const int selNew = event.GetId() - 1;
if ( selNew == m_selection )
{
if ( selNew == m_selection )
{
// change wasn't allowed, return to previous state
if (m_selection != selNew)
// change wasn't allowed, return to previous state
if (m_selection != selNew)
GetToolBar()->ToggleTool(m_selection, false);
GetToolBar()->ToggleTool(m_selection, false);
}
#endif // wxUSE_TOOLBOOK
}
#endif // wxUSE_TOOLBOOK