1#ifndef TRAY_VIEW
2#define TRAY_VIEW
3
4#include <InterfaceDefs.h>
5#include <TranslationKit.h>
6#include <Deskbar.h>
7#include <OS.h>
8
9
10#include "common.h"
11#include "settings.h"
12#include <Roster.h>
13
14//exported instantiator function
15extern "C" _EXPORT BView* instantiate_deskbar_item();
16
17
18//since we can't remove the view from the deskbar from within the same thread
19//as tray view, a thread will be spawned and this function called. It removed TrayView
20//from the Deskbar
21long removeFromDeskbar(void *);
22
23class _EXPORT TrayView;
24
25
26/*********************************************
27	class TrayView derived from BView
28
29	The icon in the Deskbar tray, provides the fundamental
30	user interface. Archivable, so it can be flattened and fired
31	at the deskbar.
32
33*********************************************/
34
35class TrayView:public BView{
36	private:
37
38		BBitmap *_activeIcon, *_inactiveIcon;
39		entry_ref _appPath;
40		bool watching;
41
42		void _init(void); //initialization common to all constructors
43
44	public:
45		AutoRaiseSettings *_settings;
46		mode_mouse fNormalMM;
47		volatile int32 current_window; // id
48		bigtime_t raise_delay;
49		volatile thread_id last_raiser_thread;
50		team_id fDeskbarTeam;
51
52		bigtime_t polling_delay; // for !DANO
53		sem_id fPollerSem;
54		thread_id poller_thread;
55
56		TrayView();
57		TrayView(BMessage *mdArchive);
58		virtual ~TrayView();
59
60		virtual status_t Archive(BMessage *data, bool deep = true) const;
61		static TrayView *Instantiate(BMessage *data);
62
63		virtual void Draw(BRect updateRect );
64		virtual void AttachedToWindow();
65		virtual void MouseDown(BPoint where);
66		virtual void MessageReceived(BMessage* message);
67		virtual void GetPreferredSize(float *w, float *h);
68
69		AutoRaiseSettings *Settings() const;
70		void SetActive(bool);
71};
72
73int32 fronter(void *);
74int32 poller(void *);
75
76/*********************************************
77	ConfigMenu derived from BPopUpMenu
78	Provides the contextual left-click menu for the
79	TrayView. Fires it's messages at the TrayView specified
80	in it's constructor;
81	Also, it's by default set to asynchronously destruct,
82	so it's basically a fire & forget kinda fella.
83*********************************************/
84
85class ConfigMenu: public BPopUpMenu{
86	private:
87
88	public:
89		ConfigMenu(TrayView *tv, bool useMag);
90		virtual ~ConfigMenu();
91};
92
93
94#endif
95