2006-02-10 17:22:33 +03:00
|
|
|
/*
|
2015-03-17 02:18:07 +03:00
|
|
|
* Copyright 2006-2015, Haiku, Inc. All rights reserved.
|
2006-02-10 17:22:33 +03:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
2002-07-09 16:24:59 +04:00
|
|
|
#ifndef _TEXT_CONTROL_H
|
|
|
|
#define _TEXT_CONTROL_H
|
|
|
|
|
|
|
|
|
|
|
|
#include <Control.h>
|
2006-02-10 17:22:33 +03:00
|
|
|
#include <TextView.h>
|
2002-07-09 16:24:59 +04:00
|
|
|
|
The text control is now more flexible with its layout items.
* Before, you had to have both, the text view layout item, and the label
layout item or else nothing would ever be visible.
* Now you can only create the text view item, and it will still work.
* Also, no matter the order you added the layout items, they would always
put the label on the left, and the control to the right.
* You can place the label and text view layout items anywhere now, although
you should keep in mind that the view spans over their frame unions; IOW
they should always adjacent to each other, but not necessarily horizontally
and left to right.
* No longer uses a fixed label spacing, but utilizes
BControlLook::DefaultLabelSpacing() instead.
* However, the spacing is always added to the right of the label, no matter
how you place it in the layout. Maybe one wants to add a SetLabelTextViewGap()
like method.
2012-11-04 18:23:09 +04:00
|
|
|
|
2006-08-26 20:21:15 +04:00
|
|
|
class BLayoutItem;
|
2008-02-24 23:39:29 +03:00
|
|
|
namespace BPrivate {
|
2009-08-27 15:12:41 +04:00
|
|
|
class _BTextInput_;
|
2008-02-24 23:39:29 +03:00
|
|
|
}
|
2003-06-20 14:09:19 +04:00
|
|
|
|
2009-08-27 15:12:41 +04:00
|
|
|
|
2006-02-10 17:22:33 +03:00
|
|
|
class BTextControl : public BControl {
|
2008-09-15 23:43:18 +04:00
|
|
|
public:
|
|
|
|
BTextControl(BRect frame, const char* name,
|
|
|
|
const char* label, const char* initialText,
|
|
|
|
BMessage* message,
|
2014-12-19 04:45:44 +03:00
|
|
|
uint32 resizeMask
|
2008-09-15 23:43:18 +04:00
|
|
|
= B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
The text control is now more flexible with its layout items.
* Before, you had to have both, the text view layout item, and the label
layout item or else nothing would ever be visible.
* Now you can only create the text view item, and it will still work.
* Also, no matter the order you added the layout items, they would always
put the label on the left, and the control to the right.
* You can place the label and text view layout items anywhere now, although
you should keep in mind that the view spans over their frame unions; IOW
they should always adjacent to each other, but not necessarily horizontally
and left to right.
* No longer uses a fixed label spacing, but utilizes
BControlLook::DefaultLabelSpacing() instead.
* However, the spacing is always added to the right of the label, no matter
how you place it in the layout. Maybe one wants to add a SetLabelTextViewGap()
like method.
2012-11-04 18:23:09 +04:00
|
|
|
uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
|
2008-09-15 23:43:18 +04:00
|
|
|
BTextControl(const char* name,
|
|
|
|
const char* label, const char* initialText,
|
|
|
|
BMessage* message,
|
The text control is now more flexible with its layout items.
* Before, you had to have both, the text view layout item, and the label
layout item or else nothing would ever be visible.
* Now you can only create the text view item, and it will still work.
* Also, no matter the order you added the layout items, they would always
put the label on the left, and the control to the right.
* You can place the label and text view layout items anywhere now, although
you should keep in mind that the view spans over their frame unions; IOW
they should always adjacent to each other, but not necessarily horizontally
and left to right.
* No longer uses a fixed label spacing, but utilizes
BControlLook::DefaultLabelSpacing() instead.
* However, the spacing is always added to the right of the label, no matter
how you place it in the layout. Maybe one wants to add a SetLabelTextViewGap()
like method.
2012-11-04 18:23:09 +04:00
|
|
|
uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
|
2008-09-15 23:43:18 +04:00
|
|
|
BTextControl(const char* label,
|
|
|
|
const char* initialText,
|
The text control is now more flexible with its layout items.
* Before, you had to have both, the text view layout item, and the label
layout item or else nothing would ever be visible.
* Now you can only create the text view item, and it will still work.
* Also, no matter the order you added the layout items, they would always
put the label on the left, and the control to the right.
* You can place the label and text view layout items anywhere now, although
you should keep in mind that the view spans over their frame unions; IOW
they should always adjacent to each other, but not necessarily horizontally
and left to right.
* No longer uses a fixed label spacing, but utilizes
BControlLook::DefaultLabelSpacing() instead.
* However, the spacing is always added to the right of the label, no matter
how you place it in the layout. Maybe one wants to add a SetLabelTextViewGap()
like method.
2012-11-04 18:23:09 +04:00
|
|
|
BMessage* message);
|
2008-09-15 23:43:18 +04:00
|
|
|
virtual ~BTextControl();
|
|
|
|
|
|
|
|
BTextControl(BMessage* archive);
|
|
|
|
static BArchivable* Instantiate(BMessage* archive);
|
|
|
|
virtual status_t Archive(BMessage* archive,
|
|
|
|
bool deep = true) const;
|
|
|
|
|
|
|
|
virtual void SetText(const char* text);
|
|
|
|
const char* Text() const;
|
2015-03-17 02:18:07 +03:00
|
|
|
int32 TextLength() const;
|
2014-10-01 14:09:27 +04:00
|
|
|
void MarkAsInvalid(bool invalid);
|
2008-09-15 23:43:18 +04:00
|
|
|
|
|
|
|
virtual void SetValue(int32 value);
|
|
|
|
virtual status_t Invoke(BMessage* message = NULL);
|
|
|
|
|
|
|
|
BTextView* TextView() const;
|
|
|
|
|
|
|
|
virtual void SetModificationMessage(BMessage* message);
|
|
|
|
BMessage* ModificationMessage() const;
|
|
|
|
|
|
|
|
virtual void SetAlignment(alignment label, alignment text);
|
|
|
|
void GetAlignment(alignment* _label,
|
|
|
|
alignment* _text) const;
|
|
|
|
virtual void SetDivider(float position);
|
|
|
|
float Divider() const;
|
|
|
|
|
|
|
|
virtual void Draw(BRect updateRect);
|
|
|
|
virtual void MouseDown(BPoint where);
|
|
|
|
virtual void AttachedToWindow();
|
|
|
|
virtual void MakeFocus(bool focus = true);
|
2014-12-19 04:45:44 +03:00
|
|
|
virtual void SetEnabled(bool enable);
|
2008-09-15 23:43:18 +04:00
|
|
|
virtual void FrameMoved(BPoint newPosition);
|
|
|
|
virtual void FrameResized(float newWidth, float newHeight);
|
|
|
|
virtual void WindowActivated(bool active);
|
|
|
|
|
2009-08-27 15:12:41 +04:00
|
|
|
virtual void GetPreferredSize(float* _width,
|
|
|
|
float* _height);
|
2008-09-15 23:43:18 +04:00
|
|
|
virtual void ResizeToPreferred();
|
|
|
|
|
|
|
|
virtual void MessageReceived(BMessage* message);
|
2009-08-27 15:12:41 +04:00
|
|
|
virtual BHandler* ResolveSpecifier(BMessage* message,
|
|
|
|
int32 index, BMessage* specifier,
|
|
|
|
int32 what, const char* property);
|
2008-09-15 23:43:18 +04:00
|
|
|
|
2014-12-19 04:45:44 +03:00
|
|
|
virtual void MouseUp(BPoint where);
|
|
|
|
virtual void MouseMoved(BPoint where, uint32 transit,
|
2008-09-15 23:43:18 +04:00
|
|
|
const BMessage* dragMessage);
|
|
|
|
virtual void DetachedFromWindow();
|
|
|
|
|
|
|
|
virtual void AllAttached();
|
|
|
|
virtual void AllDetached();
|
|
|
|
virtual status_t GetSupportedSuites(BMessage* data);
|
|
|
|
virtual void SetFlags(uint32 flags);
|
|
|
|
|
2008-09-16 14:50:31 +04:00
|
|
|
virtual BSize MinSize();
|
|
|
|
virtual BSize MaxSize();
|
|
|
|
virtual BSize PreferredSize();
|
2013-06-30 04:33:42 +04:00
|
|
|
virtual BAlignment LayoutAlignment();
|
2008-09-16 14:50:31 +04:00
|
|
|
|
2008-09-15 23:43:18 +04:00
|
|
|
BLayoutItem* CreateLabelLayoutItem();
|
|
|
|
BLayoutItem* CreateTextViewLayoutItem();
|
|
|
|
|
2008-09-16 14:50:31 +04:00
|
|
|
protected:
|
2011-12-02 07:45:50 +04:00
|
|
|
virtual status_t AllArchived(BMessage* into) const;
|
|
|
|
virtual status_t AllUnarchived(const BMessage* from);
|
|
|
|
|
2011-10-23 01:01:47 +04:00
|
|
|
virtual void LayoutInvalidated(bool descendants);
|
2008-09-16 14:50:31 +04:00
|
|
|
virtual void DoLayout();
|
|
|
|
|
2013-12-22 05:31:47 +04:00
|
|
|
virtual status_t SetIcon(const BBitmap* icon, uint32 flags = 0);
|
|
|
|
|
2008-09-15 23:43:18 +04:00
|
|
|
private:
|
2009-08-27 15:12:41 +04:00
|
|
|
// FBC padding and forbidden methods
|
2008-09-15 23:43:18 +04:00
|
|
|
virtual status_t Perform(perform_code d, void* arg);
|
|
|
|
|
|
|
|
virtual void _ReservedTextControl1();
|
|
|
|
virtual void _ReservedTextControl2();
|
|
|
|
virtual void _ReservedTextControl3();
|
|
|
|
virtual void _ReservedTextControl4();
|
|
|
|
|
|
|
|
BTextControl& operator=(const BTextControl& other);
|
|
|
|
|
2009-08-27 15:12:41 +04:00
|
|
|
private:
|
|
|
|
class LabelLayoutItem;
|
|
|
|
class TextViewLayoutItem;
|
|
|
|
struct LayoutData;
|
|
|
|
|
|
|
|
friend class _BTextInput_;
|
|
|
|
friend class LabelLayoutItem;
|
|
|
|
friend class TextViewLayoutItem;
|
|
|
|
|
2008-09-15 23:43:18 +04:00
|
|
|
void _CommitValue();
|
2014-12-19 04:45:44 +03:00
|
|
|
void _UpdateTextViewColors(bool enable);
|
2009-08-27 15:12:41 +04:00
|
|
|
void _InitData(const char* label,
|
2010-07-28 02:16:46 +04:00
|
|
|
const BMessage* archive = NULL);
|
|
|
|
void _InitText(const char* initialText,
|
|
|
|
const BMessage* archive = NULL);
|
2008-09-15 23:43:18 +04:00
|
|
|
void _ValidateLayout();
|
|
|
|
void _LayoutTextView();
|
|
|
|
void _UpdateFrame();
|
|
|
|
|
2008-09-16 14:50:31 +04:00
|
|
|
void _ValidateLayoutData();
|
|
|
|
|
2008-09-15 23:43:18 +04:00
|
|
|
private:
|
|
|
|
BPrivate::_BTextInput_* fText;
|
|
|
|
BMessage* fModificationMessage;
|
|
|
|
alignment fLabelAlign;
|
|
|
|
float fDivider;
|
|
|
|
|
2008-09-16 14:50:31 +04:00
|
|
|
LayoutData* fLayoutData;
|
2014-10-01 14:09:27 +04:00
|
|
|
uint32 fLook;
|
2008-09-16 14:50:31 +04:00
|
|
|
|
2014-10-01 14:09:27 +04:00
|
|
|
uint32 _reserved[8];
|
2002-07-09 16:24:59 +04:00
|
|
|
};
|
|
|
|
|
2015-03-17 02:18:07 +03:00
|
|
|
|
2006-02-10 17:22:33 +03:00
|
|
|
#endif // _TEXT_CONTROL_H
|