}
// get the currently selected page or wxNOT_FOUND if none
- virtual int GetSelection() const = 0;
+ int GetSelection() const { return m_selection; }
// set/get the title of a page
virtual bool SetPageText(size_t n, const wxString& strText) = 0;
// remove all pages and delete them
virtual bool DeleteAllPages()
{
+ m_selection = wxNOT_FOUND;
DoInvalidateBestSize();
WX_CLEAR_ARRAY(m_pages);
return true;
// the margin around the choice control
int m_controlMargin;
+ // The currently selected page (in range 0..m_pages.size()-1 inclusive) or
+ // wxNOT_FOUND if none (this can normally only be the case for an empty
+ // control without any pages).
+ int m_selection;
+
private:
// common part of all ctors
DECLARE_ABSTRACT_CLASS(wxBookCtrlBase)
wxDECLARE_NO_COPY_CLASS(wxBookCtrlBase);
+
DECLARE_EVENT_TABLE()
};
class WXDLLIMPEXP_CORE wxChoicebook : public wxBookCtrlBase
{
public:
- wxChoicebook()
- {
- Init();
- }
+ wxChoicebook() { }
wxChoicebook(wxWindow *parent,
wxWindowID id,
long style = 0,
const wxString& name = wxEmptyString)
{
- Init();
-
(void)Create(parent, id, pos, size, style, name);
}
const wxString& name = wxEmptyString);
- virtual int GetSelection() const;
virtual bool SetPageText(size_t n, const wxString& strText);
virtual wxString GetPageText(size_t n) const;
virtual int GetPageImage(size_t n) const;
// event handlers
void OnChoiceSelected(wxCommandEvent& event);
- // the currently selected page or wxNOT_FOUND if none
- int m_selection;
-
private:
- // common part of all constructors
- void Init();
-
DECLARE_EVENT_TABLE()
DECLARE_DYNAMIC_CLASS_NO_COPY(wxChoicebook)
};
int SetSelection(size_t nPage);
// cycle thru the tabs
// void AdvanceSelection(bool bForward = true);
- // get the currently selected page
- int GetSelection() const { return m_nSelection; }
// changes selected page without sending events
int ChangeSelection(size_t nPage);
// helper functions
void ChangePage(int nOldSel, int nSel); // change pages
- int m_nSelection; // the current selection (-1 if none)
-
wxTabView* m_tabView;
DECLARE_DYNAMIC_CLASS(wxNotebook)
// common part of all ctors
void Init();
+ // Called by GTK event handler when the current page is definitely changed.
+ void GTKOnPageChanged();
+
// helper function
wxGtkNotebookPage* GetNotebookPage(int page) const;
class WXDLLIMPEXP_CORE wxListbook : public wxBookCtrlBase
{
public:
- wxListbook()
- {
- Init();
- }
+ wxListbook() { }
wxListbook(wxWindow *parent,
wxWindowID id,
long style = 0,
const wxString& name = wxEmptyString)
{
- Init();
-
(void)Create(parent, id, pos, size, style, name);
}
// overridden base class methods
- virtual int GetSelection() const;
virtual bool SetPageText(size_t n, const wxString& strText);
virtual wxString GetPageText(size_t n) const;
virtual int GetPageImage(size_t n) const;
void OnListSelected(wxListEvent& event);
void OnSize(wxSizeEvent& event);
- // the currently selected page or wxNOT_FOUND if none
- int m_selection;
-
private:
- // common part of all constructors
- void Init();
-
// this should be called when we need to be relaid out
void UpdateSize();
// selected one (or wxNOT_FOUND on error)
// NB: this function will _not_ generate wxEVT_NOTEBOOK_PAGE_xxx events
int SetSelection(size_t nPage);
- // get the currently selected page
- int GetSelection() const { return m_nSelection; }
// changes selected page without sending events
int ChangeSelection(size_t nPage);
void Init();
// hides the currently shown page and shows the given one (if not -1) and
- // updates m_nSelection accordingly
+ // updates m_selection accordingly
void UpdateSelection(int selNew);
// remove one page from the notebook, without deleting
bool m_hasSubclassedUpdown;
#endif // __WXWINCE__
- // the current selection (-1 if none)
- int m_nSelection;
wxNotebookPageInfoList m_pageInfos;
// changes selected page without sending events
int ChangeSelection(size_t nPage);
- //
- // Get the currently selected page
- //
- inline int GetSelection(void) const { return m_nSelection; }
-
//
// Set/Get the title of a page
//
// Helper functions
//
- int m_nSelection; // The current selection (-1 if none)
-
private:
wxArrayLong m_alPageId;
int m_nTabSize; // holds the largest tab size
// ctors
// -----
// default for dynamic class
- wxNotebook();
+ wxNotebook() { }
// the same arguments as for wxControl (@@@ any special styles?)
wxNotebook(wxWindow *parent,
wxWindowID id,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxNotebookNameStr);
+ { Create( parent, id, pos, size, style, name ); }
// Create() function
bool Create(wxWindow *parent,
wxWindowID id,
// selected one (or wxNOT_FOUND on error)
// NB: this function will _not_ generate wxEVT_NOTEBOOK_PAGE_xxx events
int SetSelection(size_t nPage) { return DoSetSelection(nPage, SetSelection_SendEvent); }
- // get the currently selected page
- int GetSelection() const { return m_nSelection; }
// changes selected page without sending events
int ChangeSelection(size_t nPage) { return DoSetSelection(nPage); }
// the icon indices
wxArrayInt m_images;
- int m_nSelection; // the current selection (-1 if none)
-
DECLARE_DYNAMIC_CLASS(wxNotebook)
DECLARE_EVENT_TABLE()
};
// implement base class virtuals
- virtual int GetSelection() const;
virtual bool SetPageText(size_t n, const wxString& strText);
virtual wxString GetPageText(size_t n) const;
virtual int GetPageImage(size_t n) const;
wxBookCtrlEvent* CreatePageChangingEvent() const;
void MakeChangedEvent(wxBookCtrlEvent &event);
- // the currently selected page or wxNOT_FOUND if none
- int m_selection;
-
// whether the toolbar needs to be realized
bool m_needsRealizing;
// Standard operations inherited from wxBookCtrlBase
// -------------------------------------------------
- virtual int GetSelection() const;
virtual bool SetPageText(size_t n, const wxString& strText);
virtual wxString GetPageText(size_t n) const;
virtual int GetPageImage(size_t n) const;
// array of page ids and page windows
wxArrayTreeItemIds m_treeIds;
- // the currently selected page or wxNOT_FOUND if none
- int m_selection;
-
// in the situation when m_selection page is not wxNOT_FOUND but page is
// NULL this is the first (sub)child that has a non-NULL page
int m_actualSelection;
// --------------------------------------
virtual int SetSelection(size_t nPage) { return DoSetSelection(nPage, SetSelection_SendEvent); }
- virtual int GetSelection() const { return (int) m_sel; }
// changes selected page without sending events
int ChangeSelection(size_t nPage) { return DoSetSelection(nPage); }
// the pages titles
wxArrayString m_titles;
- // the current selection
- size_t m_sel;
-
// the spin button to change the pages
wxSpinButton *m_spinbtn;
void wxBookCtrlBase::Init()
{
+ m_selection = wxNOT_FOUND;
m_bookctrl = NULL;
m_imageList = NULL;
m_ownsImageList = false;
// wxChoicebook creation
// ----------------------------------------------------------------------------
-void wxChoicebook::Init()
-{
- m_selection = wxNOT_FOUND;
-}
-
bool
wxChoicebook::Create(wxWindow *parent,
wxWindowID id,
// selection
// ----------------------------------------------------------------------------
-int wxChoicebook::GetSelection() const
-{
- return m_selection;
-}
-
wxBookCtrlEvent* wxChoicebook::CreatePageChangingEvent() const
{
return new wxBookCtrlEvent(wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING, m_windowId);
bool wxChoicebook::DeleteAllPages()
{
- m_selection = wxNOT_FOUND;
GetChoiceCtrl()->Clear();
return wxBookCtrlBase::DeleteAllPages();
}
// wxListbook creation
// ----------------------------------------------------------------------------
-void wxListbook::Init()
-{
- m_selection = wxNOT_FOUND;
-}
-
bool
wxListbook::Create(wxWindow *parent,
wxWindowID id,
GetListView()->Focus(newsel);
}
-int wxListbook::GetSelection() const
-{
- return m_selection;
-}
-
wxBookCtrlEvent* wxListbook::CreatePageChangingEvent() const
{
return new wxBookCtrlEvent(wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING, m_windowId);
if (!wxBookCtrlBase::DeleteAllPages())
return false;
- m_selection = -1;
-
UpdateSize();
return true;
void wxToolbook::Init()
{
- m_selection = wxNOT_FOUND;
m_needsRealizing = false;
}
// selection
// ----------------------------------------------------------------------------
-int wxToolbook::GetSelection() const
-{
- return m_selection;
-}
-
wxBookCtrlEvent* wxToolbook::CreatePageChangingEvent() const
{
return new wxBookCtrlEvent(wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGING, m_windowId);
return true;
}
-int wxTreebook::GetSelection() const
-{
- return m_selection;
-}
-
int wxTreebook::DoSetSelection(size_t pagePos, int flags)
{
wxCHECK_MSG( IS_VALID_PAGE(pagePos), wxNOT_FOUND,
extern "C" {
static void
-switch_page_after(GtkWidget* widget, GtkNotebookPage*, guint, wxNotebook* win)
+switch_page_after(GtkNotebook* widget, GtkNotebookPage*, guint, wxNotebook* win)
{
g_signal_handlers_block_by_func(widget, (void*)switch_page_after, win);
- win->SendPageChangedEvent(win->m_oldSelection);
+
+ win->GTKOnPageChanged();
}
}
g_signal_handlers_unblock_by_func(m_widget, (void*)switch_page, this);
}
+ m_selection = page;
+
wxNotebookPage *client = GetPage(page);
if ( client )
client->SetFocus();
return selOld;
}
+void wxNotebook::GTKOnPageChanged()
+{
+ m_selection = gtk_notebook_get_current_page(GTK_NOTEBOOK(m_widget));
+
+ SendPageChangedEvent(m_oldSelection);
+}
+
bool wxNotebook::SetPageText( size_t page, const wxString &text )
{
wxCHECK_MSG(page < GetPageCount(), false, "invalid notebook index");
// make wxNotebook::GetSelection() return the correct (i.e. consistent
// with wxBookCtrlEvent::GetSelection()) value even though the page is
// not really changed in GTK+
- notebook->m_selection = page;
+ notebook->SetSelection(page);
}
else
{
// make wxNotebook::GetSelection() return the correct (i.e. consistent
// with wxBookCtrlEvent::GetSelection()) value even though the page is
// not really changed in GTK+
- notebook->m_selection = page;
+ notebook->SetSelection(page);
notebook->SendPageChangedEvent(old);
}
m_inSwitchPage = false;
m_imageList = NULL;
- m_selection = -1;
m_themeEnabled = true;
}
gpointer cur = notebook->cur_page;
if ( cur != NULL )
{
- wxConstCast(this, wxNotebook)->m_selection =
- g_list_index( nb_pages, cur );
+ const_cast<wxNotebook *>(this)->
+ SetSelection(g_list_index( nb_pages, cur ));
}
}
}
void wxNotebook::Init()
{
m_imageList = NULL;
- m_nSelection = wxNOT_FOUND;
#if wxUSE_UXTHEME
m_hbrBackground = NULL;
{
wxCHECK_MSG( IS_VALID_PAGE(nPage), wxNOT_FOUND, wxT("notebook page out of range") );
- if ( m_nSelection == wxNOT_FOUND || nPage != (size_t)m_nSelection )
+ if ( m_selection == wxNOT_FOUND || nPage != (size_t)m_selection )
{
if ( SendPageChangingEvent(nPage) )
{
// program allows the page change
- SendPageChangedEvent(m_nSelection, nPage);
+ SendPageChangedEvent(m_selection, nPage);
TabCtrl_SetCurSel(GetHwnd(), nPage);
}
}
- return m_nSelection;
+ return m_selection;
}
void wxNotebook::UpdateSelection(int selNew)
{
- if ( m_nSelection != wxNOT_FOUND )
- m_pages[m_nSelection]->Show(false);
+ if ( m_selection != wxNOT_FOUND )
+ m_pages[m_selection]->Show(false);
if ( selNew != wxNOT_FOUND )
{
if ( ::IsWindowVisible(GetHwnd()) )
SetFocus();
- m_nSelection = selNew;
+ m_selection = selNew;
}
int wxNotebook::ChangeSelection(size_t nPage)
{
wxCHECK_MSG( IS_VALID_PAGE(nPage), wxNOT_FOUND, wxT("notebook page out of range") );
- const int selOld = m_nSelection;
+ const int selOld = m_selection;
- if ( m_nSelection == wxNOT_FOUND || nPage != (size_t)m_nSelection )
+ if ( m_selection == wxNOT_FOUND || nPage != (size_t)m_selection )
{
TabCtrl_SetCurSel(GetHwnd(), nPage);
if ( m_pages.IsEmpty() )
{
// no selection any more, the notebook becamse empty
- m_nSelection = wxNOT_FOUND;
+ m_selection = wxNOT_FOUND;
}
else // notebook still not empty
{
// Because it could be that the slection index changed
// we need to update it.
// Note: this does not mean the selection it self changed.
- m_nSelection = selNew;
- m_pages[m_nSelection]->Refresh();
+ m_selection = selNew;
+ m_pages[m_selection]->Refresh();
}
- else if (int(nPage) == m_nSelection)
+ else if (int(nPage) == m_selection)
{
// The selection was deleted.
// Determine new selection.
- if (m_nSelection == int(GetPageCount()))
- selNew = m_nSelection - 1;
+ if (m_selection == int(GetPageCount()))
+ selNew = m_selection - 1;
else
- selNew = m_nSelection;
+ selNew = m_selection;
- // m_nSelection must be always valid so reset it before calling
+ // m_selection must be always valid so reset it before calling
// SetSelection()
- m_nSelection = wxNOT_FOUND;
+ m_selection = wxNOT_FOUND;
SetSelection(selNew);
}
else
TabCtrl_DeleteAllItems(GetHwnd());
- m_nSelection = wxNOT_FOUND;
+ m_selection = wxNOT_FOUND;
InvalidateBestSize();
return true;
// if the inserted page is before the selected one, we must update the
// index of the selected page
- if ( int(nPage) <= m_nSelection )
+ if ( int(nPage) <= m_selection )
{
// one extra page added
- m_nSelection++;
+ m_selection++;
}
// some page should be selected: either this one or the first one if there
int selNew = wxNOT_FOUND;
if ( bSelect )
selNew = nPage;
- else if ( m_nSelection == wxNOT_FOUND )
+ else if ( m_selection == wxNOT_FOUND )
selNew = 0;
if ( selNew != wxNOT_FOUND )
// page but only if entering notebook page (i.e. direction is
// backwards (Shift-TAB) comething from out-of-notebook, or
// direction is forward (TAB) from ourselves),
- if ( m_nSelection != wxNOT_FOUND &&
+ if ( m_selection != wxNOT_FOUND &&
(!event.GetDirection() || isFromSelf) )
{
// so that the page knows that the event comes from it's parent
// and is being propagated downwards
event.SetEventObject(this);
- wxWindow *page = m_pages[m_nSelection];
+ wxWindow *page = m_pages[m_selection];
if ( !page->HandleWindowEvent(event) )
{
page->SetFocus();
}
event.SetSelection(TabCtrl_GetCurSel(GetHwnd()));
- event.SetOldSelection(m_nSelection);
+ event.SetOldSelection(m_selection);
event.SetEventObject(this);
event.SetInt(idCtrl);
void wxNotebook::Init()
{
m_imageList = NULL;
- m_nSelection = -1;
m_nTabSize = 0;
} // end of wxNotebook::Init
{
wxCHECK_MSG( IS_VALID_PAGE(nPage), wxNOT_FOUND, wxT("notebook page out of range") );
- if (nPage != (size_t)m_nSelection)
+ if (nPage != (size_t)m_selection)
{
wxBookCtrlEvent vEvent( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING
,m_windowId
);
vEvent.SetSelection(nPage);
- vEvent.SetOldSelection(m_nSelection);
+ vEvent.SetOldSelection(m_selection);
vEvent.SetEventObject(this);
if (!HandleWindowEvent(vEvent) || vEvent.IsAllowed())
{
);
}
}
- m_nSelection = nPage;
+ m_selection = nPage;
return nPage;
} // end of wxNotebook::SetSelection
{
wxCHECK_MSG( IS_VALID_PAGE(nPage), wxNOT_FOUND, wxT("notebook page out of range") );
- if (nPage != (size_t)m_nSelection)
+ if (nPage != (size_t)m_selection)
{
::WinSendMsg( GetHWND()
,BKM_TURNTOPAGE
,(MPARAM)0
);
}
- m_nSelection = nPage;
+ m_selection = nPage;
return nPage;
}
//
// No selection any more, the notebook becamse empty
//
- m_nSelection = -1;
+ m_selection = wxNOT_FOUND;
}
else // notebook still not empty
{
//
int nSelNew;
- if (m_nSelection == (int)GetPageCount())
+ if (m_selection == (int)GetPageCount())
{
//
// Last page deleted, make the new last page the new selection
//
- nSelNew = m_nSelection - 1;
+ nSelNew = m_selection - 1;
}
- else if (nPage <= (size_t)m_nSelection)
+ else if (nPage <= (size_t)m_selection)
{
//
// We must show another page, even if it has the same index
//
- nSelNew = m_nSelection;
+ nSelNew = m_selection;
}
else // nothing changes for the currently selected page
{
// control (i.e. when there are too many pages) -- otherwise after
// deleting a page nothing at all is shown
//
- m_pages[m_nSelection]->Refresh();
+ m_pages[m_selection]->Refresh();
}
if (nSelNew != wxNOT_FOUND)
{
//
- // m_nSelection must be always valid so reset it before calling
+ // m_selection must be always valid so reset it before calling
// SetSelection()
//
- m_nSelection = -1;
+ m_selection = wxNOT_FOUND;
SetSelection(nSelNew);
}
}
,(MPARAM)0
,(MPARAM)BKA_ALL
);
- m_nSelection = -1;
+ m_selection = wxNOT_FOUND;
return true;
} // end of wxNotebook::DeleteAllPages
// If the inserted page is before the selected one, we must update the
// index of the selected page
//
- if (nPage <= (size_t)m_nSelection)
+ if (nPage <= (size_t)m_selection)
{
//
// One extra page added
//
- m_nSelection++;
+ m_selection++;
}
if (pPage)
if (bSelect)
nSelNew = nPage;
- else if ( m_nSelection == -1 )
+ else if ( m_selection == wxNOT_FOUND )
nSelNew = 0;
if (nSelNew != wxNOT_FOUND)
wxNotebookPage* pPage = m_pages[nSel];
pPage->Show(true);
- m_nSelection = nSel;
+ m_selection = nSel;
}
//
//
// set focus to the currently selected page if any
//
- if (m_nSelection != -1)
- m_pages[m_nSelection]->SetFocus();
+ if (m_selection != wxNOT_FOUND)
+ m_pages[m_selection]->SetFocus();
rEvent.Skip();
} // end of wxNotebook::OnSetFocus
//
// No, it doesn't come from child, case (b): forward to a page
//
- if (m_nSelection != -1)
+ if (m_selection != wxNOT_FOUND)
{
//
// So that the page knows that the event comes from it's parent
//
rEvent.SetEventObject(this);
- wxWindow* pPage = m_pages[m_nSelection];
+ wxWindow* pPage = m_pages[m_selection];
if (!pPage->HandleWindowEvent(rEvent))
{
IMPLEMENT_DYNAMIC_CLASS(wxNotebook, wxBookCtrlBase)
-
-// common part of all ctors
-void wxNotebook::Init()
-{
- m_nSelection = -1;
-}
-
-// default for dynamic class
-wxNotebook::wxNotebook()
-{
- Init();
-}
-
-// the same arguments as for wxControl
-wxNotebook::wxNotebook( wxWindow *parent,
- wxWindowID id,
- const wxPoint& pos,
- const wxSize& size,
- long style,
- const wxString& name )
-{
- Init();
-
- Create( parent, id, pos, size, style, name );
-}
-
bool wxNotebook::Create( wxWindow *parent,
wxWindowID id,
const wxPoint& pos,
{
wxCHECK_MSG( IS_VALID_PAGE(nPage), wxNOT_FOUND, wxT("DoSetSelection: invalid notebook page") );
- if ( m_nSelection == wxNOT_FOUND || nPage != (size_t)m_nSelection )
+ if ( m_selection == wxNOT_FOUND || nPage != (size_t)m_selection )
{
if ( flags & SetSelection_SendEvent )
{
if ( !SendPageChangingEvent(nPage) )
{
// vetoed by program
- return m_nSelection;
+ return m_selection;
}
//else: program allows the page change
- SendPageChangedEvent(m_nSelection, nPage);
+ SendPageChangedEvent(m_selection, nPage);
}
- ChangePage(m_nSelection, nPage);
+ ChangePage(m_selection, nPage);
}
//else: no change
- return m_nSelection;
+ return m_selection;
}
bool wxNotebook::SetPageText(size_t nPage, const wxString& strText)
MacSetupTabs();
- if (m_nSelection >= (int)GetPageCount())
- m_nSelection = GetPageCount() - 1;
+ if (m_selection >= (int)GetPageCount())
+ m_selection = GetPageCount() - 1;
- if (m_nSelection >= 0)
- m_pages[m_nSelection]->Show(true);
+ if (m_selection >= 0)
+ m_pages[m_selection]->Show(true);
InvalidateBestSize();
{
WX_CLEAR_ARRAY(m_pages) ;
MacSetupTabs();
- m_nSelection = -1 ;
+ m_selection = wxNOT_FOUND ;
InvalidateBestSize();
return true;
// if the inserted page is before the selected one, we must update the
// index of the selected page
- if ( int(nPage) <= m_nSelection )
+ if ( int(nPage) <= m_selection )
{
- m_nSelection++;
+ m_selection++;
// while this still is the same page showing, we need to update the tabs
- m_peer->SetValue( m_nSelection + 1 ) ;
+ m_peer->SetValue( m_selection + 1 ) ;
}
// some page should be selected: either this one or the first one if there
int selNew = wxNOT_FOUND;
if ( bSelect )
selNew = nPage;
- else if ( m_nSelection == -1 )
+ else if ( m_selection == wxNOT_FOUND )
selNew = 0;
if ( selNew != wxNOT_FOUND )
// has become visible for the first time after creation, and
// we postponed showing the page in ChangePage().
// So show the selected page now.
- if ( m_nSelection != -1 )
+ if ( m_selection != wxNOT_FOUND )
{
- wxNotebookPage *pPage = m_pages[m_nSelection];
+ wxNotebookPage *pPage = m_pages[m_selection];
if ( !pPage->IsShown() )
{
pPage->Show( true );
void wxNotebook::OnSetFocus(wxFocusEvent& event)
{
// set focus to the currently selected page if any
- if ( m_nSelection != -1 )
- m_pages[m_nSelection]->SetFocus();
+ if ( m_selection != wxNOT_FOUND )
+ m_pages[m_selection]->SetFocus();
event.Skip();
}
if ( ((wxWindow*)event.GetEventObject()) == parent )
{
// no, it doesn't come from child, case (b): forward to a page
- if ( m_nSelection != -1 )
+ if ( m_selection != wxNOT_FOUND )
{
// so that the page knows that the event comes from it's parent
// and is being propagated downwards
event.SetEventObject( this );
- wxWindow *page = m_pages[m_nSelection];
+ wxWindow *page = m_pages[m_selection];
if ( !page->HandleWindowEvent( event ) )
{
page->SetFocus();
}
}
- m_nSelection = nSel;
- m_peer->SetValue( m_nSelection + 1 ) ;
+ m_selection = nSel;
+ m_peer->SetValue( m_selection + 1 ) ;
}
bool wxNotebook::OSXHandleClicked( double WXUNUSED(timestampsec) )
bool status = false ;
SInt32 newSel = m_peer->GetValue() - 1 ;
- if ( newSel != m_nSelection )
+ if ( newSel != m_selection )
{
wxBookCtrlEvent changing(
wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, m_windowId,
- newSel , m_nSelection );
+ newSel , m_selection );
changing.SetEventObject( this );
HandleWindowEvent( changing );
{
wxBookCtrlEvent event(
wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, m_windowId,
- newSel, m_nSelection );
+ newSel, m_selection );
event.SetEventObject( this );
HandleWindowEvent( event );
}
else
{
- m_peer->SetValue( m_nSelection + 1 ) ;
+ m_peer->SetValue( m_selection + 1 ) ;
}
status = true ;
#define IS_VALID_PAGE(nPage) (((size_t)nPage) < GetPageCount())
#endif
-// ----------------------------------------------------------------------------
-// constants
-// ----------------------------------------------------------------------------
-
-static const size_t INVALID_PAGE = (size_t)-1;
-
// ----------------------------------------------------------------------------
// private classes
// ----------------------------------------------------------------------------
void wxNotebook::Init()
{
- m_sel = INVALID_PAGE;
-
m_heightTab =
m_widthMax = 0;
{
wxCHECK_MSG( IS_VALID_PAGE(nPage), wxNOT_FOUND, wxT("invalid notebook page") );
- if ( (size_t)nPage == m_sel )
+ if ( (size_t)nPage == m_selection )
{
// don't do anything if there is nothing to do
- return m_sel;
+ return m_selection;
}
if ( flags & SetSelection_SendEvent )
if ( !SendPageChangingEvent(nPage) )
{
// program doesn't allow the page change
- return m_sel;
+ return m_selection;
}
}
- // we need to change m_sel first, before calling RefreshTab() below as
+ // we need to change m_selection first, before calling RefreshTab() below as
// otherwise the previously selected tab wouldn't be redrawn properly under
// wxGTK which calls Refresh() immediately and not during the next event
// loop iteration as wxMSW does and as it should
- size_t selOld = m_sel;
+ size_t selOld = m_selection;
- m_sel = nPage;
+ m_selection = nPage;
- if ( selOld != INVALID_PAGE )
+ if ( selOld != wxNOT_FOUND )
{
RefreshTab(selOld, true /* this tab was selected */);
m_pages[selOld]->Hide();
}
- if ( m_sel != INVALID_PAGE ) // this is impossible - but test nevertheless
+ if ( m_selection != wxNOT_FOUND ) // this is impossible - but test nevertheless
{
if ( HasSpinBtn() )
{
// keep it in sync
- m_spinbtn->SetValue(m_sel);
+ m_spinbtn->SetValue(m_selection);
}
- if ( m_sel < m_firstVisible )
+ if ( m_selection < m_firstVisible )
{
// selection is to the left of visible part of tabs
- ScrollTo(m_sel);
+ ScrollTo(m_selection);
}
- else if ( m_sel > m_lastFullyVisible )
+ else if ( m_selection > m_lastFullyVisible )
{
// selection is to the right of visible part of tabs
- ScrollLastTo(m_sel);
+ ScrollLastTo(m_selection);
}
else // we already see this tab
{
// no need to scroll
- RefreshTab(m_sel);
+ RefreshTab(m_selection);
}
- m_pages[m_sel]->SetSize(GetPageRect());
- m_pages[m_sel]->Show();
+ m_pages[m_selection]->SetSize(GetPageRect());
+ m_pages[m_selection]->Show();
}
if ( flags & SetSelection_SendEvent )
m_accels.Clear();
m_widths.Clear();
- // it is not valid any longer
- m_sel = INVALID_PAGE;
-
// spin button is not needed any more
UpdateSpinBtn();
size_t count = GetPageCount();
if ( count )
{
- if ( m_sel == (size_t)nPage )
+ if ( m_selection == (size_t)nPage )
{
// avoid sending event to this page which doesn't exist in the
// notebook any more
- m_sel = INVALID_PAGE;
+ m_selection = wxNOT_FOUND;
SetSelection(nPage == count ? nPage - 1 : nPage);
}
- else if ( m_sel > (size_t)nPage )
+ else if ( m_selection > (size_t)nPage )
{
// no need to change selection, just adjust the index
- m_sel--;
+ m_selection--;
}
}
else // no more tabs left
{
- m_sel = INVALID_PAGE;
+ m_selection = wxNOT_FOUND;
}
// have to refresh everything
void wxNotebook::RefreshCurrent()
{
- if ( m_sel != INVALID_PAGE )
+ if ( m_selection != wxNOT_FOUND )
{
- RefreshTab(m_sel);
+ RefreshTab(m_selection);
}
}
wxCHECK_RET( IS_VALID_PAGE(page), wxT("invalid notebook page") );
wxRect rect = GetTabRect(page);
- if ( forceSelected || ((size_t)page == m_sel) )
+ if ( forceSelected || ((size_t)page == m_selection) )
{
const wxSize indent = GetRenderer()->GetTabIndent();
rect.Inflate(indent.x, indent.y);
}
int flags = 0;
- if ( n == m_sel )
+ if ( n == m_selection )
{
flags |= wxCONTROL_SELECTED;
{
GetTabSize(n, &rect.width, &rect.height);
- if ( n == m_sel )
+ if ( n == m_selection )
{
// don't redraw it now as this tab has to be drawn over the other
// ones as it takes more place and spills over to them
// now redraw the selected tab
if ( rectSel.width )
{
- DoDrawTab(dc, rectSel, m_sel);
+ DoDrawTab(dc, rectSel, m_selection);
}
dc.DestroyClippingRegion();
UpdateSpinBtn();
- if ( m_sel != INVALID_PAGE )
+ if ( m_selection != wxNOT_FOUND )
{
// resize the currently shown page
wxRect rectPage = GetPageRect();
- m_pages[m_sel]->SetSize(rectPage);
+ m_pages[m_selection]->SetSize(rectPage);
// also scroll it into view if needed (note that m_lastVisible
// was updated by the call to UpdateSpinBtn() above, this is why it
// is needed here)
if ( HasSpinBtn() )
{
- if ( m_sel < m_firstVisible )
+ if ( m_selection < m_firstVisible )
{
// selection is to the left of visible part of tabs
- ScrollTo(m_sel);
+ ScrollTo(m_selection);
}
- else if ( m_sel > m_lastFullyVisible )
+ else if ( m_selection > m_lastFullyVisible )
{
// selection is to the right of visible part of tabs
- ScrollLastTo(m_sel);
+ ScrollLastTo(m_selection);
}
}
}
m_spinbtn = new wxNotebookSpinBtn(this);
// set the correct value to keep it in sync
- m_spinbtn->SetValue(m_sel);
+ m_spinbtn->SetValue(m_selection);
}
// position it correctly