contents up previous next

wxtaskbaricon

this class represents a taskbar icon. a taskbar icon is an icon that appears in the 'system tray' and responds to mouse clicks, optionally with a tooltip above it to help provide information.

x window system note

under x window system, the window manager must support either the system tray protocol by freedesktop.org (wms used by modern desktop environments such as gnome >= 2, kde >= 3 and xfce >= 4 all do) or the older methods used in gnome 1.2 and kde 1 and 2. if it doesn't, the icon will appear as a toplevel window on user's desktop.

because not all window managers have system tray, there's no guarantee that wxtaskbaricon will work correctly under x window system and so the applications should use it only as an optional component of their user interface. the user should be required to explicitly enable the taskbar icon on unix, it shouldn't be on by default.

derived from

wxevthandler
wxobject

include files

<wx/taskbar.h>

event handling

to process input from a taskbar icon, use the following event handler macros to direct input to member functions that take a wxtaskbariconevent argument. note that not all ports are required to send these events and so it's better to override createpopupmenu if all that the application does is that it shows a popup menu in reaction to mouse click.

evt_taskbar_move(func) process a wxevt_taskbar_move event.
evt_taskbar_left_down(func) process a wxevt_taskbar_left_down event.
evt_taskbar_left_up(func) process a wxevt_taskbar_left_up event.
evt_taskbar_right_down(func) process a wxevt_taskbar_right_down event.
evt_taskbar_right_up(func) process a wxevt_taskbar_right_up event.
evt_taskbar_left_dclick(func) process a wxevt_taskbar_left_dclick event.
evt_taskbar_right_dclick(func) process a wxevt_taskbar_right_dclick event.
evt_taskbar_click(func) this is a synonym for either evt_taskbar_right_down or up depending on the platform, use this event macro to catch the event which should result in the menu being displayed on the current platform.
members

wxtaskbaricon::wxtaskbaricon
wxtaskbaricon::~wxtaskbaricon
wxtaskbaricon::createpopupmenu
wxtaskbaricon::isiconinstalled
wxtaskbaricon::isok
wxtaskbaricon::popupmenu
wxtaskbaricon::removeicon
wxtaskbaricon::seticon


wxtaskbaricon::wxtaskbaricon

wxtaskbaricon()

default constructor.


wxtaskbaricon::~wxtaskbaricon

~wxtaskbaricon()

destroys the wxtaskbaricon object, removing the icon if not already removed.


wxtaskbaricon::createpopupmenu

virtual wxmenu* createpopupmenu()

this method is called by the library when the user requests popup menu (on windows and unix platforms, this is when the user right-clicks the icon). override this function in order to provide popup menu associated with the icon.

if createpopupmenu returns null (this happens by default), no menu is shown, otherwise the menu is displayed and then deleted by the library as soon as the user dismisses it. the events can be handled by a class derived from wxtaskbaricon.


wxtaskbaricon::isiconinstalled

bool isiconinstalled()

returns true if seticon was called with no subsequent removeicon.


wxtaskbaricon::isok

bool isok()

returns true if the object initialized successfully.


wxtaskbaricon::popupmenu

bool popupmenu(wxmenu* menu)

pops up a menu at the current mouse position. the events can be handled by a class derived from wxtaskbaricon.

note

it is recommended to override createpopupmenu callback instead of calling this method from event handler, because some ports (e.g. wxcocoa) may not implement popupmenu and mouse click events at all.


wxtaskbaricon::removeicon

bool removeicon()

removes the icon previously set with seticon.


wxtaskbaricon::seticon

bool seticon(const wxicon& icon, const wxstring& tooltip)

sets the icon, and optional tooltip text.