xref: /haiku/src/apps/launchbox/LaunchButton.h (revision 239222b2369c39dc52df52b0a7cdd6cc0a91bc92)
1 /*
2  * Copyright 2006-2009, Stephan Aßmus <superstippi@gmx.de>
3  * All rights reserved. Distributed under the terms of the MIT License.
4  */
5 #ifndef LAUNCH_BUTTON_H
6 #define LAUNCH_BUTTON_H
7 
8 #include <List.h>
9 #include <String.h>
10 
11 #include "IconButton.h"
12 
13 enum {
14 	MSG_ADD_SLOT				= 'adsl',
15 	MSG_CLEAR_SLOT				= 'clsl',
16 	MSG_REMOVE_SLOT				= 'rmsl',
17 	MSG_LAUNCH					= 'lnch',
18 };
19 
20 class LaunchButton : public IconButton {
21 public:
22 								LaunchButton(const char* name, uint32 id,
23 									const char* label = NULL,
24 									BMessage* message = NULL,
25 									BHandler* target = NULL);
26 	virtual						~LaunchButton();
27 
28 	// IconButton interface
29 	virtual	void				AttachedToWindow();
30 	virtual	void				Draw(BRect updateRect);
31 	virtual	void				MessageReceived(BMessage* message);
32 	virtual	void				MouseDown(BPoint where);
33 	virtual	void				MouseUp(BPoint where);
34 	virtual	void				MouseMoved(BPoint where, uint32 transit,
35 									const BMessage* dragMessage);
36 
37 	virtual	BSize				MinSize();
38 	virtual	BSize				PreferredSize();
39 	virtual	BSize				MaxSize();
40 
41 	// LaunchButton
42 			void				SetTo(const entry_ref* ref);
43 			entry_ref*			Ref() const;
44 
45 			void				SetTo(const char* appSig, bool updateIcon);
46 			const char*			AppSignature() const
47 									{ return fAppSig; }
48 
49 			void				SetDescription(const char* text);
50 			const char*			Description() const
51 									{ return fDescription.String(); }
52 
53 			void				SetIconSize(uint32 size);
54 			uint32				IconSize() const
55 									{ return fIconSize; }
56 
57 	static	void				SetIgnoreDoubleClick(bool refuse);
58 	static	bool				IgnoreDoubleClick()
59 									{ return sIgnoreDoubleClick; }
60 
61 private:
62 			void				_UpdateToolTip();
63 			void				_UpdateIcon(const entry_ref* ref);
64 
65 			void				_NotifySettingsChanged();
66 
67 			entry_ref*			fRef;
68 			char*				fAppSig;
69 			BString				fDescription;
70 
71 			bool				fAnticipatingDrop;
72 			bigtime_t			fLastClickTime;
73 			BPoint				fDragStart;
74 
75 			uint32				fIconSize;
76 
77 	static	bigtime_t			sClickSpeed;
78 	static	bool				sIgnoreDoubleClick;
79 };
80 
81 #endif // LAUNCH_BUTTON_H
82