1 /* 2 * Copyright 2006-2011, 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 9 #include <IconButton.h> 10 #include <List.h> 11 #include <String.h> 12 13 14 enum { 15 MSG_ADD_SLOT = 'adsl', 16 MSG_CLEAR_SLOT = 'clsl', 17 MSG_REMOVE_SLOT = 'rmsl', 18 MSG_LAUNCH = 'lnch', 19 }; 20 21 22 class LaunchButton : public BIconButton { 23 public: 24 LaunchButton(const char* name, uint32 id, 25 const char* label = NULL, 26 BMessage* message = NULL, 27 BHandler* target = NULL); 28 virtual ~LaunchButton(); 29 30 // BIconButton interface 31 virtual void AttachedToWindow(); 32 virtual void Draw(BRect updateRect); 33 virtual void MessageReceived(BMessage* message); 34 virtual void MouseDown(BPoint where); 35 virtual void MouseUp(BPoint where); 36 virtual void MouseMoved(BPoint where, uint32 transit, 37 const BMessage* dragMessage); 38 39 virtual BSize MinSize(); 40 virtual BSize PreferredSize(); 41 virtual BSize MaxSize(); 42 43 // LaunchButton 44 void SetTo(const entry_ref* ref); 45 entry_ref* Ref() const; 46 47 void SetTo(const char* appSig, bool updateIcon); 48 const char* AppSignature() const 49 { return fAppSig; } 50 51 void SetDescription(const char* text); 52 const char* Description() const 53 { return fDescription.String(); } 54 55 void SetIconSize(uint32 size); 56 uint32 IconSize() const 57 { return fIconSize; } 58 59 static void SetIgnoreDoubleClick(bool refuse); 60 static bool IgnoreDoubleClick() 61 { return sIgnoreDoubleClick; } 62 63 private: 64 void _UpdateToolTip(); 65 void _UpdateIcon(const entry_ref* ref); 66 67 void _NotifySettingsChanged(); 68 69 void _DrawFrame(BRect frame, 70 rgb_color left, rgb_color top, 71 rgb_color right, rgb_color bottom); 72 73 private: 74 entry_ref* fRef; 75 char* fAppSig; 76 BString fDescription; 77 78 bool fAnticipatingDrop; 79 bigtime_t fLastClickTime; 80 BPoint fDragStart; 81 82 uint32 fIconSize; 83 84 static bigtime_t sClickSpeed; 85 static bool sIgnoreDoubleClick; 86 }; 87 88 #endif // LAUNCH_BUTTON_H 89