1 /* 2 * Copyright 2001-2013, 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 B_CONTROL_PARTIALLY_ON = 2 17 }; 18 19 class BBitmap; 20 class BWindow; 21 22 namespace BPrivate { 23 class BIcon; 24 }; 25 26 27 class BControl : public BView, public BInvoker { 28 public: 29 BControl(BRect frame, const char* name, 30 const char* label, BMessage* message, 31 uint32 resizingMode, uint32 flags); 32 BControl(const char* name, const char* label, 33 BMessage* message, uint32 flags); 34 virtual ~BControl(); 35 36 BControl(BMessage* archive); 37 static BArchivable* Instantiate(BMessage* archive); 38 virtual status_t Archive(BMessage* archive, 39 bool deep = true) const; 40 41 virtual void WindowActivated(bool active); 42 43 virtual void AttachedToWindow(); 44 virtual void DetachedFromWindow(); 45 virtual void AllAttached(); 46 virtual void AllDetached(); 47 48 virtual void MessageReceived(BMessage* message); 49 virtual void MakeFocus(bool focused = true); 50 51 virtual void KeyDown(const char* bytes, int32 numBytes); 52 virtual void MouseDown(BPoint point); 53 virtual void MouseUp(BPoint point); 54 virtual void MouseMoved(BPoint point, uint32 transit, 55 const BMessage *message); 56 57 virtual void SetLabel(const char* string); 58 const char* Label() const; 59 60 virtual void SetValue(int32 value); 61 int32 Value() const; 62 63 virtual void SetEnabled(bool enabled); 64 bool IsEnabled() const; 65 66 virtual void GetPreferredSize(float* _width, 67 float* _height); 68 virtual void ResizeToPreferred(); 69 70 virtual status_t Invoke(BMessage* message = NULL); 71 virtual BHandler* ResolveSpecifier(BMessage* message, 72 int32 index, BMessage* specifier, 73 int32 what, const char* property); 74 virtual status_t GetSupportedSuites(BMessage* message); 75 76 virtual status_t Perform(perform_code d, void* arg); 77 78 virtual status_t SetIcon(const BBitmap* bitmap, 79 uint32 flags = 0); 80 status_t SetIconBitmap(const BBitmap* bitmap, 81 uint32 which, uint32 flags = 0); 82 const BBitmap* IconBitmap(uint32 which) const; 83 84 protected: 85 bool IsFocusChanging() const; 86 bool IsTracking() const; 87 void SetTracking(bool state); 88 89 void SetValueNoUpdate(int32 value); 90 91 private: 92 struct IconData; 93 94 private: 95 virtual void _ReservedControl2(); 96 virtual void _ReservedControl3(); 97 virtual void _ReservedControl4(); 98 99 BControl& operator=(const BControl&); 100 101 void InitData(BMessage* data = NULL); 102 103 private: 104 char* fLabel; 105 int32 fValue; 106 bool fEnabled; 107 bool fFocusChanging; 108 bool fTracking; 109 bool fWantsNav; 110 BPrivate::BIcon* fIcon; 111 112 #ifdef B_HAIKU_64_BIT 113 uint32 _reserved[2]; 114 #else 115 uint32 _reserved[3]; 116 #endif 117 }; 118 119 #endif // _CONTROL_H 120