1 /* 2 * Copyright 2006, Haiku, Inc. All Rights Reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _TEXT_CONTROL_H 6 #define _TEXT_CONTROL_H 7 8 9 #include <Control.h> 10 #include <TextView.h> 11 12 class _BTextInput_; 13 14 15 class BTextControl : public BControl { 16 public: 17 BTextControl(BRect frame, const char* name, 18 const char* label, const char* initialText, 19 BMessage* message, 20 uint32 resizeMode = B_FOLLOW_LEFT | B_FOLLOW_TOP, 21 uint32 flags = B_WILL_DRAW | B_NAVIGABLE); 22 virtual ~BTextControl(); 23 24 BTextControl(BMessage* archive); 25 static BArchivable* Instantiate(BMessage* archive); 26 virtual status_t Archive(BMessage* archive, bool deep = true) const; 27 28 virtual void SetText(const char* text); 29 const char* Text() const; 30 31 virtual void SetValue(int32 value); 32 virtual status_t Invoke(BMessage* message = NULL); 33 34 BTextView* TextView() const; 35 36 virtual void SetModificationMessage(BMessage* message); 37 BMessage* ModificationMessage() const; 38 39 virtual void SetAlignment(alignment label, alignment text); 40 void GetAlignment(alignment* _label, alignment* _text) const; 41 virtual void SetDivider(float position); 42 float Divider() const; 43 44 virtual void Draw(BRect updateRect); 45 virtual void MouseDown(BPoint where); 46 virtual void AttachedToWindow(); 47 virtual void MakeFocus(bool focus = true); 48 virtual void SetEnabled(bool enabled); 49 virtual void FrameMoved(BPoint newPosition); 50 virtual void FrameResized(float newWidth, float newHeight); 51 virtual void WindowActivated(bool active); 52 53 virtual void GetPreferredSize(float* _width, float* _height); 54 virtual void ResizeToPreferred(); 55 56 virtual void MessageReceived(BMessage* message); 57 virtual BHandler* ResolveSpecifier(BMessage* message, int32 index, 58 BMessage* specifier, int32 what, 59 const char* property); 60 61 virtual void MouseUp(BPoint point); 62 virtual void MouseMoved(BPoint point, uint32 transit, 63 const BMessage* dragMessage); 64 virtual void DetachedFromWindow(); 65 66 virtual void AllAttached(); 67 virtual void AllDetached(); 68 virtual status_t GetSupportedSuites(BMessage* data); 69 virtual void SetFlags(uint32 flags); 70 71 private: 72 friend class _BTextInput_; 73 74 virtual status_t Perform(perform_code d, void* arg); 75 76 virtual void _ReservedTextControl1(); 77 virtual void _ReservedTextControl2(); 78 virtual void _ReservedTextControl3(); 79 virtual void _ReservedTextControl4(); 80 81 BTextControl& operator=(const BTextControl& other); 82 83 void _CommitValue(); 84 void _UpdateTextViewColors(bool enabled); 85 void _InitData(const char* label, const char* initialText, 86 BMessage* archive = NULL); 87 88 private: 89 _BTextInput_* fText; 90 char* fLabel; 91 BMessage* fModificationMessage; 92 alignment fLabelAlign; 93 float fDivider; 94 float fPreviousWidth; 95 float fPreviousHeight; 96 97 uint32 _reserved[6]; 98 99 bool fClean; 100 bool fSkipSetFlags; 101 102 bool _reserved1; 103 bool _reserved2; 104 }; 105 106 #endif // _TEXT_CONTROL_H 107