本文整理汇总了C++中BPopUpMenu::SetFont方法的典型用法代码示例。如果您正苦于以下问题:C++ BPopUpMenu::SetFont方法的具体用法?C++ BPopUpMenu::SetFont怎么用?C++ BPopUpMenu::SetFont使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BPopUpMenu
的用法示例。
在下文中一共展示了BPopUpMenu::SetFont方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BMessage
SpaceBarSettingsView::SpaceBarSettingsView(BRect rect)
: SettingsView(rect, "SpaceBarSettingsView")
{
rect.OffsetTo(B_ORIGIN);
fSpaceBarShowCheckBox = new BCheckBox(rect, "", "Show space bars on volumes",
new BMessage(kUpdateVolumeSpaceBar));
fSpaceBarShowCheckBox->ResizeToPreferred();
AddChild(fSpaceBarShowCheckBox);
rect = fSpaceBarShowCheckBox->Frame();
rect.OffsetBy(0, fSpaceBarShowCheckBox->Bounds().Height() + kItemExtraSpacing);
BPopUpMenu *menu = new BPopUpMenu(B_EMPTY_STRING);
menu->SetFont(be_plain_font);
BMenuItem *item;
menu->AddItem(item = new BMenuItem("Used space color", new BMessage(kSpaceBarSwitchColor)));
item->SetMarked(true);
fCurrentColor = 0;
menu->AddItem(new BMenuItem("Free space color", new BMessage(kSpaceBarSwitchColor)));
menu->AddItem(new BMenuItem("Warning space color", new BMessage(kSpaceBarSwitchColor)));
BBox *box = new BBox(rect);
box->SetLabel(fColorPicker = new BMenuField(rect, NULL, NULL, menu));
AddChild(box);
fColorControl = new BColorControl(BPoint(8, fColorPicker->Bounds().Height()
+ 8 + kItemExtraSpacing),
B_CELLS_16x16, 1, "SpaceColorControl", new BMessage(kSpaceBarColorChanged));
fColorControl->SetValue(TrackerSettings().UsedSpaceColor());
fColorControl->ResizeToPreferred();
box->AddChild(fColorControl);
box->ResizeTo(fColorControl->Bounds().Width() + 16,
fColorControl->Frame().bottom + 8);
}
示例2: BMessage
BPopUpMenu*
DeskbarView::_BuildMenu()
{
BPopUpMenu* menu = new BPopUpMenu(B_EMPTY_STRING, false, false);
menu->SetFont(be_plain_font);
menu->AddItem(new BMenuItem(MDR_DIALECT_CHOICE (
"Create new message", "N) 新規メッセージ作成")B_UTF8_ELLIPSIS,
new BMessage(MD_OPEN_NEW)));
menu->AddSeparatorItem();
BMessenger tracker(kTrackerSignature);
BNavMenu* navMenu;
BMenuItem* item;
BMessage* msg;
entry_ref ref;
BPath path;
find_directory(B_USER_SETTINGS_DIRECTORY, &path);
path.Append("Mail/Menu Links");
BDirectory directory;
if (_CreateMenuLinks(directory, path)) {
int32 count = 0;
while (directory.GetNextRef(&ref) == B_OK) {
count++;
path.SetTo(&ref);
// the true here dereferences the symlinks all the way :)
BEntry entry(&ref, true);
// do we want to use the NavMenu, or just an ordinary BMenuItem?
// we are using the NavMenu only for directories and queries
bool useNavMenu = false;
if (entry.InitCheck() == B_OK) {
if (entry.IsDirectory())
useNavMenu = true;
else if (entry.IsFile()) {
// Files should use the BMenuItem unless they are queries
char mimeString[B_MIME_TYPE_LENGTH];
BNode node(&entry);
BNodeInfo info(&node);
if (info.GetType(mimeString) == B_OK
&& strcmp(mimeString, "application/x-vnd.Be-query")
== 0)
useNavMenu = true;
}
// clobber the existing ref only if the symlink derefernces
// completely, otherwise we'll stick with what we have
entry.GetRef(&ref);
}
msg = new BMessage(B_REFS_RECEIVED);
msg->AddRef("refs", &ref);
if (useNavMenu) {
item = new BMenuItem(navMenu = new BNavMenu(path.Leaf(),
B_REFS_RECEIVED, tracker), msg);
navMenu->SetNavDir(&ref);
} else
item = new BMenuItem(path.Leaf(), msg);
menu->AddItem(item);
if(entry.InitCheck() != B_OK)
item->SetEnabled(false);
}
if (count > 0)
menu->AddSeparatorItem();
}
// Hack for R5's buggy Query Notification
#ifdef HAIKU_TARGET_PLATFORM_BEOS
menu->AddItem(new BMenuItem(
MDR_DIALECT_CHOICE("Refresh New Mail Count",
"未読メールカウントを更新"),
new BMessage(MD_REFRESH_QUERY)));
#endif
// The New E-mail query
if (fNewMessages > 0) {
BString string;
MDR_DIALECT_CHOICE(
string << fNewMessages << " new message"
<< (fNewMessages != 1 ? "s" : B_EMPTY_STRING),
string << fNewMessages << " 通の未読メッセージ");
_GetNewQueryRef(ref);
item = new BMenuItem(navMenu = new BNavMenu(string.String(),
B_REFS_RECEIVED, BMessenger(kTrackerSignature)),
msg = new BMessage(B_REFS_RECEIVED));
msg->AddRef("refs", &ref);
navMenu->SetNavDir(&ref);
menu->AddItem(item);
} else {
menu->AddItem(item = new BMenuItem(
//.........这里部分代码省略.........
示例3: BMessage
void
WorkspacesView::MouseDown(BPoint where)
{
// With enabled auto-raise feature, we'll get mouse messages we don't
// want to handle here.
if (!Bounds().Contains(where))
return;
int32 buttons = 0;
if (Window() != NULL && Window()->CurrentMessage() != NULL)
Window()->CurrentMessage()->FindInt32("buttons", &buttons);
if ((buttons & B_SECONDARY_MOUSE_BUTTON) == 0)
return;
// open context menu
BPopUpMenu *menu = new BPopUpMenu(B_EMPTY_STRING, false, false);
menu->SetFont(be_plain_font);
// TODO: alternatively change the count here directly?
BMenuItem* changeItem = new BMenuItem("Change workspace count"
B_UTF8_ELLIPSIS, new BMessage(kMsgChangeCount));
menu->AddItem(changeItem);
WorkspacesWindow* window = dynamic_cast<WorkspacesWindow*>(Window());
if (window != NULL) {
BMenuItem* item;
menu->AddSeparatorItem();
menu->AddItem(item = new BMenuItem("Show window title",
new BMessage(kMsgToggleTitle)));
if (window->Look() == B_TITLED_WINDOW_LOOK)
item->SetMarked(true);
menu->AddItem(item = new BMenuItem("Show window border",
new BMessage(kMsgToggleBorder)));
if (window->Look() == B_TITLED_WINDOW_LOOK
|| window->Look() == B_MODAL_WINDOW_LOOK)
item->SetMarked(true);
menu->AddSeparatorItem();
menu->AddItem(item = new BMenuItem("Always on top",
new BMessage(kMsgToggleAlwaysOnTop)));
if (window->Feel() == B_FLOATING_ALL_WINDOW_FEEL)
item->SetMarked(true);
menu->AddItem(item = new BMenuItem("Auto-raise",
new BMessage(kMsgToggleAutoRaise)));
if (window->IsAutoRaising())
item->SetMarked(true);
menu->AddSeparatorItem();
menu->AddItem(new BMenuItem("About Workspaces" B_UTF8_ELLIPSIS,
new BMessage(B_ABOUT_REQUESTED)));
menu->AddItem(new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED)));
menu->SetTargetForItems(window);
}
changeItem->SetTarget(this);
ConvertToScreen(&where);
menu->Go(where, true, true, true);
}
示例4: BMessage
void
NetworkStatusView::MouseDown(BPoint point)
{
BPopUpMenu* menu = new BPopUpMenu(B_EMPTY_STRING, false, false);
menu->SetAsyncAutoDestruct(true);
menu->SetFont(be_plain_font);
BString wifiInterface;
BNetworkDevice wifiDevice;
// Add interfaces
for (std::map<BString, int32>::const_iterator it
= fInterfaceStatuses.begin(); it != fInterfaceStatuses.end(); ++it) {
const BString& name = it->first;
BString label = name;
label += ": ";
label += kStatusDescriptions[
_DetermineInterfaceStatus(name.String())];
BMessage* info = new BMessage(kMsgShowConfiguration);
info->AddString("interface", name.String());
menu->AddItem(new BMenuItem(label.String(), info));
// We only show the networks of the first wireless device we find.
if (wifiInterface.IsEmpty()) {
wifiDevice.SetTo(name);
if (wifiDevice.IsWireless())
wifiInterface = name;
}
}
if (!fInterfaceStatuses.empty())
menu->AddSeparatorItem();
// Add wireless networks, if any
if (!wifiInterface.IsEmpty()) {
std::set<BNetworkAddress> associated;
BNetworkAddress address;
uint32 cookie = 0;
while (wifiDevice.GetNextAssociatedNetwork(cookie, address) == B_OK)
associated.insert(address);
cookie = 0;
wireless_network network;
typedef std::vector<wireless_network> WirelessNetworkVector;
WirelessNetworkVector wirelessNetworks;
while (wifiDevice.GetNextNetwork(cookie, network) == B_OK)
wirelessNetworks.push_back(network);
std::sort(wirelessNetworks.begin(), wirelessNetworks.end(),
signal_strength_compare);
int32 count = 0;
for (WirelessNetworkVector::iterator it = wirelessNetworks.begin();
it != wirelessNetworks.end(); it++) {
wireless_network &network = *it;
BMessage* message = new BMessage(kMsgJoinNetwork);
message->AddString("device", wifiInterface);
message->AddString("name", network.name);
message->AddFlat("address", &network.address);
BMenuItem* item = new WirelessNetworkMenuItem(network.name,
network.signal_strength, network.authentication_mode, message);
menu->AddItem(item);
if (associated.find(network.address) != associated.end())
item->SetMarked(true);
count++;
}
if (count == 0) {
BMenuItem* item = new BMenuItem(
B_TRANSLATE("<no wireless networks found>"), NULL);
item->SetEnabled(false);
menu->AddItem(item);
}
menu->AddSeparatorItem();
}
menu->AddItem(new BMenuItem(B_TRANSLATE(
"Open network preferences" B_UTF8_ELLIPSIS),
new BMessage(kMsgOpenNetworkPreferences)));
if (fInDeskbar) {
menu->AddItem(new BMenuItem(B_TRANSLATE("Quit"),
new BMessage(B_QUIT_REQUESTED)));
}
menu->SetTargetForItems(this);
ConvertToScreen(&point);
menu->Go(point, true, true, true);
}
示例5: BMessage
void
WorkspacesView::MouseDown(BPoint where)
{
// With enabled auto-raise feature, we'll get mouse messages we don't
// want to handle here.
if (!Bounds().Contains(where))
return;
int32 buttons = 0;
if (Window() != NULL && Window()->CurrentMessage() != NULL)
Window()->CurrentMessage()->FindInt32("buttons", &buttons);
if ((buttons & B_SECONDARY_MOUSE_BUTTON) == 0)
return;
// open context menu
BPopUpMenu *menu = new BPopUpMenu(B_EMPTY_STRING, false, false);
menu->SetFont(be_plain_font);
// TODO: alternatively change the count here directly?
BMenuItem* changeItem = new BMenuItem(B_TRANSLATE("Change workspace count"
B_UTF8_ELLIPSIS), new BMessage(kMsgChangeCount));
menu->AddItem(changeItem);
WorkspacesWindow* window = dynamic_cast<WorkspacesWindow*>(Window());
if (window != NULL) {
// inside Workspaces app
BMenuItem* item;
menu->AddSeparatorItem();
menu->AddItem(item = new BMenuItem(B_TRANSLATE("Show window tab"),
new BMessage(kMsgToggleTitle)));
if (window->Look() == B_TITLED_WINDOW_LOOK)
item->SetMarked(true);
menu->AddItem(item = new BMenuItem(B_TRANSLATE("Show window border"),
new BMessage(kMsgToggleBorder)));
if (window->Look() == B_TITLED_WINDOW_LOOK
|| window->Look() == B_MODAL_WINDOW_LOOK)
item->SetMarked(true);
menu->AddSeparatorItem();
menu->AddItem(item = new BMenuItem(B_TRANSLATE("Always on top"),
new BMessage(kMsgToggleAlwaysOnTop)));
if (window->Feel() == B_FLOATING_ALL_WINDOW_FEEL)
item->SetMarked(true);
menu->AddItem(item = new BMenuItem(B_TRANSLATE("Auto-raise"),
new BMessage(kMsgToggleAutoRaise)));
if (window->IsAutoRaising())
item->SetMarked(true);
if (be_roster->IsRunning(kDeskbarSignature)) {
menu->AddItem(item = new BMenuItem(B_TRANSLATE("Live in the Deskbar"),
new BMessage(kMsgToggleLiveInDeskbar)));
BDeskbar deskbar;
item->SetMarked(deskbar.HasItem(kDeskbarItemName));
}
menu->AddSeparatorItem();
menu->AddItem(new BMenuItem(B_TRANSLATE("About Workspaces"
B_UTF8_ELLIPSIS), new BMessage(B_ABOUT_REQUESTED)));
menu->AddItem(new BMenuItem(B_TRANSLATE("Quit"),
new BMessage(B_QUIT_REQUESTED)));
menu->SetTargetForItems(window);
} else {
// we're replicated in some way...
BMenuItem* item;
menu->AddSeparatorItem();
// check which way
BDragger *dragger = dynamic_cast<BDragger*>(ChildAt(0));
if (dragger) {
// replicant
menu->AddItem(item = new BMenuItem(B_TRANSLATE("Remove replicant"),
new BMessage(B_TRASH_TARGET)));
item->SetTarget(dragger);
} else {
// Deskbar item
menu->AddItem(item = new BMenuItem(B_TRANSLATE("Remove replicant"),
new BMessage(kMsgToggleLiveInDeskbar)));
item->SetTarget(this);
}
}
changeItem->SetTarget(this);
ConvertToScreen(&where);
menu->Go(where, true, true, true);
}
示例6: FindColumnTitle
void
BTitleView::MouseDown(BPoint where)
{
if (!Window()->IsActive()) {
// wasn't active, just activate and bail
Window()->Activate();
return;
}
// finish any pending edits
fPoseView->CommitActivePose();
BColumnTitle *title = FindColumnTitle(where);
BColumnTitle *resizedTitle = InColumnResizeArea(where);
uint32 buttons;
GetMouse(&where, &buttons);
// Check if the user clicked the secondary mouse button.
// if so, display the attribute menu:
if (buttons & B_SECONDARY_MOUSE_BUTTON) {
BContainerWindow *window = dynamic_cast<BContainerWindow *>
(Window());
BPopUpMenu *menu = new BPopUpMenu("Attributes", false, false);
menu->SetFont(be_plain_font);
window->NewAttributeMenu(menu);
window->AddMimeTypesToMenu(menu);
window->MarkAttributeMenu(menu);
menu->SetTargetForItems(window->PoseView());
menu->Go(ConvertToScreen(where), true, false);
return;
}
bigtime_t doubleClickSpeed;
get_click_speed(&doubleClickSpeed);
if (resizedTitle) {
bool force = static_cast<bool>(buttons & B_TERTIARY_MOUSE_BUTTON);
if (force || buttons & B_PRIMARY_MOUSE_BUTTON) {
if (force || fPreviouslyClickedColumnTitle != 0) {
if (force || system_time() - fPreviousLeftClickTime < doubleClickSpeed) {
if (fPoseView->ResizeColumnToWidest(resizedTitle->Column())) {
Invalidate();
return;
}
}
}
fPreviousLeftClickTime = system_time();
fPreviouslyClickedColumnTitle = resizedTitle;
}
} else if (!title)
return;
SetMouseEventMask(B_POINTER_EVENTS, B_NO_POINTER_HISTORY | B_LOCK_WINDOW_FOCUS);
// track the mouse
if (resizedTitle) {
fTrackingState = new ColumnResizeState(this, resizedTitle, where,
system_time() + doubleClickSpeed);
} else {
fTrackingState = new ColumnDragState(this, title, where,
system_time() + doubleClickSpeed);
}
}
示例7: showContextMenu
void MediaNodePanel::showContextMenu(
BPoint point)
{
D_METHOD(("MediaNodePanel::showContextMenu()\n"));
BPopUpMenu *menu = new BPopUpMenu("MediaNodePanel PopUp", false, false, B_ITEMS_IN_COLUMN);
menu->SetFont(be_plain_font);
BMenuItem *item;
BMessage *message;
// add the "Tweak Parameters" item
message = new BMessage(MediaRoutingView::M_NODE_TWEAK_PARAMETERS);
menu->AddItem(item = new BMenuItem("Tweak parameters", message, 'P'));
if (!(ref->kind() & B_CONTROLLABLE))
{
item->SetEnabled(false);
}
message = new BMessage(InfoWindowManager::M_INFO_WINDOW_REQUESTED);
message->AddInt32("nodeID", ref->id());
menu->AddItem(new BMenuItem("Get info", message, 'I'));
menu->AddSeparatorItem();
menu->AddItem(item = new BMenuItem("Release", new BMessage(MediaRoutingView::M_DELETE_SELECTION), 'T'));
if (!ref->isInternal())
{
item->SetEnabled(false);
}
menu->AddSeparatorItem();
// add the "Cycle" item
message = new BMessage(MediaRoutingView::M_NODE_CHANGE_CYCLING);
message->AddBool("cycle", !ref->isCycling());
menu->AddItem(item = new BMenuItem("Cycle", message));
item->SetMarked(ref->isCycling());
if (ref->flags() & NodeRef::NO_SEEK)
{
item->SetEnabled(false);
}
// add the "Run Mode" sub menu
BMenu *subMenu = new BMenu("Run mode");
subMenu->SetFont(be_plain_font);
for (uint32 runMode = 1; runMode <= BMediaNode::B_RECORDING; runMode++)
{
BString itemName = MediaString::getStringFor(static_cast<BMediaNode::run_mode>
(runMode));
message = new BMessage(MediaRoutingView::M_NODE_CHANGE_RUN_MODE);
message->AddInt32("run_mode", runMode);
subMenu->AddItem(item = new BMenuItem(itemName.String(), message));
if (ref->runMode() == runMode)
{
item->SetMarked(true);
}
else if ((ref->runMode() == 0)
&& (ref->group()) && (ref->group()->runMode() == BMediaNode::run_mode(runMode)))
{
item->SetMarked(true);
}
}
subMenu->AddSeparatorItem();
message = new BMessage(MediaRoutingView::M_NODE_CHANGE_RUN_MODE);
message->AddInt32("run_mode", 0);
subMenu->AddItem(item = new BMenuItem("(same as group)", message));
if (ref->group() == 0)
{
item->SetEnabled(false);
}
else if ((ref->runMode() < 1) && (ref->group()->runMode() > 0))
{
item->SetMarked(true);
}
menu->AddItem(subMenu);
subMenu->SetTargetForItems(view());
// [c.lenz 24dec99] hide rarely used commands in a 'Advanced' submenu
subMenu = new BMenu("Advanced");
subMenu->SetFont(be_plain_font);
// [e.moon 5dec99] ad-hoc timesource support
if(ref->kind() & B_TIME_SOURCE) {
message = new BMessage(MediaRoutingView::M_NODE_START_TIME_SOURCE);
message->AddInt32("nodeID", ref->id());
subMenu->AddItem(new BMenuItem(
"Start time source",
message));
message = new BMessage(MediaRoutingView::M_NODE_START_TIME_SOURCE);
message->AddInt32("nodeID", ref->id());
subMenu->AddItem(new BMenuItem(
"Stop time source",
message));
}
// [c.lenz 24dec99] support for BControllable::StartControlPanel()
if(ref->kind() & B_CONTROLLABLE) {
if (subMenu->CountItems() > 0)
subMenu->AddSeparatorItem();
message = new BMessage(MediaRoutingView::M_NODE_START_CONTROL_PANEL);
subMenu->AddItem(new BMenuItem("Start Control Panel", message,
'P', B_COMMAND_KEY | B_SHIFT_KEY));
}
//.........这里部分代码省略.........
示例8: BMessage
void
PadView::DisplayMenu(BPoint where, LaunchButton* button) const
{
MainWindow* window = dynamic_cast<MainWindow*>(Window());
if (window == NULL)
return;
LaunchButton* nearestButton = button;
if (!nearestButton) {
// find the nearest button
for (int32 i = 0; (nearestButton = ButtonAt(i)); i++) {
if (nearestButton->Frame().top > where.y)
break;
}
}
BPopUpMenu* menu = new BPopUpMenu(B_TRANSLATE("launch popup"), false, false);
// add button
BMessage* message = new BMessage(MSG_ADD_SLOT);
message->AddPointer("be:source", (void*)nearestButton);
BMenuItem* item = new BMenuItem(B_TRANSLATE("Add button here"), message);
item->SetTarget(window);
menu->AddItem(item);
// button options
if (button) {
// clear button
message = new BMessage(MSG_CLEAR_SLOT);
message->AddPointer("be:source", (void*)button);
item = new BMenuItem(B_TRANSLATE("Clear button"), message);
item->SetTarget(window);
menu->AddItem(item);
// remove button
message = new BMessage(MSG_REMOVE_SLOT);
message->AddPointer("be:source", (void*)button);
item = new BMenuItem(B_TRANSLATE("Remove button"), message);
item->SetTarget(window);
menu->AddItem(item);
// Open containing folder button
if (button->Ref() != NULL) {
message = new BMessage(MSG_OPEN_CONTAINING_FOLDER);
message->AddPointer("be:source", (void*)button);
item = new BMenuItem(B_TRANSLATE("Open containing folder"), message);
item->SetTarget(window);
menu->AddItem(item);
}
// set button description
if (button->Ref()) {
message = new BMessage(MSG_SET_DESCRIPTION);
message->AddPointer("be:source", (void*)button);
item = new BMenuItem(B_TRANSLATE("Set description"B_UTF8_ELLIPSIS),
message);
item->SetTarget(window);
menu->AddItem(item);
}
}
menu->AddSeparatorItem();
// window settings
BMenu* settingsM = new BMenu(B_TRANSLATE("Settings"));
settingsM->SetFont(be_plain_font);
const char* toggleLayoutLabel;
if (fButtonLayout->Orientation() == B_HORIZONTAL)
toggleLayoutLabel = B_TRANSLATE("Vertical layout");
else
toggleLayoutLabel = B_TRANSLATE("Horizontal layout");
item = new BMenuItem(toggleLayoutLabel, new BMessage(MSG_TOGGLE_LAYOUT));
item->SetTarget(this);
settingsM->AddItem(item);
BMenu* iconSizeM = new BMenu(B_TRANSLATE("Icon size"));
for (uint32 i = 0; i < sizeof(kIconSizes) / sizeof(uint32); i++) {
uint32 iconSize = kIconSizes[i];
message = new BMessage(MSG_SET_ICON_SIZE);
message->AddInt32("size", iconSize);
BString label;
label << iconSize << " x " << iconSize;
item = new BMenuItem(label.String(), message);
item->SetTarget(this);
item->SetMarked(IconSize() == iconSize);
iconSizeM->AddItem(item);
}
settingsM->AddItem(iconSizeM);
item = new BMenuItem(B_TRANSLATE("Ignore double-click"),
new BMessage(MSG_SET_IGNORE_DOUBLECLICK));
item->SetTarget(this);
item->SetMarked(IgnoreDoubleClick());
settingsM->AddItem(item);
uint32 what = window->Look() == B_BORDERED_WINDOW_LOOK ? MSG_SHOW_BORDER : MSG_HIDE_BORDER;
item = new BMenuItem(B_TRANSLATE("Show window border"), new BMessage(what));
item->SetTarget(window);
item->SetMarked(what == MSG_HIDE_BORDER);
settingsM->AddItem(item);
item = new BMenuItem(B_TRANSLATE("Auto-raise"), new BMessage(MSG_TOGGLE_AUTORAISE));
item->SetTarget(window);
item->SetMarked(window->AutoRaise());
settingsM->AddItem(item);
item = new BMenuItem(B_TRANSLATE("Show on all workspaces"), new BMessage(MSG_SHOW_ON_ALL_WORKSPACES));
//.........这里部分代码省略.........
示例9: MemoryBarMenuItem
status_t
thread_popup(void *arg)
{
Tpopup_param* param = (Tpopup_param*) arg;
int32 mcookie, hcookie;
unsigned long m;
long h;
BMenuItem* item;
bool top = param->top;
system_info systemInfo;
get_system_info(&systemInfo);
info_pack* infos = new info_pack[systemInfo.used_teams];
// TODO: this doesn't necessarily get all teams
for (m = 0, mcookie = 0; m < systemInfo.used_teams; m++) {
infos[m].team_icon = NULL;
infos[m].team_name[0] = 0;
infos[m].thread_info = NULL;
if (get_next_team_info(&mcookie, &infos[m].team_info) == B_OK) {
infos[m].thread_info = new thread_info[infos[m].team_info.thread_count];
for (h = 0, hcookie = 0; h < infos[m].team_info.thread_count; h++) {
if (get_next_thread_info(infos[m].team_info.team, &hcookie,
&infos[m].thread_info[h]) != B_OK)
infos[m].thread_info[h].thread = -1;
}
get_team_name_and_icon(infos[m], true);
} else {
systemInfo.used_teams = m;
infos[m].team_info.team = -1;
}
}
BPopUpMenu* popup = new BPopUpMenu("Global Popup", false, false);
popup->SetFont(be_plain_font);
// Quit section
BMenu* QuitPopup = new QuitMenu(B_TRANSLATE("Quit an application"),
infos, systemInfo.used_teams);
QuitPopup->SetFont(be_plain_font);
popup->AddItem(QuitPopup);
// Memory Usage section
MemoryBarMenu* MemoryPopup = new MemoryBarMenu(B_TRANSLATE("Memory usage"),
infos, systemInfo);
int64 committedMemory = (int64)systemInfo.used_pages * B_PAGE_SIZE / 1024;
for (m = 0; m < systemInfo.used_teams; m++) {
if (infos[m].team_info.team >= 0) {
MemoryBarMenuItem* memoryItem =
new MemoryBarMenuItem(infos[m].team_name,
infos[m].team_info.team, infos[m].team_icon, false, NULL);
MemoryPopup->AddItem(memoryItem);
memoryItem->UpdateSituation(committedMemory);
}
}
addtopbottom(MemoryPopup);
// CPU Load section
TeamBarMenu* CPUPopup = new TeamBarMenu(B_TRANSLATE("Threads and CPU "
"usage"), infos, systemInfo.used_teams);
for (m = 0; m < systemInfo.used_teams; m++) {
if (infos[m].team_info.team >= 0) {
ThreadBarMenu* TeamPopup = new ThreadBarMenu(infos[m].team_name,
infos[m].team_info.team, infos[m].team_info.thread_count);
BMessage* kill_team = new BMessage('KlTm');
kill_team->AddInt32("team", infos[m].team_info.team);
TeamBarMenuItem* item = new TeamBarMenuItem(TeamPopup, kill_team,
infos[m].team_info.team, infos[m].team_icon, false);
item->SetTarget(gPCView);
CPUPopup->AddItem(item);
}
}
addtopbottom(CPUPopup);
addtopbottom(new BSeparatorItem());
// CPU on/off section
if (gCPUcount > 1) {
for (unsigned int i = 0; i < gCPUcount; i++) {
char item_name[32];
sprintf (item_name, B_TRANSLATE("Processor %d"), i + 1);
BMessage* m = new BMessage ('CPU ');
m->AddInt32 ("cpu", i);
item = new IconMenuItem (gPCView->fProcessorIcon, item_name, m);
if (_kern_cpu_enabled(i))
item->SetMarked (true);
item->SetTarget(gPCView);
addtopbottom(item);
}
addtopbottom (new BSeparatorItem ());
}
// Scheduler modes
static const char* schedulerModes[] = { B_TRANSLATE_MARK("Low latency"),
B_TRANSLATE_MARK("Power saving") };
unsigned int modesCount = sizeof(schedulerModes) / sizeof(const char*);
int32 currentMode = get_scheduler_mode();
for (unsigned int i = 0; i < modesCount; i++) {
BMessage* m = new BMessage('Schd');
m->AddInt32("mode", i);
//.........这里部分代码省略.........
示例10: font
/***********************************************************
* MouseDown
***********************************************************/
void
HListView::MouseDown(BPoint pos) {
int32 buttons = 0;
ResourceUtils utils;
BPoint point = pos;
MenuUtils menu_utils;
Window()->CurrentMessage()->FindInt32("buttons", &buttons);
this->MakeFocus(true);
// Handling of right click
if (buttons == B_SECONDARY_MOUSE_BUTTON) {
int32 sel = IndexOf(pos);
if (sel >= 0)
Select(sel);
else
DeselectAll();
sel = CurrentSelection();
HListItem* item = NULL;
if (sel >= 0)
item = cast_as(ItemAt(sel), HListItem);
BPopUpMenu* theMenu = new BPopUpMenu("RIGHT_CLICK", false, false);
BFont font(be_plain_font);
font.SetSize(10);
theMenu->SetFont(&font);
menu_utils.AddMenuItem(theMenu
, _("Add New Download")
, M_ADD_URL
, NULL, NULL
, 'A', 0, utils.GetBitmapResource('BBMP', "BMP:ADDURL"));
theMenu->AddSeparatorItem();
menu_utils.AddMenuItem(theMenu
, _("Suspend")
, M_SUSPEND, NULL, NULL
, 0, 0, utils.GetBitmapResource('BBMP', "BMP:SUSPEND"));
if (item) {
theMenu->FindItem(M_SUSPEND)->SetEnabled(item->IsSuspendable());
} else {
theMenu->FindItem(M_SUSPEND)->SetEnabled(false);
}
menu_utils.AddMenuItem(theMenu
, _("Resume")
, M_RESUME, NULL, NULL
, 0, 0, utils.GetBitmapResource('BBMP', "BMP:RESUME"));
if (item) {
theMenu->FindItem(M_RESUME)->SetEnabled(item->IsResumable());
} else {
theMenu->FindItem(M_RESUME)->SetEnabled(false);
}
theMenu->AddSeparatorItem();
menu_utils.AddMenuItem(theMenu
, _("Stop")
, M_STOP, NULL, NULL
, 0, 0, utils.GetBitmapResource('BBMP', "BMP:STOP"));
if (item)
theMenu->FindItem(M_STOP)->SetEnabled(item->IsStarted());
else
theMenu->FindItem(M_STOP)->SetEnabled(false);
menu_utils.AddMenuItem(theMenu
, _("Start")
, M_START, NULL, NULL
, 0, 0, utils.GetBitmapResource('BBMP', "BMP:CONNECTING"));
if (sel >= 0)
theMenu->FindItem(M_START)->SetEnabled(!item->IsStarted());
else
theMenu->FindItem(M_START)->SetEnabled(false);
theMenu->AddSeparatorItem();
menu_utils.AddMenuItem(theMenu
, _("Delete")
, M_DELETE, NULL, NULL
, 'T', 0, utils.GetBitmapResource('BBMP', "BMP:TRASH"));
theMenu->FindItem(M_DELETE)->SetEnabled((sel >= 0) ? true : false);
BRect r;
ConvertToScreen(&pos);
r.top = pos.y - 5;
r.bottom = pos.y + 5;
r.left = pos.x - 5;
r.right = pos.x + 5;
BMenuItem* theItem = theMenu->Go(pos, false, true, r);
if (theItem) {
BMessage* aMessage = theItem->Message();
if (aMessage)
this->Window()->PostMessage(aMessage);
}
delete theMenu;
} else
//.........这里部分代码省略.........
示例11: MemoryBarMenuItem
long
thread_popup(void *arg)
{
Tpopup_param* param = (Tpopup_param*) arg;
int32 mcookie, hcookie;
long m, h;
BMenuItem* item;
bool top = param->top;
system_info systemInfo;
get_system_info(&systemInfo);
info_pack* infos = new info_pack[systemInfo.used_teams];
// TODO: this doesn't necessarily get all teams
for (m = 0, mcookie = 0; m < systemInfo.used_teams; m++) {
infos[m].team_icon = NULL;
infos[m].team_name[0] = 0;
infos[m].thread_info = NULL;
if (get_next_team_info(&mcookie, &infos[m].team_info) == B_OK) {
infos[m].thread_info = new thread_info[infos[m].team_info.thread_count];
for (h = 0, hcookie = 0; h < infos[m].team_info.thread_count; h++) {
if (get_next_thread_info(infos[m].team_info.team, &hcookie,
&infos[m].thread_info[h]) != B_OK)
infos[m].thread_info[h].thread = -1;
}
get_team_name_and_icon(infos[m], true);
} else {
systemInfo.used_teams = m;
infos[m].team_info.team = -1;
}
}
BPopUpMenu* popup = new BPopUpMenu("Global Popup", false, false);
popup->SetFont(be_plain_font);
// Quit section
BMenu* QuitPopup = new QuitMenu(B_TRANSLATE("Quit an application"),
infos, systemInfo.used_teams);
QuitPopup->SetFont(be_plain_font);
popup->AddItem(QuitPopup);
// Memory Usage section
MemoryBarMenu* MemoryPopup = new MemoryBarMenu(B_TRANSLATE("Memory usage"),
infos, systemInfo);
int commitedMemory = int(systemInfo.used_pages * B_PAGE_SIZE / 1024);
for (m = 0; m < systemInfo.used_teams; m++) {
if (infos[m].team_info.team >= 0) {
MemoryBarMenuItem* memoryItem =
new MemoryBarMenuItem(infos[m].team_name,
infos[m].team_info.team, infos[m].team_icon, false, NULL);
MemoryPopup->AddItem(memoryItem);
memoryItem->UpdateSituation(commitedMemory);
}
}
addtopbottom(MemoryPopup);
// CPU Load section
TeamBarMenu* CPUPopup = new TeamBarMenu(B_TRANSLATE("Threads and CPU "
"usage"), infos, systemInfo.used_teams);
for (m = 0; m < systemInfo.used_teams; m++) {
if (infos[m].team_info.team >= 0) {
ThreadBarMenu* TeamPopup = new ThreadBarMenu(infos[m].team_name,
infos[m].team_info.team, infos[m].team_info.thread_count);
BMessage* kill_team = new BMessage('KlTm');
kill_team->AddInt32("team", infos[m].team_info.team);
TeamBarMenuItem* item = new TeamBarMenuItem(TeamPopup, kill_team,
infos[m].team_info.team, infos[m].team_icon, false);
item->SetTarget(gPCView);
CPUPopup->AddItem(item);
}
}
addtopbottom(CPUPopup);
addtopbottom(new BSeparatorItem());
// CPU on/off section
if (gCPUcount > 1) {
for (int i = 0; i < gCPUcount; i++) {
char item_name[32];
sprintf (item_name, B_TRANSLATE("Processor %d"), i + 1);
BMessage* m = new BMessage ('CPU ');
m->AddInt32 ("cpu", i);
item = new IconMenuItem (gPCView->fProcessorIcon, item_name, m);
if (_kern_cpu_enabled(i))
item->SetMarked (true);
item->SetTarget(gPCView);
addtopbottom(item);
}
addtopbottom (new BSeparatorItem ());
}
if (!be_roster->IsRunning(kTrackerSig)) {
item = new IconMenuItem(gPCView->fTrackerIcon,
B_TRANSLATE("Restart Tracker"), new BMessage('Trac'));
item->SetTarget(gPCView);
addtopbottom(item);
}
if (!be_roster->IsRunning(kDeskbarSig)) {
item = new IconMenuItem(gPCView->fDeskbarIcon,
B_TRANSLATE("Restart Deskbar"), new BMessage('Dbar'));
//.........这里部分代码省略.........
示例12: rect
void
CAssemblyWindow::AddToolBar()
{
BMessage *message;
// make the pop up menu for 'Select' tool
BPopUpMenu *selectMenu = new BPopUpMenu("", false, false);
selectMenu->SetFont(be_plain_font);
message = new BMessage(SELECT_MODE_CHANGED);
message->AddInt32("mev:mode", CEventEditor::RECTANGLE_SELECTION);
selectMenu->AddItem(new CIconMenuItem("Rectangle", message,
ResourceUtils::LoadImage("ArrowTool")));
message = new BMessage(*message);
message->ReplaceInt32("mev:mode", CEventEditor::LASSO_SELECTION);
selectMenu->AddItem(new CIconMenuItem("Lasso", message,
ResourceUtils::LoadImage("LassoTool")));
selectMenu->SetTargetForItems(this);
// make the pop up menu for 'Create' tool
BPopUpMenu *createMenu = new BPopUpMenu("", false, false);
createMenu->SetFont(be_plain_font);
message = new BMessage(NEW_EVENT_TYPE_CHANGED);
message->AddInt32("type", EvtType_Count);
createMenu->AddItem(new CIconMenuItem("Default", message,
ResourceUtils::LoadImage("PencilTool")));
createMenu->AddSeparatorItem();
message = new BMessage(*message);
message->ReplaceInt32("type", EvtType_Tempo);
createMenu->AddItem(new CIconMenuItem("Tempo", message,
ResourceUtils::LoadImage("MetroTool")));
message = new BMessage(*message);
message->ReplaceInt32("type", EvtType_TimeSig);
createMenu->AddItem(new CIconMenuItem("Time Signature", message,
ResourceUtils::LoadImage("TimeSigTool")));
message = new BMessage(*message);
message->ReplaceInt32("type", EvtType_Repeat);
createMenu->AddItem(new CIconMenuItem("Repeat", message,
ResourceUtils::LoadImage("RepeatTool")));
message = new BMessage(*message);
message->ReplaceInt32("type", EvtType_End);
createMenu->AddItem(new CIconMenuItem("Part End", message,
ResourceUtils::LoadImage("EndTool")));
createMenu->SetTargetForItems(this);
BRect rect(Bounds());
if (KeyMenuBar())
rect.top = KeyMenuBar()->Frame().bottom + 1.0;
rect.right += 1.0;
// add the tool bar
CToolBar *toolBar = new CToolBar(rect, "General");
CTool *tool;
toolBar->AddTool(tool = new CBitmapTool("Snap To Grid",
ResourceUtils::LoadImage("GridTool"),
new BMessage(CEventEditor::TOOL_GRID)));
tool->SetValue(B_CONTROL_ON);
toolBar->AddSeparator();
toolBar->AddTool(tool = new CMenuTool("Select",
ResourceUtils::LoadImage("ArrowTool"),
selectMenu,
new BMessage(CEventEditor::TOOL_SELECT)));
tool->SetValue(B_CONTROL_ON);
toolBar->AddTool(new CMenuTool("Create", ResourceUtils::LoadImage("PencilTool"),
createMenu, new BMessage(CEventEditor::TOOL_CREATE)));
toolBar->AddTool(tool = new CBitmapTool("Eraser",
ResourceUtils::LoadImage("EraserTool"),
new BMessage(CEventEditor::TOOL_ERASE)));
toolBar->MakeRadioGroup("Select", "Eraser", true);
SetToolBar(toolBar);
}