* Made the archive version of BTextControl::_InitData() more resistant against
a broken archive - it will now create a new _BTextInput_ child, if it couldn't find one. This fixes #2086. * Cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25123 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
cfb0e47367
commit
991c062ff3
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2001-2005, Haiku Inc.
|
||||
* Copyright 2001-2008, Haiku Inc.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
@ -8,7 +8,7 @@
|
||||
* Ingo Weinhold <bonefish@cs.tu-berlin.de>
|
||||
*/
|
||||
|
||||
/** BTextControl displays text that can act like a control. */
|
||||
/*! BTextControl displays text that can act like a control. */
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
@ -72,9 +72,8 @@ private:
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
BTextControl::BTextControl(BRect frame, const char *name, const char *label,
|
||||
const char *text, BMessage *message, uint32 mask,
|
||||
uint32 flags)
|
||||
BTextControl::BTextControl(BRect frame, const char* name, const char* label,
|
||||
const char* text, BMessage* message, uint32 mask, uint32 flags)
|
||||
: BControl(frame, name, label, message, mask, flags | B_FRAME_EVENTS)
|
||||
{
|
||||
_InitData(label, text);
|
||||
@ -82,21 +81,20 @@ BTextControl::BTextControl(BRect frame, const char *name, const char *label,
|
||||
}
|
||||
|
||||
|
||||
BTextControl::BTextControl(const char *name, const char *label,
|
||||
const char *text, BMessage *message,
|
||||
uint32 flags)
|
||||
BTextControl::BTextControl(const char* name, const char* label,
|
||||
const char* text, BMessage* message, uint32 flags)
|
||||
: BControl(BRect(0, 0, -1, -1), name, label, message, B_FOLLOW_NONE,
|
||||
flags | B_FRAME_EVENTS | B_SUPPORTS_LAYOUT)
|
||||
flags | B_FRAME_EVENTS | B_SUPPORTS_LAYOUT)
|
||||
{
|
||||
_InitData(label, text);
|
||||
_ValidateLayout();
|
||||
}
|
||||
|
||||
|
||||
BTextControl::BTextControl(const char *label,
|
||||
const char *text, BMessage *message)
|
||||
BTextControl::BTextControl(const char* label, const char* text,
|
||||
BMessage* message)
|
||||
: BControl(BRect(0, 0, -1, -1), NULL, label, message, B_FOLLOW_NONE,
|
||||
B_WILL_DRAW | B_NAVIGABLE | B_FRAME_EVENTS | B_SUPPORTS_LAYOUT)
|
||||
B_WILL_DRAW | B_NAVIGABLE | B_FRAME_EVENTS | B_SUPPORTS_LAYOUT)
|
||||
{
|
||||
_InitData(label, text);
|
||||
_ValidateLayout();
|
||||
@ -136,13 +134,13 @@ BTextControl::BTextControl(BMessage* archive)
|
||||
}
|
||||
|
||||
|
||||
BArchivable *
|
||||
BTextControl::Instantiate(BMessage *archive)
|
||||
BArchivable*
|
||||
BTextControl::Instantiate(BMessage* archive)
|
||||
{
|
||||
if (validate_instantiation(archive, "BTextControl"))
|
||||
return new BTextControl(archive);
|
||||
else
|
||||
return NULL;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@ -731,7 +729,8 @@ BTextControl::_InitData(const char* label, const char* initialText,
|
||||
|
||||
if (archive)
|
||||
fText = static_cast<BPrivate::_BTextInput_*>(FindView("_input_"));
|
||||
else {
|
||||
|
||||
if (fText == NULL) {
|
||||
BRect frame(fDivider, bounds.top,
|
||||
bounds.right, bounds.bottom);
|
||||
// we are stroking the frame around the text view, which
|
||||
|
@ -7,6 +7,9 @@
|
||||
* Marc Flerackers (mflerackers@androme.be)
|
||||
*/
|
||||
|
||||
|
||||
#include "TextInput.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -17,24 +20,22 @@
|
||||
#include <TextView.h>
|
||||
#include <Window.h>
|
||||
|
||||
#include "TextInput.h"
|
||||
|
||||
|
||||
namespace BPrivate {
|
||||
|
||||
|
||||
_BTextInput_::_BTextInput_(BRect frame, BRect textRect, uint32 resizeMask,
|
||||
uint32 flags)
|
||||
: BTextView(frame, "_input_", textRect, resizeMask, flags)
|
||||
, fPreviousText(NULL)
|
||||
: BTextView(frame, "_input_", textRect, resizeMask, flags),
|
||||
fPreviousText(NULL)
|
||||
{
|
||||
MakeResizable(true);
|
||||
}
|
||||
|
||||
|
||||
_BTextInput_::_BTextInput_(BMessage* archive)
|
||||
: BTextView(archive)
|
||||
, fPreviousText(NULL)
|
||||
: BTextView(archive),
|
||||
fPreviousText(NULL)
|
||||
{
|
||||
MakeResizable(true);
|
||||
}
|
||||
@ -46,8 +47,8 @@ _BTextInput_::~_BTextInput_()
|
||||
}
|
||||
|
||||
|
||||
BArchivable *
|
||||
_BTextInput_::Instantiate(BMessage *archive)
|
||||
BArchivable*
|
||||
_BTextInput_::Instantiate(BMessage* archive)
|
||||
{
|
||||
if (validate_instantiation(archive, "_BTextInput_"))
|
||||
return new _BTextInput_(archive);
|
||||
@ -57,7 +58,7 @@ _BTextInput_::Instantiate(BMessage *archive)
|
||||
|
||||
|
||||
status_t
|
||||
_BTextInput_::Archive(BMessage *data, bool deep) const
|
||||
_BTextInput_::Archive(BMessage* data, bool deep) const
|
||||
{
|
||||
return BTextView::Archive(data, true);
|
||||
}
|
||||
@ -173,7 +174,7 @@ _BTextInput_::SetInitialText()
|
||||
|
||||
|
||||
void
|
||||
_BTextInput_::Paste(BClipboard *clipboard)
|
||||
_BTextInput_::Paste(BClipboard* clipboard)
|
||||
{
|
||||
BTextView::Paste(clipboard);
|
||||
Invalidate();
|
||||
@ -181,13 +182,13 @@ _BTextInput_::Paste(BClipboard *clipboard)
|
||||
|
||||
|
||||
void
|
||||
_BTextInput_::InsertText(const char *inText, int32 inLength,
|
||||
int32 inOffset, const text_run_array *inRuns)
|
||||
_BTextInput_::InsertText(const char* inText, int32 inLength,
|
||||
int32 inOffset, const text_run_array* inRuns)
|
||||
{
|
||||
char *buffer = NULL;
|
||||
char* buffer = NULL;
|
||||
|
||||
if (strpbrk(inText, "\r\n") && inLength <= 1024) {
|
||||
buffer = (char *)malloc(inLength);
|
||||
buffer = (char*)malloc(inLength);
|
||||
|
||||
if (buffer) {
|
||||
strcpy(buffer, inText);
|
||||
@ -219,10 +220,10 @@ _BTextInput_::DeleteText(int32 fromOffset, int32 toOffset)
|
||||
}
|
||||
|
||||
|
||||
BTextControl *
|
||||
BTextControl*
|
||||
_BTextInput_::TextControl()
|
||||
{
|
||||
BTextControl *textControl = NULL;
|
||||
BTextControl* textControl = NULL;
|
||||
|
||||
if (Parent())
|
||||
textControl = dynamic_cast<BTextControl*>(Parent());
|
||||
|
Loading…
Reference in New Issue
Block a user