Updated BTextControl and its custom BLayoutItems. Also a bit of style cleanup. Broke up BTextControl::_InitData() method into _InitData() and _InitText() and moved initialization of the BTextView there.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37780 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2006-2009, Haiku, Inc. All rights reserved.
|
* Copyright 2006-2010, Haiku, Inc. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#ifndef _TEXT_CONTROL_H
|
#ifndef _TEXT_CONTROL_H
|
||||||
@@ -36,6 +36,8 @@ public:
|
|||||||
static BArchivable* Instantiate(BMessage* archive);
|
static BArchivable* Instantiate(BMessage* archive);
|
||||||
virtual status_t Archive(BMessage* archive,
|
virtual status_t Archive(BMessage* archive,
|
||||||
bool deep = true) const;
|
bool deep = true) const;
|
||||||
|
virtual status_t AllArchived(BMessage* into) const;
|
||||||
|
virtual status_t AllUnarchived(const BMessage* from);
|
||||||
|
|
||||||
virtual void SetText(const char* text);
|
virtual void SetText(const char* text);
|
||||||
const char* Text() const;
|
const char* Text() const;
|
||||||
@@ -117,8 +119,9 @@ private:
|
|||||||
void _CommitValue();
|
void _CommitValue();
|
||||||
void _UpdateTextViewColors(bool enabled);
|
void _UpdateTextViewColors(bool enabled);
|
||||||
void _InitData(const char* label,
|
void _InitData(const char* label,
|
||||||
const char* initialText,
|
const BMessage* archive = NULL);
|
||||||
BMessage* archive = NULL);
|
void _InitText(const char* initialText,
|
||||||
|
const BMessage* archive = NULL);
|
||||||
void _ValidateLayout();
|
void _ValidateLayout();
|
||||||
void _LayoutTextView();
|
void _LayoutTextView();
|
||||||
void _UpdateFrame();
|
void _UpdateFrame();
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
|
|
||||||
#include <binary_compatibility/Interface.h>
|
#include <binary_compatibility/Interface.h>
|
||||||
|
#include <binary_compatibility/Support.h>
|
||||||
|
|
||||||
#include "TextInput.h"
|
#include "TextInput.h"
|
||||||
|
|
||||||
@@ -43,6 +44,13 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
const char* const kFrameField = "BTextControl:layoutitem:frame";
|
||||||
|
const char* const kTextViewItemField = "BTextControl:textViewItem";
|
||||||
|
const char* const kLabelItemField = "BMenuField:labelItem";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static property_info sPropertyList[] = {
|
static property_info sPropertyList[] = {
|
||||||
{
|
{
|
||||||
"Value",
|
"Value",
|
||||||
@@ -58,6 +66,7 @@ static property_info sPropertyList[] = {
|
|||||||
class BTextControl::LabelLayoutItem : public BAbstractLayoutItem {
|
class BTextControl::LabelLayoutItem : public BAbstractLayoutItem {
|
||||||
public:
|
public:
|
||||||
LabelLayoutItem(BTextControl* parent);
|
LabelLayoutItem(BTextControl* parent);
|
||||||
|
LabelLayoutItem(BMessage* from);
|
||||||
|
|
||||||
virtual bool IsVisible();
|
virtual bool IsVisible();
|
||||||
virtual void SetVisible(bool visible);
|
virtual void SetVisible(bool visible);
|
||||||
@@ -65,6 +74,7 @@ public:
|
|||||||
virtual BRect Frame();
|
virtual BRect Frame();
|
||||||
virtual void SetFrame(BRect frame);
|
virtual void SetFrame(BRect frame);
|
||||||
|
|
||||||
|
void SetParent(BTextControl* parent);
|
||||||
virtual BView* View();
|
virtual BView* View();
|
||||||
|
|
||||||
virtual BSize BaseMinSize();
|
virtual BSize BaseMinSize();
|
||||||
@@ -72,6 +82,8 @@ public:
|
|||||||
virtual BSize BasePreferredSize();
|
virtual BSize BasePreferredSize();
|
||||||
virtual BAlignment BaseAlignment();
|
virtual BAlignment BaseAlignment();
|
||||||
|
|
||||||
|
virtual status_t Archive(BMessage* into, bool deep = true) const;
|
||||||
|
static BArchivable* Instantiate(BMessage* from);
|
||||||
private:
|
private:
|
||||||
BTextControl* fParent;
|
BTextControl* fParent;
|
||||||
BRect fFrame;
|
BRect fFrame;
|
||||||
@@ -81,6 +93,7 @@ private:
|
|||||||
class BTextControl::TextViewLayoutItem : public BAbstractLayoutItem {
|
class BTextControl::TextViewLayoutItem : public BAbstractLayoutItem {
|
||||||
public:
|
public:
|
||||||
TextViewLayoutItem(BTextControl* parent);
|
TextViewLayoutItem(BTextControl* parent);
|
||||||
|
TextViewLayoutItem(BMessage* from);
|
||||||
|
|
||||||
virtual bool IsVisible();
|
virtual bool IsVisible();
|
||||||
virtual void SetVisible(bool visible);
|
virtual void SetVisible(bool visible);
|
||||||
@@ -88,6 +101,7 @@ public:
|
|||||||
virtual BRect Frame();
|
virtual BRect Frame();
|
||||||
virtual void SetFrame(BRect frame);
|
virtual void SetFrame(BRect frame);
|
||||||
|
|
||||||
|
void SetParent(BTextControl* parent);
|
||||||
virtual BView* View();
|
virtual BView* View();
|
||||||
|
|
||||||
virtual BSize BaseMinSize();
|
virtual BSize BaseMinSize();
|
||||||
@@ -95,6 +109,8 @@ public:
|
|||||||
virtual BSize BasePreferredSize();
|
virtual BSize BasePreferredSize();
|
||||||
virtual BAlignment BaseAlignment();
|
virtual BAlignment BaseAlignment();
|
||||||
|
|
||||||
|
virtual status_t Archive(BMessage* into, bool deep = true) const;
|
||||||
|
static BArchivable* Instantiate(BMessage* from);
|
||||||
private:
|
private:
|
||||||
BTextControl* fParent;
|
BTextControl* fParent;
|
||||||
BRect fFrame;
|
BRect fFrame;
|
||||||
@@ -103,11 +119,12 @@ private:
|
|||||||
|
|
||||||
struct BTextControl::LayoutData {
|
struct BTextControl::LayoutData {
|
||||||
LayoutData(float width, float height)
|
LayoutData(float width, float height)
|
||||||
: label_layout_item(NULL),
|
:
|
||||||
text_view_layout_item(NULL),
|
label_layout_item(NULL),
|
||||||
previous_width(width),
|
text_view_layout_item(NULL),
|
||||||
previous_height(height),
|
previous_width(width),
|
||||||
valid(false)
|
previous_height(height),
|
||||||
|
valid(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,28 +150,34 @@ static const int32 kLabelInputSpacing = 3;
|
|||||||
|
|
||||||
BTextControl::BTextControl(BRect frame, const char* name, const char* label,
|
BTextControl::BTextControl(BRect frame, const char* name, const char* label,
|
||||||
const char* text, BMessage* message, uint32 mask, uint32 flags)
|
const char* text, BMessage* message, uint32 mask, uint32 flags)
|
||||||
: BControl(frame, name, label, message, mask, flags | B_FRAME_EVENTS)
|
:
|
||||||
|
BControl(frame, name, label, message, mask, flags | B_FRAME_EVENTS)
|
||||||
{
|
{
|
||||||
_InitData(label, text);
|
_InitData(label);
|
||||||
|
_InitText(text);
|
||||||
_ValidateLayout();
|
_ValidateLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BTextControl::BTextControl(const char* name, const char* label,
|
BTextControl::BTextControl(const char* name, const char* label,
|
||||||
const char* text, BMessage* message, uint32 flags)
|
const char* text, BMessage* message, uint32 flags)
|
||||||
: BControl(name, label, message, flags | B_FRAME_EVENTS)
|
:
|
||||||
|
BControl(name, label, message, flags | B_FRAME_EVENTS)
|
||||||
{
|
{
|
||||||
_InitData(label, text);
|
_InitData(label);
|
||||||
|
_InitText(text);
|
||||||
_ValidateLayout();
|
_ValidateLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BTextControl::BTextControl(const char* label, const char* text,
|
BTextControl::BTextControl(const char* label, const char* text,
|
||||||
BMessage* message)
|
BMessage* message)
|
||||||
: BControl(NULL, label, message,
|
:
|
||||||
|
BControl(NULL, label, message,
|
||||||
B_WILL_DRAW | B_NAVIGABLE | B_FRAME_EVENTS)
|
B_WILL_DRAW | B_NAVIGABLE | B_FRAME_EVENTS)
|
||||||
{
|
{
|
||||||
_InitData(label, text);
|
_InitData(label);
|
||||||
|
_InitText(text);
|
||||||
_ValidateLayout();
|
_ValidateLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,29 +190,27 @@ BTextControl::~BTextControl()
|
|||||||
|
|
||||||
|
|
||||||
BTextControl::BTextControl(BMessage* archive)
|
BTextControl::BTextControl(BMessage* archive)
|
||||||
: BControl(archive)
|
:
|
||||||
|
BControl(BUnarchiver::PrepareArchive(archive))
|
||||||
{
|
{
|
||||||
_InitData(Label(), NULL, archive);
|
BUnarchiver unarchiver(archive);
|
||||||
|
|
||||||
int32 labelAlignment = B_ALIGN_LEFT;
|
_InitData(Label(), archive);
|
||||||
int32 textAlignment = B_ALIGN_LEFT;
|
|
||||||
|
|
||||||
if (archive->HasInt32("_a_label"))
|
if (!BUnarchiver::IsArchiveManaged(archive))
|
||||||
archive->FindInt32("_a_label", &labelAlignment);
|
_InitText(NULL, archive);
|
||||||
|
|
||||||
if (archive->HasInt32("_a_text"))
|
|
||||||
archive->FindInt32("_a_text", &textAlignment);
|
|
||||||
|
|
||||||
SetAlignment((alignment)labelAlignment, (alignment)textAlignment);
|
|
||||||
|
|
||||||
|
status_t err = B_OK;
|
||||||
if (archive->HasFloat("_divide"))
|
if (archive->HasFloat("_divide"))
|
||||||
archive->FindFloat("_divide", &fDivider);
|
err = archive->FindFloat("_divide", &fDivider);
|
||||||
|
|
||||||
if (archive->HasMessage("_mod_msg")) {
|
if (err == B_OK && archive->HasMessage("_mod_msg")) {
|
||||||
BMessage* message = new BMessage;
|
BMessage* message = new BMessage;
|
||||||
archive->FindMessage("_mod_msg", message);
|
err = archive->FindMessage("_mod_msg", message);
|
||||||
SetModificationMessage(message);
|
SetModificationMessage(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unarchiver.Finish(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -206,6 +227,7 @@ BTextControl::Instantiate(BMessage* archive)
|
|||||||
status_t
|
status_t
|
||||||
BTextControl::Archive(BMessage *data, bool deep) const
|
BTextControl::Archive(BMessage *data, bool deep) const
|
||||||
{
|
{
|
||||||
|
BArchiver archiver(data);
|
||||||
status_t ret = BControl::Archive(data, deep);
|
status_t ret = BControl::Archive(data, deep);
|
||||||
alignment labelAlignment, textAlignment;
|
alignment labelAlignment, textAlignment;
|
||||||
|
|
||||||
@@ -221,7 +243,60 @@ BTextControl::Archive(BMessage *data, bool deep) const
|
|||||||
if (ModificationMessage() && (ret == B_OK))
|
if (ModificationMessage() && (ret == B_OK))
|
||||||
ret = data->AddMessage("_mod_msg", ModificationMessage());
|
ret = data->AddMessage("_mod_msg", ModificationMessage());
|
||||||
|
|
||||||
return ret;
|
return archiver.Finish(ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
BTextControl::AllArchived(BMessage* into) const
|
||||||
|
{
|
||||||
|
BArchiver archiver(into);
|
||||||
|
status_t err = B_OK;
|
||||||
|
|
||||||
|
if (archiver.IsArchived(fLayoutData->text_view_layout_item)) {
|
||||||
|
err = archiver.AddArchivable(kTextViewItemField,
|
||||||
|
fLayoutData->text_view_layout_item);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (err == B_OK && archiver.IsArchived(fLayoutData->label_layout_item)) {
|
||||||
|
err = archiver.AddArchivable(kLabelItemField,
|
||||||
|
fLayoutData->label_layout_item);
|
||||||
|
}
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
BTextControl::AllUnarchived(const BMessage* from)
|
||||||
|
{
|
||||||
|
status_t err;
|
||||||
|
if ((err = BControl::AllUnarchived(from)) != B_OK)
|
||||||
|
return err;
|
||||||
|
|
||||||
|
_InitText(NULL, from);
|
||||||
|
|
||||||
|
BUnarchiver unarchiver(from);
|
||||||
|
if (unarchiver.IsInstantiated(kTextViewItemField)) {
|
||||||
|
err = unarchiver.FindObject(kTextViewItemField,
|
||||||
|
BUnarchiver::B_DONT_ASSUME_OWNERSHIP,
|
||||||
|
fLayoutData->text_view_layout_item);
|
||||||
|
|
||||||
|
if (err == B_OK)
|
||||||
|
fLayoutData->text_view_layout_item->SetParent(this);
|
||||||
|
else
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (unarchiver.IsInstantiated(kLabelItemField)) {
|
||||||
|
err = unarchiver.FindObject(kLabelItemField,
|
||||||
|
BUnarchiver::B_DONT_ASSUME_OWNERSHIP,
|
||||||
|
fLayoutData->label_layout_item);
|
||||||
|
|
||||||
|
if (err == B_OK)
|
||||||
|
fLayoutData->label_layout_item->SetParent(this);
|
||||||
|
}
|
||||||
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -548,7 +623,7 @@ BTextControl::SetFlags(uint32 flags)
|
|||||||
if (flags & B_NAVIGABLE)
|
if (flags & B_NAVIGABLE)
|
||||||
fText->SetFlags(fText->Flags() | B_NAVIGABLE);
|
fText->SetFlags(fText->Flags() | B_NAVIGABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't make this one navigable
|
// Don't make this one navigable
|
||||||
flags &= ~B_NAVIGABLE;
|
flags &= ~B_NAVIGABLE;
|
||||||
|
|
||||||
@@ -583,13 +658,13 @@ BTextControl::MessageReceived(BMessage *message)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (handled) {
|
if (handled) {
|
||||||
message->SendReply(&reply);
|
message->SendReply(&reply);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BControl::MessageReceived(message);
|
BControl::MessageReceived(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -900,6 +975,22 @@ BTextControl::Perform(perform_code code, void* _data)
|
|||||||
BTextControl::DoLayout();
|
BTextControl::DoLayout();
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
case PERFORM_CODE_ALL_UNARCHIVED:
|
||||||
|
{
|
||||||
|
perform_data_all_unarchived* data
|
||||||
|
= (perform_data_all_unarchived*)_data;
|
||||||
|
|
||||||
|
data->return_value = BTextControl::AllUnarchived(data->archive);
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
case PERFORM_CODE_ALL_ARCHIVED:
|
||||||
|
{
|
||||||
|
perform_data_all_archived* data
|
||||||
|
= (perform_data_all_archived*)_data;
|
||||||
|
|
||||||
|
data->return_value = BTextControl::AllArchived(data->archive);
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return BControl::Perform(code, _data);
|
return BControl::Perform(code, _data);
|
||||||
@@ -956,8 +1047,7 @@ BTextControl::_CommitValue()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BTextControl::_InitData(const char* label, const char* initialText,
|
BTextControl::_InitData(const char* label, const BMessage* archive)
|
||||||
BMessage* archive)
|
|
||||||
{
|
{
|
||||||
BRect bounds(Bounds());
|
BRect bounds(Bounds());
|
||||||
|
|
||||||
@@ -984,13 +1074,20 @@ BTextControl::_InitData(const char* label, const char* initialText,
|
|||||||
fDivider = floorf(bounds.Width() / 2.0f);
|
fDivider = floorf(bounds.Width() / 2.0f);
|
||||||
|
|
||||||
uint32 navigableFlags = Flags() & B_NAVIGABLE;
|
uint32 navigableFlags = Flags() & B_NAVIGABLE;
|
||||||
if (navigableFlags != 0)
|
if (navigableFlags != 0)
|
||||||
BView::SetFlags(Flags() & ~B_NAVIGABLE);
|
BView::SetFlags(Flags() & ~B_NAVIGABLE);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BTextControl::_InitText(const char* initialText, const BMessage* archive)
|
||||||
|
{
|
||||||
if (archive)
|
if (archive)
|
||||||
fText = static_cast<BPrivate::_BTextInput_*>(FindView("_input_"));
|
fText = static_cast<BPrivate::_BTextInput_*>(FindView("_input_"));
|
||||||
|
|
||||||
if (fText == NULL) {
|
if (fText == NULL) {
|
||||||
|
BRect bounds(Bounds());
|
||||||
BRect frame(fDivider, bounds.top, bounds.right, bounds.bottom);
|
BRect frame(fDivider, bounds.top, bounds.right, bounds.bottom);
|
||||||
// we are stroking the frame around the text view, which
|
// we are stroking the frame around the text view, which
|
||||||
// is 2 pixels wide
|
// is 2 pixels wide
|
||||||
@@ -998,13 +1095,30 @@ BTextControl::_InitData(const char* label, const char* initialText,
|
|||||||
BRect textRect(frame.OffsetToCopy(B_ORIGIN));
|
BRect textRect(frame.OffsetToCopy(B_ORIGIN));
|
||||||
|
|
||||||
fText = new BPrivate::_BTextInput_(frame, textRect,
|
fText = new BPrivate::_BTextInput_(frame, textRect,
|
||||||
B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS | navigableFlags);
|
B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS
|
||||||
|
| (Flags() & B_NAVIGABLE));
|
||||||
AddChild(fText);
|
AddChild(fText);
|
||||||
|
|
||||||
SetText(initialText);
|
SetText(initialText);
|
||||||
fText->SetAlignment(B_ALIGN_LEFT);
|
fText->SetAlignment(B_ALIGN_LEFT);
|
||||||
fText->AlignTextRect();
|
fText->AlignTextRect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Although this is not strictly initializing the text view,
|
||||||
|
// it cannot be done while fText is NULL, so it resides here.
|
||||||
|
if (archive) {
|
||||||
|
int32 labelAlignment = B_ALIGN_LEFT;
|
||||||
|
int32 textAlignment = B_ALIGN_LEFT;
|
||||||
|
|
||||||
|
status_t err = B_OK;
|
||||||
|
if (archive->HasInt32("_a_label"))
|
||||||
|
err = archive->FindInt32("_a_label", &labelAlignment);
|
||||||
|
|
||||||
|
if (err == B_OK && archive->HasInt32("_a_text"))
|
||||||
|
err = archive->FindInt32("_a_text", &textAlignment);
|
||||||
|
|
||||||
|
SetAlignment((alignment)labelAlignment, (alignment)textAlignment);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1125,12 +1239,23 @@ BTextControl::_ValidateLayoutData()
|
|||||||
|
|
||||||
|
|
||||||
BTextControl::LabelLayoutItem::LabelLayoutItem(BTextControl* parent)
|
BTextControl::LabelLayoutItem::LabelLayoutItem(BTextControl* parent)
|
||||||
: fParent(parent),
|
:
|
||||||
fFrame()
|
fParent(parent),
|
||||||
|
fFrame()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BTextControl::LabelLayoutItem::LabelLayoutItem(BMessage* from)
|
||||||
|
:
|
||||||
|
BAbstractLayoutItem(from),
|
||||||
|
fParent(NULL),
|
||||||
|
fFrame()
|
||||||
|
{
|
||||||
|
from->FindRect(kFrameField, &fFrame);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
BTextControl::LabelLayoutItem::IsVisible()
|
BTextControl::LabelLayoutItem::IsVisible()
|
||||||
{
|
{
|
||||||
@@ -1160,6 +1285,13 @@ BTextControl::LabelLayoutItem::SetFrame(BRect frame)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BTextControl::LabelLayoutItem::SetParent(BTextControl* parent)
|
||||||
|
{
|
||||||
|
fParent = parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
BView*
|
BView*
|
||||||
BTextControl::LabelLayoutItem::View()
|
BTextControl::LabelLayoutItem::View()
|
||||||
{
|
{
|
||||||
@@ -1201,12 +1333,34 @@ BTextControl::LabelLayoutItem::BaseAlignment()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
BTextControl::LabelLayoutItem::Archive(BMessage* into, bool deep) const
|
||||||
|
{
|
||||||
|
BArchiver archiver(into);
|
||||||
|
status_t err = BAbstractLayoutItem::Archive(into, deep);
|
||||||
|
if (err == B_OK)
|
||||||
|
err = into->AddRect(kFrameField, fFrame);
|
||||||
|
|
||||||
|
return archiver.Finish(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BArchivable*
|
||||||
|
BTextControl::LabelLayoutItem::Instantiate(BMessage* from)
|
||||||
|
{
|
||||||
|
if (validate_instantiation(from, "BTextControl::LabelLayoutItem"))
|
||||||
|
return new LabelLayoutItem(from);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
BTextControl::TextViewLayoutItem::TextViewLayoutItem(BTextControl* parent)
|
BTextControl::TextViewLayoutItem::TextViewLayoutItem(BTextControl* parent)
|
||||||
: fParent(parent),
|
:
|
||||||
fFrame()
|
fParent(parent),
|
||||||
|
fFrame()
|
||||||
{
|
{
|
||||||
// by default the part right of the divider shall have an unlimited maximum
|
// by default the part right of the divider shall have an unlimited maximum
|
||||||
// width
|
// width
|
||||||
@@ -1214,6 +1368,16 @@ BTextControl::TextViewLayoutItem::TextViewLayoutItem(BTextControl* parent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BTextControl::TextViewLayoutItem::TextViewLayoutItem(BMessage* from)
|
||||||
|
:
|
||||||
|
BAbstractLayoutItem(from),
|
||||||
|
fParent(NULL),
|
||||||
|
fFrame()
|
||||||
|
{
|
||||||
|
from->FindRect(kFrameField, &fFrame);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
BTextControl::TextViewLayoutItem::IsVisible()
|
BTextControl::TextViewLayoutItem::IsVisible()
|
||||||
{
|
{
|
||||||
@@ -1243,6 +1407,13 @@ BTextControl::TextViewLayoutItem::SetFrame(BRect frame)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BTextControl::TextViewLayoutItem::SetParent(BTextControl* parent)
|
||||||
|
{
|
||||||
|
fParent = parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
BView*
|
BView*
|
||||||
BTextControl::TextViewLayoutItem::View()
|
BTextControl::TextViewLayoutItem::View()
|
||||||
{
|
{
|
||||||
@@ -1288,3 +1459,25 @@ BTextControl::TextViewLayoutItem::BaseAlignment()
|
|||||||
return BAlignment(B_ALIGN_USE_FULL_WIDTH, B_ALIGN_USE_FULL_HEIGHT);
|
return BAlignment(B_ALIGN_USE_FULL_WIDTH, B_ALIGN_USE_FULL_HEIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
BTextControl::TextViewLayoutItem::Archive(BMessage* into, bool deep) const
|
||||||
|
{
|
||||||
|
BArchiver archiver(into);
|
||||||
|
status_t err = BAbstractLayoutItem::Archive(into, deep);
|
||||||
|
if (err == B_OK)
|
||||||
|
err = into->AddRect(kFrameField, fFrame);
|
||||||
|
|
||||||
|
return archiver.Finish(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BArchivable*
|
||||||
|
BTextControl::TextViewLayoutItem::Instantiate(BMessage* from)
|
||||||
|
{
|
||||||
|
if (validate_instantiation(from, "BTextControl::TextViewLayoutItem"))
|
||||||
|
return new TextViewLayoutItem(from);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user