1 /* 2 * Copyright 2001-2013, Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _BUTTON_H 6 #define _BUTTON_H 7 8 #include <Control.h> 9 10 11 class BButton : public BControl { 12 public: 13 enum BBehavior { 14 B_BUTTON_BEHAVIOR, 15 B_TOGGLE_BEHAVIOR, 16 B_POP_UP_BEHAVIOR, 17 }; 18 19 public: 20 BButton(BRect frame, const char* name, 21 const char* label, BMessage* message, 22 uint32 resizingMode 23 = B_FOLLOW_LEFT | B_FOLLOW_TOP, 24 uint32 flags = B_WILL_DRAW | B_NAVIGABLE 25 | B_FULL_UPDATE_ON_RESIZE); 26 BButton(const char* name, const char* label, 27 BMessage *message, 28 uint32 flags = B_WILL_DRAW | B_NAVIGABLE 29 | B_FULL_UPDATE_ON_RESIZE); 30 BButton(const char* label, 31 BMessage* message = NULL); 32 33 BButton(BMessage *archive); 34 35 virtual ~BButton(); 36 37 static BArchivable* Instantiate(BMessage* archive); 38 virtual status_t Archive(BMessage* archive, 39 bool deep = true) const; 40 41 virtual void Draw(BRect updateRect); 42 virtual void MouseDown(BPoint point); 43 virtual void AttachedToWindow(); 44 virtual void KeyDown(const char* bytes, int32 numBytes); 45 virtual void MakeDefault(bool flag); 46 virtual void SetLabel(const char* string); 47 bool IsDefault() const; 48 49 bool IsFlat() const; 50 void SetFlat(bool flat); 51 52 BBehavior Behavior() const; 53 void SetBehavior(BBehavior behavior); 54 55 BMessage* PopUpMessage() const; 56 void SetPopUpMessage(BMessage* message); 57 58 virtual void MessageReceived(BMessage* message); 59 virtual void WindowActivated(bool active); 60 virtual void MouseMoved(BPoint point, uint32 transit, 61 const BMessage* message); 62 virtual void MouseUp(BPoint point); 63 virtual void DetachedFromWindow(); 64 virtual void SetValue(int32 value); 65 virtual void GetPreferredSize (float* _width, 66 float* _height); 67 virtual void ResizeToPreferred(); 68 virtual status_t Invoke(BMessage* message = NULL); 69 virtual void FrameMoved(BPoint newLocation); 70 virtual void FrameResized(float width, float height); 71 72 virtual void MakeFocus(bool focused = true); 73 virtual void AllAttached(); 74 virtual void AllDetached(); 75 76 virtual BHandler* ResolveSpecifier(BMessage* message, 77 int32 index, BMessage* specifier, 78 int32 what, const char* property); 79 virtual status_t GetSupportedSuites(BMessage* message); 80 virtual status_t Perform(perform_code d, void* arg); 81 82 83 virtual BSize MinSize(); 84 virtual BSize MaxSize(); 85 virtual BSize PreferredSize(); 86 87 virtual status_t SetIcon(const BBitmap* icon, uint32 flags = 0); 88 89 protected: 90 virtual void LayoutInvalidated(bool descendants = false); 91 92 private: 93 virtual void _ReservedButton1(); 94 virtual void _ReservedButton2(); 95 virtual void _ReservedButton3(); 96 97 BButton& operator=(const BButton &); 98 99 BSize _ValidatePreferredSize(); 100 101 BRect _PopUpRect() const; 102 103 inline bool _Flag(uint32 flag) const; 104 inline bool _SetFlag(uint32 flag, bool set); 105 106 private: 107 BSize fPreferredSize; 108 uint32 fFlags; 109 BBehavior fBehavior; 110 BMessage* fPopUpMessage; 111 }; 112 113 #endif // _BUTTON_H 114