From 6164f93ca283074f4a0209ede0bc3fef3c68d996 Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin <vadim@wxwidgets.org>
Date: Wed, 31 Jan 2001 16:00:00 +0000
Subject: [PATCH] event handling seems to work again, new sample (event) added
 and documented

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@9242 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---
 configure                  |   7 +-
 configure.in               |   5 +-
 docs/latex/wx/tsamples.tex |  12 +
 include/wx/event.h         |  95 ++++--
 samples/configure          |   2 +
 samples/configure.in       |   1 +
 samples/event/Makefile.in  |  13 +
 samples/event/event.cpp    | 321 +++++++++++++++++++
 samples/event/makefile.b32 |  10 +
 samples/event/makefile.bcc |  14 +
 samples/event/makefile.dos |  10 +
 samples/event/makefile.g95 |  10 +
 samples/event/makefile.sc  |  37 +++
 samples/event/makefile.sl  |  14 +
 samples/event/makefile.twn |  35 +++
 samples/event/makefile.unx |  23 ++
 samples/event/makefile.vc  |  11 +
 samples/event/makefile.wat |  11 +
 src/common/event.cpp       | 609 +++++++++++--------------------------
 19 files changed, 785 insertions(+), 455 deletions(-)
 create mode 100644 samples/event/Makefile.in
 create mode 100644 samples/event/event.cpp
 create mode 100644 samples/event/makefile.b32
 create mode 100644 samples/event/makefile.bcc
 create mode 100644 samples/event/makefile.dos
 create mode 100644 samples/event/makefile.g95
 create mode 100644 samples/event/makefile.sc
 create mode 100644 samples/event/makefile.sl
 create mode 100644 samples/event/makefile.twn
 create mode 100644 samples/event/makefile.unx
 create mode 100644 samples/event/makefile.vc
 create mode 100644 samples/event/makefile.wat

diff --git a/configure b/configure
index 7ae4bee379..815e55bca5 100755
--- a/configure
+++ b/configure
@@ -15012,8 +15012,9 @@ LDFLAGS="$LDFLAGS $PROFILE"
 
 if test "$wxUSE_GUI" = "yes"; then
         
-            SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS controls dialogs dragimag drawing dynamic \
-                     font fractal image menu minimal richedit"
+            SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS controls dialogs dragimag \
+                     drawing dynamic event font fractal image menu \
+                     minimal richedit"
 
         CPPFLAGS="$CPPFLAGS \$(EXTRADEFS) \$(APPEXTRADEFS)"
 else
@@ -15117,7 +15118,7 @@ SAMPLES_SUBDIRS="`echo $SAMPLES_SUBDIRS | tr -s ' ' | tr ' ' '\n' | sort | uniq
 
 
 echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
-echo "configure:15121: checking whether ${MAKE-make} sets \${MAKE}" >&5
+echo "configure:15122: checking whether ${MAKE-make} sets \${MAKE}" >&5
 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
diff --git a/configure.in b/configure.in
index d183055305..264c0c5823 100644
--- a/configure.in
+++ b/configure.in
@@ -3797,8 +3797,9 @@ if test "$wxUSE_GUI" = "yes"; then
 
     dnl TODO some samples are never built so far:
     dnl      ipc, mfc, nativdlg, oleauto, ownerdrw, proplist
-    SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS controls dialogs dragimag drawing dynamic \
-                     font fractal image menu minimal richedit"
+    SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS controls dialogs dragimag \
+                     drawing dynamic event font fractal image menu \
+                     minimal richedit"
 
     dnl this is needed to be able to find AFM files
     CPPFLAGS="$CPPFLAGS \$(EXTRADEFS) \$(APPEXTRADEFS)"
diff --git a/docs/latex/wx/tsamples.tex b/docs/latex/wx/tsamples.tex
index 6c448dc45c..2db061b5c2 100644
--- a/docs/latex/wx/tsamples.tex
+++ b/docs/latex/wx/tsamples.tex
@@ -144,6 +144,18 @@ a dialog or frame. This is most typically the case for any scripting
 language that would work as a wrapper for wxWindows or programs where
 forms or similar datagrams can be created by the uses.
 
+See also the \helpref{event sample}{sampleevent}
+
+\subsection{Event sample}\label{sampleevent}
+
+The event sample demonstrates various features of the wxWindows events. It
+shows using dynamic events and connecting/disconnecting the event handlers
+during the run time and also using 
+\helpref{PushEventHandler()}{wxwindowpusheventhandler} and
+\helpref{PopEventHandler()}{wxwindowpopeventhandler}.
+
+It replaces the old dynamic sample.
+
 \subsection{Exec sample}\label{sampleexec}
 
 The exec sample demonstrates the \helpref{wxExecute}{wxexecute} and 
diff --git a/include/wx/event.h b/include/wx/event.h
index fc61c50906..df4641fa56 100644
--- a/include/wx/event.h
+++ b/include/wx/event.h
@@ -91,8 +91,11 @@ enum
     wxEVT_NULL = 0,
     wxEVT_FIRST = 10000,
 #else // !WXWIN_COMPATIBILITY_EVENT_TYPES
-    extern wxEventType wxEVT_NULL;
-    extern wxEventType wxEVT_FIRST;
+    // it is important to still have these as constants to avoid
+    // initialization order related problems
+    const wxEventType wxEVT_NULL = 0;
+    const wxEventType wxEVT_FIRST = 10000;
+    const wxEventType wxEVT_USER_FIRST = wxEVT_FIRST + 2000;
 #endif // WXWIN_COMPATIBILITY_EVENT_TYPES/!WXWIN_COMPATIBILITY_EVENT_TYPES
 
 DECLARE_EVENT_TYPE(wxEVT_COMMAND_BUTTON_CLICKED, 1)
@@ -312,8 +315,6 @@ DECLARE_EVENT_TYPE(wxEVT_CALENDAR_WEEKDAY_CLICKED, 955)
 DECLARE_EVENT_TYPE(wxEVT_HELP, 1050)
 DECLARE_EVENT_TYPE(wxEVT_DETAILED_HELP, 1051)
 
-DECLARE_EVENT_TYPE(wxEVT_USER_FIRST, 2000)
-
 #if WXWIN_COMPATIBILITY_EVENT_TYPES
 };
 #endif // WXWIN_COMPATIBILITY_EVENT_TYPES
@@ -1507,31 +1508,76 @@ protected:
 
 typedef void (wxObject::*wxObjectEventFunction)(wxEvent&);
 
-struct WXDLLEXPORT wxEventTableEntry
+// struct containing the members common to static and dynamic event tables
+// entries
+struct WXDLLEXPORT wxEventTableEntryBase
 {
-#if !WXWIN_COMPATIBILITY_EVENT_TYPES
-    wxEventTableEntry(int evType, int id, int idLast,
-                      wxObjectEventFunction fn, wxObject *data);
-#endif // !WXWIN_COMPATIBILITY_EVENT_TYPES
+    // provide default ctors for everything in backwards compatibility mode
+#if WXWIN_COMPATIBILITY_EVENT_TYPES
+    wxEventTableEntryBase() { }
+#else // !WXWIN_COMPATIBILITY_EVENT_TYPES
+    wxEventTableEntryBase(int id, int idLast,
+                          wxObjectEventFunction fn, wxObject *data)
+    {
+        m_id = id;
+        m_lastId = idLast;
+        m_fn = fn;
+        m_callbackUserData = data;
+    }
+#endif // WXWIN_COMPATIBILITY_EVENT_TYPES/!WXWIN_COMPATIBILITY_EVENT_TYPES
+
+    // the range of ids for this entry: if m_lastId == -1, the range consists
+    // only of m_id, otherwise it is m_id..m_lastId inclusive
+    int m_id, m_lastId;
 
-    int m_eventType;            // the event type
-    int m_id;                   // control/menu/toolbar id
-    int m_lastId;               // used for ranges of ids
-    wxObjectEventFunction m_fn; // function to call: not wxEventFunction,
-                                // because of dependency problems
+    // function to call: not wxEventFunction, because of dependency problems
+    wxObjectEventFunction m_fn;
 
+    // arbitrary user data asosciated with the callback
     wxObject* m_callbackUserData;
 };
 
-struct WXDLLEXPORT wxDynamicEventTableEntry : public wxEventTableEntry
+// an entry from a static event table
+struct WXDLLEXPORT wxEventTableEntry : public wxEventTableEntryBase
 {
-#if !WXWIN_COMPATIBILITY_EVENT_TYPES
+#if WXWIN_COMPATIBILITY_EVENT_TYPES
+    wxEventTableEntry() { }
+#else // !WXWIN_COMPATIBILITY_EVENT_TYPES
+    wxEventTableEntry(const int& evType, int id, int idLast,
+                      wxObjectEventFunction fn, wxObject *data)
+                 : wxEventTableEntryBase(id, idLast, fn, data),
+                   m_eventType(evType)
+    {
+    }
+#endif // WXWIN_COMPATIBILITY_EVENT_TYPES/!WXWIN_COMPATIBILITY_EVENT_TYPES
+
+    // the reference to event type: this allows us to not care about the
+    // (undefined) order in which the event table entries and the event types
+    // are initialized: initially the value of this reference might be
+    // invalid, but by the time it is used for the first time, all global
+    // objects will have been initialized (including the event type constants)
+    // and so it will have the correct value when it is needed
+    const int& m_eventType;
+};
+
+// an entry used in dynamic event table managed by wxEvtHandler::Connect()
+struct WXDLLEXPORT wxDynamicEventTableEntry : public wxEventTableEntryBase
+{
+#if WXWIN_COMPATIBILITY_EVENT_TYPES
+    wxDynamicEventTableEntry() { }
+#else // !WXWIN_COMPATIBILITY_EVENT_TYPES
     wxDynamicEventTableEntry(int evType, int id, int idLast,
                              wxObjectEventFunction fn, wxObject *data)
-        : wxEventTableEntry(evType, id, idLast, fn, data)
+        : wxEventTableEntryBase(id, idLast, fn, data)
     {
+        m_eventType = evType;
     }
-#endif // !WXWIN_COMPATIBILITY_EVENT_TYPES
+#endif // WXWIN_COMPATIBILITY_EVENT_TYPES/!WXWIN_COMPATIBILITY_EVENT_TYPES
+
+    // not a reference here as we can't keep a reference to a temporary int
+    // created to wrap the constant value typically passed to Connect() - nor
+    // do we need it
+    int m_eventType;
 };
 
 struct WXDLLEXPORT wxEventTable
