Initial Checkin
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1933 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -0,0 +1,290 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Copyright (c) 2001-2002, OpenBeOS
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// File Name: Menubar.cpp
|
||||
// Author: Marc Flerackers ([email protected])
|
||||
// Description: BMenuBar is a menu that's at the root of a menu hierarchy.
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// Standard Includes -----------------------------------------------------------
|
||||
|
||||
// System Includes -------------------------------------------------------------
|
||||
#include <MenuBar.h>
|
||||
#include <MenuItem.h>
|
||||
#include <Window.h>
|
||||
|
||||
// Project Includes ------------------------------------------------------------
|
||||
|
||||
// Local Includes --------------------------------------------------------------
|
||||
|
||||
// Local Defines ---------------------------------------------------------------
|
||||
|
||||
// Globals ---------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
BMenuBar::BMenuBar(BRect frame, const char *title, uint32 resizeMask,
|
||||
menu_layout layout, bool resizeToFit)
|
||||
: BMenu(frame, title, resizeMask,
|
||||
B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE, layout, resizeToFit),
|
||||
fBorder(B_BORDER_FRAME),
|
||||
fTrackingPID(-1),
|
||||
fPrevFocusToken(-1),
|
||||
fMenuSem(-1),
|
||||
fLastBounds(NULL),
|
||||
fTracking(false)
|
||||
{
|
||||
// TODO: which flags to pass to BMenu?
|
||||
InitData(layout);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
BMenuBar::BMenuBar(BMessage *data)
|
||||
: BMenu(data),
|
||||
fBorder(B_BORDER_FRAME),
|
||||
fTrackingPID(-1),
|
||||
fPrevFocusToken(-1),
|
||||
fMenuSem(-1),
|
||||
fLastBounds(NULL),
|
||||
fTracking(false)
|
||||
{
|
||||
int32 border;
|
||||
|
||||
if (data->FindInt32("_border", &border) == B_OK)
|
||||
SetBorder((menu_bar_border)border);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
BMenuBar::~BMenuBar()
|
||||
{
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
BArchivable *BMenuBar::Instantiate(BMessage *data)
|
||||
{
|
||||
if ( validate_instantiation(data, "BMenuBar"))
|
||||
return new BMenuBar(data);
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
status_t BMenuBar::Archive(BMessage *data, bool deep) const
|
||||
{
|
||||
status_t err = BMenu::Archive(data, deep);
|
||||
|
||||
if (err != B_OK)
|
||||
return err;
|
||||
|
||||
if (Border() != B_BORDER_FRAME)
|
||||
err = data->AddInt32("_border", Border());
|
||||
|
||||
return err;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BMenuBar::SetBorder(menu_bar_border border)
|
||||
{
|
||||
fBorder = border;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
menu_bar_border BMenuBar::Border() const
|
||||
{
|
||||
return fBorder;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BMenuBar::Draw(BRect updateRect)
|
||||
{
|
||||
// TODO: implement additional border styles
|
||||
BRect bounds(Bounds());
|
||||
|
||||
SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), B_LIGHTEN_2_TINT));
|
||||
StrokeLine(BPoint(0.0f, bounds.bottom - 2.0f ), BPoint(0.0f, 0.0f));
|
||||
StrokeLine(BPoint(bounds.right, 0.0f ) );
|
||||
|
||||
SetHighColor(tint_color ( ui_color ( B_MENU_BACKGROUND_COLOR ), B_DARKEN_1_TINT));
|
||||
StrokeLine(BPoint ( 1.0f, bounds.bottom - 1.0f ),
|
||||
BPoint(bounds.right, bounds.bottom - 1.0f ) );
|
||||
|
||||
SetHighColor(tint_color(ui_color (B_MENU_BACKGROUND_COLOR), B_DARKEN_2_TINT));
|
||||
StrokeLine(BPoint(0.0f, bounds.bottom), BPoint(bounds.right, bounds.bottom));
|
||||
StrokeLine(BPoint(bounds.right, 0.0f), BPoint(bounds.right, bounds.bottom));
|
||||
|
||||
DrawItems(updateRect);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BMenuBar::AttachedToWindow()
|
||||
{
|
||||
Install(Window());
|
||||
Window()->SetKeyMenuBar(this);
|
||||
|
||||
BMenu::AttachedToWindow();
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BMenuBar::DetachedFromWindow()
|
||||
{
|
||||
BMenu::DetachedFromWindow();
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BMenuBar::MessageReceived(BMessage *msg)
|
||||
{
|
||||
BMenu::MessageReceived(msg);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BMenuBar::MouseDown(BPoint where)
|
||||
{
|
||||
StealFocus();
|
||||
BMenu::MouseDown(where);
|
||||
|
||||
// TODO: the real code should look like this:
|
||||
/*
|
||||
if (!Window()->IsActive())
|
||||
{
|
||||
Window()->Activate();
|
||||
Window()->UpdateIfNeeded();
|
||||
}
|
||||
|
||||
StartMenuBar();
|
||||
*/
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BMenuBar::WindowActivated(bool state)
|
||||
{
|
||||
BView::WindowActivated(state);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BMenuBar::MouseUp(BPoint where)
|
||||
{
|
||||
BMenu::MouseUp(where);
|
||||
RestoreFocus();
|
||||
|
||||
// BView::MouseUp(where);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BMenuBar::FrameMoved(BPoint new_position)
|
||||
{
|
||||
BMenu::FrameMoved(new_position);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BMenuBar::FrameResized(float new_width, float new_height)
|
||||
{
|
||||
BMenu::FrameResized(new_width, new_height);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BMenuBar::Show()
|
||||
{
|
||||
BView::Show();
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BMenuBar::Hide()
|
||||
{
|
||||
BView::Hide();
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
BHandler *BMenuBar::ResolveSpecifier(BMessage *msg, int32 index,
|
||||
BMessage *specifier, int32 form,
|
||||
const char *property)
|
||||
{
|
||||
return BMenu::ResolveSpecifier(msg, index, specifier, form, property);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
status_t BMenuBar::GetSupportedSuites(BMessage *data)
|
||||
{
|
||||
return BMenu::GetSupportedSuites(data);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BMenuBar::ResizeToPreferred()
|
||||
{
|
||||
BMenu::ResizeToPreferred();
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BMenuBar::GetPreferredSize(float *width, float *height)
|
||||
{
|
||||
BMenu::GetPreferredSize(width, height);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BMenuBar::MakeFocus(bool state)
|
||||
{
|
||||
BMenu::MakeFocus(state);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BMenuBar::AllAttached()
|
||||
{
|
||||
BMenu::AllAttached();
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BMenuBar::AllDetached()
|
||||
{
|
||||
BMenu::AllDetached();
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
status_t BMenuBar::Perform(perform_code d, void *arg)
|
||||
{
|
||||
return BMenu::Perform(d, arg);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BMenuBar::_ReservedMenuBar1() {}
|
||||
void BMenuBar::_ReservedMenuBar2() {}
|
||||
void BMenuBar::_ReservedMenuBar3() {}
|
||||
void BMenuBar::_ReservedMenuBar4() {}
|
||||
//------------------------------------------------------------------------------
|
||||
BMenuBar &BMenuBar::operator=(const BMenuBar &)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BMenuBar::StartMenuBar(int32 menuIndex, bool sticky, bool show_menu,
|
||||
BRect *special_rect)
|
||||
{
|
||||
/*
|
||||
if (!Window())
|
||||
return;
|
||||
|
||||
Window()->Lock();
|
||||
Window()->MenusBeginning();
|
||||
sem_id = create_sem(??, ??);
|
||||
set_menu_sem(BWindow, sem);
|
||||
fTrackingPID = spawn_thread(TrackTask, "menu_tracking?", B_NORMAL_PRIORITY, ??);
|
||||
Window()->Unlock();
|
||||
*/
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
long BMenuBar::TrackTask(void *arg)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
BMenuItem *BMenuBar::Track(int32 *action, int32 startIndex, bool showMenu)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BMenuBar::StealFocus()
|
||||
{
|
||||
//fPrevFocusToken = _get_object_token_(Window()->CurrentFocus());
|
||||
MakeFocus();
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BMenuBar::RestoreFocus()
|
||||
{
|
||||
//fPrevFocusToken
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BMenuBar::InitData(menu_layout layout)
|
||||
{
|
||||
SetItemMargins(8, 2, 8, 2);
|
||||
SetIgnoreHidden(true);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -0,0 +1,481 @@
|
||||
// Standard Includes -----------------------------------------------------------
|
||||
#include <string.h>
|
||||
#include <malloc.h>
|
||||
|
||||
// System Includes -------------------------------------------------------------
|
||||
#include <MenuItem.h>
|
||||
#include <String.h>
|
||||
#include <Message.h>
|
||||
#include <Window.h>
|
||||
|
||||
// Project Includes ------------------------------------------------------------
|
||||
|
||||
// Local Includes --------------------------------------------------------------
|
||||
|
||||
// Local Defines ---------------------------------------------------------------
|
||||
|
||||
// Globals ---------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
BMenuItem::BMenuItem(const char *label, BMessage *message, char shortcut,
|
||||
uint32 modifiers)
|
||||
: BInvoker(message, NULL),
|
||||
fSubmenu(NULL),
|
||||
fWindow(NULL),
|
||||
fSuper(NULL),
|
||||
fModifiers(modifiers),
|
||||
fCachedWidth(0.0f),
|
||||
fTriggerIndex(0),
|
||||
fUserTrigger(0),
|
||||
fSysTrigger(0),
|
||||
fShortcutChar(shortcut),
|
||||
fMark(false),
|
||||
fEnabled(true),
|
||||
fSelected(false)
|
||||
{
|
||||
fLabel = strdup(label);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
BMenuItem::BMenuItem(BMenu *menu, BMessage *message)
|
||||
: BInvoker(message, NULL),
|
||||
fSubmenu(menu),
|
||||
fWindow(NULL),
|
||||
fSuper(NULL),
|
||||
fModifiers(0),
|
||||
fCachedWidth(0.0f),
|
||||
fTriggerIndex(0),
|
||||
fUserTrigger(0),
|
||||
fSysTrigger(0),
|
||||
fShortcutChar(0),
|
||||
fMark(false),
|
||||
fEnabled(true),
|
||||
fSelected(false)
|
||||
{
|
||||
fLabel = strdup(menu->Name());
|
||||
|
||||
fSubmenu->fSuperitem = this;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
BMenuItem::BMenuItem(BMessage *data)
|
||||
{
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
BArchivable *BMenuItem::Instantiate(BMessage *data)
|
||||
{
|
||||
if (validate_instantiation(data, "BMenuItem"))
|
||||
return new BMenuItem(data);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
status_t BMenuItem::Archive(BMessage *data, bool deep) const
|
||||
{
|
||||
if (Label())
|
||||
data->AddString("_label", Label());
|
||||
|
||||
if (!IsEnabled())
|
||||
data->AddBool("_disable", true);
|
||||
|
||||
if (IsMarked())
|
||||
data->AddBool("_marked", true);
|
||||
|
||||
if (fUserTrigger)
|
||||
data->AddInt32("_user_trig", fUserTrigger);
|
||||
|
||||
if (fShortcutChar && fModifiers)
|
||||
{
|
||||
data->AddInt32("_shortcut", fShortcutChar);
|
||||
data->AddInt32("_mods", fModifiers);
|
||||
}
|
||||
|
||||
if (Message())
|
||||
data->AddMessage("_msg", Message());
|
||||
|
||||
if (deep && Submenu())
|
||||
{
|
||||
BMessage submenu;
|
||||
Submenu()->Archive(&submenu);
|
||||
data->AddMessage("_submenu", &submenu);
|
||||
}
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
BMenuItem::~BMenuItem()
|
||||
{
|
||||
if (fLabel)
|
||||
free(fLabel);
|
||||
|
||||
if (fSubmenu)
|
||||
delete fSubmenu;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BMenuItem::SetLabel(const char *string)
|
||||
{
|
||||
if (fLabel)
|
||||
free(fLabel);
|
||||
|
||||
fLabel = strdup(string);
|
||||
|
||||
Menu()->InvalidateLayout();
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BMenuItem::SetEnabled(bool state)
|
||||
{
|
||||
if (Menu()->IsEnabled() == false)
|
||||
return;
|
||||
|
||||
fEnabled = state;
|
||||
|
||||
if (Submenu())
|
||||
Submenu()->SetEnabled(state);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BMenuItem::SetMarked(bool state)
|
||||
{
|
||||
fMark = state;
|
||||
|
||||
if (state && Menu())
|
||||
Menu()->ItemMarked(this);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BMenuItem::SetTrigger(char ch)
|
||||
{
|
||||
fUserTrigger = ch;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BMenuItem::SetShortcut(char ch, uint32 modifiers)
|
||||
{
|
||||
fShortcutChar = ch;
|
||||
fModifiers = modifiers;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
const char *BMenuItem::Label() const
|
||||
{
|
||||
return fLabel;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
bool BMenuItem::IsEnabled() const
|
||||
{
|
||||
return fEnabled;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
bool BMenuItem::IsMarked() const
|
||||
{
|
||||
return fMark;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
char BMenuItem::Trigger() const
|
||||
{
|
||||
if (fUserTrigger)
|
||||
return fUserTrigger;
|
||||
else
|
||||
return fSysTrigger;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
char BMenuItem::Shortcut(uint32 *modifiers) const
|
||||
{
|
||||
if (modifiers)
|
||||
*modifiers = fModifiers;
|
||||
|
||||
return fShortcutChar;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
BMenu *BMenuItem::Submenu() const
|
||||
{
|
||||
return fSubmenu;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
BMenu *BMenuItem::Menu() const
|
||||
{
|
||||
return fSuper;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
BRect BMenuItem::Frame() const
|
||||
{
|
||||
return fBounds;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BMenuItem::GetContentSize(float *width, float *height)
|
||||
{
|
||||
BMenu *menu = Menu();
|
||||
|
||||
if (menu->fFontHeight == -1)
|
||||
menu->CacheFontInfo();
|
||||
|
||||
*width = (float)ceil(menu->StringWidth(fLabel));
|
||||
*height = menu->fFontHeight;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BMenuItem::TruncateLabel(float maxWidth, char *newLabel)
|
||||
{
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BMenuItem::DrawContent()
|
||||
{
|
||||
fSuper->DrawString(fLabel);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BMenuItem::Draw()
|
||||
{
|
||||
if (IsEnabled() && fSelected)
|
||||
{
|
||||
fSuper->SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR),
|
||||
B_DARKEN_2_TINT));
|
||||
fSuper->SetLowColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR),
|
||||
B_DARKEN_2_TINT));
|
||||
fSuper->FillRect(Frame());
|
||||
}
|
||||
|
||||
BPoint pt = ContentLocation();
|
||||
|
||||
fSuper->MovePenTo(pt.x, pt.y + Menu()->fAscent);
|
||||
if (IsEnabled())
|
||||
fSuper->SetHighColor(ui_color(B_MENU_ITEM_TEXT_COLOR));
|
||||
else
|
||||
fSuper->SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR),
|
||||
B_DISABLED_LABEL_TINT));
|
||||
DrawContent();
|
||||
|
||||
if (Menu()->Layout() == B_ITEMS_IN_COLUMN)
|
||||
{
|
||||
if (IsMarked())
|
||||
DrawMarkSymbol();
|
||||
|
||||
if (Submenu())
|
||||
DrawSubmenuSymbol();
|
||||
else if (fShortcutChar)
|
||||
DrawShortcutSymbol();
|
||||
}
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BMenuItem::Highlight(bool flag)
|
||||
{
|
||||
//Menu()->InvertRect(Frame());
|
||||
Menu()->Invalidate(Frame());
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
bool BMenuItem::IsSelected() const
|
||||
{
|
||||
return fSelected;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
BPoint BMenuItem::ContentLocation () const
|
||||
{
|
||||
if (!Menu())
|
||||
return BPoint();
|
||||
|
||||
return BPoint(fBounds.left + Menu()->fPad.left,
|
||||
fBounds.top + Menu()->fPad.top);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BMenuItem::_ReservedMenuItem1() {}
|
||||
void BMenuItem::_ReservedMenuItem2() {}
|
||||
void BMenuItem::_ReservedMenuItem3() {}
|
||||
void BMenuItem::_ReservedMenuItem4() {}
|
||||
//------------------------------------------------------------------------------
|
||||
BMenuItem::BMenuItem(const BMenuItem &)
|
||||
{
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
BMenuItem &BMenuItem::operator=(const BMenuItem &)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BMenuItem::InitData()
|
||||
{
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BMenuItem::InitMenuData(BMenu *menu)
|
||||
{
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BMenuItem::Install(BWindow *window)
|
||||
{
|
||||
if (Submenu())
|
||||
Submenu()->Install(window);
|
||||
|
||||
char shortcut;
|
||||
uint32 modifiers;
|
||||
if (shortcut = Shortcut(&modifiers))
|
||||
window->AddShortcut(shortcut, modifiers, this);
|
||||
|
||||
if (Target() == NULL)
|
||||
SetTarget(window);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
status_t BMenuItem::Invoke(BMessage *message)
|
||||
{
|
||||
if (IsEnabled())
|
||||
{
|
||||
BMessage msg;
|
||||
|
||||
if (message)
|
||||
msg = *message;
|
||||
else if (Message())
|
||||
msg = *Message();
|
||||
else
|
||||
return B_OK;
|
||||
|
||||
msg.AddInt64("when", system_time()); // TODO
|
||||
msg.AddPointer("source", this);
|
||||
msg.AddInt32("index", Menu()->IndexOf(this));
|
||||
|
||||
return BInvoker::Invoke(&msg);
|
||||
}
|
||||
else
|
||||
return B_OK;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BMenuItem::Uninstall()
|
||||
{
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BMenuItem::SetSuper(BMenu *super)
|
||||
{
|
||||
fSuper = super;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BMenuItem::Select(bool on)
|
||||
{
|
||||
fSelected = on;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BMenuItem::DrawMarkSymbol()
|
||||
{
|
||||
fSuper->SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR),
|
||||
B_DARKEN_1_TINT));
|
||||
fSuper->StrokeLine(BPoint(fBounds.left + 6.0f, fBounds.bottom - 3.0f),
|
||||
BPoint(fBounds.left + 10.0f, fBounds.bottom - 12.0f));
|
||||
fSuper->StrokeLine(BPoint(fBounds.left + 7.0f, fBounds.bottom - 3.0f),
|
||||
BPoint(fBounds.left + 11.0f, fBounds.bottom - 12.0f));
|
||||
|
||||
fSuper->SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR),
|
||||
B_DARKEN_4_TINT));
|
||||
|
||||
fSuper->StrokeLine(BPoint(fBounds.left + 6.0f, fBounds.bottom - 4.0f),
|
||||
BPoint(fBounds.left + 10.0f, fBounds.bottom - 13.0f));
|
||||
fSuper->StrokeLine(BPoint(fBounds.left + 5.0f, fBounds.bottom - 4.0f),
|
||||
BPoint(fBounds.left + 9.0f, fBounds.bottom - 13.0f));
|
||||
fSuper->StrokeLine(BPoint(fBounds.left + 5.0f, fBounds.bottom - 3.0f),
|
||||
BPoint(fBounds.left + 3.0f, fBounds.bottom - 9.0f));
|
||||
fSuper->StrokeLine(BPoint(fBounds.left + 4.0f, fBounds.bottom - 4.0f),
|
||||
BPoint(fBounds.left + 2.0f, fBounds.bottom - 9.0f));
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BMenuItem::DrawShortcutSymbol()
|
||||
{
|
||||
BString shortcut("");
|
||||
|
||||
if (fModifiers & B_CONTROL_KEY)
|
||||
shortcut += "ctl+";
|
||||
|
||||
shortcut += fShortcutChar;
|
||||
|
||||
fSuper->DrawString(shortcut.String(), ContentLocation() +
|
||||
BPoint(fBounds.Width() - 14.0f - 22.0f, fBounds.Height() - 4.0f));
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BMenuItem::DrawSubmenuSymbol()
|
||||
{
|
||||
fSuper->SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR),
|
||||
B_LIGHTEN_MAX_TINT));
|
||||
fSuper->FillTriangle(BPoint(fBounds.right - 14.0f, fBounds.bottom - 4.0f),
|
||||
BPoint(fBounds.right - 14.0f, fBounds.bottom - 12.0f),
|
||||
BPoint(fBounds.right - 5.0f, fBounds.bottom - 8.0f));
|
||||
|
||||
fSuper->SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR),
|
||||
B_DARKEN_2_TINT));
|
||||
fSuper->StrokeLine(BPoint(fBounds.right - 14.0f, fBounds.bottom - 5),
|
||||
BPoint(fBounds.right - 9.0f, fBounds.bottom - 7));
|
||||
fSuper->StrokeLine(BPoint(fBounds.right - 7.0f, fBounds.bottom - 8),
|
||||
BPoint(fBounds.right - 7.0f, fBounds.bottom - 8));
|
||||
|
||||
fSuper->SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR),
|
||||
B_DARKEN_3_TINT));
|
||||
fSuper->StrokeTriangle(BPoint(fBounds.right - 14.0f, fBounds.bottom - 4.0f),
|
||||
BPoint(fBounds.right - 14.0f, fBounds.bottom - 12.0f),
|
||||
BPoint(fBounds.right - 5.0f, fBounds.bottom - 8.0f));
|
||||
|
||||
fSuper->SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR),
|
||||
B_LIGHTEN_1_TINT));
|
||||
fSuper->StrokeTriangle(BPoint(fBounds.right - 12.0f, fBounds.bottom - 7.0f),
|
||||
BPoint(fBounds.right - 12.0f, fBounds.bottom - 9.0f),
|
||||
BPoint(fBounds.right - 9.0f, fBounds.bottom - 8.0f));
|
||||
fSuper->FillTriangle(BPoint(fBounds.right - 12.0f, fBounds.bottom - 7.0f),
|
||||
BPoint(fBounds.right - 12.0f, fBounds.bottom - 9.0f),
|
||||
BPoint(fBounds.right - 9.0f, fBounds.bottom - 8.0f));
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BMenuItem::DrawControlChar(const char *control)
|
||||
{
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BMenuItem::SetSysTrigger(char ch)
|
||||
{
|
||||
fSysTrigger = ch;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
BSeparatorItem::BSeparatorItem()
|
||||
: BMenuItem(NULL, NULL, 0, 0)
|
||||
{
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
BSeparatorItem::BSeparatorItem(BMessage *data)
|
||||
: BMenuItem(data)
|
||||
{
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
BSeparatorItem::~BSeparatorItem()
|
||||
{
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
status_t BSeparatorItem::Archive(BMessage *data, bool deep) const
|
||||
{
|
||||
return BMenuItem::Archive(data, deep);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
BArchivable *BSeparatorItem::Instantiate(BMessage *data)
|
||||
{
|
||||
if (validate_instantiation(data, "BSeparatorItem"))
|
||||
return new BSeparatorItem(data);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BSeparatorItem::SetEnabled(bool state)
|
||||
{
|
||||
BSeparatorItem::SetEnabled(state);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BSeparatorItem::GetContentSize(float *width, float *height)
|
||||
{
|
||||
*width = 2.0f;
|
||||
*height = 8.0f;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BSeparatorItem::Draw()
|
||||
{
|
||||
BRect bounds = Frame();
|
||||
|
||||
Menu()->SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR),
|
||||
B_DARKEN_2_TINT));
|
||||
Menu()->StrokeLine(BPoint(bounds.left + 1.0f, bounds.top + 4.0f),
|
||||
BPoint(bounds.right - 1.0f, bounds.top + 4.0f));
|
||||
Menu()->SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR),
|
||||
B_LIGHTEN_2_TINT));
|
||||
Menu()->StrokeLine(BPoint(bounds.left + 1.0f, bounds.top + 5.0f),
|
||||
BPoint(bounds.right - 1.0f, bounds.top + 5.0f));
|
||||
|
||||
Menu()->SetHighColor(0, 0, 0);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BSeparatorItem::_ReservedSeparatorItem1() {}
|
||||
void BSeparatorItem::_ReservedSeparatorItem2() {}
|
||||
//------------------------------------------------------------------------------
|
||||
BSeparatorItem &BSeparatorItem::operator=(const BSeparatorItem &)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
Reference in New Issue
Block a user