- Moved wxApp::SendIdleEvents and wxApp::ProcessIdle into common code.

- wxWindow::OnInternalIdle is now used in all ports, and ensures that
  user OnIdle events do not interfere with crucial internal processing.
- wxWindow::UpdateWindowUI is now a documented function that
  sends wxUpdateUIEvents, and can be overridden. It has a helper function
  DoUpdateWindowUI for taking appropriate wxUpdateUIEvent action.
- Added functions to wxUpdateUIEvent: Set/GetMode, Set/GetUpdateInterval,
  CanUpdate, to assist with optimising update event frequency.
- Added functions to wxIdleEvent: Set/GetMode, CanSend, to
  determine whether a window should receive idle events.
- Added wxWS_EX_PROCESS_IDLE, wxWS_EX_PROCESS_UI_UPDATES window
  styles for use with conservative idle and update event modes.
- wxMSW and wxGTK now send menu update events only when a menu is
  about to be used.
- Added WM_INITMENU processing instead of WM_ENTERMENULOOP, or
  accelerators don't always get called since menu items may still
  be disabled.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@21789 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2003-07-09 10:15:21 +00:00
parent 50b27824da
commit e39af974ef
81 changed files with 733 additions and 959 deletions

View File

@@ -379,7 +379,15 @@ public:
// parties
//
// it should return TRUE if more idle events are needed, FALSE if not
virtual bool ProcessIdle() = 0;
virtual bool ProcessIdle() ;
// Send idle event to all top-level windows.
// Returns TRUE if more idle time is requested.
virtual bool SendIdleEvents();
// Send idle event to window and all subwindows
// Returns TRUE if more idle time is requested.
virtual bool SendIdleEvents(wxWindow* win);
// top level window functions

View File

@@ -51,18 +51,11 @@ public:
virtual void Exit();
virtual bool Yield(bool onlyIfNeeded = FALSE);
virtual bool ProcessIdle();
virtual void WakeUpIdle() { CocoaRequestIdle(); }
/* Idle Processing */
void OnIdle(wxIdleEvent& event);
// Send idle event to all top-level windows.
// Returns TRUE if more idle time is requested.
bool SendIdleEvents();
// Send idle event to window and all subwindows
// Returns TRUE if more idle time is requested.
bool SendIdleEvents(wxWindowCocoa* win);
virtual bool Initialize(int& argc, wxChar **argv);
virtual void CleanUp();
virtual bool CallOnInit();

View File

@@ -1033,6 +1033,12 @@ enum wxBorder
// possibly be made to work in the future, at least on Windows
#define wxWS_EX_THEMED_BACKGROUND 0x00000008
// this window should always process idle events
#define wxWS_EX_PROCESS_IDLE 0x00000010
// this window should always process UI update events
#define wxWS_EX_PROCESS_UI_UPDATES 0x00000020
// Use this style to add a context-sensitive help to the window (currently for
// Win32 only and it doesn't work if wxMINIMIZE_BOX or wxMAXIMIZE_BOX are used)
#define wxFRAME_EX_CONTEXTHELP 0x00000004
@@ -1860,6 +1866,17 @@ enum wxPrintMode
wxPRINT_MODE_PRINTER = 3 // Send to printer
};
// ----------------------------------------------------------------------------
// UpdateWindowUI flags
// ----------------------------------------------------------------------------
enum wxUpdateUI
{
wxUPDATE_UI_NONE = 0x0000,
wxUPDATE_UI_RECURSE = 0x0001,
wxUPDATE_UI_FROMIDLE = 0x0002 // Invoked from On(Internal)Idle
};
// ----------------------------------------------------------------------------
// miscellaneous
// ----------------------------------------------------------------------------

View File

