wxTopLevelWindows is now a wxWindowList, better compatibility with the old

wxList in list.h


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2005 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
1999-03-30 09:43:29 +00:00
parent 8ffd43c56b
commit e146b8c8bf
22 changed files with 206 additions and 185 deletions

View File

@@ -30,7 +30,7 @@
//-----------------------------------------------------------------------------
extern const char *wxFrameNameStr;
extern wxList wxTopLevelWindows;
extern wxWindowList wxTopLevelWindows;
//-----------------------------------------------------------------------------
// global function

View File

@@ -30,7 +30,7 @@
//-----------------------------------------------------------------------------
extern const char *wxFrameNameStr;
extern wxList wxTopLevelWindows;
extern wxWindowList wxTopLevelWindows;
//-----------------------------------------------------------------------------
// global function

View File

@@ -216,6 +216,13 @@ public:
void SetKeyType(wxKeyType keyType)
{ wxASSERT( m_count==0 ); m_keyType = keyType; }
#ifdef wxLIST_COMPATIBILITY
int Number() const { return GetCount(); }
wxNode *First() const { return (wxNode *)GetFirst(); }
wxNode *Last() const { return (wxNode *)GetLast(); }
wxNode *Nth(size_t index) const { return (wxNode *)Item(index); }
#endif // wxLIST_COMPATIBILITY
protected:
// all methods here are "overloaded" in derived classes to provide compile
@@ -433,11 +440,17 @@ private:
// #include <wx/listimpl.cpp>
#define WX_DEFINE_LIST(name) "don't forget to include listimpl.cpp!"
// =============================================================================
// now we can define classes 100% compatible with the old ones
// =============================================================================
// ----------------------------------------------------------------------------
// commonly used string classes
// ----------------------------------------------------------------------------
class wxWindow;
WX_DECLARE_LIST(wxWindow, wxWindowList);
#ifdef wxLIST_COMPATIBILITY
// -----------------------------------------------------------------------------
@@ -454,10 +467,6 @@ public:
// compatibility methods
void Sort(wxSortCompareFunction compfunc) { wxListBase::Sort(compfunc); }
int Number() const { return GetCount(); }
wxNode *First() const { return (wxNode *)GetFirst(); }
wxNode *Last() const { return (wxNode *)GetLast(); }
wxNode *Nth(size_t index) const { return (wxNode *)Item(index); }
wxNode *Member(wxObject *object) const { return (wxNode *)Find(object); }
};
@@ -494,12 +503,6 @@ public:
// alphabetic sort
void Sort();
// compatibility methods
int Number() const { return GetCount(); }
wxNode *First() const { return (wxNode *)GetFirst(); }
wxNode *Last() const { return (wxNode *)GetLast(); }
wxNode *Nth(size_t index) const { return (wxNode *)Item(index); }
private:
void DoCopy(const wxStringList&); // common part of copy ctor and operator=
};

View File

@@ -757,7 +757,7 @@ inline int wxWindow::GetReturnCode() { return m_returnCode; }
// Get the active window.
wxWindow* WXDLLEXPORT wxGetActiveWindow();
WXDLLEXPORT_DATA(extern wxList) wxTopLevelWindows;
WXDLLEXPORT_DATA(extern wxWindowList) wxTopLevelWindows;
// A little class to switch off size optimization while an instance of the object
// exists

View File

@@ -874,7 +874,7 @@ inline bool wxWindow::IsBeingDeleted() { return m_isBeingDeleted; }
// Window specific (so far)
WXDLLEXPORT wxWindow* wxGetActiveWindow();
WXDLLEXPORT_DATA(extern wxList) wxTopLevelWindows;
WXDLLEXPORT_DATA(extern wxWindowList) wxTopLevelWindows;
WXDLLEXPORT int wxCharCodeMSWToWX(int keySym);
WXDLLEXPORT int wxCharCodeWXToMSW(int id, bool *IsVirtual);

View File

@@ -37,6 +37,13 @@
#include "wx/utils.h" // for copystring() (beurk...)
#endif
// -----------------------------------------------------------------------------
// implementation of standard lists
// -----------------------------------------------------------------------------
#include "wx/listimpl.cpp"
WX_DEFINE_LIST(wxWindowList);
// =============================================================================
// implementation
// =============================================================================
@@ -634,4 +641,3 @@ void wxStringList::Sort()
delete [] array;
}

