replaced wxList for storing HWND <-> wxWindow with wxHashTable

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@12250 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2001-11-02 00:44:19 +00:00
parent a4aad4def6
commit 1bffa9138f
3 changed files with 13 additions and 12 deletions

View File

@@ -28,6 +28,13 @@
// a better solution should be found later... // a better solution should be found later...
#define wxUSE_MOUSEEVENT_HACK 0 #define wxUSE_MOUSEEVENT_HACK 0
#include "wx/hash.h"
// pseudo-template HWND <-> wxWindow hash table
WX_DECLARE_HASH(wxWindow, wxWindowList, wxWinHashTable);
extern wxWinHashTable *wxWinHandleHash;
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// constants // constants
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------

View File

@@ -124,7 +124,6 @@
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
extern wxChar *wxBuffer; extern wxChar *wxBuffer;
extern wxList *wxWinHandleList;
extern wxList WXDLLEXPORT wxPendingDelete; extern wxList WXDLLEXPORT wxPendingDelete;
#ifndef __WXMICROWIN__ #ifndef __WXMICROWIN__
extern void wxSetKeyboardHook(bool doIt); extern void wxSetKeyboardHook(bool doIt);
@@ -295,7 +294,7 @@ bool wxApp::Initialize()
wxRegisterPenWin(); wxRegisterPenWin();
#endif #endif
wxWinHandleList = new wxList(wxKEY_INTEGER); wxWinHandleHash = new wxWinHashTable(wxKEY_INTEGER, 100);
// This is to foil optimizations in Visual C++ that throw out dummy.obj. // This is to foil optimizations in Visual C++ that throw out dummy.obj.
// PLEASE DO NOT ALTER THIS. // PLEASE DO NOT ALTER THIS.
@@ -701,8 +700,7 @@ void wxApp::CleanUp()
Ctl3dUnregister(wxhInstance); Ctl3dUnregister(wxhInstance);
#endif #endif
if (wxWinHandleList) delete wxWinHandleHash;
delete wxWinHandleList;
// GL: I'm annoyed ... I don't know where to put this and I don't want to // GL: I'm annoyed ... I don't know where to put this and I don't want to
// create a module for that as it's part of the core. // create a module for that as it's part of the core.

View File

@@ -118,7 +118,6 @@
#endif #endif
#endif #endif
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// global variables // global variables
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -2594,14 +2593,11 @@ long wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam
// wxWindow <-> HWND map // wxWindow <-> HWND map
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
wxList *wxWinHandleList = NULL; wxWinHashTable *wxWinHandleHash = NULL;
wxWindow *wxFindWinFromHandle(WXHWND hWnd) wxWindow *wxFindWinFromHandle(WXHWND hWnd)
{ {
wxNode *node = wxWinHandleList->Find((long)hWnd); return wxWinHandleHash->Get((long)hWnd);
if ( !node )
return NULL;
return (wxWindow *)node->Data();
} }
void wxAssociateWinWithHandle(HWND hWnd, wxWindowMSW *win) void wxAssociateWinWithHandle(HWND hWnd, wxWindowMSW *win)
@@ -2622,13 +2618,13 @@ void wxAssociateWinWithHandle(HWND hWnd, wxWindowMSW *win)
#endif // __WXDEBUG__ #endif // __WXDEBUG__
if (!oldWin) if (!oldWin)
{ {
wxWinHandleList->Append((long)hWnd, win); wxWinHandleHash->Put((long)hWnd, win);
} }
} }
void wxRemoveHandleAssociation(wxWindowMSW *win) void wxRemoveHandleAssociation(wxWindowMSW *win)
{ {
wxWinHandleList->DeleteObject(win); wxWinHandleHash->Delete((long)win->GetHWND());
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------