Implement sending wxIconizeEvent in wxOSX.

Translate windowDid{Miniaturize,Deminiaturize} callbacks to calls to
SendIconizeEvent().

See #16718.
This commit is contained in:
Rob Krakora 2015-07-18 01:15:29 +02:00 committed by Vadim Zeitlin
parent 563329f89f
commit 31e1387541
6 changed files with 47 additions and 3 deletions

View File

@ -113,7 +113,8 @@ public:
virtual void HandleResized( double timestampsec );
virtual void HandleMoved( double timestampsec );
virtual void HandleResizing( double timestampsec, wxRect* rect );
virtual void HandleMiniaturize( double WXUNUSED(timestampsec), bool miniaturized );
void WindowWasPainted();
virtual bool Destroy();

View File

@ -82,6 +82,9 @@ public:
virtual void SetRepresentedFilename(const wxString& filename);
// do *not* call this to iconize the frame, this is a private function!
void OSXSetIconizeState(bool iconic);
protected:
// common part of all ctors
void Init();
@ -92,6 +95,7 @@ protected:
// should the frame be maximized when it will be shown? set by Maximize()
// when it is called while the frame is hidden
bool m_maximizeOnShow;
private :
wxDECLARE_EVENT_TABLE();
};

View File

@ -4263,8 +4263,6 @@ public:
An event being sent when the frame is iconized (minimized) or restored.
Currently only wxMSW and wxGTK generate such events.
@onlyfor{wxmsw,wxgtk}
@beginEventTable{wxIconizeEvent}

View File

@ -322,6 +322,8 @@ static NSResponder* s_formerFirstResponder = NULL;
- (void)windowDidResignKey:(NSNotification *)notification;
- (void)windowDidBecomeKey:(NSNotification *)notification;
- (void)windowDidMove:(NSNotification *)notification;
- (void)windowDidMiniaturize:(NSNotification *)notification;
- (void)windowDidDeminiaturize:(NSNotification *)notification;
- (BOOL)windowShouldClose:(id)window;
- (BOOL)windowShouldZoom:(NSWindow *)window toFrame:(NSRect)newFrame;
#if wxHAS_FULL_SCREEN_API
@ -413,6 +415,28 @@ extern int wxOSXGetIdFromSelector(SEL action );
[self triggerMenu:_cmd];
}
- (void)windowDidMiniaturize:(NSNotification *)notification
{
NSWindow* window = (NSWindow*) [notification object];
wxNonOwnedWindowCocoaImpl* windowimpl = [window WX_implementation];
if ( windowimpl )
{
if ( wxNonOwnedWindow* wxpeer = windowimpl->GetWXPeer() )
wxpeer->HandleMiniaturize(0, [window isMiniaturized]);
}
}
- (void)windowDidDeminiaturize:(NSNotification *)notification
{
NSWindow* window = (NSWindow*) [notification object];
wxNonOwnedWindowCocoaImpl* windowimpl = [window WX_implementation];
if ( windowimpl )
{
if ( wxNonOwnedWindow* wxpeer = windowimpl->GetWXPeer() )
wxpeer->HandleMiniaturize(0, [window isMiniaturized]);
}
}
- (BOOL)windowShouldClose:(id)nwindow
{
wxNonOwnedWindowCocoaImpl* windowimpl = [(NSWindow*) nwindow WX_implementation];

View File

@ -552,4 +552,12 @@ bool wxNonOwnedWindow::DoSetPathShape(const wxGraphicsPath& path)
return DoSetRegionShape(wxRegion(bmp));
}
void
wxNonOwnedWindow::HandleMiniaturize(double WXUNUSED(timestampsec),
bool miniaturized)
{
if ( wxTopLevelWindowMac* top = (wxTopLevelWindowMac*) MacGetTopLevelWindow() )
top->OSXSetIconizeState(miniaturized);
}
#endif // wxUSE_GRAPHICS_CONTEXT

View File

@ -229,3 +229,12 @@ void wxTopLevelWindowMac::SetRepresentedFilename(const wxString& filename)
{
m_nowpeer->SetRepresentedFilename(filename);
}
void wxTopLevelWindowMac::OSXSetIconizeState(bool iconize)
{
if ( iconize != m_iconized )
{
m_iconized = iconize;
(void)SendIconizeEvent(iconize);
}
}