From efb2fa41ff7dd0253b33ca4477c2642806574090 Mon Sep 17 00:00:00 2001 From: Kevin Ollivier Date: Mon, 7 Dec 2009 01:54:21 +0000 Subject: [PATCH] Add wxTLW::SetModified to allow apps to set the TLW's dirty state. On Mac this gives us the dot in the close button, not implemented elsewhere yet. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62796 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/osx/cocoa/private.h | 3 +++ include/wx/osx/core/private.h | 3 +++ include/wx/osx/toplevel.h | 3 +++ include/wx/toplevel.h | 5 +++++ interface/wx/toplevel.h | 12 ++++++++++++ src/osx/cocoa/nonownedwnd.mm | 10 ++++++++++ src/osx/toplevel_osx.cpp | 10 ++++++++++ 7 files changed, 46 insertions(+) diff --git a/include/wx/osx/cocoa/private.h b/include/wx/osx/cocoa/private.h index caf331cf2a..65991e48df 100644 --- a/include/wx/osx/cocoa/private.h +++ b/include/wx/osx/cocoa/private.h @@ -244,6 +244,9 @@ public : virtual void WindowToScreen( int *x, int *y ); virtual bool IsActive(); + + virtual void SetModified(bool modified); + virtual bool GetModified() const; wxNonOwnedWindow* GetWXPeer() { return m_wxPeer; } protected : diff --git a/include/wx/osx/core/private.h b/include/wx/osx/core/private.h index 3326b1f1c8..59d4841241 100644 --- a/include/wx/osx/core/private.h +++ b/include/wx/osx/core/private.h @@ -753,6 +753,9 @@ public : static wxNonOwnedWindowImpl* CreateNonOwnedWindow( wxNonOwnedWindow* wxpeer, wxWindow* parent, const wxPoint& pos, const wxSize& size, long style, long extraStyle, const wxString& name ) ; + + virtual void SetModified(bool WXUNUSED(modified)) { } + virtual bool GetModified() const { return false; } protected : wxNonOwnedWindow* m_wxPeer; diff --git a/include/wx/osx/toplevel.h b/include/wx/osx/toplevel.h index 80ccb39ed5..1e7f864463 100644 --- a/include/wx/osx/toplevel.h +++ b/include/wx/osx/toplevel.h @@ -75,6 +75,9 @@ public: virtual void SetTitle( const wxString& title); virtual wxString GetTitle() const; + virtual void SetModified(bool modified); + virtual bool GetModified() const; + protected: // common part of all ctors void Init(); diff --git a/include/wx/toplevel.h b/include/wx/toplevel.h index 93490abc3c..53213dd885 100644 --- a/include/wx/toplevel.h +++ b/include/wx/toplevel.h @@ -256,6 +256,9 @@ public: // a different API for SetSizeHints virtual void SetMinSize(const wxSize& minSize); virtual void SetMaxSize(const wxSize& maxSize); + + virtual void SetModified(bool modified) { m_modified = modified; } + virtual bool GetModified() const { return m_modified; } protected: // the frame client to screen translation should take account of the @@ -304,6 +307,8 @@ protected: // a temporary override of m_winDefault, use the latter if NULL wxWindowRef m_winTmpDefault; + + bool m_modified; wxDECLARE_NO_COPY_CLASS(wxTopLevelWindowBase); DECLARE_EVENT_TABLE() diff --git a/interface/wx/toplevel.h b/interface/wx/toplevel.h index acb79b1c72..d712256b50 100644 --- a/interface/wx/toplevel.h +++ b/interface/wx/toplevel.h @@ -439,6 +439,18 @@ public: there are any open top level windows. */ virtual bool ShouldPreventAppExit() const; + + /** + This function sets the wxTopLevelWindow's modified state, so that the + wxTopLevelWindow can change its GUI to reflect the current state. (e.g. on + Mac, the close button gets a black dot to reflect that there are unsaved changes) + */ + virtual void SetModified(bool modified); + + /** + Returns the current modified state of the wxTopLevelWindow. + */ + virtual bool GetModified() const; /** Depending on the value of @a show parameter the window is either shown diff --git a/src/osx/cocoa/nonownedwnd.mm b/src/osx/cocoa/nonownedwnd.mm index d17540c296..10098f74f5 100644 --- a/src/osx/cocoa/nonownedwnd.mm +++ b/src/osx/cocoa/nonownedwnd.mm @@ -727,6 +727,16 @@ bool wxNonOwnedWindowCocoaImpl::IsActive() return [m_macWindow isKeyWindow]; } +void wxNonOwnedWindowCocoaImpl::SetModified(bool modified) +{ + [m_macWindow setDocumentEdited:modified]; +} + +bool wxNonOwnedWindowCocoaImpl::GetModified() const +{ + return [m_macWindow isDocumentEdited]; +} + wxNonOwnedWindowImpl* wxNonOwnedWindowImpl::CreateNonOwnedWindow( wxNonOwnedWindow* wxpeer, wxWindow* parent, const wxPoint& pos, const wxSize& size, long style, long extraStyle, const wxString& name ) { diff --git a/src/osx/toplevel_osx.cpp b/src/osx/toplevel_osx.cpp index 5ad97e65c3..cd91ccb82b 100644 --- a/src/osx/toplevel_osx.cpp +++ b/src/osx/toplevel_osx.cpp @@ -186,3 +186,13 @@ bool wxTopLevelWindowMac::IsActive() { return m_nowpeer->IsActive(); } + +void wxTopLevelWindowMac::SetModified(bool modified) +{ + m_nowpeer->SetModified(modified); +} + +bool wxTopLevelWindowMac::GetModified() const +{ + return m_nowpeer->GetModified(); +} \ No newline at end of file -- 2.45.2