View File

@@ -73,6 +73,13 @@
extern char *wxBuffer;
// ----------------------------------------------------------------------------
// private functions
// ----------------------------------------------------------------------------
static wxWindow *wxFindWindowByLabel1(const wxString& title, wxWindow * parent);
static wxWindow *wxFindWindowByName1 (const wxString& title, wxWindow * parent);
#ifdef __WXMAC__
int strcasecmp(const char *str_1, const char *str_2)
{
@@ -418,8 +425,6 @@ wxString wxStripMenuCodes(const wxString& str)
*
*/
static wxWindow *wxFindWindowByLabel1 (const wxString& title, wxWindow * parent);
wxWindow *
wxFindWindowByLabel (const wxString& title, wxWindow * parent)
{
@@ -429,9 +434,11 @@ wxFindWindowByLabel (const wxString& title, wxWindow * parent)
}
else
{
for (wxNode * node = wxTopLevelWindows.First (); node; node = node->Next ())
for ( wxWindowList::Node * node = wxTopLevelWindows.GetFirst();
node;
node = node->GetNext() )
{
wxWindow *win = (wxWindow *) node->Data ();
wxWindow *win = node->GetData();
wxWindow *retwin = wxFindWindowByLabel1 (title, win);
if (retwin)
return retwin;
@@ -453,18 +460,19 @@ wxFindWindowByLabel1 (const wxString& title, wxWindow * parent)
if (parent)
{
for (wxNode * node = parent->GetChildren().First (); node; node = node->Next ())
for ( wxNode * node = parent->GetChildren().GetFirst();
node;
node = node->GetNext() )
{
wxWindow *win = (wxWindow *) node->Data ();
wxWindow *win = (wxWindow *)node->GetData();
wxWindow *retwin = wxFindWindowByLabel1 (title, win);
if (retwin)
return retwin;
} // for()
}
}
return (wxWindow *) NULL; // Not found
}
/*
@@ -473,8 +481,6 @@ wxFindWindowByLabel1 (const wxString& title, wxWindow * parent)
*
*/
static wxWindow *wxFindWindowByName1 (const wxString& title, wxWindow * parent);
wxWindow *
wxFindWindowByName (const wxString& title, wxWindow * parent)
{
@@ -484,15 +490,18 @@ wxFindWindowByName (const wxString& title, wxWindow * parent)
}
else
{
for (wxNode * node = wxTopLevelWindows.First (); node; node = node->Next ())
for ( wxWindowList::Node * node = wxTopLevelWindows.GetFirst();
node;
node = node->GetNext() )
{
wxWindow *win = (wxWindow *) node->Data ();
wxWindow *win = node->GetData();
wxWindow *retwin = wxFindWindowByName1 (title, win);
if (retwin)
return retwin;
} // for()
}
}
// Failed? Try by label instead.
return wxFindWindowByLabel(title, parent);
}
@@ -730,20 +739,22 @@ whereami(name)
// Yield to other apps/messages and disable user input
bool wxSafeYield(wxWindow *win)
{
wxNode *node;
for ( node = wxTopLevelWindows.GetFirst();
node;
node = node->GetNext() )
((wxWindow*)node->GetData())->Enable(FALSE);
wxWindowList::Node *node;
for ( node = wxTopLevelWindows.GetFirst(); node; node = node->GetNext() )
{
node->GetData()->Enable(FALSE);
}
// always enable ourselves
if(win) win->Enable(true);
if ( win )
win->Enable(TRUE);
bool rc = wxYield();
for ( node = wxTopLevelWindows.GetFirst();
node;
node = node->GetNext() )
((wxWindow*)node->GetData())->Enable(TRUE);
for ( node = wxTopLevelWindows.GetFirst(); node; node = node->GetNext() )
{
node->GetData()->Enable(TRUE);
}
return rc;
}

View File

