* Replaced some "new" with new(std::nothrow) where appropriate in our base
classes (BView, BWindow, BAlert, BButton - BTextView should be part of this, too, to make BAlerts work). * However, it's not that simple, because there is often no way to return an error. Most of that code obviously assumes to be able to throw exceptions (it's just not communicated to the caller). Maybe we should just start documenting exceptions for R1 (and properly use exceptions later on). * Automatic white space cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28646 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2001-2006, Haiku.
|
* Copyright 2001-2008, Haiku.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -73,7 +73,7 @@ icon_layout_scale()
|
|||||||
#ifdef __HAIKU__
|
#ifdef __HAIKU__
|
||||||
return max_c(1, ((int32)be_plain_font->Size() + 15) / 16);
|
return max_c(1, ((int32)be_plain_font->Size() + 15) / 16);
|
||||||
#endif
|
#endif
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -182,7 +182,7 @@ BAlert::BAlert(BMessage* data)
|
|||||||
if (data->FindInt32("_but_width", &temp) == B_OK)
|
if (data->FindInt32("_but_width", &temp) == B_OK)
|
||||||
fButtonWidth = (button_width)temp;
|
fButtonWidth = (button_width)temp;
|
||||||
|
|
||||||
AddCommonFilter(new _BAlertFilter_(this));
|
AddCommonFilter(new(std::nothrow) _BAlertFilter_(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -192,7 +192,7 @@ BAlert::Instantiate(BMessage* data)
|
|||||||
if (!validate_instantiation(data, "BAlert"))
|
if (!validate_instantiation(data, "BAlert"))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return new BAlert(data);
|
return new(std::nothrow) BAlert(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -440,7 +440,7 @@ void BAlert::_ReservedAlert2() {}
|
|||||||
void BAlert::_ReservedAlert3() {}
|
void BAlert::_ReservedAlert3() {}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BAlert::_InitObject(const char* text, const char* button0, const char* button1,
|
BAlert::_InitObject(const char* text, const char* button0, const char* button1,
|
||||||
const char* button2, button_width buttonWidth, button_spacing spacing,
|
const char* button2, button_width buttonWidth, button_spacing spacing,
|
||||||
alert_type type)
|
alert_type type)
|
||||||
@@ -455,7 +455,10 @@ BAlert::_InitObject(const char* text, const char* button0, const char* button1,
|
|||||||
fButtonWidth = buttonWidth;
|
fButtonWidth = buttonWidth;
|
||||||
|
|
||||||
// Set up the "_master_" view
|
// Set up the "_master_" view
|
||||||
TAlertView* view = new TAlertView(Bounds());
|
TAlertView* view = new(std::nothrow) TAlertView(Bounds());
|
||||||
|
if (view == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
AddChild(view);
|
AddChild(view);
|
||||||
view->SetBitmap(_InitIcon());
|
view->SetBitmap(_InitIcon());
|
||||||
|
|
||||||
@@ -541,9 +544,12 @@ BAlert::_InitObject(const char* text, const char* button0, const char* button1,
|
|||||||
textViewRect.left = (kWindowIconOffset
|
textViewRect.left = (kWindowIconOffset
|
||||||
+ kIconStripeWidth) * iconLayoutScale - 2;
|
+ kIconStripeWidth) * iconLayoutScale - 2;
|
||||||
|
|
||||||
fTextView = new BTextView(textViewRect, "_tv_",
|
fTextView = new(std::nothrow) BTextView(textViewRect, "_tv_",
|
||||||
textViewRect.OffsetByCopy(B_ORIGIN),
|
textViewRect.OffsetByCopy(B_ORIGIN),
|
||||||
B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW);
|
B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW);
|
||||||
|
if (fTextView == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
fTextView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
fTextView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
rgb_color textColor = ui_color(B_PANEL_TEXT_COLOR);
|
rgb_color textColor = ui_color(B_PANEL_TEXT_COLOR);
|
||||||
fTextView->SetFontAndColor(be_plain_font, B_FONT_ALL, &textColor);
|
fTextView->SetFontAndColor(be_plain_font, B_FONT_ALL, &textColor);
|
||||||
@@ -562,7 +568,7 @@ BAlert::_InitObject(const char* text, const char* button0, const char* button1,
|
|||||||
textViewRect.bottom += textHeight;
|
textViewRect.bottom += textHeight;
|
||||||
fTextView->SetTextRect(textViewRect);
|
fTextView->SetTextRect(textViewRect);
|
||||||
|
|
||||||
AddCommonFilter(new _BAlertFilter_(this));
|
AddCommonFilter(new(std::nothrow) _BAlertFilter_(this));
|
||||||
|
|
||||||
MoveTo(AlertPosition(Frame().Width(), Frame().Height()));
|
MoveTo(AlertPosition(Frame().Width(), Frame().Height()));
|
||||||
}
|
}
|
||||||
@@ -602,7 +608,7 @@ BAlert::_InitIcon()
|
|||||||
strerror(status)));
|
strerror(status)));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Which icon are we trying to load?
|
// Which icon are we trying to load?
|
||||||
const char* iconName = ""; // Don't want any seg faults
|
const char* iconName = ""; // Don't want any seg faults
|
||||||
switch (alertType) {
|
switch (alertType) {
|
||||||
@@ -627,7 +633,7 @@ BAlert::_InitIcon()
|
|||||||
|
|
||||||
int32 iconSize = 32 * icon_layout_scale();
|
int32 iconSize = 32 * icon_layout_scale();
|
||||||
// Allocate the icon bitmap
|
// Allocate the icon bitmap
|
||||||
icon = new (std::nothrow) BBitmap(BRect(0, 0, iconSize - 1, iconSize - 1),
|
icon = new(std::nothrow) BBitmap(BRect(0, 0, iconSize - 1, iconSize - 1),
|
||||||
0, B_RGBA32);
|
0, B_RGBA32);
|
||||||
if (icon == NULL || icon->InitCheck() < B_OK) {
|
if (icon == NULL || icon->InitCheck() < B_OK) {
|
||||||
FTRACE((stderr, "BAlert::_InitIcon() - No memory for bitmap\n"));
|
FTRACE((stderr, "BAlert::_InitIcon() - No memory for bitmap\n"));
|
||||||
@@ -693,7 +699,7 @@ BAlert::_CreateButton(int32 which, const char* label)
|
|||||||
char name[32];
|
char name[32];
|
||||||
snprintf(name, sizeof(name), "_b%ld_", which);
|
snprintf(name, sizeof(name), "_b%ld_", which);
|
||||||
|
|
||||||
BButton* button = new (std::nothrow) BButton(rect, name, label, message,
|
BButton* button = new(std::nothrow) BButton(rect, name, label, message,
|
||||||
B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
|
B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
|
||||||
if (button == NULL)
|
if (button == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -742,7 +748,7 @@ TAlertView::Instantiate(BMessage* archive)
|
|||||||
if (!validate_instantiation(archive, "TAlertView"))
|
if (!validate_instantiation(archive, "TAlertView"))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return new TAlertView(archive);
|
return new(std::nothrow) TAlertView(archive);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2001-2005, Haiku.
|
* Copyright 2001-2008, Haiku.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -13,6 +13,8 @@
|
|||||||
|
|
||||||
#include <Button.h>
|
#include <Button.h>
|
||||||
|
|
||||||
|
#include <new>
|
||||||
|
|
||||||
#include <Font.h>
|
#include <Font.h>
|
||||||
#include <LayoutUtils.h>
|
#include <LayoutUtils.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
@@ -21,12 +23,12 @@
|
|||||||
#include <binary_compatibility/Interface.h>
|
#include <binary_compatibility/Interface.h>
|
||||||
|
|
||||||
|
|
||||||
BButton::BButton(BRect frame, const char *name, const char *label, BMessage *message,
|
BButton::BButton(BRect frame, const char* name, const char* label,
|
||||||
uint32 resizingMode, uint32 flags)
|
BMessage* message, uint32 resizingMode, uint32 flags)
|
||||||
: BControl(frame, name, label, message, resizingMode,
|
: BControl(frame, name, label, message, resizingMode,
|
||||||
flags | B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE),
|
flags | B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE),
|
||||||
fPreferredSize(-1, -1),
|
fPreferredSize(-1, -1),
|
||||||
fDrawAsDefault(false)
|
fDrawAsDefault(false)
|
||||||
{
|
{
|
||||||
// Resize to minimum height if needed
|
// Resize to minimum height if needed
|
||||||
font_height fh;
|
font_height fh;
|
||||||
@@ -37,21 +39,21 @@ BButton::BButton(BRect frame, const char *name, const char *label, BMessage *mes
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BButton::BButton(const char* name, const char* label, BMessage *message,
|
BButton::BButton(const char* name, const char* label, BMessage* message,
|
||||||
uint32 flags)
|
uint32 flags)
|
||||||
: BControl(name, label, message,
|
: BControl(name, label, message,
|
||||||
flags | B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE),
|
flags | B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE),
|
||||||
fPreferredSize(-1, -1),
|
fPreferredSize(-1, -1),
|
||||||
fDrawAsDefault(false)
|
fDrawAsDefault(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BButton::BButton(const char* label, BMessage *message)
|
BButton::BButton(const char* label, BMessage* message)
|
||||||
: BControl(NULL, label, message,
|
: BControl(NULL, label, message,
|
||||||
B_WILL_DRAW | B_NAVIGABLE | B_FULL_UPDATE_ON_RESIZE),
|
B_WILL_DRAW | B_NAVIGABLE | B_FULL_UPDATE_ON_RESIZE),
|
||||||
fPreferredSize(-1, -1),
|
fPreferredSize(-1, -1),
|
||||||
fDrawAsDefault(false)
|
fDrawAsDefault(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,9 +63,9 @@ BButton::~BButton()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BButton::BButton(BMessage *archive)
|
BButton::BButton(BMessage* archive)
|
||||||
: BControl(archive),
|
: BControl(archive),
|
||||||
fPreferredSize(-1, -1)
|
fPreferredSize(-1, -1)
|
||||||
{
|
{
|
||||||
if (archive->FindBool("_default", &fDrawAsDefault) != B_OK)
|
if (archive->FindBool("_default", &fDrawAsDefault) != B_OK)
|
||||||
fDrawAsDefault = false;
|
fDrawAsDefault = false;
|
||||||
@@ -72,11 +74,11 @@ BButton::BButton(BMessage *archive)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BArchivable *
|
BArchivable*
|
||||||
BButton::Instantiate(BMessage *archive)
|
BButton::Instantiate(BMessage* archive)
|
||||||
{
|
{
|
||||||
if (validate_instantiation(archive, "BButton"))
|
if (validate_instantiation(archive, "BButton"))
|
||||||
return new BButton(archive);
|
return new(std::nothrow) BButton(archive);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -89,7 +91,7 @@ BButton::Archive(BMessage* archive, bool deep) const
|
|||||||
|
|
||||||
if (err != B_OK)
|
if (err != B_OK)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
if (IsDefault())
|
if (IsDefault())
|
||||||
err = archive->AddBool("_default", true);
|
err = archive->AddBool("_default", true);
|
||||||
|
|
||||||
@@ -102,10 +104,10 @@ BButton::Draw(BRect updateRect)
|
|||||||
{
|
{
|
||||||
font_height fh;
|
font_height fh;
|
||||||
GetFontHeight(&fh);
|
GetFontHeight(&fh);
|
||||||
|
|
||||||
const BRect bounds = Bounds();
|
const BRect bounds = Bounds();
|
||||||
BRect rect = bounds;
|
BRect rect = bounds;
|
||||||
|
|
||||||
const bool enabled = IsEnabled();
|
const bool enabled = IsEnabled();
|
||||||
const bool pushed = Value() == B_CONTROL_ON;
|
const bool pushed = Value() == B_CONTROL_ON;
|
||||||
#if 0
|
#if 0
|
||||||
@@ -119,49 +121,49 @@ BButton::Draw(BRect updateRect)
|
|||||||
fillArea.InsetBy(3.0f, 3.0f);
|
fillArea.InsetBy(3.0f, 3.0f);
|
||||||
|
|
||||||
BString text = Label();
|
BString text = Label();
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
// Label truncation
|
// Label truncation
|
||||||
BFont font;
|
BFont font;
|
||||||
GetFont(&font);
|
GetFont(&font);
|
||||||
font.TruncateString(&text, B_TRUNCATE_END, fillArea.Width());
|
font.TruncateString(&text, B_TRUNCATE_END, fillArea.Width());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Label position
|
// Label position
|
||||||
const float stringWidth = StringWidth(text.String());
|
const float stringWidth = StringWidth(text.String());
|
||||||
const float x = (bounds.right - stringWidth) / 2.0f;
|
const float x = (bounds.right - stringWidth) / 2.0f;
|
||||||
const float labelY = bounds.top
|
const float labelY = bounds.top
|
||||||
+ ((bounds.Height() - fh.ascent - fh.descent) / 2.0f)
|
+ ((bounds.Height() - fh.ascent - fh.descent) / 2.0f)
|
||||||
+ fh.ascent + 1.0f;
|
+ fh.ascent + 1.0f;
|
||||||
const float focusLineY = labelY + fh.descent;
|
const float focusLineY = labelY + fh.descent;
|
||||||
|
|
||||||
/* speed trick:
|
/* speed trick:
|
||||||
if the focus changes but the button is not pressed then we can
|
if the focus changes but the button is not pressed then we can
|
||||||
redraw only the focus line,
|
redraw only the focus line,
|
||||||
if the focus changes and the button is pressed invert the internal rect
|
if the focus changes and the button is pressed invert the internal rect
|
||||||
this block takes care of all the focus changes
|
this block takes care of all the focus changes
|
||||||
*/
|
*/
|
||||||
if (IsFocusChanging()) {
|
if (IsFocusChanging()) {
|
||||||
if (pushed) {
|
if (pushed) {
|
||||||
rect.InsetBy(2.0, 2.0);
|
rect.InsetBy(2.0, 2.0);
|
||||||
InvertRect(rect);
|
InvertRect(rect);
|
||||||
} else
|
} else
|
||||||
DrawFocusLine(x, focusLineY, stringWidth, IsFocus() && Window()->IsActive());
|
DrawFocusLine(x, focusLineY, stringWidth, IsFocus() && Window()->IsActive());
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Colors
|
// Colors
|
||||||
const rgb_color panelBgColor = ui_color(B_PANEL_BACKGROUND_COLOR);
|
const rgb_color panelBgColor = ui_color(B_PANEL_BACKGROUND_COLOR);
|
||||||
const rgb_color buttonBgColor=tint_color(panelBgColor, B_LIGHTEN_1_TINT);
|
const rgb_color buttonBgColor=tint_color(panelBgColor, B_LIGHTEN_1_TINT);
|
||||||
const rgb_color maxLightColor=tint_color(panelBgColor, B_LIGHTEN_MAX_TINT);
|
const rgb_color maxLightColor=tint_color(panelBgColor, B_LIGHTEN_MAX_TINT);
|
||||||
const rgb_color maxShadowColor=tint_color(panelBgColor, B_DARKEN_MAX_TINT);
|
const rgb_color maxShadowColor=tint_color(panelBgColor, B_DARKEN_MAX_TINT);
|
||||||
const rgb_color darkBorderColor = tint_color(panelBgColor,
|
const rgb_color darkBorderColor = tint_color(panelBgColor,
|
||||||
enabled ? B_DARKEN_4_TINT : B_DARKEN_2_TINT);
|
enabled ? B_DARKEN_4_TINT : B_DARKEN_2_TINT);
|
||||||
const rgb_color firstBevelColor = enabled ? tint_color(panelBgColor, B_DARKEN_2_TINT)
|
const rgb_color firstBevelColor = enabled ? tint_color(panelBgColor, B_DARKEN_2_TINT)
|
||||||
: panelBgColor;
|
: panelBgColor;
|
||||||
const rgb_color cornerColor = IsDefault() ? firstBevelColor : panelBgColor;
|
const rgb_color cornerColor = IsDefault() ? firstBevelColor : panelBgColor;
|
||||||
|
|
||||||
// Fill the button area
|
// Fill the button area
|
||||||
SetHighColor(buttonBgColor);
|
SetHighColor(buttonBgColor);
|
||||||
FillRect(fillArea);
|
FillRect(fillArea);
|
||||||
@@ -169,7 +171,7 @@ BButton::Draw(BRect updateRect)
|
|||||||
// external border
|
// external border
|
||||||
SetHighColor(darkBorderColor);
|
SetHighColor(darkBorderColor);
|
||||||
StrokeRect(rect);
|
StrokeRect(rect);
|
||||||
|
|
||||||
BeginLineArray(14);
|
BeginLineArray(14);
|
||||||
|
|
||||||
// Corners
|
// Corners
|
||||||
@@ -179,30 +181,30 @@ BButton::Draw(BRect updateRect)
|
|||||||
AddLine(rect.RightBottom(), rect.RightBottom(), cornerColor);
|
AddLine(rect.RightBottom(), rect.RightBottom(), cornerColor);
|
||||||
|
|
||||||
rect.InsetBy(1.0f,1.0f);
|
rect.InsetBy(1.0f,1.0f);
|
||||||
|
|
||||||
// Shadow
|
// Shadow
|
||||||
AddLine(rect.LeftBottom(), rect.RightBottom(), firstBevelColor);
|
AddLine(rect.LeftBottom(), rect.RightBottom(), firstBevelColor);
|
||||||
AddLine(rect.RightBottom(), rect.RightTop(), firstBevelColor);
|
AddLine(rect.RightBottom(), rect.RightTop(), firstBevelColor);
|
||||||
// Light
|
// Light
|
||||||
AddLine(rect.LeftTop(), rect.LeftBottom(),buttonBgColor);
|
AddLine(rect.LeftTop(), rect.LeftBottom(),buttonBgColor);
|
||||||
AddLine(rect.LeftTop(), rect.RightTop(), buttonBgColor);
|
AddLine(rect.LeftTop(), rect.RightTop(), buttonBgColor);
|
||||||
|
|
||||||
rect.InsetBy(1.0f, 1.0f);
|
rect.InsetBy(1.0f, 1.0f);
|
||||||
|
|
||||||
// Shadow
|
// Shadow
|
||||||
AddLine(rect.LeftBottom(), rect.RightBottom(), panelBgColor);
|
AddLine(rect.LeftBottom(), rect.RightBottom(), panelBgColor);
|
||||||
AddLine(rect.RightBottom(), rect.RightTop(), panelBgColor);
|
AddLine(rect.RightBottom(), rect.RightTop(), panelBgColor);
|
||||||
// Light
|
// Light
|
||||||
AddLine(rect.LeftTop(), rect.LeftBottom(),maxLightColor);
|
AddLine(rect.LeftTop(), rect.LeftBottom(),maxLightColor);
|
||||||
AddLine(rect.LeftTop(), rect.RightTop(), maxLightColor);
|
AddLine(rect.LeftTop(), rect.RightTop(), maxLightColor);
|
||||||
|
|
||||||
rect.InsetBy(1.0f,1.0f);
|
rect.InsetBy(1.0f,1.0f);
|
||||||
|
|
||||||
// Light
|
// Light
|
||||||
AddLine(rect.LeftTop(), rect.LeftBottom(),maxLightColor);
|
AddLine(rect.LeftTop(), rect.LeftBottom(),maxLightColor);
|
||||||
AddLine(rect.LeftTop(), rect.RightTop(), maxLightColor);
|
AddLine(rect.LeftTop(), rect.RightTop(), maxLightColor);
|
||||||
|
|
||||||
EndLineArray();
|
EndLineArray();
|
||||||
|
|
||||||
// Invert if clicked
|
// Invert if clicked
|
||||||
if (enabled && pushed) {
|
if (enabled && pushed) {
|
||||||
@@ -216,12 +218,12 @@ BButton::Draw(BRect updateRect)
|
|||||||
SetHighColor(maxLightColor);
|
SetHighColor(maxLightColor);
|
||||||
SetLowColor(maxShadowColor);
|
SetLowColor(maxShadowColor);
|
||||||
} else {
|
} else {
|
||||||
SetHighColor(maxShadowColor);
|
SetHighColor(maxShadowColor);
|
||||||
SetLowColor(tint_color(panelBgColor, B_LIGHTEN_2_TINT));
|
SetLowColor(tint_color(panelBgColor, B_LIGHTEN_2_TINT));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SetHighColor(tint_color(panelBgColor, B_DISABLED_LABEL_TINT));
|
SetHighColor(tint_color(panelBgColor, B_DISABLED_LABEL_TINT));
|
||||||
SetLowColor(tint_color(panelBgColor, B_LIGHTEN_2_TINT));
|
SetLowColor(tint_color(panelBgColor, B_LIGHTEN_2_TINT));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw the label
|
// Draw the label
|
||||||
@@ -239,16 +241,16 @@ BButton::Draw(BRect updateRect)
|
|||||||
fillArea.InsetBy(3.0, 3.0);
|
fillArea.InsetBy(3.0, 3.0);
|
||||||
|
|
||||||
BString text = Label();
|
BString text = Label();
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
// Label truncation
|
// Label truncation
|
||||||
BFont font;
|
BFont font;
|
||||||
GetFont(&font);
|
GetFont(&font);
|
||||||
font.TruncateString(&text, B_TRUNCATE_END, fillArea.Width() - 4);
|
font.TruncateString(&text, B_TRUNCATE_END, fillArea.Width() - 4);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Label position
|
// Label position
|
||||||
const float stringWidth = StringWidth(text.String());
|
const float stringWidth = StringWidth(text.String());
|
||||||
const float x = (rect.right - stringWidth) / 2.0;
|
const float x = (rect.right - stringWidth) / 2.0;
|
||||||
const float labelY = bounds.top
|
const float labelY = bounds.top
|
||||||
+ ((bounds.Height() - fh.ascent - fh.descent) / 2.0)
|
+ ((bounds.Height() - fh.ascent - fh.descent) / 2.0)
|
||||||
@@ -257,11 +259,11 @@ BButton::Draw(BRect updateRect)
|
|||||||
|
|
||||||
/* speed trick:
|
/* speed trick:
|
||||||
if the focus changes but the button is not pressed then we can
|
if the focus changes but the button is not pressed then we can
|
||||||
redraw only the focus line,
|
redraw only the focus line,
|
||||||
if the focus changes and the button is pressed invert the internal rect
|
if the focus changes and the button is pressed invert the internal rect
|
||||||
this block takes care of all the focus changes
|
this block takes care of all the focus changes
|
||||||
*/
|
*/
|
||||||
if (IsFocusChanging()) {
|
if (IsFocusChanging()) {
|
||||||
if (pushed) {
|
if (pushed) {
|
||||||
rect.InsetBy(2.0, 2.0);
|
rect.InsetBy(2.0, 2.0);
|
||||||
InvertRect(rect);
|
InvertRect(rect);
|
||||||
@@ -269,16 +271,16 @@ BButton::Draw(BRect updateRect)
|
|||||||
DrawFocusLine(x, focusLineY, stringWidth, IsFocus()
|
DrawFocusLine(x, focusLineY, stringWidth, IsFocus()
|
||||||
&& Window()->IsActive());
|
&& Window()->IsActive());
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// colors
|
// colors
|
||||||
rgb_color panelBgColor = ui_color(B_PANEL_BACKGROUND_COLOR);
|
rgb_color panelBgColor = ui_color(B_PANEL_BACKGROUND_COLOR);
|
||||||
rgb_color buttonBgColor = tint_color(panelBgColor, B_LIGHTEN_1_TINT);
|
rgb_color buttonBgColor = tint_color(panelBgColor, B_LIGHTEN_1_TINT);
|
||||||
rgb_color lightColor;
|
rgb_color lightColor;
|
||||||
rgb_color maxLightColor;
|
rgb_color maxLightColor;
|
||||||
rgb_color maxShadowColor = tint_color(panelBgColor, B_DARKEN_MAX_TINT);
|
rgb_color maxShadowColor = tint_color(panelBgColor, B_DARKEN_MAX_TINT);
|
||||||
|
|
||||||
rgb_color dark1BorderColor;
|
rgb_color dark1BorderColor;
|
||||||
rgb_color dark2BorderColor;
|
rgb_color dark2BorderColor;
|
||||||
@@ -292,11 +294,11 @@ BButton::Draw(BRect updateRect)
|
|||||||
|
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
lightColor = tint_color(panelBgColor, B_LIGHTEN_2_TINT);
|
lightColor = tint_color(panelBgColor, B_LIGHTEN_2_TINT);
|
||||||
maxLightColor = tint_color(panelBgColor, B_LIGHTEN_MAX_TINT);
|
maxLightColor = tint_color(panelBgColor, B_LIGHTEN_MAX_TINT);
|
||||||
|
|
||||||
dark1BorderColor = tint_color(panelBgColor, B_DARKEN_3_TINT);
|
dark1BorderColor = tint_color(panelBgColor, B_DARKEN_3_TINT);
|
||||||
dark2BorderColor = tint_color(panelBgColor, B_DARKEN_4_TINT);
|
dark2BorderColor = tint_color(panelBgColor, B_DARKEN_4_TINT);
|
||||||
|
|
||||||
bevelColor1 = tint_color(panelBgColor, B_DARKEN_2_TINT);
|
bevelColor1 = tint_color(panelBgColor, B_DARKEN_2_TINT);
|
||||||
bevelColor2 = panelBgColor;
|
bevelColor2 = panelBgColor;
|
||||||
|
|
||||||
@@ -311,7 +313,7 @@ BButton::Draw(BRect updateRect)
|
|||||||
+ panelBgColor.green) / 2;
|
+ panelBgColor.green) / 2;
|
||||||
borderBevelLight.blue = (borderBevelLight.blue
|
borderBevelLight.blue = (borderBevelLight.blue
|
||||||
+ panelBgColor.blue) / 2;
|
+ panelBgColor.blue) / 2;
|
||||||
|
|
||||||
dark1BorderColor = tint_color(dark1BorderColor, B_DARKEN_3_TINT);
|
dark1BorderColor = tint_color(dark1BorderColor, B_DARKEN_3_TINT);
|
||||||
dark2BorderColor = tint_color(dark1BorderColor, B_DARKEN_4_TINT);
|
dark2BorderColor = tint_color(dark1BorderColor, B_DARKEN_4_TINT);
|
||||||
|
|
||||||
@@ -325,11 +327,11 @@ BButton::Draw(BRect updateRect)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
lightColor = tint_color(panelBgColor, B_LIGHTEN_2_TINT);
|
lightColor = tint_color(panelBgColor, B_LIGHTEN_2_TINT);
|
||||||
maxLightColor = tint_color(panelBgColor, B_LIGHTEN_1_TINT);
|
maxLightColor = tint_color(panelBgColor, B_LIGHTEN_1_TINT);
|
||||||
|
|
||||||
dark1BorderColor = tint_color(panelBgColor, B_DARKEN_1_TINT);
|
dark1BorderColor = tint_color(panelBgColor, B_DARKEN_1_TINT);
|
||||||
dark2BorderColor = tint_color(panelBgColor, B_DARKEN_2_TINT);
|
dark2BorderColor = tint_color(panelBgColor, B_DARKEN_2_TINT);
|
||||||
|
|
||||||
bevelColor1 = panelBgColor;
|
bevelColor1 = panelBgColor;
|
||||||
bevelColor2 = buttonBgColor;
|
bevelColor2 = buttonBgColor;
|
||||||
|
|
||||||
@@ -376,7 +378,7 @@ BButton::Draw(BRect updateRect)
|
|||||||
BPoint(rect.left + 1, rect.bottom), dark2BorderColor);
|
BPoint(rect.left + 1, rect.bottom), dark2BorderColor);
|
||||||
|
|
||||||
rect.InsetBy(1.0, 1.0);
|
rect.InsetBy(1.0, 1.0);
|
||||||
|
|
||||||
// Light
|
// Light
|
||||||
AddLine(BPoint(rect.left, rect.top),
|
AddLine(BPoint(rect.left, rect.top),
|
||||||
BPoint(rect.left, rect.top), buttonBgColor);
|
BPoint(rect.left, rect.top), buttonBgColor);
|
||||||
@@ -385,9 +387,9 @@ BButton::Draw(BRect updateRect)
|
|||||||
AddLine(BPoint(rect.left, rect.bottom),
|
AddLine(BPoint(rect.left, rect.bottom),
|
||||||
BPoint(rect.left, rect.bottom), bevelColor2);
|
BPoint(rect.left, rect.bottom), bevelColor2);
|
||||||
AddLine(BPoint(rect.left + 1, rect.top),
|
AddLine(BPoint(rect.left + 1, rect.top),
|
||||||
BPoint(rect.right - 1, rect.top), lightColor);
|
BPoint(rect.right - 1, rect.top), lightColor);
|
||||||
AddLine(BPoint(rect.right, rect.top),
|
AddLine(BPoint(rect.right, rect.top),
|
||||||
BPoint(rect.right, rect.top), bevelColor2);
|
BPoint(rect.right, rect.top), bevelColor2);
|
||||||
// Shadow
|
// Shadow
|
||||||
AddLine(BPoint(rect.left + 1, rect.bottom),
|
AddLine(BPoint(rect.left + 1, rect.bottom),
|
||||||
BPoint(rect.right - 1, rect.bottom), bevelColor1);
|
BPoint(rect.right - 1, rect.bottom), bevelColor1);
|
||||||
@@ -395,27 +397,27 @@ BButton::Draw(BRect updateRect)
|
|||||||
BPoint(rect.right, rect.bottom), bevelColorRBCorner);
|
BPoint(rect.right, rect.bottom), bevelColorRBCorner);
|
||||||
AddLine(BPoint(rect.right, rect.bottom - 1),
|
AddLine(BPoint(rect.right, rect.bottom - 1),
|
||||||
BPoint(rect.right, rect.top + 1), bevelColor1);
|
BPoint(rect.right, rect.top + 1), bevelColor1);
|
||||||
|
|
||||||
rect.InsetBy(1.0, 1.0);
|
rect.InsetBy(1.0, 1.0);
|
||||||
|
|
||||||
// Light
|
// Light
|
||||||
AddLine(BPoint(rect.left, rect.top),
|
AddLine(BPoint(rect.left, rect.top),
|
||||||
BPoint(rect.left, rect.bottom - 1), maxLightColor);
|
BPoint(rect.left, rect.bottom - 1), maxLightColor);
|
||||||
AddLine(BPoint(rect.left, rect.bottom),
|
AddLine(BPoint(rect.left, rect.bottom),
|
||||||
BPoint(rect.left, rect.bottom), buttonBgColor);
|
BPoint(rect.left, rect.bottom), buttonBgColor);
|
||||||
AddLine(BPoint(rect.left + 1, rect.top),
|
AddLine(BPoint(rect.left + 1, rect.top),
|
||||||
BPoint(rect.right - 1, rect.top), maxLightColor);
|
BPoint(rect.right - 1, rect.top), maxLightColor);
|
||||||
AddLine(BPoint(rect.right, rect.top),
|
AddLine(BPoint(rect.right, rect.top),
|
||||||
BPoint(rect.right, rect.top), buttonBgColor);
|
BPoint(rect.right, rect.top), buttonBgColor);
|
||||||
// Shadow
|
// Shadow
|
||||||
AddLine(BPoint(rect.left + 1, rect.bottom),
|
AddLine(BPoint(rect.left + 1, rect.bottom),
|
||||||
BPoint(rect.right, rect.bottom), bevelColor2);
|
BPoint(rect.right, rect.bottom), bevelColor2);
|
||||||
AddLine(BPoint(rect.right, rect.bottom - 1),
|
AddLine(BPoint(rect.right, rect.bottom - 1),
|
||||||
BPoint(rect.right, rect.top + 1), bevelColor2);
|
BPoint(rect.right, rect.top + 1), bevelColor2);
|
||||||
|
|
||||||
rect.InsetBy(1.0,1.0);
|
rect.InsetBy(1.0,1.0);
|
||||||
|
|
||||||
EndLineArray();
|
EndLineArray();
|
||||||
|
|
||||||
// Invert if clicked
|
// Invert if clicked
|
||||||
if (enabled && pushed) {
|
if (enabled && pushed) {
|
||||||
@@ -436,7 +438,7 @@ BButton::Draw(BRect updateRect)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SetHighColor(tint_color(panelBgColor, B_DISABLED_LABEL_TINT));
|
SetHighColor(tint_color(panelBgColor, B_DISABLED_LABEL_TINT));
|
||||||
SetLowColor(buttonBgColor);
|
SetLowColor(buttonBgColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw the label
|
// Draw the label
|
||||||
@@ -445,7 +447,7 @@ BButton::Draw(BRect updateRect)
|
|||||||
// Focus line
|
// Focus line
|
||||||
if (enabled && IsFocus() && Window()->IsActive() && !pushed)
|
if (enabled && IsFocus() && Window()->IsActive() && !pushed)
|
||||||
DrawFocusLine(x, focusLineY, stringWidth, true);
|
DrawFocusLine(x, focusLineY, stringWidth, true);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -520,7 +522,7 @@ BButton::MakeDefault(bool flag)
|
|||||||
{
|
{
|
||||||
BButton *oldDefault = NULL;
|
BButton *oldDefault = NULL;
|
||||||
BWindow *window = Window();
|
BWindow *window = Window();
|
||||||
|
|
||||||
if (window)
|
if (window)
|
||||||
oldDefault = window->DefaultButton();
|
oldDefault = window->DefaultButton();
|
||||||
|
|
||||||
@@ -601,7 +603,7 @@ BButton::MouseUp(BPoint point)
|
|||||||
|
|
||||||
if (Bounds().Contains(point))
|
if (Bounds().Contains(point))
|
||||||
Invoke();
|
Invoke();
|
||||||
|
|
||||||
SetTracking(false);
|
SetTracking(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -646,7 +648,7 @@ BButton::Invoke(BMessage *message)
|
|||||||
{
|
{
|
||||||
Sync();
|
Sync();
|
||||||
snooze(50000);
|
snooze(50000);
|
||||||
|
|
||||||
status_t err = BControl::Invoke(message);
|
status_t err = BControl::Invoke(message);
|
||||||
|
|
||||||
SetValue(B_CONTROL_OFF);
|
SetValue(B_CONTROL_OFF);
|
||||||
@@ -815,7 +817,7 @@ BButton::DrawDefault(BRect bounds, bool enabled)
|
|||||||
rgb_color no_tint = ui_color(B_PANEL_BACKGROUND_COLOR),
|
rgb_color no_tint = ui_color(B_PANEL_BACKGROUND_COLOR),
|
||||||
lighten1 = tint_color(no_tint, B_LIGHTEN_1_TINT),
|
lighten1 = tint_color(no_tint, B_LIGHTEN_1_TINT),
|
||||||
darken1 = tint_color(no_tint, B_DARKEN_1_TINT);
|
darken1 = tint_color(no_tint, B_DARKEN_1_TINT);
|
||||||
|
|
||||||
rgb_color borderColor;
|
rgb_color borderColor;
|
||||||
if (enabled)
|
if (enabled)
|
||||||
borderColor = tint_color(no_tint, B_DARKEN_4_TINT);
|
borderColor = tint_color(no_tint, B_DARKEN_4_TINT);
|
||||||
@@ -847,9 +849,9 @@ BButton::DrawDefault(BRect bounds, bool enabled)
|
|||||||
float inset = enabled? 2.0f : 3.0f;
|
float inset = enabled? 2.0f : 3.0f;
|
||||||
SetHighColor(lighten1);
|
SetHighColor(lighten1);
|
||||||
|
|
||||||
FillRect(BRect(bounds.left, bounds.top,
|
FillRect(BRect(bounds.left, bounds.top,
|
||||||
bounds.right, bounds.top+inset-1.0f));
|
bounds.right, bounds.top+inset-1.0f));
|
||||||
FillRect(BRect(bounds.left, bounds.bottom-inset+1.0f,
|
FillRect(BRect(bounds.left, bounds.bottom-inset+1.0f,
|
||||||
bounds.right, bounds.bottom));
|
bounds.right, bounds.bottom));
|
||||||
FillRect(BRect(bounds.left, bounds.top+inset-1.0f,
|
FillRect(BRect(bounds.left, bounds.top+inset-1.0f,
|
||||||
bounds.left+inset-1.0f, bounds.bottom-inset+1.0f));
|
bounds.left+inset-1.0f, bounds.bottom-inset+1.0f));
|
||||||
@@ -902,7 +904,7 @@ BButton::DrawFocusLine(float x, float y, float width, bool visible)
|
|||||||
// Blue Line
|
// Blue Line
|
||||||
StrokeLine(BPoint(x, y), BPoint(x + width, y));
|
StrokeLine(BPoint(x, y), BPoint(x + width, y));
|
||||||
|
|
||||||
if (visible)
|
if (visible)
|
||||||
SetHighColor(255, 255, 255);
|
SetHighColor(255, 255, 255);
|
||||||
// White Line
|
// White Line
|
||||||
StrokeLine(BPoint(x, y + 1.0f), BPoint(x + width, y + 1.0f));
|
StrokeLine(BPoint(x, y + 1.0f), BPoint(x + width, y + 1.0f));
|
||||||
@@ -926,7 +928,7 @@ BButton::_ValidatePreferredSize()
|
|||||||
// height
|
// height
|
||||||
font_height fontHeight;
|
font_height fontHeight;
|
||||||
GetFontHeight(&fontHeight);
|
GetFontHeight(&fontHeight);
|
||||||
|
|
||||||
fPreferredSize.height
|
fPreferredSize.height
|
||||||
= ceilf((fontHeight.ascent + fontHeight.descent) * 1.8)
|
= ceilf((fontHeight.ascent + fontHeight.descent) * 1.8)
|
||||||
+ (fDrawAsDefault ? 6.0f : 0);
|
+ (fDrawAsDefault ? 6.0f : 0);
|
||||||
|
|||||||
+27
-17
@@ -482,7 +482,7 @@ BView::Instantiate(BMessage *data)
|
|||||||
if (!validate_instantiation(data , "BView"))
|
if (!validate_instantiation(data , "BView"))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return new BView(data);
|
return new(std::nothrow) BView(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1265,11 +1265,14 @@ BView::DragMessage(BMessage *message, BRect dragRect, BHandler *replyTo)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: that's not really what should happen - the app_server should take the chance
|
// TODO: that's not really what should happen - the app_server should take
|
||||||
// *NOT* to need to drag a whole bitmap around but just a frame.
|
// the chance *NOT* to need to drag a whole bitmap around but just a frame.
|
||||||
|
|
||||||
// create a drag bitmap for the rect
|
// create a drag bitmap for the rect
|
||||||
BBitmap *bitmap = new BBitmap(dragRect, B_RGBA32);
|
BBitmap *bitmap = new(std::nothrow) BBitmap(dragRect, B_RGBA32);
|
||||||
|
if (bitmap == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
uint32 *bits = (uint32*)bitmap->Bits();
|
uint32 *bits = (uint32*)bitmap->Bits();
|
||||||
uint32 bytesPerRow = bitmap->BytesPerRow();
|
uint32 bytesPerRow = bitmap->BytesPerRow();
|
||||||
uint32 width = dragRect.IntegerWidth() + 1;
|
uint32 width = dragRect.IntegerWidth() + 1;
|
||||||
@@ -1316,7 +1319,7 @@ BView::DragMessage(BMessage *message, BBitmap *image,
|
|||||||
if (image == NULL) {
|
if (image == NULL) {
|
||||||
// TODO: workaround for drags without a bitmap - should not be necessary if
|
// TODO: workaround for drags without a bitmap - should not be necessary if
|
||||||
// we move the rectangle dragging into the app_server
|
// we move the rectangle dragging into the app_server
|
||||||
image = new (nothrow) BBitmap(BRect(0, 0, 0, 0), B_RGBA32);
|
image = new(std::nothrow) BBitmap(BRect(0, 0, 0, 0), B_RGBA32);
|
||||||
if (image == NULL)
|
if (image == NULL)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1348,8 +1351,8 @@ BView::DragMessage(BMessage *message, BBitmap *image,
|
|||||||
// TODO: create area and flatten message into that area!
|
// TODO: create area and flatten message into that area!
|
||||||
// send area info over port, not the actual message!
|
// send area info over port, not the actual message!
|
||||||
int32 bufferSize = privateMessage.NativeFlattenedSize();
|
int32 bufferSize = privateMessage.NativeFlattenedSize();
|
||||||
char* buffer = new (nothrow) char[bufferSize];
|
char* buffer = new(std::nothrow) char[bufferSize];
|
||||||
if (buffer) {
|
if (buffer != NULL) {
|
||||||
privateMessage.NativeFlatten(buffer, bufferSize);
|
privateMessage.NativeFlatten(buffer, bufferSize);
|
||||||
|
|
||||||
fOwner->fLink->StartMessage(AS_VIEW_DRAG_IMAGE);
|
fOwner->fLink->StartMessage(AS_VIEW_DRAG_IMAGE);
|
||||||
@@ -3373,12 +3376,14 @@ BView::BeginLineArray(int32 count)
|
|||||||
// not fatal, but it helps during
|
// not fatal, but it helps during
|
||||||
// development of your app and is in
|
// development of your app and is in
|
||||||
// line with R5...
|
// line with R5...
|
||||||
delete [] fCommArray->array;
|
delete[] fCommArray->array;
|
||||||
delete fCommArray;
|
delete fCommArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: since this method cannot return failure, and further AddLine()
|
||||||
|
// calls with a NULL fCommArray would drop into the debugger anyway,
|
||||||
|
// we allow the possible std::bad_alloc exceptions here...
|
||||||
fCommArray = new _array_data_;
|
fCommArray = new _array_data_;
|
||||||
|
|
||||||
fCommArray->maxCount = count;
|
fCommArray->maxCount = count;
|
||||||
fCommArray->count = 0;
|
fCommArray->count = 0;
|
||||||
fCommArray->array = new _array_hdr_[count];
|
fCommArray->array = new _array_hdr_[count];
|
||||||
@@ -4631,7 +4636,7 @@ BView::_InitData(BRect frame, const char *name, uint32 resizingMode,
|
|||||||
// BView constructor. This does not cause problems under BeOS as it just
|
// BView constructor. This does not cause problems under BeOS as it just
|
||||||
// ors the two fields to one 32bit flag.
|
// ors the two fields to one 32bit flag.
|
||||||
// For now we do the same but print the above warning message.
|
// For now we do the same but print the above warning message.
|
||||||
// ToDo: this should be removed at some point and the original
|
// TODO: this should be removed at some point and the original
|
||||||
// version restored:
|
// version restored:
|
||||||
// fFlags = (resizingMode & _RESIZE_MASK_) | (flags & ~_RESIZE_MASK_);
|
// fFlags = (resizingMode & _RESIZE_MASK_) | (flags & ~_RESIZE_MASK_);
|
||||||
fFlags = resizingMode | flags;
|
fFlags = resizingMode | flags;
|
||||||
@@ -4662,6 +4667,8 @@ BView::_InitData(BRect frame, const char *name, uint32 resizingMode,
|
|||||||
fIsPrinting = false;
|
fIsPrinting = false;
|
||||||
fAttached = false;
|
fAttached = false;
|
||||||
|
|
||||||
|
// TODO: Since we cannot communicate failure, we don't use std::nothrow here
|
||||||
|
// TODO: Maybe we could auto-delete those views on AddChild() instead?
|
||||||
fState = new BPrivate::ViewState;
|
fState = new BPrivate::ViewState;
|
||||||
|
|
||||||
fBounds = frame.OffsetToCopy(B_ORIGIN);
|
fBounds = frame.OffsetToCopy(B_ORIGIN);
|
||||||
@@ -4744,19 +4751,22 @@ BView::_ClipToPicture(BPicture *picture, BPoint where,
|
|||||||
bounds.right = bounds.left + ((bounds.IntegerWidth() + 1) / 32 + 1) * 32 - 1;
|
bounds.right = bounds.left + ((bounds.IntegerWidth() + 1) / 32 + 1) * 32 - 1;
|
||||||
|
|
||||||
// TODO: I used a RGBA32 bitmap because drawing on a GRAY8 doesn't work.
|
// TODO: I used a RGBA32 bitmap because drawing on a GRAY8 doesn't work.
|
||||||
BBitmap *bitmap = new BBitmap(bounds, B_RGBA32, true);
|
BBitmap *bitmap = new(std::nothrow) BBitmap(bounds, B_RGBA32, true);
|
||||||
if (bitmap && bitmap->InitCheck() == B_OK && bitmap->Lock()) {
|
if (bitmap != NULL && bitmap->InitCheck() == B_OK && bitmap->Lock()) {
|
||||||
BView *view = new BView(bounds, "drawing view", B_FOLLOW_NONE, 0);
|
BView *view = new(std::nothrow) BView(bounds, "drawing view",
|
||||||
bitmap->AddChild(view);
|
B_FOLLOW_NONE, 0);
|
||||||
view->DrawPicture(picture, where);
|
if (view != NULL) {
|
||||||
view->Sync();
|
bitmap->AddChild(view);
|
||||||
|
view->DrawPicture(picture, where);
|
||||||
|
view->Sync();
|
||||||
|
}
|
||||||
bitmap->Unlock();
|
bitmap->Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
BRegion region;
|
BRegion region;
|
||||||
int32 width = bounds.IntegerWidth() + 1;
|
int32 width = bounds.IntegerWidth() + 1;
|
||||||
int32 height = bounds.IntegerHeight() + 1;
|
int32 height = bounds.IntegerHeight() + 1;
|
||||||
if (bitmap->LockBits() == B_OK) {
|
if (bitmap != NULL && bitmap->LockBits() == B_OK) {
|
||||||
uint32 bit = 0;
|
uint32 bit = 0;
|
||||||
uint32 *bits = (uint32 *)bitmap->Bits();
|
uint32 *bits = (uint32 *)bitmap->Bits();
|
||||||
clipping_rect rect;
|
clipping_rect rect;
|
||||||
|
|||||||
@@ -424,7 +424,7 @@ BWindow::Instantiate(BMessage *data)
|
|||||||
if (!validate_instantiation(data , "BWindow"))
|
if (!validate_instantiation(data , "BWindow"))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return new BWindow(data);
|
return new(std::nothrow) BWindow(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1225,7 +1225,7 @@ FrameMoved(origin);
|
|||||||
status_t error = fLink->Read<int32>(&token);
|
status_t error = fLink->Read<int32>(&token);
|
||||||
if (error < B_OK || token == B_NULL_TOKEN)
|
if (error < B_OK || token == B_NULL_TOKEN)
|
||||||
break;
|
break;
|
||||||
ViewUpdateInfo* info = new (std::nothrow) ViewUpdateInfo;
|
ViewUpdateInfo* info = new(std::nothrow) ViewUpdateInfo;
|
||||||
if (info == NULL || !infos.AddItem(info)) {
|
if (info == NULL || !infos.AddItem(info)) {
|
||||||
delete info;
|
delete info;
|
||||||
break;
|
break;
|
||||||
@@ -1596,7 +1596,7 @@ BWindow::SetPulseRate(bigtime_t rate)
|
|||||||
if (rate > 0) {
|
if (rate > 0) {
|
||||||
if (fPulseRunner == NULL) {
|
if (fPulseRunner == NULL) {
|
||||||
BMessage message(B_PULSE);
|
BMessage message(B_PULSE);
|
||||||
fPulseRunner = new BMessageRunner(BMessenger(this),
|
fPulseRunner = new(std::nothrow) BMessageRunner(BMessenger(this),
|
||||||
&message, rate);
|
&message, rate);
|
||||||
} else {
|
} else {
|
||||||
fPulseRunner->SetInterval(rate);
|
fPulseRunner->SetInterval(rate);
|
||||||
@@ -1619,7 +1619,9 @@ BWindow::PulseRate() const
|
|||||||
void
|
void
|
||||||
BWindow::AddShortcut(uint32 key, uint32 modifiers, BMenuItem *item)
|
BWindow::AddShortcut(uint32 key, uint32 modifiers, BMenuItem *item)
|
||||||
{
|
{
|
||||||
Shortcut* shortcut = new Shortcut(key, modifiers, item);
|
Shortcut* shortcut = new(std::nothrow) Shortcut(key, modifiers, item);
|
||||||
|
if (shortcut == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
// removes the shortcut if it already exists!
|
// removes the shortcut if it already exists!
|
||||||
RemoveShortcut(key, modifiers);
|
RemoveShortcut(key, modifiers);
|
||||||
@@ -1636,12 +1638,16 @@ BWindow::AddShortcut(uint32 key, uint32 modifiers, BMessage *message)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BWindow::AddShortcut(uint32 key, uint32 modifiers, BMessage *message, BHandler *target)
|
BWindow::AddShortcut(uint32 key, uint32 modifiers, BMessage* message,
|
||||||
|
BHandler* target)
|
||||||
{
|
{
|
||||||
if (message == NULL)
|
if (message == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Shortcut* shortcut = new Shortcut(key, modifiers, message, target);
|
Shortcut* shortcut = new(std::nothrow) Shortcut(key, modifiers, message,
|
||||||
|
target);
|
||||||
|
if (shortcut == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
// removes the shortcut if it already exists!
|
// removes the shortcut if it already exists!
|
||||||
RemoveShortcut(key, modifiers);
|
RemoveShortcut(key, modifiers);
|
||||||
@@ -2569,8 +2575,12 @@ BWindow::_InitData(BRect frame, const char* title, window_look look,
|
|||||||
STRACE(("BWindow::InitData(): contacting app_server...\n"));
|
STRACE(("BWindow::InitData(): contacting app_server...\n"));
|
||||||
|
|
||||||
// let app_server know that a window has been created.
|
// let app_server know that a window has been created.
|
||||||
fLink = new BPrivate::PortLink(
|
fLink = new(std::nothrow) BPrivate::PortLink(
|
||||||
BApplication::Private::ServerLink()->SenderPort(), receivePort);
|
BApplication::Private::ServerLink()->SenderPort(), receivePort);
|
||||||
|
if (fLink == NULL) {
|
||||||
|
// Zombie!
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
BPrivate::AppServerLink lockLink;
|
BPrivate::AppServerLink lockLink;
|
||||||
@@ -2873,6 +2883,7 @@ BWindow::_CreateTopView()
|
|||||||
STRACE(("_CreateTopView(): enter\n"));
|
STRACE(("_CreateTopView(): enter\n"));
|
||||||
|
|
||||||
BRect frame = fFrame.OffsetToCopy(B_ORIGIN);
|
BRect frame = fFrame.OffsetToCopy(B_ORIGIN);
|
||||||
|
// TODO: what to do here about std::nothrow?
|
||||||
fTopView = new BView(frame, "fTopView",
|
fTopView = new BView(frame, "fTopView",
|
||||||
B_FOLLOW_ALL, B_WILL_DRAW);
|
B_FOLLOW_ALL, B_WILL_DRAW);
|
||||||
fTopView->fTopLevelView = true;
|
fTopView->fTopLevelView = true;
|
||||||
@@ -3505,7 +3516,7 @@ BView*
|
|||||||
BWindow::_FindView(BView* view, BPoint point) const
|
BWindow::_FindView(BView* view, BPoint point) const
|
||||||
{
|
{
|
||||||
// point is assumed to be already in view's coordinates
|
// point is assumed to be already in view's coordinates
|
||||||
if (!view->IsHidden() && view->Bounds().Contains(point)) {
|
if (!view->IsHidden() && view->Bounds().Contains(point)) {
|
||||||
if (!view->fFirstChild)
|
if (!view->fFirstChild)
|
||||||
return view;
|
return view;
|
||||||
else {
|
else {
|
||||||
|
|||||||
Reference in New Issue
Block a user