Implement sending wxIconizeEvent in wxOSX.

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

Closes #16718.

(this is a backport of 31e1387541 from master)
This commit is contained in:
Rob Krakora
2015-07-18 01:15:29 +02:00
committed by Vadim Zeitlin
parent f313ecf9b6
commit 76ee2fa0a0
7 changed files with 48 additions and 3 deletions

View File

@@ -639,6 +639,7 @@ wxOSX:
- Fix wxSearchCtrl appearance under 10.10 (John Roberts).
- Generate correct events for WXK_NUMPAD_ENTER (John Roberts).
- Fix handling of WXK_NUMPAD_ENTER in wxTextCtrl (John Roberts).
- Send wxIconizeEvent when a window is iconized/restore (Rob Krakora).
- Fix printing all pages non-interactively (John Roberts).
- Fix custom paper support (tijsv).
- Return false from wxSound::Create()/IsOk() if the file doesn't exist.

View File

@@ -114,6 +114,8 @@ public:
virtual void HandleMoved( double timestampsec );
virtual void HandleResizing( double timestampsec, wxRect* rect );
void OSXHandleMiniaturize(double WXUNUSED(timestampsec), bool miniaturized);
void WindowWasPainted();
virtual bool Destroy();

View File

@@ -81,6 +81,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();

View File

@@ -4210,8 +4210,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

@@ -309,6 +309,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;
@@ -397,6 +399,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->OSXHandleMiniaturize(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->OSXHandleMiniaturize(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::OSXHandleMiniaturize(double WXUNUSED(timestampsec),
bool miniaturized)
{
if ( wxTopLevelWindowMac* top = (wxTopLevelWindowMac*) MacGetTopLevelWindow() )
top->OSXSetIconizeState(miniaturized);
}
#endif // wxUSE_GRAPHICS_CONTEXT

View File

@@ -224,3 +224,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);
}
}