Add wxTopLevelWindow::Enable{Maximize,Minimize}Button()
Allow to disable maximize and minimize buttons dynamically just as we already allow to disable the "Close" button using EnableCloseButton(). Currently implemented for MSW and OSX only. Closes #17133.
This commit is contained in:
parent
6055d8d0a5
commit
fe9a5f47f4
@ -85,6 +85,7 @@ All (GUI):
|
||||
- Add wxAppProgressIndicator for MSW (Chaobin Zhang) and OS X (Tobias Taschner).
|
||||
- Add wxEVT_MAGNIFY mouse event (Joost Nieuwenhuijse).
|
||||
- Add wxProcess::Activate().
|
||||
- Add wxTopLevelWindow::Enable{Maximize,Minimize}Button() (John Roberts).
|
||||
- Make results of wxDC::DrawEllipticArc() consistent across all platforms.
|
||||
- XRC handler for wxAuiToolBar added (Kinaou Hervé, David Hart).
|
||||
- Improve wxLIST_AUTOSIZE_XXX support in generic wxListCtrl (Kinaou Hervé).
|
||||
|
@ -68,6 +68,8 @@ public:
|
||||
// wxMSW only: EnableCloseButton(false) may be used to remove the "Close"
|
||||
// button from the title bar
|
||||
virtual bool EnableCloseButton(bool enable = true);
|
||||
virtual bool EnableMaximizeButton(bool enable = true) wxOVERRIDE;
|
||||
virtual bool EnableMinimizeButton(bool enable = true) wxOVERRIDE;
|
||||
|
||||
// Set window transparency if the platform supports it
|
||||
virtual bool SetTransparent(wxByte alpha);
|
||||
|
@ -232,6 +232,8 @@ public :
|
||||
virtual void SetTitle( const wxString& title, wxFontEncoding encoding ) ;
|
||||
|
||||
virtual bool EnableCloseButton(bool enable) wxOVERRIDE;
|
||||
virtual bool EnableMaximizeButton(bool enable) wxOVERRIDE;
|
||||
virtual bool EnableMinimizeButton(bool enable) wxOVERRIDE;
|
||||
|
||||
virtual bool IsMaximized() const;
|
||||
|
||||
|
@ -848,6 +848,8 @@ public :
|
||||
virtual void SetTitle( const wxString& title, wxFontEncoding encoding ) = 0;
|
||||
|
||||
virtual bool EnableCloseButton(bool enable) = 0;
|
||||
virtual bool EnableMaximizeButton(bool enable) = 0;
|
||||
virtual bool EnableMinimizeButton(bool enable) = 0;
|
||||
|
||||
virtual bool IsMaximized() const = 0;
|
||||
|
||||
|
@ -77,6 +77,8 @@ public:
|
||||
// EnableCloseButton(false) used to disable the "Close"
|
||||
// button on the title bar
|
||||
virtual bool EnableCloseButton(bool enable = true) wxOVERRIDE;
|
||||
virtual bool EnableMaximizeButton(bool enable = true) wxOVERRIDE;
|
||||
virtual bool EnableMinimizeButton(bool enable = true) wxOVERRIDE;
|
||||
|
||||
virtual void SetLabel(const wxString& label) { SetTitle( label ); }
|
||||
virtual wxString GetLabel() const { return GetTitle(); }
|
||||
|
@ -206,6 +206,8 @@ public:
|
||||
|
||||
// enable/disable close button [x]
|
||||
virtual bool EnableCloseButton(bool WXUNUSED(enable) = true) { return false; }
|
||||
virtual bool EnableMaximizeButton(bool WXUNUSED(enable) = true) { return false; }
|
||||
virtual bool EnableMinimizeButton(bool WXUNUSED(enable) = true) { return false; }
|
||||
|
||||
// Attracts the users attention to this window if the application is
|
||||
// inactive (should be called when a background event occurs)
|
||||
|
@ -148,6 +148,39 @@ public:
|
||||
*/
|
||||
virtual bool EnableCloseButton(bool enable = true);
|
||||
|
||||
/**
|
||||
Enables or disables the Maximize button (in the right or left upper
|
||||
corner of a frame or dialog).
|
||||
|
||||
Currently only implemented for wxMSW and wxOSX.
|
||||
|
||||
The window style must contain wxMAXIMIZE_BOX.
|
||||
|
||||
Returns @true if operation was successful. Note that a successful
|
||||
operation does not change the window style flags.
|
||||
|
||||
@since 3.1.0
|
||||
*/
|
||||
virtual bool EnableMaximizeButton(bool enable = true);
|
||||
|
||||
/**
|
||||
Enables or disables the Minimize button (in the right or left upper
|
||||
corner of a frame or dialog).
|
||||
|
||||
Currently only implemented for wxMSW and wxOSX.
|
||||
|
||||
The window style must contain wxMINIMIZE_BOX.
|
||||
|
||||
Note that in wxMSW a successful operation will change the window
|
||||
style flags.
|
||||
|
||||
Returns @true if operation was successful. Note that a successful
|
||||
operation does not change the window style flags.
|
||||
|
||||
@since 3.1.0
|
||||
*/
|
||||
virtual bool EnableMinimizeButton(bool enable = true);
|
||||
|
||||
/**
|
||||
Returns a pointer to the button which is the default for this window, or
|
||||
@c @NULL. The default button is the one activated by pressing the Enter
|
||||
|
@ -1194,6 +1194,56 @@ bool wxTopLevelWindowMSW::EnableCloseButton(bool enable)
|
||||
return true;
|
||||
}
|
||||
|
||||
// Window must have wxCAPTION and either wxCLOSE_BOX or wxSYSTEM_MENU for the
|
||||
// button to be visible. Also check for wxMAXIMIZE_BOX because we don't want
|
||||
// to enable a button that is excluded from the current style.
|
||||
|
||||
bool wxTopLevelWindowMSW::EnableMaximizeButton(bool enable)
|
||||
{
|
||||
if ( ( HasFlag(wxCAPTION) &&
|
||||
( HasFlag(wxCLOSE_BOX) || HasFlag(wxSYSTEM_MENU) ) ) &&
|
||||
HasFlag(wxMAXIMIZE_BOX) )
|
||||
{
|
||||
if ( enable )
|
||||
{
|
||||
SetWindowStyleFlag(GetWindowStyleFlag() | wxMAXIMIZE_BOX);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetWindowStyleFlag(GetWindowStyleFlag() ^ wxMAXIMIZE_BOX);
|
||||
// Restore the style to our internal store
|
||||
wxWindowBase::SetWindowStyleFlag(GetWindowStyle() | wxMAXIMIZE_BOX);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool wxTopLevelWindowMSW::EnableMinimizeButton(bool enable)
|
||||
{
|
||||
if ( ( HasFlag(wxCAPTION) &&
|
||||
( HasFlag(wxCLOSE_BOX) || HasFlag(wxSYSTEM_MENU) ) ) &&
|
||||
HasFlag(wxMINIMIZE_BOX) )
|
||||
{
|
||||
if ( enable )
|
||||
{
|
||||
SetWindowStyleFlag(GetWindowStyleFlag() | wxMINIMIZE_BOX);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetWindowStyleFlag(GetWindowStyleFlag() ^ wxMINIMIZE_BOX);
|
||||
// Restore the style to our internal store
|
||||
wxWindowBase::SetWindowStyleFlag(GetWindowStyle() | wxMINIMIZE_BOX);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void wxTopLevelWindowMSW::RequestUserAttention(int flags)
|
||||
{
|
||||
#if defined(FLASHW_STOP) && wxUSE_DYNLIB_CLASS
|
||||
|
@ -946,6 +946,20 @@ bool wxNonOwnedWindowCocoaImpl::EnableCloseButton(bool enable)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wxNonOwnedWindowCocoaImpl::EnableMaximizeButton(bool enable)
|
||||
{
|
||||
[[m_macWindow standardWindowButton:NSWindowZoomButton] setEnabled:enable];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wxNonOwnedWindowCocoaImpl::EnableMinimizeButton(bool enable)
|
||||
{
|
||||
[[m_macWindow standardWindowButton:NSWindowMiniaturizeButton] setEnabled:enable];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wxNonOwnedWindowCocoaImpl::IsMaximized() const
|
||||
{
|
||||
if (([m_macWindow styleMask] & NSResizableWindowMask) != 0)
|
||||
|
@ -215,6 +215,23 @@ bool wxTopLevelWindowMac::EnableCloseButton(bool enable)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool wxTopLevelWindowMac::EnableMaximizeButton(bool enable)
|
||||
{
|
||||
// Both wxRESIZE_BORDER and wxMAXIMIZE_BOX create a resize border and
|
||||
// add a maximize button.
|
||||
if ( HasFlag(wxMAXIMIZE_BOX) || HasFlag(wxRESIZE_BORDER) )
|
||||
return m_nowpeer->EnableMaximizeButton( enable);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool wxTopLevelWindowMac::EnableMinimizeButton(bool enable)
|
||||
{
|
||||
if ( HasFlag(wxMINIMIZE_BOX) )
|
||||
return m_nowpeer->EnableMinimizeButton( enable);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void wxTopLevelWindowMac::RequestUserAttention(int flags)
|
||||
{
|
||||
return m_nowpeer->RequestUserAttention(flags);
|
||||
|
Loading…
Reference in New Issue
Block a user