Skip to content

Commit

Permalink
Style fixes to BMenu and related classes.
Browse files Browse the repository at this point in the history
  • Loading branch information
jscipione committed May 6, 2013
1 parent 3f5d1e7 commit d97b434
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 76 deletions.
3 changes: 2 additions & 1 deletion headers/os/interface/Menu.h
Expand Up @@ -10,6 +10,7 @@
#include <List.h>
#include <View.h>


class BMenu;
class BMenuBar;
class BMenuItem;
Expand Down Expand Up @@ -216,7 +217,7 @@ class BMenu : public BView {
void _ComputeColumnLayout(int32 index, bool bestFit,
bool moveItems, BRect* override, BRect& outRect);
void _ComputeRowLayout(int32 index, bool bestFit,
bool moveItems, BRect& outRect);
bool moveItems, BRect& outRect);
void _ComputeMatrixLayout(BRect& outRect);

BRect _CalcFrame(BPoint where, bool* scrollOn);
Expand Down
4 changes: 2 additions & 2 deletions headers/os/interface/MenuField.h
Expand Up @@ -35,7 +35,7 @@ class BMenuField : public BView {
virtual status_t Archive(BMessage* archive,
bool deep = true) const;

virtual void Draw(BRect update);
virtual void Draw(BRect updateRect);
virtual void AttachedToWindow();
virtual void AllAttached();
virtual void MouseDown(BPoint where);
Expand Down Expand Up @@ -121,7 +121,7 @@ class BMenuField : public BView {

void InitObject(const char* label);
void InitObject2();
void DrawLabel(BRect bounds, BRect update);
void DrawLabel(BRect bounds, BRect updateRect);
static void InitMenu(BMenu* menu);

int32 _MenuTask();
Expand Down
2 changes: 1 addition & 1 deletion src/kits/interface/BMCPrivate.cpp
Expand Up @@ -271,7 +271,6 @@ _BMCMenuBar_::FrameResized(float width, float height)
dirty = Bounds();
dirty.left = dirty.right - diff - 12;
Invalidate(dirty);

} else if (diff < 0) {
// clean up the dirty right line of
// the menu field when shrinking
Expand All @@ -295,6 +294,7 @@ _BMCMenuBar_::FrameResized(float width, float height)
diff = Frame().right + 2 - fMenuField->Bounds().right;
fMenuField->ResizeBy(diff, 0.0);
}

BMenuBar::FrameResized(width, height);
}

Expand Down
12 changes: 6 additions & 6 deletions src/kits/interface/Menu.cpp
Expand Up @@ -733,7 +733,7 @@ BMenu::AddItem(BMenuItem* item, BRect frame)
"be called if the menu layout is B_ITEMS_IN_MATRIX");
}

if (!item)
if (item == NULL)
return false;

