GDWindow::GDWindow(BRect frame) : BWindow(frame, "GrafDemo 4.6", B_DOCUMENT_WINDOW,0) { Lock(); // Add the graph to the window BRect grafRect = Bounds(); grafRect.top += mb_height + 2; mGraphView= new GDView(grafRect); AddChild(mGraphView); SetSizeLimits(frame.right - frame.left,9999,frame.bottom - frame.top,9999); // Add the main menu bar and menus BRect menuRect(0,0,1000,mb_height); BMenuBar* menuBar = new BMenuBar(menuRect,"MB"); BMenu* fileMenu = new BMenu("File"); BMenuItem* aboutItem = new BMenuItem("About...",new BMessage(B_ABOUT_REQUESTED)); aboutItem->SetTarget(be_app); fileMenu->AddItem(aboutItem); fileMenu->AddSeparatorItem(); fileMenu->AddItem(new BMenuItem("Quit",new BMessage(B_QUIT_REQUESTED))); menuBar->AddItem(fileMenu); BMenu* editMenu = new BMenu("Edit"); editMenu->AddItem(new BMenuItem("Erase",new BMessage(G_erase_data))); editMenu->AddItem(new BMenuItem("Reset Axes",new BMessage(G_reset_axes))); editMenu->SetTargetForItems(mGraphView); menuBar->AddItem(editMenu); BMenu* paramsMenu = new BMenu("Params"); BMessage* cFitMesg = new BMessage(G_set_params); cFitMesg->AddInt16(pName,0); BMessage* p2Mesg = new BMessage(G_set_params); p2Mesg->AddInt16(pName,2); BMessage* p3Mesg = new BMessage(G_set_params); p3Mesg->AddInt16(pName,3); BMessage* p4Mesg = new BMessage(G_set_params); p4Mesg->AddInt16(pName,4); paramsMenu->AddItem(new BMenuItem("Cubic Spline",cFitMesg)); paramsMenu->AddSeparatorItem(); paramsMenu->AddItem(new BMenuItem("1st Order",p2Mesg)); paramsMenu->AddItem(new BMenuItem("2nd Order",p3Mesg)); paramsMenu->AddItem(new BMenuItem("3rd Order",p4Mesg)); paramsMenu->SetRadioMode(true); paramsMenu->FindItem("2nd Order")->SetMarked(true); paramsMenu->SetTargetForItems(mGraphView); menuBar->AddItem(paramsMenu); BMenu* axisMenu = new BMenu("Axes"); axisMenu->AddItem(new BMenuItem("Set Axes"B_UTF8_ELLIPSIS,new BMessage(G_change_axis))); axisMenu->SetTargetForItems(mGraphView); menuBar->AddItem(axisMenu); AddChild(menuBar); Unlock(); }
S9xRefreshWindow::S9xRefreshWindow(BRect rect, BWindow *parent, uint32 closemsg) : BWindow(rect, "FullScreen - Refresh Rate", B_FLOATING_WINDOW, B_NOT_ZOOMABLE | B_NOT_RESIZABLE), fWindow(parent), fS9xMsg(closemsg) { display_mode *modes; uint32 mode_count; if(BScreen().GetModeList(&modes, &mode_count) == B_NO_ERROR) { BMenu *menu = new BMenu("menu"); for(unsigned int i = 0; i < mode_count; i++) { // if((modes[i].virtual_width == 640) && (modes[i].space == B_RGB16)) { BMessage *msg = new BMessage(ID_REFRESH); msg->AddPointer("refr_rate", (void *)&modes[i]); BString item_name; item_name << (modes[i].timing.pixel_clock * 1000) / (modes[i].timing.h_total * modes[i].timing.v_total) << " Hz"; menu->AddItem(new BMenuItem(item_name.String(), msg)); // } } BRect r(20, 20, 200, 60); BMenuField *field = new BMenuField(r, "field", "Refresh Rate:", menu); AddChild(field); menu->SetLabelFromMarked(true); menu->ItemAt(0)->SetMarked(true); menu->SetTargetForItems(fWindow); } Show(); }
// SetMenu void TransformerListView::SetMenu(BMenu* menu) { if (fMenu == menu) return; fMenu = menu; if (fMenu == NULL) return; BMenu* addMenu = new BMenu(B_TRANSLATE("Add")); int32 cookie = 0; uint32 type; BString name; while (TransformerFactory::NextType(&cookie, &type, &name)) { // TODO: Disable the "Transformation" and "Perspective" transformers // since they are not very useful or even implemented at all. if (name == B_TRANSLATE("Transformation") || name == B_TRANSLATE("Perspective")) continue; // End of TODO. BMessage* message = new BMessage(MSG_ADD_TRANSFORMER); message->AddInt32("type", type); addMenu->AddItem(new BMenuItem(name.String(), message)); } addMenu->SetTargetForItems(this); fMenu->AddItem(addMenu); _UpdateMenu(); }
void AppearancePrefView::AttachedToWindow() { fTabTitle->SetTarget(this); fWindowTitle->SetTarget(this); fBlinkCursor->SetTarget(this); fBrightInsteadOfBold->SetTarget(this); fWarnOnExit->SetTarget(this); fFontField->Menu()->SetTargetForItems(this); for (int32 i = 0; i < fFontField->Menu()->CountItems(); i++) { BMenu* fontSizeMenu = fFontField->Menu()->SubmenuAt(i); if (fontSizeMenu == NULL) continue; fontSizeMenu->SetTargetForItems(this); } fColorControl->SetTarget(this); fColorField->Menu()->SetTargetForItems(this); fColorSchemeField->Menu()->SetTargetForItems(this); fWindowSizeField->Menu()->SetTargetForItems(this); fEncodingField->Menu()->SetTargetForItems(this); _SetCurrentColorScheme(); }
void ControlView::_UpdateFontmenus(bool setInitialfont) { BFont font; BMenu* stylemenu = NULL; font_family fontFamilyName, currentFamily; font_style fontStyleName, currentStyle; GetFont(&font); font.GetFamilyAndStyle(¤tFamily, ¤tStyle); const int32 fontfamilies = count_font_families(); fFontFamilyMenu->RemoveItems(0, fFontFamilyMenu->CountItems(), true); for (int32 i = 0; i < fontfamilies; i++) { if (get_font_family(i, &fontFamilyName) == B_OK) { stylemenu = new BMenu(fontFamilyName); const int32 styles = count_font_styles(fontFamilyName); BMessage* familyMsg = new BMessage(FONTFAMILY_CHANGED_MSG); familyMsg->AddString("_family", fontFamilyName); BMenuItem* familyItem = new BMenuItem(stylemenu, familyMsg); fFontFamilyMenu->AddItem(familyItem); for (int32 j = 0; j < styles; j++) { if (get_font_style(fontFamilyName, j, &fontStyleName) == B_OK) { BMessage* fontMsg = new BMessage(FONTSTYLE_CHANGED_MSG); fontMsg->AddString("_family", fontFamilyName); fontMsg->AddString("_style", fontStyleName); BMenuItem* styleItem = new BMenuItem(fontStyleName, fontMsg); styleItem->SetMarked(false); // setInitialfont is used when we attach the FontField if (!strcmp(fontStyleName, currentStyle) && !strcmp(fontFamilyName, currentFamily) && setInitialfont) { styleItem->SetMarked(true); familyItem->SetMarked(true); BString string; string << currentFamily << " " << currentStyle; if (fFontMenuField) fFontMenuField->MenuItem()->SetLabel(string.String()); } stylemenu->AddItem(styleItem); } } } stylemenu->SetRadioMode(true); stylemenu->SetTargetForItems(this); } fFontFamilyMenu->SetLabelFromMarked(true); fFontFamilyMenu->SetTargetForItems(this); }
/*! \brief Called to take special actions when the child views are attached. It's used to set correctly the divider for the BMenuField. */ void BOptionPopUp::AllAttached() { BMenu *menu = fMenuField->Menu(); if (menu != NULL) { float labelWidth = fMenuField->StringWidth(fMenuField->Label()); fMenuField->SetDivider(labelWidth + kLabelSpace); menu->SetTargetForItems(this); } }
void MediaReplicant::MouseDown(BPoint point) { int32 buttons = B_PRIMARY_MOUSE_BUTTON; if (Looper() != NULL && Looper()->CurrentMessage() != NULL) Looper()->CurrentMessage()->FindInt32("buttons", &buttons); BPoint where = ConvertToScreen(point); if ((buttons & B_SECONDARY_MOUSE_BUTTON) != 0) { BPopUpMenu* menu = new BPopUpMenu("", false, false); menu->SetFont(be_plain_font); menu->AddItem(new BMenuItem( B_TRANSLATE("Media preferences" B_UTF8_ELLIPSIS), new BMessage(kMsgOpenMediaSettings))); menu->AddItem(new BMenuItem( B_TRANSLATE("Sound preferences" B_UTF8_ELLIPSIS), new BMessage(kMsgOpenSoundSettings))); menu->AddSeparatorItem(); menu->AddItem(new BMenuItem(B_TRANSLATE("Open MediaPlayer"), new BMessage(kMsgOpenMediaPlayer))); menu->AddSeparatorItem(); BMenu* subMenu = new BMenu(B_TRANSLATE("Options")); menu->AddItem(subMenu); BMenuItem* item = new BMenuItem(B_TRANSLATE("Control physical output"), new BMessage(kMsgVolumeWhich)); item->SetMarked(fVolumeWhich == VOLUME_USE_PHYS_OUTPUT); subMenu->AddItem(item); item = new BMenuItem(B_TRANSLATE("Beep"), new BMessage(kMsgToggleBeep)); item->SetMarked(!fDontBeep); subMenu->AddItem(item); menu->SetTargetForItems(this); subMenu->SetTargetForItems(this); menu->Go(where, true, true, BRect(where - BPoint(4, 4), where + BPoint(4, 4))); } else { // Show VolumeWindow fVolumeSlider = new VolumeWindow(BRect(where.x, where.y, where.x + 207, where.y + 19), fDontBeep, fVolumeWhich); fVolumeSlider->Show(); } }
void AccountView::AttachedToWindow() { // Once we are attached to window, the GUI is already created // so we can set our window as target for messages for (int32 i = 0; i < CountChildren(); i++) { BView* child = ChildAt(i); BMenu* menu = dynamic_cast<BMenu*>(child); BMenuField* menuField = dynamic_cast<BMenuField*>(child); BTextControl* textControl = dynamic_cast<BTextControl*>(child); NotifyingTextView* textView = dynamic_cast<NotifyingTextView*>(child); BCheckBox* checkBox = dynamic_cast<BCheckBox*>(child); if (menuField) menu = menuField->Menu(); if (menu) { for (int32 j = 0; j < menu->CountItems(); j++) { BMenuItem* item = menu->ItemAt(j); item->SetMessage(new BMessage(kChanged)); item->SetTarget(Window()); } menu->SetTargetForItems(Window()); } if (textControl) { textControl->SetMessage(new BMessage(kChanged)); textControl->SetTarget(Window()); } if (checkBox) { checkBox->SetMessage(new BMessage(kChanged)); checkBox->SetTarget(Window()); } if (textView) { textView->SetMessage(new BMessage(kChanged)); textView->SetTarget(Window()); } } }
void BrowserWindow::PopupMenu( KParts::BrowserExtension* /*pcSource*/, const std::string& cURL ) { #if 0 m_pcPopupMenu = new os::Menu( Rect( 0, 0, 10, 10 ), "popup", ITEMS_IN_COLUMN ); // Menu* pcSpeedMenu = new os::Menu( Rect( 0, 0, 10, 10 ), "Speed", ITEMS_IN_COLUMN ); // m_pcPopupMenu->AddItem( pcSpeedMenu ); os::Message* pcMsg; m_pcPopupMenu->AddItem( new os::MenuItem( "New window", new os::Message( ID_NEW_WINDOW ) ) ); m_pcPopupMenu->AddItem( new os::MenuItem( "Reload", new os::Message( ID_RELOAD ) ) ); if ( cURL.empty() == false ) { m_pcPopupMenu->AddItem( new os::MenuSeparator() ); pcMsg = new os::Message( ID_OPEN_LINK ); pcMsg->AddString( "url", cURL ); m_pcPopupMenu->AddItem( new os::MenuItem( "Open link in new window", pcMsg ) ); pcMsg = new os::Message( ID_SAVE_LINK ); pcMsg->AddString( "url", cURL ); m_pcPopupMenu->AddItem( new os::MenuItem( "Save link as...", pcMsg ) ); pcMsg = new os::Message( ID_COPY_LINK_LOCATION ); pcMsg->AddString( "url", cURL ); m_pcPopupMenu->AddItem( new os::MenuItem( "Copy link location", pcMsg ) ); } // m_pcPopupMenu->AddItem( new os::MenuItem( "View document source", new os::Message( ID_VIEW_DOC_SRC ) ) ); // pcMsg = new os::Message( ID_VIEW_FRAME_SRC ); // pcMsg->AddPointer( "browser", pcSource ); // m_pcPopupMenu->AddItem( new os::MenuItem( "View frame source", new os::Message( ID_VIEW_FRAME_SRC ) ) ); m_pcPopupMenu->AddItem( new os::MenuSeparator() ); m_pcPopupMenu->AddItem( new os::MenuItem( "Quit", new os::Message( M_QUIT ) ) ); m_pcPopupMenu->SetTargetForItems( this ); os::Point cMousePos; m_pcStatusBar->GetMouse( &cMousePos, NULL ); m_pcPopupMenu->Open( m_pcStatusBar->ConvertToScreen( cMousePos ) ); #endif }
void PictureTestWindow::BuildGUI() { BView* backdrop = new BView(Bounds(), "backdrop", B_FOLLOW_ALL, B_WILL_DRAW); backdrop->SetViewColor(::ui_color(B_PANEL_BACKGROUND_COLOR)); AddChild(backdrop); BMenuBar* mb = new BMenuBar(Bounds(), "menubar"); BMenu* m = new BMenu("File"); m->AddItem(new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED), 'Q')); m->SetTargetForItems(be_app_messenger); mb->AddItem(m); m = new BMenu("Tests"); m->AddItem(new BMenuItem("Run", new BMessage(kMsgRunTests), 'R')); m->AddItem(new BMenuItem("Run Color Space B_RGB32", new BMessage(kMsgRunTests1), 'S')); mb->AddItem(m); backdrop->AddChild(mb); BRect b = Bounds(); b.top = mb->Bounds().bottom + 1; fHeader = new BStringView(b, "header", "X", B_FOLLOW_LEFT | B_FOLLOW_RIGHT | B_FOLLOW_TOP); float width, height; fHeader->GetPreferredSize(&width, &height); fHeader->ResizeTo(b.Width(), height); backdrop->AddChild(fHeader); b.top = fHeader->Frame().bottom + 1; b.right -= B_V_SCROLL_BAR_WIDTH; b.bottom -= B_H_SCROLL_BAR_HEIGHT; fListView = new BListView(b, "Results", B_SINGLE_SELECTION_LIST, B_FOLLOW_ALL_SIDES, B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE); backdrop->AddChild(new BScrollView("scroll_results", fListView, B_FOLLOW_ALL_SIDES, 0, true, true)); UpdateHeader(); }
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)); } // [em 1feb00] group tweaks if(ref->group()) { message = new BMessage(MediaRoutingView::M_GROUP_SET_LOCKED); message->AddInt32("groupID", ref->group()->id()); bool isLocked = (ref->group()->groupFlags() & NodeGroup::GROUP_LOCKED); message->AddBool("locked", !isLocked); if (subMenu->CountItems() > 0) subMenu->AddSeparatorItem(); subMenu->AddItem( new BMenuItem( isLocked ? "Unlock group" : "Lock group", message)); } if (subMenu->CountItems() > 0) { menu->AddItem(subMenu); subMenu->SetTargetForItems(view()); } menu->SetTargetForItems(view()); view()->ConvertToScreen(&point); point -= BPoint(1.0, 1.0); menu->Go(point, true, true, true); }
bool TDeskbarMenu::AddStandardDeskbarMenuItems() { bool dragging = false; if (fBarView) dragging = fBarView->Dragging(); BMenuItem* item; // One of them is used if HAIKU_DISTRO_COMPATIBILITY_OFFICIAL, and the other if // not. However, we want both of them to end up in the catalog, so we have to // make them visible to collectcatkeys in either case. B_TRANSLATE_MARK_VOID("About Haiku") B_TRANSLATE_MARK_VOID("About this system") item = new BMenuItem( #ifdef HAIKU_DISTRO_COMPATIBILITY_OFFICIAL B_TRANSLATE_NOCOLLECT("About Haiku") #else B_TRANSLATE_NOCOLLECT("About this system") #endif , new BMessage(kShowSplash)); item->SetEnabled(!dragging); AddItem(item); static const char* kFindMenuItemStr = B_TRANSLATE_MARK("Find" B_UTF8_ELLIPSIS); #ifdef SHOW_RECENT_FIND_ITEMS item = new BMenuItem( TrackerBuildRecentFindItemsMenu(kFindMenuItemStr), new BMessage(kFindButton)); #else item = new BMenuItem(B_TRANSLATE_NOCOLLECT(kFindMenuItemStr), new BMessage(kFindButton)); #endif item->SetEnabled(!dragging); AddItem(item); item = new BMenuItem(B_TRANSLATE("Show replicants"), new BMessage(kToggleDraggers)); item->SetEnabled(!dragging); item->SetMarked(BDragger::AreDraggersDrawn()); AddItem(item); static const char* kMountMenuStr = B_TRANSLATE_MARK("Mount"); #ifdef MOUNT_MENU_IN_DESKBAR DeskbarMountMenu* mountMenu = new DeskbarMountMenu( B_TRANSLATE_NOCOLLECT(kMountMenuStr)); mountMenu->SetEnabled(!dragging); AddItem(mountMenu); #endif item = new BMenuItem(B_TRANSLATE("Deskbar preferences" B_UTF8_ELLIPSIS), new BMessage(kConfigShow)); item->SetTarget(be_app); AddItem(item); AddSeparatorItem(); BMenu* shutdownMenu = new BMenu(B_TRANSLATE("Shutdown" B_UTF8_ELLIPSIS)); item = new BMenuItem(B_TRANSLATE("Restart system"), new BMessage(kRebootSystem)); item->SetEnabled(!dragging); shutdownMenu->AddItem(item); B_TRANSLATE_MARK_VOID("Suspend"); #ifdef APM_SUPPORT if (_kapm_control_(APM_CHECK_ENABLED) == B_OK) { item = new BMenuItem(B_TRANSLATE_NOCOLLECT("Suspend"), new BMessage(kSuspendSystem)); item->SetEnabled(!dragging); shutdownMenu->AddItem(item); } #endif item = new BMenuItem(B_TRANSLATE("Power off"), new BMessage(kShutdownSystem)); item->SetEnabled(!dragging); shutdownMenu->AddItem(item); shutdownMenu->SetFont(be_plain_font); shutdownMenu->SetTargetForItems(be_app); BMessage* message = new BMessage(kShutdownSystem); message->AddBool("confirm", true); AddItem(new BMenuItem(shutdownMenu, message)); fAddState = kAddingRecents; return true; }
void InspectorWindow::_Init() { fLanguage = new CppLanguage(); fExpressionInfo = new ExpressionInfo(); fExpressionInfo->AddListener(this); BScrollView* scrollView; BMenu* hexMenu = new BMenu("Hex Mode"); BMessage* message = new BMessage(MSG_SET_HEX_MODE); message->AddInt32("mode", HexModeNone); BMenuItem* item = new BMenuItem("<None>", message, '0'); hexMenu->AddItem(item); message = new BMessage(*message); message->ReplaceInt32("mode", HexMode8BitInt); item = new BMenuItem("8-bit integer", message, '1'); hexMenu->AddItem(item); message = new BMessage(*message); message->ReplaceInt32("mode", HexMode16BitInt); item = new BMenuItem("16-bit integer", message, '2'); hexMenu->AddItem(item); message = new BMessage(*message); message->ReplaceInt32("mode", HexMode32BitInt); item = new BMenuItem("32-bit integer", message, '3'); hexMenu->AddItem(item); message = new BMessage(*message); message->ReplaceInt32("mode", HexMode64BitInt); item = new BMenuItem("64-bit integer", message, '4'); hexMenu->AddItem(item); BMenu* endianMenu = new BMenu("Endian Mode"); message = new BMessage(MSG_SET_ENDIAN_MODE); message->AddInt32("mode", EndianModeLittleEndian); item = new BMenuItem("Little Endian", message, 'L'); endianMenu->AddItem(item); message = new BMessage(*message); message->ReplaceInt32("mode", EndianModeBigEndian); item = new BMenuItem("Big Endian", message, 'B'); endianMenu->AddItem(item); BMenu* textMenu = new BMenu("Text Mode"); message = new BMessage(MSG_SET_TEXT_MODE); message->AddInt32("mode", TextModeNone); item = new BMenuItem("<None>", message, 'N'); textMenu->AddItem(item); message = new BMessage(*message); message->ReplaceInt32("mode", TextModeASCII); item = new BMenuItem("ASCII", message, 'A'); textMenu->AddItem(item); BLayoutBuilder::Group<>(this, B_VERTICAL) .SetInsets(B_USE_DEFAULT_SPACING) .AddGroup(B_HORIZONTAL) .Add(fAddressInput = new BTextControl("addrInput", "Target Address:", "", new BMessage(MSG_INSPECT_ADDRESS))) .Add(fPreviousBlockButton = new BButton("navPrevious", "<", new BMessage(MSG_NAVIGATE_PREVIOUS_BLOCK))) .Add(fNextBlockButton = new BButton("navNext", ">", new BMessage(MSG_NAVIGATE_NEXT_BLOCK))) .End() .AddGroup(B_HORIZONTAL) .Add(fHexMode = new BMenuField("hexMode", "Hex Mode:", hexMenu)) .AddGlue() .Add(fEndianMode = new BMenuField("endianMode", "Endian Mode:", endianMenu)) .AddGlue() .Add(fTextMode = new BMenuField("viewMode", "Text Mode:", textMenu)) .End() .Add(scrollView = new BScrollView("memory scroll", NULL, 0, false, true), 3.0f) .AddGroup(B_HORIZONTAL) .Add(fWritableBlockIndicator = new BStringView("writableIndicator", _GetCurrentWritableIndicator())) .AddGlue() .Add(fEditBlockButton = new BButton("editBlock", "Edit", new BMessage(MSG_EDIT_CURRENT_BLOCK))) .Add(fCommitBlockButton = new BButton("commitBlock", "Commit", new BMessage(MSG_COMMIT_MODIFIED_BLOCK))) .Add(fRevertBlockButton = new BButton("revertBlock", "Revert", new BMessage(MSG_REVERT_MODIFIED_BLOCK))) .End() .End(); fHexMode->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); fEndianMode->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); fTextMode->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); int32 targetEndian = fTeam->GetArchitecture()->IsBigEndian() ? EndianModeBigEndian : EndianModeLittleEndian; scrollView->SetTarget(fMemoryView = MemoryView::Create(fTeam, this)); fAddressInput->SetTarget(this); fPreviousBlockButton->SetTarget(this); fNextBlockButton->SetTarget(this); fPreviousBlockButton->SetEnabled(false); fNextBlockButton->SetEnabled(false); fEditBlockButton->SetTarget(this); fCommitBlockButton->SetTarget(this); fRevertBlockButton->SetTarget(this); fEditBlockButton->SetEnabled(false); fCommitBlockButton->Hide(); fRevertBlockButton->Hide(); hexMenu->SetLabelFromMarked(true); hexMenu->SetTargetForItems(fMemoryView); endianMenu->SetLabelFromMarked(true); endianMenu->SetTargetForItems(fMemoryView); textMenu->SetLabelFromMarked(true); textMenu->SetTargetForItems(fMemoryView); // default to 8-bit format w/ text display hexMenu->ItemAt(1)->SetMarked(true); textMenu->ItemAt(1)->SetMarked(true); if (targetEndian == EndianModeBigEndian) endianMenu->ItemAt(1)->SetMarked(true); else endianMenu->ItemAt(0)->SetMarked(true); fAddressInput->TextView()->MakeFocus(true); AddShortcut(B_LEFT_ARROW, B_COMMAND_KEY, new BMessage( MSG_NAVIGATE_PREVIOUS_BLOCK)); AddShortcut(B_RIGHT_ARROW, B_COMMAND_KEY, new BMessage( MSG_NAVIGATE_NEXT_BLOCK)); }
bool TBeMenu::AddStandardBeMenuItems() { bool dragging = false; if (fBarView) dragging = fBarView->Dragging(); BMenuItem* item = new BMenuItem( #ifdef ANTARES_DISTRO_COMPATIBILITY_OFFICIAL "About Antares" #else "About this system" #endif B_UTF8_ELLIPSIS, new BMessage(kShowSplash)); item->SetEnabled(!dragging); AddItem(item); #ifdef SHOW_RECENT_FIND_ITEMS item = new BMenuItem(TrackerBuildRecentFindItemsMenu("Find"B_UTF8_ELLIPSIS), new BMessage(kFindButton)); #else item = new BMenuItem("Find"B_UTF8_ELLIPSIS, new BMessage(kFindButton)); #endif item->SetEnabled(!dragging); AddItem(item); item = new BMenuItem("Show replicants", new BMessage(kToggleDraggers)); item->SetEnabled(!dragging); item->SetMarked(BDragger::AreDraggersDrawn()); AddItem(item); #ifdef MOUNT_MENU_IN_DESKBAR DeskbarMountMenu* mountMenu = new DeskbarMountMenu("Mount"); mountMenu->SetEnabled(!dragging); AddItem(mountMenu); #endif item = new BMenuItem("Deskbar preferences" B_UTF8_ELLIPSIS, new BMessage(kConfigShow)); item->SetTarget(be_app); AddItem(item); AddSeparatorItem(); BMenu* shutdownMenu = new BMenu("Shutdown" B_UTF8_ELLIPSIS); item = new BMenuItem("Restart system", new BMessage(kRebootSystem)); item->SetEnabled(!dragging); shutdownMenu->AddItem(item); #ifdef APM_SUPPORT if (_kapm_control_(APM_CHECK_ENABLED) == B_OK) { item = new BMenuItem("Suspend", new BMessage(kSuspendSystem)); item->SetEnabled(!dragging); shutdownMenu->AddItem(item); } #endif item = new BMenuItem("Power off", new BMessage(kShutdownSystem)); item->SetEnabled(!dragging); shutdownMenu->AddItem(item); shutdownMenu->SetFont(be_plain_font); shutdownMenu->SetTargetForItems(be_app); BMessage* message = new BMessage(kShutdownSystem); message->AddBool("confirm", true); AddItem(new BMenuItem(shutdownMenu, message)); fAddState = kAddingRecents; return true; }
CharacterWindow::CharacterWindow() : BWindow(BRect(100, 100, 700, 550), "CharacterMap", B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_QUIT_ON_WINDOW_CLOSE | B_AUTO_UPDATE_SIZE_LIMITS) { BMessage settings; _LoadSettings(settings); BRect frame; if (settings.FindRect("window frame", &frame) == B_OK) { MoveTo(frame.LeftTop()); ResizeTo(frame.Width(), frame.Height()); } // create GUI SetLayout(new BGroupLayout(B_VERTICAL)); BMenuBar* menuBar = new BMenuBar("menu"); fFilterControl = new BTextControl("Filter:", NULL, NULL); fFilterControl->SetModificationMessage(new BMessage(kMsgFilterChanged)); BButton* clearButton = new BButton("clear", "Clear", new BMessage(kMsgClearFilter)); fUnicodeBlockView = new UnicodeBlockView("unicodeBlocks"); fUnicodeBlockView->SetSelectionMessage( new BMessage(kMsgUnicodeBlockSelected)); BScrollView* unicodeScroller = new BScrollView("unicodeScroller", fUnicodeBlockView, 0, false, true); fCharacterView = new CharacterView("characters"); fCharacterView->SetTarget(this, kMsgCharacterChanged); // TODO: have a context object shared by CharacterView/UnicodeBlockView bool show; if (settings.FindBool("show private blocks", &show) == B_OK) { fCharacterView->ShowPrivateBlocks(show); fUnicodeBlockView->ShowPrivateBlocks(show); } if (settings.FindBool("show contained blocks only", &show) == B_OK) { fCharacterView->ShowContainedBlocksOnly(show); fUnicodeBlockView->ShowPrivateBlocks(show); } const char* family; const char* style; if (settings.FindString("font family", &family) == B_OK && settings.FindString("font style", &style) == B_OK) { _SetFont(family, style); } int32 fontSize; if (settings.FindInt32("font size", &fontSize) == B_OK) { BFont font = fCharacterView->CharacterFont(); if (fontSize < kMinFontSize) fontSize = kMinFontSize; else if (fontSize > kMaxFontSize) fontSize = kMaxFontSize; font.SetSize(fontSize); fCharacterView->SetCharacterFont(font); } else fontSize = (int32)fCharacterView->CharacterFont().Size(); BScrollView* characterScroller = new BScrollView("characterScroller", fCharacterView, 0, false, true); fFontSizeSlider = new FontSizeSlider("fontSizeSlider", "Font size:", new BMessage(kMsgFontSizeChanged), kMinFontSize, kMaxFontSize); fFontSizeSlider->SetValue(fontSize); fCodeView = new BStringView("code", "-"); fCodeView->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, fCodeView->PreferredSize().Height())); AddChild(BGroupLayoutBuilder(B_VERTICAL) .Add(menuBar) .Add(BGroupLayoutBuilder(B_HORIZONTAL, 10)//BSplitLayoutBuilder() .Add(BGroupLayoutBuilder(B_VERTICAL, 10) .Add(BGroupLayoutBuilder(B_HORIZONTAL, 10) .Add(fFilterControl) .Add(clearButton)) .Add(unicodeScroller)) .Add(BGroupLayoutBuilder(B_VERTICAL, 10) .Add(characterScroller) .Add(fFontSizeSlider) .Add(fCodeView)) .SetInsets(10, 10, 10, 10))); // Add menu // "File" menu BMenu* menu = new BMenu("File"); BMenuItem* item; menu->AddItem(item = new BMenuItem("About CharacterMap" B_UTF8_ELLIPSIS, new BMessage(B_ABOUT_REQUESTED))); menu->AddSeparatorItem(); menu->AddItem(new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED), 'Q')); menu->SetTargetForItems(this); item->SetTarget(be_app); menuBar->AddItem(menu); menu = new BMenu("View"); menu->AddItem(item = new BMenuItem("Show private blocks", new BMessage(kMsgPrivateBlocks))); item->SetMarked(fCharacterView->IsShowingPrivateBlocks()); // TODO: this feature is not yet supported by Haiku! #if 0 menu->AddItem(item = new BMenuItem("Only show blocks contained in font", new BMessage(kMsgContainedBlocks))); item->SetMarked(fCharacterView->IsShowingContainedBlocksOnly()); #endif menuBar->AddItem(menu); menuBar->AddItem(_CreateFontMenu()); AddCommonFilter(new EscapeMessageFilter(kMsgClearFilter)); AddCommonFilter(new RedirectUpAndDownFilter(fUnicodeBlockView)); // TODO: why is this needed? fUnicodeBlockView->SetTarget(this); fFilterControl->MakeFocus(); }
ActivityWindow::ActivityWindow() : BWindow(BRect(100, 100, 500, 350), B_TRANSLATE_SYSTEM_NAME("ActivityMonitor"), B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_QUIT_ON_WINDOW_CLOSE) { BMessage settings; _LoadSettings(settings); BRect frame; if (settings.FindRect("window frame", &frame) == B_OK) { MoveTo(frame.LeftTop()); ResizeTo(frame.Width(), frame.Height()); } #ifdef __HAIKU__ BGroupLayout* layout = new BGroupLayout(B_VERTICAL, 0); SetLayout(layout); // create GUI BMenuBar* menuBar = new BMenuBar("menu"); layout->AddView(menuBar); fLayout = new BGroupLayout(B_VERTICAL); float inset = ceilf(be_plain_font->Size() * 0.7); fLayout->SetInsets(inset, inset, inset, inset); fLayout->SetSpacing(inset); BView* top = new BView("top", 0, fLayout); top->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); layout->AddView(top); BMessage viewState; int32 count = 0; for (int32 i = 0; settings.FindMessage("activity view", i, &viewState) == B_OK; i++) { ActivityView* view = new ActivityView("ActivityMonitor", &viewState); fLayout->AddItem(view->CreateHistoryLayoutItem()); fLayout->AddItem(view->CreateLegendLayoutItem()); count++; } if (count == 0) { // Add default views (memory & CPU usage) _AddDefaultView(); _AddDefaultView(); } #else // !__HAIKU__ BView *layout = new BView(Bounds(), "topmost", B_FOLLOW_NONE, 0); AddChild(layout); // create GUI BRect mbRect(Bounds()); mbRect.bottom = 10; BMenuBar* menuBar = new BMenuBar(mbRect, "menu"); layout->AddChild(menuBar); BRect topRect(Bounds()); topRect.top = menuBar->Bounds().bottom + 1; BView* top = new BView(topRect, "top", B_FOLLOW_ALL, 0); top->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); layout->AddChild(top); BMessage viewState; int32 count = 0; ActivityView *aview; BRect rect; for (int32 i = 0; settings.FindMessage("activity view", i, &viewState) == B_OK; i++) { aview = new ActivityView("ActivityMonitor", &viewState); if (!rect.IsValid()) rect = aview->Bounds(); else rect.OffsetBySelf(0.0, aview->Bounds().Height()); top->AddChild(aview); count++; } if (count == 0) top->AddChild(new ActivityView("ActivityMonitor", NULL)); #endif // add menu // "File" menu BMenu* menu = new BMenu(B_TRANSLATE("File")); menu->AddItem(new BMenuItem(B_TRANSLATE("Add graph"), new BMessage(kMsgAddView))); menu->AddSeparatorItem(); menu->AddItem(new BMenuItem(B_TRANSLATE("Quit"), new BMessage(B_QUIT_REQUESTED), 'Q')); menu->SetTargetForItems(this); menuBar->AddItem(menu); // "Settings" menu menu = new BMenu(B_TRANSLATE("Settings")); menu->AddItem(new BMenuItem(B_TRANSLATE("Settings" B_UTF8_ELLIPSIS), new BMessage(kMsgShowSettings))); menu->SetTargetForItems(this); menuBar->AddItem(menu); }
void InspectorWindow::_Init() { BScrollView* scrollView; BMenu* hexMenu = new BMenu("Hex Mode"); BMessage* message = new BMessage(MSG_SET_HEX_MODE); message->AddInt32("mode", HexModeNone); BMenuItem* item = new BMenuItem("<None>", message, '0'); hexMenu->AddItem(item); message = new BMessage(*message); message->ReplaceInt32("mode", HexMode8BitInt); item = new BMenuItem("8-bit integer", message, '1'); hexMenu->AddItem(item); message = new BMessage(*message); message->ReplaceInt32("mode", HexMode16BitInt); item = new BMenuItem("16-bit integer", message, '2'); hexMenu->AddItem(item); message = new BMessage(*message); message->ReplaceInt32("mode", HexMode32BitInt); item = new BMenuItem("32-bit integer", message, '3'); hexMenu->AddItem(item); message = new BMessage(*message); message->ReplaceInt32("mode", HexMode64BitInt); item = new BMenuItem("64-bit integer", message, '4'); hexMenu->AddItem(item); BMenu* endianMenu = new BMenu("Endian Mode"); message = new BMessage(MSG_SET_ENDIAN_MODE); message->AddInt32("mode", EndianModeLittleEndian); item = new BMenuItem("Little Endian", message, 'L'); endianMenu->AddItem(item); message = new BMessage(*message); message->ReplaceInt32("mode", EndianModeBigEndian); item = new BMenuItem("Big Endian", message, 'B'); endianMenu->AddItem(item); BMenu* textMenu = new BMenu("Text Mode"); message = new BMessage(MSG_SET_TEXT_MODE); message->AddInt32("mode", TextModeNone); item = new BMenuItem("<None>", message, 'N'); textMenu->AddItem(item); message = new BMessage(*message); message->ReplaceInt32("mode", TextModeASCII); item = new BMenuItem("ASCII", message, 'A'); textMenu->AddItem(item); BLayoutBuilder::Group<>(this, B_VERTICAL) .SetInsets(4.0f, 4.0f, 4.0f, 4.0f) .AddGroup(B_HORIZONTAL, 4.0f) .Add(fAddressInput = new BTextControl("addrInput", "Target Address:", "", new BMessage(MSG_INSPECT_ADDRESS))) .Add(fPreviousBlockButton = new BButton("navPrevious", "<", new BMessage(MSG_NAVIGATE_PREVIOUS_BLOCK))) .Add(fNextBlockButton = new BButton("navNext", ">", new BMessage(MSG_NAVIGATE_NEXT_BLOCK))) .End() .AddGroup(B_HORIZONTAL, 4.0f) .Add(fHexMode = new BMenuField("hexMode", "Hex Mode:", hexMenu)) .AddGlue() .Add(fEndianMode = new BMenuField("endianMode", "Endian Mode:", endianMenu)) .AddGlue() .Add(fTextMode = new BMenuField("viewMode", "Text Mode:", textMenu)) .End() .Add(scrollView = new BScrollView("memory scroll", NULL, 0, false, true), 3.0f) .End(); fHexMode->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); fEndianMode->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); fTextMode->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); int32 targetEndian = fTeam->GetArchitecture()->IsBigEndian() ? EndianModeBigEndian : EndianModeLittleEndian; scrollView->SetTarget(fMemoryView = MemoryView::Create(fTeam)); fAddressInput->SetTarget(this); fPreviousBlockButton->SetTarget(this); fNextBlockButton->SetTarget(this); fPreviousBlockButton->SetEnabled(false); fNextBlockButton->SetEnabled(false); hexMenu->SetLabelFromMarked(true); hexMenu->SetTargetForItems(fMemoryView); endianMenu->SetLabelFromMarked(true); endianMenu->SetTargetForItems(fMemoryView); textMenu->SetLabelFromMarked(true); textMenu->SetTargetForItems(fMemoryView); // default to 8-bit format w/ text display hexMenu->ItemAt(1)->SetMarked(true); textMenu->ItemAt(1)->SetMarked(true); if (targetEndian == EndianModeBigEndian) endianMenu->ItemAt(1)->SetMarked(true); else endianMenu->ItemAt(0)->SetMarked(true); fAddressInput->TextView()->MakeFocus(true); }
SudokuWindow::SudokuWindow() : BWindow(BRect(100, 100, 500, 520), B_TRANSLATE_SYSTEM_NAME("Sudoku"), B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_QUIT_ON_WINDOW_CLOSE), fGenerator(NULL), fStoredState(NULL), fExportFormat(kExportAsText) { BMessage settings; _LoadSettings(settings); BRect frame; if (settings.FindRect("window frame", &frame) == B_OK) { MoveTo(frame.LeftTop()); ResizeTo(frame.Width(), frame.Height()); frame.OffsetTo(B_ORIGIN); } else frame = Bounds(); if (settings.HasMessage("stored state")) { fStoredState = new BMessage; if (settings.FindMessage("stored state", fStoredState) != B_OK) { delete fStoredState; fStoredState = NULL; } } int32 level = 0; settings.FindInt32("level", &level); // create GUI BMenuBar* menuBar = new BMenuBar(Bounds(), "menu"); AddChild(menuBar); frame.top = menuBar->Frame().bottom; BView* top = new BView(frame, NULL, B_FOLLOW_ALL, B_WILL_DRAW); top->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); AddChild(top); fSudokuView = new SudokuView( top->Bounds().InsetByCopy(10, 10).OffsetToSelf(0, 0), "sudoku view", settings, B_FOLLOW_NONE); CenteredViewContainer* container = new CenteredViewContainer(fSudokuView, top->Bounds().InsetByCopy(10, 10), "center", B_FOLLOW_ALL); container->SetHighColor(top->ViewColor()); top->AddChild(container); // add menu // "File" menu BMenu* menu = new BMenu(B_TRANSLATE("File")); fNewMenu = new BMenu(B_TRANSLATE("New")); menu->AddItem(new BMenuItem(fNewMenu, new BMessage(kMsgGenerateSudoku))); fNewMenu->Superitem()->SetShortcut('N', B_COMMAND_KEY); BMessage* message = new BMessage(kMsgGenerateSudoku); message->AddInt32("level", kEasyLevel); fNewMenu->AddItem(new BMenuItem(B_TRANSLATE("Easy"), message)); message = new BMessage(kMsgGenerateSudoku); message->AddInt32("level", kAdvancedLevel); fNewMenu->AddItem(new BMenuItem(B_TRANSLATE("Advanced"), message)); message = new BMessage(kMsgGenerateSudoku); message->AddInt32("level", kHardLevel); fNewMenu->AddItem(new BMenuItem(B_TRANSLATE("Hard"), message)); fNewMenu->AddSeparatorItem(); fNewMenu->AddItem(new BMenuItem(B_TRANSLATE("Blank"), new BMessage(kMsgNewBlank))); menu->AddItem(new BMenuItem(B_TRANSLATE("Start again"), new BMessage(kMsgStartAgain))); menu->AddSeparatorItem(); BMenu* recentsMenu = BRecentFilesList::NewFileListMenu( B_TRANSLATE("Open file" B_UTF8_ELLIPSIS), NULL, NULL, this, 10, false, NULL, kSignature); BMenuItem *item; menu->AddItem(item = new BMenuItem(recentsMenu, new BMessage(kMsgOpenFilePanel))); item->SetShortcut('O', B_COMMAND_KEY); menu->AddSeparatorItem(); BMenu* subMenu = new BMenu(B_TRANSLATE("Export as" B_UTF8_ELLIPSIS)); message = new BMessage(kMsgExportAs); message->AddInt32("as", kExportAsText); subMenu->AddItem(new BMenuItem(B_TRANSLATE("Text"), message)); message= new BMessage(kMsgExportAs); message->AddInt32("as", kExportAsHTML); subMenu->AddItem(new BMenuItem(B_TRANSLATE("HTML"), message)); menu->AddItem(subMenu); menu->AddItem(item = new BMenuItem(B_TRANSLATE("Copy"), new BMessage(B_COPY), 'C')); menu->AddSeparatorItem(); menu->AddItem(new BMenuItem(B_TRANSLATE("Quit"), new BMessage(B_QUIT_REQUESTED), 'Q')); menu->SetTargetForItems(this); item->SetTarget(be_app); menuBar->AddItem(menu); // "View" menu menu = new BMenu(B_TRANSLATE("View")); menu->AddItem(item = new BMenuItem(B_TRANSLATE("Mark invalid values"), new BMessage(kMsgMarkInvalid))); if ((fSudokuView->HintFlags() & kMarkInvalid) != 0) item->SetMarked(true); menu->AddItem(item = new BMenuItem(B_TRANSLATE("Mark valid hints"), new BMessage(kMsgMarkValidHints))); if ((fSudokuView->HintFlags() & kMarkValidHints) != 0) item->SetMarked(true); menu->SetTargetForItems(this); menuBar->AddItem(menu); // "Help" menu menu = new BMenu(B_TRANSLATE("Help")); menu->AddItem(fUndoItem = new BMenuItem(B_TRANSLATE("Undo"), new BMessage(B_UNDO), 'Z')); fUndoItem->SetEnabled(false); menu->AddItem(fRedoItem = new BMenuItem(B_TRANSLATE("Redo"), new BMessage(B_REDO), 'Z', B_SHIFT_KEY)); fRedoItem->SetEnabled(false); menu->AddSeparatorItem(); menu->AddItem(new BMenuItem(B_TRANSLATE("Snapshot current"), new BMessage(kMsgStoreState))); menu->AddItem(fRestoreStateItem = new BMenuItem( B_TRANSLATE("Restore snapshot"), new BMessage(kMsgRestoreState))); fRestoreStateItem->SetEnabled(fStoredState != NULL); menu->AddSeparatorItem(); menu->AddItem(new BMenuItem(B_TRANSLATE("Set all hints"), new BMessage(kMsgSetAllHints))); menu->AddSeparatorItem(); menu->AddItem(new BMenuItem(B_TRANSLATE("Solve"), new BMessage(kMsgSolveSudoku))); menu->AddItem(new BMenuItem(B_TRANSLATE("Solve single field"), new BMessage(kMsgSolveSingle))); menu->SetTargetForItems(fSudokuView); menuBar->AddItem(menu); fOpenPanel = new BFilePanel(B_OPEN_PANEL); fOpenPanel->SetTarget(this); fSavePanel = new BFilePanel(B_SAVE_PANEL); fSavePanel->SetTarget(this); _SetLevel(level); fSudokuView->StartWatching(this, kUndoRedoChanged); // we like to know whenever the undo/redo state changes fProgressWindow = new ProgressWindow(this, new BMessage(kMsgAbortSudokuGenerator)); if (fSudokuView->Field()->IsEmpty()) PostMessage(kMsgGenerateSudoku); }
void FontSelectionView::UpdateFontsMenu() { int32 numFamilies = count_font_families(); fFontsMenu->RemoveItems(0, fFontsMenu->CountItems(), true); BFont font; fFontsMenu->GetFont(&font); font_family currentFamily; font_style currentStyle; fCurrentFont.GetFamilyAndStyle(¤tFamily, ¤tStyle); for (int32 i = 0; i < numFamilies; i++) { font_family family; uint32 flags; if (get_font_family(i, &family, &flags) != B_OK) continue; // if we're setting the fixed font, we only want to show fixed and // full-and-half-fixed fonts if (strcmp(Name(), "fixed") == 0 && (flags & (B_IS_FIXED | B_PRIVATE_FONT_IS_FULL_AND_HALF_FIXED)) == 0) { continue; } float width = font.StringWidth(family); if (width > fMaxFontNameWidth) fMaxFontNameWidth = width; BMenu* stylesMenu = new BMenu(family); stylesMenu->SetRadioMode(true); stylesMenu->SetFont(&font); BMessage* message = new BMessage(kMsgSetFamily); message->AddString("family", family); message->AddString("name", Name()); BMenuItem* familyItem = new BMenuItem(stylesMenu, message); fFontsMenu->AddItem(familyItem); int32 numStyles = count_font_styles(family); for (int32 j = 0; j < numStyles; j++) { font_style style; if (get_font_style(family, j, &style, &flags) != B_OK) continue; message = new BMessage(kMsgSetStyle); message->AddString("family", (char*)family); message->AddString("style", (char*)style); message->AddString("name", Name()); BMenuItem* item = new BMenuItem(style, message); if (!strcmp(style, currentStyle) && !strcmp(family, currentFamily)) { item->SetMarked(true); familyItem->SetMarked(true); } stylesMenu->AddItem(item); } stylesMenu->SetTargetForItems(fMessageTarget); } fFontsMenu->SetTargetForItems(fMessageTarget); }
void TeamsWindow::_Init() { BMessage settings; _LoadSettings(settings); BRect frame; if (settings.FindRect("teams window frame", &frame) == B_OK) { MoveTo(frame.LeftTop()); ResizeTo(frame.Width(), frame.Height()); } BMenu* connectionMenu = new BMenu("Connection"); ObjectDeleter<BMenu> menuDeleter(connectionMenu); connectionMenu->SetLabelFromMarked(true); TargetHostInterfaceRoster* roster = TargetHostInterfaceRoster::Default(); for (int32 i = 0; i < roster->CountActiveInterfaces(); i++) { TargetHostInterface* interface = roster->ActiveInterfaceAt(i); BMenuItem* item = new BMenuItem(interface->GetTargetHost()->Name(), new BMessage(MSG_SWITCH_TARGET_CONNECTION)); if (item->Message()->AddPointer("interface", interface) != B_OK) { delete item; throw std::bad_alloc(); } if (interface->IsLocal()) { item->SetMarked(true); fTargetHostInterface = interface; } connectionMenu->AddItem(item); } BGroupLayout* connectionLayout = NULL; BLayoutBuilder::Group<>(this, B_VERTICAL) .AddGroup(B_HORIZONTAL) .SetInsets(B_USE_DEFAULT_SPACING) .GetLayout(&connectionLayout) .Add(fConnectionField = new BMenuField("Connected to:", connectionMenu)) .AddGlue() .Add(fCreateConnectionButton = new BButton("Create new connection" B_UTF8_ELLIPSIS, new BMessage( MSG_SHOW_CONNECTION_CONFIG_WINDOW))) .End() .Add(fTeamsListView = new TeamsListView("TeamsList")) .SetInsets(1.0f, 1.0f, 1.0f, 5.0f) .AddGroup(B_HORIZONTAL) .SetInsets(B_USE_DEFAULT_SPACING) .Add(fAttachTeamButton = new BButton("Attach", new BMessage( MSG_DEBUG_THIS_TEAM))) .AddGlue() .Add(fCreateTeamButton = new BButton("Start new team" B_UTF8_ELLIPSIS, new BMessage(MSG_SHOW_START_TEAM_WINDOW))) .Add(fLoadCoreButton = new BButton("Load core" B_UTF8_ELLIPSIS, new BMessage(MSG_LOAD_CORE_TEAM))) .End() .End(); connectionLayout->SetVisible(false); menuDeleter.Detach(); AddListener(fTeamsListView); connectionMenu->SetTargetForItems(this); fTeamsListView->SetInvocationMessage(new BMessage(MSG_DEBUG_THIS_TEAM)); fTeamsListView->SetSelectionMessage(new BMessage( MSG_TEAM_SELECTION_CHANGED)); fAttachTeamButton->SetEnabled(false); fCreateTeamButton->SetTarget(this); fLoadCoreButton->SetTarget(this); fCreateConnectionButton->SetTarget(be_app); _NotifySelectedInterfaceChanged(fTargetHostInterface); }
CharacterWindow::CharacterWindow() : BWindow(BRect(100, 100, 700, 550), B_TRANSLATE_SYSTEM_NAME("CharacterMap"), B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_QUIT_ON_WINDOW_CLOSE | B_AUTO_UPDATE_SIZE_LIMITS) { BMessage settings; _LoadSettings(settings); BRect frame; if (settings.FindRect("window frame", &frame) == B_OK) { MoveTo(frame.LeftTop()); ResizeTo(frame.Width(), frame.Height()); } else { float scaling = be_plain_font->Size() / 12.0f; ResizeTo(Frame().Width() * scaling, Frame().Height() * scaling); CenterOnScreen(); } // create GUI BMenuBar* menuBar = new BMenuBar("menu"); fFilterControl = new BTextControl(B_TRANSLATE("Filter:"), NULL, NULL); fFilterControl->SetModificationMessage(new BMessage(kMsgFilterChanged)); BButton* clearButton = new BButton("clear", B_TRANSLATE("Clear"), new BMessage(kMsgClearFilter)); fUnicodeBlockView = new UnicodeBlockView("unicodeBlocks"); fUnicodeBlockView->SetSelectionMessage( new BMessage(kMsgUnicodeBlockSelected)); BScrollView* unicodeScroller = new BScrollView("unicodeScroller", fUnicodeBlockView, 0, false, true); fCharacterView = new CharacterView("characters"); fCharacterView->SetTarget(this, kMsgCharacterChanged); fGlyphView = new BStringView("glyph", ""); fGlyphView->SetExplicitMaxSize(BSize(B_SIZE_UNSET, fGlyphView->PreferredSize().Height())); // TODO: have a context object shared by CharacterView/UnicodeBlockView bool show; if (settings.FindBool("show private blocks", &show) == B_OK) { fCharacterView->ShowPrivateBlocks(show); fUnicodeBlockView->ShowPrivateBlocks(show); } if (settings.FindBool("show contained blocks only", &show) == B_OK) { fCharacterView->ShowContainedBlocksOnly(show); fUnicodeBlockView->ShowPrivateBlocks(show); } const char* family; const char* style; BString displayName; if (settings.FindString("font family", &family) == B_OK && settings.FindString("font style", &style) == B_OK) { _SetFont(family, style); displayName << family << " " << style; } else { font_family currentFontFamily; font_style currentFontStyle; fCharacterView->CharacterFont().GetFamilyAndStyle(¤tFontFamily, ¤tFontStyle); displayName << currentFontFamily << " " << currentFontStyle; } int32 fontSize; if (settings.FindInt32("font size", &fontSize) == B_OK) { BFont font = fCharacterView->CharacterFont(); if (fontSize < kMinFontSize) fontSize = kMinFontSize; else if (fontSize > kMaxFontSize) fontSize = kMaxFontSize; font.SetSize(fontSize); fCharacterView->SetCharacterFont(font); } else fontSize = (int32)fCharacterView->CharacterFont().Size(); BScrollView* characterScroller = new BScrollView("characterScroller", fCharacterView, 0, false, true); fFontSizeSlider = new FontSizeSlider("fontSizeSlider", displayName, new BMessage(kMsgFontSizeChanged), kMinFontSize, kMaxFontSize); fFontSizeSlider->SetValue(fontSize); fCodeView = new BStringView("code", "-"); fCodeView->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, fCodeView->PreferredSize().Height())); // Set minimum width for character pane to prevent UI // from jumping when longer code strings are displayed. // use 'w' character for sizing as it's likely the widest // character for a Latin font. 40 characters is a little // wider than needed so hopefully this covers other // non-Latin fonts that may be wider. BFont viewFont; fCodeView->GetFont(&viewFont); fCharacterView->SetExplicitMinSize(BSize(viewFont.StringWidth("w") * 40, B_SIZE_UNSET)); BLayoutBuilder::Group<>(this, B_VERTICAL, 0) .Add(menuBar) .AddGroup(B_HORIZONTAL) .SetInsets(B_USE_WINDOW_SPACING) .AddGroup(B_VERTICAL) .AddGroup(B_HORIZONTAL) .Add(fFilterControl) .Add(clearButton) .End() .Add(unicodeScroller) .End() .AddGroup(B_VERTICAL) .Add(characterScroller) .Add(fFontSizeSlider) .AddGroup(B_HORIZONTAL) .Add(fGlyphView) .Add(fCodeView); // Add menu // "File" menu BMenu* menu = new BMenu(B_TRANSLATE("File")); BMenuItem* item; menu->AddItem(new BMenuItem(B_TRANSLATE("Quit"), new BMessage(B_QUIT_REQUESTED), 'Q')); menu->SetTargetForItems(this); menuBar->AddItem(menu); menu = new BMenu(B_TRANSLATE("View")); menu->AddItem(item = new BMenuItem(B_TRANSLATE("Show private blocks"), new BMessage(kMsgPrivateBlocks))); item->SetMarked(fCharacterView->IsShowingPrivateBlocks()); // TODO: this feature is not yet supported by Haiku! #if 0 menu->AddItem(item = new BMenuItem("Only show blocks contained in font", new BMessage(kMsgContainedBlocks))); item->SetMarked(fCharacterView->IsShowingContainedBlocksOnly()); #endif menuBar->AddItem(menu); fFontMenu = _CreateFontMenu(); menuBar->AddItem(fFontMenu); AddCommonFilter(new EscapeMessageFilter(kMsgClearFilter)); AddCommonFilter(new RedirectUpAndDownFilter(fUnicodeBlockView)); // TODO: why is this needed? fUnicodeBlockView->SetTarget(this); fFilterControl->MakeFocus(); fUnicodeBlockView->SelectBlockForCharacter(0); }
void ActivityView::MouseDown(BPoint where) { int32 buttons = B_SECONDARY_MOUSE_BUTTON; if (Looper() != NULL && Looper()->CurrentMessage() != NULL) Looper()->CurrentMessage()->FindInt32("buttons", &buttons); if (buttons == B_PRIMARY_MOUSE_BUTTON) { fZoomPoint = where; fOriginalResolution = fDrawResolution; fZooming = true; SetMouseEventMask(B_POINTER_EVENTS); return; } BPopUpMenu *menu = new BPopUpMenu(B_EMPTY_STRING, false, false); menu->SetFont(be_plain_font); BMenu* additionalMenu = new BMenu(B_TRANSLATE("Additional items")); additionalMenu->SetFont(be_plain_font); SystemInfo info; BMenuItem* item; for (int32 i = 0; i < DataSource::CountSources(); i++) { const DataSource* source = DataSource::SourceAt(i); if (source->MultiCPUOnly() && info.CPUCount() == 1) continue; BMessage* message = new BMessage(kMsgToggleDataSource); message->AddInt32("index", i); item = new BMenuItem(source->Name(), message); if (FindDataSource(source)) item->SetMarked(true); if (source->Primary()) menu->AddItem(item); else additionalMenu->AddItem(item); } menu->AddItem(new BMenuItem(additionalMenu)); menu->AddSeparatorItem(); menu->AddItem(item = new BMenuItem(B_TRANSLATE("Show legend"), new BMessage(kMsgToggleLegend))); item->SetMarked(fShowLegend); menu->SetTargetForItems(this); additionalMenu->SetTargetForItems(this); ActivityWindow* window = dynamic_cast<ActivityWindow*>(Window()); if (window != NULL && window->ActivityViewCount() > 1) { menu->AddSeparatorItem(); BMessage* message = new BMessage(kMsgRemoveView); message->AddPointer("view", this); menu->AddItem(item = new BMenuItem(B_TRANSLATE("Remove graph"), message)); item->SetTarget(window); } ConvertToScreen(&where); menu->Go(where, true, false, true); }
status_t InterfaceHardwareView::Update() { // Populate fields with current settings if (fSettings->HasLink()) { if (fSettings->IsWireless()) { BString network = fSettings->WirelessNetwork(); network.Prepend(" ("); network.Prepend(B_TRANSLATE("connected")); network.Append(")"); fStatusField->SetText(network.String()); } else { fStatusField->SetText(B_TRANSLATE("connected")); } } else fStatusField->SetText(B_TRANSLATE("disconnected")); fMacAddressField->SetText(fSettings->HardwareAddress()); // TODO : Find how to get link speed fLinkSpeedField->SetText("100 Mb/s"); // Update Link stats ifreq_stats stats; char buffer[100]; fSettings->Stats(&stats); string_for_size(stats.send.bytes, buffer, sizeof(buffer)); fLinkTxField->SetText(buffer); string_for_size(stats.receive.bytes, buffer, sizeof(buffer)); fLinkRxField->SetText(buffer); // TODO move the wireless info to a separate tab. We should have a // BListView of available networks, rather than a menu, to make them more // readable and easier to browse and select. if (fNetworkMenuField->IsHidden(fNetworkMenuField) && fSettings->IsWireless()) { fNetworkMenuField->Show(); } else if (!fNetworkMenuField->IsHidden(fNetworkMenuField) && !fSettings->IsWireless()) { fNetworkMenuField->Hide(); } if (fSettings->IsWireless()) { // Rebuild network menu BMenu* menu = fNetworkMenuField->Menu(); menu->RemoveItems(0, menu->CountItems(), true); std::set<BNetworkAddress> associated; BNetworkAddress address; uint32 cookie = 0; while (fSettings->GetNextAssociatedNetwork(cookie, address) == B_OK) associated.insert(address); wireless_network network; int32 count = 0; cookie = 0; while (fSettings->GetNextNetwork(cookie, network) == B_OK) { BMessage* message = new BMessage(kMsgNetwork); message->AddString("device", fSettings->Name()); message->AddString("name", network.name); BMenuItem* item = new WirelessNetworkMenuItem(network.name, network.signal_strength, network.authentication_mode, message); if (associated.find(network.address) != associated.end()) item->SetMarked(true); menu->AddItem(item); count++; } if (count == 0) { BMenuItem* item = new BMenuItem( B_TRANSLATE("<no wireless networks found>"), NULL); item->SetEnabled(false); menu->AddItem(item); } else { BMenuItem* item = new BMenuItem( B_TRANSLATE("Choose automatically"), NULL); if (menu->FindMarked() == NULL) item->SetMarked(true); menu->AddItem(item, 0); menu->AddItem(new BSeparatorItem(), 1); } menu->SetTargetForItems(this); } fRenegotiate->SetEnabled(!fSettings->IsDisabled()); fOnOff->SetLabel(fSettings->IsDisabled() ? "Enable" : "Disable"); return B_OK; }
void TextDocumentTest::_UpdateFontmenus(bool setInitialfont) { BFont font = BFont(); BMenu* stylemenu = NULL; font_family fontFamilyName, currentFamily; font_style fontStyleName, currentStyle; //GetFont(&font); font.GetFamilyAndStyle(¤tFamily, ¤tStyle); const int32 fontfamilies = count_font_families(); fFontFamilyMenu->RemoveItems(0, fFontFamilyMenu->CountItems(), true); for (int32 i = 0; i < fontfamilies; i++) { if (get_font_family(i, &fontFamilyName) == B_OK) { stylemenu = new BPopUpMenu(fontFamilyName); stylemenu->SetLabelFromMarked(false); const int32 styles = count_font_styles(fontFamilyName); //TODO change msg.. to a suitable msg BMessage* familyMsg = new BMessage('todo'); familyMsg->AddString("_family", fontFamilyName); BMenuItem* familyItem = new BMenuItem(stylemenu, familyMsg); fFontFamilyMenu->AddItem(familyItem); for (int32 j = 0; j < styles; j++) { if (get_font_style(fontFamilyName, j, &fontStyleName) == B_OK) { //TODO change msg.. to a suitable msg BMessage* fontMsg = new BMessage('todo'); fontMsg->AddString("_family", fontFamilyName); fontMsg->AddString("_style", fontStyleName); BMenuItem* styleItem = new BMenuItem(fontStyleName, fontMsg); styleItem->SetMarked(false); // setInitialfont is used when we attach the FontField if (!strcmp(fontStyleName, currentStyle) && !strcmp(fontFamilyName, currentFamily) && setInitialfont) { styleItem->SetMarked(true); familyItem->SetMarked(true); BString string; string << currentFamily << " " << currentStyle; if (fFontMenuField) fFontMenuField->MenuItem()->SetLabel(string.String()); } stylemenu->AddItem(styleItem); } } stylemenu->SetRadioMode(true); stylemenu->SetTargetForItems(this); } } fFontFamilyMenu->SetLabelFromMarked(false); fFontFamilyMenu->SetTargetForItems(this); }
void DevicesView::CreateLayout() { BMenuBar* menuBar = new BMenuBar("menu"); BMenu* menu = new BMenu(B_TRANSLATE("Devices")); BMenuItem* item; menu->AddItem(new BMenuItem(B_TRANSLATE("Refresh devices"), new BMessage(kMsgRefresh), 'R')); menu->AddItem(item = new BMenuItem(B_TRANSLATE("Report compatibility"), new BMessage(kMsgReportCompatibility))); item->SetEnabled(false); menu->AddItem(item = new BMenuItem(B_TRANSLATE( "Generate system information"), new BMessage(kMsgGenerateSysInfo))); item->SetEnabled(false); menu->AddSeparatorItem(); menu->AddItem(new BMenuItem(B_TRANSLATE("Quit"), new BMessage(B_QUIT_REQUESTED), 'Q')); menu->SetTargetForItems(this); item->SetTarget(be_app); menuBar->AddItem(menu); fDevicesOutline = new BOutlineListView("devices_list"); fDevicesOutline->SetTarget(this); fDevicesOutline->SetSelectionMessage(new BMessage(kMsgSelectionChanged)); BScrollView *scrollView = new BScrollView("devicesScrollView", fDevicesOutline, B_WILL_DRAW | B_FRAME_EVENTS, true, true); // Horizontal scrollbar doesn't behave properly like the vertical // scrollbar... If you make the view bigger (exposing a larger percentage // of the view), it does not adjust the width of the scroll 'dragger' // why? Bug? In scrollview or in outlinelistview? BPopUpMenu* orderByPopupMenu = new BPopUpMenu("orderByMenu"); BMenuItem* byCategory = new BMenuItem(B_TRANSLATE("Category"), new BMessage(kMsgOrderCategory)); BMenuItem* byConnection = new BMenuItem(B_TRANSLATE("Connection"), new BMessage(kMsgOrderConnection)); byCategory->SetMarked(true); fOrderBy = byCategory->IsMarked() ? ORDER_BY_CATEGORY : ORDER_BY_CONNECTION; orderByPopupMenu->AddItem(byCategory); orderByPopupMenu->AddItem(byConnection); fOrderByMenu = new BMenuField(B_TRANSLATE("Order by:"), orderByPopupMenu); fTabView = new BTabView("fTabView", B_WIDTH_FROM_LABEL); fBasicTab = new BTab(); fBasicView = new PropertyListPlain("basicView"); fTabView->AddTab(fBasicView, fBasicTab); fBasicTab->SetLabel(B_TRANSLATE("Basic information")); fDeviceTypeTab = new BTab(); fBusView = new PropertyListPlain("busView"); fTabView->AddTab(fBusView, fDeviceTypeTab); fDeviceTypeTab->SetLabel(B_TRANSLATE("Bus")); fDetailedTab = new BTab(); fAttributesView = new PropertyList("attributesView"); fTabView->AddTab(fAttributesView, fDetailedTab); fDetailedTab->SetLabel(B_TRANSLATE("Detailed")); BLayoutBuilder::Group<>(this, B_VERTICAL, 0) .Add(menuBar) .AddSplit(B_HORIZONTAL) .SetInsets(B_USE_ITEM_INSETS) .AddGroup(B_VERTICAL) .Add(fOrderByMenu, 1) .Add(scrollView, 2) .End() .Add(fTabView, 2); }
/** * gens_menu_parse(): Parse the menu structs. * @param menu First item of the array of menu structs to parse. * @param container Container to add the menu items to. */ void gens_menu_parse(const GensMenuItem_t* menu, BMenuBar *menuBar, BWindow* win) { // TODO: Parse the menu struct. BMenuItem* item; // File menu BMenu *m = new BMenu("File"); m->AddItem(item = new BMenuItem("Open ROM", NULL)); item->SetShortcut('O', B_COMMAND_KEY); m->AddItem(item = new BMenuItem("Boot CD", NULL)); item->SetShortcut('B', B_COMMAND_KEY); m->AddItem(new BMenuItem("Netplay", NULL)); BMenu *subMenu = new BMenu("ROM History"); subMenu->AddItem(new BMenuItem("DUMMY HISTORY LINE", NULL)); m->AddItem(subMenu); m->AddItem(new BMenuItem("Close ROM", NULL)); m->AddSeparatorItem(); m->AddItem(new BMenuItem("Game Genie", NULL)); m->AddSeparatorItem(); m->AddItem(new BMenuItem("Load State...", NULL)); m->AddItem(new BMenuItem("Save State as...", NULL)); m->AddItem(new BMenuItem("Quick Load", NULL)); m->AddItem(new BMenuItem("Quick Save", NULL)); subMenu = new BMenu("Change State"); subMenu->AddItem(new BMenuItem("DUMMY SAVESTATE LINE", NULL)); m->AddItem(subMenu); m->AddSeparatorItem(); m->AddItem(item = new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED))); item->SetShortcut('Q', B_COMMAND_KEY); m->SetTargetForItems(win); menuBar->AddItem(m); // Graphics menu m = new BMenu("Graphics"); m->AddItem(new BMenuItem("Full Screen", NULL)); m->AddItem(item = new BMenuItem("VSync", NULL)); if (true) item->SetMarked(true); m->AddItem(item = new BMenuItem("Stretch", NULL)); if (true) item->SetMarked(true); m->AddSeparatorItem(); m->AddItem(item = new BMenuItem("OpenGL", NULL)); if (true) item->SetMarked(true); subMenu = new BMenu("OpenGL Resolution"); subMenu->AddItem(new BMenuItem("320x240", NULL)); subMenu->AddItem(new BMenuItem("640x480", NULL)); subMenu->AddItem(new BMenuItem("800x600", NULL)); subMenu->AddItem(new BMenuItem("1024x768", NULL)); subMenu->AddItem(new BMenuItem("Custom", NULL)); m->AddItem(subMenu); subMenu = new BMenu("Bits per pixel"); subMenu->AddItem(new BMenuItem("16", NULL)); subMenu->AddItem(new BMenuItem("24", NULL)); subMenu->AddItem(new BMenuItem("32", NULL)); m->AddItem(subMenu); m->AddSeparatorItem(); m->AddItem(new BMenuItem("Color Adjust", NULL)); subMenu = new BMenu("Render"); subMenu->AddItem(new BMenuItem("Normal", NULL)); subMenu->AddItem(new BMenuItem("Double", NULL)); subMenu->AddItem(new BMenuItem("Interpolated", NULL)); subMenu->AddItem(new BMenuItem("Scanline", NULL)); subMenu->AddItem(new BMenuItem("50% Scanline", NULL)); subMenu->AddItem(new BMenuItem("25% Scanline", NULL)); subMenu->AddItem(new BMenuItem("Interpolated Scanline", NULL)); subMenu->AddItem(new BMenuItem("Interpolated 50% Scanline", NULL)); subMenu->AddItem(new BMenuItem("Interpolated 25% Scanline", NULL)); subMenu->AddItem(new BMenuItem("2xSAI (Kreed)", NULL)); subMenu->AddItem(new BMenuItem("Scale2x", NULL)); subMenu->AddItem(new BMenuItem("Hq2x", NULL)); m->AddItem(subMenu); m->AddSeparatorItem(); m->AddItem(item = new BMenuItem("Sprite Limit", NULL)); if (true) item->SetMarked(true); m->AddSeparatorItem(); subMenu = new BMenu("Frame Skip"); subMenu->AddItem(new BMenuItem("Auto", NULL)); subMenu->AddItem(new BMenuItem("0", NULL)); subMenu->AddItem(new BMenuItem("1", NULL)); subMenu->AddItem(new BMenuItem("2", NULL)); subMenu->AddItem(new BMenuItem("3", NULL)); subMenu->AddItem(new BMenuItem("4", NULL)); subMenu->AddItem(new BMenuItem("5", NULL)); subMenu->AddItem(new BMenuItem("6", NULL)); subMenu->AddItem(new BMenuItem("7", NULL)); subMenu->AddItem(new BMenuItem("8", NULL)); m->AddItem(subMenu); m->AddSeparatorItem(); m->AddItem(new BMenuItem("Screen Shot", NULL)); menuBar->AddItem(m); // CPU menu m = new BMenu("CPU"); subMenu = new BMenu("Debug"); subMenu->AddItem(item = new BMenuItem("Genesis - 68000", NULL)); if (true) item->SetMarked(true); subMenu->AddItem(item = new BMenuItem("Genesis - Z80", NULL)); if (true) item->SetMarked(true); subMenu->AddItem(item = new BMenuItem("Genesis - VDP", NULL)); if (true) item->SetMarked(true); m->AddItem(subMenu); m->AddSeparatorItem(); subMenu = new BMenu("Country"); subMenu->AddItem(new BMenuItem("Autodetect", NULL)); subMenu->AddItem(new BMenuItem("Japan (NTSC)", NULL)); subMenu->AddItem(new BMenuItem("USA (NTSC)", NULL)); subMenu->AddItem(new BMenuItem("Europe (PAL)", NULL)); subMenu->AddItem(new BMenuItem("Japan (PAL)", NULL)); subMenu->AddSeparatorItem(); BMenu *subMenu2 = new BMenu("Auto detection order"); subMenu->AddItem(subMenu2); subMenu2->AddItem(new BMenuItem("USA (NTSC)", NULL)); subMenu2->AddItem(new BMenuItem("Japan (NTSC)", NULL)); subMenu2->AddItem(new BMenuItem("Europe (PAL)", NULL)); m->AddItem(subMenu); m->AddSeparatorItem(); m->AddItem(new BMenuItem("Hard Reset", NULL)); m->AddItem(new BMenuItem("Reset 68000", NULL)); m->AddItem(new BMenuItem("Reset Z80", NULL)); m->AddSeparatorItem(); m->AddItem(item = new BMenuItem("Perfect Synchro (SLOW)", NULL)); if (true) item->SetMarked(true); // Sound menu. menuBar->AddItem(m); m = new BMenu("Sound"); m->AddItem(item = new BMenuItem("Enabled", NULL)); if (true) item->SetMarked(true); m->AddSeparatorItem(); subMenu = new BMenu("Rate"); subMenu->AddItem(new BMenuItem("11025", NULL)); subMenu->AddItem(new BMenuItem("16000", NULL)); subMenu->AddItem(new BMenuItem("22050", NULL)); subMenu->AddItem(new BMenuItem("32000", NULL)); subMenu->AddItem(new BMenuItem("44100", NULL)); subMenu->AddItem(new BMenuItem("48000", NULL)); m->AddItem(subMenu); m->AddItem(item = new BMenuItem("Stereo", NULL)); if (true) item->SetMarked(true); m->AddSeparatorItem(); m->AddItem(item = new BMenuItem("Z80", NULL)); if (true) item->SetMarked(true); m->AddSeparatorItem(); m->AddItem(item = new BMenuItem("YM2612", NULL)); if (true) item->SetMarked(true); m->AddItem(item = new BMenuItem("YM2612 Improved", NULL)); if (true) item->SetMarked(true); m->AddSeparatorItem(); m->AddItem(item = new BMenuItem("DAC", NULL)); if (true) item->SetMarked(true); m->AddItem(item = new BMenuItem("DAC Improved", NULL)); if (true) item->SetMarked(true); m->AddSeparatorItem(); m->AddItem(item = new BMenuItem("PSG", NULL)); if (true) item->SetMarked(true); m->AddItem(item = new BMenuItem("PSG Improved", NULL)); if (true) item->SetMarked(true); m->AddSeparatorItem(); m->AddItem(item = new BMenuItem("PCM", NULL)); if (true) item->SetMarked(true); m->AddItem(item = new BMenuItem("PWM", NULL)); if (true) item->SetMarked(true); m->AddSeparatorItem(); m->AddItem(item = new BMenuItem("CDDA", NULL)); if (true) item->SetMarked(true); m->AddSeparatorItem(); m->AddItem(new BMenuItem("Start WAV Dump", NULL)); m->AddItem(new BMenuItem("Start GYM Dump", NULL)); menuBar->AddItem(m); // Options menu m = new BMenu("Options"); m->AddItem(new BMenuItem("General Options", NULL)); m->AddItem(new BMenuItem("Joypads...", NULL)); m->AddItem(new BMenuItem("Directories...", NULL)); m->AddItem(new BMenuItem("BIOS/Misc Files...", NULL)); m->AddSeparatorItem(); m->AddItem(new BMenuItem("SDL Sound Test", NULL)); m->AddSeparatorItem(); m->AddItem(new BMenuItem("Current CD Drive", NULL)); subMenu = new BMenu("Sega CD SRAM Size"); subMenu->AddItem(new BMenuItem("None", NULL)); subMenu->AddItem(new BMenuItem("8 kb", NULL)); subMenu->AddItem(new BMenuItem("16 kb", NULL)); subMenu->AddItem(new BMenuItem("32 kb", NULL)); subMenu->AddItem(new BMenuItem("64 kb", NULL)); m->AddItem(subMenu); m->AddSeparatorItem(); m->AddItem(new BMenuItem("Load config", NULL)); m->AddItem(new BMenuItem("Save config as", NULL)); menuBar->AddItem(m); // Help menu m = new BMenu("Help"); m->AddItem(new BMenuItem("About", NULL)); menuBar->AddItem(m); }
void EthernetSettingsView::_ShowConfiguration(Settings* settings) { fCurrentSettings = settings; // Clear the inputs. fIPTextControl->SetText(""); fGatewayTextControl->SetText(""); fNetMaskTextControl->SetText(""); fPrimaryDNSTextControl->SetText(""); fSecondaryDNSTextControl->SetText(""); fDomainTextControl->SetText(""); fDeviceMenuField->SetEnabled(settings != NULL); fTypeMenuField->SetEnabled(settings != NULL); bool enableControls = false; BMenuItem* item; if (settings == NULL || settings->IsDisabled()) item = fTypeMenuField->Menu()->FindItem(B_TRANSLATE("Disabled")); else if (settings->AutoConfigure()) item = fTypeMenuField->Menu()->FindItem(B_TRANSLATE("DHCP")); else { item = fTypeMenuField->Menu()->FindItem(B_TRANSLATE("Static")); enableControls = true; } if (item != NULL) item->SetMarked(true); if (settings == NULL) { if (!fNetworkMenuField->IsHidden(fNetworkMenuField)) fNetworkMenuField->Hide(); _EnableTextControls(false); return; } // Show/hide networks menu BNetworkDevice device(settings->Name()); if (fNetworkMenuField->IsHidden(fNetworkMenuField) && device.IsWireless()) { fNetworkMenuField->Show(); Window()->InvalidateLayout(); } else if (!fNetworkMenuField->IsHidden(fNetworkMenuField) && !device.IsWireless()) { fNetworkMenuField->Hide(); Window()->InvalidateLayout(); } if (device.IsWireless()) { // Rebuild network menu BMenu* menu = fNetworkMenuField->Menu(); menu->RemoveItems(0, menu->CountItems(), true); wireless_network network; int32 count = 0; uint32 cookie = 0; while (device.GetNextNetwork(cookie, network) == B_OK) { BMessage* message = new BMessage(kMsgNetwork); message->AddString("device", device.Name()); message->AddString("name", network.name); BMenuItem* item = new WirelessNetworkMenuItem(network.name, network.signal_strength, (network.flags & B_NETWORK_IS_ENCRYPTED) != 0, message); if (fCurrentSettings->WirelessNetwork() == network.name) item->SetMarked(true); menu->AddItem(item); count++; } if (count == 0) { BMenuItem* item = new BMenuItem( B_TRANSLATE("<no wireless networks found>"), NULL); item->SetEnabled(false); menu->AddItem(item); } else { BMenuItem* item = new BMenuItem( B_TRANSLATE("Choose automatically"), NULL); if (menu->FindMarked() == NULL) item->SetMarked(true); menu->AddItem(item, 0); menu->AddItem(new BSeparatorItem(), 1); } menu->SetTargetForItems(this); } item = fDeviceMenuField->Menu()->FindItem(settings->Name()); if (item != NULL) item->SetMarked(true); fIPTextControl->SetText(settings->IP()); fGatewayTextControl->SetText(settings->Gateway()); fNetMaskTextControl->SetText(settings->Netmask()); if (settings->NameServers().CountItems() >= 2) { fSecondaryDNSTextControl->SetText( settings->NameServers().ItemAt(1)->String()); } if (settings->NameServers().CountItems() >= 1) { fPrimaryDNSTextControl->SetText( settings->NameServers().ItemAt(0)->String()); } fDomainTextControl->SetText(settings->Domain()); _EnableTextControls(enableControls); }
FileTypesWindow::FileTypesWindow(const BMessage& settings) : BWindow(_Frame(settings), B_TRANSLATE_SYSTEM_NAME("FileTypes"), B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS), fNewTypeWindow(NULL) { bool showIcons; bool showRule; if (settings.FindBool("show_icons", &showIcons) != B_OK) showIcons = true; if (settings.FindBool("show_rule", &showRule) != B_OK) showRule = false; float padding = be_control_look->DefaultItemSpacing(); BAlignment labelAlignment = be_control_look->DefaultLabelAlignment(); BAlignment fullAlignment(B_ALIGN_USE_FULL_WIDTH, B_ALIGN_USE_FULL_HEIGHT); // add the menu BMenuBar* menuBar = new BMenuBar(""); BMenu* menu = new BMenu(B_TRANSLATE("File")); BMenuItem* item = new BMenuItem( B_TRANSLATE("New resource file" B_UTF8_ELLIPSIS), NULL, 'N', B_COMMAND_KEY); item->SetEnabled(false); menu->AddItem(item); BMenu* recentsMenu = BRecentFilesList::NewFileListMenu( B_TRANSLATE("Open" B_UTF8_ELLIPSIS), NULL, NULL, be_app, 10, false, NULL, kSignature); item = new BMenuItem(recentsMenu, new BMessage(kMsgOpenFilePanel)); item->SetShortcut('O', B_COMMAND_KEY); menu->AddItem(item); menu->AddItem(new BMenuItem( B_TRANSLATE("Application types" B_UTF8_ELLIPSIS), new BMessage(kMsgOpenApplicationTypesWindow))); menu->AddSeparatorItem(); menu->AddItem(new BMenuItem(B_TRANSLATE("Quit"), new BMessage(B_QUIT_REQUESTED), 'Q', B_COMMAND_KEY)); menu->SetTargetForItems(be_app); menuBar->AddItem(menu); menu = new BMenu(B_TRANSLATE("Settings")); item = new BMenuItem(B_TRANSLATE("Show icons in list"), new BMessage(kMsgToggleIcons)); item->SetMarked(showIcons); item->SetTarget(this); menu->AddItem(item); item = new BMenuItem(B_TRANSLATE("Show recognition rule"), new BMessage(kMsgToggleRule)); item->SetMarked(showRule); item->SetTarget(this); menu->AddItem(item); menuBar->AddItem(menu); menuBar->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_TOP)); // MIME Types list BButton* addTypeButton = new BButton("add", B_TRANSLATE("Add" B_UTF8_ELLIPSIS), new BMessage(kMsgAddType)); fRemoveTypeButton = new BButton("remove", B_TRANSLATE("Remove"), new BMessage(kMsgRemoveType) ); fTypeListView = new MimeTypeListView("typeview", NULL, showIcons, false); fTypeListView->SetSelectionMessage(new BMessage(kMsgTypeSelected)); fTypeListView->SetExplicitMinSize(BSize(200, B_SIZE_UNSET)); BScrollView* typeListScrollView = new BScrollView("scrollview", fTypeListView, B_FRAME_EVENTS | B_WILL_DRAW, false, true); // "Icon" group fIconView = new TypeIconView("icon"); fIconBox = new BBox("Icon BBox"); fIconBox->SetLabel(B_TRANSLATE("Icon")); BLayoutBuilder::Group<>(fIconBox, B_VERTICAL, padding) .SetInsets(padding) .AddGlue(1) .Add(fIconView, 3) .AddGlue(1); // "File Recognition" group fRecognitionBox = new BBox("Recognition Box"); fRecognitionBox->SetLabel(B_TRANSLATE("File recognition")); fRecognitionBox->SetExplicitAlignment(fullAlignment); fExtensionLabel = new StringView(B_TRANSLATE("Extensions:"), NULL); fExtensionLabel->LabelView()->SetExplicitAlignment(labelAlignment); fAddExtensionButton = new BButton("add ext", B_TRANSLATE("Add" B_UTF8_ELLIPSIS), new BMessage(kMsgAddExtension)); fAddExtensionButton->SetExplicitMaxSize( BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET)); fRemoveExtensionButton = new BButton("remove ext", B_TRANSLATE("Remove"), new BMessage(kMsgRemoveExtension)); fExtensionListView = new ExtensionListView("listview ext", B_SINGLE_SELECTION_LIST); fExtensionListView->SetSelectionMessage( new BMessage(kMsgExtensionSelected)); fExtensionListView->SetInvocationMessage( new BMessage(kMsgExtensionInvoked)); BScrollView* scrollView = new BScrollView("scrollview ext", fExtensionListView, B_FRAME_EVENTS | B_WILL_DRAW, false, true); fRuleControl = new BTextControl("rule", B_TRANSLATE("Rule:"), "", new BMessage(kMsgRuleEntered)); fRuleControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT); fRuleControl->Hide(); BLayoutBuilder::Grid<>(fRecognitionBox, padding, padding / 2) .SetInsets(padding, padding * 2, padding, padding) .Add(fExtensionLabel->LabelView(), 0, 0) .Add(scrollView, 0, 1, 2, 2) .Add(fAddExtensionButton, 2, 1) .Add(fRemoveExtensionButton, 2, 2) .Add(fRuleControl, 0, 3, 3, 1); // "Description" group fDescriptionBox = new BBox("description BBox"); fDescriptionBox->SetLabel(B_TRANSLATE("Description")); fDescriptionBox->SetExplicitAlignment(fullAlignment); fInternalNameView = new StringView(B_TRANSLATE("Internal name:"), NULL); fInternalNameView->SetEnabled(false); fTypeNameControl = new BTextControl("type", B_TRANSLATE("Type name:"), "", new BMessage(kMsgTypeEntered)); fDescriptionControl = new BTextControl("description", B_TRANSLATE("Description:"), "", new BMessage(kMsgDescriptionEntered)); BLayoutBuilder::Grid<>(fDescriptionBox, padding / 2, padding / 2) .SetInsets(padding, padding * 2, padding, padding) .Add(fInternalNameView->LabelView(), 0, 0) .Add(fInternalNameView->TextView(), 1, 0) .Add(fTypeNameControl->CreateLabelLayoutItem(), 0, 1) .Add(fTypeNameControl->CreateTextViewLayoutItem(), 1, 1, 2) .Add(fDescriptionControl->CreateLabelLayoutItem(), 0, 2) .Add(fDescriptionControl->CreateTextViewLayoutItem(), 1, 2, 2); // "Preferred Application" group fPreferredBox = new BBox("preferred BBox"); fPreferredBox->SetLabel(B_TRANSLATE("Preferred application")); menu = new BPopUpMenu("preferred"); menu->AddItem(item = new BMenuItem(B_TRANSLATE("None"), new BMessage(kMsgPreferredAppChosen))); item->SetMarked(true); fPreferredField = new BMenuField("preferred", (char*)NULL, menu); fSelectButton = new BButton("select", B_TRANSLATE("Select" B_UTF8_ELLIPSIS), new BMessage(kMsgSelectPreferredApp)); fSameAsButton = new BButton("same as", B_TRANSLATE("Same as" B_UTF8_ELLIPSIS), new BMessage(kMsgSamePreferredAppAs)); BLayoutBuilder::Group<>(fPreferredBox, B_HORIZONTAL, padding) .SetInsets(padding, padding * 2, padding, padding) .Add(fPreferredField) .Add(fSelectButton) .Add(fSameAsButton); // "Extra Attributes" group fAttributeBox = new BBox("Attribute Box"); fAttributeBox->SetLabel(B_TRANSLATE("Extra attributes")); fAddAttributeButton = new BButton("add attr", B_TRANSLATE("Add" B_UTF8_ELLIPSIS), new BMessage(kMsgAddAttribute)); fAddAttributeButton->SetExplicitMaxSize( BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET)); fRemoveAttributeButton = new BButton("remove attr", B_TRANSLATE("Remove"), new BMessage(kMsgRemoveAttribute)); fRemoveAttributeButton->SetExplicitMaxSize( BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET)); fMoveUpAttributeButton = new BButton("move up attr", B_TRANSLATE("Move up"), new BMessage(kMsgMoveUpAttribute)); fMoveUpAttributeButton->SetExplicitMaxSize( BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET)); fMoveDownAttributeButton = new BButton("move down attr", B_TRANSLATE("Move down"), new BMessage(kMsgMoveDownAttribute)); fMoveDownAttributeButton->SetExplicitMaxSize( BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET)); fAttributeListView = new AttributeListView("listview attr"); fAttributeListView->SetSelectionMessage( new BMessage(kMsgAttributeSelected)); fAttributeListView->SetInvocationMessage( new BMessage(kMsgAttributeInvoked)); BScrollView* attributesScroller = new BScrollView("scrollview attr", fAttributeListView, B_FRAME_EVENTS | B_WILL_DRAW, false, true); BLayoutBuilder::Group<>(fAttributeBox, B_HORIZONTAL, padding) .SetInsets(padding, padding * 2, padding, padding) .Add(attributesScroller, 1.0f) .AddGroup(B_VERTICAL, padding / 2, 0.0f) .SetInsets(0) .Add(fAddAttributeButton) .Add(fRemoveAttributeButton) .AddStrut(padding) .Add(fMoveUpAttributeButton) .Add(fMoveDownAttributeButton) .AddGlue(); fMainSplitView = new BSplitView(B_HORIZONTAL, floorf(padding / 2)); BLayoutBuilder::Group<>(this, B_VERTICAL, 0) .SetInsets(0) .Add(menuBar) .AddGroup(B_HORIZONTAL, 0) .SetInsets(padding, padding, padding, padding) .AddSplit(fMainSplitView) .AddGroup(B_VERTICAL, padding) .Add(typeListScrollView) .AddGroup(B_HORIZONTAL, padding) .Add(addTypeButton) .Add(fRemoveTypeButton) .AddGlue() .End() .End() // Right side .AddGroup(B_VERTICAL, padding) .AddGroup(B_HORIZONTAL, padding) .Add(fIconBox, 1) .Add(fRecognitionBox, 3) .End() .Add(fDescriptionBox) .Add(fPreferredBox) .Add(fAttributeBox, 5); _SetType(NULL); _ShowSnifferRule(showRule); float leftWeight; float rightWeight; if (settings.FindFloat("left_split_weight", &leftWeight) != B_OK || settings.FindFloat("right_split_weight", &rightWeight) != B_OK) { leftWeight = 0.2; rightWeight = 1.0 - leftWeight; } fMainSplitView->SetItemWeight(0, leftWeight, false); fMainSplitView->SetItemWeight(1, rightWeight, true); BMimeType::StartWatching(this); }
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( MDR_DIALECT_CHOICE ("No new messages","未読メッセージなし"), NULL)); item->SetEnabled(false); } BMailAccounts accounts; if (modifiers() & B_SHIFT_KEY) { BMenu *accountMenu = new BMenu( MDR_DIALECT_CHOICE ("Check for mails only","R) メール受信のみ")); BFont font; menu->GetFont(&font); accountMenu->SetFont(&font); for (int32 i = 0; i < accounts.CountAccounts(); i++) { BMailAccountSettings* account = accounts.AccountAt(i); BMessage* message = new BMessage(MD_CHECK_FOR_MAILS); message->AddInt32("account", account->AccountID()); accountMenu->AddItem(new BMenuItem(account->Name(), message)); } if (accounts.CountAccounts() == 0) { item = new BMenuItem("<no accounts>", NULL); item->SetEnabled(false); accountMenu->AddItem(item); } accountMenu->SetTargetForItems(this); menu->AddItem(new BMenuItem(accountMenu, new BMessage(MD_CHECK_FOR_MAILS))); // Not used: // menu->AddItem(new BMenuItem(MDR_DIALECT_CHOICE ( // "Check For Mails Only","メール受信のみ"), new BMessage(MD_CHECK_FOR_MAILS))); menu->AddItem(new BMenuItem( MDR_DIALECT_CHOICE ("Send pending mails", "M) 保留メールを送信"), new BMessage(MD_SEND_MAILS))); } else { menu->AddItem(item = new BMenuItem( MDR_DIALECT_CHOICE ("Check for mail now", "C) メールチェック"), new BMessage(MD_CHECK_SEND_NOW))); if (accounts.CountAccounts() == 0) item->SetEnabled(false); } menu->AddSeparatorItem(); menu->AddItem(new BMenuItem( MDR_DIALECT_CHOICE ("Preferences", "P) メール環境設定") B_UTF8_ELLIPSIS, new BMessage(MD_OPEN_PREFS))); if (modifiers() & B_SHIFT_KEY) { menu->AddItem(new BMenuItem( MDR_DIALECT_CHOICE ("Shutdown mail services", "Q) 終了"), new BMessage(B_QUIT_REQUESTED))); } // Reset Item Targets (only those which aren't already set) for (int32 i = menu->CountItems(); i-- > 0;) { item = menu->ItemAt(i); if (item && (msg = item->Message()) != NULL) { if (msg->what == B_REFS_RECEIVED) item->SetTarget(tracker); else item->SetTarget(this); } } return menu; }
FileTypesWindow::FileTypesWindow(const BMessage& settings) : BWindow(_Frame(settings), "FileTypes", B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS), fNewTypeWindow(NULL) { bool showIcons; bool showRule; if (settings.FindBool("show_icons", &showIcons) != B_OK) showIcons = true; if (settings.FindBool("show_rule", &showRule) != B_OK) showRule = false; // add the menu BMenuBar* menuBar = new BMenuBar(BRect(0, 0, 0, 0), NULL); AddChild(menuBar); BMenu* menu = new BMenu("File"); BMenuItem* item; menu->AddItem(item = new BMenuItem("New resource file" B_UTF8_ELLIPSIS, NULL, 'N', B_COMMAND_KEY)); item->SetEnabled(false); BMenu* recentsMenu = BRecentFilesList::NewFileListMenu("Open" B_UTF8_ELLIPSIS, NULL, NULL, be_app, 10, false, NULL, kSignature); item = new BMenuItem(recentsMenu, new BMessage(kMsgOpenFilePanel)); item->SetShortcut('O', B_COMMAND_KEY); menu->AddItem(item); menu->AddItem(new BMenuItem("Application types" B_UTF8_ELLIPSIS, new BMessage(kMsgOpenApplicationTypesWindow))); menu->AddSeparatorItem(); menu->AddItem(new BMenuItem("About FileTypes" B_UTF8_ELLIPSIS, new BMessage(B_ABOUT_REQUESTED))); menu->AddSeparatorItem(); menu->AddItem(new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED), 'Q', B_COMMAND_KEY)); menu->SetTargetForItems(be_app); menuBar->AddItem(menu); menu = new BMenu("Settings"); item = new BMenuItem("Show icons in list", new BMessage(kMsgToggleIcons)); item->SetMarked(showIcons); item->SetTarget(this); menu->AddItem(item); item = new BMenuItem("Show recognition rule", new BMessage(kMsgToggleRule)); item->SetMarked(showRule); item->SetTarget(this); menu->AddItem(item); menuBar->AddItem(menu); // MIME Types list BRect rect = Bounds(); rect.top = menuBar->Bounds().Height() + 1.0f; BView* topView = new BView(rect, NULL, B_FOLLOW_ALL, B_WILL_DRAW); topView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); AddChild(topView); BButton* button = new BButton(rect, "add", "Add" B_UTF8_ELLIPSIS, new BMessage(kMsgAddType), B_FOLLOW_BOTTOM); button->ResizeToPreferred(); button->MoveTo(8.0f, topView->Bounds().bottom - 8.0f - button->Bounds().Height()); topView->AddChild(button); rect = button->Frame(); rect.OffsetBy(rect.Width() + 8.0f, 0.0f); fRemoveTypeButton = new BButton(rect, "remove", "Remove", new BMessage(kMsgRemoveType), B_FOLLOW_BOTTOM); fRemoveTypeButton->ResizeToPreferred(); topView->AddChild(fRemoveTypeButton); rect.bottom = rect.top - 10.0f; rect.top = 10.0f; rect.left = 10.0f; rect.right -= B_V_SCROLL_BAR_WIDTH + 2.0f; if (rect.right < 180) rect.right = 180; fTypeListView = new MimeTypeListView(rect, "typeview", NULL, showIcons, false, B_FOLLOW_LEFT | B_FOLLOW_TOP_BOTTOM); fTypeListView->SetSelectionMessage(new BMessage(kMsgTypeSelected)); BScrollView* scrollView = new BScrollView("scrollview", fTypeListView, B_FOLLOW_LEFT | B_FOLLOW_TOP_BOTTOM, B_FRAME_EVENTS | B_WILL_DRAW, false, true); topView->AddChild(scrollView); // "Icon" group font_height plainHeight; be_plain_font->GetHeight(&plainHeight); float height = ceilf(plainHeight.ascent + plainHeight.descent + plainHeight.leading) + 2.0f; BFont font(be_bold_font); float labelWidth = font.StringWidth("Icon"); font_height boldHeight; font.GetHeight(&boldHeight); BRect innerRect; fIconView = new TypeIconView(innerRect, "icon", B_FOLLOW_LEFT | B_FOLLOW_V_CENTER); fIconView->ResizeToPreferred(); rect.left = rect.right + 12.0f + B_V_SCROLL_BAR_WIDTH; rect.right = rect.left + max_c(fIconView->Bounds().Width(), labelWidth) + 16.0f; rect.bottom = rect.top + ceilf(boldHeight.ascent) + max_c(fIconView->Bounds().Height(), button->Bounds().Height() * 2.0f + height + 4.0f) + 12.0f; rect.top -= 2.0f; fIconBox = new BBox(rect); fIconBox->SetLabel("Icon"); topView->AddChild(fIconBox); innerRect.left = 8.0f; innerRect.top = plainHeight.ascent + 3.0f + (rect.Height() - boldHeight.ascent - fIconView->Bounds().Height()) / 2.0f; if (innerRect.top + fIconView->Bounds().Height() > fIconBox->Bounds().Height() - 6.0f) innerRect.top = fIconBox->Bounds().Height() - 6.0f - fIconView->Bounds().Height(); fIconView->MoveTo(innerRect.LeftTop()); fIconBox->AddChild(fIconView); // "File Recognition" group BRect rightRect(rect); rightRect.left = rect.right + 8.0f; rightRect.right = topView->Bounds().Width() - 8.0f; fRecognitionBox = new BBox(rightRect, NULL, B_FOLLOW_LEFT_RIGHT); fRecognitionBox->SetLabel("File recognition"); topView->AddChild(fRecognitionBox); innerRect = fRecognitionBox->Bounds().InsetByCopy(8.0f, 4.0f); innerRect.top += ceilf(boldHeight.ascent); fExtensionLabel = new StringView(innerRect, "extension", "Extensions:", NULL); fExtensionLabel->SetAlignment(B_ALIGN_LEFT, B_ALIGN_LEFT); fExtensionLabel->ResizeToPreferred(); fRecognitionBox->AddChild(fExtensionLabel); innerRect.top += fExtensionLabel->Bounds().Height() + 2.0f; innerRect.left = innerRect.right - button->StringWidth("Remove") - 16.0f; innerRect.bottom = innerRect.top + button->Bounds().Height(); fAddExtensionButton = new BButton(innerRect, "add ext", "Add" B_UTF8_ELLIPSIS, new BMessage(kMsgAddExtension), B_FOLLOW_RIGHT); fRecognitionBox->AddChild(fAddExtensionButton); innerRect.OffsetBy(0, innerRect.Height() + 4.0f); fRemoveExtensionButton = new BButton(innerRect, "remove ext", "Remove", new BMessage(kMsgRemoveExtension), B_FOLLOW_RIGHT); fRecognitionBox->AddChild(fRemoveExtensionButton); innerRect.right = innerRect.left - 10.0f - B_V_SCROLL_BAR_WIDTH; innerRect.left = 10.0f; innerRect.top = fAddExtensionButton->Frame().top + 2.0f; innerRect.bottom = innerRect.bottom - 2.0f; // take scrollview border into account fExtensionListView = new ExtensionListView(innerRect, "listview ext", B_SINGLE_SELECTION_LIST, B_FOLLOW_LEFT_RIGHT); fExtensionListView->SetSelectionMessage(new BMessage(kMsgExtensionSelected)); fExtensionListView->SetInvocationMessage(new BMessage(kMsgExtensionInvoked)); scrollView = new BScrollView("scrollview ext", fExtensionListView, B_FOLLOW_LEFT_RIGHT, B_FRAME_EVENTS | B_WILL_DRAW, false, true); fRecognitionBox->AddChild(scrollView); innerRect.left = 8.0f; innerRect.top = innerRect.bottom + 10.0f; innerRect.right = fRecognitionBox->Bounds().right - 8.0f; innerRect.bottom = innerRect.top + 20.0f; fRuleControl = new BTextControl(innerRect, "rule", "Rule:", "", new BMessage(kMsgRuleEntered), B_FOLLOW_LEFT_RIGHT); //fRuleControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT); fRuleControl->SetDivider(fRuleControl->StringWidth(fRuleControl->Label()) + 6.0f); fRuleControl->Hide(); fRecognitionBox->AddChild(fRuleControl); // "Description" group rect.top = rect.bottom + 8.0f; rect.bottom = rect.top + ceilf(boldHeight.ascent) + 24.0f; rect.right = rightRect.right; fDescriptionBox = new BBox(rect, NULL, B_FOLLOW_LEFT_RIGHT); fDescriptionBox->SetLabel("Description"); topView->AddChild(fDescriptionBox); innerRect = fDescriptionBox->Bounds().InsetByCopy(8.0f, 6.0f); innerRect.top += ceilf(boldHeight.ascent); innerRect.bottom = innerRect.top + button->Bounds().Height(); fInternalNameView = new StringView(innerRect, "internal", "Internal name:", "", B_FOLLOW_LEFT_RIGHT); labelWidth = fInternalNameView->StringWidth(fInternalNameView->Label()) + 2.0f; fInternalNameView->SetDivider(labelWidth); fInternalNameView->SetEnabled(false); fInternalNameView->ResizeToPreferred(); fDescriptionBox->AddChild(fInternalNameView); innerRect.OffsetBy(0, fInternalNameView->Bounds().Height() + 5.0f); fTypeNameControl = new BTextControl(innerRect, "type", "Type name:", "", new BMessage(kMsgTypeEntered), B_FOLLOW_LEFT_RIGHT); fTypeNameControl->SetDivider(labelWidth); fTypeNameControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT); fDescriptionBox->ResizeBy(0, fInternalNameView->Bounds().Height() + fTypeNameControl->Bounds().Height() * 2.0f); fDescriptionBox->AddChild(fTypeNameControl); innerRect.OffsetBy(0, fTypeNameControl->Bounds().Height() + 5.0f); fDescriptionControl = new BTextControl(innerRect, "description", "Description:", "", new BMessage(kMsgDescriptionEntered), B_FOLLOW_LEFT_RIGHT); fDescriptionControl->SetDivider(labelWidth); fDescriptionControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT); fDescriptionBox->AddChild(fDescriptionControl); // "Preferred Application" group rect = fDescriptionBox->Frame(); rect.top = rect.bottom + 8.0f; rect.bottom = rect.top + ceilf(boldHeight.ascent) + button->Bounds().Height() + 14.0f; fPreferredBox = new BBox(rect, NULL, B_FOLLOW_LEFT_RIGHT); fPreferredBox->SetLabel("Preferred application"); topView->AddChild(fPreferredBox); innerRect = fPreferredBox->Bounds().InsetByCopy(8.0f, 6.0f); innerRect.top += ceilf(boldHeight.ascent); innerRect.left = innerRect.right - button->StringWidth( "Same as" B_UTF8_ELLIPSIS) - 24.0f; innerRect.bottom = innerRect.top + button->Bounds().Height(); fSameAsButton = new BButton(innerRect, "same as", "Same as" B_UTF8_ELLIPSIS, new BMessage(kMsgSamePreferredAppAs), B_FOLLOW_RIGHT); fPreferredBox->AddChild(fSameAsButton); innerRect.OffsetBy(-innerRect.Width() - 6.0f, 0.0f); fSelectButton = new BButton(innerRect, "select", "Select" B_UTF8_ELLIPSIS, new BMessage(kMsgSelectPreferredApp), B_FOLLOW_RIGHT); fPreferredBox->AddChild(fSelectButton); menu = new BPopUpMenu("preferred"); menu->AddItem(item = new BMenuItem("None", new BMessage(kMsgPreferredAppChosen))); item->SetMarked(true); innerRect.right = innerRect.left - 6.0f; innerRect.left = 8.0f; fPreferredField = new BMenuField(innerRect, "preferred", NULL, menu, true, B_FOLLOW_LEFT_RIGHT); float width; fPreferredField->GetPreferredSize(&width, &height); fPreferredField->ResizeTo(innerRect.Width(), height); fPreferredField->MoveBy(0.0f, (innerRect.Height() - height) / 2.0f); fPreferredBox->AddChild(fPreferredField); // "Extra Attributes" group rect.top = rect.bottom + 8.0f; rect.bottom = topView->Bounds().Height() - 8.0f; fAttributeBox = new BBox(rect, NULL, B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP_BOTTOM); fAttributeBox->SetLabel("Extra attributes"); topView->AddChild(fAttributeBox); innerRect = fAttributeBox->Bounds().InsetByCopy(8.0f, 6.0f); innerRect.top += ceilf(boldHeight.ascent); innerRect.left = innerRect.right - button->StringWidth("Remove") - 16.0f; innerRect.bottom = innerRect.top + button->Bounds().Height(); fAddAttributeButton = new BButton(innerRect, "add attr", "Add" B_UTF8_ELLIPSIS, new BMessage(kMsgAddAttribute), B_FOLLOW_RIGHT); fAttributeBox->AddChild(fAddAttributeButton); innerRect.OffsetBy(0, innerRect.Height() + 4.0f); fRemoveAttributeButton = new BButton(innerRect, "remove attr", "Remove", new BMessage(kMsgRemoveAttribute), B_FOLLOW_RIGHT); fAttributeBox->AddChild(fRemoveAttributeButton); /* innerRect.OffsetBy(0, innerRect.Height() + 4.0f); button = new BButton(innerRect, "push attr", "Push Up", new BMessage(kMsgRemoveAttribute), B_FOLLOW_RIGHT); fAttributeBox->AddChild(button); */ innerRect.right = innerRect.left - 10.0f - B_V_SCROLL_BAR_WIDTH; innerRect.left = 10.0f; innerRect.top = 8.0f + ceilf(boldHeight.ascent); innerRect.bottom = fAttributeBox->Bounds().bottom - 10.0f; // take scrollview border into account fAttributeListView = new AttributeListView(innerRect, "listview attr", B_FOLLOW_ALL); fAttributeListView->SetSelectionMessage(new BMessage(kMsgAttributeSelected)); fAttributeListView->SetInvocationMessage(new BMessage(kMsgAttributeInvoked)); scrollView = new BScrollView("scrollview attr", fAttributeListView, B_FOLLOW_ALL, B_FRAME_EVENTS | B_WILL_DRAW, false, true); fAttributeBox->AddChild(scrollView); SetSizeLimits(rightRect.left + 72.0f + font.StringWidth("jpg") + font.StringWidth(fRecognitionBox->Label()), 32767.0f, rect.top + 2.0f * button->Bounds().Height() + boldHeight.ascent + 32.0f + menuBar->Bounds().Height(), 32767.0f); _SetType(NULL); _ShowSnifferRule(showRule); BMimeType::StartWatching(this); }