void Skip(bool skip = TRUE) { m_skipped = skip; }
bool GetSkipped() const { return m_skipped; };
+ // implementation only: this test is explicitlty anti OO and this functions
+ // exists only for optimization purposes
+ bool IsCommandEvent() const { return m_isCommandEvent; }
+
public:
bool m_skipped;
wxObject* m_eventObject;
long m_timeStamp;
int m_id;
wxObject* m_callbackUserData;
+
+ // optimization: instead of using costly IsKindOf() we keep a flag telling
+ // whether we're a command event (by far the most common case)
+ bool m_isCommandEvent;
};
// Item or menu event class
void SetLoggingOff(bool logOff) { m_loggingOff = logOff; }
bool GetLoggingOff() const { return m_loggingOff; }
- void Veto(bool veto = TRUE) { wxASSERT( m_canVeto ); m_veto = veto; }
+ void Veto(bool veto = TRUE)
+ {
+ // GetVeto() will return FALSE anyhow...
+ wxCHECK_RET( m_canVeto,
+ "call to Veto() ignored (can't veto this event)" );
+
+ m_veto = veto;
+ }
void SetCanVeto(bool canVeto) { m_canVeto = canVeto; }
+ // No more asserts here please, the one you put here was wrong.
bool CanVeto() const { return m_canVeto; }
- bool GetVeto() const { wxASSERT( m_canVeto ); return m_veto; }
+ bool GetVeto() const { return m_canVeto && m_veto; }
#if WXWIN_COMPATIBILITY
// This is probably obsolete now, since we use CanVeto instead, in
virtual long Default()
{ return GetNextHandler() ? GetNextHandler()->Default() : 0; };
+#if WXWIN_COMPATIBILITY
virtual bool OnClose();
+#endif
virtual bool ProcessEvent(wxEvent& event);
virtual bool SearchEventTable(wxEventTable& table, wxEvent& event);
static const wxEventTableEntry sm_eventTableEntries[];
protected:
- static const wxEventTable sm_eventTable;
- virtual const wxEventTable* GetEventTable() const;
+ static const wxEventTable sm_eventTable;
+
+ virtual const wxEventTable *GetEventTable() const;
+
protected:
wxEvtHandler* m_nextHandler;
wxEvtHandler* m_previousHandler;
- bool m_enabled; // Is event handler enabled?
+ bool m_enabled; // Is event handler enabled?
wxList* m_dynamicEvents;
+
+ // optimization: instead of using costly IsKindOf() to decide whether we're
+ // a window (which is true in 99% of cases), use this flag
+ bool m_isWindow;
};
typedef void (wxEvtHandler::*wxEventFunction)(wxEvent&);
// EVT_COMMAND
#define EVT_COMMAND(id, event, fn) { event, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
-#define EVT_COMMAND_RANGE(id1, id2, event, fn) { eventId, id1, id2, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
+#define EVT_COMMAND_RANGE(id1, id2, event, fn) { event, id1, id2, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL },
// Scrolling
#define EVT_SCROLL(func) \