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 56 virtual ~BButton(); 57 58 BButton(BMessage *archive); 59 60 static BArchivable *Instantiate(BMessage *archive); 61 virtual status_t Archive (BMessage *archive, bool deep = true) const; 62 63 virtual void Draw(BRect updateRect); 64 virtual void MouseDown(BPoint point); 65 virtual void AttachedToWindow(); 66 virtual void KeyDown(const char *bytes, int32 numBytes); 67 virtual void MakeDefault(bool flag); 68 virtual void SetLabel(const char *string); 69 bool IsDefault() const; 70 71 virtual void MessageReceived(BMessage *message); 72 virtual void WindowActivated(bool active); 73 virtual void MouseMoved(BPoint point, uint32 transit, const BMessage *message); 74 virtual void MouseUp(BPoint point); 75 virtual void DetachedFromWindow(); 76 virtual void SetValue(int32 value); 77 virtual void GetPreferredSize (float *width, float *height); 78 virtual void ResizeToPreferred(); 79 virtual status_t Invoke(BMessage *message = NULL); 80 virtual void FrameMoved(BPoint newLocation); 81 virtual void FrameResized(float width, float height); 82 83 virtual void MakeFocus(bool focused = true); 84 virtual void AllAttached(); 85 virtual void AllDetached(); 86 87 virtual BHandler *ResolveSpecifier(BMessage *message, 88 int32 index, 89 BMessage *specifier, 90 int32 what, 91 const char *property); 92 virtual status_t GetSupportedSuites(BMessage *message); 93 virtual status_t Perform(perform_code d, void *arg); 94 95 private: 96 97 virtual void _ReservedButton1(); 98 virtual void _ReservedButton2(); 99 virtual void _ReservedButton3(); 100 101 BButton &operator=(const BButton &); 102 103 BRect DrawDefault(BRect bounds, bool enabled); 104 void DrawFocusLine(float x, float y, float width, 105 bool bVisible); 106 107 status_t Execute (); 108 109 float fCachedWidth; 110 bool fDrawAsDefault; 111 uint32 _reserved[3]; 112 }; 113 //------------------------------------------------------------------------------ 114 115 #endif // _BUTTON_H 116 117 /* 118 * $Log $ 119 * 120 * $Id $ 121 * 122 */ 123