item->fBounds = frame;
Expand All @@ -758,7 +758,7 @@ bool
BMenu::AddItem(BMenu* submenu)
{
BMenuItem* item = new (nothrow) BMenuItem(submenu);
if (!item)
if (item == NULL)
return false;

if (!AddItem(item, CountItems())) {
Expand All @@ -780,7 +780,7 @@ BMenu::AddItem(BMenu* submenu, int32 index)
}

BMenuItem* item = new (nothrow) BMenuItem(submenu);
if (!item)
if (item == NULL)
return false;

if (!AddItem(item, index)) {
Expand All @@ -802,7 +802,7 @@ BMenu::AddItem(BMenu* submenu, BRect frame)
}

BMenuItem* item = new (nothrow) BMenuItem(submenu);
if (!item)
if (item == NULL)
return false;

if (!AddItem(item, frame)) {
Expand Down Expand Up @@ -2848,7 +2848,8 @@ BMenu::_UpdateWindowViewSize(const bool &move)
return;

bool scroll = false;
const BPoint screenLocation = move ? ScreenLocation() : window->Frame().LeftTop();
const BPoint screenLocation = move ? ScreenLocation()
: window->Frame().LeftTop();
BRect frame = _CalcFrame(screenLocation, &scroll);
ResizeTo(frame.Width(), frame.Height());

Expand Down Expand Up @@ -3024,4 +3025,3 @@ B_IF_GCC_2(InvalidateLayout__5BMenub,_ZN5BMenu16InvalidateLayoutEb)(
{
menu->InvalidateLayout();
}

24 changes: 12 additions & 12 deletions src/kits/interface/MenuField.cpp
Expand Up @@ -353,12 +353,12 @@ BMenuField::AllUnarchived(const BMessage* from)


void
BMenuField::Draw(BRect update)
BMenuField::Draw(BRect updateRect)
{
BRect bounds(Bounds());
bool active = IsFocus() && Window()->IsActive();

DrawLabel(bounds, update);
DrawLabel(bounds, updateRect);

BRect frame(fMenuBar->Frame());

Expand All @@ -370,7 +370,7 @@ BMenuField::Draw(BRect update)
flags |= BControlLook::B_DISABLED;
if (active)
flags |= BControlLook::B_FOCUSED;
be_control_look->DrawMenuFieldFrame(this, frame, update, base,
be_control_look->DrawMenuFieldFrame(this, frame, updateRect, base,
background, flags);
}

Expand Down Expand Up @@ -423,7 +423,7 @@ BMenuField::MouseDown(BPoint where)
fMenuBar->StartMenuBar(-1, false, true, &bounds);

fMenuTaskID = spawn_thread((thread_func)_thread_entry,
"_m_task_", B_NORMAL_PRIORITY, this);
"_m_task_", B_NORMAL_PRIORITY, this);
if (fMenuTaskID >= 0)
resume_thread(fMenuTaskID);
}
Expand Down Expand Up @@ -473,9 +473,9 @@ BMenuField::MakeFocus(bool state)


void
BMenuField::MessageReceived(BMessage* msg)
BMenuField::MessageReceived(BMessage* message)
{
BView::MessageReceived(msg);
BView::MessageReceived(message);
}


Expand Down Expand Up @@ -980,7 +980,7 @@ BMenuField::InitObject2()


void
BMenuField::DrawLabel(BRect bounds, BRect update)
BMenuField::DrawLabel(BRect bounds, BRect updateRect)
{
CALLED();

Expand Down Expand Up @@ -1107,8 +1107,8 @@ BMenuField::_InitMenuBar(BMenu* menu, BRect frame, bool fixedSize)
fMenu = menu;
InitMenu(menu);

if ((Flags() & B_SUPPORTS_LAYOUT)) {
fMenuBar = new _BMCMenuBar_(fixedSize, this);
if ((Flags() & B_SUPPORTS_LAYOUT) != 0) {
fMenuBar = new _BMCMenuBar_(this);
} else {
frame.left = _MenuBarOffset();
frame.top = kVMargin;
Expand Down Expand Up @@ -1147,7 +1147,7 @@ BMenuField::_InitMenuBar(const BMessage* archive)
fFixedSizeMB = fixed;

fMenuBar = (BMenuBar*)FindView("_mc_mb_");
if (!fMenuBar) {
if (fMenuBar == NULL) {
_InitMenuBar(new BMenu(""), BRect(0, 0, 100, 15), fFixedSizeMB);
InitObject2();
} else {
Expand Down Expand Up @@ -1194,8 +1194,8 @@ BMenuField::_ValidateLayoutData()
divider = fLayoutData->label_width + 5;

// If we shan't do real layout, we let the current divider take influence.
if (!(Flags() & B_SUPPORTS_LAYOUT))
divider = max_c(divider, fDivider);
if ((Flags() & B_SUPPORTS_LAYOUT) == 0)
divider = std::max(divider, fDivider);

// get the minimal (== preferred) menu bar size
// TODO: BMenu::MinSize() is using the ResizeMode() to decide the
Expand Down

0 comments on commit d97b434

Please sign in to comment.