@@ -1540,13 +1586,15 @@ struct WXDLLEXPORT wxEventTable
     const wxEventTableEntry *entries; // bottom of entry array
 };
 
+// ----------------------------------------------------------------------------
+// wxEvtHandler: the base class for all objects handling wxWindows events
+// ----------------------------------------------------------------------------
+
 class WXDLLEXPORT wxEvtHandler : public wxObject
 {
-    DECLARE_DYNAMIC_CLASS(wxEvtHandler)
-
 public:
     wxEvtHandler();
-    ~wxEvtHandler();
+    virtual ~wxEvtHandler();
 
     wxEvtHandler *GetNextHandler() const { return m_nextHandler; }
     wxEvtHandler *GetPreviousHandler() const { return m_previousHandler; }
@@ -1632,11 +1680,11 @@ protected:
 
     virtual const wxEventTable *GetEventTable() const;
 
-protected:
     wxEvtHandler*       m_nextHandler;
     wxEvtHandler*       m_previousHandler;
     wxList*             m_dynamicEvents;
     wxList*             m_pendingEvents;
+
 #if wxUSE_THREADS
 #if defined (__VISAGECPP__)
     wxCriticalSection   m_eventsLocker;
@@ -1651,6 +1699,9 @@ protected:
 
     // Is event handler enabled?
     bool                m_enabled;
+
+private:
+    DECLARE_DYNAMIC_CLASS(wxEvtHandler)
 };
 
 typedef void (wxEvtHandler::*wxEventFunction)(wxEvent&);
diff --git a/samples/configure b/samples/configure
index 0d057c1e6c..c5e4d1bb65 100755
--- a/samples/configure
+++ b/samples/configure
@@ -663,6 +663,7 @@ trap 'rm -fr `echo "
             dragimag/Makefile
             drawing/Makefile
             dynamic/Makefile
+            event/Makefile
             exec/Makefile
             font/Makefile
             grid/Makefile
