1 /* 2 * Copyright 2001-2009, Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _CONTROL_H 6 #define _CONTROL_H 7 8 #include <Invoker.h> 9 #include <Message.h> // For convenience 10 #include <View.h> 11 12 13 enum { 14 B_CONTROL_OFF = 0, 15 B_CONTROL_ON = 1 16 }; 17 18 class BWindow; 19 20 21 class BControl : public BView, public BInvoker { 22 public: 23 BControl(BRect frame, const char* name, 24 const char* label, BMessage* message, 25 uint32 resizingMode, uint32 flags); 26 BControl(const char* name, const char* label, 27 BMessage* message, uint32 flags); 28 virtual ~BControl(); 29 30 BControl(BMessage* archive); 31 static BArchivable* Instantiate(BMessage* archive); 32 virtual status_t Archive(BMessage* archive, 33 bool deep = true) const; 34 35 virtual void WindowActivated(bool active); 36 37 virtual void AttachedToWindow(); 38 virtual void DetachedFromWindow(); 39 virtual void AllAttached(); 40 virtual void AllDetached(); 41 42 virtual void MessageReceived(BMessage* message); 43 virtual void MakeFocus(bool focused = true); 44 45 virtual void KeyDown(const char* bytes, int32 numBytes); 46 virtual void MouseDown(BPoint point); 47 virtual void MouseUp(BPoint point); 48 virtual void MouseMoved(BPoint point, uint32 transit, 49 const BMessage *message); 50 51 virtual void SetLabel(const char* string); 52 const char* Label() const; 53 54 virtual void SetValue(int32 value); 55 int32 Value() const; 56 57 virtual void SetEnabled(bool enabled); 58 bool IsEnabled() const; 59 60 virtual void GetPreferredSize(float* _width, 61 float* _height); 62 virtual void ResizeToPreferred(); 63 64 virtual status_t Invoke(BMessage* message = NULL); 65 virtual BHandler* ResolveSpecifier(BMessage* message, 66 int32 index, BMessage* specifier, 67 int32 what, const char* property); 68 virtual status_t GetSupportedSuites(BMessage* message); 69 70 virtual status_t Perform(perform_code d, void* arg); 71 72 protected: 73 bool IsFocusChanging() const; 74 bool IsTracking() const; 75 void SetTracking(bool state); 76 77 void SetValueNoUpdate(int32 value); 78 79 private: 80 virtual void _ReservedControl1(); 81 virtual void _ReservedControl2(); 82 virtual void _ReservedControl3(); 83 virtual void _ReservedControl4(); 84 85 BControl& operator=(const BControl&); 86 87 void InitData(BMessage* data = NULL); 88 89 char* fLabel; 90 int32 fValue; 91 bool fEnabled; 92 bool fFocusChanging; 93 bool fTracking; 94 bool fWantsNav; 95 96 uint32 _reserved[4]; 97 }; 98 99 #endif // _CONTROL_H 100