1 /* 2 * Copyright 2001-2015 Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _CHECK_BOX_H 6 #define _CHECK_BOX_H 7 8 9 #include <Control.h> 10 11 12 class BCheckBox : public BControl { 13 public: 14 BCheckBox(BRect frame, const char* name, 15 const char* label, BMessage* message, 16 uint32 resizingMode = B_FOLLOW_LEFT_TOP, 17 uint32 flags = B_WILL_DRAW | B_NAVIGABLE); 18 BCheckBox(const char* name, const char* label, 19 BMessage* message, uint32 flags 20 = B_WILL_DRAW | B_NAVIGABLE); 21 BCheckBox(const char* label, 22 BMessage* message = NULL); 23 BCheckBox(BMessage* data); 24 25 virtual ~BCheckBox(); 26 27 static BArchivable* Instantiate(BMessage* data); 28 virtual status_t Archive(BMessage* data, bool deep = true) const; 29 30 virtual void Draw(BRect updateRect); 31 32 virtual void AttachedToWindow(); 33 virtual void DetachedFromWindow(); 34 virtual void AllAttached(); 35 virtual void AllDetached(); 36 37 virtual void FrameMoved(BPoint newPosition); 38 virtual void FrameResized(float newWidth, float newHeight); 39 virtual void WindowActivated(bool active); 40 41 virtual void MessageReceived(BMessage* message); 42 43 virtual void KeyDown(const char* bytes, int32 numBytes); 44 45 virtual void MouseDown(BPoint where); 46 virtual void MouseUp(BPoint where); 47 virtual void MouseMoved(BPoint where, uint32 code, 48 const BMessage* dragMessage); 49 50 virtual void GetPreferredSize(float* _width, 51 float* _height); 52 virtual void ResizeToPreferred(); 53 54 virtual BSize MinSize(); 55 virtual BSize MaxSize(); 56 virtual BSize PreferredSize(); 57 virtual BAlignment LayoutAlignment(); 58 59 virtual void MakeFocus(bool focused = true); 60 61 virtual void SetValue(int32 value); 62 virtual status_t Invoke(BMessage* message = NULL); 63 64 virtual BHandler* ResolveSpecifier(BMessage* message, 65 int32 index, BMessage* specifier, 66 int32 what, const char* property); 67 virtual status_t GetSupportedSuites(BMessage* message); 68 69 virtual status_t Perform(perform_code code, void* data); 70 71 virtual status_t SetIcon(const BBitmap* icon, uint32 flags = 0); 72 73 bool IsPartialStateToOff() const; 74 void SetPartialStateToOff(bool partialToOff); 75 76 protected: 77 virtual void LayoutInvalidated(bool descendants = false); 78 79 private: 80 // FBC padding 81 virtual void _ReservedCheckBox1(); 82 virtual void _ReservedCheckBox2(); 83 virtual void _ReservedCheckBox3(); 84 85 private: 86 inline BRect _CheckBoxFrame(const font_height& fontHeight) 87 const; 88 BRect _CheckBoxFrame() const; 89 BSize _ValidatePreferredSize(); 90 int32 _NextState() const; 91 92 private: 93 // Forbidden 94 BCheckBox& operator=(const BCheckBox&); 95 96 private: 97 BSize fPreferredSize; 98 bool fOutlined; 99 bool fPartialToOff; 100 }; 101 102 103 #endif // _CHECK_BOX_H 104