X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/14f355c2b5c71fc7c3d680aea366582d2ac60f7b..9a78988fedc6e5364368cd09e60308180d3a7425:/src/msw/notebook.cpp diff --git a/src/msw/notebook.cpp b/src/msw/notebook.cpp index 37ae63235e..9110079e5f 100644 --- a/src/msw/notebook.cpp +++ b/src/msw/notebook.cpp @@ -68,22 +68,12 @@ #include "wx/panel.h" #endif -/* - notebookpage - object - object_ref - label - selected - style - usenotebooksizer -*/ - // ---------------------------------------------------------------------------- // macros // ---------------------------------------------------------------------------- // check that the page index is valid -#define IS_VALID_PAGE(nPage) (((nPage) >= 0) && ((nPage) < GetPageCount())) +#define IS_VALID_PAGE(nPage) ((nPage) < GetPageCount()) // hide the ugly cast #define m_hwnd (HWND)GetHWND() @@ -109,6 +99,10 @@ // event table // ---------------------------------------------------------------------------- +#include + +WX_DEFINE_LIST( wxNotebookPageInfoList ) ; + DEFINE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED) DEFINE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING) @@ -123,18 +117,82 @@ BEGIN_EVENT_TABLE(wxNotebook, wxControl) END_EVENT_TABLE() #if wxUSE_EXTENDED_RTTI +WX_DEFINE_FLAGS( wxNotebookStyle ) + +wxBEGIN_FLAGS( wxNotebookStyle ) + // new style border flags, we put them first to + // use them for streaming out + wxFLAGS_MEMBER(wxBORDER_SIMPLE) + wxFLAGS_MEMBER(wxBORDER_SUNKEN) + wxFLAGS_MEMBER(wxBORDER_DOUBLE) + wxFLAGS_MEMBER(wxBORDER_RAISED) + wxFLAGS_MEMBER(wxBORDER_STATIC) + wxFLAGS_MEMBER(wxBORDER_NONE) + + // old style border flags + wxFLAGS_MEMBER(wxSIMPLE_BORDER) + wxFLAGS_MEMBER(wxSUNKEN_BORDER) + wxFLAGS_MEMBER(wxDOUBLE_BORDER) + wxFLAGS_MEMBER(wxRAISED_BORDER) + wxFLAGS_MEMBER(wxSTATIC_BORDER) + wxFLAGS_MEMBER(wxNO_BORDER) + + // standard window styles + wxFLAGS_MEMBER(wxTAB_TRAVERSAL) + wxFLAGS_MEMBER(wxCLIP_CHILDREN) + wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW) + wxFLAGS_MEMBER(wxWANTS_CHARS) + wxFLAGS_MEMBER(wxNO_FULL_REPAINT_ON_RESIZE) + wxFLAGS_MEMBER(wxALWAYS_SHOW_SB ) + wxFLAGS_MEMBER(wxVSCROLL) + wxFLAGS_MEMBER(wxHSCROLL) + + wxFLAGS_MEMBER(wxNB_FIXEDWIDTH) + wxFLAGS_MEMBER(wxNB_LEFT) + wxFLAGS_MEMBER(wxNB_RIGHT) + wxFLAGS_MEMBER(wxNB_BOTTOM) + +wxEND_FLAGS( wxNotebookStyle ) + IMPLEMENT_DYNAMIC_CLASS_XTI(wxNotebook, wxControl,"wx/notebook.h") +IMPLEMENT_DYNAMIC_CLASS_XTI(wxNotebookPageInfo, wxObject , "wx/notebook.h" ) + +wxCOLLECTION_TYPE_INFO( wxNotebookPageInfo * , wxNotebookPageInfoList ) ; + +template<> void wxCollectionToVariantArray( wxNotebookPageInfoList const &theList, wxxVariantArray &value) +{ + wxListCollectionToVariantArray( theList , value ) ; +} + +wxBEGIN_PROPERTIES_TABLE(wxNotebook) + wxEVENT_PROPERTY( PageChanging , wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING , wxNotebookEvent ) + wxEVENT_PROPERTY( PageChanged , wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED , wxNotebookEvent ) -WX_BEGIN_PROPERTIES_TABLE(wxNotebook) -WX_END_PROPERTIES_TABLE() + wxPROPERTY_COLLECTION( PageInfos , wxNotebookPageInfoList , wxNotebookPageInfo* , AddPageInfo , GetPageInfos , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) + wxPROPERTY_FLAGS( WindowStyle , wxNotebookStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style +wxEND_PROPERTIES_TABLE() -WX_BEGIN_HANDLERS_TABLE(wxNotebook) -WX_END_HANDLERS_TABLE() +wxBEGIN_HANDLERS_TABLE(wxNotebook) +wxEND_HANDLERS_TABLE() -WX_CONSTRUCTOR_4( wxNotebook , wxWindow* , Parent , wxWindowID , Id , wxPoint , Position , wxSize , Size ) +wxCONSTRUCTOR_5( wxNotebook , wxWindow* , Parent , wxWindowID , Id , wxPoint , Position , wxSize , Size , long , WindowStyle) + + +wxBEGIN_PROPERTIES_TABLE(wxNotebookPageInfo) + wxREADONLY_PROPERTY( Page , wxNotebookPage* , GetPage , , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) + wxREADONLY_PROPERTY( Text , wxString , GetText , wxString() , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) + wxREADONLY_PROPERTY( Selected , bool , GetSelected , false, 0 /*flags*/ , wxT("Helpstring") , wxT("group") ) + wxREADONLY_PROPERTY( ImageId , int , GetImageId , -1 , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) +wxEND_PROPERTIES_TABLE() + +wxBEGIN_HANDLERS_TABLE(wxNotebookPageInfo) +wxEND_HANDLERS_TABLE() + +wxCONSTRUCTOR_4( wxNotebookPageInfo , wxNotebookPage* , Page , wxString , Text , bool , Selected , int , ImageId ) #else IMPLEMENT_DYNAMIC_CLASS(wxNotebook, wxControl) +IMPLEMENT_DYNAMIC_CLASS(wxNotebookPageInfo, wxObject ) #endif IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent, wxNotifyEvent) @@ -146,6 +204,19 @@ IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent, wxNotifyEvent) // wxNotebook construction // ---------------------------------------------------------------------------- +const wxNotebookPageInfoList& wxNotebook::GetPageInfos() const +{ + wxNotebookPageInfoList* list = const_cast< wxNotebookPageInfoList* >( &m_pageInfos ) ; + WX_CLEAR_LIST( wxNotebookPageInfoList , *list ) ; + for( size_t i = 0 ; i < GetPageCount() ; ++i ) + { + wxNotebookPageInfo *info = new wxNotebookPageInfo() ; + info->Create( const_cast(this)->GetPage(i) , GetPageText(i) , GetSelection() == int(i) , GetPageImage(i) ) ; + list->Append( info ) ; + } + return m_pageInfos ; +} + // common part of all ctors void wxNotebook::Init() { @@ -239,7 +310,7 @@ WXDWORD wxNotebook::MSWGetStyle(long style, WXDWORD *exstyle) const // wxNotebook accessors // ---------------------------------------------------------------------------- -int wxNotebook::GetPageCount() const +size_t wxNotebook::GetPageCount() const { // consistency check wxASSERT( (int)m_pages.Count() == TabCtrl_GetItemCount(m_hwnd) ); @@ -252,11 +323,11 @@ int wxNotebook::GetRowCount() const return TabCtrl_GetRowCount(m_hwnd); } -int wxNotebook::SetSelection(int nPage) +int wxNotebook::SetSelection(size_t nPage) { wxCHECK_MSG( IS_VALID_PAGE(nPage), -1, wxT("notebook page out of range") ); - if ( nPage != m_nSelection ) + if ( int(nPage) != m_nSelection ) { wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, m_windowId); event.SetSelection(nPage); @@ -275,7 +346,7 @@ int wxNotebook::SetSelection(int nPage) return m_nSelection; } -bool wxNotebook::SetPageText(int nPage, const wxString& strText) +bool wxNotebook::SetPageText(size_t nPage, const wxString& strText) { wxCHECK_MSG( IS_VALID_PAGE(nPage), FALSE, wxT("notebook page out of range") ); @@ -286,7 +357,7 @@ bool wxNotebook::SetPageText(int nPage, const wxString& strText) return TabCtrl_SetItem(m_hwnd, nPage, &tcItem) != 0; } -wxString wxNotebook::GetPageText(int nPage) const +wxString wxNotebook::GetPageText(size_t nPage) const { wxCHECK_MSG( IS_VALID_PAGE(nPage), wxEmptyString, wxT("notebook page out of range") ); @@ -303,7 +374,7 @@ wxString wxNotebook::GetPageText(int nPage) const return str; } -int wxNotebook::GetPageImage(int nPage) const +int wxNotebook::GetPageImage(size_t nPage) const { wxCHECK_MSG( IS_VALID_PAGE(nPage), -1, wxT("notebook page out of range") ); @@ -313,7 +384,7 @@ int wxNotebook::GetPageImage(int nPage) const return TabCtrl_GetItem(m_hwnd, nPage, &tcItem) ? tcItem.iImage : -1; } -bool wxNotebook::SetPageImage(int nPage, int nImage) +bool wxNotebook::SetPageImage(size_t nPage, int nImage) { wxCHECK_MSG( IS_VALID_PAGE(nPage), FALSE, wxT("notebook page out of range") ); @@ -412,7 +483,7 @@ void wxNotebook::AdjustPageSize(wxNotebookPage *page) // ---------------------------------------------------------------------------- // remove one page from the notebook, without deleting -wxNotebookPage *wxNotebook::DoRemovePage(int nPage) +wxNotebookPage *wxNotebook::DoRemovePage(size_t nPage) { wxNotebookPage *pageRemoved = wxNotebookBase::DoRemovePage(nPage); if ( !pageRemoved ) @@ -429,12 +500,12 @@ wxNotebookPage *wxNotebook::DoRemovePage(int nPage) { // change the selected page if it was deleted or became invalid int selNew; - if ( m_nSelection == GetPageCount() ) + if ( m_nSelection == int(GetPageCount()) ) { // last page deleted, make the new last page the new selection selNew = m_nSelection - 1; } - else if ( nPage <= m_nSelection ) + else if ( int(nPage) <= m_nSelection ) { // we must show another page, even if it has the same index selNew = m_nSelection; @@ -466,8 +537,8 @@ wxNotebookPage *wxNotebook::DoRemovePage(int nPage) // remove all pages bool wxNotebook::DeleteAllPages() { - int nPageCount = GetPageCount(); - int nPage; + size_t nPageCount = GetPageCount(); + size_t nPage; for ( nPage = 0; nPage < nPageCount; nPage++ ) delete m_pages[nPage]; @@ -481,7 +552,7 @@ bool wxNotebook::DeleteAllPages() } // same as AddPage() but does it at given position -bool wxNotebook::InsertPage(int nPage, +bool wxNotebook::InsertPage(size_t nPage, wxNotebookPage *pPage, const wxString& strText, bool bSelect, @@ -575,7 +646,7 @@ bool wxNotebook::InsertPage(int nPage, // if the inserted page is before the selected one, we must update the // index of the selected page - if ( nPage <= m_nSelection ) + if ( int(nPage) <= m_nSelection ) { // one extra page added m_nSelection++;