Added support for compiling with wxUSE_STL set to 1.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30809 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Neis
2004-11-28 18:39:30 +00:00
parent c6efd6e0ec
commit 2461cfa0d9
10 changed files with 208 additions and 153 deletions

View File

@@ -575,5 +575,19 @@ WXDLLEXPORT int wxCharCodeOS2ToWX(int nKeySym);
WXDLLEXPORT int wxCharCodeWXToOS2( int nId WXDLLEXPORT int wxCharCodeWXToOS2( int nId
,bool* pbIsVirtual ,bool* pbIsVirtual
); );
// ----------------------------------------------------------------------------
// global objects
// ----------------------------------------------------------------------------
// notice that this hash must be defined after wxWindow declaration as it
// needs to "see" its dtor and not just forward declaration
#include "wx/hash.h"
// pseudo-template HWND <-> wxWindow hash table
WX_DECLARE_HASH(wxWindowOS2, wxWindowList, wxWinHashTable);
extern wxWinHashTable *wxWinHandleHash;
#endif #endif
// _WX_WINDOW_H_ // _WX_WINDOW_H_

View File

@@ -82,7 +82,6 @@ extern "C" int _System bsdselect(int,
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
extern wxChar* wxBuffer; extern wxChar* wxBuffer;
extern wxList* wxWinHandleList;
extern wxList WXDLLEXPORT wxPendingDelete; extern wxList WXDLLEXPORT wxPendingDelete;
extern wxCursor* g_globalCursor; extern wxCursor* g_globalCursor;
@@ -240,7 +239,7 @@ bool wxApp::Initialize(int& argc, wxChar **argv)
// wxRedirectIOToConsole(); // wxRedirectIOToConsole();
#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.
@@ -419,8 +418,8 @@ void wxApp::CleanUp()
// TODO: ::DeleteObject( wxDisableButtonBrush ); // TODO: ::DeleteObject( wxDisableButtonBrush );
} }
if (wxWinHandleList) delete wxWinHandleHash;
delete wxWinHandleList; wxWinHandleHash = NULL;
// Delete Message queue // Delete Message queue
if (wxTheApp->m_hMq) if (wxTheApp->m_hMq)

View File

