From d162a7ee7d6bab3d0c714b865806377aeb5d0d9e Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 25 Jan 2003 12:28:51 +0000 Subject: [PATCH] removed warnings about using the deprecated functions and replaced untyped wxLists with the type safe equivalents (patch 668204 from Dimitri) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@18925 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/dde.h | 11 +++ include/wx/msw/dde.h | 27 ++++--- include/wx/msw/gdiimage.h | 6 +- include/wx/msw/taskbar.h | 12 ++- src/msw/app.cpp | 12 ++- src/msw/dde.cpp | 154 +++++++++++++++++++++----------------- src/msw/gdiimage.cpp | 24 +++--- src/msw/mdi.cpp | 16 ++-- src/msw/taskbar.cpp | 13 ++-- 9 files changed, 164 insertions(+), 111 deletions(-) diff --git a/include/wx/dde.h b/include/wx/dde.h index 03a7665b1c..15d70578b4 100644 --- a/include/wx/dde.h +++ b/include/wx/dde.h @@ -1,6 +1,17 @@ #ifndef _WX_DDE_H_BASE_ #define _WX_DDE_H_BASE_ +#include "wx/list.h" + +class wxDDEClient; +class wxDDEServer; +class wxDDEConnection; + +WX_DECLARE_LIST(wxDDEClient, wxDDEClientList); +WX_DECLARE_LIST(wxDDEServer, wxDDEServerList); +WX_DECLARE_LIST(wxDDEConnection, wxDDEConnectionList); + + #if defined(__WXMSW__) #include "wx/msw/dde.h" #elif defined(__WXMOTIF__) diff --git a/include/wx/msw/dde.h b/include/wx/msw/dde.h index 4d305f46b6..1c9627d55a 100644 --- a/include/wx/msw/dde.h +++ b/include/wx/msw/dde.h @@ -100,12 +100,15 @@ class WXDLLEXPORT wxDDEServer: public wxServerBase wxDDEConnection *FindConnection(WXHCONV conv); bool DeleteConnection(WXHCONV conv); inline wxString& GetServiceName(void) const { return (wxString&) m_serviceName; } - inline wxList& GetConnections(void) const { return (wxList&) m_connections; } - - protected: - int m_lastError; - wxString m_serviceName; - wxList m_connections; + inline wxDDEConnectionList& GetConnections(void) const + { + return (wxDDEConnectionList&) m_connections; + } + +protected: + int m_lastError; + wxString m_serviceName; + wxDDEConnectionList m_connections; }; class WXDLLEXPORT wxDDEClient: public wxClientBase @@ -126,11 +129,15 @@ class WXDLLEXPORT wxDDEClient: public wxClientBase // Find/delete wxDDEConnection corresponding to the HCONV wxDDEConnection *FindConnection(WXHCONV conv); bool DeleteConnection(WXHCONV conv); - inline wxList& GetConnections(void) const { return (wxList&) m_connections; } - protected: - int m_lastError; - wxList m_connections; + inline wxDDEConnectionList& GetConnections(void) const + { + return (wxDDEConnectionList&) m_connections; + } + +protected: + int m_lastError; + wxDDEConnectionList m_connections; }; void WXDLLEXPORT wxDDEInitialize(); diff --git a/include/wx/msw/gdiimage.h b/include/wx/msw/gdiimage.h index 3bf601dda4..522e5477df 100644 --- a/include/wx/msw/gdiimage.h +++ b/include/wx/msw/gdiimage.h @@ -28,6 +28,8 @@ class WXDLLEXPORT wxGDIImageRefData; class WXDLLEXPORT wxGDIImageHandler; class WXDLLEXPORT wxGDIImage; +WX_DECLARE_LIST(wxGDIImageHandler, wxGDIImageHandlerList); + // ---------------------------------------------------------------------------- // wxGDIImageRefData: common data fields for all derived classes // ---------------------------------------------------------------------------- @@ -135,7 +137,7 @@ class WXDLLEXPORT wxGDIImage : public wxGDIObject { public: // handlers list interface - static wxList& GetHandlers() { return ms_handlers; } + static wxGDIImageHandlerList& GetHandlers() { return ms_handlers; } static void AddHandler(wxGDIImageHandler *handler); static void InsertHandler(wxGDIImageHandler *handler); @@ -186,7 +188,7 @@ protected: // create the data for the derived class here virtual wxGDIImageRefData *CreateData() const = 0; - static wxList ms_handlers; + static wxGDIImageHandlerList ms_handlers; }; #endif // _WX_MSW_GDIIMAGE_H_ diff --git a/include/wx/msw/taskbar.h b/include/wx/msw/taskbar.h index 2da54b6894..b6fccfa2c4 100644 --- a/include/wx/msw/taskbar.h +++ b/include/wx/msw/taskbar.h @@ -17,9 +17,13 @@ #pragma interface "taskbar.h" #endif -#include -#include -#include +#include "wx/event.h" +#include "wx/list.h" +#include "wx/icon.h" + +class wxTaskBarIcon; + +WX_DECLARE_LIST(wxTaskBarIcon, wxTaskBarIconList); class WXDLLEXPORT wxTaskBarIcon: public wxEvtHandler { DECLARE_DYNAMIC_CLASS(wxTaskBarIcon) @@ -58,7 +62,7 @@ public: protected: WXHWND m_hWnd; bool m_iconAdded; - static wxList sm_taskBarIcons; + static wxTaskBarIconList sm_taskBarIcons; static bool sm_registeredClass; static unsigned int sm_taskbarMsg; diff --git a/src/msw/app.cpp b/src/msw/app.cpp index 05cb68f704..bb05dd8873 100644 --- a/src/msw/app.cpp +++ b/src/msw/app.cpp @@ -1140,24 +1140,22 @@ bool wxApp::SendIdleEvents() // Send idle event to window and all subwindows bool wxApp::SendIdleEvents(wxWindow* win) { - bool needMore = FALSE; - wxIdleEvent event; event.SetEventObject(win); win->GetEventHandler()->ProcessEvent(event); - if (event.MoreRequested()) - needMore = TRUE; + bool needMore = event.MoreRequested(); - wxWindowList::Node* node = win->GetChildren().GetFirst(); - while (node) + wxWindowList::Node *node = win->GetChildren().GetFirst(); + while ( node ) { - wxWindow* win = node->GetData(); + wxWindow *win = node->GetData(); if (SendIdleEvents(win)) needMore = TRUE; node = node->GetNext(); } + return needMore; } diff --git a/src/msw/dde.cpp b/src/msw/dde.cpp index 03fdc05daf..a03da5030b 100644 --- a/src/msw/dde.cpp +++ b/src/msw/dde.cpp @@ -124,10 +124,16 @@ static void DDELogError(const wxString& s, UINT error = DMLERR_NO_ERROR); static DWORD DDEIdInst = 0L; static wxDDEConnection *DDECurrentlyConnecting = NULL; - static wxList wxAtomTable(wxKEY_STRING); -static wxList wxDDEClientObjects; -static wxList wxDDEServerObjects; + +#include "wx/listimpl.cpp" + +WX_DEFINE_LIST(wxDDEClientList); +WX_DEFINE_LIST(wxDDEServerList); +WX_DEFINE_LIST(wxDDEConnectionList); + +static wxDDEClientList wxDDEClientObjects; +static wxDDEServerList wxDDEServerObjects; static bool DDEInitialized = false; @@ -211,64 +217,75 @@ void wxDDECleanUp() // Global find connection static wxDDEConnection *DDEFindConnection(HCONV hConv) { - wxNode *node = wxDDEServerObjects.GetFirst(); - wxDDEConnection *found = NULL; - while (node && !found) - { - wxDDEServer *object = (wxDDEServer *)node->GetData(); - found = object->FindConnection((WXHCONV) hConv); - node = node->GetNext(); - } - if (found) - return found; - - node = wxDDEClientObjects.GetFirst(); - while (node && !found) - { - wxDDEClient *object = (wxDDEClient *)node->GetData(); - found = object->FindConnection((WXHCONV) hConv); - node = node->GetNext(); - } - return found; + wxDDEServerList::Node *serverNode = wxDDEServerObjects.GetFirst(); + wxDDEConnection *found = NULL; + while (serverNode && !found) + { + wxDDEServer *object = serverNode->GetData(); + found = object->FindConnection((WXHCONV) hConv); + serverNode = serverNode->GetNext(); + } + + if (found) + { + return found; + } + + wxDDEClientList::Node *clientNode = wxDDEClientObjects.GetFirst(); + while (clientNode && !found) + { + wxDDEClient *object = clientNode->GetData(); + found = object->FindConnection((WXHCONV) hConv); + clientNode = clientNode->GetNext(); + } + return found; } // Global delete connection static void DDEDeleteConnection(HCONV hConv) { - wxNode *node = wxDDEServerObjects.GetFirst(); - bool found = false; - while (node && !found) - { - wxDDEServer *object = (wxDDEServer *)node->GetData(); - found = object->DeleteConnection((WXHCONV) hConv); - node = node->GetNext(); - } - if (found) - return; - - node = wxDDEClientObjects.GetFirst(); - while (node && !found) - { - wxDDEClient *object = (wxDDEClient *)node->GetData(); - found = object->DeleteConnection((WXHCONV) hConv); - node = node->GetNext(); - } + wxDDEServerList::Node *serverNode = wxDDEServerObjects.GetFirst(); + bool found = false; + while (serverNode && !found) + { + wxDDEServer *object = serverNode->GetData(); + found = object->DeleteConnection((WXHCONV) hConv); + serverNode = serverNode->GetNext(); + } + if (found) + { + return; + } + + wxDDEClientList::Node *clientNode = wxDDEClientObjects.GetFirst(); + while (clientNode && !found) + { + wxDDEClient *object = clientNode->GetData(); + found = object->DeleteConnection((WXHCONV) hConv); + clientNode = clientNode->GetNext(); + } } // Find a server from a service name static wxDDEServer *DDEFindServer(const wxString& s) { - wxNode *node = wxDDEServerObjects.GetFirst(); - wxDDEServer *found = NULL; - while (node && !found) - { - wxDDEServer *object = (wxDDEServer *)node->GetData(); - - if (object->GetServiceName() == s) - found = object; - else node = node->GetNext(); - } - return found; + wxDDEServerList::Node *node = wxDDEServerObjects.GetFirst(); + wxDDEServer *found = NULL; + while (node && !found) + { + wxDDEServer *object = node->GetData(); + + if (object->GetServiceName() == s) + { + found = object; + } + else + { + node = node->GetNext(); + } + } + + return found; } // ---------------------------------------------------------------------------- @@ -311,11 +328,11 @@ wxDDEServer::~wxDDEServer() wxDDEServerObjects.DeleteObject(this); - wxNode *node = m_connections.GetFirst(); + wxDDEConnectionList::Node *node = m_connections.GetFirst(); while (node) { - wxDDEConnection *connection = (wxDDEConnection *)node->GetData(); - wxNode *next = node->GetNext(); + wxDDEConnection *connection = node->GetData(); + wxDDEConnectionList::Node *next = node->GetNext(); connection->SetConnected(false); connection->OnDisconnect(); // May delete the node implicitly node = next; @@ -325,8 +342,8 @@ wxDDEServer::~wxDDEServer() node = m_connections.GetFirst(); while (node) { - wxDDEConnection *connection = (wxDDEConnection *)node->GetData(); - wxNode *next = node->GetNext(); + wxDDEConnection *connection = node->GetData(); + wxDDEConnectionList::Node *next = node->GetNext(); delete connection; node = next; } @@ -339,11 +356,11 @@ wxConnectionBase *wxDDEServer::OnAcceptConnection(const wxString& /* topic */) wxDDEConnection *wxDDEServer::FindConnection(WXHCONV conv) { - wxNode *node = m_connections.GetFirst(); + wxDDEConnectionList::Node *node = m_connections.GetFirst(); wxDDEConnection *found = NULL; while (node && !found) { - wxDDEConnection *connection = (wxDDEConnection *)node->GetData(); + wxDDEConnection *connection = node->GetData(); if (connection->m_hConv == conv) found = connection; else node = node->GetNext(); @@ -354,17 +371,20 @@ wxDDEConnection *wxDDEServer::FindConnection(WXHCONV conv) // Only delete the entry in the map, not the actual connection bool wxDDEServer::DeleteConnection(WXHCONV conv) { - wxNode *node = m_connections.GetFirst(); + wxDDEConnectionList::Node *node = m_connections.GetFirst(); bool found = false; while (node && !found) { - wxDDEConnection *connection = (wxDDEConnection *)node->GetData(); + wxDDEConnection *connection = node->GetData(); if (connection->m_hConv == conv) { found = true; delete node; } - else node = node->GetNext(); + else + { + node = node->GetNext(); + } } return found; } @@ -383,10 +403,10 @@ wxDDEClient::wxDDEClient() wxDDEClient::~wxDDEClient() { wxDDEClientObjects.DeleteObject(this); - wxNode *node = m_connections.GetFirst(); + wxDDEConnectionList::Node *node = m_connections.GetFirst(); while (node) { - wxDDEConnection *connection = (wxDDEConnection *)node->GetData(); + wxDDEConnection *connection = node->GetData(); delete connection; // Deletes the node implicitly (see ~wxDDEConnection) node = m_connections.GetFirst(); } @@ -431,11 +451,11 @@ wxConnectionBase *wxDDEClient::OnMakeConnection() wxDDEConnection *wxDDEClient::FindConnection(WXHCONV conv) { - wxNode *node = m_connections.GetFirst(); + wxDDEConnectionList::Node *node = m_connections.GetFirst(); wxDDEConnection *found = NULL; while (node && !found) { - wxDDEConnection *connection = (wxDDEConnection *)node->GetData(); + wxDDEConnection *connection = node->GetData(); if (connection->m_hConv == conv) found = connection; else node = node->GetNext(); @@ -446,11 +466,11 @@ wxDDEConnection *wxDDEClient::FindConnection(WXHCONV conv) // Only delete the entry in the map, not the actual connection bool wxDDEClient::DeleteConnection(WXHCONV conv) { - wxNode *node = m_connections.GetFirst(); + wxDDEConnectionList::Node *node = m_connections.GetFirst(); bool found = false; while (node && !found) { - wxDDEConnection *connection = (wxDDEConnection *)node->GetData(); + wxDDEConnection *connection = node->GetData(); if (connection->m_hConv == conv) { found = true; diff --git a/src/msw/gdiimage.cpp b/src/msw/gdiimage.cpp index 6891c30349..7fb451d303 100644 --- a/src/msw/gdiimage.cpp +++ b/src/msw/gdiimage.cpp @@ -45,6 +45,10 @@ #include "wx/msw/gdiimage.h" #include "wx/bitmap.h" +#include "wx/listimpl.cpp" +WX_DEFINE_LIST(wxGDIImageHandlerList); + + #ifdef __WIN16__ # include "wx/msw/curico.h" #endif // __WIN16__ @@ -191,7 +195,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxICOResourceHandler, wxObject) // implementation // ============================================================================ -wxList wxGDIImage::ms_handlers; +wxGDIImageHandlerList wxGDIImage::ms_handlers; // ---------------------------------------------------------------------------- // wxGDIImage functions forwarded to wxGDIImageRefData @@ -241,10 +245,10 @@ bool wxGDIImage::RemoveHandler(const wxString& name) wxGDIImageHandler *wxGDIImage::FindHandler(const wxString& name) { - wxNode *node = ms_handlers.GetFirst(); + wxGDIImageHandlerList::Node *node = ms_handlers.GetFirst(); while ( node ) { - wxGDIImageHandler *handler = (wxGDIImageHandler *)node->GetData(); + wxGDIImageHandler *handler = node->GetData(); if ( handler->GetName() == name ) return handler; node = node->GetNext(); @@ -256,10 +260,10 @@ wxGDIImageHandler *wxGDIImage::FindHandler(const wxString& name) wxGDIImageHandler *wxGDIImage::FindHandler(const wxString& extension, long type) { - wxNode *node = ms_handlers.GetFirst(); + wxGDIImageHandlerList::Node *node = ms_handlers.GetFirst(); while ( node ) { - wxGDIImageHandler *handler = (wxGDIImageHandler *)node->GetData(); + wxGDIImageHandler *handler = node->GetData(); if ( (handler->GetExtension() = extension) && (type == -1 || handler->GetType() == type) ) { @@ -273,10 +277,10 @@ wxGDIImageHandler *wxGDIImage::FindHandler(const wxString& extension, wxGDIImageHandler *wxGDIImage::FindHandler(long type) { - wxNode *node = ms_handlers.GetFirst(); + wxGDIImageHandlerList::Node *node = ms_handlers.GetFirst(); while ( node ) { - wxGDIImageHandler *handler = (wxGDIImageHandler *)node->GetData(); + wxGDIImageHandler *handler = node->GetData(); if ( handler->GetType() == type ) return handler; @@ -288,11 +292,11 @@ wxGDIImageHandler *wxGDIImage::FindHandler(long type) void wxGDIImage::CleanUpHandlers() { - wxNode *node = ms_handlers.GetFirst(); + wxGDIImageHandlerList::Node *node = ms_handlers.GetFirst(); while ( node ) { - wxGDIImageHandler *handler = (wxGDIImageHandler *)node->GetData(); - wxNode *next = node->GetNext(); + wxGDIImageHandler *handler = node->GetData(); + wxGDIImageHandlerList::Node *next = node->GetNext(); delete handler; delete node; node = next; diff --git a/src/msw/mdi.cpp b/src/msw/mdi.cpp index 5a6f624b6d..a11484a3ed 100644 --- a/src/msw/mdi.cpp +++ b/src/msw/mdi.cpp @@ -557,10 +557,10 @@ bool wxMDIParentFrame::HandleCommand(WXWORD id, WXWORD cmd, WXHWND hwnd) if ( IsMdiCommandId(id) ) { - wxWindowList::Node* node = GetChildren().GetFirst(); + wxWindowList::Node *node = GetChildren().GetFirst(); while ( node ) { - wxWindow* child = node->GetData(); + wxWindow *child = node->GetData(); if ( child->GetHWND() ) { long childId = wxGetWindowId(child->GetHWND()); @@ -1245,14 +1245,18 @@ void wxMDIClientWindow::DoSetSize(int x, int y, int width, int height, int sizeF { if (GetParent()) { - wxWindowList::Node* node = GetParent()->GetChildren().GetFirst(); + wxWindowList::Node *node = GetParent()->GetChildren().GetFirst(); while (node) { - wxWindow* child = node->GetData(); + wxWindow *child = node->GetData(); if (child->IsKindOf(CLASSINFO(wxMDIChildFrame))) { - HWND hWnd = (HWND) child->GetHWND(); - ::RedrawWindow(hWnd, NULL, NULL, RDW_FRAME|RDW_ALLCHILDREN|RDW_INVALIDATE ); + ::RedrawWindow(GetHwndOf(child), + NULL, + NULL, + RDW_FRAME | + RDW_ALLCHILDREN | + RDW_INVALIDATE); } node = node->GetNext(); } diff --git a/src/msw/taskbar.cpp b/src/msw/taskbar.cpp index 19fb0189a9..6be5dd0428 100644 --- a/src/msw/taskbar.cpp +++ b/src/msw/taskbar.cpp @@ -49,13 +49,16 @@ #include #endif +#include "wx/listimpl.cpp" +WX_DEFINE_LIST(wxTaskBarIconList); + LRESULT APIENTRY _EXPORT wxTaskBarIconWindowProc( HWND hWnd, unsigned msg, UINT wParam, LONG lParam ); wxChar *wxTaskBarWindowClass = (wxChar*) wxT("wxTaskBarWindowClass"); -wxList wxTaskBarIcon::sm_taskBarIcons; -bool wxTaskBarIcon::sm_registeredClass = false; +wxTaskBarIconList wxTaskBarIcon::sm_taskBarIcons; +bool wxTaskBarIcon::sm_registeredClass = FALSE; UINT wxTaskBarIcon::sm_taskbarMsg = 0; DEFINE_EVENT_TYPE( wxEVT_TASKBAR_MOVE ) @@ -247,10 +250,10 @@ void wxTaskBarIcon::_OnRButtonDClick(wxEvent& e) { OnRButtonDClick(e); } wxTaskBarIcon* wxTaskBarIcon::FindObjectForHWND(WXHWND hWnd) { - wxNode *node = sm_taskBarIcons.GetFirst(); + wxTaskBarIconList::Node *node = sm_taskBarIcons.GetFirst(); while (node) { - wxTaskBarIcon* obj = (wxTaskBarIcon*) node->GetData(); + wxTaskBarIcon *obj = node->GetData(); if (obj->GetHWND() == hWnd) return obj; node = node->GetNext(); @@ -372,7 +375,7 @@ long wxTaskBarIcon::WindowProc( WXHWND hWnd, unsigned int msg, unsigned int wPar LRESULT APIENTRY _EXPORT wxTaskBarIconWindowProc( HWND hWnd, unsigned msg, UINT wParam, LONG lParam ) { - wxTaskBarIcon* obj = wxTaskBarIcon::FindObjectForHWND((WXHWND) hWnd); + wxTaskBarIcon *obj = wxTaskBarIcon::FindObjectForHWND((WXHWND) hWnd); if (obj) return obj->WindowProc((WXHWND) hWnd, msg, wParam, lParam); else -- 2.47.2