@@ -1496,6 +1496,20 @@ private:
wxEVT_UPDATE_UI
*/
// Whether to always send update events to windows, or
// to only send update events to those with the
// wxWS_EX_PROCESS_UI_UPDATES style.
enum wxUpdateUIMode
{
// Send UI update events to all windows
wxUPDATE_UI_PROCESS_ALL,
// Send UI update events to windows that have
// the wxWS_EX_PROCESS_UI_UPDATES flag specified
wxUPDATE_UI_PROCESS_SPECIFIED
};
class WXDLLIMPEXP_CORE wxUpdateUIEvent : public wxCommandEvent
{
public:
@@ -1531,18 +1545,26 @@ public:
// Sets the interval between updates in milliseconds.
// Set to -1 to disable updates, or to 0 to update as frequently as possible.
static void SetUpdateInterval(long updateInterval) { m_updateInterval = updateInterval; }
static void SetUpdateInterval(long updateInterval) { sm_updateInterval = updateInterval; }
// Returns the current interval between updates in milliseconds
static long GetUpdateInterval() { return m_updateInterval ; }
static long GetUpdateInterval() { return sm_updateInterval ; }
// Can we update?
static bool CanUpdate() ;
// Can we update this window?
static bool CanUpdate(wxWindow* win) ;
// Reset the update time to provide a delay until the next
// time we should update
static void ResetUpdateTime() ;
// Specify how wxWindows will send update events: to
// all windows, or only to those which specify that they
// will process the events.
static void SetMode(wxUpdateUIMode mode) { sm_updateMode = mode; }
// Returns the UI update mode
static wxUpdateUIMode GetMode() { return sm_updateMode ; }
virtual wxEvent *Clone() const { return new wxUpdateUIEvent(*this); }
protected:
@@ -1553,9 +1575,10 @@ protected:
bool m_setChecked;
wxString m_text;
#if wxUSE_LONGLONG
static wxLongLong m_lastUpdate;
static wxLongLong sm_lastUpdate;
#endif
static long m_updateInterval;
static long sm_updateInterval;
static wxUpdateUIMode sm_updateMode;
private:
DECLARE_DYNAMIC_CLASS(wxUpdateUIEvent)
@@ -1875,6 +1898,20 @@ private:
wxEVT_IDLE
*/
// Whether to always send idle events to windows, or
// to only send update events to those with the
// wxWS_EX_PROCESS_IDLE style.
enum wxIdleMode
{
// Send idle events to all windows
wxIDLE_PROCESS_ALL,
// Send idle events to windows that have
// the wxWS_EX_PROCESS_IDLE flag specified
wxIDLE_PROCESS_SPECIFIED
};
class WXDLLIMPEXP_CORE wxIdleEvent : public wxEvent
{
public:
@@ -1892,8 +1929,20 @@ public:
virtual wxEvent *Clone() const { return new wxIdleEvent(*this); }
// Specify how wxWindows will send idle events: to
// all windows, or only to those which specify that they
// will process the events.
static void SetMode(wxIdleMode mode) { sm_idleMode = mode; }
// Returns the idle event mode
static wxIdleMode GetMode() { return sm_idleMode ; }
// Can we send an idle event?
static bool CanSend(wxWindow* win) ;
protected:
bool m_requestMore;
static wxIdleMode sm_idleMode;
private:
DECLARE_DYNAMIC_CLASS(wxIdleEvent)

View File

@@ -141,7 +141,6 @@ public:
// -------------------------------
// event handlers
void OnIdle(wxIdleEvent& event);
void OnMenuOpen(wxMenuEvent& event);
void OnMenuHighlight(wxMenuEvent& event);
@@ -151,6 +150,12 @@ public:
void DoMenuUpdates(wxMenu* menu, wxWindow* focusWin);
#endif // wxUSE_MENUS
// do the UI update processing for this window
virtual void UpdateWindowUI(long flags = wxUPDATE_UI_NONE);
// Implement internal behaviour (menu updating on some platforms)
virtual void OnInternalIdle();
// if there is no real wxTopLevelWindow on this platform we have to define
// some wxTopLevelWindowBase pure virtual functions here to avoid breaking
// old ports (wxMotif) which don't define them in wxFrame

View File

@@ -50,13 +50,10 @@ public:
virtual void Exit();
virtual bool Yield(bool onlyIfNeeded = FALSE);
virtual bool ProcessIdle();
virtual void WakeUpIdle();
// implementation only from now on
void OnIdle( wxIdleEvent &event );
bool SendIdleEvents();
bool SendIdleEvents( wxWindow* win );
virtual bool Initialize(int& argc, wxChar **argv);
virtual void CleanUp();
@@ -90,8 +87,6 @@ private:
bool m_isInAssert;
#endif // __WXDEBUG__
bool CallInternalIdle( wxWindow* win );
DECLARE_DYNAMIC_CLASS(wxApp)
DECLARE_EVENT_TABLE()
};

View File

@@ -50,13 +50,10 @@ public:
virtual void Exit();
virtual bool Yield(bool onlyIfNeeded = FALSE);
virtual bool ProcessIdle();
virtual void WakeUpIdle();
// implementation only from now on
void OnIdle( wxIdleEvent &event );
bool SendIdleEvents();
bool SendIdleEvents( wxWindow* win );
virtual bool Initialize(int& argc, wxChar **argv);
virtual void CleanUp();
@@ -90,8 +87,6 @@ private:
bool m_isInAssert;
#endif // __WXDEBUG__
bool CallInternalIdle( wxWindow* win );
DECLARE_DYNAMIC_CLASS(wxApp)
DECLARE_EVENT_TABLE()
};