@@ -807,6 +808,7 @@ CONFIG_FILES=\${CONFIG_FILES-"Makefile
             dragimag/Makefile
             drawing/Makefile
             dynamic/Makefile
+            event/Makefile
             exec/Makefile
             font/Makefile
             grid/Makefile
diff --git a/samples/configure.in b/samples/configure.in
index c257f52edc..191f945f1e 100644
--- a/samples/configure.in
+++ b/samples/configure.in
@@ -31,6 +31,7 @@ AC_OUTPUT([
             dragimag/Makefile
             drawing/Makefile
             dynamic/Makefile
+            event/Makefile
             exec/Makefile
             font/Makefile
             grid/Makefile
diff --git a/samples/event/Makefile.in b/samples/event/Makefile.in
new file mode 100644
index 0000000000..fdec4551b3
--- /dev/null
+++ b/samples/event/Makefile.in
@@ -0,0 +1,13 @@
+# Purpose: makefile for event example (UNIX).
+# Created: 2001-01-31
+
+top_srcdir = @top_srcdir@/..
+top_builddir = ../..
+program_dir = samples/event
+
+PROGRAM=event
+
+OBJECTS=$(PROGRAM).o
+
+include ../../src/makeprog.env
+
diff --git a/samples/event/event.cpp b/samples/event/event.cpp
new file mode 100644
index 0000000000..15895cf038
--- /dev/null
+++ b/samples/event/event.cpp
@@ -0,0 +1,321 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        event.cpp
+// Purpose:     wxWindows sample demonstrating different event usage
+// Author:      Vadim Zeitlin
+// Modified by:
+// Created:     31.01.01
+// RCS-ID:      $Id$
+// Copyright:   (c) 2001 Vadim Zeitlin
+// Licence:     wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+// ============================================================================
+// declarations
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// headers
+// ----------------------------------------------------------------------------
+
+#ifdef __GNUG__
+    // DO NOT use event.cpp here, it breaks statics initialization in
+    // src/common/event.cpp and nothing works at all then!
+    #pragma implementation "eventsample.cpp"
+    #pragma interface "eventsample.cpp"
+#endif
+
+// For compilers that support precompilation, includes "wx/wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+    #pragma hdrstop
+#endif
+
+// for all others, include the necessary headers (this file is usually all you
+// need because it includes almost all "standard" wxWindows headers)
+#ifndef WX_PRECOMP
+    #include "wx/wx.h"
+#endif
+
+// ----------------------------------------------------------------------------
+// private classes
+// ----------------------------------------------------------------------------
+
+// Define a new application type, each program should derive a class from wxApp
+class MyApp : public wxApp
+{
+public:
+    // override base class virtuals
+    // ----------------------------
+
+    // this one is called on application startup and is a good place for the app
+    // initialization (doing it here and not in the ctor allows to have an error
+    // return: if OnInit() returns false, the application terminates)
+    virtual bool OnInit();
+};
+
+// Define a new frame type: this is going to be our main frame
+class MyFrame : public wxFrame
+{
+public:
+    // ctor(s)
+    MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size);
+    virtual ~MyFrame();
+
+    void OnQuit(wxCommandEvent& event);
+    void OnAbout(wxCommandEvent& event);
+    void OnConnect(wxCommandEvent& event);
+    void OnDynamic(wxCommandEvent& event);
+    void OnPushEventHandler(wxCommandEvent& event);
+    void OnPopEventHandler(wxCommandEvent& event);
+    void OnTest(wxCommandEvent& event);
+
+    void OnUpdateUIPop(wxUpdateUIEvent& event);
+
+protected:
+    // number of pushed event handlers
+    size_t m_nPush;
+
+private:
+    // any class wishing to process wxWindows events must use this macro
+    DECLARE_EVENT_TABLE()
+};
+
+// Define a custom event handler
+class MyEvtHandler : public wxEvtHandler
+{
+public:
+    MyEvtHandler(size_t level) { m_level = level; }
+
+    void OnTest(wxCommandEvent& event)
+    {
+        wxLogMessage(_T("This is the pushed test event handler #%u"), m_level);
+
+        // if we don't skip the event, the other event handlers won't get it:
+        // try commenting out this line and see what changes
+        event.Skip();
+    }
+
+private:
+    size_t m_level;
+
+    DECLARE_EVENT_TABLE()
+};
+
+// ----------------------------------------------------------------------------
+// constants
+// ----------------------------------------------------------------------------
+
+// IDs for the controls and the menu commands
+enum
+{
+    // menu items
+    Event_Quit = 1,
+    Event_About,
+    Event_Connect,
+    Event_Dynamic,
+    Event_Push,
+    Event_Pop,
+    Event_Test
+};
+
+// status bar fields
+enum
+{
+    Status_Main = 0,
+    Status_Dynamic,
+    Status_Push
+};
+
+// ----------------------------------------------------------------------------
+// event tables and other macros for wxWindows
+// ----------------------------------------------------------------------------
+
+// the event tables connect the wxWindows events with the functions (event
+// handlers) which process them. It can be also done at run-time, but for the
+// simple menu events like this the static method is much simpler.
+BEGIN_EVENT_TABLE(MyFrame, wxFrame)
+    EVT_MENU(Event_Quit,  MyFrame::OnQuit)
+    EVT_MENU(Event_About, MyFrame::OnAbout)
+
+    EVT_MENU(Event_Connect, MyFrame::OnConnect)
+
+    EVT_MENU(Event_Test, MyFrame::OnTest)
+    EVT_MENU(Event_Push, MyFrame::OnPushEventHandler)
+    EVT_MENU(Event_Pop, MyFrame::OnPopEventHandler)
+
+    EVT_UPDATE_UI(Event_Pop, MyFrame::OnUpdateUIPop)
+END_EVENT_TABLE()
+
+BEGIN_EVENT_TABLE(MyEvtHandler, wxEvtHandler)
+    EVT_MENU(Event_Test, MyEvtHandler::OnTest)
+END_EVENT_TABLE()
+
+// Create a new application object: this macro will allow wxWindows to create
+// the application object during program execution (it's better than using a
+// static object for many reasons) and also declares the accessor function
+// wxGetApp() which will return the reference of the right type (i.e. MyApp and
+// not wxApp)
+IMPLEMENT_APP(MyApp)
+
+// ============================================================================
+// implementation
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// the application class
+// ----------------------------------------------------------------------------
+
+// 'Main program' equivalent: the program execution "starts" here
+bool MyApp::OnInit()
+{
+    // create the main application window
+    MyFrame *frame = new MyFrame("Event wxWindows Sample",
+                                 wxPoint(50, 50), wxSize(450, 340));
+
+    // and show it (the frames, unlike simple controls, are not shown when
+    // created initially)
+    frame->Show(TRUE);
+
+    // success: wxApp::OnRun() will be called which will enter the main message
+    // loop and the application will run. If we returned FALSE here, the
+    // application would exit immediately.
+    return TRUE;
+}
+
+// ----------------------------------------------------------------------------
+// main frame
+// ----------------------------------------------------------------------------
+
+// frame constructor
+MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
+       : wxFrame((wxFrame *)NULL, -1, title, pos, size)
+{
+    // create a menu bar
+    wxMenu *menuFile = new wxMenu;
+
+    menuFile->Append(Event_About, "&About...\tCtrl-A", "Show about dialog");
+    menuFile->AppendSeparator();
+    menuFile->Append(Event_Quit, "E&xit\tAlt-X", "Quit this program");
+
+    wxMenu *menuEvent = new wxMenu;
+    menuEvent->Append(Event_Connect, "&Connect\tCtrl-C",
+                     "Connect or disconnect the dynamic event handler",
+                     TRUE /* checkable */);
+    menuEvent->Append(Event_Dynamic, "&Dynamic event\tCtrl-D",
+                      "Dynamic event sample - only works after Connect");
+    menuEvent->AppendSeparator();
+    menuEvent->Append(Event_Push, "&Push event handler\tCtrl-P",
+                      "Push event handler for test event");
+    menuEvent->Append(Event_Pop, "P&op event handler\tCtrl-O",
+                      "Pop event handler for test event");
+    menuEvent->Append(Event_Test, "Test event\tCtrl-T",
+                      "Test event processed by pushed event handler");
+
+    // now append the freshly created menu to the menu bar...
+    wxMenuBar *menuBar = new wxMenuBar();
+    menuBar->Append(menuFile, "&File");
+    menuBar->Append(menuEvent, "&Event");
+
+    // ... and attach this menu bar to the frame
+    SetMenuBar(menuBar);
+
+#if wxUSE_STATUSBAR
+    CreateStatusBar(3);
+    SetStatusText("Welcome to wxWindows event sample");
+    SetStatusText(_T("Dynamic: off"), Status_Dynamic);
+    SetStatusText(_T("Push count: 0"), Status_Push);
+#endif // wxUSE_STATUSBAR
+}
+
+MyFrame::~MyFrame()
+{
+    // we must pop any remaining event handlers to avoid memory leaks and
+    // crashes!
+    while ( m_nPush-- != 0 )
+    {
+        PopEventHandler(TRUE /* delete handler */);
+    }
+}
+
+// ----------------------------------------------------------------------------
+// standard event handlers
+// ----------------------------------------------------------------------------
+
+void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
+{
+    // TRUE is to force the frame to close
+    Close(TRUE);
+}
+
+void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
+{
+    wxMessageBox(_T("Event sample shows different ways of using events\n"
+                    "© 2001 Vadim Zeitlin"),
+                 _T("About Event Sample"), wxOK | wxICON_INFORMATION, this);
+}
+
+// ----------------------------------------------------------------------------
+// dynamic event handling stuff
+// ----------------------------------------------------------------------------
+
+void MyFrame::OnDynamic(wxCommandEvent& WXUNUSED(event))
+{
+    wxMessageBox(_T("This is a dynamic event handler which can be connected "
+                    "and disconnected during run-time."),
+                 _T("Dynamic Event Handler"), wxOK | wxICON_INFORMATION, this);
+}
+
+void MyFrame::OnConnect(wxCommandEvent& event)
+{
+    if ( event.IsChecked() )
+    {
+        // disconnect
+        Connect(Event_Dynamic, -1, wxEVT_COMMAND_MENU_SELECTED,
+                (wxObjectEventFunction)
+                (wxEventFunction)
+                (wxCommandEventFunction)&MyFrame::OnDynamic);
+
+        SetStatusText(_T("You can now use \"Dynamic\" item in the menu"));
+        SetStatusText(_T("Dynamic: on"), Status_Dynamic);
+    }
+    else // connect
+    {
+        Disconnect(Event_Dynamic, -1, wxEVT_COMMAND_MENU_SELECTED);
+
+        SetStatusText(_T("You can no more use \"Dynamic\" item in the menu"));
+        SetStatusText(_T("Dynamic: off"), Status_Dynamic);
+    }
+}
+
+// ----------------------------------------------------------------------------
+// push/pop event handlers support
+// ----------------------------------------------------------------------------
+
+void MyFrame::OnPushEventHandler(wxCommandEvent& WXUNUSED(event))
+{
+    PushEventHandler(new MyEvtHandler(++m_nPush));
+
+    SetStatusText(wxString::Format(_T("Push count: %u"), m_nPush), Status_Push);
+}
+
+void MyFrame::OnPopEventHandler(wxCommandEvent& WXUNUSED(event))
+{
+    wxCHECK_RET( m_nPush, _T("this command should be disabled!") );
+
+    PopEventHandler(TRUE /* delete handler */);
+    m_nPush--;
+
+    SetStatusText(wxString::Format(_T("Push count: %u"), m_nPush), Status_Push);
+}
+
+void MyFrame::OnTest(wxCommandEvent& event)
+{
+    wxLogMessage(_T("This is the test event handler in the main frame"));
+}
+
+void MyFrame::OnUpdateUIPop(wxUpdateUIEvent& event)
+{
+    event.Enable( m_nPush > 0 );
+}
+
diff --git a/samples/event/makefile.b32 b/samples/event/makefile.b32
new file mode 100644
index 0000000000..b8a5b21535
--- /dev/null
+++ b/samples/event/makefile.b32
@@ -0,0 +1,10 @@
+# Purpose: makefile for event example (BC++ 32bit)
+# Created: 2001-01-31
+
+WXDIR = $(WXWIN)
+
+TARGET=event
+OBJECTS = $(TARGET).obj
+
+!include $(WXDIR)\src\makeprog.b32
+
diff --git a/samples/event/makefile.bcc b/samples/event/makefile.bcc
new file mode 100644
index 0000000000..6a9e6986dd
--- /dev/null
+++ b/samples/event/makefile.bcc
@@ -0,0 +1,14 @@
+# Purpose: makefile for event example (BC++ 16bit)
+# Created: 2001-01-31
+
+!if "$(WXWIN)" == ""
+!error You must define the WXWIN variable in autoexec.bat, e.g. WXWIN=c:\wx
+!endif
+
+WXDIR = $(WXWIN)
+
+TARGET=event
+OBJECTS=$(TARGET).obj
+
+!include $(WXDIR)\src\makeprog.bcc
+
diff --git a/samples/event/makefile.dos b/samples/event/makefile.dos
new file mode 100644
index 0000000000..5525138d28
--- /dev/null
+++ b/samples/event/makefile.dos
@@ -0,0 +1,10 @@
+# Purpose: makefile for event example (VC++ 1.5x)
+# Created: 2001-01-31
+
+WXDIR = $(WXWIN)
+
+TARGET=event
+OBJECTS=$(TARGET).obj
+
+!include $(WXDIR)\src\makeprog.msc
+
diff --git a/samples/event/makefile.g95 b/samples/event/makefile.g95
new file mode 100644
index 0000000000..7ba40b8ac4
--- /dev/null
+++ b/samples/event/makefile.g95
@@ -0,0 +1,10 @@
+# Purpose: makefile for event example (Cygwin/Mingw32)
+# Created: #03.01.00
+
+WXDIR = ../..
+
+TARGET=event
+OBJECTS = $(TARGET).o
+
+include $(WXDIR)/src/makeprog.g95
+
diff --git a/samples/event/makefile.sc b/samples/event/makefile.sc
new file mode 100644
index 0000000000..fb0aceb47d
--- /dev/null
+++ b/samples/event/makefile.sc
@@ -0,0 +1,37 @@
+# Purpose: makefile for event example (Symantec C++)
+# Created: 2001-01-31
+
+WXDIR = $(WXWIN)
+WXLIB = $(WXDIR)\lib\wx.lib
+INCDIR = $(WXDIR)\include
+INCLUDE=$(INCDIR)
+TARGET=event
+
+include $(WXDIR)\src\makesc.env
+
+event.exe: event.obj $(DEFFILE) event.res
+	*$(CC) $(LDFLAGS) -o$@ $** $(LIBS)
+    *$(RC) -k event.res
+
+sc32.def:
+     echo EXETYPE NT > sc32.def
+     echo SUBSYSTEM WINDOWS >> sc32.def
+
+sc16.def:
+     echo NAME $(TARGET) > sc16.def
+     echo EXETYPE WINDOWS >> sc16.def
+     echo STUB         'WINSTUB.EXE' >> sc16.def
+     echo CODE         PRELOAD MOVEABLE DISCARDABLE >> sc16.def
+     echo DATA         PRELOAD MOVEABLE MULTIPLE >> sc16.def
+     echo HEAPSIZE     1024 >> sc16.def
+     echo STACKSIZE    8192 >> sc16.def
+
+clean:
+    -del *.obj
+	-del *.exe
+	-del *.res
+	-del *.map
+	-del *.rws
+    -del sc32.def
+    -del sc16.def
+
diff --git a/samples/event/makefile.sl b/samples/event/makefile.sl
new file mode 100644
index 0000000000..3e0483c189
--- /dev/null
+++ b/samples/event/makefile.sl
@@ -0,0 +1,14 @@
+# Purpose: makefile for event example (Salford C++)
+# Created: 2001-01-31
+
+PROGRAM = event
+OBJECTS = $(PROGRAM).obj
+
+include ..\..\src\makeprog.sl
+
+all:        wx $(TARGET)
+
+wx:
+    cd $(WXDIR)\src\msw ^ mk32 -f makefile.sl all
+    cd $(WXDIR)\samples\event
+
diff --git a/samples/event/makefile.twn b/samples/event/makefile.twn
new file mode 100644
index 0000000000..0c192f6ae4
--- /dev/null
+++ b/samples/event/makefile.twn
@@ -0,0 +1,35 @@
+# Purpose: makefile for event example (TWIN)
+# Created: 2001-01-31
+
+WXDIR = ../..
+
+# All common UNIX compiler flags and options are now in
+# this central makefile.
+include $(WXDIR)/src/maketwin.env
+
+OBJECTS = $(OBJDIR)/event.$(OBJSUFF) $(OBJDIR)/event.$(OBJSUFF)
+
+all:    $(OBJDIR) event$(GUISUFFIX)$(EXESUFF)
+
+wx:
+
+$(OBJDIR):
+	mkdir $(OBJDIR)
+
+event$(GUISUFFIX)$(EXESUFF):	$(OBJECTS) $(WXLIB)
+	$(CC) $(LDFLAGS) -o event$(GUISUFFIX)$(EXESUFF) $(OBJECTS) $(LDLIBS)
+
+$(OBJDIR)/event.$(OBJSUFF):	event.$(SRCSUFF)
+	$(CC) -c $(CPPFLAGS) -o $@ event.$(SRCSUFF)
+
+event.c:  event.rc
+	$(RESCOMP) $(RCINPUTSWITCH) event.rc $(RCOUTPUTSWITCH) event.c $(RESFLAGS)
+
+$(OBJDIR)/event.$(OBJSUFF):	event.c
+	$(CC) -c $(CPPFLAGS) -o $@ event.c
+
+#$(OBJDIR)/event.o:  event.rc
+#	$(RESCOMP) $(RCINPUTSWITCH) event.rc $(RCOUTPUTSWITCH) $(OBJDIR)/event.o $(RESFLAGS)
+
+clean:
+	rm -f $(OBJECTS) event$(GUISUFFIX).exe core *.rsc *.res
diff --git a/samples/event/makefile.unx b/samples/event/makefile.unx
new file mode 100644
index 0000000000..f2e963d8ae
--- /dev/null
+++ b/samples/event/makefile.unx
@@ -0,0 +1,23 @@
+# Purpose: makefile for event example (Unix)
+# Created: 2001-01-31
+
+CC = gcc
+
+PROGRAM = event
+
+OBJECTS = $(PROGRAM).o
+
+# implementation
+
+.SUFFIXES:	.o .cpp
+
+.cpp.o :
+	$(CC) -c `wx-config --cflags` -o $@ $<
+
+all:    $(PROGRAM)
+
+$(PROGRAM):	$(OBJECTS)
+	$(CC) -o $(PROGRAM) $(OBJECTS) `wx-config --libs`
+
+clean:
+	rm -f *.o $(PROGRAM)
diff --git a/samples/event/makefile.vc b/samples/event/makefile.vc
new file mode 100644
index 0000000000..f3f15218dd
--- /dev/null
+++ b/samples/event/makefile.vc
@@ -0,0 +1,11 @@
+# Purpose: makefile for event example (VC++ 32bit)
+# Created: 2001-01-31
+
+# Set WXDIR for your system
+WXDIR = $(WXWIN)
+
+PROGRAM=event
+OBJECTS = $(PROGRAM).obj
+
+!include $(WXDIR)\src\makeprog.vc
+
diff --git a/samples/event/makefile.wat b/samples/event/makefile.wat
new file mode 100644
index 0000000000..bdd01b8093
--- /dev/null
+++ b/samples/event/makefile.wat
@@ -0,0 +1,11 @@
+# Purpose: makefile for event example (Watcom)
+# Created: 2001-01-31
+
+WXDIR = $(%WXWIN)
+
+PROGRAM = event
+OBJECTS = $(PROGRAM).obj
+
+!include $(WXDIR)\src\makeprog.wat
+
+
diff --git a/src/common/event.cpp b/src/common/event.cpp
index 3b7d95962d..0012b8b359 100644
--- a/src/common/event.cpp
+++ b/src/common/event.cpp
@@ -46,15 +46,6 @@
     #include "wx/validate.h"
 #endif // wxUSE_GUI
 
-// ----------------------------------------------------------------------------
-// event constants
-// ----------------------------------------------------------------------------
-
-#if !WXWIN_COMPATIBILITY_EVENT_TYPES
-    wxEventType wxEVT_NULL = 0;
-    wxEventType wxEVT_FIRST = 10000;
-#endif // !WXWIN_COMPATIBILITY_EVENT_TYPES
-
 // ----------------------------------------------------------------------------
 // wxWin macros
 // ----------------------------------------------------------------------------
@@ -117,212 +108,218 @@ wxList *wxPendingEvents = (wxList *)NULL;
 
 #if !WXWIN_COMPATIBILITY_EVENT_TYPES
 
-wxEventType wxEVT_COMMAND_BUTTON_CLICKED;
-wxEventType wxEVT_COMMAND_CHECKBOX_CLICKED;
-wxEventType wxEVT_COMMAND_CHOICE_SELECTED;
-wxEventType wxEVT_COMMAND_LISTBOX_SELECTED;
-wxEventType wxEVT_COMMAND_LISTBOX_DOUBLECLICKED;
-wxEventType wxEVT_COMMAND_CHECKLISTBOX_TOGGLED;
-wxEventType wxEVT_COMMAND_TEXT_UPDATED;
-wxEventType wxEVT_COMMAND_TEXT_ENTER;
-wxEventType wxEVT_COMMAND_MENU_SELECTED;
-wxEventType wxEVT_COMMAND_SLIDER_UPDATED;
-wxEventType wxEVT_COMMAND_RADIOBOX_SELECTED;
-wxEventType wxEVT_COMMAND_RADIOBUTTON_SELECTED;
-wxEventType wxEVT_COMMAND_SCROLLBAR_UPDATED;
-wxEventType wxEVT_COMMAND_VLBOX_SELECTED;
-wxEventType wxEVT_COMMAND_COMBOBOX_SELECTED;
-wxEventType wxEVT_COMMAND_TOOL_RCLICKED;
-wxEventType wxEVT_COMMAND_TOOL_ENTER;
-wxEventType wxEVT_COMMAND_SPINCTRL_UPDATED;
+wxEventType wxEVT_COMMAND_BUTTON_CLICKED = wxNewEventType();
+wxEventType wxEVT_COMMAND_CHECKBOX_CLICKED = wxNewEventType();
+wxEventType wxEVT_COMMAND_CHOICE_SELECTED = wxNewEventType();
+wxEventType wxEVT_COMMAND_LISTBOX_SELECTED = wxNewEventType();
+wxEventType wxEVT_COMMAND_LISTBOX_DOUBLECLICKED = wxNewEventType();
+wxEventType wxEVT_COMMAND_CHECKLISTBOX_TOGGLED = wxNewEventType();
+wxEventType wxEVT_COMMAND_TEXT_UPDATED = wxNewEventType();
+wxEventType wxEVT_COMMAND_TEXT_ENTER = wxNewEventType();
+wxEventType wxEVT_COMMAND_MENU_SELECTED = wxNewEventType();
+wxEventType wxEVT_COMMAND_SLIDER_UPDATED = wxNewEventType();
+wxEventType wxEVT_COMMAND_RADIOBOX_SELECTED = wxNewEventType();
+wxEventType wxEVT_COMMAND_RADIOBUTTON_SELECTED = wxNewEventType();
+wxEventType wxEVT_COMMAND_SCROLLBAR_UPDATED = wxNewEventType();
+wxEventType wxEVT_COMMAND_VLBOX_SELECTED = wxNewEventType();
+wxEventType wxEVT_COMMAND_COMBOBOX_SELECTED = wxNewEventType();
+wxEventType wxEVT_COMMAND_TOOL_RCLICKED = wxNewEventType();
+wxEventType wxEVT_COMMAND_TOOL_ENTER = wxNewEventType();
+wxEventType wxEVT_COMMAND_SPINCTRL_UPDATED = wxNewEventType();
 
 // Sockets and timers send events, too
-wxEventType wxEVT_SOCKET;
-wxEventType wxEVT_TIMER;
+wxEventType wxEVT_SOCKET = wxNewEventType();
+wxEventType wxEVT_TIMER = wxNewEventType();
 
 // Mouse event types
-wxEventType wxEVT_LEFT_DOWN;
-wxEventType wxEVT_LEFT_UP;
-wxEventType wxEVT_MIDDLE_DOWN;
-wxEventType wxEVT_MIDDLE_UP;
-wxEventType wxEVT_RIGHT_DOWN;
-wxEventType wxEVT_RIGHT_UP;
-wxEventType wxEVT_MOTION;
-wxEventType wxEVT_ENTER_WINDOW;
-wxEventType wxEVT_LEAVE_WINDOW;
-wxEventType wxEVT_LEFT_DCLICK;
-wxEventType wxEVT_MIDDLE_DCLICK;
-wxEventType wxEVT_RIGHT_DCLICK;
-wxEventType wxEVT_SET_FOCUS;
-wxEventType wxEVT_KILL_FOCUS;
+wxEventType wxEVT_LEFT_DOWN = wxNewEventType();
+wxEventType wxEVT_LEFT_UP = wxNewEventType();
+wxEventType wxEVT_MIDDLE_DOWN = wxNewEventType();
+wxEventType wxEVT_MIDDLE_UP = wxNewEventType();
+wxEventType wxEVT_RIGHT_DOWN = wxNewEventType();
+wxEventType wxEVT_RIGHT_UP = wxNewEventType();
+wxEventType wxEVT_MOTION = wxNewEventType();
+wxEventType wxEVT_ENTER_WINDOW = wxNewEventType();
+wxEventType wxEVT_LEAVE_WINDOW = wxNewEventType();
+wxEventType wxEVT_LEFT_DCLICK = wxNewEventType();
+wxEventType wxEVT_MIDDLE_DCLICK = wxNewEventType();
+wxEventType wxEVT_RIGHT_DCLICK = wxNewEventType();
+wxEventType wxEVT_SET_FOCUS = wxNewEventType();
+wxEventType wxEVT_KILL_FOCUS = wxNewEventType();
 
 // Non-client mouse events
-wxEventType wxEVT_NC_LEFT_DOWN;
-wxEventType wxEVT_NC_LEFT_UP;
-wxEventType wxEVT_NC_MIDDLE_DOWN;
-wxEventType wxEVT_NC_MIDDLE_UP;
-wxEventType wxEVT_NC_RIGHT_DOWN;
-wxEventType wxEVT_NC_RIGHT_UP;
-wxEventType wxEVT_NC_MOTION;
-wxEventType wxEVT_NC_ENTER_WINDOW;
-wxEventType wxEVT_NC_LEAVE_WINDOW;
-wxEventType wxEVT_NC_LEFT_DCLICK;
-wxEventType wxEVT_NC_MIDDLE_DCLICK;
-wxEventType wxEVT_NC_RIGHT_DCLICK;
+wxEventType wxEVT_NC_LEFT_DOWN = wxNewEventType();
+wxEventType wxEVT_NC_LEFT_UP = wxNewEventType();
+wxEventType wxEVT_NC_MIDDLE_DOWN = wxNewEventType();
+wxEventType wxEVT_NC_MIDDLE_UP = wxNewEventType();
+wxEventType wxEVT_NC_RIGHT_DOWN = wxNewEventType();
+wxEventType wxEVT_NC_RIGHT_UP = wxNewEventType();
+wxEventType wxEVT_NC_MOTION = wxNewEventType();
+wxEventType wxEVT_NC_ENTER_WINDOW = wxNewEventType();
+wxEventType wxEVT_NC_LEAVE_WINDOW = wxNewEventType();
+wxEventType wxEVT_NC_LEFT_DCLICK = wxNewEventType();
+wxEventType wxEVT_NC_MIDDLE_DCLICK = wxNewEventType();
+wxEventType wxEVT_NC_RIGHT_DCLICK = wxNewEventType();
 
 // Character input event type
-wxEventType wxEVT_CHAR;
-wxEventType wxEVT_CHAR_HOOK;
-wxEventType wxEVT_NAVIGATION_KEY;
-wxEventType wxEVT_KEY_DOWN;
-wxEventType wxEVT_KEY_UP;
+wxEventType wxEVT_CHAR = wxNewEventType();
+wxEventType wxEVT_CHAR_HOOK = wxNewEventType();
+wxEventType wxEVT_NAVIGATION_KEY = wxNewEventType();
+wxEventType wxEVT_KEY_DOWN = wxNewEventType();
+wxEventType wxEVT_KEY_UP = wxNewEventType();
 
 // Set cursor event
-wxEventType wxEVT_SET_CURSOR;
+wxEventType wxEVT_SET_CURSOR = wxNewEventType();
 
 // wxScrollbar and wxSlider event identifiers
-wxEventType wxEVT_SCROLL_TOP;
-wxEventType wxEVT_SCROLL_BOTTOM;
-wxEventType wxEVT_SCROLL_LINEUP;
-wxEventType wxEVT_SCROLL_LINEDOWN;
-wxEventType wxEVT_SCROLL_PAGEUP;
-wxEventType wxEVT_SCROLL_PAGEDOWN;
-wxEventType wxEVT_SCROLL_THUMBTRACK;
-wxEventType wxEVT_SCROLL_THUMBRELEASE;
+wxEventType wxEVT_SCROLL_TOP = wxNewEventType();
+wxEventType wxEVT_SCROLL_BOTTOM = wxNewEventType();
+wxEventType wxEVT_SCROLL_LINEUP = wxNewEventType();
+wxEventType wxEVT_SCROLL_LINEDOWN = wxNewEventType();
+wxEventType wxEVT_SCROLL_PAGEUP = wxNewEventType();
+wxEventType wxEVT_SCROLL_PAGEDOWN = wxNewEventType();
+wxEventType wxEVT_SCROLL_THUMBTRACK = wxNewEventType();
+wxEventType wxEVT_SCROLL_THUMBRELEASE = wxNewEventType();
 
 // Scroll events from wxWindow
-wxEventType wxEVT_SCROLLWIN_TOP;
-wxEventType wxEVT_SCROLLWIN_BOTTOM;
-wxEventType wxEVT_SCROLLWIN_LINEUP;
-wxEventType wxEVT_SCROLLWIN_LINEDOWN;
-wxEventType wxEVT_SCROLLWIN_PAGEUP;
-wxEventType wxEVT_SCROLLWIN_PAGEDOWN;
-wxEventType wxEVT_SCROLLWIN_THUMBTRACK;
-wxEventType wxEVT_SCROLLWIN_THUMBRELEASE;
+wxEventType wxEVT_SCROLLWIN_TOP = wxNewEventType();
+wxEventType wxEVT_SCROLLWIN_BOTTOM = wxNewEventType();
+wxEventType wxEVT_SCROLLWIN_LINEUP = wxNewEventType();
+wxEventType wxEVT_SCROLLWIN_LINEDOWN = wxNewEventType();
+wxEventType wxEVT_SCROLLWIN_PAGEUP = wxNewEventType();
+wxEventType wxEVT_SCROLLWIN_PAGEDOWN = wxNewEventType();
+wxEventType wxEVT_SCROLLWIN_THUMBTRACK = wxNewEventType();
+wxEventType wxEVT_SCROLLWIN_THUMBRELEASE = wxNewEventType();
 
 // System events
-wxEventType wxEVT_SIZE;
-wxEventType wxEVT_MOVE;
-wxEventType wxEVT_CLOSE_WINDOW;
-wxEventType wxEVT_END_SESSION;
-wxEventType wxEVT_QUERY_END_SESSION;
-wxEventType wxEVT_ACTIVATE_APP;
-wxEventType wxEVT_POWER;
-wxEventType wxEVT_ACTIVATE;
-wxEventType wxEVT_CREATE;
-wxEventType wxEVT_DESTROY;
-wxEventType wxEVT_SHOW;
-wxEventType wxEVT_ICONIZE;
-wxEventType wxEVT_MAXIMIZE;
-wxEventType wxEVT_MOUSE_CAPTURE_CHANGED;
-wxEventType wxEVT_PAINT;
-wxEventType wxEVT_ERASE_BACKGROUND;
-wxEventType wxEVT_NC_PAINT;
-wxEventType wxEVT_PAINT_ICON;
-wxEventType wxEVT_MENU_CHAR;
-wxEventType wxEVT_MENU_INIT;
-wxEventType wxEVT_MENU_HIGHLIGHT;
-wxEventType wxEVT_POPUP_MENU_INIT;
-wxEventType wxEVT_CONTEXT_MENU;
-wxEventType wxEVT_SYS_COLOUR_CHANGED;
-wxEventType wxEVT_SETTING_CHANGED;
-wxEventType wxEVT_QUERY_NEW_PALETTE;
-wxEventType wxEVT_PALETTE_CHANGED;
-wxEventType wxEVT_JOY_BUTTON_DOWN;
-wxEventType wxEVT_JOY_BUTTON_UP;
-wxEventType wxEVT_JOY_MOVE;
-wxEventType wxEVT_JOY_ZMOVE;
-wxEventType wxEVT_DROP_FILES;
-wxEventType wxEVT_DRAW_ITEM;
-wxEventType wxEVT_MEASURE_ITEM;
-wxEventType wxEVT_COMPARE_ITEM;
-wxEventType wxEVT_INIT_DIALOG;
-wxEventType wxEVT_IDLE;
-wxEventType wxEVT_UPDATE_UI;
+wxEventType wxEVT_SIZE = wxNewEventType();
+wxEventType wxEVT_MOVE = wxNewEventType();
+wxEventType wxEVT_CLOSE_WINDOW = wxNewEventType();
+wxEventType wxEVT_END_SESSION = wxNewEventType();
+wxEventType wxEVT_QUERY_END_SESSION = wxNewEventType();
+wxEventType wxEVT_ACTIVATE_APP = wxNewEventType();
+wxEventType wxEVT_POWER = wxNewEventType();
+wxEventType wxEVT_ACTIVATE = wxNewEventType();
+wxEventType wxEVT_CREATE = wxNewEventType();
+wxEventType wxEVT_DESTROY = wxNewEventType();
+wxEventType wxEVT_SHOW = wxNewEventType();
+wxEventType wxEVT_ICONIZE = wxNewEventType();
+wxEventType wxEVT_MAXIMIZE = wxNewEventType();
+wxEventType wxEVT_MOUSE_CAPTURE_CHANGED = wxNewEventType();
+wxEventType wxEVT_PAINT = wxNewEventType();
+wxEventType wxEVT_ERASE_BACKGROUND = wxNewEventType();
+wxEventType wxEVT_NC_PAINT = wxNewEventType();
+wxEventType wxEVT_PAINT_ICON = wxNewEventType();
+wxEventType wxEVT_MENU_CHAR = wxNewEventType();
+wxEventType wxEVT_MENU_INIT = wxNewEventType();
+wxEventType wxEVT_MENU_HIGHLIGHT = wxNewEventType();
+wxEventType wxEVT_POPUP_MENU_INIT = wxNewEventType();
+wxEventType wxEVT_CONTEXT_MENU = wxNewEventType();
+wxEventType wxEVT_SYS_COLOUR_CHANGED = wxNewEventType();
+wxEventType wxEVT_SETTING_CHANGED = wxNewEventType();
+wxEventType wxEVT_QUERY_NEW_PALETTE = wxNewEventType();
+wxEventType wxEVT_PALETTE_CHANGED = wxNewEventType();
+wxEventType wxEVT_JOY_BUTTON_DOWN = wxNewEventType();
+wxEventType wxEVT_JOY_BUTTON_UP = wxNewEventType();
+wxEventType wxEVT_JOY_MOVE = wxNewEventType();
+wxEventType wxEVT_JOY_ZMOVE = wxNewEventType();
+wxEventType wxEVT_DROP_FILES = wxNewEventType();
+wxEventType wxEVT_DRAW_ITEM = wxNewEventType();
+wxEventType wxEVT_MEASURE_ITEM = wxNewEventType();
+wxEventType wxEVT_COMPARE_ITEM = wxNewEventType();
+wxEventType wxEVT_INIT_DIALOG = wxNewEventType();
+wxEventType wxEVT_IDLE = wxNewEventType();
+wxEventType wxEVT_UPDATE_UI = wxNewEventType();
 
 // System misc.
-wxEventType wxEVT_END_PROCESS;
+wxEventType wxEVT_END_PROCESS = wxNewEventType();
 
 // Dial up events
-wxEventType wxEVT_DIALUP_CONNECTED;
-wxEventType wxEVT_DIALUP_DISCONNECTED;
+wxEventType wxEVT_DIALUP_CONNECTED = wxNewEventType();
+wxEventType wxEVT_DIALUP_DISCONNECTED = wxNewEventType();
 
 // Generic command events
 // Note: a click is a higher-level event than button down/up
-wxEventType wxEVT_COMMAND_LEFT_CLICK;
-wxEventType wxEVT_COMMAND_LEFT_DCLICK;
-wxEventType wxEVT_COMMAND_RIGHT_CLICK;
-wxEventType wxEVT_COMMAND_RIGHT_DCLICK;
-wxEventType wxEVT_COMMAND_SET_FOCUS;
-wxEventType wxEVT_COMMAND_KILL_FOCUS;
-wxEventType wxEVT_COMMAND_ENTER;
+wxEventType wxEVT_COMMAND_LEFT_CLICK = wxNewEventType();
+wxEventType wxEVT_COMMAND_LEFT_DCLICK = wxNewEventType();
+wxEventType wxEVT_COMMAND_RIGHT_CLICK = wxNewEventType();
+wxEventType wxEVT_COMMAND_RIGHT_DCLICK = wxNewEventType();
+wxEventType wxEVT_COMMAND_SET_FOCUS = wxNewEventType();
+wxEventType wxEVT_COMMAND_KILL_FOCUS = wxNewEventType();
+wxEventType wxEVT_COMMAND_ENTER = wxNewEventType();
 
 // Tree control event types
-wxEventType wxEVT_COMMAND_TREE_BEGIN_DRAG;
-wxEventType wxEVT_COMMAND_TREE_BEGIN_RDRAG;
-wxEventType wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT;
-wxEventType wxEVT_COMMAND_TREE_END_LABEL_EDIT;
-wxEventType wxEVT_COMMAND_TREE_DELETE_ITEM;
-wxEventType wxEVT_COMMAND_TREE_GET_INFO;
-wxEventType wxEVT_COMMAND_TREE_SET_INFO;
-wxEventType wxEVT_COMMAND_TREE_ITEM_EXPANDED;
-wxEventType wxEVT_COMMAND_TREE_ITEM_EXPANDING;
-wxEventType wxEVT_COMMAND_TREE_ITEM_COLLAPSED;
-wxEventType wxEVT_COMMAND_TREE_ITEM_COLLAPSING;
-wxEventType wxEVT_COMMAND_TREE_SEL_CHANGED;
-wxEventType wxEVT_COMMAND_TREE_SEL_CHANGING;
-wxEventType wxEVT_COMMAND_TREE_KEY_DOWN;
-wxEventType wxEVT_COMMAND_TREE_ITEM_ACTIVATED;
-wxEventType wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK;
-wxEventType wxEVT_COMMAND_TREE_ITEM_MIDDLE_CLICK;
-wxEventType wxEVT_COMMAND_TREE_END_DRAG;
+wxEventType wxEVT_COMMAND_TREE_BEGIN_DRAG = wxNewEventType();
+wxEventType wxEVT_COMMAND_TREE_BEGIN_RDRAG = wxNewEventType();
+wxEventType wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT = wxNewEventType();
+wxEventType wxEVT_COMMAND_TREE_END_LABEL_EDIT = wxNewEventType();
+wxEventType wxEVT_COMMAND_TREE_DELETE_ITEM = wxNewEventType();
+wxEventType wxEVT_COMMAND_TREE_GET_INFO = wxNewEventType();
+wxEventType wxEVT_COMMAND_TREE_SET_INFO = wxNewEventType();
+wxEventType wxEVT_COMMAND_TREE_ITEM_EXPANDED = wxNewEventType();
+wxEventType wxEVT_COMMAND_TREE_ITEM_EXPANDING = wxNewEventType();
+wxEventType wxEVT_COMMAND_TREE_ITEM_COLLAPSED = wxNewEventType();
+wxEventType wxEVT_COMMAND_TREE_ITEM_COLLAPSING = wxNewEventType();
+wxEventType wxEVT_COMMAND_TREE_SEL_CHANGED = wxNewEventType();
+wxEventType wxEVT_COMMAND_TREE_SEL_CHANGING = wxNewEventType();
+wxEventType wxEVT_COMMAND_TREE_KEY_DOWN = wxNewEventType();
+wxEventType wxEVT_COMMAND_TREE_ITEM_ACTIVATED = wxNewEventType();
+wxEventType wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK = wxNewEventType();
+wxEventType wxEVT_COMMAND_TREE_ITEM_MIDDLE_CLICK = wxNewEventType();
+wxEventType wxEVT_COMMAND_TREE_END_DRAG = wxNewEventType();
 
 // List control event types
-wxEventType wxEVT_COMMAND_LIST_BEGIN_DRAG;
-wxEventType wxEVT_COMMAND_LIST_BEGIN_RDRAG;
-wxEventType wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT;
-wxEventType wxEVT_COMMAND_LIST_END_LABEL_EDIT;
-wxEventType wxEVT_COMMAND_LIST_DELETE_ITEM;
-wxEventType wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS;
-wxEventType wxEVT_COMMAND_LIST_GET_INFO;
-wxEventType wxEVT_COMMAND_LIST_SET_INFO;
-wxEventType wxEVT_COMMAND_LIST_ITEM_SELECTED;
-wxEventType wxEVT_COMMAND_LIST_ITEM_DESELECTED;
-wxEventType wxEVT_COMMAND_LIST_KEY_DOWN;
-wxEventType wxEVT_COMMAND_LIST_INSERT_ITEM;
-wxEventType wxEVT_COMMAND_LIST_COL_CLICK;
-wxEventType wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK;
-wxEventType wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK;
-wxEventType wxEVT_COMMAND_LIST_ITEM_ACTIVATED;
+wxEventType wxEVT_COMMAND_LIST_BEGIN_DRAG = wxNewEventType();
+wxEventType wxEVT_COMMAND_LIST_BEGIN_RDRAG = wxNewEventType();
+wxEventType wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT = wxNewEventType();
+wxEventType wxEVT_COMMAND_LIST_END_LABEL_EDIT = wxNewEventType();
+wxEventType wxEVT_COMMAND_LIST_DELETE_ITEM = wxNewEventType();
+wxEventType wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS = wxNewEventType();
+wxEventType wxEVT_COMMAND_LIST_GET_INFO = wxNewEventType();
+wxEventType wxEVT_COMMAND_LIST_SET_INFO = wxNewEventType();
+wxEventType wxEVT_COMMAND_LIST_ITEM_SELECTED = wxNewEventType();
+wxEventType wxEVT_COMMAND_LIST_ITEM_DESELECTED = wxNewEventType();
+wxEventType wxEVT_COMMAND_LIST_KEY_DOWN = wxNewEventType();
+wxEventType wxEVT_COMMAND_LIST_INSERT_ITEM = wxNewEventType();
+wxEventType wxEVT_COMMAND_LIST_COL_CLICK = wxNewEventType();
+wxEventType wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK = wxNewEventType();
+wxEventType wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK = wxNewEventType();
+wxEventType wxEVT_COMMAND_LIST_ITEM_ACTIVATED = wxNewEventType();
 
 // Tab and notebook control event types
-wxEventType wxEVT_COMMAND_TAB_SEL_CHANGED;
-wxEventType wxEVT_COMMAND_TAB_SEL_CHANGING;
-wxEventType wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED;
-wxEventType wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING;
+wxEventType wxEVT_COMMAND_TAB_SEL_CHANGED = wxNewEventType();
+wxEventType wxEVT_COMMAND_TAB_SEL_CHANGING = wxNewEventType();
+wxEventType wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED = wxNewEventType();
+wxEventType wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING = wxNewEventType();
 
 // Splitter events
-wxEventType wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED;
-wxEventType wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING;
-wxEventType wxEVT_COMMAND_SPLITTER_DOUBLECLICKED;
-wxEventType wxEVT_COMMAND_SPLITTER_UNSPLIT;
+wxEventType wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED = wxNewEventType();
+wxEventType wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING = wxNewEventType();
+wxEventType wxEVT_COMMAND_SPLITTER_DOUBLECLICKED = wxNewEventType();
+wxEventType wxEVT_COMMAND_SPLITTER_UNSPLIT = wxNewEventType();
 
 // Wizard events
-wxEventType wxEVT_WIZARD_PAGE_CHANGED;
-wxEventType wxEVT_WIZARD_PAGE_CHANGING;
-wxEventType wxEVT_WIZARD_CANCEL;
+wxEventType wxEVT_WIZARD_PAGE_CHANGED = wxNewEventType();
+wxEventType wxEVT_WIZARD_PAGE_CHANGING = wxNewEventType();
+wxEventType wxEVT_WIZARD_CANCEL = wxNewEventType();
 
 // Calendar events
-wxEventType wxEVT_CALENDAR_SEL_CHANGED;
-wxEventType wxEVT_CALENDAR_DAY_CHANGED;
-wxEventType wxEVT_CALENDAR_MONTH_CHANGED;
-wxEventType wxEVT_CALENDAR_YEAR_CHANGED;
-wxEventType wxEVT_CALENDAR_DOUBLECLICKED;
-wxEventType wxEVT_CALENDAR_WEEKDAY_CLICKED;
+wxEventType wxEVT_CALENDAR_SEL_CHANGED = wxNewEventType();
+wxEventType wxEVT_CALENDAR_DAY_CHANGED = wxNewEventType();
+wxEventType wxEVT_CALENDAR_MONTH_CHANGED = wxNewEventType();
+wxEventType wxEVT_CALENDAR_YEAR_CHANGED = wxNewEventType();
+wxEventType wxEVT_CALENDAR_DOUBLECLICKED = wxNewEventType();
+wxEventType wxEVT_CALENDAR_WEEKDAY_CLICKED = wxNewEventType();
 
 // Help events
-wxEventType wxEVT_HELP;
-wxEventType wxEVT_DETAILED_HELP;
+wxEventType wxEVT_HELP = wxNewEventType();
+wxEventType wxEVT_DETAILED_HELP = wxNewEventType();
+
+#endif // !WXWIN_COMPATIBILITY_EVENT_TYPES
+
+// ============================================================================
+// implementation
+// ============================================================================
 
 // ----------------------------------------------------------------------------
 // event initialization
@@ -337,6 +334,8 @@ int wxNewEventType()
     // check that we don't overlap with the user-defined types: if it does
     // happen, the best solution is probably to update the existing code to
     // use wxNewEventType() instead of wxEVT_USER_FIRST
+    //
+    // due to the uncertainty
     wxASSERT_MSG( s_lastUsedEventType < wxEVT_USER_FIRST - 1,
                   _T("possible event type conflict") );
 #endif // WXWIN_COMPATIBILITY_2
@@ -344,252 +343,6 @@ int wxNewEventType()
     return s_lastUsedEventType++;
 }
 
-static void InitEvents()
-{
-#ifdef __WXDEBUG__
-    // this function is supposed to be called only once, as normally this
-    // should be always true we only do this check in debug mode
-    static bool s_inInitEvents = FALSE;
-    wxCHECK_RET( !s_inInitEvents, _T("InitEvents() reentrancy!") );
-
-    // note that we don't reset it to FALSE any more as we shouldn't be called
-    // again
-    s_inInitEvents = TRUE;
-#endif // __WXDEBUG__
-
-    wxEVT_COMMAND_BUTTON_CLICKED = wxNewEventType();
-    wxEVT_COMMAND_CHECKBOX_CLICKED = wxNewEventType();
-    wxEVT_COMMAND_CHOICE_SELECTED = wxNewEventType();
-    wxEVT_COMMAND_LISTBOX_SELECTED = wxNewEventType();
-    wxEVT_COMMAND_LISTBOX_DOUBLECLICKED = wxNewEventType();
-    wxEVT_COMMAND_CHECKLISTBOX_TOGGLED = wxNewEventType();
-    wxEVT_COMMAND_TEXT_UPDATED = wxNewEventType();
-    wxEVT_COMMAND_TEXT_ENTER = wxNewEventType();
-    wxEVT_COMMAND_MENU_SELECTED = wxNewEventType();
-    wxEVT_COMMAND_TOOL_CLICKED = wxNewEventType();
-    wxEVT_COMMAND_SLIDER_UPDATED = wxNewEventType();
-    wxEVT_COMMAND_RADIOBOX_SELECTED = wxNewEventType();
-    wxEVT_COMMAND_RADIOBUTTON_SELECTED = wxNewEventType();
-    wxEVT_COMMAND_SCROLLBAR_UPDATED = wxNewEventType();
-    wxEVT_COMMAND_VLBOX_SELECTED = wxNewEventType();
-    wxEVT_COMMAND_COMBOBOX_SELECTED = wxNewEventType();
-    wxEVT_COMMAND_TOOL_RCLICKED = wxNewEventType();
-    wxEVT_COMMAND_TOOL_ENTER = wxNewEventType();
-    wxEVT_COMMAND_SPINCTRL_UPDATED = wxNewEventType();
-
-    // Sockets and timers send events, too
-    wxEVT_SOCKET = wxNewEventType();
-    wxEVT_TIMER = wxNewEventType();
-
-    // Mouse event types
-    wxEVT_LEFT_DOWN = wxNewEventType();
-    wxEVT_LEFT_UP = wxNewEventType();
-    wxEVT_MIDDLE_DOWN = wxNewEventType();
-    wxEVT_MIDDLE_UP = wxNewEventType();
-    wxEVT_RIGHT_DOWN = wxNewEventType();
-    wxEVT_RIGHT_UP = wxNewEventType();
-    wxEVT_MOTION = wxNewEventType();
-    wxEVT_ENTER_WINDOW = wxNewEventType();
-    wxEVT_LEAVE_WINDOW = wxNewEventType();
-    wxEVT_LEFT_DCLICK = wxNewEventType();
-    wxEVT_MIDDLE_DCLICK = wxNewEventType();
-    wxEVT_RIGHT_DCLICK = wxNewEventType();
-    wxEVT_SET_FOCUS = wxNewEventType();
-    wxEVT_KILL_FOCUS = wxNewEventType();
-
-    // Non-client mouse events
-    wxEVT_NC_LEFT_DOWN = wxNewEventType();
-    wxEVT_NC_LEFT_UP = wxNewEventType();
-    wxEVT_NC_MIDDLE_DOWN = wxNewEventType();
-    wxEVT_NC_MIDDLE_UP = wxNewEventType();
-    wxEVT_NC_RIGHT_DOWN = wxNewEventType();
-    wxEVT_NC_RIGHT_UP = wxNewEventType();
-    wxEVT_NC_MOTION = wxNewEventType();
-    wxEVT_NC_ENTER_WINDOW = wxNewEventType();
-    wxEVT_NC_LEAVE_WINDOW = wxNewEventType();
-    wxEVT_NC_LEFT_DCLICK = wxNewEventType();
-    wxEVT_NC_MIDDLE_DCLICK = wxNewEventType();
-    wxEVT_NC_RIGHT_DCLICK = wxNewEventType();
-
-    // Character input event type
-    wxEVT_CHAR = wxNewEventType();
-    wxEVT_CHAR_HOOK = wxNewEventType();
-    wxEVT_NAVIGATION_KEY = wxNewEventType();
-    wxEVT_KEY_DOWN = wxNewEventType();
-    wxEVT_KEY_UP = wxNewEventType();
-
-    // Set cursor event
-    wxEVT_SET_CURSOR = wxNewEventType();
-
-    // wxScrollbar and wxSlider event identifiers
-    wxEVT_SCROLL_TOP = wxNewEventType();
-    wxEVT_SCROLL_BOTTOM = wxNewEventType();
-    wxEVT_SCROLL_LINEUP = wxNewEventType();
-    wxEVT_SCROLL_LINEDOWN = wxNewEventType();
-    wxEVT_SCROLL_PAGEUP = wxNewEventType();
-    wxEVT_SCROLL_PAGEDOWN = wxNewEventType();
-    wxEVT_SCROLL_THUMBTRACK = wxNewEventType();
-    wxEVT_SCROLL_THUMBRELEASE = wxNewEventType();
-
-    // Scroll events from wxWindow
-    wxEVT_SCROLLWIN_TOP = wxNewEventType();
-    wxEVT_SCROLLWIN_BOTTOM = wxNewEventType();
-    wxEVT_SCROLLWIN_LINEUP = wxNewEventType();
-    wxEVT_SCROLLWIN_LINEDOWN = wxNewEventType();
-    wxEVT_SCROLLWIN_PAGEUP = wxNewEventType();
-    wxEVT_SCROLLWIN_PAGEDOWN = wxNewEventType();
-    wxEVT_SCROLLWIN_THUMBTRACK = wxNewEventType();
-    wxEVT_SCROLLWIN_THUMBRELEASE = wxNewEventType();
-
-    // System events
-    wxEVT_SIZE = wxNewEventType();
-    wxEVT_MOVE = wxNewEventType();
-    wxEVT_CLOSE_WINDOW = wxNewEventType();
-    wxEVT_END_SESSION = wxNewEventType();
-    wxEVT_QUERY_END_SESSION = wxNewEventType();
-    wxEVT_ACTIVATE_APP = wxNewEventType();
-    wxEVT_POWER = wxNewEventType();
-    wxEVT_ACTIVATE = wxNewEventType();
-    wxEVT_CREATE = wxNewEventType();
-    wxEVT_DESTROY = wxNewEventType();
-    wxEVT_SHOW = wxNewEventType();
-    wxEVT_ICONIZE = wxNewEventType();
-    wxEVT_MAXIMIZE = wxNewEventType();
-    wxEVT_MOUSE_CAPTURE_CHANGED = wxNewEventType();
-    wxEVT_PAINT = wxNewEventType();
-    wxEVT_ERASE_BACKGROUND = wxNewEventType();
-    wxEVT_NC_PAINT = wxNewEventType();
-    wxEVT_PAINT_ICON = wxNewEventType();
-    wxEVT_MENU_CHAR = wxNewEventType();
-    wxEVT_MENU_INIT = wxNewEventType();
-    wxEVT_MENU_HIGHLIGHT = wxNewEventType();
-    wxEVT_POPUP_MENU_INIT = wxNewEventType();
-    wxEVT_CONTEXT_MENU = wxNewEventType();
-    wxEVT_SYS_COLOUR_CHANGED = wxNewEventType();
-    wxEVT_SETTING_CHANGED = wxNewEventType();
-    wxEVT_QUERY_NEW_PALETTE = wxNewEventType();
-    wxEVT_PALETTE_CHANGED = wxNewEventType();
-    wxEVT_JOY_BUTTON_DOWN = wxNewEventType();
-    wxEVT_JOY_BUTTON_UP = wxNewEventType();
-    wxEVT_JOY_MOVE = wxNewEventType();
-    wxEVT_JOY_ZMOVE = wxNewEventType();
-    wxEVT_DROP_FILES = wxNewEventType();
-    wxEVT_DRAW_ITEM = wxNewEventType();
-    wxEVT_MEASURE_ITEM = wxNewEventType();
-    wxEVT_COMPARE_ITEM = wxNewEventType();
-    wxEVT_INIT_DIALOG = wxNewEventType();
-    wxEVT_IDLE = wxNewEventType();
-    wxEVT_UPDATE_UI = wxNewEventType();
-
-    // System misc.
-    wxEVT_END_PROCESS = wxNewEventType();
-
-    // Dial up events
-    wxEVT_DIALUP_CONNECTED = wxNewEventType();
-    wxEVT_DIALUP_DISCONNECTED = wxNewEventType();
-
-    // Generic command events
-    // Note: a click is a higher-level event than button down/up
-    wxEVT_COMMAND_LEFT_CLICK = wxNewEventType();
-    wxEVT_COMMAND_LEFT_DCLICK = wxNewEventType();
-    wxEVT_COMMAND_RIGHT_CLICK = wxNewEventType();
-    wxEVT_COMMAND_RIGHT_DCLICK = wxNewEventType();
-    wxEVT_COMMAND_SET_FOCUS = wxNewEventType();
-    wxEVT_COMMAND_KILL_FOCUS = wxNewEventType();
-    wxEVT_COMMAND_ENTER = wxNewEventType();
-
-    // Tree control event types
-    wxEVT_COMMAND_TREE_BEGIN_DRAG = wxNewEventType();
-    wxEVT_COMMAND_TREE_BEGIN_RDRAG = wxNewEventType();
-    wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT = wxNewEventType();
-    wxEVT_COMMAND_TREE_END_LABEL_EDIT = wxNewEventType();
-    wxEVT_COMMAND_TREE_DELETE_ITEM = wxNewEventType();
-    wxEVT_COMMAND_TREE_GET_INFO = wxNewEventType();
-    wxEVT_COMMAND_TREE_SET_INFO = wxNewEventType();
-    wxEVT_COMMAND_TREE_ITEM_EXPANDED = wxNewEventType();
-    wxEVT_COMMAND_TREE_ITEM_EXPANDING = wxNewEventType();
-    wxEVT_COMMAND_TREE_ITEM_COLLAPSED = wxNewEventType();
-    wxEVT_COMMAND_TREE_ITEM_COLLAPSING = wxNewEventType();
-    wxEVT_COMMAND_TREE_SEL_CHANGED = wxNewEventType();
-    wxEVT_COMMAND_TREE_SEL_CHANGING = wxNewEventType();
-    wxEVT_COMMAND_TREE_KEY_DOWN = wxNewEventType();
-    wxEVT_COMMAND_TREE_ITEM_ACTIVATED = wxNewEventType();
-    wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK = wxNewEventType();
-    wxEVT_COMMAND_TREE_ITEM_MIDDLE_CLICK = wxNewEventType();
-    wxEVT_COMMAND_TREE_END_DRAG = wxNewEventType();
-
-    // List control event types
-    wxEVT_COMMAND_LIST_BEGIN_DRAG = wxNewEventType();
-    wxEVT_COMMAND_LIST_BEGIN_RDRAG = wxNewEventType();
-    wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT = wxNewEventType();
-    wxEVT_COMMAND_LIST_END_LABEL_EDIT = wxNewEventType();
-    wxEVT_COMMAND_LIST_DELETE_ITEM = wxNewEventType();
-    wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS = wxNewEventType();
-    wxEVT_COMMAND_LIST_GET_INFO = wxNewEventType();
-    wxEVT_COMMAND_LIST_SET_INFO = wxNewEventType();
-    wxEVT_COMMAND_LIST_ITEM_SELECTED = wxNewEventType();
-    wxEVT_COMMAND_LIST_ITEM_DESELECTED = wxNewEventType();
-    wxEVT_COMMAND_LIST_KEY_DOWN = wxNewEventType();
-    wxEVT_COMMAND_LIST_INSERT_ITEM = wxNewEventType();
-    wxEVT_COMMAND_LIST_COL_CLICK = wxNewEventType();
-    wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK = wxNewEventType();
-    wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK = wxNewEventType();
-    wxEVT_COMMAND_LIST_ITEM_ACTIVATED = wxNewEventType();
-
-    // Tab and notebook control event types
-    wxEVT_COMMAND_TAB_SEL_CHANGED = wxNewEventType();
-    wxEVT_COMMAND_TAB_SEL_CHANGING = wxNewEventType();
-    wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED = wxNewEventType();
-    wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING = wxNewEventType();
-
-    // Splitter events
-    wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED = wxNewEventType();
-    wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING = wxNewEventType();
-    wxEVT_COMMAND_SPLITTER_DOUBLECLICKED = wxNewEventType();
-    wxEVT_COMMAND_SPLITTER_UNSPLIT = wxNewEventType();
-
-    // Wizard events
-    wxEVT_WIZARD_PAGE_CHANGED = wxNewEventType();
-    wxEVT_WIZARD_PAGE_CHANGING = wxNewEventType();
-    wxEVT_WIZARD_CANCEL = wxNewEventType();
-
-    // Calendar events
-    wxEVT_CALENDAR_SEL_CHANGED = wxNewEventType();
-    wxEVT_CALENDAR_DAY_CHANGED = wxNewEventType();
-    wxEVT_CALENDAR_MONTH_CHANGED = wxNewEventType();
-    wxEVT_CALENDAR_YEAR_CHANGED = wxNewEventType();
-    wxEVT_CALENDAR_DOUBLECLICKED = wxNewEventType();
-    wxEVT_CALENDAR_WEEKDAY_CLICKED = wxNewEventType();
-
-    // Help events
-    wxEVT_HELP = wxNewEventType();
-    wxEVT_DETAILED_HELP = wxNewEventType();
-}
-
-// ----------------------------------------------------------------------------
-// wxEventTableEntry
-// ----------------------------------------------------------------------------
-
-wxEventTableEntry::wxEventTableEntry(int evType, int id, int idLast,
-                                     wxObjectEventFunction fn, wxObject *data)
-{
-    static bool s_initEventsDone = FALSE;
-    if ( !s_initEventsDone )
-    {
-        InitEvents();
-
-        s_initEventsDone = TRUE;
-    }
-
-    m_eventType = evType;
-    m_id = id;
-    m_lastId = idLast;
-    m_fn = fn;
-    m_callbackUserData = data;
-}
-
-#endif // WXWIN_COMPATIBILITY_EVENT_TYPES
-
 // ----------------------------------------------------------------------------
 // wxEvent
 // ----------------------------------------------------------------------------
@@ -877,7 +630,7 @@ void wxKeyEvent::CopyObject(wxObject& obj_d) const
     obj->m_x = m_x;
     obj->m_y = m_y;
     obj->m_keyCode = m_keyCode;
-    
+
     obj->m_shiftDown   = m_shiftDown;
     obj->m_controlDown = m_controlDown;
     obj->m_metaDown    = m_metaDown;
@@ -1123,7 +876,7 @@ void wxEvtHandler::AddPendingEvent(wxEvent& event)
     wxPendingEvents->Append(this);
 
     wxLEAVE_CRIT_SECT(*wxPendingEventsLocker);
-    
+
     // 3) Inform the system that new pending events are somwehere,
     //    and that these should be processed in idle time.
     wxWakeUpIdle();
@@ -1144,7 +897,7 @@ void wxEvtHandler::ProcessPendingEvents()
         delete node;
 
         // In ProcessEvent, new events might get added and
-	    // we can safely leave the crtical section here.
+        // we can safely leave the crtical section here.
 #if defined(__VISAGECPP__)
         wxLEAVE_CRIT_SECT( m_eventsLocker);
 #else
@@ -1182,7 +935,7 @@ bool wxEvtHandler::ProcessEvent(wxEvent& event)
     // An event handler can be enabled or disabled
     if ( GetEvtHandlerEnabled() )
     {
-    
+
 #if 0
 /*
         What is this? When using GUI threads, a non main
-- 
2.50.0

