1 /* 2 * Copyright 2001-2009, 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 BButton(BRect frame, const char* name, 14 const char* label, BMessage* message, 15 uint32 resizingMode 16 = B_FOLLOW_LEFT | B_FOLLOW_TOP, 17 uint32 flags = B_WILL_DRAW | B_NAVIGABLE 18 | B_FULL_UPDATE_ON_RESIZE); 19 BButton(const char* name, const char* label, 20 BMessage *message, 21 uint32 flags = B_WILL_DRAW | B_NAVIGABLE 22 | B_FULL_UPDATE_ON_RESIZE); 23 BButton(const char* label, 24 BMessage* message = NULL); 25 26 BButton(BMessage *archive); 27 28 virtual ~BButton(); 29 30 static BArchivable* Instantiate(BMessage* archive); 31 virtual status_t Archive(BMessage* archive, 32 bool deep = true) const; 33 34 virtual void Draw(BRect updateRect); 35 virtual void MouseDown(BPoint point); 36 virtual void AttachedToWindow(); 37 virtual void KeyDown(const char* bytes, int32 numBytes); 38 virtual void MakeDefault(bool flag); 39 virtual void SetLabel(const char* string); 40 bool IsDefault() const; 41 42 virtual void MessageReceived(BMessage* message); 43 virtual void WindowActivated(bool active); 44 virtual void MouseMoved(BPoint point, uint32 transit, 45 const BMessage* message); 46 virtual void MouseUp(BPoint point); 47 virtual void DetachedFromWindow(); 48 virtual void SetValue(int32 value); 49 virtual void GetPreferredSize (float* _width, 50 float* _height); 51 virtual void ResizeToPreferred(); 52 virtual status_t Invoke(BMessage* message = NULL); 53 virtual void FrameMoved(BPoint newLocation); 54 virtual void FrameResized(float width, float height); 55 56 virtual void MakeFocus(bool focused = true); 57 virtual void AllAttached(); 58 virtual void AllDetached(); 59 60 virtual BHandler* ResolveSpecifier(BMessage* message, 61 int32 index, BMessage* specifier, 62 int32 what, const char* property); 63 virtual status_t GetSupportedSuites(BMessage* message); 64 virtual status_t Perform(perform_code d, void* arg); 65 66 67 virtual BSize MinSize(); 68 virtual BSize MaxSize(); 69 virtual BSize PreferredSize(); 70 71 72 protected: 73 virtual void LayoutInvalidated(bool descendants = false); 74 75 private: 76 virtual void _ReservedButton1(); 77 virtual void _ReservedButton2(); 78 virtual void _ReservedButton3(); 79 80 private: 81 BButton& operator=(const BButton &); 82 83 BSize _ValidatePreferredSize(); 84 85 BRect _DrawDefault(BRect bounds, bool enabled); 86 void _DrawFocusLine(float x, float y, float width, 87 bool bVisible); 88 89 BSize fPreferredSize; 90 bool fDrawAsDefault; 91 92 uint32 _reserved[2]; 93 }; 94 95 #endif // _BUTTON_H 96