View File

@@ -56,7 +56,6 @@ class WXDLLEXPORT wxApp: public wxAppBase
virtual void Exit();
virtual bool Yield(bool onlyIfNeeded = FALSE);
virtual bool ProcessIdle();
virtual void WakeUpIdle();
virtual void SetPrintMode(int mode) { m_printMode = mode; }
@@ -71,14 +70,6 @@ class WXDLLEXPORT wxApp: public wxAppBase
void OnEndSession(wxCloseEvent& event);
void OnQueryEndSession(wxCloseEvent& event);
// Send idle event to all top-level windows.
// Returns TRUE if more idle time is requested.
bool SendIdleEvents();
// Send idle event to window and all subwindows
// Returns TRUE if more idle time is requested.
bool SendIdleEvents(wxWindowMac* win);
// Windows only, but for compatibility...
inline void SetAuto3D(bool flag) { m_auto3D = flag; }
inline bool GetAuto3D() const { return m_auto3D; }

View File

@@ -173,7 +173,6 @@ public:
void OnSetFocus(wxFocusEvent& event) ;
void OnNcPaint(wxNcPaintEvent& event);
void OnEraseBackground(wxEraseEvent& event);
void OnIdle(wxIdleEvent& event);
void OnMouseEvent( wxMouseEvent &event ) ;
void MacOnScroll(wxScrollEvent&event ) ;
@@ -181,6 +180,8 @@ public:
bool AcceptsFocus() const ;
public:
void OnInternalIdle();
// For implementation purposes - sometimes decorations make the client area
// smaller
virtual wxPoint GetClientAreaOrigin() const;

View File

@@ -47,12 +47,9 @@ public:
virtual bool Initialized();
virtual bool Pending();
virtual void Dispatch();
virtual bool ProcessIdle();
// implementation only from now on
void OnIdle(wxIdleEvent &event);
bool SendIdleEvents();
bool SendIdleEvents(wxWindow* win);
virtual bool Initialize(int& argc, wxChar **argv);
virtual void CleanUp();

View File

@@ -135,7 +135,7 @@ protected:
// themselves inside the given rectangle
virtual void DoMoveWindow(int x, int y, int width, int height);
void OnIdle(wxIdleEvent& event);
void OnInternalIdle();
private:
// common part of all ctors

View File

@@ -59,7 +59,6 @@ public:
virtual void Exit();
virtual bool Yield(bool onlyIfNeeded = FALSE);
virtual bool ProcessIdle();
virtual void WakeUpIdle(); // implemented in motif/evtloop.cpp
virtual bool OnInitGui();
@@ -69,14 +68,6 @@ public:
void OnIdle(wxIdleEvent& event);
// Send idle event to all top-level windows.
// Returns TRUE if more idle time is requested.
bool SendIdleEvents();
// Send idle event to window and all subwindows
// Returns TRUE if more idle time is requested.
bool SendIdleEvents(wxWindow* win);
protected:
bool m_showOnInit;

View File