@@ -140,11 +140,11 @@ bool wxYield()
// it's necessary to call ProcessIdle() to update the frames sizes which
// might have been changed (it also will update other things set from
// OnUpdateUI() which is a nice (and desired) side effect)
for ( wxNode *node = wxTopLevelWindows.GetFirst();
for ( wxWindowList::Node *node = wxTopLevelWindows.GetFirst();
node;
node = node->GetNext() )
{
wxWindow *win = ((wxWindow*)node->GetData());
wxWindow *win = node->GetData();
win->OnInternalIdle();
}
@@ -312,14 +312,15 @@ bool wxApp::SendIdleEvents()
{
bool needMore = FALSE;
wxNode* node = wxTopLevelWindows.First();
wxWindowList::Node* node = wxTopLevelWindows.GetFirst();
while (node)
{
wxWindow* win = (wxWindow*) node->Data();
wxWindow* win = node->GetData();
if (SendIdleEvents(win))
needMore = TRUE;
node = node->Next();
node = node->GetNext();
}
return needMore;
}
@@ -411,10 +412,12 @@ void wxApp::DeletePendingObjects()
wxWindow *wxApp::GetTopWindow()
{
if (m_topWindow) return m_topWindow;
wxNode *node = wxTopLevelWindows.First();
if (!node) return (wxWindow *) NULL;
return (wxWindow*)node->Data();
if (m_topWindow)
return m_topWindow;
else if (wxTopLevelWindows.GetCount() > 0)
return wxTopLevelWindows.GetFirst()->GetData();
else
return NULL;
}
void wxApp::SetTopWindow( wxWindow *win )
@@ -565,7 +568,7 @@ int wxEntry( int argc, char *argv[] )
if (!wxTheApp->OnInit())
return 0;
wxTheApp->m_initialized = (wxTopLevelWindows.Number() > 0);
wxTheApp->m_initialized = wxTopLevelWindows.GetCount() != 0;
int retValue = 0;

View File

@@ -33,7 +33,7 @@ XrmDatabase wxResourceDatabase;
char *wxBuffer = (char *) NULL;
/* Windows List */
wxList wxTopLevelWindows;
wxWindowList wxTopLevelWindows;
/* List of windows pending deletion */
wxList wxPendingDelete;

View File

@@ -36,7 +36,6 @@ const int wxSTATUS_HEIGHT = 25;
// data
//-----------------------------------------------------------------------------
extern wxList wxTopLevelWindows;
extern wxList wxPendingDelete;
//-----------------------------------------------------------------------------

View File

@@ -171,7 +171,6 @@ void debug_focus_in( GtkWidget* widget, const char* name, const char *window )
//-----------------------------------------------------------------------------
extern wxList wxPendingDelete;
extern wxList wxTopLevelWindows;
extern bool g_blockEventsOnDrag;
extern bool g_blockEventsOnScroll;
static bool g_capturing = FALSE;

View File

@@ -140,11 +140,11 @@ bool wxYield()
// it's necessary to call ProcessIdle() to update the frames sizes which
// might have been changed (it also will update other things set from
// OnUpdateUI() which is a nice (and desired) side effect)
for ( wxNode *node = wxTopLevelWindows.GetFirst();
for ( wxWindowList::Node *node = wxTopLevelWindows.GetFirst();
node;
node = node->GetNext() )
{
wxWindow *win = ((wxWindow*)node->GetData());
wxWindow *win = node->GetData();
win->OnInternalIdle();
}
@@ -312,14 +312,15 @@ bool wxApp::SendIdleEvents()
{
bool needMore = FALSE;
wxNode* node = wxTopLevelWindows.First();
wxWindowList::Node* node = wxTopLevelWindows.GetFirst();
while (node)
{
wxWindow* win = (wxWindow*) node->Data();
wxWindow* win = node->GetData();
if (SendIdleEvents(win))
needMore = TRUE;
node = node->Next();
node = node->GetNext();
}
return needMore;
}
@@ -411,10 +412,12 @@ void wxApp::DeletePendingObjects()
wxWindow *wxApp::GetTopWindow()
{
if (m_topWindow) return m_topWindow;
wxNode *node = wxTopLevelWindows.First();
if (!node) return (wxWindow *) NULL;
return (wxWindow*)node->Data();
if (m_topWindow)
return m_topWindow;
else if (wxTopLevelWindows.GetCount() > 0)
return wxTopLevelWindows.GetFirst()->GetData();
else
return NULL;
}
void wxApp::SetTopWindow( wxWindow *win )
@@ -565,7 +568,7 @@ int wxEntry( int argc, char *argv[] )
if (!wxTheApp->OnInit())
return 0;
wxTheApp->m_initialized = (wxTopLevelWindows.Number() > 0);
wxTheApp->m_initialized = wxTopLevelWindows.GetCount() != 0;
int retValue = 0;

View File

@@ -33,7 +33,7 @@ XrmDatabase wxResourceDatabase;
char *wxBuffer = (char *) NULL;
/* Windows List */
wxList wxTopLevelWindows;
wxWindowList wxTopLevelWindows;
/* List of windows pending deletion */
wxList wxPendingDelete;

View File

@@ -36,7 +36,6 @@ const int wxSTATUS_HEIGHT = 25;
// data
//-----------------------------------------------------------------------------
extern wxList wxTopLevelWindows;
extern wxList wxPendingDelete;
//-----------------------------------------------------------------------------

View File

@@ -171,7 +171,6 @@ void debug_focus_in( GtkWidget* widget, const char* name, const char *window )
//-----------------------------------------------------------------------------
extern wxList wxPendingDelete;
extern wxList wxTopLevelWindows;
extern bool g_blockEventsOnDrag;
extern bool g_blockEventsOnScroll;
static bool g_capturing = FALSE;

View File

@@ -211,9 +211,8 @@ int wxEntry( int argc, char *argv[] )
// GUI-specific initialization, such as creating an app context.
wxTheApp->OnInitGui();
// Here frames insert themselves automatically
// into wxTopLevelWindows by getting created
// in OnInit().
// Here frames insert themselves automatically into wxTopLevelWindows by
// getting created in OnInit().
int retValue = 0;
if (wxTheApp->OnInit())
@@ -438,15 +437,16 @@ void wxApp::OnIdle(wxIdleEvent& event)
bool wxApp::SendIdleEvents()
{
bool needMore = FALSE;
wxNode* node = wxTopLevelWindows.First();
wxWindowList::Node* node = wxTopLevelWindows.GetFirst();
while (node)
{
wxWindow* win = (wxWindow*) node->Data();
wxWindow* win = node->GetData();
if (SendIdleEvents(win))
needMore = TRUE;
node = node->Next();
node = node->GetNext();
}
return needMore;
}
@@ -519,8 +519,8 @@ wxWindow* wxApp::GetTopWindow() const
{
if (m_topWindow)
return m_topWindow;
else if (wxTopLevelWindows.Number() > 0)
return (wxWindow*) wxTopLevelWindows.First()->Data();
else if (wxTopLevelWindows.GetCount() > 0)
return wxTopLevelWindows.GetFirst()->GetData();
else
return NULL;
}

View File

@@ -22,7 +22,7 @@
char *wxBuffer = NULL;
// Windows List
wxList wxTopLevelWindows;
wxWindowList wxTopLevelWindows;
// List of windows pending deletion
wxList wxPendingDelete;

View File

@@ -22,6 +22,7 @@
#include "wx/app.h"
#include "wx/msgdlg.h"
#include "wx/cursor.h"
#include "wx/window.h" // for wxTopLevelWindows
#include <ctype.h>
#include <stdarg.h>
@@ -60,8 +61,6 @@
static char *GetIniFile (char *dest, const char *filename);
extern wxList wxTopLevelWindows;
// ============================================================================
// implementation
// ============================================================================

View File

@@ -1016,14 +1016,14 @@ void wxApp::OnIdle(wxIdleEvent& event)
bool wxApp::SendIdleEvents()
{
bool needMore = FALSE;
wxNode* node = wxTopLevelWindows.First();
wxWindowList::Node* node = wxTopLevelWindows.First();
while (node)
{
wxWindow* win = (wxWindow*) node->Data();
wxWindow* win = node->GetData();
if (SendIdleEvents(win))
needMore = TRUE;
node = node->Next();
node = node->GetNext();
}
return needMore;
@@ -1097,8 +1097,8 @@ wxWindow* wxApp::GetTopWindow() const
{
if (m_topWindow)
return m_topWindow;
else if (wxTopLevelWindows.Number() > 0)
return (wxWindow*) wxTopLevelWindows.First()->Data();
else if (wxTopLevelWindows.GetCount() > 0)
return wxTopLevelWindows.GetFirst()->GetData();
else
return NULL;
}

View File

@@ -32,7 +32,7 @@
char *wxBuffer = NULL;
// Windows List
wxList wxTopLevelWindows;
wxWindowList wxTopLevelWindows;
// List of windows pending deletion
wxList WXDLLEXPORT wxPendingDelete;