Make wxTaskBarIcon's ctor have the same API on all platforms even though setting the icon type can only be done on wxOSX-cocoa

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71242 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn 2012-04-20 05:41:54 +00:00
parent b83b7724da
commit 70175534bf
9 changed files with 39 additions and 25 deletions

View File

@ -14,7 +14,7 @@
class WXDLLIMPEXP_ADV wxTaskBarIcon: public wxTaskBarIconBase class WXDLLIMPEXP_ADV wxTaskBarIcon: public wxTaskBarIconBase
{ {
public: public:
wxTaskBarIcon(); wxTaskBarIcon(wxTaskBarIconType iconType = wxTBI_DEFAULT_TYPE);
~wxTaskBarIcon(); ~wxTaskBarIcon();
virtual bool SetIcon(const wxIcon& icon, const wxString& tooltip = wxString()); virtual bool SetIcon(const wxIcon& icon, const wxString& tooltip = wxString());
virtual bool RemoveIcon(); virtual bool RemoveIcon();

View File

@ -21,7 +21,7 @@ class WXDLLIMPEXP_FWD_ADV wxTaskBarIconWindow;
class WXDLLIMPEXP_ADV wxTaskBarIcon : public wxTaskBarIconBase class WXDLLIMPEXP_ADV wxTaskBarIcon : public wxTaskBarIconBase
{ {
public: public:
wxTaskBarIcon(); wxTaskBarIcon(wxTaskBarIconType iconType = wxTBI_DEFAULT_TYPE);
virtual ~wxTaskBarIcon(); virtual ~wxTaskBarIcon();
// Accessors // Accessors

View File

@ -19,21 +19,7 @@ class WXDLLIMPEXP_ADV wxTaskBarIcon : public wxTaskBarIconBase
{ {
DECLARE_DYNAMIC_CLASS_NO_COPY(wxTaskBarIcon) DECLARE_DYNAMIC_CLASS_NO_COPY(wxTaskBarIcon)
public: public:
// type of taskbar item to create (currently only DOCK is implemented) wxTaskBarIcon(wxTaskBarIconType iconType = wxTBI_DEFAULT_TYPE);
enum wxTaskBarIconType
{
DOCK
#if wxOSX_USE_COCOA
, CUSTOM_STATUSITEM
#endif
#if wxOSX_USE_COCOA
, DEFAULT_TYPE = CUSTOM_STATUSITEM
#else
, DEFAULT_TYPE = DOCK
#endif
};
wxTaskBarIcon(wxTaskBarIconType iconType = DEFAULT_TYPE);
virtual ~wxTaskBarIcon(); virtual ~wxTaskBarIcon();
// returns true if the taskbaricon is in the global menubar // returns true if the taskbaricon is in the global menubar

View File

@ -20,6 +20,21 @@
class WXDLLIMPEXP_FWD_ADV wxTaskBarIconEvent; class WXDLLIMPEXP_FWD_ADV wxTaskBarIconEvent;
// ----------------------------------------------------------------------------
// type of taskbar item to create. Only applicable in wxOSX_COCOA
enum wxTaskBarIconType
{
wxTBI_DOCK,
wxTBI_CUSTOM_STATUSITEM,
#if wxOSX_USE_COCOA
wxTBI_DEFAULT_TYPE = wxTBI_CUSTOM_STATUSITEM
#else
wxTBI_DEFAULT_TYPE = wxTBI_DOCK
#endif
};
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxTaskBarIconBase: define wxTaskBarIcon interface // wxTaskBarIconBase: define wxTaskBarIcon interface
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@ -6,6 +6,18 @@
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
/**
On OSX Cocoa the taskbar icon can be in the doc or in the status area.
This enumeration can be used to select which will be instantiated.
*/
enum wxTaskBarIconType
{
wxTBI_DOCK,
wxTBI_CUSTOM_STATUSITEM,
wxTBI_DEFAULT_TYPE
};
/** /**
@class wxTaskBarIconEvent @class wxTaskBarIconEvent
@ -26,6 +38,7 @@ public:
wxTaskBarIconEvent(wxEventType evtType, wxTaskBarIcon *tbIcon); wxTaskBarIconEvent(wxEventType evtType, wxTaskBarIcon *tbIcon);
}; };
/** /**
@class wxTaskBarIcon @class wxTaskBarIcon
@ -79,9 +92,9 @@ class wxTaskBarIcon : public wxEvtHandler
{ {
public: public:
/** /**
Default constructor. Default constructor. The iconType is only applicable on wxOSX_Cocoa.
*/ */
wxTaskBarIcon(); wxTaskBarIcon(wxTaskBarIconType iconType = wxTBI_DEFAULT_TYPE);
/** /**
Destroys the wxTaskBarIcon object, removing the icon if not already removed. Destroys the wxTaskBarIcon object, removing the icon if not already removed.

View File

@ -266,7 +266,7 @@ void wxTaskBarIcon::Private::size_allocate(int width, int height)
IMPLEMENT_DYNAMIC_CLASS(wxTaskBarIcon, wxEvtHandler) IMPLEMENT_DYNAMIC_CLASS(wxTaskBarIcon, wxEvtHandler)
wxTaskBarIcon::wxTaskBarIcon() wxTaskBarIcon::wxTaskBarIcon(wxTaskBarIconType WXUNUSED(iconType))
{ {
m_priv = new Private(this); m_priv = new Private(this);
} }

View File

@ -177,7 +177,7 @@ struct NotifyIconData : public NOTIFYICONDATA
// wxTaskBarIcon // wxTaskBarIcon
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
wxTaskBarIcon::wxTaskBarIcon() wxTaskBarIcon::wxTaskBarIcon(wxTaskBarIconType WXUNUSED(iconType))
{ {
m_win = NULL; m_win = NULL;
m_iconAdded = false; m_iconAdded = false;

View File

@ -469,8 +469,8 @@ IMPLEMENT_DYNAMIC_CLASS(wxTaskBarIcon, wxEvtHandler)
wxTaskBarIcon::wxTaskBarIcon(wxTaskBarIconType WXUNUSED_UNLESS_DEBUG(nType)) wxTaskBarIcon::wxTaskBarIcon(wxTaskBarIconType WXUNUSED_UNLESS_DEBUG(nType))
{ {
wxASSERT_MSG( wxASSERT_MSG(
nType == DOCK, nType == wxTBI_DOCK,
wxT("Only the DOCK implementation of wxTaskBarIcon on Mac-Carbon is currently supported!") ); wxT("Only the wxTBI_DOCK implementation of wxTaskBarIcon on Mac-Carbon is currently supported!") );
m_impl = new wxDockTaskBarIcon(this); m_impl = new wxDockTaskBarIcon(this);
} }

View File

@ -141,9 +141,9 @@ IMPLEMENT_DYNAMIC_CLASS(wxTaskBarIcon, wxEvtHandler)
wxTaskBarIcon::wxTaskBarIcon(wxTaskBarIconType iconType) wxTaskBarIcon::wxTaskBarIcon(wxTaskBarIconType iconType)
{ {
if(iconType == DOCK) if(iconType == wxTBI_DOCK)
m_impl = new wxTaskBarIconDockImpl(this); m_impl = new wxTaskBarIconDockImpl(this);
else if(iconType == CUSTOM_STATUSITEM) else if(iconType == wxTBI_CUSTOM_STATUSITEM)
m_impl = new wxTaskBarIconCustomStatusItemImpl(this); m_impl = new wxTaskBarIconCustomStatusItemImpl(this);
else else
{ m_impl = NULL; { m_impl = NULL;