xref: /haiku/src/apps/autoraise/AutoRaiseIcon.h (revision 107712bf01c9777592fd24f7c06c455d1110df0a)
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
15 extern "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
20 //TrayView from the Deskbar
21 status_t removeFromDeskbar(void *);
22 
23 class _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
31 	fired at the deskbar.
32 
33 *********************************************/
34 
35 class TrayView:public BView{
36 	private:
37 
38 		BBitmap *_activeIcon, *_inactiveIcon;
39 		bool watching;
40 
41 		void _init(void); //initialization common to all constructors
42 
43 	public:
44 		AutoRaiseSettings *_settings;
45 		mode_mouse fNormalMM;
46 		volatile int32 current_window; // id
47 		bigtime_t raise_delay;
48 		volatile thread_id last_raiser_thread;
49 		team_id fDeskbarTeam;
50 
51 		bigtime_t polling_delay;
52 		sem_id fPollerSem;
53 		thread_id poller_thread;
54 
55 		TrayView();
56 		TrayView(BMessage *mdArchive);
57 		virtual ~TrayView();
58 
59 		virtual status_t Archive(BMessage *data, bool deep = true) const;
60 		static TrayView *Instantiate(BMessage *data);
61 
62 		virtual void Draw(BRect updateRect );
63 		virtual void AttachedToWindow();
64 		virtual void MouseDown(BPoint where);
65 		virtual void MessageReceived(BMessage* message);
66 		virtual void GetPreferredSize(float *w, float *h);
67 
68 		AutoRaiseSettings *Settings() const;
69 		void SetActive(bool);
70 };
71 
72 int32 fronter(void *);
73 int32 poller(void *);
74 
75 /*********************************************
76 	ConfigMenu derived from BPopUpMenu
77 	Provides the contextual left-click menu for the
78 	TrayView. Fires it's messages at the TrayView specified
79 	in it's constructor;
80 	Also, it's by default set to asynchronously destruct,
81 	so it's basically a fire & forget kinda fella.
82 *********************************************/
83 
84 class ConfigMenu: public BPopUpMenu{
85 	private:
86 
87 	public:
88 		ConfigMenu(TrayView *tv, bool useMag);
89 		virtual ~ConfigMenu();
90 };
91 
92 
93 #endif
94