2 * Copyright 2006-2015, Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
5 #ifndef _TEXT_CONTROL_H
6 #define _TEXT_CONTROL_H
19 class BTextControl
: public BControl
{
21 BTextControl(BRect frame
, const char* name
,
22 const char* label
, const char* initialText
,
24 uint32 resizeMask
= B_FOLLOW_LEFT_TOP
,
25 uint32 flags
= B_WILL_DRAW
| B_NAVIGABLE
);
26 BTextControl(const char* name
,
27 const char* label
, const char* initialText
,
29 uint32 flags
= B_WILL_DRAW
| B_NAVIGABLE
);
30 BTextControl(const char* label
,
31 const char* initialText
,
33 virtual ~BTextControl();
35 BTextControl(BMessage
* archive
);
36 static BArchivable
* Instantiate(BMessage
* archive
);
37 virtual status_t
Archive(BMessage
* archive
,
38 bool deep
= true) const;
40 virtual void SetText(const char* text
);
41 const char* Text() const;
42 int32
TextLength() const;
43 void MarkAsInvalid(bool invalid
);
45 virtual void SetValue(int32 value
);
46 virtual status_t
Invoke(BMessage
* message
= NULL
);
48 BTextView
* TextView() const;
50 virtual void SetModificationMessage(BMessage
* message
);
51 BMessage
* ModificationMessage() const;
53 virtual void SetAlignment(alignment label
, alignment text
);
54 void GetAlignment(alignment
* _label
,
55 alignment
* _text
) const;
56 virtual void SetDivider(float position
);
57 float Divider() const;
59 virtual void Draw(BRect updateRect
);
60 virtual void MouseDown(BPoint where
);
61 virtual void AttachedToWindow();
62 virtual void MakeFocus(bool focus
= true);
63 virtual void SetEnabled(bool enable
);
64 virtual void FrameMoved(BPoint newPosition
);
65 virtual void FrameResized(float newWidth
, float newHeight
);
66 virtual void WindowActivated(bool active
);
68 virtual void GetPreferredSize(float* _width
,
70 virtual void ResizeToPreferred();
72 virtual void MessageReceived(BMessage
* message
);
73 virtual BHandler
* ResolveSpecifier(BMessage
* message
,
74 int32 index
, BMessage
* specifier
,
75 int32 what
, const char* property
);
77 virtual void MouseUp(BPoint where
);
78 virtual void MouseMoved(BPoint where
, uint32 transit
,
79 const BMessage
* dragMessage
);
80 virtual void DetachedFromWindow();
82 virtual void AllAttached();
83 virtual void AllDetached();
84 virtual status_t
GetSupportedSuites(BMessage
* data
);
85 virtual void SetFlags(uint32 flags
);
87 virtual BSize
MinSize();
88 virtual BSize
MaxSize();
89 virtual BSize
PreferredSize();
90 virtual BAlignment
LayoutAlignment();
92 BLayoutItem
* CreateLabelLayoutItem();
93 BLayoutItem
* CreateTextViewLayoutItem();
96 virtual status_t
AllArchived(BMessage
* into
) const;
97 virtual status_t
AllUnarchived(const BMessage
* from
);
99 virtual void LayoutInvalidated(bool descendants
);
100 virtual void DoLayout();
102 virtual status_t
SetIcon(const BBitmap
* icon
, uint32 flags
= 0);
105 // FBC padding and forbidden methods
106 virtual status_t
Perform(perform_code d
, void* arg
);
108 virtual void _ReservedTextControl1();
109 virtual void _ReservedTextControl2();
110 virtual void _ReservedTextControl3();
111 virtual void _ReservedTextControl4();
113 BTextControl
& operator=(const BTextControl
& other
);
116 class LabelLayoutItem
;
117 class TextViewLayoutItem
;
120 friend class _BTextInput_
;
121 friend class LabelLayoutItem
;
122 friend class TextViewLayoutItem
;
125 void _UpdateTextViewColors(bool enable
);
126 void _InitData(const char* label
,
127 const BMessage
* archive
= NULL
);
128 void _InitText(const char* initialText
,
129 const BMessage
* archive
= NULL
);
130 void _ValidateLayout();
131 void _LayoutTextView();
134 void _ValidateLayoutData();
137 BPrivate::_BTextInput_
* fText
;
138 BMessage
* fModificationMessage
;
139 alignment fLabelAlign
;
142 LayoutData
* fLayoutData
;
149 #endif // _TEXT_CONTROL_H