* Cleanup, no functional change.

* Remove superfluous operator=() implementations.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32174 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2009-08-07 08:01:27 +00:00
parent d82ea8abda
commit 50f8cd14bb
6 changed files with 320 additions and 319 deletions

View File

@ -1,17 +1,19 @@
/*
* Copyright 2006-2008, Haiku, Inc. All Rights Reserved.
* Copyright 2006-2009, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _MENU_FIELD_H
#define _MENU_FIELD_H
#include <BeBuild.h>
#include <Menu.h> /* For convenience */
#include <Menu.h>
#include <View.h>
class BMenuBar;
class BMenuField : public BView {
public:
BMenuField(BRect frame, const char* name,
@ -107,8 +109,7 @@ private:
virtual void _ReservedMenuField2();
virtual void _ReservedMenuField3();
BMenuField &operator=(const BMenuField&);
BMenuField& operator=(const BMenuField& other);
void InitObject(const char* label);
void InitObject2();

View File

@ -52,13 +52,6 @@ _BMCFilter_::Filter(BMessage *message, BHandler **handler)
}
_BMCFilter_ &
_BMCFilter_::operator=(const _BMCFilter_ &)
{
return *this;
}
// #pragma mark -
@ -389,13 +382,6 @@ _BMCMenuBar_::MaxSize()
}
_BMCMenuBar_
&_BMCMenuBar_::operator=(const _BMCMenuBar_ &)
{
return *this;
}
void
_BMCMenuBar_::_Init(bool setMaxContentWidth)
{

View File

@ -8,6 +8,7 @@
* Rene Gollent (anevilyak@gmail.com)
*/
#include <Menu.h>
#include <new>
@ -399,9 +400,10 @@ BMenu::AddItem(BMenuItem *item)
bool
BMenu::AddItem(BMenuItem* item, int32 index)
{
if (fLayout == B_ITEMS_IN_MATRIX)
if (fLayout == B_ITEMS_IN_MATRIX) {
debugger("BMenu::AddItem(BMenuItem*, int32) this method can only "
"be called if the menu layout is not B_ITEMS_IN_MATRIX");
}
if (!item || !_AddItem(item, index))
return false;
@ -422,9 +424,10 @@ BMenu::AddItem(BMenuItem *item, int32 index)
bool
BMenu::AddItem(BMenuItem* item, BRect frame)
{
if (fLayout != B_ITEMS_IN_MATRIX)
if (fLayout != B_ITEMS_IN_MATRIX) {
debugger("BMenu::AddItem(BMenuItem*, BRect) this method can only "
"be called if the menu layout is B_ITEMS_IN_MATRIX");
}
if (!item)
return false;
@ -468,9 +471,10 @@ BMenu::AddItem(BMenu *submenu)
bool
BMenu::AddItem(BMenu* submenu, int32 index)
{
if (fLayout == B_ITEMS_IN_MATRIX)
if (fLayout == B_ITEMS_IN_MATRIX) {
debugger("BMenu::AddItem(BMenuItem*, int32) this method can only "
"be called if the menu layout is not B_ITEMS_IN_MATRIX");
}
BMenuItem* item = new (nothrow) BMenuItem(submenu);
if (!item)
@ -489,9 +493,10 @@ BMenu::AddItem(BMenu *submenu, int32 index)
bool
BMenu::AddItem(BMenu* submenu, BRect frame)
{
if (fLayout != B_ITEMS_IN_MATRIX)
if (fLayout != B_ITEMS_IN_MATRIX) {
debugger("BMenu::AddItem(BMenu*, BRect) this method can only "
"be called if the menu layout is B_ITEMS_IN_MATRIX");
}
BMenuItem* item = new (nothrow) BMenuItem(submenu);
if (!item)
@ -607,7 +612,7 @@ BMenu *
BMenu::SubmenuAt(int32 index) const
{
BMenuItem* item = static_cast<BMenuItem*>(fItems.ItemAt(index));
return (item != NULL) ? item->Submenu() : NULL;
return item != NULL ? item->Submenu() : NULL;
}
@ -1364,13 +1369,6 @@ void BMenu::_ReservedMenu5() {}
void BMenu::_ReservedMenu6() {}
BMenu &
BMenu::operator=(const BMenu &)
{
return *this;
}
void
BMenu::_InitData(BMessage* archive)
{
@ -1627,7 +1625,8 @@ BMenu::_Track(int *action, long start)
// mouseSpeed in px per ms
// (actually point_distance returns the square of the distance,
// so it's more px^2 per ms)
mouseSpeed = (int32)(point_distance(newLocation, location) * 1000 / (newPollTime - pollTime));
mouseSpeed = (int32)(point_distance(newLocation, location) * 1000
/ (newPollTime - pollTime));
pollTime = newPollTime;
if (newLocation != location || newButtons != buttons) {
@ -2217,7 +2216,6 @@ BMenu::_CalcFrame(BPoint where, bool *scrollOn)
frame.OffsetBy(screenFrame.right - frame.right, 0);
else if (frame.left < screenFrame.left)
frame.OffsetBy(-frame.left, 0);
} else if (superMenu->Layout() == B_ITEMS_IN_COLUMN) {
if (frame.right > screenFrame.right)
frame.OffsetBy(-superItem->Frame().Width() - frame.Width() - 2, 0);
@ -2640,8 +2638,8 @@ BMenu::_UpdateWindowViewSize(bool updatePosition)
return;
bool scroll = false;
const BPoint screenLocation = updatePosition ? ScreenLocation()
: window->Frame().LeftTop();
const BPoint screenLocation = updatePosition
? ScreenLocation() : window->Frame().LeftTop();
BRect frame = _CalcFrame(screenLocation, &scroll);
ResizeTo(frame.Width(), frame.Height());
@ -2732,7 +2730,8 @@ BMenu::_QuitTracking(bool onlyThis)
// TODO: Maybe the following two methods would fit better into InterfaceDefs.cpp
// In R5, they do all the work client side, we let the app_server handle the details.
// In R5, they do all the work client side, we let the app_server handle the
// details.
status_t
set_menu_info(menu_info* info)
{

View File

@ -8,6 +8,7 @@
* Stephan Aßmus <superstippi@gmx.de>
*/
#include <MenuBar.h>
#include <math.h>
@ -44,7 +45,8 @@ struct menubar_data {
BMenuBar::BMenuBar(BRect frame, const char* title, uint32 resizeMask,
menu_layout layout, bool resizeToFit)
: BMenu(frame, title, resizeMask, B_WILL_DRAW | B_FRAME_EVENTS, layout,
:
BMenu(frame, title, resizeMask, B_WILL_DRAW | B_FRAME_EVENTS, layout,
resizeToFit),
fBorder(B_BORDER_FRAME),
fTrackingPID(-1),
@ -58,7 +60,8 @@ BMenuBar::BMenuBar(BRect frame, const char *title, uint32 resizeMask,
BMenuBar::BMenuBar(const char* title, menu_layout layout, uint32 flags)
: BMenu(BRect(), title, B_FOLLOW_NONE,
:
BMenu(BRect(), title, B_FOLLOW_NONE,
flags | B_WILL_DRAW | B_FRAME_EVENTS | B_SUPPORTS_LAYOUT,
layout, false),
fBorder(B_BORDER_FRAME),
@ -73,7 +76,8 @@ BMenuBar::BMenuBar(const char *title, menu_layout layout, uint32 flags)
BMenuBar::BMenuBar(BMessage* data)
: BMenu(data),
:
BMenu(data),
fBorder(B_BORDER_FRAME),
fTrackingPID(-1),
fPrevFocusToken(-1),
@ -183,7 +187,8 @@ BMenuBar::Draw(BRect updateRect)
BPoint(bounds.right, bounds.bottom - 1.0f));
SetHighColor(tint_color(noTint, B_DARKEN_2_TINT));
StrokeLine(BPoint(0.0f, bounds.bottom), BPoint(bounds.right, bounds.bottom));
StrokeLine(BPoint(0.0f, bounds.bottom),
BPoint(bounds.right, bounds.bottom));
StrokeLine(BPoint(bounds.right, 0.0f), BPoint(bounds.right, bounds.bottom));
SetHighColor(color);
@ -294,7 +299,8 @@ BMenuBar::Hide()
BHandler*
BMenuBar::ResolveSpecifier(BMessage *msg, int32 index, BMessage *specifier, int32 form, const char *property)
BMenuBar::ResolveSpecifier(BMessage* msg, int32 index, BMessage* specifier,
int32 form, const char* property)
{
return BMenu::ResolveSpecifier(msg, index, specifier, form, property);
}
@ -438,7 +444,8 @@ BMenuBar::operator=(const BMenuBar &)
void
BMenuBar::StartMenuBar(int32 menuIndex, bool sticky, bool showMenu, BRect *specialRect)
BMenuBar::StartMenuBar(int32 menuIndex, bool sticky, bool showMenu,
BRect* specialRect)
{
if (fTracking)
return;
@ -461,7 +468,8 @@ BMenuBar::StartMenuBar(int32 menuIndex, bool sticky, bool showMenu, BRect *speci
fMenuSem = create_sem(0, "window close sem");
_set_menu_sem_(window, fMenuSem);
fTrackingPID = spawn_thread(_TrackTask, "menu_tracking", B_DISPLAY_PRIORITY, NULL);
fTrackingPID = spawn_thread(_TrackTask, "menu_tracking", B_DISPLAY_PRIORITY,
NULL);
if (fTrackingPID >= 0) {
menubar_data data;
data.menuBar = this;
@ -482,8 +490,7 @@ BMenuBar::StartMenuBar(int32 menuIndex, bool sticky, bool showMenu, BRect *speci
}
/* static */
int32
/*static*/ int32
BMenuBar::_TrackTask(void* arg)
{
menubar_data data;
@ -571,7 +578,8 @@ BMenuBar::_Track(int32 *action, int32 startIndex, bool showMenu)
// that are children of BMenuFields "sticky" (see ticket #953)
if (localAction == MENU_STATE_CLOSED) {
if (fExtraRect != NULL && fExtraRect->Contains(where)
// 9 = 3 pixels ^ 2 (since point_distance() returns the square of the distance)
// 9 = 3 pixels ^ 2 (since point_distance() returns the
// square of the distance)
&& point_distance(newWhere, where) < 9) {
_SetStickyMode(true);
fExtraRect = NULL;
@ -687,7 +695,8 @@ BMenuBar::_RestoreFocus()
if (window != NULL && window->Lock()) {
BHandler* handler = NULL;
if (fPrevFocusToken != -1
&& gDefaultTokens.GetToken(fPrevFocusToken, B_HANDLER_TOKEN, (void **)&handler) == B_OK) {
&& gDefaultTokens.GetToken(fPrevFocusToken, B_HANDLER_TOKEN,
(void**)&handler) == B_OK) {
BView* view = dynamic_cast<BView*>(handler);
if (view != NULL && view->Window() == window)
view->MakeFocus();

View File

@ -1,5 +1,5 @@
/*
* Copyright 2001-2008, Haiku, Inc.
* Copyright 2001-2009, Haiku, Inc.
* Distributed under the terms of the MIT License.
*
* Authors:
@ -8,6 +8,7 @@
* Ingo Weinhold <bonefish@cs.tu-berlin.de>
*/
#include <MenuField.h>
#include <stdlib.h>
@ -87,7 +88,8 @@ private:
struct BMenuField::LayoutData {
LayoutData()
: label_layout_item(NULL),
:
label_layout_item(NULL),
menu_bar_layout_item(NULL),
previous_height(-1),
valid(false)
@ -115,7 +117,8 @@ static float kVMargin = 2.0f;
BMenuField::BMenuField(BRect frame, const char* name, const char* label,
BMenu* menu, uint32 resize, uint32 flags)
: BView(frame, name, resize, flags)
:
BView(frame, name, resize, flags)
{
CALLED();
@ -132,7 +135,8 @@ BMenuField::BMenuField(BRect frame, const char *name, const char *label,
BMenuField::BMenuField(BRect frame, const char* name, const char* label,
BMenu* menu, bool fixedSize, uint32 resize, uint32 flags)
: BView(frame, name, resize, flags)
:
BView(frame, name, resize, flags)
{
InitObject(label);
@ -147,7 +151,8 @@ BMenuField::BMenuField(BRect frame, const char *name, const char *label,
BMenuField::BMenuField(const char* name, const char* label, BMenu* menu,
BMessage* message, uint32 flags)
: BView(name, flags | B_FRAME_EVENTS)
:
BView(name, flags | B_FRAME_EVENTS)
{
InitObject(label);
@ -157,9 +162,9 @@ BMenuField::BMenuField(const char* name, const char* label, BMenu* menu,
}
BMenuField::BMenuField(const char* label,
BMenu* menu, BMessage* message)
: BView(NULL, B_WILL_DRAW | B_NAVIGABLE | B_FRAME_EVENTS)
BMenuField::BMenuField(const char* label, BMenu* menu, BMessage* message)
:
BView(NULL, B_WILL_DRAW | B_NAVIGABLE | B_FRAME_EVENTS)
{
InitObject(label);
@ -170,7 +175,8 @@ BMenuField::BMenuField(const char* label,
BMenuField::BMenuField(BMessage* data)
: BView(data)
:
BView(data)
{
const char* label = NULL;
data->FindString("_label", &label);
@ -200,10 +206,9 @@ BMenuField::BMenuField(BMessage *data)
bool dmark = false;
data->FindBool("be:dmark", &dmark);
if (_BMCMenuBar_ *menuBar = dynamic_cast<_BMCMenuBar_ *>(fMenuBar)) {
if (_BMCMenuBar_* menuBar = dynamic_cast<_BMCMenuBar_*>(fMenuBar))
menuBar->TogglePopUpMarker(dmark);
}
}
BMenuField::~BMenuField()
@ -248,9 +253,9 @@ BMenuField::Archive(BMessage *data, bool deep) const
ret = data->AddBool("be:fixeds", true);
bool dmark = false;
if (_BMCMenuBar_ *menuBar = dynamic_cast<_BMCMenuBar_ *>(fMenuBar)) {
if (_BMCMenuBar_* menuBar = dynamic_cast<_BMCMenuBar_*>(fMenuBar))
dmark = menuBar->IsPopUpMarkerShown();
}
data->AddBool("be:dmark", dmark);
return ret;
@ -854,13 +859,6 @@ void BMenuField::_ReservedMenuField2() {}
void BMenuField::_ReservedMenuField3() {}
BMenuField &
BMenuField::operator=(const BMenuField &)
{
return *this;
}
void
BMenuField::InitObject(const char* label)
{
@ -957,8 +955,7 @@ BMenuField::InitMenu(BMenu *menu)
}
/* static */
int32
/*static*/ int32
BMenuField::_thread_entry(void* arg)
{
return static_cast<BMenuField*>(arg)->_MenuTask();
@ -1098,7 +1095,7 @@ BMenuField::_ValidateLayoutData()
// TODO: BMenu::MinSize() is using the ResizeMode() to decide the
// minimum width. If the mode is B_FOLLOW_LEFT_RIGHT, it will use the
// parent's frame width or window's frame width. So at least the returned
// size is wrong, but appearantly it doesn't have much bad effect.
// size is wrong, but apparantly it doesn't have much bad effect.
fLayoutData->menu_bar_min = fMenuBar->MinSize();
TRACE("menu bar min width: %.2f\n", fLayoutData->menu_bar_min.width);
@ -1117,7 +1114,6 @@ BMenuField::_ValidateLayoutData()
fLayoutData->valid = true;
TRACE("width: %.2f, height: %.2f\n", min.width, min.height);
}

View File

@ -27,7 +27,8 @@ class BMenuScroller : public BView {
BMenuScroller(BRect frame);
bool IsEnabled() const;
void SetEnabled(const bool &enabled);
void SetEnabled(bool enabled);
private:
bool fEnabled;
};
@ -51,6 +52,7 @@ class BMenuFrame : public BView {
class UpperScroller : public BMenuScroller {
public:
UpperScroller(BRect frame);
virtual void Draw(BRect updateRect);
};
@ -58,6 +60,7 @@ public:
class LowerScroller : public BMenuScroller {
public:
LowerScroller(BRect frame);
virtual void Draw(BRect updateRect);
};
@ -72,7 +75,8 @@ const int kScrollerHeight = 10;
BMenuScroller::BMenuScroller(BRect frame)
: BView(frame, "menu scroller", 0, B_WILL_DRAW | B_FRAME_EVENTS),
:
BView(frame, "menu scroller", 0, B_WILL_DRAW | B_FRAME_EVENTS),
fEnabled(false)
{
SetViewColor(ui_color(B_MENU_BACKGROUND_COLOR));
@ -87,7 +91,7 @@ BMenuScroller::IsEnabled() const
void
BMenuScroller::SetEnabled(const bool &enabled)
BMenuScroller::SetEnabled(bool enabled)
{
fEnabled = enabled;
}
@ -112,9 +116,10 @@ UpperScroller::Draw(BRect updateRect)
// Draw the upper arrow.
if (IsEnabled())
SetHighColor(0, 0, 0);
else
else {
SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR),
B_DARKEN_2_TINT));
}
FillRect(Bounds(), B_SOLID_LOW);
@ -143,9 +148,10 @@ LowerScroller::Draw(BRect updateRect)
// Draw the lower arrow.
if (IsEnabled())
SetHighColor(0, 0, 0);
else
else {
SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR),
B_DARKEN_2_TINT));
}
FillRect(frame, B_SOLID_LOW);
@ -161,7 +167,8 @@ LowerScroller::Draw(BRect updateRect)
BMenuFrame::BMenuFrame(BMenu *menu)
: BView(BRect(0, 0, 1, 1), "menu frame", B_FOLLOW_ALL_SIDES, B_WILL_DRAW),
:
BView(BRect(0, 0, 1, 1), "menu frame", B_FOLLOW_ALL_SIDES, B_WILL_DRAW),
fMenu(menu)
{
}
@ -205,8 +212,8 @@ BMenuFrame::Draw(BRect updateRect)
// TODO: Review this as it's a bit hacky.
// Menu has a size of 0, 0, since there are no items in it.
// So the BMenuFrame class has to fake it and draw an empty item.
// Note that we can't add a real "empty" item because then we couldn't
// tell if the item was added by us or not.
// Note that we can't add a real "empty" item because then we
// couldn't tell if the item was added by us or not.
// See also BMenu::UpdateWindowViewSize()
SetHighColor(ui_color(B_MENU_BACKGROUND_COLOR));
SetLowColor(HighColor());
@ -215,8 +222,11 @@ BMenuFrame::Draw(BRect updateRect)
font_height height;
GetFontHeight(&height);
SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), B_DISABLED_LABEL_TINT));
BPoint where((Bounds().Width() - fMenu->StringWidth(kEmptyMenuLabel)) / 2, ceilf(height.ascent + 1));
SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR),
B_DISABLED_LABEL_TINT));
BPoint where(
(Bounds().Width() - fMenu->StringWidth(kEmptyMenuLabel)) / 2,
ceilf(height.ascent + 1));
DrawString(kEmptyMenuLabel, where);
}