Refactor: use wxBookCtrlBase::m_selection in all derived classes.
All book control classes with the exception of wxGTK wxNotebook stored the currently selected page in m_selection or m_nSelection (or, in wxUniv wxNotebook case, m_sel) variable. Remove all of them and add m_selection directly to the base class itself so that it can be reused everywhere. Closes #12622. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65931 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
7e837615b9
commit
681be2ef80
@ -106,7 +106,7 @@ public:
|
||||
}
|
||||
|
||||
// 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;
|
||||
@ -181,6 +181,7 @@ public:
|
||||
// remove all pages and delete them
|
||||
virtual bool DeleteAllPages()
|
||||
{
|
||||
m_selection = wxNOT_FOUND;
|
||||
DoInvalidateBestSize();
|
||||
WX_CLEAR_ARRAY(m_pages);
|
||||
return true;
|
||||
@ -332,6 +333,11 @@ protected:
|
||||
// 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
|
||||
@ -342,6 +348,7 @@ private:
|
||||
|
||||
DECLARE_ABSTRACT_CLASS(wxBookCtrlBase)
|
||||
wxDECLARE_NO_COPY_CLASS(wxBookCtrlBase);
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
|
@ -39,10 +39,7 @@ wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGI
|
||||
class WXDLLIMPEXP_CORE wxChoicebook : public wxBookCtrlBase
|
||||
{
|
||||
public:
|
||||
wxChoicebook()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
wxChoicebook() { }
|
||||
|
||||
wxChoicebook(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
@ -51,8 +48,6 @@ public:
|
||||
long style = 0,
|
||||
const wxString& name = wxEmptyString)
|
||||
{
|
||||
Init();
|
||||
|
||||
(void)Create(parent, id, pos, size, style, name);
|
||||
}
|
||||
|
||||
@ -65,7 +60,6 @@ public:
|
||||
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;
|
||||
@ -102,13 +96,7 @@ protected:
|
||||
// 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)
|
||||
};
|
||||
|
@ -65,8 +65,6 @@ public:
|
||||
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);
|
||||
@ -149,8 +147,6 @@ protected:
|
||||
// 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)
|
||||
|
@ -110,6 +110,9 @@ public:
|
||||
// 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;
|
||||
|
||||
|
@ -39,10 +39,7 @@ wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING
|
||||
class WXDLLIMPEXP_CORE wxListbook : public wxBookCtrlBase
|
||||
{
|
||||
public:
|
||||
wxListbook()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
wxListbook() { }
|
||||
|
||||
wxListbook(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
@ -51,8 +48,6 @@ public:
|
||||
long style = 0,
|
||||
const wxString& name = wxEmptyString)
|
||||
{
|
||||
Init();
|
||||
|
||||
(void)Create(parent, id, pos, size, style, name);
|
||||
}
|
||||
|
||||
@ -66,7 +61,6 @@ public:
|
||||
|
||||
|
||||
// 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;
|
||||
@ -101,13 +95,7 @@ protected:
|
||||
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();
|
||||
|
||||
|
@ -89,8 +89,6 @@ public:
|
||||
// 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);
|
||||
@ -199,7 +197,7 @@ protected:
|
||||
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
|
||||
@ -236,8 +234,6 @@ protected:
|
||||
bool m_hasSubclassedUpdown;
|
||||
#endif // __WXWINCE__
|
||||
|
||||
// the current selection (-1 if none)
|
||||
int m_nSelection;
|
||||
|
||||
wxNotebookPageInfoList m_pageInfos;
|
||||
|
||||
|
@ -69,11 +69,6 @@ public:
|
||||
// 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
|
||||
//
|
||||
@ -193,8 +188,6 @@ protected:
|
||||
// Helper functions
|
||||
//
|
||||
|
||||
int m_nSelection; // The current selection (-1 if none)
|
||||
|
||||
private:
|
||||
wxArrayLong m_alPageId;
|
||||
int m_nTabSize; // holds the largest tab size
|
||||
|
@ -34,7 +34,7 @@ public:
|
||||
// ctors
|
||||
// -----
|
||||
// default for dynamic class
|
||||
wxNotebook();
|
||||
wxNotebook() { }
|
||||
// the same arguments as for wxControl (@@@ any special styles?)
|
||||
wxNotebook(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
@ -42,6 +42,7 @@ public:
|
||||
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,
|
||||
@ -58,8 +59,6 @@ public:
|
||||
// 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); }
|
||||
@ -135,8 +134,6 @@ protected:
|
||||
// the icon indices
|
||||
wxArrayInt m_images;
|
||||
|
||||
int m_nSelection; // the current selection (-1 if none)
|
||||
|
||||
DECLARE_DYNAMIC_CLASS(wxNotebook)
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
@ -70,7 +70,6 @@ public:
|
||||
|
||||
|
||||
// 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;
|
||||
@ -110,9 +109,6 @@ protected:
|
||||
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;
|
||||
|
||||
|
@ -126,7 +126,6 @@ public:
|
||||
// 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;
|
||||
@ -152,9 +151,6 @@ protected:
|
||||
// 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;
|
||||
|
@ -64,7 +64,6 @@ public:
|
||||
// --------------------------------------
|
||||
|
||||
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); }
|
||||
@ -210,9 +209,6 @@ protected:
|
||||
// the pages titles
|
||||
wxArrayString m_titles;
|
||||
|
||||
// the current selection
|
||||
size_t m_sel;
|
||||
|
||||
// the spin button to change the pages
|
||||
wxSpinButton *m_spinbtn;
|
||||
|
||||
|
@ -53,6 +53,7 @@ END_EVENT_TABLE()
|
||||
|
||||
void wxBookCtrlBase::Init()
|
||||
{
|
||||
m_selection = wxNOT_FOUND;
|
||||
m_bookctrl = NULL;
|
||||
m_imageList = NULL;
|
||||
m_ownsImageList = false;
|
||||
|
@ -64,11 +64,6 @@ END_EVENT_TABLE()
|
||||
// wxChoicebook creation
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxChoicebook::Init()
|
||||
{
|
||||
m_selection = wxNOT_FOUND;
|
||||
}
|
||||
|
||||
bool
|
||||
wxChoicebook::Create(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
@ -165,11 +160,6 @@ void wxChoicebook::SetImageList(wxImageList *imageList)
|
||||
// selection
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
int wxChoicebook::GetSelection() const
|
||||
{
|
||||
return m_selection;
|
||||
}
|
||||
|
||||
wxBookCtrlEvent* wxChoicebook::CreatePageChangingEvent() const
|
||||
{
|
||||
return new wxBookCtrlEvent(wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING, m_windowId);
|
||||
@ -254,7 +244,6 @@ wxWindow *wxChoicebook::DoRemovePage(size_t page)
|
||||
|
||||
bool wxChoicebook::DeleteAllPages()
|
||||
{
|
||||
m_selection = wxNOT_FOUND;
|
||||
GetChoiceCtrl()->Clear();
|
||||
return wxBookCtrlBase::DeleteAllPages();
|
||||
}
|
||||
|
@ -85,11 +85,6 @@ END_EVENT_TABLE()
|
||||
// wxListbook creation
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxListbook::Init()
|
||||
{
|
||||
m_selection = wxNOT_FOUND;
|
||||
}
|
||||
|
||||
bool
|
||||
wxListbook::Create(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
@ -311,11 +306,6 @@ void wxListbook::UpdateSelectedPage(size_t newsel)
|
||||
GetListView()->Focus(newsel);
|
||||
}
|
||||
|
||||
int wxListbook::GetSelection() const
|
||||
{
|
||||
return m_selection;
|
||||
}
|
||||
|
||||
wxBookCtrlEvent* wxListbook::CreatePageChangingEvent() const
|
||||
{
|
||||
return new wxBookCtrlEvent(wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING, m_windowId);
|
||||
@ -411,8 +401,6 @@ bool wxListbook::DeleteAllPages()
|
||||
if (!wxBookCtrlBase::DeleteAllPages())
|
||||
return false;
|
||||
|
||||
m_selection = -1;
|
||||
|
||||
UpdateSize();
|
||||
|
||||
return true;
|
||||
|
@ -64,7 +64,6 @@ END_EVENT_TABLE()
|
||||
|
||||
void wxToolbook::Init()
|
||||
{
|
||||
m_selection = wxNOT_FOUND;
|
||||
m_needsRealizing = false;
|
||||
}
|
||||
|
||||
@ -201,11 +200,6 @@ void wxToolbook::SetImageList(wxImageList *imageList)
|
||||
// selection
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
int wxToolbook::GetSelection() const
|
||||
{
|
||||
return m_selection;
|
||||
}
|
||||
|
||||
wxBookCtrlEvent* wxToolbook::CreatePageChangingEvent() const
|
||||
{
|
||||
return new wxBookCtrlEvent(wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGING, m_windowId);
|
||||
|
@ -556,11 +556,6 @@ bool wxTreebook::SetPageImage(size_t n, int imageId)
|
||||
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,
|
||||
|
@ -61,10 +61,11 @@ static void event_after(GtkNotebook*, GdkEvent*, wxNotebook*);
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
@ -245,6 +246,8 @@ int wxNotebook::DoSetSelection( size_t page, int flags )
|
||||
g_signal_handlers_unblock_by_func(m_widget, (void*)switch_page, this);
|
||||
}
|
||||
|
||||
m_selection = page;
|
||||
|
||||
wxNotebookPage *client = GetPage(page);
|
||||
if ( client )
|
||||
client->SetFocus();
|
||||
@ -252,6 +255,13 @@ int wxNotebook::DoSetSelection( size_t page, int flags )
|
||||
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");
|
||||
|
@ -107,7 +107,7 @@ static void gtk_notebook_page_change_callback(GtkNotebook *WXUNUSED(widget),
|
||||
// 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
|
||||
{
|
||||
@ -121,7 +121,7 @@ static void gtk_notebook_page_change_callback(GtkNotebook *WXUNUSED(widget),
|
||||
// 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);
|
||||
}
|
||||
@ -292,7 +292,6 @@ void wxNotebook::Init()
|
||||
m_inSwitchPage = false;
|
||||
|
||||
m_imageList = NULL;
|
||||
m_selection = -1;
|
||||
m_themeEnabled = true;
|
||||
}
|
||||
|
||||
@ -375,8 +374,8 @@ int wxNotebook::GetSelection() const
|
||||
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 ));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -240,7 +240,6 @@ const wxNotebookPageInfoList& wxNotebook::GetPageInfos() const
|
||||
void wxNotebook::Init()
|
||||
{
|
||||
m_imageList = NULL;
|
||||
m_nSelection = wxNOT_FOUND;
|
||||
|
||||
#if wxUSE_UXTHEME
|
||||
m_hbrBackground = NULL;
|
||||
@ -451,24 +450,24 @@ int wxNotebook::SetSelection(size_t nPage)
|
||||
{
|
||||
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 )
|
||||
{
|
||||
@ -486,16 +485,16 @@ void wxNotebook::UpdateSelection(int selNew)
|
||||
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);
|
||||
|
||||
@ -697,7 +696,7 @@ wxNotebookPage *wxNotebook::DoRemovePage(size_t 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
|
||||
{
|
||||
@ -708,22 +707,22 @@ wxNotebookPage *wxNotebook::DoRemovePage(size_t nPage)
|
||||
// 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
|
||||
@ -747,7 +746,7 @@ bool wxNotebook::DeleteAllPages()
|
||||
|
||||
TabCtrl_DeleteAllItems(GetHwnd());
|
||||
|
||||
m_nSelection = wxNOT_FOUND;
|
||||
m_selection = wxNOT_FOUND;
|
||||
|
||||
InvalidateBestSize();
|
||||
return true;
|
||||
@ -837,10 +836,10 @@ bool wxNotebook::InsertPage(size_t nPage,
|
||||
|
||||
// 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
|
||||
@ -848,7 +847,7 @@ bool wxNotebook::InsertPage(size_t nPage,
|
||||
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 )
|
||||
@ -1149,14 +1148,14 @@ void wxNotebook::OnNavigationKey(wxNavigationKeyEvent& event)
|
||||
// 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();
|
||||
@ -1451,7 +1450,7 @@ bool wxNotebook::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM* result)
|
||||
}
|
||||
|
||||
event.SetSelection(TabCtrl_GetCurSel(GetHwnd()));
|
||||
event.SetOldSelection(m_nSelection);
|
||||
event.SetOldSelection(m_selection);
|
||||
event.SetEventObject(this);
|
||||
event.SetInt(idCtrl);
|
||||
|
||||
|
@ -76,7 +76,6 @@ IMPLEMENT_DYNAMIC_CLASS(wxNotebook, wxBookCtrlBase)
|
||||
void wxNotebook::Init()
|
||||
{
|
||||
m_imageList = NULL;
|
||||
m_nSelection = -1;
|
||||
m_nTabSize = 0;
|
||||
} // end of wxNotebook::Init
|
||||
|
||||
@ -210,14 +209,14 @@ int wxNotebook::SetSelection( size_t nPage )
|
||||
{
|
||||
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())
|
||||
{
|
||||
@ -235,7 +234,7 @@ int wxNotebook::SetSelection( size_t nPage )
|
||||
);
|
||||
}
|
||||
}
|
||||
m_nSelection = nPage;
|
||||
m_selection = nPage;
|
||||
return nPage;
|
||||
} // end of wxNotebook::SetSelection
|
||||
|
||||
@ -243,7 +242,7 @@ int wxNotebook::ChangeSelection( size_t nPage )
|
||||
{
|
||||
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
|
||||
@ -251,7 +250,7 @@ int wxNotebook::ChangeSelection( size_t nPage )
|
||||
,(MPARAM)0
|
||||
);
|
||||
}
|
||||
m_nSelection = nPage;
|
||||
m_selection = nPage;
|
||||
return nPage;
|
||||
}
|
||||
|
||||
@ -404,7 +403,7 @@ wxNotebookPage* wxNotebook::DoRemovePage ( size_t nPage )
|
||||
//
|
||||
// No selection any more, the notebook becamse empty
|
||||
//
|
||||
m_nSelection = -1;
|
||||
m_selection = wxNOT_FOUND;
|
||||
}
|
||||
else // notebook still not empty
|
||||
{
|
||||
@ -413,19 +412,19 @@ wxNotebookPage* wxNotebook::DoRemovePage ( size_t nPage )
|
||||
//
|
||||
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
|
||||
{
|
||||
@ -437,16 +436,16 @@ wxNotebookPage* wxNotebook::DoRemovePage ( size_t nPage )
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
@ -469,7 +468,7 @@ bool wxNotebook::DeleteAllPages()
|
||||
,(MPARAM)0
|
||||
,(MPARAM)BKA_ALL
|
||||
);
|
||||
m_nSelection = -1;
|
||||
m_selection = wxNOT_FOUND;
|
||||
|
||||
return true;
|
||||
} // end of wxNotebook::DeleteAllPages
|
||||
@ -569,12 +568,12 @@ bool wxNotebook::InsertPage ( size_t nPage,
|
||||
// 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)
|
||||
@ -657,7 +656,7 @@ bool wxNotebook::InsertPage ( size_t nPage,
|
||||
|
||||
if (bSelect)
|
||||
nSelNew = nPage;
|
||||
else if ( m_nSelection == -1 )
|
||||
else if ( m_selection == wxNOT_FOUND )
|
||||
nSelNew = 0;
|
||||
|
||||
if (nSelNew != wxNOT_FOUND)
|
||||
@ -725,7 +724,7 @@ void wxNotebook::OnSelChange (
|
||||
wxNotebookPage* pPage = m_pages[nSel];
|
||||
|
||||
pPage->Show(true);
|
||||
m_nSelection = nSel;
|
||||
m_selection = nSel;
|
||||
}
|
||||
|
||||
//
|
||||
@ -746,8 +745,8 @@ void wxNotebook::OnSetFocus (
|
||||
//
|
||||
// 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
|
||||
|
||||
@ -786,7 +785,7 @@ void wxNotebook::OnNavigationKey (
|
||||
//
|
||||
// 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
|
||||
@ -794,7 +793,7 @@ void wxNotebook::OnNavigationKey (
|
||||
//
|
||||
rEvent.SetEventObject(this);
|
||||
|
||||
wxWindow* pPage = m_pages[m_nSelection];
|
||||
wxWindow* pPage = m_pages[m_selection];
|
||||
|
||||
if (!pPage->HandleWindowEvent(rEvent))
|
||||
{
|
||||
|
@ -40,32 +40,6 @@ END_EVENT_TABLE()
|
||||
|
||||
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,
|
||||
@ -121,25 +95,25 @@ int wxNotebook::DoSetSelection(size_t nPage, int flags)
|
||||
{
|
||||
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)
|
||||
@ -204,11 +178,11 @@ wxNotebookPage* wxNotebook::DoRemovePage(size_t nPage)
|
||||
|
||||
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();
|
||||
|
||||
@ -220,7 +194,7 @@ bool wxNotebook::DeleteAllPages()
|
||||
{
|
||||
WX_CLEAR_ARRAY(m_pages) ;
|
||||
MacSetupTabs();
|
||||
m_nSelection = -1 ;
|
||||
m_selection = wxNOT_FOUND ;
|
||||
InvalidateBestSize();
|
||||
|
||||
return true;
|
||||
@ -258,12 +232,12 @@ bool wxNotebook::InsertPage(size_t nPage,
|
||||
// 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
|
||||
@ -271,7 +245,7 @@ bool wxNotebook::InsertPage(size_t nPage,
|
||||
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 )
|
||||
@ -380,9 +354,9 @@ void wxNotebook::OnSize(wxSizeEvent& event)
|
||||
// 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 );
|
||||
@ -407,8 +381,8 @@ void wxNotebook::OnSelChange(wxBookCtrlEvent& event)
|
||||
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();
|
||||
}
|
||||
@ -441,13 +415,13 @@ void wxNotebook::OnNavigationKey(wxNavigationKeyEvent& event)
|
||||
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();
|
||||
@ -530,8 +504,8 @@ void wxNotebook::ChangePage(int nOldSel, int nSel)
|
||||
}
|
||||
}
|
||||
|
||||
m_nSelection = nSel;
|
||||
m_peer->SetValue( m_nSelection + 1 ) ;
|
||||
m_selection = nSel;
|
||||
m_peer->SetValue( m_selection + 1 ) ;
|
||||
}
|
||||
|
||||
bool wxNotebook::OSXHandleClicked( double WXUNUSED(timestampsec) )
|
||||
@ -539,11 +513,11 @@ 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 );
|
||||
|
||||
@ -551,13 +525,13 @@ bool wxNotebook::OSXHandleClicked( double WXUNUSED(timestampsec) )
|
||||
{
|
||||
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 ;
|
||||
|
@ -70,12 +70,6 @@ protected:
|
||||
#define IS_VALID_PAGE(nPage) (((size_t)nPage) < GetPageCount())
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// constants
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
static const size_t INVALID_PAGE = (size_t)-1;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// private classes
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -119,8 +113,6 @@ IMPLEMENT_DYNAMIC_CLASS(wxNotebook, wxBookCtrlBase)
|
||||
|
||||
void wxNotebook::Init()
|
||||
{
|
||||
m_sel = INVALID_PAGE;
|
||||
|
||||
m_heightTab =
|
||||
m_widthMax = 0;
|
||||
|
||||
@ -233,10 +225,10 @@ int wxNotebook::DoSetSelection(size_t nPage, int flags)
|
||||
{
|
||||
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 )
|
||||
@ -244,51 +236,51 @@ int wxNotebook::DoSetSelection(size_t nPage, int flags)
|
||||
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 )
|
||||
@ -376,9 +368,6 @@ bool wxNotebook::DeleteAllPages()
|
||||
m_accels.Clear();
|
||||
m_widths.Clear();
|
||||
|
||||
// it is not valid any longer
|
||||
m_sel = INVALID_PAGE;
|
||||
|
||||
// spin button is not needed any more
|
||||
UpdateSpinBtn();
|
||||
|
||||
@ -411,23 +400,23 @@ wxNotebookPage *wxNotebook::DoRemovePage(size_t nPage)
|
||||
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
|
||||
@ -442,9 +431,9 @@ wxNotebookPage *wxNotebook::DoRemovePage(size_t nPage)
|
||||
|
||||
void wxNotebook::RefreshCurrent()
|
||||
{
|
||||
if ( m_sel != INVALID_PAGE )
|
||||
if ( m_selection != wxNOT_FOUND )
|
||||
{
|
||||
RefreshTab(m_sel);
|
||||
RefreshTab(m_selection);
|
||||
}
|
||||
}
|
||||
|
||||
@ -453,7 +442,7 @@ void wxNotebook::RefreshTab(int page, bool forceSelected)
|
||||
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);
|
||||
@ -496,7 +485,7 @@ void wxNotebook::DoDrawTab(wxDC& dc, const wxRect& rect, size_t n)
|
||||
}
|
||||
|
||||
int flags = 0;
|
||||
if ( n == m_sel )
|
||||
if ( n == m_selection )
|
||||
{
|
||||
flags |= wxCONTROL_SELECTED;
|
||||
|
||||
@ -560,7 +549,7 @@ void wxNotebook::DoDraw(wxControlRenderer *renderer)
|
||||
{
|
||||
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
|
||||
@ -591,7 +580,7 @@ void wxNotebook::DoDraw(wxControlRenderer *renderer)
|
||||
// now redraw the selected tab
|
||||
if ( rectSel.width )
|
||||
{
|
||||
DoDrawTab(dc, rectSel, m_sel);
|
||||
DoDrawTab(dc, rectSel, m_selection);
|
||||
}
|
||||
|
||||
dc.DestroyClippingRegion();
|
||||
@ -908,27 +897,27 @@ void wxNotebook::Relayout()
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1133,7 +1122,7 @@ void wxNotebook::UpdateSpinBtn()
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user