Style fixes to BMenu and related classes.
This commit is contained in:
@@ -10,6 +10,7 @@
|
|||||||
#include <List.h>
|
#include <List.h>
|
||||||
#include <View.h>
|
#include <View.h>
|
||||||
|
|
||||||
|
|
||||||
class BMenu;
|
class BMenu;
|
||||||
class BMenuBar;
|
class BMenuBar;
|
||||||
class BMenuItem;
|
class BMenuItem;
|
||||||
@@ -216,7 +217,7 @@ private:
|
|||||||
void _ComputeColumnLayout(int32 index, bool bestFit,
|
void _ComputeColumnLayout(int32 index, bool bestFit,
|
||||||
bool moveItems, BRect* override, BRect& outRect);
|
bool moveItems, BRect* override, BRect& outRect);
|
||||||
void _ComputeRowLayout(int32 index, bool bestFit,
|
void _ComputeRowLayout(int32 index, bool bestFit,
|
||||||
bool moveItems, BRect& outRect);
|
bool moveItems, BRect& outRect);
|
||||||
void _ComputeMatrixLayout(BRect& outRect);
|
void _ComputeMatrixLayout(BRect& outRect);
|
||||||
|
|
||||||
BRect _CalcFrame(BPoint where, bool* scrollOn);
|
BRect _CalcFrame(BPoint where, bool* scrollOn);
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public:
|
|||||||
virtual status_t Archive(BMessage* archive,
|
virtual status_t Archive(BMessage* archive,
|
||||||
bool deep = true) const;
|
bool deep = true) const;
|
||||||
|
|
||||||
virtual void Draw(BRect update);
|
virtual void Draw(BRect updateRect);
|
||||||
virtual void AttachedToWindow();
|
virtual void AttachedToWindow();
|
||||||
virtual void AllAttached();
|
virtual void AllAttached();
|
||||||
virtual void MouseDown(BPoint where);
|
virtual void MouseDown(BPoint where);
|
||||||
@@ -121,7 +121,7 @@ private:
|
|||||||
|
|
||||||
void InitObject(const char* label);
|
void InitObject(const char* label);
|
||||||
void InitObject2();
|
void InitObject2();
|
||||||
void DrawLabel(BRect bounds, BRect update);
|
void DrawLabel(BRect bounds, BRect updateRect);
|
||||||
static void InitMenu(BMenu* menu);
|
static void InitMenu(BMenu* menu);
|
||||||
|
|
||||||
int32 _MenuTask();
|
int32 _MenuTask();
|
||||||
|
|||||||
@@ -271,7 +271,6 @@ _BMCMenuBar_::FrameResized(float width, float height)
|
|||||||
dirty = Bounds();
|
dirty = Bounds();
|
||||||
dirty.left = dirty.right - diff - 12;
|
dirty.left = dirty.right - diff - 12;
|
||||||
Invalidate(dirty);
|
Invalidate(dirty);
|
||||||
|
|
||||||
} else if (diff < 0) {
|
} else if (diff < 0) {
|
||||||
// clean up the dirty right line of
|
// clean up the dirty right line of
|
||||||
// the menu field when shrinking
|
// the menu field when shrinking
|
||||||
@@ -295,6 +294,7 @@ _BMCMenuBar_::FrameResized(float width, float height)
|
|||||||
diff = Frame().right + 2 - fMenuField->Bounds().right;
|
diff = Frame().right + 2 - fMenuField->Bounds().right;
|
||||||
fMenuField->ResizeBy(diff, 0.0);
|
fMenuField->ResizeBy(diff, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
BMenuBar::FrameResized(width, height);
|
BMenuBar::FrameResized(width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -733,7 +733,7 @@ BMenu::AddItem(BMenuItem* item, BRect frame)
|
|||||||
"be called if the menu layout is B_ITEMS_IN_MATRIX");
|
"be called if the menu layout is B_ITEMS_IN_MATRIX");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!item)
|
if (item == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
item->fBounds = frame;
|
item->fBounds = frame;
|
||||||
@@ -758,7 +758,7 @@ bool
|
|||||||
BMenu::AddItem(BMenu* submenu)
|
BMenu::AddItem(BMenu* submenu)
|
||||||
{
|
{
|
||||||
BMenuItem* item = new (nothrow) BMenuItem(submenu);
|
BMenuItem* item = new (nothrow) BMenuItem(submenu);
|
||||||
if (!item)
|
if (item == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!AddItem(item, CountItems())) {
|
if (!AddItem(item, CountItems())) {
|
||||||
@@ -780,7 +780,7 @@ BMenu::AddItem(BMenu* submenu, int32 index)
|
|||||||
}
|
}
|
||||||
|
|
||||||
BMenuItem* item = new (nothrow) BMenuItem(submenu);
|
BMenuItem* item = new (nothrow) BMenuItem(submenu);
|
||||||
if (!item)
|
if (item == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!AddItem(item, index)) {
|
if (!AddItem(item, index)) {
|
||||||
@@ -802,7 +802,7 @@ BMenu::AddItem(BMenu* submenu, BRect frame)
|
|||||||
}
|
}
|
||||||
|
|
||||||
BMenuItem* item = new (nothrow) BMenuItem(submenu);
|
BMenuItem* item = new (nothrow) BMenuItem(submenu);
|
||||||
if (!item)
|
if (item == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!AddItem(item, frame)) {
|
if (!AddItem(item, frame)) {
|
||||||
@@ -2848,7 +2848,8 @@ BMenu::_UpdateWindowViewSize(const bool &move)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
bool scroll = false;
|
bool scroll = false;
|
||||||
const BPoint screenLocation = move ? ScreenLocation() : window->Frame().LeftTop();
|
const BPoint screenLocation = move ? ScreenLocation()
|
||||||
|
: window->Frame().LeftTop();
|
||||||
BRect frame = _CalcFrame(screenLocation, &scroll);
|
BRect frame = _CalcFrame(screenLocation, &scroll);
|
||||||
ResizeTo(frame.Width(), frame.Height());
|
ResizeTo(frame.Width(), frame.Height());
|
||||||
|
|
||||||
@@ -3024,4 +3025,3 @@ B_IF_GCC_2(InvalidateLayout__5BMenub,_ZN5BMenu16InvalidateLayoutEb)(
|
|||||||
{
|
{
|
||||||
menu->InvalidateLayout();
|
menu->InvalidateLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -353,12 +353,12 @@ BMenuField::AllUnarchived(const BMessage* from)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BMenuField::Draw(BRect update)
|
BMenuField::Draw(BRect updateRect)
|
||||||
{
|
{
|
||||||
BRect bounds(Bounds());
|
BRect bounds(Bounds());
|
||||||
bool active = IsFocus() && Window()->IsActive();
|
bool active = IsFocus() && Window()->IsActive();
|
||||||
|
|
||||||
DrawLabel(bounds, update);
|
DrawLabel(bounds, updateRect);
|
||||||
|
|
||||||
BRect frame(fMenuBar->Frame());
|
BRect frame(fMenuBar->Frame());
|
||||||
|
|
||||||
@@ -370,7 +370,7 @@ BMenuField::Draw(BRect update)
|
|||||||
flags |= BControlLook::B_DISABLED;
|
flags |= BControlLook::B_DISABLED;
|
||||||
if (active)
|
if (active)
|
||||||
flags |= BControlLook::B_FOCUSED;
|
flags |= BControlLook::B_FOCUSED;
|
||||||
be_control_look->DrawMenuFieldFrame(this, frame, update, base,
|
be_control_look->DrawMenuFieldFrame(this, frame, updateRect, base,
|
||||||
background, flags);
|
background, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -423,7 +423,7 @@ BMenuField::MouseDown(BPoint where)
|
|||||||
fMenuBar->StartMenuBar(-1, false, true, &bounds);
|
fMenuBar->StartMenuBar(-1, false, true, &bounds);
|
||||||
|
|
||||||
fMenuTaskID = spawn_thread((thread_func)_thread_entry,
|
fMenuTaskID = spawn_thread((thread_func)_thread_entry,
|
||||||
"_m_task_", B_NORMAL_PRIORITY, this);
|
"_m_task_", B_NORMAL_PRIORITY, this);
|
||||||
if (fMenuTaskID >= 0)
|
if (fMenuTaskID >= 0)
|
||||||
resume_thread(fMenuTaskID);
|
resume_thread(fMenuTaskID);
|
||||||
}
|
}
|
||||||
@@ -473,9 +473,9 @@ BMenuField::MakeFocus(bool state)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BMenuField::MessageReceived(BMessage* msg)
|
BMenuField::MessageReceived(BMessage* message)
|
||||||
{
|
{
|
||||||
BView::MessageReceived(msg);
|
BView::MessageReceived(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -980,7 +980,7 @@ BMenuField::InitObject2()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BMenuField::DrawLabel(BRect bounds, BRect update)
|
BMenuField::DrawLabel(BRect bounds, BRect updateRect)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
|
|
||||||
@@ -1107,8 +1107,8 @@ BMenuField::_InitMenuBar(BMenu* menu, BRect frame, bool fixedSize)
|
|||||||
fMenu = menu;
|
fMenu = menu;
|
||||||
InitMenu(menu);
|
InitMenu(menu);
|
||||||
|
|
||||||
if ((Flags() & B_SUPPORTS_LAYOUT)) {
|
if ((Flags() & B_SUPPORTS_LAYOUT) != 0) {
|
||||||
fMenuBar = new _BMCMenuBar_(fixedSize, this);
|
fMenuBar = new _BMCMenuBar_(this);
|
||||||
} else {
|
} else {
|
||||||
frame.left = _MenuBarOffset();
|
frame.left = _MenuBarOffset();
|
||||||
frame.top = kVMargin;
|
frame.top = kVMargin;
|
||||||
@@ -1147,7 +1147,7 @@ BMenuField::_InitMenuBar(const BMessage* archive)
|
|||||||
fFixedSizeMB = fixed;
|
fFixedSizeMB = fixed;
|
||||||
|
|
||||||
fMenuBar = (BMenuBar*)FindView("_mc_mb_");
|
fMenuBar = (BMenuBar*)FindView("_mc_mb_");
|
||||||
if (!fMenuBar) {
|
if (fMenuBar == NULL) {
|
||||||
_InitMenuBar(new BMenu(""), BRect(0, 0, 100, 15), fFixedSizeMB);
|
_InitMenuBar(new BMenu(""), BRect(0, 0, 100, 15), fFixedSizeMB);
|
||||||
InitObject2();
|
InitObject2();
|
||||||
} else {
|
} else {
|
||||||
@@ -1194,8 +1194,8 @@ BMenuField::_ValidateLayoutData()
|
|||||||
divider = fLayoutData->label_width + 5;
|
divider = fLayoutData->label_width + 5;
|
||||||
|
|
||||||
// If we shan't do real layout, we let the current divider take influence.
|
// If we shan't do real layout, we let the current divider take influence.
|
||||||
if (!(Flags() & B_SUPPORTS_LAYOUT))
|
if ((Flags() & B_SUPPORTS_LAYOUT) == 0)
|
||||||
divider = max_c(divider, fDivider);
|
divider = std::max(divider, fDivider);
|
||||||
|
|
||||||
// get the minimal (== preferred) menu bar size
|
// get the minimal (== preferred) menu bar size
|
||||||
// TODO: BMenu::MinSize() is using the ResizeMode() to decide the
|
// TODO: BMenu::MinSize() is using the ResizeMode() to decide the
|
||||||
|
|||||||
@@ -55,8 +55,8 @@ const char *kUTF8ControlMap[] = {
|
|||||||
|
|
||||||
using BPrivate::MenuPrivate;
|
using BPrivate::MenuPrivate;
|
||||||
|
|
||||||
BMenuItem::BMenuItem(const char *label, BMessage *message, char shortcut,
|
BMenuItem::BMenuItem(const char* label, BMessage* message, char shortcut,
|
||||||
uint32 modifiers)
|
uint32 modifiers)
|
||||||
{
|
{
|
||||||
_InitData();
|
_InitData();
|
||||||
if (label != NULL)
|
if (label != NULL)
|
||||||
@@ -73,7 +73,7 @@ BMenuItem::BMenuItem(const char *label, BMessage *message, char shortcut,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BMenuItem::BMenuItem(BMenu *menu, BMessage *message)
|
BMenuItem::BMenuItem(BMenu* menu, BMessage* message)
|
||||||
{
|
{
|
||||||
_InitData();
|
_InitData();
|
||||||
SetMessage(message);
|
SetMessage(message);
|
||||||
@@ -81,7 +81,7 @@ BMenuItem::BMenuItem(BMenu *menu, BMessage *message)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BMenuItem::BMenuItem(BMessage *data)
|
BMenuItem::BMenuItem(BMessage* data)
|
||||||
{
|
{
|
||||||
_InitData();
|
_InitData();
|
||||||
|
|
||||||
@@ -121,9 +121,9 @@ BMenuItem::BMenuItem(BMessage *data)
|
|||||||
|
|
||||||
BMessage subMessage;
|
BMessage subMessage;
|
||||||
if (data->FindMessage("_submenu", &subMessage) == B_OK) {
|
if (data->FindMessage("_submenu", &subMessage) == B_OK) {
|
||||||
BArchivable *object = instantiate_object(&subMessage);
|
BArchivable* object = instantiate_object(&subMessage);
|
||||||
if (object != NULL) {
|
if (object != NULL) {
|
||||||
BMenu *menu = dynamic_cast<BMenu *>(object);
|
BMenu* menu = dynamic_cast<BMenu *>(object);
|
||||||
if (menu != NULL)
|
if (menu != NULL)
|
||||||
_InitMenuData(menu);
|
_InitMenuData(menu);
|
||||||
}
|
}
|
||||||
@@ -131,8 +131,8 @@ BMenuItem::BMenuItem(BMessage *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BArchivable *
|
BArchivable*
|
||||||
BMenuItem::Instantiate(BMessage *data)
|
BMenuItem::Instantiate(BMessage* data)
|
||||||
{
|
{
|
||||||
if (validate_instantiation(data, "BMenuItem"))
|
if (validate_instantiation(data, "BMenuItem"))
|
||||||
return new BMenuItem(data);
|
return new BMenuItem(data);
|
||||||
@@ -142,7 +142,7 @@ BMenuItem::Instantiate(BMessage *data)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BMenuItem::Archive(BMessage *data, bool deep) const
|
BMenuItem::Archive(BMessage* data, bool deep) const
|
||||||
{
|
{
|
||||||
status_t ret = BArchivable::Archive(data, deep);
|
status_t ret = BArchivable::Archive(data, deep);
|
||||||
|
|
||||||
@@ -217,7 +217,7 @@ BMenuItem::SetEnabled(bool state)
|
|||||||
if (fSubmenu != NULL)
|
if (fSubmenu != NULL)
|
||||||
fSubmenu->SetEnabled(state);
|
fSubmenu->SetEnabled(state);
|
||||||
|
|
||||||
BMenu *menu = Menu();
|
BMenu* menu = fSuper;
|
||||||
if (menu != NULL && menu->LockLooper()) {
|
if (menu != NULL && menu->LockLooper()) {
|
||||||
menu->Invalidate(fBounds);
|
menu->Invalidate(fBounds);
|
||||||
menu->UnlockLooper();
|
menu->UnlockLooper();
|
||||||
@@ -230,8 +230,8 @@ BMenuItem::SetMarked(bool state)
|
|||||||
{
|
{
|
||||||
fMark = state;
|
fMark = state;
|
||||||
|
|
||||||
if (state && Menu() != NULL) {
|
if (state && fSuper != NULL) {
|
||||||
MenuPrivate priv(Menu());
|
MenuPrivate priv(fSuper);
|
||||||
priv.ItemMarked(this);
|
priv.ItemMarked(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -292,7 +292,7 @@ BMenuItem::SetShortcut(char ch, uint32 modifiers)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char *
|
const char*
|
||||||
BMenuItem::Label() const
|
BMenuItem::Label() const
|
||||||
{
|
{
|
||||||
return fLabel;
|
return fLabel;
|
||||||
@@ -308,7 +308,7 @@ BMenuItem::IsEnabled() const
|
|||||||
if (!fEnabled)
|
if (!fEnabled)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return fSuper ? fSuper->IsEnabled() : true;
|
return fSuper != NULL ? fSuper->IsEnabled() : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -327,7 +327,7 @@ BMenuItem::Trigger() const
|
|||||||
|
|
||||||
|
|
||||||
char
|
char
|
||||||
BMenuItem::Shortcut(uint32 *modifiers) const
|
BMenuItem::Shortcut(uint32* modifiers) const
|
||||||
{
|
{
|
||||||
if (modifiers)
|
if (modifiers)
|
||||||
*modifiers = fModifiers;
|
*modifiers = fModifiers;
|
||||||
@@ -336,14 +336,14 @@ BMenuItem::Shortcut(uint32 *modifiers) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BMenu *
|
BMenu*
|
||||||
BMenuItem::Submenu() const
|
BMenuItem::Submenu() const
|
||||||
{
|
{
|
||||||
return fSubmenu;
|
return fSubmenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BMenu *
|
BMenu*
|
||||||
BMenuItem::Menu() const
|
BMenuItem::Menu() const
|
||||||
{
|
{
|
||||||
return fSuper;
|
return fSuper;
|
||||||
@@ -369,9 +369,8 @@ BMenuItem::GetContentSize(float* width, float* height)
|
|||||||
|
|
||||||
if (width)
|
if (width)
|
||||||
*width = (float)ceil(fCachedWidth);
|
*width = (float)ceil(fCachedWidth);
|
||||||
if (height) {
|
if (height)
|
||||||
*height = MenuPrivate(fSuper).FontHeight();
|
*height = MenuPrivate(fSuper).FontHeight();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -452,8 +451,7 @@ BMenuItem::Draw()
|
|||||||
bool selected = IsSelected();
|
bool selected = IsSelected();
|
||||||
|
|
||||||
// set low color and fill background if selected
|
// set low color and fill background if selected
|
||||||
bool activated = selected && (enabled || Submenu())
|
bool activated = selected && (enabled || Submenu());
|
||||||
/*&& fSuper->fRedrawAfterSticky*/;
|
|
||||||
if (activated) {
|
if (activated) {
|
||||||
if (be_control_look != NULL) {
|
if (be_control_look != NULL) {
|
||||||
BRect rect = Frame();
|
BRect rect = Frame();
|
||||||
@@ -500,7 +498,7 @@ BMenuItem::Draw()
|
|||||||
void
|
void
|
||||||
BMenuItem::Highlight(bool flag)
|
BMenuItem::Highlight(bool flag)
|
||||||
{
|
{
|
||||||
Menu()->Invalidate(Frame());
|
fSuper->Invalidate(Frame());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -514,10 +512,9 @@ BMenuItem::IsSelected() const
|
|||||||
BPoint
|
BPoint
|
||||||
BMenuItem::ContentLocation() const
|
BMenuItem::ContentLocation() const
|
||||||
{
|
{
|
||||||
const BRect &padding = MenuPrivate(fSuper).Padding();
|
const BRect& padding = MenuPrivate(fSuper).Padding();
|
||||||
|
|
||||||
return BPoint(fBounds.left + padding.left,
|
return BPoint(fBounds.left + padding.left, fBounds.top + padding.top);
|
||||||
fBounds.top + padding.top);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -532,7 +529,7 @@ BMenuItem::BMenuItem(const BMenuItem &)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BMenuItem &
|
BMenuItem&
|
||||||
BMenuItem::operator=(const BMenuItem &)
|
BMenuItem::operator=(const BMenuItem &)
|
||||||
{
|
{
|
||||||
return *this;
|
return *this;
|
||||||
@@ -559,13 +556,13 @@ BMenuItem::_InitData()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BMenuItem::_InitMenuData(BMenu *menu)
|
BMenuItem::_InitMenuData(BMenu* menu)
|
||||||
{
|
{
|
||||||
fSubmenu = menu;
|
fSubmenu = menu;
|
||||||
|
|
||||||
MenuPrivate(fSubmenu).SetSuperItem(this);
|
MenuPrivate(fSubmenu).SetSuperItem(this);
|
||||||
|
|
||||||
BMenuItem *item = menu->FindMarked();
|
BMenuItem* item = menu->FindMarked();
|
||||||
|
|
||||||
if (menu->IsRadioMode() && menu->IsLabelFromMarked() && item != NULL)
|
if (menu->IsRadioMode() && menu->IsLabelFromMarked() && item != NULL)
|
||||||
SetLabel(item->Label());
|
SetLabel(item->Label());
|
||||||
@@ -575,11 +572,10 @@ BMenuItem::_InitMenuData(BMenu *menu)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BMenuItem::Install(BWindow *window)
|
BMenuItem::Install(BWindow* window)
|
||||||
{
|
{
|
||||||
if (fSubmenu) {
|
if (fSubmenu != NULL)
|
||||||
MenuPrivate(fSubmenu).Install(window);
|
MenuPrivate(fSubmenu).Install(window);
|
||||||
}
|
|
||||||
|
|
||||||
fWindow = window;
|
fWindow = window;
|
||||||
|
|
||||||
@@ -592,7 +588,7 @@ BMenuItem::Install(BWindow *window)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BMenuItem::Invoke(BMessage *message)
|
BMenuItem::Invoke(BMessage* message)
|
||||||
{
|
{
|
||||||
if (!IsEnabled())
|
if (!IsEnabled())
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
@@ -606,21 +602,21 @@ BMenuItem::Invoke(BMessage *message)
|
|||||||
BMessage clone(kind);
|
BMessage clone(kind);
|
||||||
status_t err = B_BAD_VALUE;
|
status_t err = B_BAD_VALUE;
|
||||||
|
|
||||||
if (!message && !notify)
|
if (message == NULL && !notify)
|
||||||
message = Message();
|
message = Message();
|
||||||
|
|
||||||
if (!message) {
|
if (message == NULL) {
|
||||||
if (!fSuper->IsWatched())
|
if (!fSuper->IsWatched())
|
||||||
return err;
|
return err;
|
||||||
} else
|
} else
|
||||||
clone = *message;
|
clone = *message;
|
||||||
|
|
||||||
clone.AddInt32("index", Menu()->IndexOf(this));
|
clone.AddInt32("index", fSuper->IndexOf(this));
|
||||||
clone.AddInt64("when", (int64)system_time());
|
clone.AddInt64("when", (int64)system_time());
|
||||||
clone.AddPointer("source", this);
|
clone.AddPointer("source", this);
|
||||||
clone.AddMessenger("be:sender", BMessenger(fSuper));
|
clone.AddMessenger("be:sender", BMessenger(fSuper));
|
||||||
|
|
||||||
if (message)
|
if (message != NULL)
|
||||||
err = BInvoker::Invoke(&clone);
|
err = BInvoker::Invoke(&clone);
|
||||||
|
|
||||||
// TODO: assynchronous messaging
|
// TODO: assynchronous messaging
|
||||||
@@ -633,31 +629,32 @@ BMenuItem::Invoke(BMessage *message)
|
|||||||
void
|
void
|
||||||
BMenuItem::Uninstall()
|
BMenuItem::Uninstall()
|
||||||
{
|
{
|
||||||
if (fSubmenu != NULL) {
|
if (fSubmenu != NULL)
|
||||||
MenuPrivate(fSubmenu).Uninstall();
|
MenuPrivate(fSubmenu).Uninstall();
|
||||||
}
|
|
||||||
|
|
||||||
if (Target() == fWindow)
|
if (Target() == fWindow)
|
||||||
SetTarget(BMessenger());
|
SetTarget(BMessenger());
|
||||||
|
|
||||||
if (fShortcutChar != 0 && (fModifiers & B_COMMAND_KEY) != 0
|
if (fShortcutChar != 0 && (fModifiers & B_COMMAND_KEY) != 0
|
||||||
&& fWindow != NULL)
|
&& fWindow != NULL) {
|
||||||
fWindow->RemoveShortcut(fShortcutChar, fModifiers);
|
fWindow->RemoveShortcut(fShortcutChar, fModifiers);
|
||||||
|
}
|
||||||
|
|
||||||
fWindow = NULL;
|
fWindow = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BMenuItem::SetSuper(BMenu *super)
|
BMenuItem::SetSuper(BMenu* super)
|
||||||
{
|
{
|
||||||
if (fSuper != NULL && super != NULL)
|
if (fSuper != NULL && super != NULL) {
|
||||||
debugger("Error - can't add menu or menu item to more than 1 container (either menu or menubar).");
|
debugger("Error - can't add menu or menu item to more than 1 container"
|
||||||
|
" (either menu or menubar).");
|
||||||
if (fSubmenu != NULL) {
|
|
||||||
MenuPrivate(fSubmenu).SetSuper(super);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fSubmenu != NULL)
|
||||||
|
MenuPrivate(fSubmenu).SetSuper(super);
|
||||||
|
|
||||||
fSuper = super;
|
fSuper = super;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -668,7 +665,7 @@ BMenuItem::Select(bool selected)
|
|||||||
if (fSelected == selected)
|
if (fSelected == selected)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (Submenu() || IsEnabled()) {
|
if (Submenu() != NULL || IsEnabled()) {
|
||||||
fSelected = selected;
|
fSelected = selected;
|
||||||
Highlight(selected);
|
Highlight(selected);
|
||||||
}
|
}
|
||||||
@@ -717,7 +714,7 @@ BMenuItem::_DrawMarkSymbol()
|
|||||||
void
|
void
|
||||||
BMenuItem::_DrawShortcutSymbol()
|
BMenuItem::_DrawShortcutSymbol()
|
||||||
{
|
{
|
||||||
BMenu *menu = Menu();
|
BMenu* menu = fSuper;
|
||||||
BFont font;
|
BFont font;
|
||||||
menu->GetFont(&font);
|
menu->GetFont(&font);
|
||||||
BPoint where = ContentLocation();
|
BPoint where = ContentLocation();
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ BBitmap* MenuPrivate::sMenuItemAlt;
|
|||||||
BBitmap* MenuPrivate::sMenuItemMenu;
|
BBitmap* MenuPrivate::sMenuItemMenu;
|
||||||
|
|
||||||
|
|
||||||
MenuPrivate::MenuPrivate(BMenu *menu)
|
MenuPrivate::MenuPrivate(BMenu* menu)
|
||||||
:
|
:
|
||||||
fMenu(menu)
|
fMenu(menu)
|
||||||
{
|
{
|
||||||
@@ -147,22 +147,22 @@ MenuPrivate::Padding() const
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MenuPrivate::GetItemMargins(float *left, float *top,
|
MenuPrivate::GetItemMargins(float* left, float* top, float* right,
|
||||||
float *right, float *bottom) const
|
float* bottom) const
|
||||||
{
|
{
|
||||||
fMenu->GetItemMargins(left, top, right, bottom);
|
fMenu->GetItemMargins(left, top, right, bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
MenuPrivate::State(BMenuItem **item) const
|
MenuPrivate::State(BMenuItem** item) const
|
||||||
{
|
{
|
||||||
return fMenu->_State(item);
|
return fMenu->_State(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MenuPrivate::Install(BWindow *window)
|
MenuPrivate::Install(BWindow* window)
|
||||||
{
|
{
|
||||||
fMenu->_Install(window);
|
fMenu->_Install(window);
|
||||||
}
|
}
|
||||||
@@ -176,21 +176,21 @@ MenuPrivate::Uninstall()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MenuPrivate::SetSuper(BMenu *menu)
|
MenuPrivate::SetSuper(BMenu* menu)
|
||||||
{
|
{
|
||||||
fMenu->fSuper = menu;
|
fMenu->fSuper = menu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MenuPrivate::SetSuperItem(BMenuItem *item)
|
MenuPrivate::SetSuperItem(BMenuItem* item)
|
||||||
{
|
{
|
||||||
fMenu->fSuperitem = item;
|
fMenu->fSuperitem = item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MenuPrivate::InvokeItem(BMenuItem *item, bool now)
|
MenuPrivate::InvokeItem(BMenuItem* item, bool now)
|
||||||
{
|
{
|
||||||
fMenu->_InvokeItem(item, now);
|
fMenu->_InvokeItem(item, now);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user