@@ -151,11 +151,11 @@ public:
// For implementation purposes - sometimes decorations make the client area
// smaller
virtual wxPoint GetClientAreaOrigin() const;
// Process idle (send update events)
void OnInternalIdle();
protected:
// event handlers (not virtual by design)
void OnIdle(wxIdleEvent& event);
// Responds to colour changes: passes event on to children.
void OnSysColourChanged(wxSysColourChangedEvent& event);

View File

@@ -46,7 +46,6 @@ public:
virtual void Dispatch();
virtual bool Yield(bool onlyIfNeeded = FALSE);
virtual bool ProcessIdle();
virtual void WakeUpIdle();
virtual void SetPrintMode(int mode) { m_printMode = mode; }
@@ -57,14 +56,6 @@ public:
void OnEndSession(wxCloseEvent& event);
void OnQueryEndSession(wxCloseEvent& event);
// Send idle event to all top-level windows.
// Returns TRUE if more idle time is requested.
bool SendIdleEvents();
// Send idle event to window and all subwindows
// Returns TRUE if more idle time is requested.
bool SendIdleEvents(wxWindow* win);
protected:
int m_printMode; // wxPRINT_WINDOWS, wxPRINT_POSTSCRIPT

View File

@@ -128,6 +128,9 @@ protected:
// window proc for the frames
long MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
// handle WM_INITMENU message
bool HandleInitMenu();
virtual bool IsMDIChild() const { return FALSE; }
// get default (wxWindows) icon for the frame

View File

@@ -191,7 +191,6 @@ public:
// --------------
void OnEraseBackground(wxEraseEvent& event);
void OnIdle(wxIdleEvent& event);
void OnPaint(wxPaintEvent& event);
public:
@@ -415,6 +414,10 @@ public:
// check if mouse is in the window
bool IsMouseInWindow() const;
// virtual function for implementing internal idle
// behaviour
virtual void OnInternalIdle() ;
protected:
// the window handle
WXHWND m_hWnd;

View File

@@ -80,7 +80,6 @@ public:
virtual void Exit();
virtual bool Yield(bool onlyIfNeeded = FALSE);
virtual bool ProcessIdle(void);
virtual void WakeUpIdle(void);
virtual void SetPrintMode(int mode) { m_nPrintMode = mode; }
@@ -91,14 +90,6 @@ public:
void OnEndSession(wxCloseEvent& rEvent);
void OnQueryEndSession(wxCloseEvent& rEvent);
// Send idle event to all top-level windows.
// Returns TRUE if more idle time is requested.
bool SendIdleEvents(void);
// Send idle event to window and all subwindows
// Returns TRUE if more idle time is requested.
bool SendIdleEvents(wxWindow* pWin);
void SetAuto3D(bool bFlag) { m_bAuto3D = bFlag; }
bool GetAuto3D(void) const { return m_bAuto3D; }

View File

@@ -525,10 +525,8 @@ public:
size_t GetToolsCount() const { return m_tools.GetCount(); }
void OnIdle(wxIdleEvent& event);
// Do the toolbar button updates (check for EVT_UPDATE_UI handlers)
virtual void DoToolbarUpdates();
virtual void UpdateWindowUI(long flags = wxUPDATE_UI_NONE) ;
// don't want toolbars to accept the focus
virtual bool AcceptsFocus() const { return FALSE; }

View File

@@ -334,6 +334,9 @@ public:
wxTextCtrl& operator<<(double d);
wxTextCtrl& operator<<(const wxChar c);
// do the window-specific processing after processing the update event
virtual void DoUpdateWindowUI(wxUpdateUIEvent& event) ;
// obsolete functions
#if WXWIN_COMPATIBILITY
bool Modified() const { return IsModified(); }

View File

@@ -134,6 +134,9 @@ public:
// so should be there for all platforms
void OnActivate(wxActivateEvent &WXUNUSED(event)) { }
// do the window-specific processing after processing the update event
virtual void DoUpdateWindowUI(wxUpdateUIEvent& event) ;
protected:
// the frame client to screen translation should take account of the
// toolbar which may shift the origin of the client area

View File

