Derived from: public BControl
Declared in: MultiLineTextControl.h
Library: none
Creates something similar to a BTextControl, but which allows multiple lines of text. If it has a modification message, it will send a message to its target indicating that a change has occurred whenever text is modified. It will send an invocation message any time text has been modified and the control loses focus. Note that if the MultiLineTextControl is destroyed (for example, when the window closes) if it has had its content changed, but not been invoked, it will never get a chance to do so, so if a window represents some external data that is only changed on demand, it is important to check for modification when the window is being closed.
MultiLineTextControl(BRect frame, const char* name, const char* label, bool inline_label, const char *text, BMessage *message, uint32 resizing_mode = B_FOLLOW_LEFT | B_FOLLOW_TOP, uint32 flags = B_WILL_DRAW | B_NAVIGABLE)
if inline_label is true, the label will be placed to the left of the text entry box instead of above it. label specifies the label to be placed to the left or above the text entry box, while text specifies the text to be initially placed in the exnty box itself. message specifies the message to be sent to the target when the the control is invoked. The BInvoker portion of the inheritance chain takes posession of message, so it should not be deleted after being passed to the MultiLineTextControl constructor.
~MultiLineTextControl()
Destroys the MultiLineTextControl.
virtual void AttachedToWindow()
Augments the BControl version of AttachedToWindow() to set the background color to match the parent view.
virtual void SetDivider(float divider) inline float Divider() const
For a MultiLineTextControl with an inline label, Divider() returns the left edge of the text entry box in the MultiLineTextControl's coordinate space. SetDivider() sets the position. In general, it is best to set it to:
font->StringWidth(label)+7.
virtual void FrameResized(float width, float heigh)
Augments the BControl version of FrameResized() to adjust the text rect size of the child BTextView, and reflow the text to be appropriate for the new text rect.
inline bool IsLabelInline() const
Returns whether or not the MultiLineTextControl has an inline label.
virtual void MakeFocus(bool flag = true)
Augments the BControl version of MakeFocus() to invoke the control if the text has been modifed and the control is losing focus.
virtual void SetModificationMessage(BMessage* message) BMessage* ModificationMessage() const
Sets or returns the modification message, which is sent whenever the text is modified, even if the MultiLineTextControl is not invoked. As with BTextControl, the MultiLineTextControl takes ownership of the message passed in, so it should not be deleted by the caller. When the text is modified, before sending the message, the following entries are added to it:
Entry "when" B_INT64_TYPE: when the user modified the text, as a bigtime_t
Entry "source" B_POINTER_TYPE: a pointer to the MultiLineTextControl object
void ResetTextRect()
Resets the text rect of the child BTextView to be appropriate for the current size, taking into consideration the margins. In general, you shouldn't need to call this, it's done automatically when needed.
virtual void ResizeToWithChildren(float width, float height)
Call this instead of ResizeTo(). Since BView::ResizeTo() is not virtual, and all it does is change the view's frame, the child BTextView will not be resized with the MultiLineTextControl using ResizeTo(). ResizeToWithChildren() will resize the child BTextView appropriately.
virtual void SetTabAllowed(bool allowed) bool TabAllowed() const
Sets or returns whether tabs are allowed. If tabs are allowed, the tab key will insert a tab into the text. If tabs are not allowed, the tab key will change focus. Note that if tabs are not allowed, the user can still change focus by hitting ctrl-tab.
virtual void SetText(const char* text) const char* Text() const
Sets or returns the text contained by the text entry box.
inline void SetTextMargin(float margin) inline float TextMargin()
Sets or returns the text margin in the text entry box.
BTextView* TextView() const
Returns the child BTextView which does the main work for the MultiLineTextControl.
By Brian Tietz
Copyright 2000
Bug reports (including documentation errors) and feature requests can be sent to briant@timelinevista.com.