_BTextInput_: style cleanup.

This commit is contained in:
Axel Dörfler
2015-03-27 13:24:10 +01:00
parent 8bc3ecb054
commit ccc3ced21c
+14 -15
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2001-2008, Haiku Inc. All rights reserved. * Copyright 2001-2015, Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -28,8 +28,9 @@ namespace BPrivate {
_BTextInput_::_BTextInput_(BRect frame, BRect textRect, uint32 resizeMask, _BTextInput_::_BTextInput_(BRect frame, BRect textRect, uint32 resizeMask,
uint32 flags) uint32 flags)
: BTextView(frame, "_input_", textRect, resizeMask, flags), :
BTextView(frame, "_input_", textRect, resizeMask, flags),
fPreviousText(NULL) fPreviousText(NULL)
{ {
MakeResizable(true); MakeResizable(true);
@@ -37,7 +38,8 @@ _BTextInput_::_BTextInput_(BRect frame, BRect textRect, uint32 resizeMask,
_BTextInput_::_BTextInput_(BMessage* archive) _BTextInput_::_BTextInput_(BMessage* archive)
: BTextView(archive), :
BTextView(archive),
fPreviousText(NULL) fPreviousText(NULL)
{ {
MakeResizable(true); MakeResizable(true);
@@ -93,7 +95,7 @@ void
_BTextInput_::KeyDown(const char* bytes, int32 numBytes) _BTextInput_::KeyDown(const char* bytes, int32 numBytes)
{ {
switch (*bytes) { switch (*bytes) {
case B_ENTER: case B_ENTER:
{ {
if (!TextControl()->IsEnabled()) if (!TextControl()->IsEnabled())
break; break;
@@ -171,15 +173,13 @@ _BTextInput_::AlignTextRect()
// the text rect to be in the middle, normally this means there // the text rect to be in the middle, normally this means there
// is one pixel spacing on each side // is one pixel spacing on each side
BRect textRect(Bounds()); BRect textRect(Bounds());
float vInset = max_c(1, float vInset = max_c(1,
floorf((textRect.Height() - LineHeight(0)) / 2.0)); floorf((textRect.Height() - LineHeight(0)) / 2.0));
float hInset = 2; float hInset = 2;
float textFontWidth = TextRect().right; float textFontWidth = TextRect().right;
if (be_control_look != NULL) if (be_control_look != NULL) {
{ switch (Alignment()) {
switch(Alignment())
{
case B_ALIGN_LEFT: case B_ALIGN_LEFT:
hInset = be_control_look->DefaultLabelSpacing(); hInset = be_control_look->DefaultLabelSpacing();
break; break;
@@ -190,7 +190,7 @@ _BTextInput_::AlignTextRect()
break; break;
case B_ALIGN_CENTER: case B_ALIGN_CENTER:
hInset = (textRect.right - textFontWidth)/ 2.0; hInset = (textRect.right - textFontWidth) / 2.0;
break; break;
default: default:
@@ -209,7 +209,7 @@ _BTextInput_::SetInitialText()
free(fPreviousText); free(fPreviousText);
fPreviousText = NULL; fPreviousText = NULL;
if (Text()) if (Text() != NULL)
fPreviousText = strdup(Text()); fPreviousText = strdup(Text());
} }
@@ -259,11 +259,10 @@ BTextControl*
_BTextInput_::TextControl() _BTextInput_::TextControl()
{ {
BTextControl* textControl = NULL; BTextControl* textControl = NULL;
if (Parent() != NULL)
if (Parent())
textControl = dynamic_cast<BTextControl*>(Parent()); textControl = dynamic_cast<BTextControl*>(Parent());
if (!textControl) if (textControl == NULL)
debugger("_BTextInput_ should have a BTextControl as parent"); debugger("_BTextInput_ should have a BTextControl as parent");
return textControl; return textControl;