1 //------------------------------------------------------------------------------ 2 // Copyright (c) 2001-2002, OpenBeOS 3 // 4 // Permission is hereby granted, free of charge, to any person obtaining a 5 // copy of this software and associated documentation files (the "Software"), 6 // to deal in the Software without restriction, including without limitation 7 // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 // and/or sell copies of the Software, and to permit persons to whom the 9 // Software is furnished to do so, subject to the following conditions: 10 // 11 // The above copyright notice and this permission notice shall be included in 12 // all copies or substantial portions of the Software. 13 // 14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 // DEALINGS IN THE SOFTWARE. 21 // 22 // File Name: Button.h 23 // Author: Marc Flerackers (mflerackers@androme.be) 24 // Description: BButton displays and controls a button in a window. 25 //------------------------------------------------------------------------------ 26 27 #ifndef _BUTTON_H 28 #define _BUTTON_H 29 30 // Standard Includes ----------------------------------------------------------- 31 32 // System Includes ------------------------------------------------------------- 33 #include <BeBuild.h> 34 #include <Control.h> 35 36 // Project Includes ------------------------------------------------------------ 37 38 // Local Includes -------------------------------------------------------------- 39 40 // Local Defines --------------------------------------------------------------- 41 42 // Globals --------------------------------------------------------------------- 43 44 45 // BButton class --------------------------------------------------------------- 46 class BButton : public BControl { 47 48 public: 49 BButton(BRect frame, 50 const char *name, 51 const char *label, 52 BMessage *message, 53 uint32 resizingMode = B_FOLLOW_LEFT | B_FOLLOW_TOP, 54 uint32 flags = B_WILL_DRAW | B_NAVIGABLE 55 | B_FULL_UPDATE_ON_RESIZE); 56 BButton(const char* name, const char* label, 57 BMessage *message, 58 uint32 flags = B_WILL_DRAW | B_NAVIGABLE 59 | B_FULL_UPDATE_ON_RESIZE); 60 BButton(const char* label, BMessage *message = NULL); 61 62 virtual ~BButton(); 63 64 BButton(BMessage *archive); 65 66 static BArchivable *Instantiate(BMessage *archive); 67 virtual status_t Archive (BMessage *archive, bool deep = true) const; 68 69 virtual void Draw(BRect updateRect); 70 virtual void MouseDown(BPoint point); 71 virtual void AttachedToWindow(); 72 virtual void KeyDown(const char *bytes, int32 numBytes); 73 virtual void MakeDefault(bool flag); 74 virtual void SetLabel(const char *string); 75 bool IsDefault() const; 76 77 virtual void MessageReceived(BMessage *message); 78 virtual void WindowActivated(bool active); 79 virtual void MouseMoved(BPoint point, uint32 transit, const BMessage *message); 80 virtual void MouseUp(BPoint point); 81 virtual void DetachedFromWindow(); 82 virtual void SetValue(int32 value); 83 virtual void GetPreferredSize (float *width, float *height); 84 virtual void ResizeToPreferred(); 85 virtual status_t Invoke(BMessage *message = NULL); 86 virtual void FrameMoved(BPoint newLocation); 87 virtual void FrameResized(float width, float height); 88 89 virtual void MakeFocus(bool focused = true); 90 virtual void AllAttached(); 91 virtual void AllDetached(); 92 93 virtual BHandler *ResolveSpecifier(BMessage *message, 94 int32 index, 95 BMessage *specifier, 96 int32 what, 97 const char *property); 98 virtual status_t GetSupportedSuites(BMessage *message); 99 virtual status_t Perform(perform_code d, void *arg); 100 101 virtual void InvalidateLayout(bool descendants = false); 102 103 virtual BSize MinSize(); 104 virtual BSize MaxSize(); 105 virtual BSize PreferredSize(); 106 107 108 private: 109 BSize _ValidatePreferredSize(); 110 111 virtual void _ReservedButton1(); 112 virtual void _ReservedButton2(); 113 virtual void _ReservedButton3(); 114 115 BButton &operator=(const BButton &); 116 117 BRect DrawDefault(BRect bounds, bool enabled); 118 void DrawFocusLine(float x, float y, float width, 119 bool bVisible); 120 121 status_t Execute (); 122 123 BSize fPreferredSize; 124 bool fDrawAsDefault; 125 uint32 _reserved[2]; 126 }; 127 //------------------------------------------------------------------------------ 128 129 #endif // _BUTTON_H 130 131 /* 132 * $Log $ 133 * 134 * $Id $ 135 * 136 */ 137