@@ -169,6 +169,8 @@ public:
// let wxColourScheme choose the right colours for us
virtual bool IsContainerWindow() const { return TRUE; }
// idle processing
virtual void OnInternalIdle();
protected:
// geometry
virtual wxSize DoGetBestClientSize() const;
@@ -183,7 +185,6 @@ protected:
void Init();
// event handlers
void OnIdle(wxIdleEvent& event);
void OnSize(wxSizeEvent& event);
// common part of Clear() and DoSetItems(): clears everything

View File

@@ -119,14 +119,14 @@ public:
// for wxControlRenderer::DrawScrollbar() only
const wxScrollArrows& GetArrows() const { return m_arrows; }
// idle processing
virtual void OnInternalIdle();
protected:
virtual wxSize DoGetBestClientSize() const;
virtual void DoDraw(wxControlRenderer *renderer);
virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
// event handlers
void OnIdle(wxIdleEvent& event);
// forces update of thumb's visual appearence (does nothing if m_dirty=FALSE)
void UpdateThumb();

View File

@@ -455,7 +455,6 @@ protected:
// event handlers
// --------------
void OnIdle(wxIdleEvent& event);
void OnChar(wxKeyEvent& event);
void OnSize(wxSizeEvent& event);
@@ -476,6 +475,8 @@ protected:
bool DoCut();
bool DoPaste();
// idle processing
virtual void OnInternalIdle();
private:
// all these methods are for multiline text controls only

View File

@@ -688,7 +688,11 @@ public:
// get border for the flags of this window
wxBorder GetBorder() const { return GetBorder(GetWindowStyleFlag()); }
void UpdateWindowUI();
// send wxUpdateUIEvents to this window, and children if recurse is TRUE
virtual void UpdateWindowUI(long flags = wxUPDATE_UI_NONE);
// do the window-specific processing after processing the update event
virtual void DoUpdateWindowUI(wxUpdateUIEvent& event) ;
#if wxUSE_MENUS
bool PopupMenu( wxMenu *menu, const wxPoint& pos )
@@ -858,7 +862,14 @@ public:
void OnHelp(wxHelpEvent& event);
#endif // wxUSE_HELP
// get the haqndle of the window for the underlying window system: this
// virtual function for implementing internal idle
// behaviour
virtual void OnInternalIdle() {}
// call internal idle recursively
void ProcessInternalIdle() ;
// get the handle of the window for the underlying window system: this
// is only used for wxWin itself or for user code which wants to call
// platform-specific APIs
virtual WXWidget GetHandle() const = 0;

View File

@@ -59,7 +59,6 @@ public:
virtual void Exit();
virtual bool Yield(bool onlyIfNeeded = FALSE);
virtual bool ProcessIdle();
virtual void WakeUpIdle();
virtual bool OnInitGui();
@@ -69,14 +68,6 @@ public:
void OnIdle(wxIdleEvent& event);
// Send idle event to all top-level windows.
// Returns TRUE if more idle time is requested.
bool SendIdleEvents();
// Send idle event to window and all subwindows
// Returns TRUE if more idle time is requested.
bool SendIdleEvents(wxWindow* win);
// Processes an X event.
virtual bool ProcessXEvent(WXEvent* event);

View File

@@ -248,10 +248,10 @@ public:
void OnEraseBackground( wxEraseEvent &event );
void OnMouse( wxMouseEvent &event );
void OnChar( wxKeyEvent &event );
void OnIdle( wxIdleEvent &event );
void OnSetFocus( wxFocusEvent& event );
void OnKillFocus( wxFocusEvent& event );
void OnInternalIdle();
void RefreshLine( int n );
void RefreshDown( int n );
void MoveCursor( int new_x, int new_y, bool shift = FALSE, bool centre = FALSE );

View File

@@ -155,9 +155,6 @@ public:
// OnInternalIdle
virtual void OnInternalIdle();
// For compatibility across platforms (not in event table)
void OnIdle(wxIdleEvent& WXUNUSED(event)) {}
protected:
// Responds to colour changes: passes event on to children.
void OnSysColourChanged(wxSysColourChangedEvent& event);