added wxTaskBarIcon::IsAvailable
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@55991 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
b15f9375cb
commit
cf78bdcb68
@ -20,7 +20,7 @@ public:
|
||||
wxTaskBarIconAreaBase();
|
||||
|
||||
// Returns true if SYSTRAY protocol is supported by the desktop
|
||||
bool IsProtocolSupported();
|
||||
static bool IsProtocolSupported();
|
||||
|
||||
wxEvtHandler *m_invokingWindow;
|
||||
|
||||
|
@ -29,6 +29,12 @@ class WXDLLIMPEXP_ADV wxTaskBarIconBase : public wxEvtHandler
|
||||
public:
|
||||
wxTaskBarIconBase() { }
|
||||
|
||||
#if defined(__WXGTK__) || defined(__WXX11__) || defined(__WXMOTIF__)
|
||||
static bool IsAvailable();
|
||||
#else
|
||||
static bool IsAvailable() { return true; };
|
||||
#endif
|
||||
|
||||
// Operations:
|
||||
virtual bool SetIcon(const wxIcon& icon,
|
||||
const wxString& tooltip = wxEmptyString) = 0;
|
||||
|
@ -72,5 +72,28 @@ public:
|
||||
Sets the icon, and optional tooltip text.
|
||||
*/
|
||||
bool SetIcon(const wxIcon& icon, const wxString& tooltip);
|
||||
|
||||
/**
|
||||
Returns true if system tray is available in the desktop environment the
|
||||
app runs under.
|
||||
|
||||
On Windows and Mac OS X, the tray is always available and this function
|
||||
simply returns true.
|
||||
|
||||
On Unix, X11 environment may or may not provide the tray, depending on
|
||||
user's desktop environment. Most modern desktops support the tray via
|
||||
the System Tray Protocol by freedesktop.org
|
||||
(http://freedesktop.org/wiki/Specifications/systemtray-spec).
|
||||
|
||||
@note Tray availability may change during application's lifetime
|
||||
under X11 and so applications shouldn't cache the result.
|
||||
|
||||
@note wxTaskBarIcon supports older GNOME 1.2 and KDE 1/2 methods of
|
||||
adding icons to tray, but they are unreliable and this method
|
||||
doesn't detect them.
|
||||
|
||||
@since 2.9.0
|
||||
*/
|
||||
static bool IsAvailable();
|
||||
};
|
||||
|
||||
|
@ -60,6 +60,16 @@ bool MyApp::OnInit()
|
||||
if ( !wxApp::OnInit() )
|
||||
return false;
|
||||
|
||||
if ( !wxTaskBarIcon::IsAvailable() )
|
||||
{
|
||||
wxMessageBox
|
||||
(
|
||||
"There appears to be no system tray support in your current environment. This sample may not behave as expected.",
|
||||
"Warning",
|
||||
wxOK | wxICON_EXCLAMATION
|
||||
);
|
||||
}
|
||||
|
||||
// Create the main window
|
||||
gs_dialog = new MyDialog(wxT("wxTaskBarIcon Test Dialog"));
|
||||
|
||||
|
@ -66,7 +66,7 @@
|
||||
wxDEFAULT_FRAME_STYLE | wxFRAME_NO_TASKBAR |
|
||||
wxSIMPLE_BORDER | wxFRAME_SHAPED) {}
|
||||
|
||||
bool IsProtocolSupported() const { return false; }
|
||||
static bool IsProtocolSupported() const { return false; }
|
||||
};
|
||||
#endif
|
||||
|
||||
@ -250,6 +250,15 @@ void wxTaskBarIconArea::OnMenuEvent(wxCommandEvent& event)
|
||||
m_icon->ProcessEvent(event);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxTaskBarIconBase class:
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
bool wxTaskBarIconBase::IsAvailable()
|
||||
{
|
||||
return wxTaskBarIconArea::IsProtocolSupported();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxTaskBarIcon class:
|
||||
// ----------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user