From 222ed1d678dff2f5c3c4164321dd05e8f47de487 Mon Sep 17 00:00:00 2001 From: Mattia Barbon Date: Thu, 10 Jul 2003 19:55:12 +0000 Subject: [PATCH] STL-ification patch for wxMSW and wxGTK. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@21876 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/cmdproc.h | 2 +- include/wx/dataobj.h | 1 + include/wx/gdicmn.h | 37 ++++++++----- include/wx/paper.h | 13 ++++- src/common/appcmn.cpp | 12 ++--- src/common/artprov.cpp | 7 +-- src/common/cmdproc.cpp | 25 +++++---- src/common/containr.cpp | 10 ++-- src/common/dcbase.cpp | 14 ++--- src/common/dobjcmn.cpp | 11 ++-- src/common/docview.cpp | 38 +++++++------- src/common/gdicmn.cpp | 111 ++++++++++++++++++++------------------- src/common/image.cpp | 32 +++++------ src/common/layout.cpp | 2 +- src/common/menucmn.cpp | 50 ++++++++---------- src/common/paper.cpp | 82 ++++++++++++++++++++--------- src/common/sizer.cpp | 68 +++++++++++++----------- src/common/statbar.cpp | 9 ++-- src/common/tbarbase.cpp | 30 +++++------ src/common/toplvcmn.cpp | 2 +- src/common/valtext.cpp | 47 ++--------------- src/common/wincmn.cpp | 71 +++++++++++++------------ src/generic/accel.cpp | 14 +++-- src/generic/dcpsg.cpp | 4 +- src/generic/dirctrlg.cpp | 17 +++--- src/generic/imaglist.cpp | 23 ++++---- src/generic/laywin.cpp | 4 +- src/generic/listctrl.cpp | 57 +++++++++++--------- src/generic/prntdlgg.cpp | 10 ++-- src/generic/tbarsmpl.cpp | 6 +-- src/gtk/choice.cpp | 10 ++-- src/gtk/colour.cpp | 7 +-- src/gtk/combobox.cpp | 20 +++---- src/gtk/listbox.cpp | 20 +++---- src/gtk/mdi.cpp | 6 +-- src/gtk/menu.cpp | 32 +++++------ src/gtk/notebook.cpp | 5 +- src/gtk/radiobox.cpp | 40 +++++++------- src/gtk/radiobut.cpp | 2 +- src/gtk/tbargtk.cpp | 7 +-- src/gtk/window.cpp | 8 +-- src/gtk1/choice.cpp | 10 ++-- src/gtk1/colour.cpp | 7 +-- src/gtk1/combobox.cpp | 20 +++---- src/gtk1/listbox.cpp | 20 +++---- src/gtk1/mdi.cpp | 6 +-- src/gtk1/menu.cpp | 32 +++++------ src/gtk1/notebook.cpp | 5 +- src/gtk1/radiobox.cpp | 40 +++++++------- src/gtk1/radiobut.cpp | 2 +- src/gtk1/tbargtk.cpp | 7 +-- src/gtk1/window.cpp | 8 +-- src/html/helpctrl.cpp | 2 +- src/html/helpfrm.cpp | 5 +- src/html/htmlpars.cpp | 23 +++++--- src/html/htmlwin.cpp | 21 ++++---- src/html/htmprint.cpp | 5 +- src/html/winpars.cpp | 2 +- src/msw/dialog.cpp | 2 +- src/msw/filedlg.cpp | 2 +- src/msw/frame.cpp | 2 +- src/msw/gdiimage.cpp | 12 ++--- src/msw/mdi.cpp | 4 +- src/msw/menu.cpp | 22 ++++---- src/msw/menuitem.cpp | 2 +- src/msw/nativdlg.cpp | 2 +- src/msw/radiobut.cpp | 6 +-- src/msw/taskbar.cpp | 2 +- src/msw/tbar95.cpp | 10 ++-- src/msw/timer.cpp | 25 ++++++--- src/msw/treectrl.cpp | 3 +- src/msw/window.cpp | 12 ++--- src/x11/colour.cpp | 4 +- 73 files changed, 668 insertions(+), 623 deletions(-) diff --git a/include/wx/cmdproc.h b/include/wx/cmdproc.h index d630a15224..970922d40b 100644 --- a/include/wx/cmdproc.h +++ b/include/wx/cmdproc.h @@ -114,7 +114,7 @@ protected: int m_maxNoCommands; wxList m_commands; - wxNode* m_currentCommand; + wxList::compatibility_iterator m_currentCommand; #if wxUSE_MENUS wxMenu* m_commandEditMenu; diff --git a/include/wx/dataobj.h b/include/wx/dataobj.h index 4aa203de82..a80b6a4c6e 100644 --- a/include/wx/dataobj.h +++ b/include/wx/dataobj.h @@ -260,6 +260,7 @@ class WXDLLEXPORT wxDataObjectComposite : public wxDataObject public: // ctor wxDataObjectComposite(); + virtual ~wxDataObjectComposite(); // add data object (it will be deleted by wxDataObjectComposite, hence it // must be allocated on the heap) whose format will become the preferred diff --git a/include/wx/gdicmn.h b/include/wx/gdicmn.h index 3b5fb2e410..ae96ef1794 100644 --- a/include/wx/gdicmn.h +++ b/include/wx/gdicmn.h @@ -377,11 +377,11 @@ typedef wxInt8 wxDash; class WXDLLEXPORT wxPenList : public wxList { - DECLARE_DYNAMIC_CLASS(wxPenList) + // DECLARE_DYNAMIC_CLASS(wxPenList) public: wxPenList() { } - ~wxPenList(); + virtual ~wxPenList(); void AddPen(wxPen *pen); void RemovePen(wxPen *pen); @@ -390,11 +390,11 @@ public: class WXDLLEXPORT wxBrushList : public wxList { - DECLARE_DYNAMIC_CLASS(wxBrushList) + // DECLARE_DYNAMIC_CLASS(wxBrushList) public: wxBrushList() { } - ~wxBrushList(); + virtual ~wxBrushList(); void AddBrush(wxBrush *brush); void RemoveBrush(wxBrush *brush); @@ -403,11 +403,11 @@ public: class WXDLLEXPORT wxFontList : public wxList { - DECLARE_DYNAMIC_CLASS(wxFontList) + // DECLARE_DYNAMIC_CLASS(wxFontList) public: wxFontList() { } - ~wxFontList(); + virtual ~wxFontList(); void AddFont(wxFont *font); void RemoveFont(wxFont *font); @@ -417,16 +417,19 @@ public: wxFontEncoding encoding = wxFONTENCODING_DEFAULT); }; -class WXDLLEXPORT wxColourDatabase : public wxList +class WXDLLEXPORT wxStringToColourHashMap; + +class WXDLLEXPORT wxColourDatabase { - DECLARE_CLASS(wxColourDatabase) + // DECLARE_CLASS(wxColourDatabase) public: - wxColourDatabase(int type); - ~wxColourDatabase() ; + wxColourDatabase(); + virtual ~wxColourDatabase() ; // Not const because it may add a name to the database wxColour *FindColour(const wxString& colour) ; + wxColour *FindColourNoAdd(const wxString& colour) const; wxString FindName(const wxColour& colour) const; void Initialize(); #ifdef __WXPM__ @@ -434,15 +437,19 @@ public: long* m_palTable; size_t m_nSize; #endif +private: + wxColour* FindColour(const wxString& colour, bool add); + + wxStringToColourHashMap* m_map; }; class WXDLLEXPORT wxBitmapList : public wxList { - DECLARE_DYNAMIC_CLASS(wxBitmapList) + // DECLARE_DYNAMIC_CLASS(wxBitmapList) public: wxBitmapList(); - ~wxBitmapList(); + virtual ~wxBitmapList(); void AddBitmap(wxBitmap *bitmap); void RemoveBitmap(wxBitmap *bitmap); @@ -452,11 +459,13 @@ class WXDLLEXPORT wxResourceCache: public wxList { public: wxResourceCache() { } +#if !wxUSE_STL wxResourceCache(const unsigned int keyType) : wxList(keyType) { } - ~wxResourceCache(); +#endif + virtual ~wxResourceCache(); private: - DECLARE_DYNAMIC_CLASS(wxResourceCache) + // DECLARE_DYNAMIC_CLASS(wxResourceCache) }; // --------------------------------------------------------------------------- diff --git a/include/wx/paper.h b/include/wx/paper.h index 6be58b4ce4..d6703eb299 100644 --- a/include/wx/paper.h +++ b/include/wx/paper.h @@ -69,10 +69,14 @@ private: DECLARE_DYNAMIC_CLASS(wxPrintPaperType) }; -class WXDLLEXPORT wxPrintPaperDatabase: public wxList +class WXDLLEXPORT wxStringToPrintPaperTypeHashMap; +class WXDLLEXPORT wxPrintPaperTypeList; + +class WXDLLEXPORT wxPrintPaperDatabase { public: wxPrintPaperDatabase(); + ~wxPrintPaperDatabase(); void CreateDatabase(); void ClearDatabase(); @@ -104,8 +108,13 @@ public: // Get the paper size wxPaperSize GetSize(const wxSize& size); + // + wxPrintPaperType* Item(size_t index) const; + size_t GetCount() const; private: - DECLARE_DYNAMIC_CLASS(wxPrintPaperDatabase) + wxStringToPrintPaperTypeHashMap* m_map; + wxPrintPaperTypeList* m_list; + // DECLARE_DYNAMIC_CLASS(wxPrintPaperDatabase) }; WXDLLEXPORT_DATA(extern wxPrintPaperDatabase*) wxThePrintPaperDatabase; diff --git a/src/common/appcmn.cpp b/src/common/appcmn.cpp index 9424db3196..97c2f5eb2d 100644 --- a/src/common/appcmn.cpp +++ b/src/common/appcmn.cpp @@ -85,7 +85,7 @@ bool wxAppBase::Initialize(int& argc, wxChar **argv) wxPendingEventsLocker = new wxCriticalSection; #endif - wxTheColourDatabase = new wxColourDatabase(wxKEY_STRING); + wxTheColourDatabase = new wxColourDatabase; wxTheColourDatabase->Initialize(); wxInitializeStockLists(); @@ -189,7 +189,7 @@ void wxAppBase::SetActive(bool active, wxWindow * WXUNUSED(lastFocus)) void wxAppBase::DeletePendingObjects() { - wxNode *node = wxPendingDelete.GetFirst(); + wxList::compatibility_iterator node = wxPendingDelete.GetFirst(); while (node) { wxObject *obj = node->GetData(); @@ -197,7 +197,7 @@ void wxAppBase::DeletePendingObjects() delete obj; if (wxPendingDelete.Member(obj)) - delete node; + wxPendingDelete.Erase(node); // Deleting one object may have deleted other pending // objects, so start from beginning of list again. @@ -208,7 +208,7 @@ void wxAppBase::DeletePendingObjects() // Returns TRUE if more time is needed. bool wxAppBase::ProcessIdle() { - wxWindowList::Node* node = wxTopLevelWindows.GetFirst(); + wxWindowList::compatibility_iterator node = wxTopLevelWindows.GetFirst(); node = wxTopLevelWindows.GetFirst(); while (node) { @@ -231,7 +231,7 @@ bool wxAppBase::SendIdleEvents() { bool needMore = FALSE; - wxWindowList::Node* node = wxTopLevelWindows.GetFirst(); + wxWindowList::compatibility_iterator node = wxTopLevelWindows.GetFirst(); while (node) { wxWindow* win = node->GetData(); @@ -257,7 +257,7 @@ bool wxAppBase::SendIdleEvents(wxWindow* win) needMore = event.MoreRequested(); } - wxWindowList::Node *node = win->GetChildren().GetFirst(); + wxWindowList::compatibility_iterator node = win->GetChildren().GetFirst(); while ( node ) { wxWindow *win = node->GetData(); diff --git a/src/common/artprov.cpp b/src/common/artprov.cpp index 194219d32d..74f8f798e7 100644 --- a/src/common/artprov.cpp +++ b/src/common/artprov.cpp @@ -114,7 +114,6 @@ wxArtProviderCache *wxArtProvider::sm_cache = NULL; if ( !sm_providers ) { sm_providers = new wxArtProvidersList; - sm_providers->DeleteContents(TRUE); sm_cache = new wxArtProviderCache; } @@ -127,7 +126,8 @@ wxArtProviderCache *wxArtProvider::sm_cache = NULL; wxCHECK_MSG( sm_providers, FALSE, _T("no wxArtProvider exists") ); wxCHECK_MSG( sm_providers->GetCount() > 0, FALSE, _T("wxArtProviders stack is empty") ); - sm_providers->DeleteNode(sm_providers->GetFirst()); + delete sm_providers->GetFirst()->GetData(); + sm_providers->Erase(sm_providers->GetFirst()); sm_cache->Clear(); return TRUE; } @@ -138,6 +138,7 @@ wxArtProviderCache *wxArtProvider::sm_cache = NULL; if ( sm_providers->DeleteObject(provider) ) { + delete provider; sm_cache->Clear(); return TRUE; } @@ -165,7 +166,7 @@ wxArtProviderCache *wxArtProvider::sm_cache = NULL; wxBitmap bmp; if ( !sm_cache->GetBitmap(hashId, &bmp) ) { - for (wxArtProvidersList::Node *node = sm_providers->GetFirst(); + for (wxArtProvidersList::compatibility_iterator node = sm_providers->GetFirst(); node; node = node->GetNext()) { bmp = node->GetData()->CreateBitmap(id, client, size); diff --git a/src/common/cmdproc.cpp b/src/common/cmdproc.cpp index 4945bdbe28..6a7475fadb 100644 --- a/src/common/cmdproc.cpp +++ b/src/common/cmdproc.cpp @@ -64,7 +64,6 @@ wxCommand::~wxCommand() wxCommandProcessor::wxCommandProcessor(int maxCommands) { m_maxNoCommands = maxCommands; - m_currentCommand = (wxNode *) NULL; #if wxUSE_MENUS m_commandEditMenu = (wxMenu *) NULL; #endif // wxUSE_MENUS @@ -114,10 +113,10 @@ void wxCommandProcessor::Store(wxCommand *command) if ( (int)m_commands.GetCount() == m_maxNoCommands ) { - wxNode *firstNode = m_commands.GetFirst(); + wxList::compatibility_iterator firstNode = m_commands.GetFirst(); wxCommand *firstCommand = (wxCommand *)firstNode->GetData(); delete firstCommand; - delete firstNode; + m_commands.Erase(firstNode); } // Correct a bug: we must chop off the current 'branch' @@ -126,12 +125,12 @@ void wxCommandProcessor::Store(wxCommand *command) ClearCommands(); else { - wxNode *node = m_currentCommand->GetNext(); + wxList::compatibility_iterator node = m_currentCommand->GetNext(); while (node) { - wxNode *next = node->GetNext(); + wxList::compatibility_iterator next = node->GetNext(); delete (wxCommand *)node->GetData(); - delete node; + m_commands.Erase(node); node = next; } } @@ -160,7 +159,7 @@ bool wxCommandProcessor::Undo() bool wxCommandProcessor::Redo() { wxCommand *redoCommand = (wxCommand *) NULL; - wxNode *redoNode = (wxNode *) NULL; + wxList::compatibility_iterator redoNode; if ( m_currentCommand ) { @@ -202,13 +201,13 @@ bool wxCommandProcessor::CanUndo() const bool wxCommandProcessor::CanRedo() const { - if ((m_currentCommand != (wxNode*) NULL) && (m_currentCommand->GetNext() == (wxNode*) NULL)) + if (m_currentCommand && !m_currentCommand->GetNext()) return FALSE; - if ((m_currentCommand != (wxNode*) NULL) && (m_currentCommand->GetNext() != (wxNode*) NULL)) + if (m_currentCommand && m_currentCommand->GetNext()) return TRUE; - if ((m_currentCommand == (wxNode*) NULL) && (m_commands.GetCount() > 0)) + if (!m_currentCommand && (m_commands.GetCount() > 0)) return TRUE; return FALSE; @@ -300,15 +299,15 @@ wxString wxCommandProcessor::GetRedoMenuLabel() const void wxCommandProcessor::ClearCommands() { - wxNode *node = m_commands.GetFirst(); + wxList::compatibility_iterator node = m_commands.GetFirst(); while (node) { wxCommand *command = (wxCommand *)node->GetData(); delete command; - delete node; + m_commands.Erase(node); node = m_commands.GetFirst(); } - m_currentCommand = (wxNode *) NULL; + m_currentCommand = wxList::compatibility_iterator(); } diff --git a/src/common/containr.cpp b/src/common/containr.cpp index fe1ea94cab..f695be6334 100644 --- a/src/common/containr.cpp +++ b/src/common/containr.cpp @@ -61,7 +61,7 @@ bool wxControlContainer::AcceptsFocus() const // otherwise we can accept focus either if we have no children at all // (in this case we're probably not used as a container) or only when // at least one child will accept focus - wxWindowList::Node *node = m_winParent->GetChildren().GetFirst(); + wxWindowList::compatibility_iterator node = m_winParent->GetChildren().GetFirst(); if ( !node ) return TRUE; @@ -185,7 +185,7 @@ void wxControlContainer::HandleOnNavigationKey( wxNavigationKeyEvent& event ) // the node of the children list from which we should start looking for the // next acceptable child - wxWindowList::Node *node, *start_node; + wxWindowList::compatibility_iterator node, start_node; // we should start from the first/last control and not from the one which // had focus the last time if we're propagating the event downwards because @@ -200,7 +200,7 @@ void wxControlContainer::HandleOnNavigationKey( wxNavigationKeyEvent& event ) node = forward ? children.GetFirst() : children.GetLast(); // we want to cycle over all nodes - start_node = (wxWindowList::Node *)NULL; + start_node = wxWindowList::compatibility_iterator(); } else { @@ -224,7 +224,7 @@ void wxControlContainer::HandleOnNavigationKey( wxNavigationKeyEvent& event ) } else { - start_node = (wxWindowList::Node *)NULL; + start_node = wxWindowList::compatibility_iterator(); } if ( !start_node && m_winLastFocused ) @@ -413,7 +413,7 @@ bool wxSetFocusToChild(wxWindow *win, wxWindow **childLastFocused) } // set the focus to the first child who wants it - wxWindowList::Node *node = win->GetChildren().GetFirst(); + wxWindowList::compatibility_iterator node = win->GetChildren().GetFirst(); while ( node ) { wxWindow *child = node->GetData(); diff --git a/src/common/dcbase.cpp b/src/common/dcbase.cpp index f239d3bc01..8534732e7b 100644 --- a/src/common/dcbase.cpp +++ b/src/common/dcbase.cpp @@ -73,7 +73,7 @@ void wxDCBase::DrawLines(const wxList *list, wxCoord xoffset, wxCoord yoffset) wxPoint *points = new wxPoint[n]; int i = 0; - for ( wxNode *node = list->GetFirst(); node; node = node->GetNext(), i++ ) + for ( wxList::compatibility_iterator node = list->GetFirst(); node; node = node->GetNext(), i++ ) { wxPoint *point = (wxPoint *)node->GetData(); points[i].x = point->x; @@ -94,7 +94,7 @@ void wxDCBase::DrawPolygon(const wxList *list, wxPoint *points = new wxPoint[n]; int i = 0; - for ( wxNode *node = list->GetFirst(); node; node = node->GetNext(), i++ ) + for ( wxList::compatibility_iterator node = list->GetFirst(); node; node = node->GetNext(), i++ ) { wxPoint *point = (wxPoint *)node->GetData(); points[i].x = point->x; @@ -131,7 +131,7 @@ void wxDCBase::DrawSpline(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoor DrawSpline(&point_list); - for( wxNode *node = point_list.GetFirst(); node; node = node->GetNext() ) + for( wxList::compatibility_iterator node = point_list.GetFirst(); node; node = node->GetNext() ) { wxPoint *p = (wxPoint *)node->GetData(); delete p; @@ -254,12 +254,12 @@ static bool wx_spline_add_point(double x, double y) static void wx_spline_draw_point_array(wxDCBase *dc) { dc->DrawLines(&wx_spline_point_list, 0, 0 ); - wxNode *node = wx_spline_point_list.GetFirst(); + wxList::compatibility_iterator node = wx_spline_point_list.GetFirst(); while (node) { wxPoint *point = (wxPoint *)node->GetData(); delete point; - delete node; + wx_spline_point_list.Erase(node); node = wx_spline_point_list.GetFirst(); } } @@ -272,7 +272,7 @@ void wxDCBase::DoDrawSpline( wxList *points ) double cx1, cy1, cx2, cy2, cx3, cy3, cx4, cy4; double x1, y1, x2, y2; - wxNode *node = points->GetFirst(); + wxList::compatibility_iterator node = points->GetFirst(); p = (wxPoint *)node->GetData(); x1 = p->x; @@ -290,7 +290,7 @@ void wxDCBase::DoDrawSpline( wxList *points ) wx_spline_add_point(x1, y1); - while ((node = node->GetNext()) != NULL) + while ((node = node->GetNext())) { p = (wxPoint *)node->GetData(); x1 = x2; diff --git a/src/common/dobjcmn.cpp b/src/common/dobjcmn.cpp index 658449d91f..432cb49bfe 100644 --- a/src/common/dobjcmn.cpp +++ b/src/common/dobjcmn.cpp @@ -97,14 +97,17 @@ bool wxDataObjectBase::IsSupported(const wxDataFormat& format, wxDataObjectComposite::wxDataObjectComposite() { m_preferred = 0; +} - m_dataObjects.DeleteContents(TRUE); +wxDataObjectComposite::~wxDataObjectComposite() +{ + WX_CLEAR_LIST(wxSimpleDataObjectList, m_dataObjects); } wxDataObjectSimple * wxDataObjectComposite::GetObject(const wxDataFormat& format) const { - wxSimpleDataObjectList::Node *node = m_dataObjects.GetFirst(); + wxSimpleDataObjectList::compatibility_iterator node = m_dataObjects.GetFirst(); while ( node ) { wxDataObjectSimple *dataObj = node->GetData(); @@ -131,7 +134,7 @@ void wxDataObjectComposite::Add(wxDataObjectSimple *dataObject, bool preferred) wxDataFormat wxDataObjectComposite::GetPreferredFormat(Direction WXUNUSED(dir)) const { - wxSimpleDataObjectList::Node *node = m_dataObjects.Item( m_preferred ); + wxSimpleDataObjectList::compatibility_iterator node = m_dataObjects.Item( m_preferred ); wxCHECK_MSG( node, wxFormatInvalid, wxT("no preferred format") ); @@ -189,7 +192,7 @@ void wxDataObjectComposite::GetAllFormats(wxDataFormat *formats, Direction WXUNUSED(dir)) const { size_t n = 0; - wxSimpleDataObjectList::Node *node; + wxSimpleDataObjectList::compatibility_iterator node; for ( node = m_dataObjects.GetFirst(); node; node = node->GetNext() ) { // TODO if ( !outputOnlyToo ) && this one counts ... diff --git a/src/common/docview.cpp b/src/common/docview.cpp index e0720053f1..c158c43243 100644 --- a/src/common/docview.cpp +++ b/src/common/docview.cpp @@ -184,14 +184,14 @@ bool wxDocument::DeleteAllViews() { wxDocManager* manager = GetDocumentManager(); - wxNode *node = m_documentViews.GetFirst(); + wxList::compatibility_iterator node = m_documentViews.GetFirst(); while (node) { wxView *view = (wxView *)node->GetData(); if (!view->Close()) return FALSE; - wxNode *next = node->GetNext(); + wxList::compatibility_iterator next = node->GetNext(); delete view; // Deletes node implicitly node = next; @@ -276,7 +276,7 @@ bool wxDocument::SaveAs() SetTitle(wxFileNameFromPath(fileName)); // Notify the views that the filename has changed - wxNode *node = m_documentViews.GetFirst(); + wxList::compatibility_iterator node = m_documentViews.GetFirst(); while (node) { wxView *view = (wxView *)node->GetData(); @@ -525,7 +525,7 @@ void wxDocument::OnChangedViewList() void wxDocument::UpdateAllViews(wxView *sender, wxObject *hint) { - wxNode *node = m_documentViews.GetFirst(); + wxList::compatibility_iterator node = m_documentViews.GetFirst(); while (node) { wxView *view = (wxView *)node->GetData(); @@ -537,7 +537,7 @@ void wxDocument::UpdateAllViews(wxView *sender, wxObject *hint) void wxDocument::NotifyClosing() { - wxNode *node = m_documentViews.GetFirst(); + wxList::compatibility_iterator node = m_documentViews.GetFirst(); while (node) { wxView *view = (wxView *)node->GetData(); @@ -552,7 +552,7 @@ void wxDocument::SetFilename(const wxString& filename, bool notifyViews) if ( notifyViews ) { // Notify the views that the filename has changed - wxNode *node = m_documentViews.GetFirst(); + wxList::compatibility_iterator node = m_documentViews.GetFirst(); while (node) { wxView *view = (wxView *)node->GetData(); @@ -806,12 +806,12 @@ bool wxDocManager::CloseDocument(wxDocument* doc, bool force) bool wxDocManager::CloseDocuments(bool force) { - wxNode *node = m_docs.GetFirst(); + wxList::compatibility_iterator node = m_docs.GetFirst(); while (node) { wxDocument *doc = (wxDocument *)node->GetData(); - wxNode *next = node->GetNext(); - + wxList::compatibility_iterator next = node->GetNext(); + if (!CloseDocument(doc, force)) return FALSE; @@ -828,11 +828,11 @@ bool wxDocManager::Clear(bool force) if (!CloseDocuments(force)) return FALSE; - wxNode *node = m_templates.GetFirst(); + wxList::compatibility_iterator node = m_templates.GetFirst(); while (node) { wxDocTemplate *templ = (wxDocTemplate*) node->GetData(); - wxNode* next = node->GetNext(); + wxList::compatibility_iterator next = node->GetNext(); delete templ; node = next; } @@ -1530,7 +1530,7 @@ wxDocTemplate *wxDocManager::SelectDocumentPath(wxDocTemplate **templates, wxDocTemplate *wxDocManager::SelectDocumentType(wxDocTemplate **templates, int noTemplates, bool sort) { - wxArrayString strings(sort); + wxArrayString strings; wxDocTemplate **data = new wxDocTemplate *[noTemplates]; int i; int n = 0; @@ -1562,6 +1562,7 @@ wxDocTemplate *wxDocManager::SelectDocumentType(wxDocTemplate **templates, if (sort) { + strings.Sort(wxStringSortAscending); // Yes, this will be slow, but template lists // are typically short. int j; @@ -1610,7 +1611,7 @@ wxDocTemplate *wxDocManager::SelectDocumentType(wxDocTemplate **templates, wxDocTemplate *wxDocManager::SelectViewType(wxDocTemplate **templates, int noTemplates, bool sort) { - wxArrayString strings(sort); + wxArrayString strings; wxDocTemplate **data = new wxDocTemplate *[noTemplates]; int i; int n = 0; @@ -1640,6 +1641,7 @@ wxDocTemplate *wxDocManager::SelectViewType(wxDocTemplate **templates, if (sort) { + strings.Sort(wxStringSortAscending); // Yes, this will be slow, but template lists // are typically short. int j; @@ -2022,7 +2024,7 @@ void wxFileHistory::AddFileToHistory(const wxString& file) // Move existing files (if any) down so we can insert file at beginning. if (m_fileHistoryN < m_fileMaxFiles) { - wxNode* node = m_fileMenus.GetFirst(); + wxList::compatibility_iterator node = m_fileMenus.GetFirst(); while (node) { wxMenu* menu = (wxMenu*) node->GetData(); @@ -2067,7 +2069,7 @@ void wxFileHistory::AddFileToHistory(const wxString& file) wxString buf; buf.Printf(s_MRUEntryFormat, i + 1, pathInMenu.c_str()); - wxNode* node = m_fileMenus.GetFirst(); + wxList::compatibility_iterator node = m_fileMenus.GetFirst(); while (node) { wxMenu* menu = (wxMenu*) node->GetData(); @@ -2092,7 +2094,7 @@ void wxFileHistory::RemoveFileFromHistory(size_t i) m_fileHistory[j] = m_fileHistory[j + 1]; } - wxNode* node = m_fileMenus.GetFirst(); + wxList::compatibility_iterator node = m_fileMenus.GetFirst(); while ( node ) { wxMenu* menu = (wxMenu*) node->GetData(); @@ -2117,7 +2119,7 @@ void wxFileHistory::RemoveFileFromHistory(size_t i) // delete the last separator too if no more files are left if ( m_fileHistoryN == 1 ) { - wxMenuItemList::Node *node = menu->GetMenuItems().GetLast(); + wxMenuItemList::compatibility_iterator node = menu->GetMenuItems().GetLast(); if ( node ) { wxMenuItem *menuItem = node->GetData(); @@ -2196,7 +2198,7 @@ void wxFileHistory::AddFilesToMenu() { if (m_fileHistoryN > 0) { - wxNode* node = m_fileMenus.GetFirst(); + wxList::compatibility_iterator node = m_fileMenus.GetFirst(); while (node) { wxMenu* menu = (wxMenu*) node->GetData(); diff --git a/src/common/gdicmn.cpp b/src/common/gdicmn.cpp index c797b70ca2..7bf932f207 100644 --- a/src/common/gdicmn.cpp +++ b/src/common/gdicmn.cpp @@ -37,6 +37,7 @@ #include "wx/dc.h" #include "wx/utils.h" #include "wx/settings.h" +#include "wx/hashmap.h" #include "wx/log.h" #include @@ -63,12 +64,12 @@ #include "wx/mac/private.h" #include "wx/mac/uma.h" #endif -IMPLEMENT_CLASS(wxColourDatabase, wxList) -IMPLEMENT_DYNAMIC_CLASS(wxFontList, wxList) -IMPLEMENT_DYNAMIC_CLASS(wxPenList, wxList) -IMPLEMENT_DYNAMIC_CLASS(wxBrushList, wxList) -IMPLEMENT_DYNAMIC_CLASS(wxBitmapList, wxList) -IMPLEMENT_DYNAMIC_CLASS(wxResourceCache, wxList) +//IMPLEMENT_CLASS(wxColourDatabase, wxList) +//IMPLEMENT_DYNAMIC_CLASS(wxFontList, wxList) +//IMPLEMENT_DYNAMIC_CLASS(wxPenList, wxList) +//IMPLEMENT_DYNAMIC_CLASS(wxBrushList, wxList) +//IMPLEMENT_DYNAMIC_CLASS(wxBitmapList, wxList) +//IMPLEMENT_DYNAMIC_CLASS(wxResourceCache, wxList) IMPLEMENT_ABSTRACT_CLASS(wxDCBase, wxObject) @@ -186,21 +187,22 @@ bool wxRect::Intersects(const wxRect& rect) const return r.width != 0; } -wxColourDatabase::wxColourDatabase (int type) : wxList (type) +WX_DECLARE_STRING_HASH_MAP( wxColour*, wxStringToColourHashMap ); + +wxColourDatabase::wxColourDatabase () { + m_map = new wxStringToColourHashMap; } wxColourDatabase::~wxColourDatabase () { - // Cleanup Colour allocated in Initialize() - wxNode *node = GetFirst (); - while (node) - { - wxColour *col = (wxColour *) node->GetData (); - wxNode *next = node->GetNext (); - delete col; - node = next; - } + typedef wxStringToColourHashMap::iterator iterator; + + for( iterator it = m_map->begin(), en = m_map->end(); it != en; ++it ) + delete it->second; + + delete m_map; + m_map = NULL; #ifdef __WXPM__ delete [] m_palTable; #endif @@ -298,7 +300,7 @@ void wxColourDatabase::Initialize () for ( n = 0; n < WXSIZEOF(wxColourTable); n++ ) { const wxColourDesc& cc = wxColourTable[n]; - Append(cc.name, new wxColour(cc.r,cc.g,cc.b)); + (*m_map)[cc.name] = new wxColour(cc.r,cc.g,cc.b); } #ifdef __WXPM__ m_palTable = new long[n]; @@ -321,6 +323,16 @@ void wxColourDatabase::Initialize () */ wxColour *wxColourDatabase::FindColour(const wxString& colour) +{ + return FindColour(colour, true); +} + +wxColour *wxColourDatabase::FindColourNoAdd(const wxString& colour) const +{ + return ((wxColourDatabase*)this)->FindColour(colour, false); +} + +wxColour *wxColourDatabase::FindColour(const wxString& colour, bool add) { // VZ: make the comparaison case insensitive and also match both grey and // gray @@ -330,17 +342,14 @@ wxColour *wxColourDatabase::FindColour(const wxString& colour) if ( !colName2.Replace(_T("GRAY"), _T("GREY")) ) colName2.clear(); - wxNode *node = GetFirst(); - while ( node ) - { - const wxChar *key = node->GetKeyString(); - if ( colName == key || colName2 == key ) - { - return (wxColour *)node->GetData(); - } + wxStringToColourHashMap::iterator it = m_map->find(colName); + if ( it == m_map->end() ) + it = m_map->find(colName2); + if ( it != m_map->end() ) + return it->second; - node = node->GetNext(); - } + if ( !add ) + return NULL; #ifdef __WXMSW__ return NULL; @@ -372,7 +381,7 @@ wxColour *wxColourDatabase::FindColour(const wxString& colour) delete col; return (wxColour *) NULL; } - Append( colour, col ); + (*m_map)[colour] = col; return col; #endif @@ -400,7 +409,7 @@ wxColour *wxColourDatabase::FindColour(const wxString& colour) #endif wxColour *col = new wxColour(r, g, b); - Append(colour, col); + (*m_map)[colour] = col; return col; #endif // __X__ @@ -408,29 +417,21 @@ wxColour *wxColourDatabase::FindColour(const wxString& colour) wxString wxColourDatabase::FindName (const wxColour& colour) const { - wxString name; - unsigned char red = colour.Red (); unsigned char green = colour.Green (); unsigned char blue = colour.Blue (); - for (wxNode * node = GetFirst (); node; node = node->GetNext ()) + typedef wxStringToColourHashMap::iterator iterator; + + for (iterator it = m_map->begin(), en = m_map->end(); it != en; ++it ) { - wxColour *col = (wxColour *) node->GetData (); + wxColour *col = it->second; if (col->Red () == red && col->Green () == green && col->Blue () == blue) - { - const wxChar *found = node->GetKeyString(); - if ( found ) - { - name = found; - - break; - } - } + return it->first; } - return name; + return wxEmptyString; } void wxInitializeStockLists() @@ -589,11 +590,11 @@ wxBitmapList::wxBitmapList() wxBitmapList::~wxBitmapList () { - wxNode *node = GetFirst (); + wxList::compatibility_iterator node = GetFirst (); while (node) { wxBitmap *bitmap = (wxBitmap *) node->GetData (); - wxNode *next = node->GetNext (); + wxList::compatibility_iterator next = node->GetNext (); if (bitmap->GetVisible()) delete bitmap; node = next; @@ -603,11 +604,11 @@ wxBitmapList::~wxBitmapList () // Pen and Brush lists wxPenList::~wxPenList () { - wxNode *node = GetFirst (); + wxList::compatibility_iterator node = GetFirst (); while (node) { wxPen *pen = (wxPen *) node->GetData (); - wxNode *next = node->GetNext (); + wxList::compatibility_iterator next = node->GetNext (); if (pen->GetVisible()) delete pen; node = next; @@ -626,7 +627,7 @@ void wxPenList::RemovePen (wxPen * pen) wxPen *wxPenList::FindOrCreatePen (const wxColour& colour, int width, int style) { - for (wxNode * node = GetFirst (); node; node = node->GetNext ()) + for (wxList::compatibility_iterator node = GetFirst (); node; node = node->GetNext ()) { wxPen *each_pen = (wxPen *) node->GetData (); if (each_pen && @@ -658,11 +659,11 @@ wxPen *wxPenList::FindOrCreatePen (const wxColour& colour, int width, int style) wxBrushList::~wxBrushList () { - wxNode *node = GetFirst (); + wxList::compatibility_iterator node = GetFirst (); while (node) { wxBrush *brush = (wxBrush *) node->GetData (); - wxNode *next = node->GetNext (); + wxList::compatibility_iterator next = node->GetNext (); if (brush && brush->GetVisible()) delete brush; node = next; @@ -676,7 +677,7 @@ void wxBrushList::AddBrush (wxBrush * brush) wxBrush *wxBrushList::FindOrCreateBrush (const wxColour& colour, int style) { - for (wxNode * node = GetFirst (); node; node = node->GetNext ()) + for (wxList::compatibility_iterator node = GetFirst (); node; node = node->GetNext ()) { wxBrush *each_brush = (wxBrush *) node->GetData (); if (each_brush && @@ -713,7 +714,7 @@ void wxBrushList::RemoveBrush (wxBrush * brush) wxFontList::~wxFontList () { - wxNode *node = GetFirst (); + wxList::compatibility_iterator node = GetFirst (); while (node) { // Only delete objects that are 'visible', i.e. @@ -721,7 +722,7 @@ wxFontList::~wxFontList () // where the pointers are expected to be shared // (and therefore not deleted by any one part of an app). wxFont *font = (wxFont *) node->GetData (); - wxNode *next = node->GetNext (); + wxList::compatibility_iterator next = node->GetNext (); if (font->GetVisible()) delete font; node = next; @@ -747,7 +748,7 @@ wxFont *wxFontList::FindOrCreateFont(int pointSize, wxFontEncoding encoding) { wxFont *font = (wxFont *)NULL; - wxNode *node; + wxList::compatibility_iterator node; for ( node = GetFirst(); node; node = node->GetNext() ) { font = (wxFont *)node->GetData(); @@ -845,7 +846,7 @@ wxSize wxGetDisplaySizeMM() wxResourceCache::~wxResourceCache () { - wxNode *node = GetFirst (); + wxList::compatibility_iterator node = GetFirst (); while (node) { wxObject *item = (wxObject *)node->GetData(); delete item; diff --git a/src/common/image.cpp b/src/common/image.cpp index baa5f6b8b4..5192bc06d8 100644 --- a/src/common/image.cpp +++ b/src/common/image.cpp @@ -1128,7 +1128,7 @@ bool wxImage::CanRead( wxInputStream &stream ) { const wxList& list = GetHandlers(); - for ( wxList::Node *node = list.GetFirst(); node; node = node->GetNext() ) + for ( wxList::compatibility_iterator node = list.GetFirst(); node; node = node->GetNext() ) { wxImageHandler *handler=(wxImageHandler*)node->GetData(); if (handler->CanRead( stream )) @@ -1146,7 +1146,7 @@ int wxImage::GetImageCount( wxInputStream &stream, long type ) { wxList &list=GetHandlers(); - for (wxList::Node *node = list.GetFirst(); node; node = node->GetNext()) + for (wxList::compatibility_iterator node = list.GetFirst(); node; node = node->GetNext()) { handler=(wxImageHandler*)node->GetData(); if ( handler->CanRead(stream) ) @@ -1189,7 +1189,7 @@ bool wxImage::LoadFile( wxInputStream& stream, long type, int index ) { wxList &list=GetHandlers(); - for ( wxList::Node *node = list.GetFirst(); node; node = node->GetNext() ) + for ( wxList::compatibility_iterator node = list.GetFirst(); node; node = node->GetNext() ) { handler=(wxImageHandler*)node->GetData(); if ( handler->CanRead(stream) ) @@ -1266,9 +1266,6 @@ bool wxImage::SaveFile( wxOutputStream& stream, const wxString& mimetype ) const void wxImage::AddHandler( wxImageHandler *handler ) { - // make sure that the memory will be freed at the program end - sm_handlers.DeleteContents(true); - // Check for an existing handler of the type being added. if (FindHandler( handler->GetType() ) == 0) { @@ -1290,9 +1287,6 @@ void wxImage::AddHandler( wxImageHandler *handler ) void wxImage::InsertHandler( wxImageHandler *handler ) { - // make sure that the memory will be freed at the program end - sm_handlers.DeleteContents(true); - // Check for an existing handler of the type being added. if (FindHandler( handler->GetType() ) == 0) { @@ -1313,6 +1307,7 @@ bool wxImage::RemoveHandler( const wxString& name ) if (handler) { sm_handlers.DeleteObject(handler); + delete handler; return true; } else @@ -1321,7 +1316,7 @@ bool wxImage::RemoveHandler( const wxString& name ) wxImageHandler *wxImage::FindHandler( const wxString& name ) { - wxNode *node = sm_handlers.GetFirst(); + wxList::compatibility_iterator node = sm_handlers.GetFirst(); while (node) { wxImageHandler *handler = (wxImageHandler*)node->GetData(); @@ -1334,7 +1329,7 @@ wxImageHandler *wxImage::FindHandler( const wxString& name ) wxImageHandler *wxImage::FindHandler( const wxString& extension, long bitmapType ) { - wxNode *node = sm_handlers.GetFirst(); + wxList::compatibility_iterator node = sm_handlers.GetFirst(); while (node) { wxImageHandler *handler = (wxImageHandler*)node->GetData(); @@ -1348,7 +1343,7 @@ wxImageHandler *wxImage::FindHandler( const wxString& extension, long bitmapType wxImageHandler *wxImage::FindHandler( long bitmapType ) { - wxNode *node = sm_handlers.GetFirst(); + wxList::compatibility_iterator node = sm_handlers.GetFirst(); while (node) { wxImageHandler *handler = (wxImageHandler *)node->GetData(); @@ -1360,7 +1355,7 @@ wxImageHandler *wxImage::FindHandler( long bitmapType ) wxImageHandler *wxImage::FindHandlerMime( const wxString& mimetype ) { - wxNode *node = sm_handlers.GetFirst(); + wxList::compatibility_iterator node = sm_handlers.GetFirst(); while (node) { wxImageHandler *handler = (wxImageHandler *)node->GetData(); @@ -1379,24 +1374,24 @@ void wxImage::InitStandardHandlers() void wxImage::CleanUpHandlers() { - wxNode *node = sm_handlers.GetFirst(); + wxList::compatibility_iterator node = sm_handlers.GetFirst(); while (node) { wxImageHandler *handler = (wxImageHandler *)node->GetData(); - wxNode *next = node->GetNext(); + wxList::compatibility_iterator next = node->GetNext(); delete handler; - delete node; node = next; } -} + sm_handlers.Clear(); +} wxString wxImage::GetImageExtWildcard() { wxString fmts; wxList& Handlers = wxImage::GetHandlers(); - wxNode* Node = Handlers.GetFirst(); + wxList::compatibility_iterator Node = Handlers.GetFirst(); while ( Node ) { wxImageHandler* Handler = (wxImageHandler*)Node->GetData(); @@ -1408,7 +1403,6 @@ wxString wxImage::GetImageExtWildcard() return wxT("(") + fmts + wxT(")|") + fmts; } - //----------------------------------------------------------------------------- // wxImageHandler //----------------------------------------------------------------------------- diff --git a/src/common/layout.cpp b/src/common/layout.cpp index 1dd0c63123..8966a49b9f 100644 --- a/src/common/layout.cpp +++ b/src/common/layout.cpp @@ -734,7 +734,7 @@ int wxIndividualLayoutConstraint::GetEdge(wxEdge which, // If the edge or dimension belongs to the parent, then we know the // dimension is obtainable immediately. E.g. a wxExpandSizer may contain a // button (but the button's true parent is a panel, not the sizer) - if (other->GetChildren().Find(thisWin)) + if (other->GetChildren().Find((wxWindow*)thisWin)) { switch (which) { diff --git a/src/common/menucmn.cpp b/src/common/menucmn.cpp index 5422c06677..221de1a5b2 100644 --- a/src/common/menucmn.cpp +++ b/src/common/menucmn.cpp @@ -276,8 +276,6 @@ void wxMenuItemBase::SetAccel(wxAcceleratorEntry *accel) void wxMenuBase::Init(long style) { - m_items.DeleteContents(TRUE); - m_menuBar = (wxMenuBar *)NULL; m_menuParent = (wxMenu *)NULL; @@ -289,8 +287,8 @@ void wxMenuBase::Init(long style) wxMenuBase::~wxMenuBase() { - // nothing to do, wxMenuItemList dtor will delete the menu items. - + WX_CLEAR_LIST(wxMenuItemList, m_items); + // Actually, in GTK, the submenus have to get deleted first. } @@ -345,7 +343,7 @@ bool wxMenuBase::DoInsert(size_t pos, wxMenuItem *item) { wxCHECK_MSG( item, FALSE, wxT("invalid item in wxMenu::Insert()") ); - wxMenuItemList::Node *node = m_items.Item(pos); + wxMenuItemList::compatibility_iterator node = m_items.Item(pos); wxCHECK_MSG( node, FALSE, wxT("invalid index in wxMenu::Insert()") ); m_items.Insert(node, item); @@ -367,15 +365,14 @@ wxMenuItem *wxMenuBase::Remove(wxMenuItem *item) wxMenuItem *wxMenuBase::DoRemove(wxMenuItem *item) { - wxMenuItemList::Node *node = m_items.Find(item); + wxMenuItemList::compatibility_iterator node = m_items.Find(item); // if we get here, the item is valid or one of Remove() functions is broken wxCHECK_MSG( node, NULL, wxT("bug in wxMenu::Remove logic") ); // we detach the item, but we do delete the list node (i.e. don't call // DetachNode() here!) - node->SetData((wxMenuItem *)NULL); // to prevent it from deleting the item - m_items.DeleteNode(node); + m_items.Erase(node); // item isn't attached to anything any more item->SetMenu((wxMenu *)NULL); @@ -433,7 +430,7 @@ bool wxMenuBase::DoDestroy(wxMenuItem *item) int wxMenuBase::FindItem(const wxString& text) const { wxString label = wxMenuItem::GetLabelFromText(text); - for ( wxMenuItemList::Node *node = m_items.GetFirst(); + for ( wxMenuItemList::compatibility_iterator node = m_items.GetFirst(); node; node = node->GetNext() ) { @@ -464,7 +461,7 @@ wxMenuItem *wxMenuBase::FindItem(int itemId, wxMenu **itemMenu) const *itemMenu = NULL; wxMenuItem *item = NULL; - for ( wxMenuItemList::Node *node = m_items.GetFirst(); + for ( wxMenuItemList::compatibility_iterator node = m_items.GetFirst(); node && !item; node = node->GetNext() ) { @@ -493,7 +490,7 @@ wxMenuItem *wxMenuBase::FindItem(int itemId, wxMenu **itemMenu) const wxMenuItem *wxMenuBase::FindChildItem(int id, size_t *ppos) const { wxMenuItem *item = (wxMenuItem *)NULL; - wxMenuItemList::Node *node = GetMenuItems().GetFirst(); + wxMenuItemList::compatibility_iterator node = GetMenuItems().GetFirst(); size_t pos; for ( pos = 0; node; pos++ ) @@ -541,7 +538,7 @@ void wxMenuBase::UpdateUI(wxEvtHandler* source) if ( !source ) source = this; - wxMenuItemList::Node* node = GetMenuItems().GetFirst(); + wxMenuItemList::compatibility_iterator node = GetMenuItems().GetFirst(); while ( node ) { wxMenuItem* item = node->GetData(); @@ -714,17 +711,13 @@ wxString wxMenuBase::GetHelpString( int id ) const wxMenuBarBase::wxMenuBarBase() { - // we own the menus when we get them - m_menus.DeleteContents(TRUE); - // not attached yet m_menuBarFrame = NULL; } wxMenuBarBase::~wxMenuBarBase() { - // nothing to do, the list will delete the menus because of the call to - // DeleteContents() above + WX_CLEAR_LIST(wxMenuList, m_menus); } // ---------------------------------------------------------------------------- @@ -734,7 +727,7 @@ wxMenuBarBase::~wxMenuBarBase() wxMenu *wxMenuBarBase::GetMenu(size_t pos) const { - wxMenuList::Node *node = m_menus.Item(pos); + wxMenuList::compatibility_iterator node = m_menus.Item(pos); wxCHECK_MSG( node, NULL, wxT("bad index in wxMenuBar::GetMenu()") ); return node->GetData(); @@ -761,7 +754,7 @@ bool wxMenuBarBase::Insert(size_t pos, wxMenu *menu, { wxCHECK_MSG( menu, FALSE, wxT("can't insert NULL menu") ); - wxMenuList::Node *node = m_menus.Item(pos); + wxMenuList::compatibility_iterator node = m_menus.Item(pos); wxCHECK_MSG( node, FALSE, wxT("bad index in wxMenuBar::Insert()") ); m_menus.Insert(node, menu); @@ -776,7 +769,7 @@ wxMenu *wxMenuBarBase::Replace(size_t pos, wxMenu *menu, { wxCHECK_MSG( menu, NULL, wxT("can't insert NULL menu") ); - wxMenuList::Node *node = m_menus.Item(pos); + wxMenuList::compatibility_iterator node = m_menus.Item(pos); wxCHECK_MSG( node, NULL, wxT("bad index in wxMenuBar::Replace()") ); wxMenu *menuOld = node->GetData(); @@ -790,16 +783,14 @@ wxMenu *wxMenuBarBase::Replace(size_t pos, wxMenu *menu, wxMenu *wxMenuBarBase::Remove(size_t pos) { - wxMenuList::Node *node = m_menus.Item(pos); + wxMenuList::compatibility_iterator node = m_menus.Item(pos); wxCHECK_MSG( node, NULL, wxT("bad index in wxMenuBar::Remove()") ); - node = m_menus.DetachNode(node); - wxCHECK( node, NULL ); // unexpected wxMenu *menu = node->GetData(); + wxCHECK( node, NULL ); // unexpected + m_menus.Erase(node); menu->Detach(); - delete node; - return menu; } @@ -851,10 +842,11 @@ wxMenuItem *wxMenuBarBase::FindItem(int id, wxMenu **menu) const *menu = NULL; wxMenuItem *item = NULL; - size_t count = GetMenuCount(); - for ( size_t i = 0; !item && (i < count); i++ ) + size_t count = GetMenuCount(), i; + wxMenuList::const_iterator it; + for ( i = 0, it = m_menus.begin(); !item && (i < count); i++, it++ ) { - item = m_menus[i]->FindItem(id, menu); + item = (*it)->FindItem(id, menu); } return item; @@ -865,7 +857,7 @@ int wxMenuBarBase::FindMenuItem(const wxString& menu, const wxString& item) cons wxString label = wxMenuItem::GetLabelFromText(menu); int i = 0; - wxMenuList::Node *node; + wxMenuList::compatibility_iterator node; for ( node = m_menus.GetFirst(); node; node = node->GetNext(), i++ ) { if ( label == wxMenuItem::GetLabelFromText(GetLabelTop(i)) ) diff --git a/src/common/paper.cpp b/src/common/paper.cpp index e02dcdc39f..b60ad489b5 100644 --- a/src/common/paper.cpp +++ b/src/common/paper.cpp @@ -33,6 +33,7 @@ #include "wx/paper.h" #include "wx/module.h" +#include "wx/hashmap.h" #include #include @@ -49,7 +50,7 @@ // End __WXMSW__ IMPLEMENT_DYNAMIC_CLASS(wxPrintPaperType, wxObject) -IMPLEMENT_DYNAMIC_CLASS(wxPrintPaperDatabase, wxList) +// IMPLEMENT_DYNAMIC_CLASS(wxPrintPaperDatabase, wxList) /* * Paper size database for all platforms @@ -83,11 +84,22 @@ wxSize wxPrintPaperType::GetSizeDeviceUnits() const * Print paper database for PostScript */ +WX_DECLARE_STRING_HASH_MAP(wxPrintPaperType*, wxStringToPrintPaperTypeHashMap); +WX_DECLARE_LIST(wxPrintPaperType, wxPrintPaperTypeList); +#include +WX_DEFINE_LIST(wxPrintPaperTypeList); + wxPrintPaperDatabase* wxThePrintPaperDatabase = (wxPrintPaperDatabase*) NULL; -wxPrintPaperDatabase::wxPrintPaperDatabase():wxList(wxKEY_STRING) +wxPrintPaperDatabase::wxPrintPaperDatabase() +{ + m_map = new wxStringToPrintPaperTypeHashMap; + m_list = new wxPrintPaperTypeList; +} + +wxPrintPaperDatabase::~wxPrintPaperDatabase() { - DeleteContents(TRUE); + ClearDatabase(); } void wxPrintPaperDatabase::CreateDatabase() @@ -175,66 +187,75 @@ void wxPrintPaperDatabase::CreateDatabase() void wxPrintPaperDatabase::ClearDatabase() { - Clear(); + delete m_list; + WX_CLEAR_HASH_MAP(wxStringToPrintPaperTypeHashMap, *m_map); + delete m_map; } void wxPrintPaperDatabase::AddPaperType(wxPaperSize paperId, const wxString& name, int w, int h) { - Append(name, new wxPrintPaperType(paperId, 0, name, w, h)); + wxPrintPaperType* tmp = new wxPrintPaperType(paperId, 0, name, w, h); + (*m_map)[name] = tmp; + m_list->push_back(tmp); } void wxPrintPaperDatabase::AddPaperType(wxPaperSize paperId, int platformId, const wxString& name, int w, int h) { - Append(name, new wxPrintPaperType(paperId, platformId, name, w, h)); + wxPrintPaperType* tmp = new wxPrintPaperType(paperId, platformId, name, w, h); + (*m_map)[name] = tmp; + m_list->push_back(tmp); } wxPrintPaperType *wxPrintPaperDatabase::FindPaperType(const wxString& name) { - wxNode *node = Find(name); - if (node) - return (wxPrintPaperType *)node->GetData(); + wxStringToPrintPaperTypeHashMap::iterator it = m_map->find(name); + if (it != m_map->end()) + return it->second; else - return (wxPrintPaperType *) NULL; + return NULL; } wxPrintPaperType *wxPrintPaperDatabase::FindPaperType(wxPaperSize id) { - wxNode *node = GetFirst(); - while (node) + typedef wxStringToPrintPaperTypeHashMap::iterator iterator; + + for (iterator it = m_map->begin(), en = m_map->end(); it != en; ++it) { - wxPrintPaperType* paperType = (wxPrintPaperType*) node->GetData(); + wxPrintPaperType* paperType = it->second; if (paperType->GetId() == id) return paperType; - node = node->GetNext(); } - return (wxPrintPaperType *) NULL; + + return NULL; } wxPrintPaperType *wxPrintPaperDatabase::FindPaperTypeByPlatformId(int id) { - wxNode *node = GetFirst(); - while (node) + typedef wxStringToPrintPaperTypeHashMap::iterator iterator; + + for (iterator it = m_map->begin(), en = m_map->end(); it != en; ++it) { - wxPrintPaperType* paperType = (wxPrintPaperType*) node->GetData(); + wxPrintPaperType* paperType = it->second; if (paperType->GetPlatformId() == id) return paperType; - node = node->GetNext(); } - return (wxPrintPaperType *) NULL; + + return NULL; } wxPrintPaperType *wxPrintPaperDatabase::FindPaperType(const wxSize& sz) { - wxNode *node = GetFirst(); - while (node) + typedef wxStringToPrintPaperTypeHashMap::iterator iterator; + + for (iterator it = m_map->begin(), en = m_map->end(); it != en; ++it) { - wxPrintPaperType* paperType = (wxPrintPaperType*) node->GetData(); + wxPrintPaperType* paperType = it->second; wxSize paperSize = paperType->GetSize() ; if ( abs( paperSize.x - sz.x ) < 10 && abs( paperSize.y - sz.y ) < 10 ) return paperType; - node = node->GetNext(); } - return (wxPrintPaperType *) NULL; + + return NULL; } // Convert name to size id @@ -277,6 +298,17 @@ wxPaperSize wxPrintPaperDatabase::GetSize(const wxSize& size) return wxPAPER_NONE; } +// QUICK and DIRTY +size_t wxPrintPaperDatabase::GetCount() const +{ + return m_list->GetCount(); +} + +wxPrintPaperType* wxPrintPaperDatabase::Item(size_t index) const +{ + return m_list->Item(index)->GetData(); +} + // A module to allow initialization/cleanup of print paper // things without calling these functions from app.cpp. diff --git a/src/common/sizer.cpp b/src/common/sizer.cpp index 18faa4a469..3f7e4352a6 100644 --- a/src/common/sizer.cpp +++ b/src/common/sizer.cpp @@ -277,12 +277,11 @@ int wxSizerItem::GetOption() const wxSizer::wxSizer() : m_minSize( wxSize( 0, 0 ) ) { - m_children.DeleteContents( true ); } wxSizer::~wxSizer() { - Clear(); + WX_CLEAR_LIST(wxSizerItemList, m_children); } void wxSizer::Add( wxWindow *window, int proportion, int flag, int border, wxObject* userData ) @@ -385,13 +384,17 @@ bool wxSizer::Remove( wxSizer *sizer ) { wxASSERT_MSG( sizer, _T("Removing NULL sizer") ); - wxSizerItemList::Node *node = m_children.GetFirst(); + wxSizerItemList::compatibility_iterator node = m_children.GetFirst(); while (node) { wxSizerItem *item = node->GetData(); if (item->GetSizer() == sizer) - return m_children.DeleteNode( node ); + { + delete item; + m_children.Erase( node ); + return true; + } node = node->GetNext(); } @@ -405,7 +408,7 @@ bool wxSizer::Remove( int index ) false, _T("Remove index is out of range") ); - wxSizerItemList::Node *node = m_children.Item( index ); + wxSizerItemList::compatibility_iterator node = m_children.Item( index ); wxCHECK_MSG( node, false, _T("Failed to find child node") ); @@ -414,14 +417,16 @@ bool wxSizer::Remove( int index ) if( item->IsWindow() ) item->GetWindow()->SetContainingSizer( NULL ); - return m_children.DeleteNode( node ); + delete item; + m_children.Erase( node ); + return true; } bool wxSizer::Detach( wxSizer *sizer ) { wxASSERT_MSG( sizer, _T("Detaching NULL sizer") ); - wxSizerItemList::Node *node = m_children.GetFirst(); + wxSizerItemList::compatibility_iterator node = m_children.GetFirst(); while (node) { wxSizerItem *item = node->GetData(); @@ -429,7 +434,8 @@ bool wxSizer::Detach( wxSizer *sizer ) if (item->GetSizer() == sizer) { item->DetachSizer(); - return m_children.DeleteNode( node ); + m_children.Erase( node ); + return true; } node = node->GetNext(); } @@ -441,7 +447,7 @@ bool wxSizer::Detach( wxWindow *window ) { wxASSERT_MSG( window, _T("Detaching NULL window") ); - wxSizerItemList::Node *node = m_children.GetFirst(); + wxSizerItemList::compatibility_iterator node = m_children.GetFirst(); while (node) { wxSizerItem *item = node->GetData(); @@ -449,7 +455,8 @@ bool wxSizer::Detach( wxWindow *window ) if (item->GetWindow() == window) { item->GetWindow()->SetContainingSizer( NULL ); - return m_children.DeleteNode( node ); + m_children.Erase( node ); + return true; } node = node->GetNext(); } @@ -463,7 +470,7 @@ bool wxSizer::Detach( int index ) false, _T("Detach index is out of range") ); - wxSizerItemList::Node *node = m_children.Item( index ); + wxSizerItemList::compatibility_iterator node = m_children.Item( index ); wxCHECK_MSG( node, false, _T("Failed to find child node") ); @@ -474,13 +481,14 @@ bool wxSizer::Detach( int index ) else if( item->IsWindow() ) item->GetWindow()->SetContainingSizer( NULL ); - return m_children.DeleteNode( node ); + m_children.Erase( node ); + return true; } void wxSizer::Clear( bool delete_windows ) { // First clear the ContainingSizer pointers - wxSizerItemList::Node *node = m_children.GetFirst(); + wxSizerItemList::compatibility_iterator node = m_children.GetFirst(); while (node) { wxSizerItem *item = node->GetData(); @@ -495,12 +503,12 @@ void wxSizer::Clear( bool delete_windows ) DeleteWindows(); // Now empty the list - m_children.Clear(); + WX_CLEAR_LIST(wxSizerItemList, m_children); } void wxSizer::DeleteWindows() { - wxSizerItemList::Node *node = m_children.GetFirst(); + wxSizerItemList::compatibility_iterator node = m_children.GetFirst(); while (node) { wxSizerItem *item = node->GetData(); @@ -662,7 +670,7 @@ bool wxSizer::DoSetItemMinSize( wxWindow *window, int width, int height ) // Is it our immediate child? - wxSizerItemList::Node *node = m_children.GetFirst(); + wxSizerItemList::compatibility_iterator node = m_children.GetFirst(); while (node) { wxSizerItem *item = node->GetData(); @@ -700,7 +708,7 @@ bool wxSizer::DoSetItemMinSize( wxSizer *sizer, int width, int height ) // Is it our immediate child? - wxSizerItemList::Node *node = m_children.GetFirst(); + wxSizerItemList::compatibility_iterator node = m_children.GetFirst(); while (node) { wxSizerItem *item = node->GetData(); @@ -734,7 +742,7 @@ bool wxSizer::DoSetItemMinSize( wxSizer *sizer, int width, int height ) bool wxSizer::DoSetItemMinSize( size_t index, int width, int height ) { - wxSizerItemList::Node *node = m_children.Item( index ); + wxSizerItemList::compatibility_iterator node = m_children.Item( index ); wxCHECK_MSG( node, false, _T("Failed to find child node") ); @@ -758,7 +766,7 @@ void wxSizer::Show( wxWindow *window, bool show ) { wxASSERT_MSG( window, _T("Show for NULL window") ); - wxSizerItemList::Node *node = m_children.GetFirst(); + wxSizerItemList::compatibility_iterator node = m_children.GetFirst(); while (node) { wxSizerItem *item = node->GetData(); @@ -776,7 +784,7 @@ void wxSizer::Show( wxSizer *sizer, bool show ) { wxASSERT_MSG( sizer, _T("Show for NULL sizer") ); - wxSizerItemList::Node *node = m_children.GetFirst(); + wxSizerItemList::compatibility_iterator node = m_children.GetFirst(); while (node) { wxSizerItem *item = node->GetData(); @@ -800,7 +808,7 @@ void wxSizer::Show( size_t index, bool show ) void wxSizer::ShowItems( bool show ) { - wxSizerItemList::Node *node = m_children.GetFirst(); + wxSizerItemList::compatibility_iterator node = m_children.GetFirst(); while (node) { node->GetData()->Show( show ); @@ -810,7 +818,7 @@ void wxSizer::ShowItems( bool show ) bool wxSizer::IsShown( wxWindow *window ) const { - wxSizerItemList::Node *node = m_children.GetFirst(); + wxSizerItemList::compatibility_iterator node = m_children.GetFirst(); while (node) { wxSizerItem *item = node->GetData(); @@ -829,7 +837,7 @@ bool wxSizer::IsShown( wxWindow *window ) const bool wxSizer::IsShown( wxSizer *sizer ) const { - wxSizerItemList::Node *node = m_children.GetFirst(); + wxSizerItemList::compatibility_iterator node = m_children.GetFirst(); while (node) { wxSizerItem *item = node->GetData(); @@ -923,7 +931,7 @@ void wxGridSizer::RecalcSizes() int i = r * ncols + c; if (i < nitems) { - wxSizerItemList::Node *node = m_children.Item( i ); + wxSizerItemList::compatibility_iterator node = m_children.Item( i ); wxASSERT_MSG( node, _T("Failed to find SizerItemList node") ); @@ -945,7 +953,7 @@ wxSize wxGridSizer::CalcMin() int w = 0; int h = 0; - wxSizerItemList::Node *node = m_children.GetFirst(); + wxSizerItemList::compatibility_iterator node = m_children.GetFirst(); while (node) { wxSizerItem *item = node->GetData(); @@ -1136,7 +1144,7 @@ void wxFlexGridSizer::RecalcSizes() int i = r * ncols + c; if (i < nitems) { - wxSizerItemList::Node *node = m_children.Item( i ); + wxSizerItemList::compatibility_iterator node = m_children.Item( i ); wxASSERT_MSG( node, _T("Failed to find node") ); @@ -1173,7 +1181,7 @@ wxSize wxFlexGridSizer::CalcMin() for( s = m_colWidths.GetCount(), i = 0; i < s; ++i ) m_colWidths[ i ] = -1; - wxSizerItemList::Node *node = m_children.GetFirst(); + wxSizerItemList::compatibility_iterator node = m_children.GetFirst(); i = 0; while (node) @@ -1286,7 +1294,7 @@ void wxBoxSizer::RecalcSizes() wxPoint pt( m_position ); - wxSizerItemList::Node *node = m_children.GetFirst(); + wxSizerItemList::compatibility_iterator node = m_children.GetFirst(); while (node) { wxSizerItem *item = node->GetData(); @@ -1368,7 +1376,7 @@ wxSize wxBoxSizer::CalcMin() // Find how long each stretch unit needs to be int stretchSize = 1; - wxSizerItemList::Node *node = m_children.GetFirst(); + wxSizerItemList::compatibility_iterator node = m_children.GetFirst(); while (node) { @@ -1539,7 +1547,7 @@ wxSize wxNotebookSizer::CalcMin() int maxX = 0; int maxY = 0; - wxWindowList::Node *node = m_notebook->GetChildren().GetFirst(); + wxWindowList::compatibility_iterator node = m_notebook->GetChildren().GetFirst(); while (node) { wxWindow *item = node->GetData(); diff --git a/src/common/statbar.cpp b/src/common/statbar.cpp index 6780e01309..3867476a71 100644 --- a/src/common/statbar.cpp +++ b/src/common/statbar.cpp @@ -234,7 +234,8 @@ void wxStatusBarBase::FreeStacks() { if(m_statusTextStacks[i]) { - m_statusTextStacks[i]->Clear(); + wxListString& t = *m_statusTextStacks[i]; + WX_CLEAR_LIST(wxListString, t); delete m_statusTextStacks[i]; } } @@ -257,10 +258,11 @@ void wxStatusBarBase::PopStatusText(int number) { wxListString *st = GetStatusStack(number); wxCHECK_RET( st, _T("Unbalanced PushStatusText/PopStatusText") ); - wxListString::Node *top = st->GetFirst(); + wxListString::compatibility_iterator top = st->GetFirst(); SetStatusText(*top->GetData(), number); - st->DeleteNode(top); + delete top->GetData(); + st->Erase(top); if(st->GetCount() == 0) { delete st; @@ -288,7 +290,6 @@ wxListString *wxStatusBarBase::GetOrCreateStatusStack(int i) if(!m_statusTextStacks[i]) { m_statusTextStacks[i] = new wxListString(); - m_statusTextStacks[i]->DeleteContents(TRUE); } return m_statusTextStacks[i]; diff --git a/src/common/tbarbase.cpp b/src/common/tbarbase.cpp index a187599235..636d4133cf 100644 --- a/src/common/tbarbase.cpp +++ b/src/common/tbarbase.cpp @@ -125,8 +125,6 @@ wxToolBarToolBase::~wxToolBarToolBase() wxToolBarBase::wxToolBarBase() { // the list owns the pointers - m_tools.DeleteContents(TRUE); - m_xMargin = m_yMargin = 0; m_maxRows = m_maxCols = 0; @@ -224,7 +222,7 @@ wxToolBarToolBase *wxToolBarBase::InsertControl(size_t pos, wxControl *control) wxControl *wxToolBarBase::FindControl( int id ) { - for ( wxToolBarToolsList::Node* node = m_tools.GetFirst(); + for ( wxToolBarToolsList::compatibility_iterator node = m_tools.GetFirst(); node; node = node->GetNext() ) { @@ -279,7 +277,7 @@ wxToolBarToolBase *wxToolBarBase::InsertSeparator(size_t pos) wxToolBarToolBase *wxToolBarBase::RemoveTool(int id) { size_t pos = 0; - wxToolBarToolsList::Node *node; + wxToolBarToolsList::compatibility_iterator node; for ( node = m_tools.GetFirst(); node; node = node->GetNext() ) { if ( node->GetData()->GetId() == id ) @@ -301,10 +299,7 @@ wxToolBarToolBase *wxToolBarBase::RemoveTool(int id) return (wxToolBarToolBase *)NULL; } - // the node would delete the data, so set it to NULL to avoid this - node->SetData(NULL); - - m_tools.DeleteNode(node); + m_tools.Erase(node); return tool; } @@ -314,14 +309,15 @@ bool wxToolBarBase::DeleteToolByPos(size_t pos) wxCHECK_MSG( pos < GetToolsCount(), FALSE, _T("invalid position in wxToolBar::DeleteToolByPos()") ); - wxToolBarToolsList::Node *node = m_tools.Item(pos); + wxToolBarToolsList::compatibility_iterator node = m_tools.Item(pos); if ( !DoDeleteTool(pos, node->GetData()) ) { return FALSE; } - m_tools.DeleteNode(node); + delete node->GetData(); + m_tools.Erase(node); return TRUE; } @@ -329,7 +325,7 @@ bool wxToolBarBase::DeleteToolByPos(size_t pos) bool wxToolBarBase::DeleteTool(int id) { size_t pos = 0; - wxToolBarToolsList::Node *node; + wxToolBarToolsList::compatibility_iterator node; for ( node = m_tools.GetFirst(); node; node = node->GetNext() ) { if ( node->GetData()->GetId() == id ) @@ -343,7 +339,8 @@ bool wxToolBarBase::DeleteTool(int id) return FALSE; } - m_tools.DeleteNode(node); + delete node->GetData(); + m_tools.Erase(node); return TRUE; } @@ -352,7 +349,7 @@ wxToolBarToolBase *wxToolBarBase::FindById(int id) const { wxToolBarToolBase *tool = (wxToolBarToolBase *)NULL; - for ( wxToolBarToolsList::Node *node = m_tools.GetFirst(); + for ( wxToolBarToolsList::compatibility_iterator node = m_tools.GetFirst(); node; node = node->GetNext() ) { @@ -371,7 +368,7 @@ wxToolBarToolBase *wxToolBarBase::FindById(int id) const void wxToolBarBase::ClearTools() { - m_tools.Clear(); + WX_CLEAR_LIST(wxToolBarToolsList, m_tools); } bool wxToolBarBase::Realize() @@ -381,6 +378,7 @@ bool wxToolBarBase::Realize() wxToolBarBase::~wxToolBarBase() { + WX_CLEAR_LIST(wxToolBarToolsList, m_tools); } // ---------------------------------------------------------------------------- @@ -460,7 +458,7 @@ void wxToolBarBase::SetToolClientData(int id, wxObject *clientData) int wxToolBarBase::GetToolPos(int id) const { size_t pos = 0; - wxToolBarToolsList::Node *node; + wxToolBarToolsList::compatibility_iterator node; for ( node = m_tools.GetFirst(); node; node = node->GetNext() ) { @@ -587,7 +585,7 @@ void wxToolBarBase::UpdateWindowUI(long flags) wxEvtHandler* evtHandler = GetEventHandler() ; - for ( wxToolBarToolsList::Node* node = m_tools.GetFirst(); + for ( wxToolBarToolsList::compatibility_iterator node = m_tools.GetFirst(); node; node = node->GetNext() ) { diff --git a/src/common/toplvcmn.cpp b/src/common/toplvcmn.cpp index 8768de7360..d5d6bb27fe 100644 --- a/src/common/toplvcmn.cpp +++ b/src/common/toplvcmn.cpp @@ -161,7 +161,7 @@ void wxTopLevelWindowBase::OnSize(wxSizeEvent& WXUNUSED(event)) { // do we have _exactly_ one child? wxWindow *child = (wxWindow *)NULL; - for ( wxWindowList::Node *node = GetChildren().GetFirst(); + for ( wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); node; node = node->GetNext() ) { diff --git a/src/common/valtext.cpp b/src/common/valtext.cpp index 90627aa28d..35b6613421 100644 --- a/src/common/valtext.cpp +++ b/src/common/valtext.cpp @@ -73,20 +73,9 @@ bool wxTextValidator::Copy(const wxTextValidator& val) m_validatorStyle = val.m_validatorStyle ; m_stringValue = val.m_stringValue ; - wxStringList::Node *node = val.m_includeList.GetFirst() ; - while ( node ) - { - wxChar *s = node->GetData(); - m_includeList.Add(s); - node = node->GetNext(); - } - node = val.m_excludeList.GetFirst() ; - while ( node ) - { - wxChar *s = node->GetData(); - m_excludeList.Add(s); - node = node->GetNext(); - } + m_includeList = val.m_includeList; + m_excludeList = val.m_excludeList; + return TRUE; } @@ -232,38 +221,12 @@ bool wxTextValidator::TransferFromWindow(void) void wxTextValidator::SetIncludeList(const wxStringList& list) { -/* - if ( !M_VTEXTDATA ) - return; -*/ - - m_includeList.Clear(); - // TODO: replace with = - wxStringList::Node *node = list.GetFirst(); - while ( node ) - { - wxChar *s = node->GetData(); - m_includeList.Add(s); - node = node->GetNext(); - } + m_includeList = list; } void wxTextValidator::SetExcludeList(const wxStringList& list) { -/* - if ( !M_VTEXTDATA ) - return; -*/ - - m_excludeList.Clear(); - // TODO: replace with = - wxStringList::Node *node = list.GetFirst() ; - while ( node ) - { - wxChar *s = node->GetData(); - m_excludeList.Add(s); - node = node->GetNext(); - } + m_excludeList = list; } void wxTextValidator::OnChar(wxKeyEvent& event) diff --git a/src/common/wincmn.cpp b/src/common/wincmn.cpp index 61402fabf0..6cc620cf4f 100644 --- a/src/common/wincmn.cpp +++ b/src/common/wincmn.cpp @@ -114,7 +114,6 @@ void wxWindowBase::InitBase() // no window yet, no parent nor children m_parent = (wxWindow *)NULL; m_windowId = -1; - m_children.DeleteContents( FALSE ); // don't auto delete node data // no constraints on the minimal window size m_minWidth = @@ -263,7 +262,7 @@ wxWindowBase::~wxWindowBase() // Just in case we've loaded a top-level window via LoadNativeDialog but // we weren't a dialog class - wxTopLevelWindows.DeleteObject(this); + wxTopLevelWindows.DeleteObject((wxWindow*)this); wxASSERT_MSG( GetChildren().GetCount() == 0, wxT("children not destroyed") ); @@ -344,7 +343,7 @@ bool wxWindowBase::Close(bool force) bool wxWindowBase::DestroyChildren() { - wxWindowList::Node *node; + wxWindowList::compatibility_iterator node; for ( ;; ) { // we iterate until the list becomes empty @@ -520,7 +519,7 @@ wxSize wxWindowBase::DoGetBestSize() const int maxX = 0, maxY = 0; - for ( wxWindowList::Node *node = GetChildren().GetFirst(); + for ( wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); node; node = node->GetNext() ) { @@ -554,7 +553,7 @@ wxSize wxWindowBase::DoGetBestSize() const int maxX = 0, maxY = 0; - for ( wxWindowList::Node *node = GetChildren().GetFirst(); + for ( wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); node; node = node->GetNext() ) { @@ -708,9 +707,9 @@ void wxWindowBase::AddChild(wxWindowBase *child) // this should never happen and it will lead to a crash later if it does // because RemoveChild() will remove only one node from the children list // and the other(s) one(s) will be left with dangling pointers in them - wxASSERT_MSG( !GetChildren().Find(child), _T("AddChild() called twice") ); + wxASSERT_MSG( !GetChildren().Find((wxWindow*)child), _T("AddChild() called twice") ); - GetChildren().Append(child); + GetChildren().Append((wxWindow*)child); child->SetParent(this); } @@ -718,8 +717,8 @@ void wxWindowBase::RemoveChild(wxWindowBase *child) { wxCHECK_RET( child, wxT("can't remove a NULL child") ); - GetChildren().DeleteObject(child); - child->SetParent((wxWindow *)NULL); + GetChildren().DeleteObject((wxWindow *)child); + child->SetParent(NULL); } bool wxWindowBase::Reparent(wxWindowBase *newParent) @@ -738,7 +737,7 @@ bool wxWindowBase::Reparent(wxWindowBase *newParent) } else { - wxTopLevelWindows.DeleteObject(this); + wxTopLevelWindows.DeleteObject((wxWindow *)this); } // add it to the new one @@ -748,7 +747,7 @@ bool wxWindowBase::Reparent(wxWindowBase *newParent) } else { - wxTopLevelWindows.Append(this); + wxTopLevelWindows.Append((wxWindow *)this); } return TRUE; @@ -988,7 +987,7 @@ wxWindow *wxWindowBase::FindWindow( long id ) return (wxWindow *)this; wxWindowBase *res = (wxWindow *)NULL; - wxWindowList::Node *node; + wxWindowList::compatibility_iterator node; for ( node = m_children.GetFirst(); node && !res; node = node->GetNext() ) { wxWindowBase *child = node->GetData(); @@ -1004,7 +1003,7 @@ wxWindow *wxWindowBase::FindWindow( const wxString& name ) return (wxWindow *)this; wxWindowBase *res = (wxWindow *)NULL; - wxWindowList::Node *node; + wxWindowList::compatibility_iterator node; for ( node = m_children.GetFirst(); node && !res; node = node->GetNext() ) { wxWindow *child = node->GetData(); @@ -1060,7 +1059,7 @@ wxWindow *wxFindWindowRecursively(const wxWindow *parent, return (wxWindow *)parent; // It wasn't, so check all its children - for ( wxWindowList::Node * node = parent->GetChildren().GetFirst(); + for ( wxWindowList::compatibility_iterator node = parent->GetChildren().GetFirst(); node; node = node->GetNext() ) { @@ -1090,7 +1089,7 @@ wxWindow *wxFindWindowHelper(const wxWindow *parent, } // start at very top of wx's windows - for ( wxWindowList::Node * node = wxTopLevelWindows.GetFirst(); + for ( wxWindowList::compatibility_iterator node = wxTopLevelWindows.GetFirst(); node; node = node->GetNext() ) { @@ -1142,7 +1141,7 @@ void wxWindowBase::MakeModal(bool modal) // Disable all other windows if ( IsTopLevel() ) { - wxWindowList::Node *node = wxTopLevelWindows.GetFirst(); + wxWindowList::compatibility_iterator node = wxTopLevelWindows.GetFirst(); while (node) { wxWindow *win = node->GetData(); @@ -1159,7 +1158,7 @@ bool wxWindowBase::Validate() #if wxUSE_VALIDATORS bool recurse = (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY) != 0; - wxWindowList::Node *node; + wxWindowList::compatibility_iterator node; for ( node = m_children.GetFirst(); node; node = node->GetNext() ) { wxWindowBase *child = node->GetData(); @@ -1184,7 +1183,7 @@ bool wxWindowBase::TransferDataToWindow() #if wxUSE_VALIDATORS bool recurse = (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY) != 0; - wxWindowList::Node *node; + wxWindowList::compatibility_iterator node; for ( node = m_children.GetFirst(); node; node = node->GetNext() ) { wxWindowBase *child = node->GetData(); @@ -1218,7 +1217,7 @@ bool wxWindowBase::TransferDataFromWindow() #if wxUSE_VALIDATORS bool recurse = (GetExtraStyle() & wxWS_EX_VALIDATE_RECURSIVELY) != 0; - wxWindowList::Node *node; + wxWindowList::compatibility_iterator node; for ( node = m_children.GetFirst(); node; node = node->GetNext() ) { wxWindow *child = node->GetData(); @@ -1409,15 +1408,15 @@ void wxWindowBase::AddConstraintReference(wxWindowBase *otherWin) { if ( !m_constraintsInvolvedIn ) m_constraintsInvolvedIn = new wxWindowList; - if ( !m_constraintsInvolvedIn->Find(otherWin) ) - m_constraintsInvolvedIn->Append(otherWin); + if ( !m_constraintsInvolvedIn->Find((wxWindow *)otherWin) ) + m_constraintsInvolvedIn->Append((wxWindow *)otherWin); } // REMOVE back-pointer to other windows we're involved with. void wxWindowBase::RemoveConstraintReference(wxWindowBase *otherWin) { if ( m_constraintsInvolvedIn ) - m_constraintsInvolvedIn->DeleteObject(otherWin); + m_constraintsInvolvedIn->DeleteObject((wxWindow *)otherWin); } // Reset any constraints that mention this window @@ -1425,7 +1424,7 @@ void wxWindowBase::DeleteRelatedConstraints() { if ( m_constraintsInvolvedIn ) { - wxWindowList::Node *node = m_constraintsInvolvedIn->GetFirst(); + wxWindowList::compatibility_iterator node = m_constraintsInvolvedIn->GetFirst(); while (node) { wxWindow *win = node->GetData(); @@ -1444,8 +1443,8 @@ void wxWindowBase::DeleteRelatedConstraints() constr->centreY.ResetIfWin(this); } - wxWindowList::Node *next = node->GetNext(); - delete node; + wxWindowList::compatibility_iterator next = node->GetNext(); + m_constraintsInvolvedIn->Erase(node); node = next; } @@ -1559,7 +1558,7 @@ bool wxWindowBase::DoPhase(int phase) int noChanges = 0; // loop over all children setting their constraints - for ( wxWindowList::Node *node = GetChildren().GetFirst(); + for ( wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); node; node = node->GetNext() ) { @@ -1612,7 +1611,7 @@ void wxWindowBase::ResetConstraints() constr->centreY.SetDone(FALSE); } - wxWindowList::Node *node = GetChildren().GetFirst(); + wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); while (node) { wxWindow *win = node->GetData(); @@ -1654,7 +1653,7 @@ void wxWindowBase::SetConstraintSizes(bool recurse) if ( recurse ) { - wxWindowList::Node *node = GetChildren().GetFirst(); + wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); while (node) { wxWindow *win = node->GetData(); @@ -1782,7 +1781,7 @@ void wxWindowBase::UpdateWindowUI(long flags) if (flags & wxUPDATE_UI_RECURSE) { - wxWindowList::Node* node = GetChildren().GetFirst(); + wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); while (node) { wxWindow* child = (wxWindow*) node->GetData(); @@ -1836,7 +1835,7 @@ void wxWindowBase::ProcessInternalIdle() { OnInternalIdle(); - wxWindowList::Node *node = GetChildren().GetFirst(); + wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); while (node) { wxWindow *child = node->GetData(); @@ -1882,7 +1881,7 @@ wxPoint wxWindowBase::ConvertDialogToPixels(const wxPoint& pt) // propagate the colour change event to the subwindows void wxWindowBase::OnSysColourChanged(wxSysColourChangedEvent& event) { - wxWindowList::Node *node = GetChildren().GetFirst(); + wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); while ( node ) { // Only propagate to non-top-level windows @@ -2004,6 +2003,7 @@ wxAccessible* wxWindowBase::CreateAccessible() #endif +#if !wxUSE_STL // ---------------------------------------------------------------------------- // list classes implementation // ---------------------------------------------------------------------------- @@ -2012,6 +2012,7 @@ void wxWindowListNode::DeleteData() { delete (wxWindow *)GetData(); } +#endif // ---------------------------------------------------------------------------- // borders @@ -2271,7 +2272,7 @@ wxAccStatus wxWindowAccessible::Navigate(wxNavDir navDir, int fromId, case wxNAVDIR_DOWN: case wxNAVDIR_NEXT: { - wxWindowList::Node *node = NULL; + wxWindowList::compatibility_iterator node = NULL; if (fromId == 0) { // Can't navigate to sibling of this window @@ -2284,7 +2285,7 @@ wxAccStatus wxWindowAccessible::Navigate(wxNavDir navDir, int fromId, else { if (fromId <= (int) GetWindow()->GetChildren().GetCount()) - node = (wxWindowList::Node*) GetWindow()->GetChildren().Nth(fromId-1); + node = GetWindow()->GetChildren().Nth(fromId-1); } if (node && node->GetNext()) @@ -2300,7 +2301,7 @@ wxAccStatus wxWindowAccessible::Navigate(wxNavDir navDir, int fromId, case wxNAVDIR_UP: case wxNAVDIR_PREVIOUS: { - wxWindowList::Node *node = NULL; + wxWindowList::compatibility_iterator node = NULL; if (fromId == 0) { // Can't navigate to sibling of this window @@ -2313,7 +2314,7 @@ wxAccStatus wxWindowAccessible::Navigate(wxNavDir navDir, int fromId, else { if (fromId <= (int) GetWindow()->GetChildren().GetCount()) - node = (wxWindowList::Node*) GetWindow()->GetChildren().Nth(fromId-1); + node = GetWindow()->GetChildren().Nth(fromId-1); } if (node && node->GetPrevious()) diff --git a/src/generic/accel.cpp b/src/generic/accel.cpp index bede8f488c..edf52970cd 100644 --- a/src/generic/accel.cpp +++ b/src/generic/accel.cpp @@ -55,16 +55,19 @@ class wxAccelRefData : public wxObjectRefData public: wxAccelRefData() { - m_accels.DeleteContents(TRUE); } wxAccelRefData(const wxAccelRefData& data) : wxObjectRefData() { - m_accels.DeleteContents(TRUE); m_accels = data.m_accels; } + virtual ~wxAccelRefData() + { + WX_CLEAR_LIST(wxAccelList, m_accels); + } + wxAccelList m_accels; }; @@ -133,14 +136,15 @@ void wxAcceleratorTable::Remove(const wxAcceleratorEntry& entry) { AllocExclusive(); - wxAccelList::Node *node = M_ACCELDATA->m_accels.GetFirst(); + wxAccelList::compatibility_iterator node = M_ACCELDATA->m_accels.GetFirst(); while ( node ) { const wxAcceleratorEntry *entryCur = node->GetData(); if ( *entryCur == entry ) { - M_ACCELDATA->m_accels.DeleteNode(node); + delete node->GetData(); + M_ACCELDATA->m_accels.Erase(node); return; } @@ -164,7 +168,7 @@ wxAcceleratorTable::GetEntry(const wxKeyEvent& event) const return NULL; } - wxAccelList::Node *node = M_ACCELDATA->m_accels.GetFirst(); + wxAccelList::compatibility_iterator node = M_ACCELDATA->m_accels.GetFirst(); while ( node ) { const wxAcceleratorEntry *entry = node->GetData(); diff --git a/src/generic/dcpsg.cpp b/src/generic/dcpsg.cpp index c8d9cebdc0..5b5ad1c2f7 100644 --- a/src/generic/dcpsg.cpp +++ b/src/generic/dcpsg.cpp @@ -1564,7 +1564,7 @@ void wxPostScriptDC::DoDrawSpline( wxList *points ) double a, b, c, d, x1, y1, x2, y2, x3, y3; wxPoint *p, *q; - wxNode *node = points->GetFirst(); + wxList::compatibility_iterator node = points->GetFirst(); p = (wxPoint *)node->GetData(); x1 = p->x; y1 = p->y; @@ -1586,7 +1586,7 @@ void wxPostScriptDC::DoDrawSpline( wxList *points ) CalcBoundingBox( (wxCoord)x1, (wxCoord)y1 ); CalcBoundingBox( (wxCoord)x3, (wxCoord)y3 ); - while ((node = node->GetNext()) != NULL) + while ((node = node->GetNext())) { q = (wxPoint *)node->GetData(); diff --git a/src/generic/dirctrlg.cpp b/src/generic/dirctrlg.cpp index e6a1c6822e..045fa1b2b9 100644 --- a/src/generic/dirctrlg.cpp +++ b/src/generic/dirctrlg.cpp @@ -354,11 +354,8 @@ bool wxIsDriveAvailable(const wxString& dirName) // Function which is called by quick sort. We want to override the default wxArrayString behaviour, // and sort regardless of case. -static int LINKAGEMODE wxDirCtrlStringCompareFunction(const void *first, const void *second) +static int LINKAGEMODE wxDirCtrlStringCompareFunction(wxString* strFirst, wxString* strSecond) { - wxString *strFirst = (wxString *)first; - wxString *strSecond = (wxString *)second; - return strFirst->CmpNoCase(*strSecond); } @@ -725,7 +722,7 @@ void wxGenericDirCtrl::ExpandDir(wxTreeItemId parentId) while (d.GetNext(& eachFilename)); } } - dirs.Sort((wxArrayString::CompareFunction) wxDirCtrlStringCompareFunction); + dirs.Sort(wxDirCtrlStringCompareFunction); // Now do the filenames -- but only if we're allowed to if ((GetWindowStyle() & wxDIRCTRL_DIR_ONLY) == 0) @@ -748,7 +745,7 @@ void wxGenericDirCtrl::ExpandDir(wxTreeItemId parentId) while (d.GetNext(& eachFilename)); } } - filenames.Sort((wxArrayString::CompareFunction) wxDirCtrlStringCompareFunction); + filenames.Sort(wxDirCtrlStringCompareFunction); } // Add the sorted dirs @@ -1369,7 +1366,11 @@ wxFileIconsTable::wxFileIconsTable() wxFileIconsTable::~wxFileIconsTable() { - if (m_HashTable) delete m_HashTable; + if (m_HashTable) + { + WX_CLEAR_HASH_TABLE(*m_HashTable); + delete m_HashTable; + } if (m_smallImageList) delete m_smallImageList; } @@ -1380,7 +1381,6 @@ void wxFileIconsTable::Create() m_HashTable = new wxHashTable(wxKEY_STRING); m_smallImageList = new wxImageList(16, 16); - m_HashTable->DeleteContents(TRUE); // folder: m_smallImageList->Add(wxArtProvider::GetBitmap(wxART_FOLDER, wxART_CMN_DIALOG)); // folder_open @@ -1401,6 +1401,7 @@ void wxFileIconsTable::Create() if (GetIconID(wxEmptyString, _T("application/x-executable")) == file) { m_smallImageList->Add(wxArtProvider::GetBitmap(wxART_EXECUTABLE_FILE, wxART_CMN_DIALOG)); + delete m_HashTable->Get(_T("exe")); m_HashTable->Delete(_T("exe")); m_HashTable->Put(_T("exe"), new wxFileIconEntry(executable)); } diff --git a/src/generic/imaglist.cpp b/src/generic/imaglist.cpp index aa0e88d756..18a0f826ff 100644 --- a/src/generic/imaglist.cpp +++ b/src/generic/imaglist.cpp @@ -62,7 +62,6 @@ bool wxGenericImageList::Create( int width, int height, bool WXUNUSED(mask), int bool wxGenericImageList::Create() { - m_images.DeleteContents( TRUE ); return TRUE; } @@ -92,7 +91,7 @@ int wxGenericImageList::Add( const wxBitmap& bitmap, const wxColour& maskColour const wxBitmap *wxGenericImageList::GetBitmap( int index ) const { - wxNode *node = m_images.Item( index ); + wxList::compatibility_iterator node = m_images.Item( index ); wxCHECK_MSG( node, (wxBitmap *) NULL, wxT("wrong index in image list") ); @@ -101,7 +100,7 @@ const wxBitmap *wxGenericImageList::GetBitmap( int index ) const bool wxGenericImageList::Replace( int index, const wxBitmap &bitmap ) { - wxNode *node = m_images.Item( index ); + wxList::compatibility_iterator node = m_images.Item( index ); wxCHECK_MSG( node, FALSE, wxT("wrong index in image list") ); @@ -119,13 +118,15 @@ bool wxGenericImageList::Replace( int index, const wxBitmap &bitmap ) if (index == (int) m_images.GetCount() - 1) { - m_images.DeleteNode( node ); + delete node->GetData(); + m_images.Erase( node ); m_images.Append( newBitmap ); } else { - wxNode *next = node->GetNext(); - m_images.DeleteNode( node ); + wxList::compatibility_iterator next = node->GetNext(); + delete node->GetData(); + m_images.Erase( node ); m_images.Insert( next, newBitmap ); } @@ -134,17 +135,19 @@ bool wxGenericImageList::Replace( int index, const wxBitmap &bitmap ) bool wxGenericImageList::Remove( int index ) { - wxNode *node = m_images.Item( index ); + wxList::compatibility_iterator node = m_images.Item( index ); wxCHECK_MSG( node, FALSE, wxT("wrong index in image list") ); - m_images.DeleteNode( node ); + delete node->GetData(); + m_images.Erase( node ); return TRUE; } bool wxGenericImageList::RemoveAll() { + WX_CLEAR_LIST(wxList, m_images); m_images.Clear(); return TRUE; @@ -155,7 +158,7 @@ bool wxGenericImageList::GetSize( int index, int &width, int &height ) const width = 0; height = 0; - wxNode *node = m_images.Item( index ); + wxList::compatibility_iterator node = m_images.Item( index ); wxCHECK_MSG( node, FALSE, wxT("wrong index in image list") ); @@ -169,7 +172,7 @@ bool wxGenericImageList::GetSize( int index, int &width, int &height ) const bool wxGenericImageList::Draw( int index, wxDC &dc, int x, int y, int flags, bool WXUNUSED(solidBackground) ) { - wxNode *node = m_images.Item( index ); + wxList::compatibility_iterator node = m_images.Item( index ); wxCHECK_MSG( node, FALSE, wxT("wrong index in image list") ); diff --git a/src/generic/laywin.cpp b/src/generic/laywin.cpp index 943351d8e6..e32bb52e57 100644 --- a/src/generic/laywin.cpp +++ b/src/generic/laywin.cpp @@ -195,7 +195,7 @@ bool wxLayoutAlgorithm::LayoutMDIFrame(wxMDIParentFrame* frame, wxRect* r) wxCalculateLayoutEvent event; event.SetRect(rect); - wxWindowList::Node *node = frame->GetChildren().GetFirst(); + wxWindowList::compatibility_iterator node = frame->GetChildren().GetFirst(); while (node) { wxWindow* win = node->GetData(); @@ -264,7 +264,7 @@ bool wxLayoutAlgorithm::LayoutWindow(wxWindow* parent, wxWindow* mainWindow) // Find the last layout-aware window, so we can make it fill all remaining // space. wxWindow *lastAwareWindow = NULL; - wxWindowList::Node *node = parent->GetChildren().GetFirst(); + wxWindowList::compatibility_iterator node = parent->GetChildren().GetFirst(); while (node) { diff --git a/src/generic/listctrl.cpp b/src/generic/listctrl.cpp index cb767bfccc..704fb6e867 100644 --- a/src/generic/listctrl.cpp +++ b/src/generic/listctrl.cpp @@ -289,7 +289,11 @@ public: public: wxListLineData(wxListMainWindow *owner); - ~wxListLineData() { delete m_gi; } + ~wxListLineData() + { + WX_CLEAR_LIST(wxListItemDataList, m_items); + delete m_gi; + } // are we in report mode? inline bool InReportView() const; @@ -1090,7 +1094,6 @@ inline bool wxListLineData::IsVirtual() const wxListLineData::wxListLineData( wxListMainWindow *owner ) { m_owner = owner; - m_items.DeleteContents( TRUE ); if ( InReportView() ) { @@ -1108,7 +1111,7 @@ wxListLineData::wxListLineData( wxListMainWindow *owner ) void wxListLineData::CalculateSize( wxDC *dc, int spacing ) { - wxListItemDataList::Node *node = m_items.GetFirst(); + wxListItemDataList::compatibility_iterator node = m_items.GetFirst(); wxCHECK_RET( node, _T("no subitems at all??") ); wxListItemData *item = node->GetData(); @@ -1218,7 +1221,7 @@ void wxListLineData::SetPosition( int x, int y, int window_width, int spacing ) { - wxListItemDataList::Node *node = m_items.GetFirst(); + wxListItemDataList::compatibility_iterator node = m_items.GetFirst(); wxCHECK_RET( node, _T("no subitems at all??") ); wxListItemData *item = node->GetData(); @@ -1291,7 +1294,7 @@ void wxListLineData::InitItems( int num ) void wxListLineData::SetItem( int index, const wxListItem &info ) { - wxListItemDataList::Node *node = m_items.Item( index ); + wxListItemDataList::compatibility_iterator node = m_items.Item( index ); wxCHECK_RET( node, _T("invalid column index in SetItem") ); wxListItemData *item = node->GetData(); @@ -1300,7 +1303,7 @@ void wxListLineData::SetItem( int index, const wxListItem &info ) void wxListLineData::GetItem( int index, wxListItem &info ) { - wxListItemDataList::Node *node = m_items.Item( index ); + wxListItemDataList::compatibility_iterator node = m_items.Item( index ); if (node) { wxListItemData *item = node->GetData(); @@ -1312,7 +1315,7 @@ wxString wxListLineData::GetText(int index) const { wxString s; - wxListItemDataList::Node *node = m_items.Item( index ); + wxListItemDataList::compatibility_iterator node = m_items.Item( index ); if (node) { wxListItemData *item = node->GetData(); @@ -1324,7 +1327,7 @@ wxString wxListLineData::GetText(int index) const void wxListLineData::SetText( int index, const wxString s ) { - wxListItemDataList::Node *node = m_items.Item( index ); + wxListItemDataList::compatibility_iterator node = m_items.Item( index ); if (node) { wxListItemData *item = node->GetData(); @@ -1334,7 +1337,7 @@ void wxListLineData::SetText( int index, const wxString s ) void wxListLineData::SetImage( int index, int image ) { - wxListItemDataList::Node *node = m_items.Item( index ); + wxListItemDataList::compatibility_iterator node = m_items.Item( index ); wxCHECK_RET( node, _T("invalid column index in SetImage()") ); wxListItemData *item = node->GetData(); @@ -1343,7 +1346,7 @@ void wxListLineData::SetImage( int index, int image ) int wxListLineData::GetImage( int index ) const { - wxListItemDataList::Node *node = m_items.Item( index ); + wxListItemDataList::compatibility_iterator node = m_items.Item( index ); wxCHECK_MSG( node, -1, _T("invalid column index in GetImage()") ); wxListItemData *item = node->GetData(); @@ -1352,7 +1355,7 @@ int wxListLineData::GetImage( int index ) const wxListItemAttr *wxListLineData::GetAttr() const { - wxListItemDataList::Node *node = m_items.GetFirst(); + wxListItemDataList::compatibility_iterator node = m_items.GetFirst(); wxCHECK_MSG( node, NULL, _T("invalid column index in GetAttr()") ); wxListItemData *item = node->GetData(); @@ -1361,7 +1364,7 @@ wxListItemAttr *wxListLineData::GetAttr() const void wxListLineData::SetAttr(wxListItemAttr *attr) { - wxListItemDataList::Node *node = m_items.GetFirst(); + wxListItemDataList::compatibility_iterator node = m_items.GetFirst(); wxCHECK_RET( node, _T("invalid column index in SetAttr()") ); wxListItemData *item = node->GetData(); @@ -1434,7 +1437,7 @@ bool wxListLineData::SetAttributes(wxDC *dc, void wxListLineData::Draw( wxDC *dc ) { - wxListItemDataList::Node *node = m_items.GetFirst(); + wxListItemDataList::compatibility_iterator node = m_items.GetFirst(); wxCHECK_RET( node, _T("no subitems at all??") ); bool highlighted = IsHighlighted(); @@ -1481,7 +1484,7 @@ void wxListLineData::DrawInReportMode( wxDC *dc, y = rect.y + (LINE_SPACING + EXTRA_HEIGHT) / 2; size_t col = 0; - for ( wxListItemDataList::Node *node = m_items.GetFirst(); + for ( wxListItemDataList::compatibility_iterator node = m_items.GetFirst(); node; node = node->GetNext(), col++ ) { @@ -2169,7 +2172,6 @@ END_EVENT_TABLE() void wxListMainWindow::Init() { - m_columns.DeleteContents( TRUE ); m_dirty = TRUE; m_countVirt = 0; m_lineFrom = @@ -2265,6 +2267,7 @@ wxListMainWindow::wxListMainWindow( wxWindow *parent, wxListMainWindow::~wxListMainWindow() { DoDeleteAllItems(); + WX_CLEAR_LIST(wxListHeaderDataList, m_columns); delete m_highlightBrush; delete m_highlightUnfocusedBrush; @@ -3506,7 +3509,7 @@ int wxListMainWindow::GetItemSpacing( bool isSmall ) void wxListMainWindow::SetColumn( int col, wxListItem &item ) { - wxListHeaderDataList::Node *node = m_columns.Item( col ); + wxListHeaderDataList::compatibility_iterator node = m_columns.Item( col ); wxCHECK_RET( node, _T("invalid column index in SetColumn") ); @@ -3539,7 +3542,7 @@ void wxListMainWindow::SetColumnWidth( int col, int width ) if ( headerWin ) headerWin->m_dirty = TRUE; - wxListHeaderDataList::Node *node = m_columns.Item( col ); + wxListHeaderDataList::compatibility_iterator node = m_columns.Item( col ); wxCHECK_RET( node, _T("no column?") ); wxListHeaderData *column = node->GetData(); @@ -3567,7 +3570,7 @@ void wxListMainWindow::SetColumnWidth( int col, int width ) for ( size_t i = 0; i < count; i++ ) { wxListLineData *line = GetLine(i); - wxListItemDataList::Node *n = line->m_items.Item( col ); + wxListItemDataList::compatibility_iterator n = line->m_items.Item( col ); wxCHECK_RET( n, _T("no subitem?") ); @@ -3620,7 +3623,7 @@ int wxListMainWindow::GetHeaderWidth() const void wxListMainWindow::GetColumn( int col, wxListItem &item ) const { - wxListHeaderDataList::Node *node = m_columns.Item( col ); + wxListHeaderDataList::compatibility_iterator node = m_columns.Item( col ); wxCHECK_RET( node, _T("invalid column index in GetColumn") ); wxListHeaderData *column = node->GetData(); @@ -3629,7 +3632,7 @@ void wxListMainWindow::GetColumn( int col, wxListItem &item ) const int wxListMainWindow::GetColumnWidth( int col ) const { - wxListHeaderDataList::Node *node = m_columns.Item( col ); + wxListHeaderDataList::compatibility_iterator node = m_columns.Item( col ); wxCHECK_MSG( node, 0, _T("invalid column index") ); wxListHeaderData *column = node->GetData(); @@ -4106,12 +4109,13 @@ void wxListMainWindow::DeleteItem( long lindex ) void wxListMainWindow::DeleteColumn( int col ) { - wxListHeaderDataList::Node *node = m_columns.Item( col ); + wxListHeaderDataList::compatibility_iterator node = m_columns.Item( col ); wxCHECK_RET( node, wxT("invalid column index in DeleteColumn()") ); m_dirty = TRUE; - m_columns.DeleteNode( node ); + delete node->GetData(); + m_columns.Erase( node ); if ( !IsVirtual() ) { @@ -4119,8 +4123,9 @@ void wxListMainWindow::DeleteColumn( int col ) for ( size_t i = 0; i < m_lines.GetCount(); i++ ) { wxListLineData * const line = GetLine(i); - wxListItemDataList::Node *n = line->m_items.Item( col ); - line->m_items.DeleteNode(n); + wxListItemDataList::compatibility_iterator n = line->m_items.Item( col ); + delete n->GetData(); + line->m_items.Erase(n); } } @@ -4171,7 +4176,7 @@ void wxListMainWindow::DeleteAllItems() void wxListMainWindow::DeleteEverything() { - m_columns.Clear(); + WX_CLEAR_LIST(wxListHeaderDataList, m_columns); DeleteAllItems(); } @@ -4321,7 +4326,7 @@ void wxListMainWindow::InsertColumn( long col, wxListItem &item ) bool insert = (col >= 0) && ((size_t)col < m_columns.GetCount()); if ( insert ) { - wxListHeaderDataList::Node *node = m_columns.Item( col ); + wxListHeaderDataList::compatibility_iterator node = m_columns.Item( col ); m_columns.Insert( node, column ); } else diff --git a/src/generic/prntdlgg.cpp b/src/generic/prntdlgg.cpp index 38dd0fdfee..49cb50fb98 100644 --- a/src/generic/prntdlgg.cpp +++ b/src/generic/prntdlgg.cpp @@ -503,7 +503,7 @@ bool wxGenericPrintSetupDialog::TransferDataFromWindow() int selectedItem = m_paperTypeChoice->GetSelection(); if (selectedItem != -1) { - wxPrintPaperType *paper = (wxPrintPaperType*)wxThePrintPaperDatabase->Item(selectedItem)->GetData(); + wxPrintPaperType *paper = wxThePrintPaperDatabase->Item(selectedItem); if (paper != NULL) m_printData.SetPaperId( paper->GetId()); } @@ -527,7 +527,7 @@ wxComboBox *wxGenericPrintSetupDialog::CreatePaperTypeChoice(int *x, int *y) for (size_t i = 0; i < n; i++) { - wxPrintPaperType *paper = (wxPrintPaperType *)wxThePrintPaperDatabase->Item(i)->GetData(); + wxPrintPaperType *paper = wxThePrintPaperDatabase->Item(i); choices[i] = paper->GetName(); if (m_printData.GetPaperId() == paper->GetId()) sel = i; @@ -611,7 +611,7 @@ wxGenericPageSetupDialog::wxGenericPageSetupDialog( wxWindow *parent, for (size_t i = 0; i < n; i++) { - wxPrintPaperType *paper = (wxPrintPaperType *)wxThePrintPaperDatabase->Item(i)->GetData(); + wxPrintPaperType *paper = wxThePrintPaperDatabase->Item(i); choices[i] = paper->GetName(); } @@ -774,7 +774,7 @@ bool wxGenericPageSetupDialog::TransferDataFromWindow() int selectedItem = m_paperTypeChoice->GetSelection(); if (selectedItem != -1) { - wxPrintPaperType *paper = (wxPrintPaperType*)wxThePrintPaperDatabase->Item(selectedItem)->GetData(); + wxPrintPaperType *paper = wxThePrintPaperDatabase->Item(selectedItem); if ( paper ) { m_pageData.SetPaperSize(wxSize(paper->GetWidth()/10, paper->GetHeight()/10)); @@ -801,7 +801,7 @@ wxComboBox *wxGenericPageSetupDialog::CreatePaperTypeChoice(int *x, int *y) for (size_t i = 0; i < n; i++) { - wxPrintPaperType *paper = (wxPrintPaperType *)wxThePrintPaperDatabase->Item(i)->GetData(); + wxPrintPaperType *paper = wxThePrintPaperDatabase->Item(i); choices[i] = paper->GetName(); } diff --git a/src/generic/tbarsmpl.cpp b/src/generic/tbarsmpl.cpp index 1273337296..8aceb7f09d 100644 --- a/src/generic/tbarsmpl.cpp +++ b/src/generic/tbarsmpl.cpp @@ -276,7 +276,7 @@ bool wxToolBarSimple::Realize() int maxToolHeight = 0; // Find the maximum tool width and height - wxToolBarToolsList::Node *node = m_tools.GetFirst(); + wxToolBarToolsList::compatibility_iterator node = m_tools.GetFirst(); while ( node ) { wxToolBarToolSimple *tool = (wxToolBarToolSimple *)node->GetData(); @@ -382,7 +382,7 @@ void wxToolBarSimple::OnPaint (wxPaintEvent& WXUNUSED(event)) return; count++; - for ( wxToolBarToolsList::Node *node = m_tools.GetFirst(); + for ( wxToolBarToolsList::compatibility_iterator node = m_tools.GetFirst(); node; node = node->GetNext() ) { @@ -651,7 +651,7 @@ void wxToolBarSimple::SetRows(int nRows) wxToolBarToolBase *wxToolBarSimple::FindToolForPosition(wxCoord x, wxCoord y) const { - wxToolBarToolsList::Node *node = m_tools.GetFirst(); + wxToolBarToolsList::compatibility_iterator node = m_tools.GetFirst(); while (node) { wxToolBarToolSimple *tool = (wxToolBarToolSimple *)node->GetData(); diff --git a/src/gtk/choice.cpp b/src/gtk/choice.cpp index b04477bdd4..05b88cc2ae 100644 --- a/src/gtk/choice.cpp +++ b/src/gtk/choice.cpp @@ -156,7 +156,7 @@ void wxChoice::DoSetItemClientData( int n, void* clientData ) { wxCHECK_RET( m_widget != NULL, wxT("invalid choice control") ); - wxNode *node = m_clientList.Item( n ); + wxList::compatibility_iterator node = m_clientList.Item( n ); wxCHECK_RET( node, wxT("invalid index in wxChoice::DoSetItemClientData") ); node->SetData( (wxObject*) clientData ); @@ -166,7 +166,7 @@ void* wxChoice::DoGetItemClientData( int n ) const { wxCHECK_MSG( m_widget != NULL, NULL, wxT("invalid choice control") ); - wxNode *node = m_clientList.Item( n ); + wxList::compatibility_iterator node = m_clientList.Item( n ); wxCHECK_MSG( node, NULL, wxT("invalid index in wxChoice::DoGetItemClientData") ); return node->GetData(); @@ -176,7 +176,7 @@ void wxChoice::DoSetItemClientObject( int n, wxClientData* clientData ) { wxCHECK_RET( m_widget != NULL, wxT("invalid choice control") ); - wxNode *node = m_clientList.Item( n ); + wxList::compatibility_iterator node = m_clientList.Item( n ); wxCHECK_RET( node, wxT("invalid index in wxChoice::DoSetItemClientObject") ); // wxItemContainer already deletes data for us @@ -188,7 +188,7 @@ wxClientData* wxChoice::DoGetItemClientObject( int n ) const { wxCHECK_MSG( m_widget != NULL, (wxClientData*) NULL, wxT("invalid choice control") ); - wxNode *node = m_clientList.Item( n ); + wxList::compatibility_iterator node = m_clientList.Item( n ); wxCHECK_MSG( node, (wxClientData *)NULL, wxT("invalid index in wxChoice::DoGetItemClientObject") ); @@ -208,7 +208,7 @@ void wxChoice::Clear() // destroy the data (due to Robert's idea of using wxList // and not wxList we can't just say // m_clientList.DeleteContents(TRUE) - this would crash! - wxNode *node = m_clientList.GetFirst(); + wxList::compatibility_iterator node = m_clientList.GetFirst(); while ( node ) { delete (wxClientData *)node->GetData(); diff --git a/src/gtk/colour.cpp b/src/gtk/colour.cpp index c57698a100..ce9b00c4c1 100644 --- a/src/gtk/colour.cpp +++ b/src/gtk/colour.cpp @@ -156,12 +156,13 @@ wxColour::wxColour( unsigned char red, unsigned char green, unsigned char blue ) M_COLDATA->m_color.pixel = 0; } + + void wxColour::InitFromName( const wxString &colourName ) { - wxNode *node = (wxNode *) NULL; - if ( (wxTheColourDatabase) && (node = wxTheColourDatabase->Find(colourName)) ) + wxColour* col = NULL; + if ( (wxTheColourDatabase) && (col = wxTheColourDatabase->FindColourNoAdd(colourName)) ) { - wxColour *col = (wxColour*)node->GetData(); UnRef(); if (col) Ref( *col ); } diff --git a/src/gtk/combobox.cpp b/src/gtk/combobox.cpp index 13d19d958b..7db2b2f750 100644 --- a/src/gtk/combobox.cpp +++ b/src/gtk/combobox.cpp @@ -197,7 +197,7 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value, wxComboBox::~wxComboBox() { - wxNode *node = m_clientObjectList.GetFirst(); + wxList::compatibility_iterator node = m_clientObjectList.GetFirst(); while (node) { wxClientData *cd = (wxClientData*)node->GetData(); @@ -360,7 +360,7 @@ void wxComboBox::SetClientData( int n, void* clientData ) { wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") ); - wxNode *node = m_clientDataList.Item( n ); + wxList::compatibility_iterator node = m_clientDataList.Item( n ); if (!node) return; node->SetData( (wxObject*) clientData ); @@ -370,7 +370,7 @@ void* wxComboBox::GetClientData( int n ) const { wxCHECK_MSG( m_widget != NULL, NULL, wxT("invalid combobox") ); - wxNode *node = m_clientDataList.Item( n ); + wxList::compatibility_iterator node = m_clientDataList.Item( n ); return node ? node->GetData() : NULL; } @@ -379,7 +379,7 @@ void wxComboBox::SetClientObject( int n, wxClientData* clientData ) { wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") ); - wxNode *node = m_clientObjectList.Item( n ); + wxList::compatibility_iterator node = m_clientObjectList.Item( n ); if (!node) return; wxClientData *cd = (wxClientData*) node->GetData(); @@ -392,7 +392,7 @@ wxClientData* wxComboBox::GetClientObject( int n ) const { wxCHECK_MSG( m_widget != NULL, (wxClientData*)NULL, wxT("invalid combobox") ); - wxNode *node = m_clientObjectList.Item( n ); + wxList::compatibility_iterator node = m_clientObjectList.Item( n ); return node ? (wxClientData*) node->GetData() : NULL; } @@ -406,7 +406,7 @@ void wxComboBox::Clear() GtkWidget *list = GTK_COMBO(m_widget)->list; gtk_list_clear_items( GTK_LIST(list), 0, Number() ); - wxNode *node = m_clientObjectList.GetFirst(); + wxList::compatibility_iterator node = m_clientObjectList.GetFirst(); while (node) { wxClientData *cd = (wxClientData*)node->GetData(); @@ -440,18 +440,18 @@ void wxComboBox::Delete( int n ) gtk_list_remove_items( listbox, list ); g_list_free( list ); - wxNode *node = m_clientObjectList.Item( n ); + wxList::compatibility_iterator node = m_clientObjectList.Item( n ); if (node) { wxClientData *cd = (wxClientData*)node->GetData(); if (cd) delete cd; - m_clientObjectList.DeleteNode( node ); + m_clientObjectList.Erase( node ); } node = m_clientDataList.Item( n ); if (node) - m_clientDataList.DeleteNode( node ); - + m_clientDataList.Erase( node ); + EnableEvents(); } diff --git a/src/gtk/listbox.cpp b/src/gtk/listbox.cpp index da15521495..fc1783f954 100644 --- a/src/gtk/listbox.cpp +++ b/src/gtk/listbox.cpp @@ -448,7 +448,7 @@ void wxListBox::DoInsertItems(const wxArrayString& items, int pos) if (index != GetCount()) { GtkAddItem( items[n], index ); - wxNode *node = m_clientList.Item( index ); + wxList::compatibility_iterator node = m_clientList.Item( index ); m_clientList.Insert( node, (wxObject*) NULL ); } else @@ -471,7 +471,7 @@ void wxListBox::DoInsertItems(const wxArrayString& items, int pos) } else { - wxNode *node = m_clientList.Item( pos ); + wxList::compatibility_iterator node = m_clientList.Item( pos ); for ( size_t n = 0; n < nItems; n++ ) { GtkAddItem( items[n], pos+n ); @@ -497,7 +497,7 @@ int wxListBox::DoAppend( const wxString& item ) { GtkAddItem( item, index ); - wxNode *node = m_clientList.Item( index ); + wxList::compatibility_iterator node = m_clientList.Item( index ); m_clientList.Insert( node, (wxObject *)NULL ); return index; @@ -619,7 +619,7 @@ void wxListBox::Clear() // destroy the data (due to Robert's idea of using wxList // and not wxList we can't just say // m_clientList.DeleteContents(TRUE) - this would crash! - wxNode *node = m_clientList.GetFirst(); + wxList::compatibility_iterator node = m_clientList.GetFirst(); while ( node ) { delete (wxClientData *)node->GetData(); @@ -644,7 +644,7 @@ void wxListBox::Delete( int n ) gtk_list_remove_items( m_list, list ); g_list_free( list ); - wxNode *node = m_clientList.Item( n ); + wxList::compatibility_iterator node = m_clientList.Item( n ); if ( node ) { if ( m_clientDataItemsType == wxClientData_Object ) @@ -653,7 +653,7 @@ void wxListBox::Delete( int n ) delete cd; } - m_clientList.DeleteNode( node ); + m_clientList.Erase( node ); } if ( m_strings ) @@ -668,7 +668,7 @@ void wxListBox::DoSetItemClientData( int n, void* clientData ) { wxCHECK_RET( m_widget != NULL, wxT("invalid listbox control") ); - wxNode *node = m_clientList.Item( n ); + wxList::compatibility_iterator node = m_clientList.Item( n ); wxCHECK_RET( node, wxT("invalid index in wxListBox::DoSetItemClientData") ); node->SetData( (wxObject*) clientData ); @@ -678,7 +678,7 @@ void* wxListBox::DoGetItemClientData( int n ) const { wxCHECK_MSG( m_widget != NULL, NULL, wxT("invalid listbox control") ); - wxNode *node = m_clientList.Item( n ); + wxList::compatibility_iterator node = m_clientList.Item( n ); wxCHECK_MSG( node, NULL, wxT("invalid index in wxListBox::DoGetItemClientData") ); return node->GetData(); @@ -688,7 +688,7 @@ void wxListBox::DoSetItemClientObject( int n, wxClientData* clientData ) { wxCHECK_RET( m_widget != NULL, wxT("invalid listbox control") ); - wxNode *node = m_clientList.Item( n ); + wxList::compatibility_iterator node = m_clientList.Item( n ); wxCHECK_RET( node, wxT("invalid index in wxListBox::DoSetItemClientObject") ); // wxItemContainer already deletes data for us @@ -700,7 +700,7 @@ wxClientData* wxListBox::DoGetItemClientObject( int n ) const { wxCHECK_MSG( m_widget != NULL, (wxClientData*) NULL, wxT("invalid listbox control") ); - wxNode *node = m_clientList.Item( n ); + wxList::compatibility_iterator node = m_clientList.Item( n ); wxCHECK_MSG( node, (wxClientData *)NULL, wxT("invalid index in wxListBox::DoGetItemClientObject") ); diff --git a/src/gtk/mdi.cpp b/src/gtk/mdi.cpp index 08f0a4e5db..8cf797cd63 100644 --- a/src/gtk/mdi.cpp +++ b/src/gtk/mdi.cpp @@ -75,7 +75,7 @@ gtk_mdi_page_change_callback( GtkNotebook *WXUNUSED(widget), child = (wxMDIChildFrame*) NULL; - wxWindowList::Node *node = client_window->GetChildren().GetFirst(); + wxWindowList::compatibility_iterator node = client_window->GetChildren().GetFirst(); while (node) { wxMDIChildFrame *child_frame = wxDynamicCast( node->GetData(), wxMDIChildFrame ); @@ -170,7 +170,7 @@ void wxMDIParentFrame::OnInternalIdle() wxMDIChildFrame *active_child_frame = GetActiveChild(); bool visible_child_menu = false; - wxWindowList::Node *node = m_clientWindow->GetChildren().GetFirst(); + wxWindowList::compatibility_iterator node = m_clientWindow->GetChildren().GetFirst(); while (node) { wxMDIChildFrame *child_frame = wxDynamicCast( node->GetData(), wxMDIChildFrame ); @@ -247,7 +247,7 @@ wxMDIChildFrame *wxMDIParentFrame::GetActiveChild() const GtkNotebookPage* page = (GtkNotebookPage*) (g_list_nth(notebook->children,i)->data); if (!page) return (wxMDIChildFrame*) NULL; - wxWindowList::Node *node = m_clientWindow->GetChildren().GetFirst(); + wxWindowList::compatibility_iterator node = m_clientWindow->GetChildren().GetFirst(); while (node) { wxMDIChildFrame *child_frame = wxDynamicCast( node->GetData(), wxMDIChildFrame ); diff --git a/src/gtk/menu.cpp b/src/gtk/menu.cpp index dea54b9e72..c3593081d8 100644 --- a/src/gtk/menu.cpp +++ b/src/gtk/menu.cpp @@ -200,8 +200,6 @@ wxMenuBar::wxMenuBar( long style ) return; } - m_menus.DeleteContents( TRUE ); - /* GTK 1.2.0 doesn't have gtk_item_factory_get_item(), but GTK 1.2.1 has. */ #if GTK_CHECK_VERSION(1, 2, 1) m_accel = gtk_accel_group_new(); @@ -241,8 +239,6 @@ wxMenuBar::wxMenuBar() return; } - m_menus.DeleteContents( TRUE ); - /* GTK 1.2.0 doesn't have gtk_item_factory_get_item(), but GTK 1.2.1 has. */ #if GTK_CHECK_VERSION(1, 2, 1) m_accel = gtk_accel_group_new(); @@ -275,7 +271,7 @@ static void wxMenubarUnsetInvokingWindow( wxMenu *menu, wxWindow *win ) /* support for native hot keys */ gtk_accel_group_detach( menu->m_accel, ACCEL_OBJ_CAST(top_frame->m_widget) ); - wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst(); + wxMenuItemList::compatibility_iterator node = menu->GetMenuItems().GetFirst(); while (node) { wxMenuItem *menuitem = node->GetData(); @@ -300,7 +296,7 @@ static void wxMenubarSetInvokingWindow( wxMenu *menu, wxWindow *win ) gtk_accel_group_attach( menu->m_accel, obj ); #endif // GTK+ 1.2.1+ - wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst(); + wxMenuItemList::compatibility_iterator node = menu->GetMenuItems().GetFirst(); while (node) { wxMenuItem *menuitem = node->GetData(); @@ -324,7 +320,7 @@ void wxMenuBar::SetInvokingWindow( wxWindow *win ) gtk_accel_group_attach( m_accel, obj ); #endif // GTK+ 1.2.1+ - wxMenuList::Node *node = m_menus.GetFirst(); + wxMenuList::compatibility_iterator node = m_menus.GetFirst(); while (node) { wxMenu *menu = node->GetData(); @@ -345,7 +341,7 @@ void wxMenuBar::UnsetInvokingWindow( wxWindow *win ) gtk_accel_group_detach( m_accel, ACCEL_OBJ_CAST(top_frame->m_widget) ); #endif // GTK+ 1.2.1+ - wxMenuList::Node *node = m_menus.GetFirst(); + wxMenuList::compatibility_iterator node = m_menus.GetFirst(); while (node) { wxMenu *menu = node->GetData(); @@ -474,7 +470,7 @@ wxMenu *wxMenuBar::Replace(size_t pos, wxMenu *menu, const wxString& title) static wxMenu *CopyMenu (wxMenu *menu) { wxMenu *menucopy = new wxMenu (); - wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst(); + wxMenuItemList::compatibility_iterator node = menu->GetMenuItems().GetFirst(); while (node) { wxMenuItem *item = node->GetData(); @@ -552,7 +548,7 @@ static int FindMenuItemRecursive( const wxMenu *menu, const wxString &menuString return res; } - wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst(); + wxMenuItemList::compatibility_iterator node = menu->GetMenuItems().GetFirst(); while (node) { wxMenuItem *item = node->GetData(); @@ -567,7 +563,7 @@ static int FindMenuItemRecursive( const wxMenu *menu, const wxString &menuString int wxMenuBar::FindMenuItem( const wxString &menuString, const wxString &itemString ) const { - wxMenuList::Node *node = m_menus.GetFirst(); + wxMenuList::compatibility_iterator node = m_menus.GetFirst(); while (node) { wxMenu *menu = node->GetData(); @@ -585,7 +581,7 @@ static wxMenuItem* FindMenuItemByIdRecursive(const wxMenu* menu, int id) { wxMenuItem* result = menu->FindChildItem(id); - wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst(); + wxMenuItemList::compatibility_iterator node = menu->GetMenuItems().GetFirst(); while ( node && result == NULL ) { wxMenuItem *item = node->GetData(); @@ -602,7 +598,7 @@ static wxMenuItem* FindMenuItemByIdRecursive(const wxMenu* menu, int id) wxMenuItem* wxMenuBar::FindItem( int id, wxMenu **menuForItem ) const { wxMenuItem* result = 0; - wxMenuList::Node *node = m_menus.GetFirst(); + wxMenuList::compatibility_iterator node = m_menus.GetFirst(); while (node && result == 0) { wxMenu *menu = node->GetData(); @@ -620,7 +616,7 @@ wxMenuItem* wxMenuBar::FindItem( int id, wxMenu **menuForItem ) const void wxMenuBar::EnableTop( size_t pos, bool flag ) { - wxMenuList::Node *node = m_menus.Item( pos ); + wxMenuList::compatibility_iterator node = m_menus.Item( pos ); wxCHECK_RET( node, wxT("menu not found") ); @@ -632,7 +628,7 @@ void wxMenuBar::EnableTop( size_t pos, bool flag ) wxString wxMenuBar::GetLabelTop( size_t pos ) const { - wxMenuList::Node *node = m_menus.Item( pos ); + wxMenuList::compatibility_iterator node = m_menus.Item( pos ); wxCHECK_MSG( node, wxT("invalid"), wxT("menu not found") ); @@ -659,7 +655,7 @@ wxString wxMenuBar::GetLabelTop( size_t pos ) const void wxMenuBar::SetLabelTop( size_t pos, const wxString& label ) { - wxMenuList::Node *node = m_menus.Item( pos ); + wxMenuList::compatibility_iterator node = m_menus.Item( pos ); wxCHECK_RET( node, wxT("menu not found") ); @@ -1122,7 +1118,7 @@ void wxMenu::Init() wxMenu::~wxMenu() { - m_items.Clear(); + WX_CLEAR_LIST(wxMenuItemList, m_items); if ( GTK_IS_WIDGET( m_menu )) gtk_widget_destroy( m_menu ); @@ -1398,7 +1394,7 @@ wxMenuItem *wxMenu::DoRemove(wxMenuItem *item) int wxMenu::FindMenuIdByMenuItem( GtkWidget *menuItem ) const { - wxMenuItemList::Node *node = m_items.GetFirst(); + wxMenuItemList::compatibility_iterator node = m_items.GetFirst(); while (node) { wxMenuItem *item = node->GetData(); diff --git a/src/gtk/notebook.cpp b/src/gtk/notebook.cpp index a904117faf..33aa5ab39d 100644 --- a/src/gtk/notebook.cpp +++ b/src/gtk/notebook.cpp @@ -240,7 +240,6 @@ void wxNotebook::Init() m_inSwitchPage = FALSE; m_imageList = (wxImageList *) NULL; - m_pagesData.DeleteContents( TRUE ); m_selection = -1; m_themeEnabled = TRUE; } @@ -567,7 +566,9 @@ wxNotebookPage *wxNotebook::DoRemovePage( int page ) gtk_notebook_remove_page( GTK_NOTEBOOK(m_widget), page ); - m_pagesData.DeleteObject(GetNotebookPage(page)); + wxGtkNotebookPage* p = GetNotebookPage(page); + m_pagesData.DeleteObject(p); + delete p; return client; } diff --git a/src/gtk/radiobox.cpp b/src/gtk/radiobox.cpp index 3d70c8d4e1..855f838e87 100644 --- a/src/gtk/radiobox.cpp +++ b/src/gtk/radiobox.cpp @@ -80,7 +80,7 @@ static gint gtk_radiobox_keypress_callback( GtkWidget *widget, GdkEventKey *gdk_ return FALSE; } - wxNode *node = rb->m_boxes.Find( (wxObject*) widget ); + wxList::compatibility_iterator node = rb->m_boxes.Find( (wxObject*) widget ); if (!node) { return FALSE; @@ -260,7 +260,7 @@ bool wxRadioBox::Create( wxWindow *parent, wxWindowID id, const wxString& title, wxRadioBox::~wxRadioBox() { - wxNode *node = m_boxes.GetFirst(); + wxList::compatibility_iterator node = m_boxes.GetFirst(); while (node) { GtkWidget *button = GTK_WIDGET( node->GetData() ); @@ -314,7 +314,7 @@ wxSize wxRadioBox::LayoutItems() y = 15; int max_len = 0; - wxNode *node = m_boxes.Item( j*num_of_rows ); + wxList::compatibility_iterator node = m_boxes.Item( j*num_of_rows ); for (int i1 = 0; i1< num_of_rows; i1++) { GtkWidget *button = GTK_WIDGET( node->GetData() ); @@ -359,7 +359,7 @@ wxSize wxRadioBox::LayoutItems() { int max = 0; - wxNode *node = m_boxes.GetFirst(); + wxList::compatibility_iterator node = m_boxes.GetFirst(); while (node) { GtkWidget *button = GTK_WIDGET( node->GetData() ); @@ -405,7 +405,7 @@ bool wxRadioBox::Show( bool show ) if ((m_windowStyle & wxNO_BORDER) != 0) gtk_widget_hide( m_widget ); - wxNode *node = m_boxes.GetFirst(); + wxList::compatibility_iterator node = m_boxes.GetFirst(); while (node) { GtkWidget *button = GTK_WIDGET( node->GetData() ); @@ -424,7 +424,7 @@ int wxRadioBox::FindString( const wxString &find ) const int count = 0; - wxNode *node = m_boxes.GetFirst(); + wxList::compatibility_iterator node = m_boxes.GetFirst(); while (node) { GtkLabel *label = GTK_LABEL( BUTTON_CHILD(node->GetData()) ); @@ -450,7 +450,7 @@ void wxRadioBox::SetFocus() if (m_boxes.GetCount() == 0) return; - wxNode *node = m_boxes.GetFirst(); + wxList::compatibility_iterator node = m_boxes.GetFirst(); while (node) { GtkToggleButton *button = GTK_TOGGLE_BUTTON( node->GetData() ); @@ -467,7 +467,7 @@ void wxRadioBox::SetSelection( int n ) { wxCHECK_RET( m_widget != NULL, wxT("invalid radiobox") ); - wxNode *node = m_boxes.Item( n ); + wxList::compatibility_iterator node = m_boxes.Item( n ); wxCHECK_RET( node, wxT("radiobox wrong index") ); @@ -486,7 +486,7 @@ int wxRadioBox::GetSelection(void) const int count = 0; - wxNode *node = m_boxes.GetFirst(); + wxList::compatibility_iterator node = m_boxes.GetFirst(); while (node) { GtkToggleButton *button = GTK_TOGGLE_BUTTON( node->GetData() ); @@ -504,7 +504,7 @@ wxString wxRadioBox::GetString( int n ) const { wxCHECK_MSG( m_widget != NULL, wxT(""), wxT("invalid radiobox") ); - wxNode *node = m_boxes.Item( n ); + wxList::compatibility_iterator node = m_boxes.Item( n ); wxCHECK_MSG( node, wxT(""), wxT("radiobox wrong index") ); @@ -532,7 +532,7 @@ void wxRadioBox::SetString( int item, const wxString& label ) { wxCHECK_RET( m_widget != NULL, wxT("invalid radiobox") ); - wxNode *node = m_boxes.Item( item ); + wxList::compatibility_iterator node = m_boxes.Item( item ); wxCHECK_RET( node, wxT("radiobox wrong index") ); @@ -546,7 +546,7 @@ bool wxRadioBox::Enable( bool enable ) if ( !wxControl::Enable( enable ) ) return FALSE; - wxNode *node = m_boxes.GetFirst(); + wxList::compatibility_iterator node = m_boxes.GetFirst(); while (node) { GtkButton *button = GTK_BUTTON( node->GetData() ); @@ -564,7 +564,7 @@ void wxRadioBox::Enable( int item, bool enable ) { wxCHECK_RET( m_widget != NULL, wxT("invalid radiobox") ); - wxNode *node = m_boxes.Item( item ); + wxList::compatibility_iterator node = m_boxes.Item( item ); wxCHECK_RET( node, wxT("radiobox wrong index") ); @@ -579,7 +579,7 @@ void wxRadioBox::Show( int item, bool show ) { wxCHECK_RET( m_widget != NULL, wxT("invalid radiobox") ); - wxNode *node = m_boxes.Item( item ); + wxList::compatibility_iterator node = m_boxes.Item( item ); wxCHECK_RET( node, wxT("radiobox wrong index") ); @@ -595,7 +595,7 @@ wxString wxRadioBox::GetStringSelection() const { wxCHECK_MSG( m_widget != NULL, wxT(""), wxT("invalid radiobox") ); - wxNode *node = m_boxes.GetFirst(); + wxList::compatibility_iterator node = m_boxes.GetFirst(); while (node) { GtkToggleButton *button = GTK_TOGGLE_BUTTON( node->GetData() ); @@ -645,7 +645,7 @@ void wxRadioBox::SetNumberOfRowsOrCols( int WXUNUSED(n) ) void wxRadioBox::GtkDisableEvents() { - wxNode *node = m_boxes.GetFirst(); + wxList::compatibility_iterator node = m_boxes.GetFirst(); while (node) { gtk_signal_disconnect_by_func( GTK_OBJECT(node->GetData()), @@ -657,7 +657,7 @@ void wxRadioBox::GtkDisableEvents() void wxRadioBox::GtkEnableEvents() { - wxNode *node = m_boxes.GetFirst(); + wxList::compatibility_iterator node = m_boxes.GetFirst(); while (node) { gtk_signal_connect( GTK_OBJECT(node->GetData()), "clicked", @@ -673,7 +673,7 @@ void wxRadioBox::ApplyWidgetStyle() gtk_widget_set_style( m_widget, m_widgetStyle ); - wxNode *node = m_boxes.GetFirst(); + wxList::compatibility_iterator node = m_boxes.GetFirst(); while (node) { GtkWidget *widget = GTK_WIDGET( node->GetData() ); @@ -688,7 +688,7 @@ void wxRadioBox::ApplyWidgetStyle() #if wxUSE_TOOLTIPS void wxRadioBox::ApplyToolTip( GtkTooltips *tips, const wxChar *tip ) { - wxNode *node = m_boxes.GetFirst(); + wxList::compatibility_iterator node = m_boxes.GetFirst(); while (node) { GtkWidget *widget = GTK_WIDGET( node->GetData() ); @@ -702,7 +702,7 @@ bool wxRadioBox::IsOwnGtkWindow( GdkWindow *window ) { if (window == m_widget->window) return TRUE; - wxNode *node = m_boxes.GetFirst(); + wxList::compatibility_iterator node = m_boxes.GetFirst(); while (node) { GtkWidget *button = GTK_WIDGET( node->GetData() ); diff --git a/src/gtk/radiobut.cpp b/src/gtk/radiobut.cpp index 49a6ddb76b..3bc0caaa13 100644 --- a/src/gtk/radiobut.cpp +++ b/src/gtk/radiobut.cpp @@ -94,7 +94,7 @@ bool wxRadioButton::Create( wxWindow *parent, { // search backward for last group start wxRadioButton *chief = (wxRadioButton*) NULL; - wxWindowList::Node *node = parent->GetChildren().GetLast(); + wxWindowList::compatibility_iterator node = parent->GetChildren().GetLast(); while (node) { wxWindow *child = node->GetData(); diff --git a/src/gtk/tbargtk.cpp b/src/gtk/tbargtk.cpp index 2832d62537..5c47efac8b 100644 --- a/src/gtk/tbargtk.cpp +++ b/src/gtk/tbargtk.cpp @@ -433,8 +433,9 @@ bool wxToolBar::DoInsertTool(size_t pos, wxToolBarToolBase *toolBase) if ( tool->IsRadio() ) { - wxToolBarToolsList::Node *node = pos ? m_tools.Item(pos - 1) - : NULL; + wxToolBarToolsList::compatibility_iterator node; + if ( pos ) node = m_tools.Item(pos - 1); + while ( node ) { wxToolBarTool *tool = (wxToolBarTool *)node->GetData(); @@ -660,7 +661,7 @@ void wxToolBar::OnInternalIdle() gdk_window_set_cursor( m_widget->window, cursor.GetCursor() ); } - wxToolBarToolsList::Node *node = m_tools.GetFirst(); + wxToolBarToolsList::compatibility_iterator node = m_tools.GetFirst(); while ( node ) { wxToolBarTool *tool = (wxToolBarTool *)node->GetData(); diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 13eda5a41d..9f1d174de7 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -345,7 +345,7 @@ wxWindow *wxFindFocusedChild(wxWindowGTK *win) if ( winFocus == win ) return (wxWindow *)win; - for ( wxWindowList::Node *node = win->GetChildren().GetFirst(); + for ( wxWindowList::compatibility_iterator node = win->GetChildren().GetFirst(); node; node = node->GetNext() ) { @@ -1405,7 +1405,7 @@ wxWindowGTK *FindWindowForMouseEvent(wxWindowGTK *win, wxCoord& x, wxCoord& y) yy += pizza->yoffset; } - wxWindowList::Node *node = win->GetChildren().GetFirst(); + wxWindowList::compatibility_iterator node = win->GetChildren().GetFirst(); while (node) { wxWindowGTK *child = node->GetData(); @@ -3274,7 +3274,7 @@ static void wxWindowNotifyEnable(wxWindowGTK* win, bool enable) // Recurse, so that children have the opportunity to Do The Right Thing // and reset colours that have been messed up by a parent's (really ancestor's) // Enable call - for ( wxWindowList::Node *node = win->GetChildren().GetFirst(); + for ( wxWindowList::compatibility_iterator node = win->GetChildren().GetFirst(); node; node = node->GetNext() ) { @@ -4141,7 +4141,7 @@ void gtk_pop_hide_callback( GtkWidget *WXUNUSED(widget), bool* is_waiting ) static void SetInvokingWindow( wxMenu *menu, wxWindowGTK *win ) { menu->SetInvokingWindow( win ); - wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst(); + wxMenuItemList::compatibility_iterator node = menu->GetMenuItems().GetFirst(); while (node) { wxMenuItem *menuitem = node->GetData(); diff --git a/src/gtk1/choice.cpp b/src/gtk1/choice.cpp index b04477bdd4..05b88cc2ae 100644 --- a/src/gtk1/choice.cpp +++ b/src/gtk1/choice.cpp @@ -156,7 +156,7 @@ void wxChoice::DoSetItemClientData( int n, void* clientData ) { wxCHECK_RET( m_widget != NULL, wxT("invalid choice control") ); - wxNode *node = m_clientList.Item( n ); + wxList::compatibility_iterator node = m_clientList.Item( n ); wxCHECK_RET( node, wxT("invalid index in wxChoice::DoSetItemClientData") ); node->SetData( (wxObject*) clientData ); @@ -166,7 +166,7 @@ void* wxChoice::DoGetItemClientData( int n ) const { wxCHECK_MSG( m_widget != NULL, NULL, wxT("invalid choice control") ); - wxNode *node = m_clientList.Item( n ); + wxList::compatibility_iterator node = m_clientList.Item( n ); wxCHECK_MSG( node, NULL, wxT("invalid index in wxChoice::DoGetItemClientData") ); return node->GetData(); @@ -176,7 +176,7 @@ void wxChoice::DoSetItemClientObject( int n, wxClientData* clientData ) { wxCHECK_RET( m_widget != NULL, wxT("invalid choice control") ); - wxNode *node = m_clientList.Item( n ); + wxList::compatibility_iterator node = m_clientList.Item( n ); wxCHECK_RET( node, wxT("invalid index in wxChoice::DoSetItemClientObject") ); // wxItemContainer already deletes data for us @@ -188,7 +188,7 @@ wxClientData* wxChoice::DoGetItemClientObject( int n ) const { wxCHECK_MSG( m_widget != NULL, (wxClientData*) NULL, wxT("invalid choice control") ); - wxNode *node = m_clientList.Item( n ); + wxList::compatibility_iterator node = m_clientList.Item( n ); wxCHECK_MSG( node, (wxClientData *)NULL, wxT("invalid index in wxChoice::DoGetItemClientObject") ); @@ -208,7 +208,7 @@ void wxChoice::Clear() // destroy the data (due to Robert's idea of using wxList // and not wxList we can't just say // m_clientList.DeleteContents(TRUE) - this would crash! - wxNode *node = m_clientList.GetFirst(); + wxList::compatibility_iterator node = m_clientList.GetFirst(); while ( node ) { delete (wxClientData *)node->GetData(); diff --git a/src/gtk1/colour.cpp b/src/gtk1/colour.cpp index c57698a100..ce9b00c4c1 100644 --- a/src/gtk1/colour.cpp +++ b/src/gtk1/colour.cpp @@ -156,12 +156,13 @@ wxColour::wxColour( unsigned char red, unsigned char green, unsigned char blue ) M_COLDATA->m_color.pixel = 0; } + + void wxColour::InitFromName( const wxString &colourName ) { - wxNode *node = (wxNode *) NULL; - if ( (wxTheColourDatabase) && (node = wxTheColourDatabase->Find(colourName)) ) + wxColour* col = NULL; + if ( (wxTheColourDatabase) && (col = wxTheColourDatabase->FindColourNoAdd(colourName)) ) { - wxColour *col = (wxColour*)node->GetData(); UnRef(); if (col) Ref( *col ); } diff --git a/src/gtk1/combobox.cpp b/src/gtk1/combobox.cpp index 13d19d958b..7db2b2f750 100644 --- a/src/gtk1/combobox.cpp +++ b/src/gtk1/combobox.cpp @@ -197,7 +197,7 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value, wxComboBox::~wxComboBox() { - wxNode *node = m_clientObjectList.GetFirst(); + wxList::compatibility_iterator node = m_clientObjectList.GetFirst(); while (node) { wxClientData *cd = (wxClientData*)node->GetData(); @@ -360,7 +360,7 @@ void wxComboBox::SetClientData( int n, void* clientData ) { wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") ); - wxNode *node = m_clientDataList.Item( n ); + wxList::compatibility_iterator node = m_clientDataList.Item( n ); if (!node) return; node->SetData( (wxObject*) clientData ); @@ -370,7 +370,7 @@ void* wxComboBox::GetClientData( int n ) const { wxCHECK_MSG( m_widget != NULL, NULL, wxT("invalid combobox") ); - wxNode *node = m_clientDataList.Item( n ); + wxList::compatibility_iterator node = m_clientDataList.Item( n ); return node ? node->GetData() : NULL; } @@ -379,7 +379,7 @@ void wxComboBox::SetClientObject( int n, wxClientData* clientData ) { wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") ); - wxNode *node = m_clientObjectList.Item( n ); + wxList::compatibility_iterator node = m_clientObjectList.Item( n ); if (!node) return; wxClientData *cd = (wxClientData*) node->GetData(); @@ -392,7 +392,7 @@ wxClientData* wxComboBox::GetClientObject( int n ) const { wxCHECK_MSG( m_widget != NULL, (wxClientData*)NULL, wxT("invalid combobox") ); - wxNode *node = m_clientObjectList.Item( n ); + wxList::compatibility_iterator node = m_clientObjectList.Item( n ); return node ? (wxClientData*) node->GetData() : NULL; } @@ -406,7 +406,7 @@ void wxComboBox::Clear() GtkWidget *list = GTK_COMBO(m_widget)->list; gtk_list_clear_items( GTK_LIST(list), 0, Number() ); - wxNode *node = m_clientObjectList.GetFirst(); + wxList::compatibility_iterator node = m_clientObjectList.GetFirst(); while (node) { wxClientData *cd = (wxClientData*)node->GetData(); @@ -440,18 +440,18 @@ void wxComboBox::Delete( int n ) gtk_list_remove_items( listbox, list ); g_list_free( list ); - wxNode *node = m_clientObjectList.Item( n ); + wxList::compatibility_iterator node = m_clientObjectList.Item( n ); if (node) { wxClientData *cd = (wxClientData*)node->GetData(); if (cd) delete cd; - m_clientObjectList.DeleteNode( node ); + m_clientObjectList.Erase( node ); } node = m_clientDataList.Item( n ); if (node) - m_clientDataList.DeleteNode( node ); - + m_clientDataList.Erase( node ); + EnableEvents(); } diff --git a/src/gtk1/listbox.cpp b/src/gtk1/listbox.cpp index da15521495..fc1783f954 100644 --- a/src/gtk1/listbox.cpp +++ b/src/gtk1/listbox.cpp @@ -448,7 +448,7 @@ void wxListBox::DoInsertItems(const wxArrayString& items, int pos) if (index != GetCount()) { GtkAddItem( items[n], index ); - wxNode *node = m_clientList.Item( index ); + wxList::compatibility_iterator node = m_clientList.Item( index ); m_clientList.Insert( node, (wxObject*) NULL ); } else @@ -471,7 +471,7 @@ void wxListBox::DoInsertItems(const wxArrayString& items, int pos) } else { - wxNode *node = m_clientList.Item( pos ); + wxList::compatibility_iterator node = m_clientList.Item( pos ); for ( size_t n = 0; n < nItems; n++ ) { GtkAddItem( items[n], pos+n ); @@ -497,7 +497,7 @@ int wxListBox::DoAppend( const wxString& item ) { GtkAddItem( item, index ); - wxNode *node = m_clientList.Item( index ); + wxList::compatibility_iterator node = m_clientList.Item( index ); m_clientList.Insert( node, (wxObject *)NULL ); return index; @@ -619,7 +619,7 @@ void wxListBox::Clear() // destroy the data (due to Robert's idea of using wxList // and not wxList we can't just say // m_clientList.DeleteContents(TRUE) - this would crash! - wxNode *node = m_clientList.GetFirst(); + wxList::compatibility_iterator node = m_clientList.GetFirst(); while ( node ) { delete (wxClientData *)node->GetData(); @@ -644,7 +644,7 @@ void wxListBox::Delete( int n ) gtk_list_remove_items( m_list, list ); g_list_free( list ); - wxNode *node = m_clientList.Item( n ); + wxList::compatibility_iterator node = m_clientList.Item( n ); if ( node ) { if ( m_clientDataItemsType == wxClientData_Object ) @@ -653,7 +653,7 @@ void wxListBox::Delete( int n ) delete cd; } - m_clientList.DeleteNode( node ); + m_clientList.Erase( node ); } if ( m_strings ) @@ -668,7 +668,7 @@ void wxListBox::DoSetItemClientData( int n, void* clientData ) { wxCHECK_RET( m_widget != NULL, wxT("invalid listbox control") ); - wxNode *node = m_clientList.Item( n ); + wxList::compatibility_iterator node = m_clientList.Item( n ); wxCHECK_RET( node, wxT("invalid index in wxListBox::DoSetItemClientData") ); node->SetData( (wxObject*) clientData ); @@ -678,7 +678,7 @@ void* wxListBox::DoGetItemClientData( int n ) const { wxCHECK_MSG( m_widget != NULL, NULL, wxT("invalid listbox control") ); - wxNode *node = m_clientList.Item( n ); + wxList::compatibility_iterator node = m_clientList.Item( n ); wxCHECK_MSG( node, NULL, wxT("invalid index in wxListBox::DoGetItemClientData") ); return node->GetData(); @@ -688,7 +688,7 @@ void wxListBox::DoSetItemClientObject( int n, wxClientData* clientData ) { wxCHECK_RET( m_widget != NULL, wxT("invalid listbox control") ); - wxNode *node = m_clientList.Item( n ); + wxList::compatibility_iterator node = m_clientList.Item( n ); wxCHECK_RET( node, wxT("invalid index in wxListBox::DoSetItemClientObject") ); // wxItemContainer already deletes data for us @@ -700,7 +700,7 @@ wxClientData* wxListBox::DoGetItemClientObject( int n ) const { wxCHECK_MSG( m_widget != NULL, (wxClientData*) NULL, wxT("invalid listbox control") ); - wxNode *node = m_clientList.Item( n ); + wxList::compatibility_iterator node = m_clientList.Item( n ); wxCHECK_MSG( node, (wxClientData *)NULL, wxT("invalid index in wxListBox::DoGetItemClientObject") ); diff --git a/src/gtk1/mdi.cpp b/src/gtk1/mdi.cpp index 08f0a4e5db..8cf797cd63 100644 --- a/src/gtk1/mdi.cpp +++ b/src/gtk1/mdi.cpp @@ -75,7 +75,7 @@ gtk_mdi_page_change_callback( GtkNotebook *WXUNUSED(widget), child = (wxMDIChildFrame*) NULL; - wxWindowList::Node *node = client_window->GetChildren().GetFirst(); + wxWindowList::compatibility_iterator node = client_window->GetChildren().GetFirst(); while (node) { wxMDIChildFrame *child_frame = wxDynamicCast( node->GetData(), wxMDIChildFrame ); @@ -170,7 +170,7 @@ void wxMDIParentFrame::OnInternalIdle() wxMDIChildFrame *active_child_frame = GetActiveChild(); bool visible_child_menu = false; - wxWindowList::Node *node = m_clientWindow->GetChildren().GetFirst(); + wxWindowList::compatibility_iterator node = m_clientWindow->GetChildren().GetFirst(); while (node) { wxMDIChildFrame *child_frame = wxDynamicCast( node->GetData(), wxMDIChildFrame ); @@ -247,7 +247,7 @@ wxMDIChildFrame *wxMDIParentFrame::GetActiveChild() const GtkNotebookPage* page = (GtkNotebookPage*) (g_list_nth(notebook->children,i)->data); if (!page) return (wxMDIChildFrame*) NULL; - wxWindowList::Node *node = m_clientWindow->GetChildren().GetFirst(); + wxWindowList::compatibility_iterator node = m_clientWindow->GetChildren().GetFirst(); while (node) { wxMDIChildFrame *child_frame = wxDynamicCast( node->GetData(), wxMDIChildFrame ); diff --git a/src/gtk1/menu.cpp b/src/gtk1/menu.cpp index dea54b9e72..c3593081d8 100644 --- a/src/gtk1/menu.cpp +++ b/src/gtk1/menu.cpp @@ -200,8 +200,6 @@ wxMenuBar::wxMenuBar( long style ) return; } - m_menus.DeleteContents( TRUE ); - /* GTK 1.2.0 doesn't have gtk_item_factory_get_item(), but GTK 1.2.1 has. */ #if GTK_CHECK_VERSION(1, 2, 1) m_accel = gtk_accel_group_new(); @@ -241,8 +239,6 @@ wxMenuBar::wxMenuBar() return; } - m_menus.DeleteContents( TRUE ); - /* GTK 1.2.0 doesn't have gtk_item_factory_get_item(), but GTK 1.2.1 has. */ #if GTK_CHECK_VERSION(1, 2, 1) m_accel = gtk_accel_group_new(); @@ -275,7 +271,7 @@ static void wxMenubarUnsetInvokingWindow( wxMenu *menu, wxWindow *win ) /* support for native hot keys */ gtk_accel_group_detach( menu->m_accel, ACCEL_OBJ_CAST(top_frame->m_widget) ); - wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst(); + wxMenuItemList::compatibility_iterator node = menu->GetMenuItems().GetFirst(); while (node) { wxMenuItem *menuitem = node->GetData(); @@ -300,7 +296,7 @@ static void wxMenubarSetInvokingWindow( wxMenu *menu, wxWindow *win ) gtk_accel_group_attach( menu->m_accel, obj ); #endif // GTK+ 1.2.1+ - wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst(); + wxMenuItemList::compatibility_iterator node = menu->GetMenuItems().GetFirst(); while (node) { wxMenuItem *menuitem = node->GetData(); @@ -324,7 +320,7 @@ void wxMenuBar::SetInvokingWindow( wxWindow *win ) gtk_accel_group_attach( m_accel, obj ); #endif // GTK+ 1.2.1+ - wxMenuList::Node *node = m_menus.GetFirst(); + wxMenuList::compatibility_iterator node = m_menus.GetFirst(); while (node) { wxMenu *menu = node->GetData(); @@ -345,7 +341,7 @@ void wxMenuBar::UnsetInvokingWindow( wxWindow *win ) gtk_accel_group_detach( m_accel, ACCEL_OBJ_CAST(top_frame->m_widget) ); #endif // GTK+ 1.2.1+ - wxMenuList::Node *node = m_menus.GetFirst(); + wxMenuList::compatibility_iterator node = m_menus.GetFirst(); while (node) { wxMenu *menu = node->GetData(); @@ -474,7 +470,7 @@ wxMenu *wxMenuBar::Replace(size_t pos, wxMenu *menu, const wxString& title) static wxMenu *CopyMenu (wxMenu *menu) { wxMenu *menucopy = new wxMenu (); - wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst(); + wxMenuItemList::compatibility_iterator node = menu->GetMenuItems().GetFirst(); while (node) { wxMenuItem *item = node->GetData(); @@ -552,7 +548,7 @@ static int FindMenuItemRecursive( const wxMenu *menu, const wxString &menuString return res; } - wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst(); + wxMenuItemList::compatibility_iterator node = menu->GetMenuItems().GetFirst(); while (node) { wxMenuItem *item = node->GetData(); @@ -567,7 +563,7 @@ static int FindMenuItemRecursive( const wxMenu *menu, const wxString &menuString int wxMenuBar::FindMenuItem( const wxString &menuString, const wxString &itemString ) const { - wxMenuList::Node *node = m_menus.GetFirst(); + wxMenuList::compatibility_iterator node = m_menus.GetFirst(); while (node) { wxMenu *menu = node->GetData(); @@ -585,7 +581,7 @@ static wxMenuItem* FindMenuItemByIdRecursive(const wxMenu* menu, int id) { wxMenuItem* result = menu->FindChildItem(id); - wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst(); + wxMenuItemList::compatibility_iterator node = menu->GetMenuItems().GetFirst(); while ( node && result == NULL ) { wxMenuItem *item = node->GetData(); @@ -602,7 +598,7 @@ static wxMenuItem* FindMenuItemByIdRecursive(const wxMenu* menu, int id) wxMenuItem* wxMenuBar::FindItem( int id, wxMenu **menuForItem ) const { wxMenuItem* result = 0; - wxMenuList::Node *node = m_menus.GetFirst(); + wxMenuList::compatibility_iterator node = m_menus.GetFirst(); while (node && result == 0) { wxMenu *menu = node->GetData(); @@ -620,7 +616,7 @@ wxMenuItem* wxMenuBar::FindItem( int id, wxMenu **menuForItem ) const void wxMenuBar::EnableTop( size_t pos, bool flag ) { - wxMenuList::Node *node = m_menus.Item( pos ); + wxMenuList::compatibility_iterator node = m_menus.Item( pos ); wxCHECK_RET( node, wxT("menu not found") ); @@ -632,7 +628,7 @@ void wxMenuBar::EnableTop( size_t pos, bool flag ) wxString wxMenuBar::GetLabelTop( size_t pos ) const { - wxMenuList::Node *node = m_menus.Item( pos ); + wxMenuList::compatibility_iterator node = m_menus.Item( pos ); wxCHECK_MSG( node, wxT("invalid"), wxT("menu not found") ); @@ -659,7 +655,7 @@ wxString wxMenuBar::GetLabelTop( size_t pos ) const void wxMenuBar::SetLabelTop( size_t pos, const wxString& label ) { - wxMenuList::Node *node = m_menus.Item( pos ); + wxMenuList::compatibility_iterator node = m_menus.Item( pos ); wxCHECK_RET( node, wxT("menu not found") ); @@ -1122,7 +1118,7 @@ void wxMenu::Init() wxMenu::~wxMenu() { - m_items.Clear(); + WX_CLEAR_LIST(wxMenuItemList, m_items); if ( GTK_IS_WIDGET( m_menu )) gtk_widget_destroy( m_menu ); @@ -1398,7 +1394,7 @@ wxMenuItem *wxMenu::DoRemove(wxMenuItem *item) int wxMenu::FindMenuIdByMenuItem( GtkWidget *menuItem ) const { - wxMenuItemList::Node *node = m_items.GetFirst(); + wxMenuItemList::compatibility_iterator node = m_items.GetFirst(); while (node) { wxMenuItem *item = node->GetData(); diff --git a/src/gtk1/notebook.cpp b/src/gtk1/notebook.cpp index a904117faf..33aa5ab39d 100644 --- a/src/gtk1/notebook.cpp +++ b/src/gtk1/notebook.cpp @@ -240,7 +240,6 @@ void wxNotebook::Init() m_inSwitchPage = FALSE; m_imageList = (wxImageList *) NULL; - m_pagesData.DeleteContents( TRUE ); m_selection = -1; m_themeEnabled = TRUE; } @@ -567,7 +566,9 @@ wxNotebookPage *wxNotebook::DoRemovePage( int page ) gtk_notebook_remove_page( GTK_NOTEBOOK(m_widget), page ); - m_pagesData.DeleteObject(GetNotebookPage(page)); + wxGtkNotebookPage* p = GetNotebookPage(page); + m_pagesData.DeleteObject(p); + delete p; return client; } diff --git a/src/gtk1/radiobox.cpp b/src/gtk1/radiobox.cpp index 3d70c8d4e1..855f838e87 100644 --- a/src/gtk1/radiobox.cpp +++ b/src/gtk1/radiobox.cpp @@ -80,7 +80,7 @@ static gint gtk_radiobox_keypress_callback( GtkWidget *widget, GdkEventKey *gdk_ return FALSE; } - wxNode *node = rb->m_boxes.Find( (wxObject*) widget ); + wxList::compatibility_iterator node = rb->m_boxes.Find( (wxObject*) widget ); if (!node) { return FALSE; @@ -260,7 +260,7 @@ bool wxRadioBox::Create( wxWindow *parent, wxWindowID id, const wxString& title, wxRadioBox::~wxRadioBox() { - wxNode *node = m_boxes.GetFirst(); + wxList::compatibility_iterator node = m_boxes.GetFirst(); while (node) { GtkWidget *button = GTK_WIDGET( node->GetData() ); @@ -314,7 +314,7 @@ wxSize wxRadioBox::LayoutItems() y = 15; int max_len = 0; - wxNode *node = m_boxes.Item( j*num_of_rows ); + wxList::compatibility_iterator node = m_boxes.Item( j*num_of_rows ); for (int i1 = 0; i1< num_of_rows; i1++) { GtkWidget *button = GTK_WIDGET( node->GetData() ); @@ -359,7 +359,7 @@ wxSize wxRadioBox::LayoutItems() { int max = 0; - wxNode *node = m_boxes.GetFirst(); + wxList::compatibility_iterator node = m_boxes.GetFirst(); while (node) { GtkWidget *button = GTK_WIDGET( node->GetData() ); @@ -405,7 +405,7 @@ bool wxRadioBox::Show( bool show ) if ((m_windowStyle & wxNO_BORDER) != 0) gtk_widget_hide( m_widget ); - wxNode *node = m_boxes.GetFirst(); + wxList::compatibility_iterator node = m_boxes.GetFirst(); while (node) { GtkWidget *button = GTK_WIDGET( node->GetData() ); @@ -424,7 +424,7 @@ int wxRadioBox::FindString( const wxString &find ) const int count = 0; - wxNode *node = m_boxes.GetFirst(); + wxList::compatibility_iterator node = m_boxes.GetFirst(); while (node) { GtkLabel *label = GTK_LABEL( BUTTON_CHILD(node->GetData()) ); @@ -450,7 +450,7 @@ void wxRadioBox::SetFocus() if (m_boxes.GetCount() == 0) return; - wxNode *node = m_boxes.GetFirst(); + wxList::compatibility_iterator node = m_boxes.GetFirst(); while (node) { GtkToggleButton *button = GTK_TOGGLE_BUTTON( node->GetData() ); @@ -467,7 +467,7 @@ void wxRadioBox::SetSelection( int n ) { wxCHECK_RET( m_widget != NULL, wxT("invalid radiobox") ); - wxNode *node = m_boxes.Item( n ); + wxList::compatibility_iterator node = m_boxes.Item( n ); wxCHECK_RET( node, wxT("radiobox wrong index") ); @@ -486,7 +486,7 @@ int wxRadioBox::GetSelection(void) const int count = 0; - wxNode *node = m_boxes.GetFirst(); + wxList::compatibility_iterator node = m_boxes.GetFirst(); while (node) { GtkToggleButton *button = GTK_TOGGLE_BUTTON( node->GetData() ); @@ -504,7 +504,7 @@ wxString wxRadioBox::GetString( int n ) const { wxCHECK_MSG( m_widget != NULL, wxT(""), wxT("invalid radiobox") ); - wxNode *node = m_boxes.Item( n ); + wxList::compatibility_iterator node = m_boxes.Item( n ); wxCHECK_MSG( node, wxT(""), wxT("radiobox wrong index") ); @@ -532,7 +532,7 @@ void wxRadioBox::SetString( int item, const wxString& label ) { wxCHECK_RET( m_widget != NULL, wxT("invalid radiobox") ); - wxNode *node = m_boxes.Item( item ); + wxList::compatibility_iterator node = m_boxes.Item( item ); wxCHECK_RET( node, wxT("radiobox wrong index") ); @@ -546,7 +546,7 @@ bool wxRadioBox::Enable( bool enable ) if ( !wxControl::Enable( enable ) ) return FALSE; - wxNode *node = m_boxes.GetFirst(); + wxList::compatibility_iterator node = m_boxes.GetFirst(); while (node) { GtkButton *button = GTK_BUTTON( node->GetData() ); @@ -564,7 +564,7 @@ void wxRadioBox::Enable( int item, bool enable ) { wxCHECK_RET( m_widget != NULL, wxT("invalid radiobox") ); - wxNode *node = m_boxes.Item( item ); + wxList::compatibility_iterator node = m_boxes.Item( item ); wxCHECK_RET( node, wxT("radiobox wrong index") ); @@ -579,7 +579,7 @@ void wxRadioBox::Show( int item, bool show ) { wxCHECK_RET( m_widget != NULL, wxT("invalid radiobox") ); - wxNode *node = m_boxes.Item( item ); + wxList::compatibility_iterator node = m_boxes.Item( item ); wxCHECK_RET( node, wxT("radiobox wrong index") ); @@ -595,7 +595,7 @@ wxString wxRadioBox::GetStringSelection() const { wxCHECK_MSG( m_widget != NULL, wxT(""), wxT("invalid radiobox") ); - wxNode *node = m_boxes.GetFirst(); + wxList::compatibility_iterator node = m_boxes.GetFirst(); while (node) { GtkToggleButton *button = GTK_TOGGLE_BUTTON( node->GetData() ); @@ -645,7 +645,7 @@ void wxRadioBox::SetNumberOfRowsOrCols( int WXUNUSED(n) ) void wxRadioBox::GtkDisableEvents() { - wxNode *node = m_boxes.GetFirst(); + wxList::compatibility_iterator node = m_boxes.GetFirst(); while (node) { gtk_signal_disconnect_by_func( GTK_OBJECT(node->GetData()), @@ -657,7 +657,7 @@ void wxRadioBox::GtkDisableEvents() void wxRadioBox::GtkEnableEvents() { - wxNode *node = m_boxes.GetFirst(); + wxList::compatibility_iterator node = m_boxes.GetFirst(); while (node) { gtk_signal_connect( GTK_OBJECT(node->GetData()), "clicked", @@ -673,7 +673,7 @@ void wxRadioBox::ApplyWidgetStyle() gtk_widget_set_style( m_widget, m_widgetStyle ); - wxNode *node = m_boxes.GetFirst(); + wxList::compatibility_iterator node = m_boxes.GetFirst(); while (node) { GtkWidget *widget = GTK_WIDGET( node->GetData() ); @@ -688,7 +688,7 @@ void wxRadioBox::ApplyWidgetStyle() #if wxUSE_TOOLTIPS void wxRadioBox::ApplyToolTip( GtkTooltips *tips, const wxChar *tip ) { - wxNode *node = m_boxes.GetFirst(); + wxList::compatibility_iterator node = m_boxes.GetFirst(); while (node) { GtkWidget *widget = GTK_WIDGET( node->GetData() ); @@ -702,7 +702,7 @@ bool wxRadioBox::IsOwnGtkWindow( GdkWindow *window ) { if (window == m_widget->window) return TRUE; - wxNode *node = m_boxes.GetFirst(); + wxList::compatibility_iterator node = m_boxes.GetFirst(); while (node) { GtkWidget *button = GTK_WIDGET( node->GetData() ); diff --git a/src/gtk1/radiobut.cpp b/src/gtk1/radiobut.cpp index 49a6ddb76b..3bc0caaa13 100644 --- a/src/gtk1/radiobut.cpp +++ b/src/gtk1/radiobut.cpp @@ -94,7 +94,7 @@ bool wxRadioButton::Create( wxWindow *parent, { // search backward for last group start wxRadioButton *chief = (wxRadioButton*) NULL; - wxWindowList::Node *node = parent->GetChildren().GetLast(); + wxWindowList::compatibility_iterator node = parent->GetChildren().GetLast(); while (node) { wxWindow *child = node->GetData(); diff --git a/src/gtk1/tbargtk.cpp b/src/gtk1/tbargtk.cpp index 2832d62537..5c47efac8b 100644 --- a/src/gtk1/tbargtk.cpp +++ b/src/gtk1/tbargtk.cpp @@ -433,8 +433,9 @@ bool wxToolBar::DoInsertTool(size_t pos, wxToolBarToolBase *toolBase) if ( tool->IsRadio() ) { - wxToolBarToolsList::Node *node = pos ? m_tools.Item(pos - 1) - : NULL; + wxToolBarToolsList::compatibility_iterator node; + if ( pos ) node = m_tools.Item(pos - 1); + while ( node ) { wxToolBarTool *tool = (wxToolBarTool *)node->GetData(); @@ -660,7 +661,7 @@ void wxToolBar::OnInternalIdle() gdk_window_set_cursor( m_widget->window, cursor.GetCursor() ); } - wxToolBarToolsList::Node *node = m_tools.GetFirst(); + wxToolBarToolsList::compatibility_iterator node = m_tools.GetFirst(); while ( node ) { wxToolBarTool *tool = (wxToolBarTool *)node->GetData(); diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index 13eda5a41d..9f1d174de7 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -345,7 +345,7 @@ wxWindow *wxFindFocusedChild(wxWindowGTK *win) if ( winFocus == win ) return (wxWindow *)win; - for ( wxWindowList::Node *node = win->GetChildren().GetFirst(); + for ( wxWindowList::compatibility_iterator node = win->GetChildren().GetFirst(); node; node = node->GetNext() ) { @@ -1405,7 +1405,7 @@ wxWindowGTK *FindWindowForMouseEvent(wxWindowGTK *win, wxCoord& x, wxCoord& y) yy += pizza->yoffset; } - wxWindowList::Node *node = win->GetChildren().GetFirst(); + wxWindowList::compatibility_iterator node = win->GetChildren().GetFirst(); while (node) { wxWindowGTK *child = node->GetData(); @@ -3274,7 +3274,7 @@ static void wxWindowNotifyEnable(wxWindowGTK* win, bool enable) // Recurse, so that children have the opportunity to Do The Right Thing // and reset colours that have been messed up by a parent's (really ancestor's) // Enable call - for ( wxWindowList::Node *node = win->GetChildren().GetFirst(); + for ( wxWindowList::compatibility_iterator node = win->GetChildren().GetFirst(); node; node = node->GetNext() ) { @@ -4141,7 +4141,7 @@ void gtk_pop_hide_callback( GtkWidget *WXUNUSED(widget), bool* is_waiting ) static void SetInvokingWindow( wxMenu *menu, wxWindowGTK *win ) { menu->SetInvokingWindow( win ); - wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst(); + wxMenuItemList::compatibility_iterator node = menu->GetMenuItems().GetFirst(); while (node) { wxMenuItem *menuitem = node->GetData(); diff --git a/src/html/helpctrl.cpp b/src/html/helpctrl.cpp index 1748fef73d..67726f7456 100644 --- a/src/html/helpctrl.cpp +++ b/src/html/helpctrl.cpp @@ -271,7 +271,7 @@ void wxHtmlHelpController::AddGrabIfNeeded() // Check if there are any modal windows present, // in which case we need to add a grab. - for ( wxWindowList::Node * node = wxTopLevelWindows.GetFirst(); + for ( wxWindowList::compatibility_iterator node = wxTopLevelWindows.GetFirst(); node; node = node->GetNext() ) { diff --git a/src/html/helpfrm.cpp b/src/html/helpfrm.cpp index d51186b765..e4e1a2e681 100644 --- a/src/html/helpfrm.cpp +++ b/src/html/helpfrm.cpp @@ -1069,7 +1069,6 @@ BEGIN_EVENT_TABLE(wxHtmlHelpFrameOptionsDialog, wxDialog) EVT_SPINCTRL(-1, wxHtmlHelpFrameOptionsDialog::OnUpdateSpin) END_EVENT_TABLE() - void wxHtmlHelpFrame::OptionsDialog() { wxHtmlHelpFrameOptionsDialog dlg(this); @@ -1081,7 +1080,7 @@ void wxHtmlHelpFrame::OptionsDialog() enu.EnumerateFacenames(); m_NormalFonts = new wxArrayString; *m_NormalFonts = *enu.GetFacenames(); - m_NormalFonts->Sort(); + m_NormalFonts->Sort(wxStringSortAscending); } if (m_FixedFonts == NULL) { @@ -1089,7 +1088,7 @@ void wxHtmlHelpFrame::OptionsDialog() enu.EnumerateFacenames(wxFONTENCODING_SYSTEM, TRUE); m_FixedFonts = new wxArrayString; *m_FixedFonts = *enu.GetFacenames(); - m_FixedFonts->Sort(); + m_FixedFonts->Sort(wxStringSortAscending); } // VS: We want to show the font that is actually used by wxHtmlWindow. diff --git a/src/html/htmlpars.cpp b/src/html/htmlpars.cpp index efd6d9349e..be7d11a616 100644 --- a/src/html/htmlpars.cpp +++ b/src/html/htmlpars.cpp @@ -82,11 +82,18 @@ wxHtmlParser::~wxHtmlParser() { while (RestoreState()) {} DestroyDOMTree(); - + + if (m_HandlersStack) + { + wxList& tmp = *m_HandlersStack; + wxList::iterator it, en; + for( it = tmp.begin(), en = tmp.end(); it != en; ++it ) + delete (wxHashTable*)*it; + tmp.clear(); + } delete m_HandlersStack; m_HandlersHash.Clear(); - m_HandlersList.DeleteContents(TRUE); - m_HandlersList.Clear(); + WX_CLEAR_LIST(wxList, m_HandlersList); delete m_entitiesParser; } @@ -351,10 +358,9 @@ void wxHtmlParser::PushTagHandler(wxHtmlTagHandler *handler, wxString tags) if (m_HandlersStack == NULL) { m_HandlersStack = new wxList; - m_HandlersStack->DeleteContents(TRUE); } - m_HandlersStack->Insert(new wxHashTable(m_HandlersHash)); + m_HandlersStack->Insert((wxObject*)new wxHashTable(m_HandlersHash)); while (tokenizer.HasMoreTokens()) { @@ -366,16 +372,17 @@ void wxHtmlParser::PushTagHandler(wxHtmlTagHandler *handler, wxString tags) void wxHtmlParser::PopTagHandler() { - wxNode *first; + wxList::compatibility_iterator first; if (m_HandlersStack == NULL || - (first = m_HandlersStack->GetFirst()) == NULL) + !(first = m_HandlersStack->GetFirst())) { wxLogWarning(_("Warning: attempt to remove HTML tag handler from empty stack.")); return; } m_HandlersHash = *((wxHashTable*) first->GetData()); - m_HandlersStack->DeleteNode(first); + delete (wxHashTable*) first->GetData(); + m_HandlersStack->Erase(first); } void wxHtmlParser::SetSourceAndSaveState(const wxString& src) diff --git a/src/html/htmlwin.cpp b/src/html/htmlwin.cpp index 8afb3a1fba..261bb4b8d6 100644 --- a/src/html/htmlwin.cpp +++ b/src/html/htmlwin.cpp @@ -203,6 +203,8 @@ wxHtmlWindow::~wxHtmlWindow() if (m_Cell) delete m_Cell; + WX_CLEAR_LIST(wxHtmlProcessorList, *m_Processors); + delete m_Parser; delete m_FS; delete m_History; @@ -248,11 +250,11 @@ bool wxHtmlWindow::SetPage(const wxString& source) // pass HTML through registered processors: if (m_Processors || m_GlobalProcessors) { - wxHtmlProcessorList::Node *nodeL, *nodeG; + wxHtmlProcessorList::compatibility_iterator nodeL, nodeG; int prL, prG; - nodeL = (m_Processors) ? m_Processors->GetFirst() : NULL; - nodeG = (m_GlobalProcessors) ? m_GlobalProcessors->GetFirst() : NULL; + nodeL = (m_Processors) ? m_Processors->GetFirst() : wxHtmlProcessorList::compatibility_iterator(); + nodeG = (m_GlobalProcessors) ? m_GlobalProcessors->GetFirst() : wxHtmlProcessorList::compatibility_iterator(); // VS: there are two lists, global and local, both of them sorted by // priority. Since we have to go through _both_ lists with @@ -374,7 +376,7 @@ bool wxHtmlWindow::LoadPage(const wxString& location) else { - wxNode *node; + wxList::compatibility_iterator node; wxString src = wxEmptyString; if (m_RelatedStatusBar != -1) @@ -653,9 +655,8 @@ void wxHtmlWindow::AddProcessor(wxHtmlProcessor *processor) if (!m_Processors) { m_Processors = new wxHtmlProcessorList; - m_Processors->DeleteContents(TRUE); } - wxHtmlProcessorList::Node *node; + wxHtmlProcessorList::compatibility_iterator node; for (node = m_Processors->GetFirst(); node; node = node->GetNext()) { @@ -673,9 +674,8 @@ void wxHtmlWindow::AddProcessor(wxHtmlProcessor *processor) if (!m_GlobalProcessors) { m_GlobalProcessors = new wxHtmlProcessorList; - m_GlobalProcessors->DeleteContents(TRUE); } - wxHtmlProcessorList::Node *node; + wxHtmlProcessorList::compatibility_iterator node; for (node = m_GlobalProcessors->GetFirst(); node; node = node->GetNext()) { @@ -697,8 +697,9 @@ wxHtmlProcessorList *wxHtmlWindow::m_GlobalProcessors = NULL; void wxHtmlWindow::CleanUpStatics() { wxDELETE(m_DefaultFilter); - m_Filters.DeleteContents(TRUE); - m_Filters.Clear(); + WX_CLEAR_LIST(wxList, m_Filters); + if (m_GlobalProcessors) + WX_CLEAR_LIST(wxHtmlProcessorList, *m_GlobalProcessors); wxDELETE(m_GlobalProcessors); } diff --git a/src/html/htmprint.cpp b/src/html/htmprint.cpp index 6f4912caee..14b443a30e 100644 --- a/src/html/htmprint.cpp +++ b/src/html/htmprint.cpp @@ -169,8 +169,7 @@ wxHtmlPrintout::~wxHtmlPrintout() void wxHtmlPrintout::CleanUpStatics() { - m_Filters.DeleteContents(TRUE); - m_Filters.Clear(); + WX_CLEAR_LIST(wxList, m_Filters); } // Adds input filter @@ -293,7 +292,7 @@ void wxHtmlPrintout::SetHtmlFile(const wxString& htmlfile) wxHtmlFilterHTML defaultFilter; wxString doc; - wxNode* node = m_Filters.GetFirst(); + wxList::compatibility_iterator node = m_Filters.GetFirst(); while (node) { wxHtmlFilter *h = (wxHtmlFilter*) node->GetData(); diff --git a/src/html/winpars.cpp b/src/html/winpars.cpp index 4a5de2de4d..8410b01988 100644 --- a/src/html/winpars.cpp +++ b/src/html/winpars.cpp @@ -74,7 +74,7 @@ wxHtmlWinParser::wxHtmlWinParser(wxHtmlWindow *wnd) : wxHtmlParser() } // fill in wxHtmlParser's tables: - wxNode *node = m_Modules.GetFirst(); + wxList::compatibility_iterator node = m_Modules.GetFirst(); while (node) { wxHtmlTagsModule *mod = (wxHtmlTagsModule*) node->GetData(); diff --git a/src/msw/dialog.cpp b/src/msw/dialog.cpp index f54a3164bf..698b38d7cb 100644 --- a/src/msw/dialog.cpp +++ b/src/msw/dialog.cpp @@ -191,7 +191,7 @@ bool wxDialog::IsModal() const bool wxDialog::IsModalShowing() const { - return wxModalDialogs.Find((wxDialog *)this) != NULL; // const_cast + return wxModalDialogs.Find((wxDialog *)this); // const_cast } wxWindow *wxDialog::FindSuitableParent() const diff --git a/src/msw/filedlg.cpp b/src/msw/filedlg.cpp index 27d08e5447..1e03393399 100644 --- a/src/msw/filedlg.cpp +++ b/src/msw/filedlg.cpp @@ -345,7 +345,7 @@ int wxFileDialog::ShowModal() if ( m_dir.Last() != _T('\\') ) dir += _T('\\'); - m_fileNames.Sort(); + m_fileNames.Sort(wxStringSortAscending); m_path = dir + m_fileName; } else diff --git a/src/msw/frame.cpp b/src/msw/frame.cpp index b4a87c8cc4..76bba0ef4b 100644 --- a/src/msw/frame.cpp +++ b/src/msw/frame.cpp @@ -455,7 +455,7 @@ void wxFrame::PositionToolBar() // on the desktop, but are iconized/restored with it void wxFrame::IconizeChildFrames(bool bIconize) { - for ( wxWindowList::Node *node = GetChildren().GetFirst(); + for ( wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); node; node = node->GetNext() ) { diff --git a/src/msw/gdiimage.cpp b/src/msw/gdiimage.cpp index 1e7606bcbe..2bf6f0bce0 100644 --- a/src/msw/gdiimage.cpp +++ b/src/msw/gdiimage.cpp @@ -236,7 +236,7 @@ bool wxGDIImage::RemoveHandler(const wxString& name) wxGDIImageHandler *wxGDIImage::FindHandler(const wxString& name) { - wxGDIImageHandlerList::Node *node = ms_handlers.GetFirst(); + wxGDIImageHandlerList::compatibility_iterator node = ms_handlers.GetFirst(); while ( node ) { wxGDIImageHandler *handler = node->GetData(); @@ -251,7 +251,7 @@ wxGDIImageHandler *wxGDIImage::FindHandler(const wxString& name) wxGDIImageHandler *wxGDIImage::FindHandler(const wxString& extension, long type) { - wxGDIImageHandlerList::Node *node = ms_handlers.GetFirst(); + wxGDIImageHandlerList::compatibility_iterator node = ms_handlers.GetFirst(); while ( node ) { wxGDIImageHandler *handler = node->GetData(); @@ -268,7 +268,7 @@ wxGDIImageHandler *wxGDIImage::FindHandler(const wxString& extension, wxGDIImageHandler *wxGDIImage::FindHandler(long type) { - wxGDIImageHandlerList::Node *node = ms_handlers.GetFirst(); + wxGDIImageHandlerList::compatibility_iterator node = ms_handlers.GetFirst(); while ( node ) { wxGDIImageHandler *handler = node->GetData(); @@ -283,13 +283,13 @@ wxGDIImageHandler *wxGDIImage::FindHandler(long type) void wxGDIImage::CleanUpHandlers() { - wxGDIImageHandlerList::Node *node = ms_handlers.GetFirst(); + wxGDIImageHandlerList::compatibility_iterator node = ms_handlers.GetFirst(); while ( node ) { wxGDIImageHandler *handler = node->GetData(); - wxGDIImageHandlerList::Node *next = node->GetNext(); + wxGDIImageHandlerList::compatibility_iterator next = node->GetNext(); delete handler; - delete node; + ms_handlers.Erase( node ); node = next; } } diff --git a/src/msw/mdi.cpp b/src/msw/mdi.cpp index 6089dcde74..fa8de4d5d2 100644 --- a/src/msw/mdi.cpp +++ b/src/msw/mdi.cpp @@ -558,7 +558,7 @@ bool wxMDIParentFrame::HandleCommand(WXWORD id, WXWORD cmd, WXHWND hwnd) if ( IsMdiCommandId(id) ) { - wxWindowList::Node *node = GetChildren().GetFirst(); + wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); while ( node ) { wxWindow *child = node->GetData(); @@ -1246,7 +1246,7 @@ void wxMDIClientWindow::DoSetSize(int x, int y, int width, int height, int sizeF { if (GetParent()) { - wxWindowList::Node *node = GetParent()->GetChildren().GetFirst(); + wxWindowList::compatibility_iterator node = GetParent()->GetChildren().GetFirst(); while (node) { wxWindow *child = node->GetData(); diff --git a/src/msw/menu.cpp b/src/msw/menu.cpp index f3c898b413..761bd75da6 100644 --- a/src/msw/menu.cpp +++ b/src/msw/menu.cpp @@ -163,7 +163,7 @@ void wxMenu::UpdateAccel(wxMenuItem *item) if ( item->IsSubMenu() ) { wxMenu *submenu = item->GetSubMenu(); - wxMenuItemList::Node *node = submenu->GetMenuItems().GetFirst(); + wxMenuItemList::compatibility_iterator node = submenu->GetMenuItems().GetFirst(); while ( node ) { UpdateAccel(node->GetData()); @@ -329,7 +329,7 @@ bool wxMenu::DoAppend(wxMenuItem *item) { // we need to update its end item item->SetRadioGroupStart(m_startRadioGroup); - wxMenuItemList::Node *node = GetMenuItems().Item(m_startRadioGroup); + wxMenuItemList::compatibility_iterator node = GetMenuItems().Item(m_startRadioGroup); if ( node ) { @@ -369,7 +369,7 @@ wxMenuItem *wxMenu::DoRemove(wxMenuItem *item) { // we need to find the items position in the child list size_t pos; - wxMenuItemList::Node *node = GetMenuItems().GetFirst(); + wxMenuItemList::compatibility_iterator node = GetMenuItems().GetFirst(); for ( pos = 0; node; pos++ ) { if ( node->GetData() == item ) @@ -590,11 +590,12 @@ WXHMENU wxMenuBar::Create() } else { - size_t count = GetMenuCount(); - for ( size_t i = 0; i < count; i++ ) + size_t count = GetMenuCount(), i; + wxMenuList::iterator it; + for ( i = 0, it = m_menus.begin(); i < count; i++, it++ ) { if ( !::AppendMenu((HMENU)m_hMenu, MF_POPUP | MF_STRING, - (UINT)m_menus[i]->GetHMenu(), + (UINT)(*it)->GetHMenu(), m_titles[i]) ) { wxLogLastError(wxT("AppendMenu")); @@ -811,9 +812,10 @@ void wxMenuBar::RebuildAccelTable() // merge the accelerators of all menus into one accel table size_t nAccelCount = 0; size_t i, count = GetMenuCount(); - for ( i = 0; i < count; i++ ) + wxMenuList::iterator it; + for ( i = 0, it = m_menus.begin(); i < count; i++, it++ ) { - nAccelCount += m_menus[i]->GetAccelCount(); + nAccelCount += (*it)->GetAccelCount(); } if ( nAccelCount ) @@ -821,9 +823,9 @@ void wxMenuBar::RebuildAccelTable() wxAcceleratorEntry *accelEntries = new wxAcceleratorEntry[nAccelCount]; nAccelCount = 0; - for ( i = 0; i < count; i++ ) + for ( i = 0, it = m_menus.begin(); i < count; i++, it++ ) { - nAccelCount += m_menus[i]->CopyAccels(&accelEntries[nAccelCount]); + nAccelCount += (*it)->CopyAccels(&accelEntries[nAccelCount]); } m_accelTable = wxAcceleratorTable(nAccelCount, accelEntries); diff --git a/src/msw/menuitem.cpp b/src/msw/menuitem.cpp index b9f3ca853f..887b57f944 100644 --- a/src/msw/menuitem.cpp +++ b/src/msw/menuitem.cpp @@ -262,7 +262,7 @@ void wxMenuItem::Check(bool check) #endif // __WIN32__ // also uncheck all the other items in this radio group - wxMenuItemList::Node *node = items.Item(start); + wxMenuItemList::compatibility_iterator node = items.Item(start); for ( int n = start; n <= end && node; n++ ) { if ( n != pos ) diff --git a/src/msw/nativdlg.cpp b/src/msw/nativdlg.cpp index 0b2b1ee94e..778cd60941 100644 --- a/src/msw/nativdlg.cpp +++ b/src/msw/nativdlg.cpp @@ -135,7 +135,7 @@ wxWindow* wxWindow::GetWindowChild1(wxWindowID id) if ( m_windowId == id ) return this; - wxWindowList::Node *node = GetChildren().GetFirst(); + wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); while ( node ) { wxWindow* child = node->GetData(); diff --git a/src/msw/radiobut.cpp b/src/msw/radiobut.cpp index aee70d4034..4cff6cf1e3 100644 --- a/src/msw/radiobut.cpp +++ b/src/msw/radiobut.cpp @@ -114,14 +114,14 @@ void wxRadioButton::SetValue(bool value) if ( value ) { const wxWindowList& siblings = GetParent()->GetChildren(); - wxWindowList::Node *nodeThis = siblings.Find(this); + wxWindowList::compatibility_iterator nodeThis = siblings.Find(this); wxCHECK_RET( nodeThis, _T("radio button not a child of its parent?") ); // if it's not the first item of the group ... if ( !HasFlag(wxRB_GROUP) ) { // ... turn off all radio buttons before it - for ( wxWindowList::Node *nodeBefore = nodeThis->GetPrevious(); + for ( wxWindowList::compatibility_iterator nodeBefore = nodeThis->GetPrevious(); nodeBefore; nodeBefore = nodeBefore->GetPrevious() ) { @@ -146,7 +146,7 @@ void wxRadioButton::SetValue(bool value) } // ... and also turn off all buttons after this one - for ( wxWindowList::Node *nodeAfter = nodeThis->GetNext(); + for ( wxWindowList::compatibility_iterator nodeAfter = nodeThis->GetNext(); nodeAfter; nodeAfter = nodeAfter->GetNext() ) { diff --git a/src/msw/taskbar.cpp b/src/msw/taskbar.cpp index 4c868c06a5..4a76e3e018 100644 --- a/src/msw/taskbar.cpp +++ b/src/msw/taskbar.cpp @@ -237,7 +237,7 @@ void wxTaskBarIcon::_OnRButtonDClick(wxEvent& e) { OnRButtonDClick(e); } wxTaskBarIcon* wxTaskBarIcon::FindObjectForHWND(WXHWND hWnd) { - wxTaskBarIconList::Node *node = sm_taskBarIcons.GetFirst(); + wxTaskBarIconList::compatibility_iterator node = sm_taskBarIcons.GetFirst(); while (node) { wxTaskBarIcon *obj = node->GetData(); diff --git a/src/msw/tbar95.cpp b/src/msw/tbar95.cpp index 3f0bc66692..4fa970dc54 100644 --- a/src/msw/tbar95.cpp +++ b/src/msw/tbar95.cpp @@ -278,7 +278,7 @@ void wxToolBar::Recreate() } // reparent all our children under the new toolbar - for ( wxWindowList::Node *node = m_children.GetFirst(); + for ( wxWindowList::compatibility_iterator node = m_children.GetFirst(); node; node = node->GetNext() ) { @@ -394,7 +394,7 @@ bool wxToolBar::DoDeleteTool(size_t pos, wxToolBarToolBase *tool) // first determine the position of the first button to delete: it may be // different from pos if we use several separators to cover the space used // by a control - wxToolBarToolsList::Node *node; + wxToolBarToolsList::compatibility_iterator node; for ( node = m_tools.GetFirst(); node; node = node->GetNext() ) { wxToolBarToolBase *tool2 = node->GetData(); @@ -485,7 +485,7 @@ bool wxToolBar::Realize() // First, add the bitmap: we use one bitmap for all toolbar buttons // ---------------------------------------------------------------- - wxToolBarToolsList::Node *node; + wxToolBarToolsList::compatibility_iterator node; int bitmapId = 0; wxSize sizeBmp; @@ -1021,7 +1021,7 @@ static wxToolBarToolBase *GetItemSkippingDummySpacers(const wxToolBarToolsList& tools, size_t index ) { - wxToolBarToolsList::Node* current = tools.GetFirst(); + wxToolBarToolsList::compatibility_iterator current = tools.GetFirst(); for ( ; current != 0; current = current->GetNext() ) { @@ -1225,7 +1225,7 @@ bool wxToolBar::HandlePaint(WXWPARAM wParam, WXLPARAM lParam) // any here // first of all, do we have any controls at all? - wxToolBarToolsList::Node *node; + wxToolBarToolsList::compatibility_iterator node; for ( node = m_tools.GetFirst(); node; node = node->GetNext() ) { if ( node->GetData()->IsControl() ) diff --git a/src/msw/timer.cpp b/src/msw/timer.cpp index 0fe07b64a3..822ece8f35 100644 --- a/src/msw/timer.cpp +++ b/src/msw/timer.cpp @@ -23,6 +23,7 @@ #if wxUSE_TIMER #ifndef WX_PRECOMP + #include "wx/hashmap.h" #include "wx/setup.h" #include "wx/window.h" #include "wx/list.h" @@ -40,7 +41,13 @@ // private functions // ---------------------------------------------------------------------------- -wxList wxTimerList(wxKEY_INTEGER); +WX_DECLARE_HASH_MAP( long, + wxTimer*, + wxIntegerHash, + wxIntegerEqual, + wxTimerMap ); + +wxTimerMap wxTimerList; UINT WINAPI _EXPORT wxTimerProc(HWND hwnd, WORD, int idTimer, DWORD); // ---------------------------------------------------------------------------- @@ -75,9 +82,11 @@ void wxTimer::Init() wxTimer::~wxTimer() { + long id = m_id; + wxTimer::Stop(); - wxTimerList.DeleteObject(this); + wxTimerList.erase(id); } bool wxTimer::Start(int milliseconds, bool oneShot) @@ -94,7 +103,7 @@ bool wxTimer::Start(int milliseconds, bool oneShot) if ( m_id > 0 ) { - wxTimerList.Append(m_id, this); + wxTimerList[m_id] = this; return true; } @@ -112,7 +121,7 @@ void wxTimer::Stop() { ::KillTimer(NULL, (UINT)m_id); - wxTimerList.DeleteObject(this); + wxTimerList.erase(m_id); } m_id = 0; @@ -136,11 +145,13 @@ void wxProcessTimer(wxTimer& timer) UINT WINAPI _EXPORT wxTimerProc(HWND WXUNUSED(hwnd), WORD, int idTimer, DWORD) { - wxNode *node = wxTimerList.Find((long)idTimer); + + wxTimerMap::iterator node = wxTimerList.find((long)idTimer); - wxCHECK_MSG( node, 0, wxT("bogus timer id in wxTimerProc") ); + wxCHECK_MSG( node != wxTimerList.end(), 0, + wxT("bogus timer id in wxTimerProc") ); - wxProcessTimer(*(wxTimer *)node->GetData()); + wxProcessTimer(*(node->second)); return 0; } diff --git a/src/msw/treectrl.cpp b/src/msw/treectrl.cpp index 59a4cccf42..78b92eaffd 100644 --- a/src/msw/treectrl.cpp +++ b/src/msw/treectrl.cpp @@ -725,7 +725,8 @@ wxTreeCtrl::~wxTreeCtrl() // delete any attributes if ( m_hasAnyAttr ) { - for ( wxNode *node = m_attrs.Next(); node; node = m_attrs.Next() ) + for ( wxHashTable::compatibility_iterator node = m_attrs.Next(); + node; node = m_attrs.Next() ) { delete (wxTreeItemAttr *)node->GetData(); } diff --git a/src/msw/window.cpp b/src/msw/window.cpp index df95abf3a7..1e04a1e23d 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -262,7 +262,7 @@ wxWindow *wxWindowMSW::FindItem(long id) const } #endif // wxUSE_CONTROLS - wxWindowList::Node *current = GetChildren().GetFirst(); + wxWindowList::compatibility_iterator current = GetChildren().GetFirst(); while (current) { wxWindow *childWin = current->GetData(); @@ -280,7 +280,7 @@ wxWindow *wxWindowMSW::FindItem(long id) const // Find an item given the MS Windows handle wxWindow *wxWindowMSW::FindItemByHWND(WXHWND hWnd, bool controlOnly) const { - wxWindowList::Node *current = GetChildren().GetFirst(); + wxWindowList::compatibility_iterator current = GetChildren().GetFirst(); while (current) { wxWindow *parent = current->GetData(); @@ -517,7 +517,7 @@ bool wxWindowMSW::Enable(bool enable) // well but when it is enabled back, only those of the children which // hadn't been already disabled in the beginning should be enabled again, // so we have to keep the list of those children - for ( wxWindowList::Node *node = GetChildren().GetFirst(); + for ( wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); node; node = node->GetNext() ) { @@ -1946,7 +1946,7 @@ bool wxWindowMSW::MSWProcessMessage(WXMSG* pMsg) { // passimistic by default canSafelyCallIsDlgMsg = FALSE; - for ( wxWindowList::Node *node = GetChildren().GetFirst(); + for ( wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); node; node = node->GetNext() ) { @@ -2955,7 +2955,7 @@ bool wxWindowMSW::HandleNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) // correct button tooltips #if 0 // try all our children - wxWindowList::Node *node = GetChildren().GetFirst(); + wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); while ( node ) { wxWindow *child = node->GetData(); @@ -3612,7 +3612,7 @@ void wxWindowMSW::OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(event)) // FIXME-MT gs_hasStdCmap = FALSE; } - wxWindowList::Node *node = GetChildren().GetFirst(); + wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); while ( node ) { // Only propagate to non-top-level windows because Windows already diff --git a/src/x11/colour.cpp b/src/x11/colour.cpp index 7431369b7f..24b56a9ebf 100644 --- a/src/x11/colour.cpp +++ b/src/x11/colour.cpp @@ -158,9 +158,9 @@ wxColour::wxColour( unsigned char red, unsigned char green, unsigned char blue ) void wxColour::InitFromName( const wxString &colourName ) { wxNode *node = (wxNode *) NULL; - if ( (wxTheColourDatabase) && (node = wxTheColourDatabase->Find(colourName)) ) + wxColour* col; + if ( (wxTheColourDatabase) && (col = wxTheColourDatabase->FindColourNoAdd(colourName)) ) { - wxColour *col = (wxColour*)node->GetData(); UnRef(); if (col) Ref( *col ); } -- 2.45.2