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 DetachedFromWindow(); 31 virtual void Draw(BRect updateRect); 32 virtual void MessageReceived(BMessage* message); 33 virtual void MouseDown(BPoint where); 34 virtual void MouseUp(BPoint where); 35 virtual void MouseMoved(BPoint where, uint32 transit, 36 const BMessage* dragMessage); 37 38 virtual BSize MinSize(); 39 virtual BSize PreferredSize(); 40 virtual BSize MaxSize(); 41 42 // LaunchButton 43 void SetTo(const entry_ref* ref); 44 entry_ref* Ref() const; 45 46 void SetTo(const char* appSig, bool updateIcon); 47 const char* AppSignature() const 48 { return fAppSig; } 49 50 void SetDescription(const char* text); 51 const char* Description() const 52 { return fDescription.String(); } 53 54 void SetIconSize(uint32 size); 55 uint32 IconSize() const 56 { return fIconSize; } 57 58 private: 59 void _UpdateToolTip(); 60 void _UpdateIcon(const entry_ref* ref); 61 62 entry_ref* fRef; 63 char* fAppSig; 64 BString fDescription; 65 66 bool fAnticipatingDrop; 67 bigtime_t fLastClickTime; 68 BPoint fDragStart; 69 70 uint32 fIconSize; 71 72 static bigtime_t fClickSpeed; 73 }; 74 75 #endif // LAUNCH_BUTTON_H 76