@@ -179,12 +179,12 @@ void wxMenu::UpdateAccel(
if (pItem->IsSubMenu()) if (pItem->IsSubMenu())
{ {
wxMenu* pSubmenu = pItem->GetSubMenu(); wxMenu* pSubmenu = pItem->GetSubMenu();
wxMenuItemList::Node* pNode = pSubmenu->GetMenuItems().GetFirst(); wxMenuItemList::compatibility_iterator node = pSubmenu->GetMenuItems().GetFirst();
while (pNode) while (node)
{ {
UpdateAccel(pNode->GetData()); UpdateAccel(node->GetData());
pNode = pNode->GetNext(); node = node->GetNext();
} }
} }
else if (!pItem->IsSeparator()) else if (!pItem->IsSeparator())
@@ -416,11 +416,11 @@ wxMenuItem* wxMenu::DoAppend(
// //
pItem->SetRadioGroupStart(m_nStartRadioGroup); pItem->SetRadioGroupStart(m_nStartRadioGroup);
wxMenuItemList::Node* pNode = GetMenuItems().Item(m_nStartRadioGroup); wxMenuItemList::compatibility_iterator node = GetMenuItems().Item(m_nStartRadioGroup);
if (pNode) if (node)
{ {
pNode->GetData()->SetRadioGroupEnd(nCount); node->GetData()->SetRadioGroupEnd(nCount);
} }
else else
{ {
@@ -470,19 +470,19 @@ wxMenuItem* wxMenu::DoRemove(
// We need to find the items position in the child list // We need to find the items position in the child list
// //
size_t nPos; size_t nPos;
wxMenuItemList::Node* pNode = GetMenuItems().GetFirst(); wxMenuItemList::compatibility_iterator node = GetMenuItems().GetFirst();
for (nPos = 0; pNode; nPos++) for (nPos = 0; node; nPos++)
{ {
if (pNode->GetData() == pItem) if (node->GetData() == pItem)
break; break;
pNode = pNode->GetNext(); node = node->GetNext();
} }
// //
// DoRemove() (unlike Remove) can only be called for existing item! // DoRemove() (unlike Remove) can only be called for existing item!
// //
wxCHECK_MSG(pNode, NULL, wxT("bug in wxMenu::Remove logic")); wxCHECK_MSG(node, NULL, wxT("bug in wxMenu::Remove logic"));
#if wxUSE_ACCEL #if wxUSE_ACCEL
// //
@@ -641,7 +641,7 @@ wxMenuItem* wxMenu::FindItem(
wxMenuItem* pItem = NULL; wxMenuItem* pItem = NULL;
for ( wxMenuItemList::Node *node = m_items.GetFirst(); for ( wxMenuItemList::compatibility_iterator node = m_items.GetFirst();
node && !pItem; node && !pItem;
node = node->GetNext() ) node = node->GetNext() )
{ {
@@ -772,9 +772,9 @@ WXHMENU wxMenuBar::Create()
} }
else else
{ {
size_t nCount = GetMenuCount(); size_t nCount = GetMenuCount(), i;
wxMenuList::iterator it;
for (size_t i = 0; i < nCount; i++) for (i = 0, it = m_menus.begin(); i < nCount; i++, it++)
{ {
APIRET rc; APIRET rc;
ERRORID vError; ERRORID vError;
@@ -784,8 +784,8 @@ WXHMENU wxMenuBar::Create()
// //
// Set the parent and owner of the submenues to be the menubar, not the desktop // Set the parent and owner of the submenues to be the menubar, not the desktop
// //
hSubMenu = m_menus[i]->m_vMenuData.hwndSubMenu; hSubMenu = (*it)->m_vMenuData.hwndSubMenu;
if (!::WinSetParent(m_menus[i]->m_vMenuData.hwndSubMenu, m_hMenu, FALSE)) if (!::WinSetParent((*it)->m_vMenuData.hwndSubMenu, m_hMenu, FALSE))
{ {
vError = ::WinGetLastError(vHabmain); vError = ::WinGetLastError(vHabmain);
sError = wxPMErrorToStr(vError); sError = wxPMErrorToStr(vError);
@@ -793,7 +793,7 @@ WXHMENU wxMenuBar::Create()
return NULLHANDLE; return NULLHANDLE;
} }
if (!::WinSetOwner(m_menus[i]->m_vMenuData.hwndSubMenu, m_hMenu)) if (!::WinSetOwner((*it)->m_vMenuData.hwndSubMenu, m_hMenu))
{ {
vError = ::WinGetLastError(vHabmain); vError = ::WinGetLastError(vHabmain);
sError = wxPMErrorToStr(vError); sError = wxPMErrorToStr(vError);
@@ -801,9 +801,9 @@ WXHMENU wxMenuBar::Create()
return NULLHANDLE; return NULLHANDLE;
} }
m_menus[i]->m_vMenuData.iPosition = i; (*it)->m_vMenuData.iPosition = i;
rc = (APIRET)::WinSendMsg(m_hMenu, MM_INSERTITEM, (MPARAM)&m_menus[i]->m_vMenuData, (MPARAM)m_titles[i].c_str()); rc = (APIRET)::WinSendMsg(m_hMenu, MM_INSERTITEM, (MPARAM)&(*it)->m_vMenuData, (MPARAM)m_titles[i].c_str());
if (rc == (APIRET)MIT_MEMERROR || rc == (APIRET)MIT_ERROR) if (rc == (APIRET)MIT_MEMERROR || rc == (APIRET)MIT_ERROR)
{ {
vError = ::WinGetLastError(vHabmain); vError = ::WinGetLastError(vHabmain);
@@ -1051,7 +1051,7 @@ wxMenu* wxMenuBar::Remove(
#endif // wxUSE_ACCEL #endif // wxUSE_ACCEL
Refresh(); Refresh();
} }
m_titles.Remove(nPos); m_titles.RemoveAt(nPos);
return pMenu; return pMenu;
} // end of wxMenuBar::Remove } // end of wxMenuBar::Remove
@@ -1065,10 +1065,10 @@ void wxMenuBar::RebuildAccelTable()
size_t nAccelCount = 0; size_t nAccelCount = 0;
size_t i; size_t i;
size_t nCount = GetMenuCount(); size_t nCount = GetMenuCount();
wxMenuList::iterator it;
for (i = 0; i < nCount; i++) for (i = 0, it = m_menus.begin(); i < nCount; i++, it++)
{ {
nAccelCount += m_menus[i]->GetAccelCount(); nAccelCount += (*it)->GetAccelCount();
} }
if (nAccelCount) if (nAccelCount)
@@ -1076,9 +1076,9 @@ void wxMenuBar::RebuildAccelTable()
wxAcceleratorEntry* pAccelEntries = new wxAcceleratorEntry[nAccelCount]; wxAcceleratorEntry* pAccelEntries = new wxAcceleratorEntry[nAccelCount];
nAccelCount = 0; nAccelCount = 0;
for (i = 0; i < nCount; i++) for (i = 0, it = m_menus.begin(); i < nCount; i++, it++)
{ {
nAccelCount += m_menus[i]->CopyAccels(&pAccelEntries[nAccelCount]); nAccelCount += (*it)->CopyAccels(&pAccelEntries[nAccelCount]);
} }
m_vAccelTable = wxAcceleratorTable( nAccelCount m_vAccelTable = wxAcceleratorTable( nAccelCount
,pAccelEntries ,pAccelEntries
@@ -1128,14 +1128,14 @@ int wxMenuBar::FindMenuItem(
) const ) const
{ {
wxString sMenuLabel = wxStripMenuCodes(rMenuString); wxString sMenuLabel = wxStripMenuCodes(rMenuString);
size_t nCount = GetMenuCount(); size_t nCount = GetMenuCount(), i;
wxMenuList::const_iterator it;
for (size_t i = 0; i < nCount; i++) for (i = 0, it = m_menus.begin(); i < nCount; i++, it++)
{ {
wxString sTitle = wxStripMenuCodes(m_titles[i]); wxString sTitle = wxStripMenuCodes(m_titles[i]);
if (rMenuString == sTitle) if (rMenuString == sTitle)
return m_menus[i]->FindItem(rItemString); return (*it)->FindItem(rItemString);
} }
return wxNOT_FOUND; return wxNOT_FOUND;
} // end of wxMenuBar::FindMenuItem } // end of wxMenuBar::FindMenuItem
@@ -1149,11 +1149,11 @@ wxMenuItem* wxMenuBar::FindItem(
*ppItemMenu = NULL; *ppItemMenu = NULL;
wxMenuItem* pItem = NULL; wxMenuItem* pItem = NULL;
size_t nCount = GetMenuCount(); size_t nCount = GetMenuCount(), i;
wxMenuList::const_iterator it;
for (size_t i = 0; !pItem && (i < nCount); i++) for (i = 0, it = m_menus.begin(); !pItem && (i < nCount); i++, it++)
{ {
pItem = m_menus[i]->FindItem( nId pItem = (*it)->FindItem( nId
,ppItemMenu ,ppItemMenu
); );
} }
@@ -1170,11 +1170,11 @@ wxMenuItem* wxMenuBar::FindItem(
*ppItemMenu = NULL; *ppItemMenu = NULL;
wxMenuItem* pItem = NULL; wxMenuItem* pItem = NULL;
size_t nCount = GetMenuCount(); size_t nCount = GetMenuCount(), i;
wxMenuList::const_iterator it;
for (size_t i = 0; !pItem && (i < nCount); i++) for (i = 0, it = m_menus.begin(); !pItem && (i < nCount); i++, it++)
{ {
pItem = m_menus[i]->FindItem( nId pItem = (*it)->FindItem( nId
,hItem ,hItem
,ppItemMenu ,ppItemMenu
); );

View File

@@ -321,9 +321,9 @@ void wxMenuItem::Check(
// //
// Also uncheck all the other items in this radio group // Also uncheck all the other items in this radio group
// //
wxMenuItemList::Node* pNode = rItems.Item(nStart); wxMenuItemList::compatibility_iterator node = rItems.Item(nStart);
for (int n = nStart; n <= nEnd && pNode; n++) for (int n = nStart; n <= nEnd && node; n++)
{ {
if (n == nPos) if (n == nPos)
{ {
@@ -335,14 +335,14 @@ void wxMenuItem::Check(
} }
if (n != nPos) if (n != nPos)
{ {
pNode->GetData()->m_isChecked = FALSE; node->GetData()->m_isChecked = FALSE;
::WinSendMsg( hMenu ::WinSendMsg( hMenu
,MM_SETITEMATTR ,MM_SETITEMATTR
,MPFROM2SHORT(n, TRUE) ,MPFROM2SHORT(n, TRUE)
,MPFROM2SHORT(MIA_CHECKED, FALSE) ,MPFROM2SHORT(MIA_CHECKED, FALSE)
); );
} }
pNode = pNode->GetNext(); node = node->GetNext();
} }
} }
else // check item else // check item

View File

@@ -137,17 +137,17 @@ wxWindow* wxWindow::GetWindowChild1 (
if (m_windowId == vId) if (m_windowId == vId)
return this; return this;
wxWindowList::Node* pNode = GetChildren().GetFirst(); wxWindowList::compatibility_iterator node = GetChildren().GetFirst();
while (pNode) while (node)
{ {
wxWindow* pChild = pNode->GetData(); wxWindow* pChild = node->GetData();
wxWindow* pWin = pChild->GetWindowChild1(vId); wxWindow* pWin = pChild->GetWindowChild1(vId);
if (pWin) if (pWin)
return pWin; return pWin;
pNode = pNode->GetNext(); node = node->GetNext();
} }
return NULL; return NULL;
} // end of wxWindow::GetWindowChild1 } // end of wxWindow::GetWindowChild1

View File

@@ -223,9 +223,9 @@ void wxRadioButton::SetValue(
if (bValue) if (bValue)
{ {
const wxWindowList& rSiblings = GetParent()->GetChildren(); const wxWindowList& rSiblings = GetParent()->GetChildren();
wxWindowList::Node* pNodeThis = rSiblings.Find(this); wxWindowList::compatibility_iterator nodeThis = rSiblings.Find(this);
wxCHECK_RET(pNodeThis, _T("radio button not a child of its parent?")); wxCHECK_RET(nodeThis, _T("radio button not a child of its parent?"));
// //
// If it's not the first item of the group ... // If it's not the first item of the group ...
@@ -235,11 +235,11 @@ void wxRadioButton::SetValue(
// //
// ...turn off all radio buttons before this one // ...turn off all radio buttons before this one
// //
for ( wxWindowList::Node* pNodeBefore = pNodeThis->GetPrevious(); for ( wxWindowList::compatibility_iterator nodeBefore = nodeThis->GetPrevious();
pNodeBefore; nodeBefore;
pNodeBefore = pNodeBefore->GetPrevious() ) nodeBefore = nodeBefore->GetPrevious() )
{ {
wxRadioButton* pBtn = wxDynamicCast( pNodeBefore->GetData() wxRadioButton* pBtn = wxDynamicCast( nodeBefore->GetData()
,wxRadioButton ,wxRadioButton
); );
if (!pBtn) if (!pBtn)
@@ -265,11 +265,11 @@ void wxRadioButton::SetValue(
// //
// ... and all after this one // ... and all after this one
// //
for (wxWindowList::Node* pNodeAfter = pNodeThis->GetNext(); for (wxWindowList::compatibility_iterator nodeAfter = nodeThis->GetNext();
pNodeAfter; nodeAfter;
pNodeAfter = pNodeAfter->GetNext()) nodeAfter = nodeAfter->GetNext())
{ {
wxRadioButton* pBtn = wxDynamicCast( pNodeAfter->GetData() wxRadioButton* pBtn = wxDynamicCast( nodeAfter->GetData()
,wxRadioButton ,wxRadioButton
); );

View File

@@ -35,11 +35,31 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/timeb.h> #include <sys/timeb.h>
// ----------------------------------------------------------------------------
// private globals
// ----------------------------------------------------------------------------
// define a hash containing all the timers: it is indexed by timer id and
// contains the corresponding timer
WX_DECLARE_HASH_MAP(unsigned long, wxTimer *, wxIntegerHash, wxIntegerEqual,
wxTimerMap);
// instead of using a global here, wrap it in a static function as otherwise it
// could have been used before being initialized if a timer object were created
// globally
static wxTimerMap& TimerMap()
{
static wxTimerMap s_timerMap;
return s_timerMap;
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// private functions // private functions
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
wxList wxTimerList(wxKEY_INTEGER); // timer callback used for all timers
ULONG wxTimerProc(HWND hwnd, ULONG, int nIdTimer, ULONG); ULONG wxTimerProc(HWND hwnd, ULONG, int nIdTimer, ULONG);
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -48,6 +68,14 @@ ULONG wxTimerProc(HWND hwnd, ULONG, int nIdTimer, ULONG);
IMPLEMENT_ABSTRACT_CLASS(wxTimer, wxEvtHandler) IMPLEMENT_ABSTRACT_CLASS(wxTimer, wxEvtHandler)
// ============================================================================
// implementation
// ============================================================================
// ----------------------------------------------------------------------------
// wxTimer class
// ----------------------------------------------------------------------------
void wxTimer::Init() void wxTimer::Init()
{ {
m_ulId = 0; m_ulId = 0;
@@ -56,8 +84,6 @@ void wxTimer::Init()
wxTimer::~wxTimer() wxTimer::~wxTimer()
{ {
wxTimer::Stop(); wxTimer::Stop();
wxTimerList.DeleteObject(this);
} }
void wxTimer::Notify() void wxTimer::Notify()
@@ -87,8 +113,6 @@ bool wxTimer::Start(
wxCHECK_MSG( m_milli > 0L, FALSE, wxT("invalid value for timer") ); wxCHECK_MSG( m_milli > 0L, FALSE, wxT("invalid value for timer") );
wxTimerList.DeleteObject(this);
wxWindow* pWin = NULL; wxWindow* pWin = NULL;
if (m_owner) if (m_owner)
@@ -108,10 +132,23 @@ bool wxTimer::Start(
); );
if (m_ulId > 0L) if (m_ulId > 0L)
{ {
wxTimerList.Append( m_ulId // check that SetTimer() didn't reuse an existing id: according to
,this // the MSDN this can happen and this would be catastrophic to us as
); // we rely on ids uniquely identifying the timers because we use
return(TRUE); // them as keys in the hash
if ( TimerMap().find(m_ulId) != TimerMap().end() )
{
wxLogError(_("Timer creation failed."));
::WinStopTimer(m_Hab, pWin?(pWin->GetHWND()):NULL, m_ulId);
m_ulId = 0;
return false;
}
TimerMap()[m_ulId] = this;
return true;
} }
else else
{ {
@@ -133,7 +170,8 @@ void wxTimer::Stop()
} }
else else
::WinStopTimer(m_Hab, NULLHANDLE, m_ulId); ::WinStopTimer(m_Hab, NULLHANDLE, m_ulId);
wxTimerList.DeleteObject(this);
TimerMap().erase(m_ulId);
} }
m_ulId = 0L; m_ulId = 0L;
} }
@@ -165,11 +203,11 @@ ULONG wxTimerProc(
, ULONG , ULONG
) )
{ {
wxNode* pNode = wxTimerList.Find((ULONG)nIdTimer); wxTimerMap::iterator node = TimerMap().find((ULONG)nIdTimer);
wxCHECK_MSG(pNode, 0, wxT("bogus timer id in wxTimerProc") ); wxCHECK_MSG(node != TimerMap().end(), 0,
if (pNode) wxT("bogus timer id in wxTimerProc") );
wxProcessTimer(*(wxTimer *)pNode->GetData()); wxProcessTimer(*(node->second));
return 0; return 0;
} }

View File

@@ -445,11 +445,11 @@ bool wxToolBar::Realize()
// //
// Find the maximum tool width and height // Find the maximum tool width and height
// //
wxToolBarToolsList::Node* pNode = m_tools.GetFirst(); wxToolBarToolsList::compatibility_iterator node = m_tools.GetFirst();
while (pNode ) while (node )
{ {
wxToolBarTool* pTool = (wxToolBarTool *)pNode->GetData(); wxToolBarTool* pTool = (wxToolBarTool *)node->GetData();
if (HasFlag(wxTB_TEXT) && !pTool->GetLabel().IsEmpty()) if (HasFlag(wxTB_TEXT) && !pTool->GetLabel().IsEmpty())
{ {
@@ -470,7 +470,7 @@ bool wxToolBar::Realize()
if (pTool->GetHeight() > nMaxToolHeight) if (pTool->GetHeight() > nMaxToolHeight)
nMaxToolHeight = pTool->GetHeight(); nMaxToolHeight = pTool->GetHeight();
} }
pNode = pNode->GetNext(); node = node->GetNext();
} }
wxCoord vTbWidth = 0L; wxCoord vTbWidth = 0L;
@@ -497,10 +497,10 @@ bool wxToolBar::Realize()
int nSeparatorSize = m_toolSeparation; int nSeparatorSize = m_toolSeparation;
pNode = m_tools.GetFirst(); node = m_tools.GetFirst();
while (pNode) while (node)
{ {
wxToolBarTool* pTool = (wxToolBarTool *)pNode->GetData(); wxToolBarTool* pTool = (wxToolBarTool *)node->GetData();
if (pTool->IsSeparator()) if (pTool->IsSeparator())
{ {
@@ -567,7 +567,7 @@ bool wxToolBar::Realize()
if (m_vLastY > m_maxHeight) if (m_vLastY > m_maxHeight)
m_maxHeight = m_vLastY; m_maxHeight = m_vLastY;
pNode = pNode->GetNext(); node = node->GetNext();
} }
if ( GetWindowStyleFlag() & wxTB_HORIZONTAL ) if ( GetWindowStyleFlag() & wxTB_HORIZONTAL )
@@ -603,11 +603,11 @@ void wxToolBar::OnPaint (
nCount++; nCount++;
::WinFillRect(vDc.GetHPS(), &vDc.m_vRclPaint, GetBackgroundColour().GetPixel()); ::WinFillRect(vDc.GetHPS(), &vDc.m_vRclPaint, GetBackgroundColour().GetPixel());
for ( wxToolBarToolsList::Node* pNode = m_tools.GetFirst(); for ( wxToolBarToolsList::compatibility_iterator node = m_tools.GetFirst();
pNode; node;
pNode = pNode->GetNext() ) node = node->GetNext() )
{ {
wxToolBarTool* pTool = (wxToolBarTool*)pNode->GetData(); wxToolBarTool* pTool = (wxToolBarTool*)node->GetData();
if (pTool->IsButton() ) if (pTool->IsButton() )
DrawTool(vDc, pTool); DrawTool(vDc, pTool);
@@ -976,10 +976,10 @@ wxToolBarToolBase* wxToolBar::FindToolForPosition(
,&vTBarHeight ,&vTBarHeight
); );
vY = vTBarHeight - vY; vY = vTBarHeight - vY;
wxToolBarToolsList::Node* pNode = m_tools.GetFirst(); wxToolBarToolsList::compatibility_iterator node = m_tools.GetFirst();
while (pNode) while (node)
{ {
wxToolBarTool* pTool = (wxToolBarTool *)pNode->GetData(); wxToolBarTool* pTool = (wxToolBarTool *)node->GetData();
if (HasFlag(wxTB_TEXT) && !pTool->GetLabel().IsNull()) if (HasFlag(wxTB_TEXT) && !pTool->GetLabel().IsNull())
{ {
@@ -1001,7 +1001,7 @@ wxToolBarToolBase* wxToolBar::FindToolForPosition(
return pTool; return pTool;
} }
} }
pNode = pNode->GetNext(); node = node->GetNext();
} }
return (wxToolBarToolBase *)NULL; return (wxToolBarToolBase *)NULL;
} // end of wxToolBar::FindToolForPosition } // end of wxToolBar::FindToolForPosition

View File

@@ -515,10 +515,12 @@ wxString WXDLLEXPORT wxGetWindowText(
) )
{ {
wxString vStr; wxString vStr;
long lLen = ::WinQueryWindowTextLength((HWND)hWnd) + 1;
::WinQueryWindowText((HWND)hWnd, lLen, vStr.GetWriteBuf((int)lLen)); if ( hWnd )
vStr.UngetWriteBuf(); {
long lLen = ::WinQueryWindowTextLength((HWND)hWnd) + 1;
::WinQueryWindowText((HWND)hWnd, lLen, wxStringBuffer(vStr, lLen));
}
return vStr; return vStr;
} }
@@ -528,13 +530,14 @@ wxString WXDLLEXPORT wxGetWindowClass(
) )
{ {
wxString vStr; wxString vStr;
if ( hWnd )
{
int nLen = 256; // some starting value int nLen = 256; // some starting value
for ( ;; ) for ( ;; )
{ {
int nCount = ::WinQueryClassName((HWND)hWnd, nLen, vStr.GetWriteBuf(nLen)); int nCount = ::WinQueryClassName((HWND)hWnd, nLen, wxStringBuffer(vStr, nLen));
vStr.UngetWriteBuf();
if (nCount == nLen ) if (nCount == nLen )
{ {
// the class name might have been truncated, retry with larger // the class name might have been truncated, retry with larger
@@ -546,6 +549,7 @@ wxString WXDLLEXPORT wxGetWindowClass(
break; break;
} }
} }
}
return vStr; return vStr;
} }

View File

@@ -128,8 +128,6 @@ QMSG s_currentMsg;
wxMenu* wxCurrentPopupMenu = NULL; wxMenu* wxCurrentPopupMenu = NULL;
#endif // wxUSE_MENUS_NATIVE #endif // wxUSE_MENUS_NATIVE
wxList* wxWinHandleList = NULL;
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// private functions // private functions
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -218,17 +216,17 @@ wxWindow* wxWindowOS2::FindItem(
} }
#endif // wxUSE_CONTROLS #endif // wxUSE_CONTROLS
wxWindowList::Node* pCurrent = GetChildren().GetFirst(); wxWindowList::compatibility_iterator current = GetChildren().GetFirst();
while (pCurrent) while (current)
{ {
wxWindow* pChildWin = pCurrent->GetData(); wxWindow* pChildWin = current->GetData();
wxWindow* pWnd = pChildWin->FindItem(lId); wxWindow* pWnd = pChildWin->FindItem(lId);
if (pWnd) if (pWnd)
return pWnd; return pWnd;
pCurrent = pCurrent->GetNext(); current = current->GetNext();
} }
return(NULL); return(NULL);
} // end of wxWindowOS2::FindItem } // end of wxWindowOS2::FindItem
@@ -241,11 +239,11 @@ wxWindow* wxWindowOS2::FindItemByHWND(
, bool bControlOnly , bool bControlOnly
) const ) const
{ {
wxWindowList::Node* pCurrent = GetChildren().GetFirst(); wxWindowList::compatibility_iterator current = GetChildren().GetFirst();
while (pCurrent) while (current)
{ {
wxWindow* pParent = pCurrent->GetData(); wxWindow* pParent = current->GetData();
// //
// Do a recursive search. // Do a recursive search.
@@ -261,7 +259,7 @@ wxWindow* wxWindowOS2::FindItemByHWND(
#endif // wxUSE_CONTROLS #endif // wxUSE_CONTROLS
) )
{ {
wxWindow* pItem = pCurrent->GetData(); wxWindow* pItem = current->GetData();
if (pItem->GetHWND() == hWnd) if (pItem->GetHWND() == hWnd)
return(pItem); return(pItem);
@@ -271,7 +269,7 @@ wxWindow* wxWindowOS2::FindItemByHWND(
return(pItem); return(pItem);
} }
} }
pCurrent = pCurrent->GetNext(); current = current->GetNext();
} }
return(NULL); return(NULL);
} // end of wxWindowOS2::FindItemByHWND } // end of wxWindowOS2::FindItemByHWND
@@ -506,11 +504,11 @@ bool wxWindowOS2::Enable(
if (IsTopLevel()) if (IsTopLevel())
return TRUE; return TRUE;
wxWindowList::Node* pNode = GetChildren().GetFirst(); wxWindowList::compatibility_iterator node = GetChildren().GetFirst();
while (pNode) while (node)
{ {
wxWindow* pChild = pNode->GetData(); wxWindow* pChild = node->GetData();
if (bEnable) if (bEnable)
{ {
@@ -540,7 +538,7 @@ bool wxWindowOS2::Enable(
m_pChildrenDisabled->Append(pChild); m_pChildrenDisabled->Append(pChild);
} }
} }
pNode = pNode->GetNext(); node = node->GetNext();
} }
if (bEnable && m_pChildrenDisabled) if (bEnable && m_pChildrenDisabled)
{ {
@@ -3006,15 +3004,17 @@ MRESULT wxWindowOS2::OS2WindowProc(
return mResult; return mResult;
} // end of wxWindowOS2::OS2WindowProc } // end of wxWindowOS2::OS2WindowProc
// ----------------------------------------------------------------------------
// wxWindow <-> HWND map
// ----------------------------------------------------------------------------
wxWinHashTable *wxWinHandleHash = NULL;
wxWindow* wxFindWinFromHandle( wxWindow* wxFindWinFromHandle(
WXHWND hWnd WXHWND hWnd
) )
{ {
wxNode* pNode = wxWinHandleList->Find((long)hWnd); return (wxWindow *)wxWinHandleHash->Get((long)hWnd);
if (!pNode)
return NULL;
return (wxWindow *)pNode->GetData();
} // end of wxFindWinFromHandle } // end of wxFindWinFromHandle
void wxAssociateWinWithHandle( void wxAssociateWinWithHandle(
@@ -3042,8 +3042,8 @@ void wxAssociateWinWithHandle(
} }
else if (!pOldWin) else if (!pOldWin)
{ {
wxWinHandleList->Append( (long)hWnd wxWinHandleHash->Put( (long)hWnd
,pWin ,(wxWindow *)pWin
); );
} }
} // end of wxAssociateWinWithHandle } // end of wxAssociateWinWithHandle
@@ -3052,7 +3052,7 @@ void wxRemoveHandleAssociation(
wxWindowOS2* pWin wxWindowOS2* pWin
) )
{ {
wxWinHandleList->DeleteObject(pWin); wxWinHandleHash->Delete((long)pWin->GetHWND());
} // end of wxRemoveHandleAssociation } // end of wxRemoveHandleAssociation
// //
@@ -3660,14 +3660,14 @@ void wxWindowOS2::OnSysColourChanged(
wxSysColourChangedEvent& rEvent wxSysColourChangedEvent& rEvent
) )
{ {
wxWindowListNode* pNode = GetChildren().GetFirst(); wxWindowList::compatibility_iterator node = GetChildren().GetFirst();
while (pNode) while (node)
{ {
// //
// Only propagate to non-top-level windows // Only propagate to non-top-level windows
// //
wxWindow* pWin = (wxWindow *)pNode->GetData(); wxWindow* pWin = (wxWindow *)node->GetData();
if (pWin->GetParent()) if (pWin->GetParent())
{ {
@@ -3676,7 +3676,7 @@ void wxWindowOS2::OnSysColourChanged(
rEvent.m_eventObject = pWin; rEvent.m_eventObject = pWin;
pWin->GetEventHandler()->ProcessEvent(vEvent); pWin->GetEventHandler()->ProcessEvent(vEvent);
} }
pNode = pNode->GetNext(); node = node->GetNext();
} }
} // end of wxWindowOS2::OnSysColourChanged } // end of wxWindowOS2::OnSysColourChanged
@@ -4412,11 +4412,11 @@ void wxWindowOS2::MoveChildren(
{ {
SWP vSwp; SWP vSwp;
for (wxWindowList::Node* pNode = GetChildren().GetFirst(); for (wxWindowList::compatibility_iterator node = GetChildren().GetFirst();
pNode; node;
pNode = pNode->GetNext()) node = node->GetNext())
{ {
wxWindow* pWin = pNode->GetData(); wxWindow* pWin = node->GetData();
::WinQueryWindowPos( GetHwndOf(pWin) ::WinQueryWindowPos( GetHwndOf(pWin)
,&vSwp ,&vSwp
@@ -5311,7 +5311,7 @@ wxWindowOS2* FindWindowForMouseEvent(
if (pWinUnderMouse) if (pWinUnderMouse)
{ {
wxWindowList::Node* pCurrent = pWinUnderMouse->GetChildren().GetFirst(); wxWindowList::compatibility_iterator current = pWinUnderMouse->GetChildren().GetFirst();
wxWindow* pGrandChild = NULL; wxWindow* pGrandChild = NULL;
RECTL vRect; RECTL vRect;
POINTL vPoint2; POINTL vPoint2;
@@ -5320,9 +5320,9 @@ wxWindowOS2* FindWindowForMouseEvent(
// //
// Find a child window mouse might be under // Find a child window mouse might be under
// //
while (pCurrent) while (current)
{ {
wxWindow* pChild = pCurrent->GetData(); wxWindow* pChild = current->GetData();
vPoint2.x = vPoint.x; vPoint2.x = vPoint.x;
vPoint2.y = vPoint.y; vPoint2.y = vPoint.y;
@@ -5333,11 +5333,11 @@ wxWindowOS2* FindWindowForMouseEvent(
if (pChild->IsTopLevel()) if (pChild->IsTopLevel())
{ {
POINTL vPoint3; POINTL vPoint3;
wxWindowList::Node* pCurrent2 =pChild->GetChildren().GetFirst(); wxWindowList::compatibility_iterator current2 =pChild->GetChildren().GetFirst();
while (pCurrent2) while (current2)
{ {
wxWindow* pGrandChild = pCurrent2->GetData(); wxWindow* pGrandChild = current2->GetData();
vPoint3.x = vPoint2.x; vPoint3.x = vPoint2.x;
vPoint3.y = vPoint2.y; vPoint3.y = vPoint2.y;
@@ -5353,7 +5353,7 @@ wxWindowOS2* FindWindowForMouseEvent(
pWinUnderMouse = pGrandChild; pWinUnderMouse = pGrandChild;
break; break;
} }
pCurrent2 = pCurrent2->GetNext(); current2 = current2->GetNext();
} }
if (pGrandChild) if (pGrandChild)
break; break;
@@ -5365,7 +5365,7 @@ wxWindowOS2* FindWindowForMouseEvent(
if (rcVisible && rcEnabled) if (rcVisible && rcEnabled)
break; break;
} }
pCurrent = pCurrent->GetNext(); current = current->GetNext();
} }
} }
} }