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