Renamer_Remove::Renamer_Remove() : Renamer() { fName = B_TRANSLATE("Remove"); fPosition1 = new BSpinner(NULL, B_TRANSLATE("Remove from position"), new BMessage(MSG_RENAME_SETTINGS)); fPosition1->SetMinValue(0); fPosition1->SetValue(0); BPopUpMenu* myMenu; myMenu = new BPopUpMenu(B_TRANSLATE("Please select")); myMenu->AddItem(new BMenuItem(B_TRANSLATE("from the front (left)"), new BMessage(MSG_RENAME_SETTINGS))); myMenu->AddItem(new BMenuItem(B_TRANSLATE("from the back (right)"), new BMessage(MSG_RENAME_SETTINGS))); myMenu->ItemAt(0)->SetMarked(true); fDirection1 = new BMenuField(NULL, NULL, myMenu); fPosition2 = new BSpinner(NULL, B_TRANSLATE("To position"), new BMessage(MSG_RENAME_SETTINGS)); fPosition2->SetMinValue(0); fPosition2->SetValue(0); myMenu = new BPopUpMenu(B_TRANSLATE("Please select")); myMenu->AddItem(new BMenuItem(B_TRANSLATE("from the front (left)"), new BMessage(MSG_RENAME_SETTINGS))); myMenu->AddItem(new BMenuItem(B_TRANSLATE("from the back (right)"), new BMessage(MSG_RENAME_SETTINGS))); myMenu->ItemAt(0)->SetMarked(true); fDirection2 = new BMenuField(NULL, NULL, myMenu); BLayoutBuilder::Group<>(this, B_VERTICAL) .SetInsets(B_USE_WINDOW_INSETS) .AddGroup(B_HORIZONTAL) .Add(fPosition1) .Add(fDirection1) .End() .AddGroup(B_HORIZONTAL) .Add(fPosition2) .Add(fDirection2) .End() .AddGlue(); }
//------------------------------------------------------------------------------ void WindowEditor::InitFeelMenu() { BPopUpMenu* menu = new BPopUpMenu("Normal"); BMessage* msg; for (int i = 0; WindowFeels[i].label; ++i) { msg = new BMessage(MSG_WINDOW_SET_FEEL); msg->AddInt32("newfeel", WindowFeels[i].message); menu->AddItem(new BMenuItem(WindowFeels[i].label, msg)); } #if 0 msg->AddInt32("newfeel",B_NORMAL_WINDOW_FEEL); menu->AddItem(new BMenuItem("Normal",msg)); msg = new BMessage(MSG_WINDOW_SET_FEEL); msg->AddInt32("newfeel",B_MODAL_APP_WINDOW_FEEL); menu->AddItem(new BMenuItem("Modal Across Application",msg)); msg = new BMessage(MSG_WINDOW_SET_FEEL); msg->AddInt32("newfeel",B_MODAL_ALL_WINDOW_FEEL); menu->AddItem(new BMenuItem("Modal Across System",msg)); msg = new BMessage(MSG_WINDOW_SET_FEEL); msg->AddInt32("newfeel",B_FLOATING_APP_WINDOW_FEEL); menu->AddItem(new BMenuItem("Floating Across Application",msg)); msg = new BMessage(MSG_WINDOW_SET_FEEL); msg->AddInt32("newfeel",B_FLOATING_ALL_WINDOW_FEEL); menu->AddItem(new BMenuItem("Floating Across System",msg)); #endif switch (fWindowInfo.feel) { case B_NORMAL_WINDOW_FEEL: menu->ItemAt(0)->SetMarked(true); break; case B_MODAL_APP_WINDOW_FEEL: menu->ItemAt(1)->SetMarked(true); break; case B_MODAL_SUBSET_WINDOW_FEEL: menu->ItemAt(1)->SetMarked(true); break; case B_MODAL_ALL_WINDOW_FEEL: menu->ItemAt(2)->SetMarked(true); break; case B_FLOATING_APP_WINDOW_FEEL: menu->ItemAt(3)->SetMarked(true); break; case B_FLOATING_SUBSET_WINDOW_FEEL: menu->ItemAt(3)->SetMarked(true); break; case B_FLOATING_ALL_WINDOW_FEEL: menu->ItemAt(4)->SetMarked(true); break; } fFeelField = new BMenuField(BRect(10,70,240,90),"look","Window Behavior: ",menu); fFeelField->SetDivider(be_plain_font->StringWidth("Window Behavior: ")); AddChild(fFeelField); }
BPopUpMenu* TPrefsWindow::_BuildFontMenu(BFont* font) { font_family def_family; font_style def_style; font_family f_family; font_style f_style; BPopUpMenu *menu = new BPopUpMenu(""); font->GetFamilyAndStyle(&def_family, &def_style); int32 family_menu_index = 0; int family_count = count_font_families(); for (int family_loop = 0; family_loop < family_count; family_loop++) { get_font_family(family_loop, &f_family); BMenu *family_menu = new BMenu(f_family); int style_count = count_font_styles(f_family); for (int style_loop = 0; style_loop < style_count; style_loop++) { get_font_style(f_family, style_loop, &f_style); BMessage *msg = new BMessage(P_FONT); msg->AddString("font", f_family); msg->AddString("style", f_style); // we send this to make setting the Family easier when things // change msg->AddInt32("parent_index", family_menu_index); BMenuItem *item = new BMenuItem(f_style, msg); family_menu->AddItem(item); if ((strcmp(def_family, f_family) == 0) && (strcmp(def_style, f_style) == 0)) { item->SetMarked(true); } item->SetTarget(this); } menu->AddItem(family_menu); BMenuItem *item = menu->ItemAt(family_menu_index); BMessage *msg = new BMessage(P_FONT); msg->AddString("font", f_family); item->SetMessage(msg); item->SetTarget(this); if (strcmp(def_family, f_family) == 0) item->SetMarked(true); family_menu_index++; } return menu; }
//------------------------------------------------------------------------------ void WindowEditor::InitLookMenu() { BPopUpMenu *menu = new BPopUpMenu("Document Window"); BMessage *msg; for (int i = 0; WindowLooks[i].label; ++i) { msg = new BMessage(MSG_WINDOW_SET_LOOK); msg->AddInt32("newlook", WindowLooks[i].message); menu->AddItem(new BMenuItem(WindowLooks[i].label, msg)); } #if 0 msg = new BMessage(MSG_WINDOW_SET_LOOK); msg->AddInt32("newlook",B_TITLED_WINDOW_LOOK); menu->AddItem(new BMenuItem("Titled Window",msg)); msg = new BMessage(MSG_WINDOW_SET_LOOK); msg->AddInt32("newlook",B_FLOATING_WINDOW_LOOK); menu->AddItem(new BMenuItem("Floating Window",msg)); msg = new BMessage(MSG_WINDOW_SET_LOOK); msg->AddInt32("newlook",B_MODAL_WINDOW_LOOK); menu->AddItem(new BMenuItem("Modal Window",msg)); msg = new BMessage(MSG_WINDOW_SET_LOOK); msg->AddInt32("newlook",B_BORDERED_WINDOW_LOOK); menu->AddItem(new BMenuItem("Bordered Window",msg)); msg = new BMessage(MSG_WINDOW_SET_LOOK); msg->AddInt32("newlook",B_NO_BORDER_WINDOW_LOOK); menu->AddItem(new BMenuItem("Borderless Window",msg)); #endif switch (fWindowInfo.look) { case B_DOCUMENT_WINDOW_LOOK: menu->ItemAt(0)->SetMarked(true); break; case B_TITLED_WINDOW_LOOK: menu->ItemAt(1)->SetMarked(true); break; case B_FLOATING_WINDOW_LOOK: menu->ItemAt(2)->SetMarked(true); break; case B_MODAL_WINDOW_LOOK: menu->ItemAt(3)->SetMarked(true); break; case B_BORDERED_WINDOW_LOOK: menu->ItemAt(4)->SetMarked(true); break; case B_NO_BORDER_WINDOW_LOOK: menu->ItemAt(5)->SetMarked(true); break; } fLookField = new BMenuField(BRect(10,40,240,60),"look","Window Look: ",menu); fLookField->SetDivider(be_plain_font->StringWidth("Window Look: ")); AddChild(fLookField); }
/*static*/ BMenu* AppearancePrefView::_MakeFontMenu(uint32 command, const char* defaultFamily, const char* defaultStyle) { BPopUpMenu* menu = new BPopUpMenu(""); int32 numFamilies = count_font_families(); uint32 flags; for (int32 i = 0; i < numFamilies; i++) { font_family family; if (get_font_family(i, &family, &flags) == B_OK) { BFont font; font_style style; int32 numStyles = count_font_styles(family); for (int32 j = 0; j < numStyles; j++) { if (get_font_style(family, j, &style) == B_OK) { font.SetFamilyAndStyle(family, style); if (IsFontUsable(font)) { BMessage* message = new BMessage(command); const char* size = PrefHandler::Default()->getString(PREF_HALF_FONT_SIZE); message->AddString("font_family", family); message->AddString("font_style", style); message->AddString("font_size", size); char fontMenuLabel[134]; snprintf(fontMenuLabel, sizeof(fontMenuLabel), "%s - %s", family, style); BMenu* fontSizeMenu = _MakeFontSizeMenu(fontMenuLabel, MSG_HALF_FONT_CHANGED, family, style, size); BMenuItem* item = new BMenuItem(fontSizeMenu, message); menu->AddItem(item); if (strcmp(defaultFamily, family) == 0 && strcmp(defaultStyle, style) == 0) item->SetMarked(true); } } } } } if (menu->FindMarked() == NULL) menu->ItemAt(0)->SetMarked(true); return menu; }
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; }
ProjectSettingsWindow::ProjectSettingsWindow(BRect frame, Project* project) : BWindow(frame, TR("Project settings"), B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_AUTO_UPDATE_SIZE_LIMITS), fProject(project), fDirty(false) { if (fProject == NULL) debugger("Bad project given to Project Settings window"); fRefFilter = new TypedRefFilter(NULL, B_DIRECTORY_NODE); BMessenger messenger(this); entry_ref projectFolderRef; BEntry(fProject->GetPath().GetFolder()).GetRef(&projectFolderRef); fFilePanel = new BFilePanel(B_OPEN_PANEL, &messenger, &projectFolderRef, B_DIRECTORY_NODE, true, new BMessage(M_ADD_PATH), fRefFilter); fAutolock = new BAutolock(fProject); AddCommonFilter(new EscapeCancelFilter()); fTargetText = new AutoTextControl("targetname", TR("Target name:"), fProject->GetTargetName(), new BMessage(M_TARGET_NAME_CHANGED)); BPopUpMenu* targetTypeMenu = new BPopUpMenu(TR("Target type")); targetTypeMenu->AddItem(new BMenuItem(TR("Application"), new BMessage(M_SET_TARGET_TYPE))); targetTypeMenu->AddItem(new BMenuItem(TR("Shared library"), new BMessage(M_SET_TARGET_TYPE))); targetTypeMenu->AddItem(new BMenuItem(TR("Static library"), new BMessage(M_SET_TARGET_TYPE))); targetTypeMenu->AddItem(new BMenuItem(TR("Device driver"), new BMessage(M_SET_TARGET_TYPE))); fTypeField = new BMenuField("type", TR("Target type:"), targetTypeMenu); SetToolTip(fTypeField, TR("The kind of program you want to build")); BMenuItem* item = targetTypeMenu->ItemAt(fProject->TargetType()); if (item != NULL) item->SetMarked(true); fIncludeList = new IncludeList(fProject->GetPath().GetFolder()); SetToolTip(fIncludeList, TR("The folders you want Paladin to search for header files")); BScrollView* includeScrollView = new BScrollView("includescrollview", fIncludeList, B_WILL_DRAW, true, true); includeScrollView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); includeScrollView->SetExplicitMinSize( BSize(be_plain_font->StringWidth("M") * 34.0f, be_plain_font->StringWidth("M") * 12.0f)); for (int32 i = 0; i < fProject->CountLocalIncludes(); i++) { fIncludeList->AddItem(new BStringItem( fProject->LocalIncludeAt(i).Relative().String())); } float buttonWidth = be_plain_font->StringWidth("+") * 2.0f + 3.0f; BButton* addButton = new BButton("addbutton", TR("+"), new BMessage(M_SHOW_ADD_PATH)); addButton->SetExplicitSize(BSize(buttonWidth, buttonWidth)); addButton->SetToolTip(TR("Add a file to the include path list")); BButton* removeButton = new BButton("removebutton", TR("−"), new BMessage(M_REMOVE_PATH)); removeButton->SetExplicitSize(BSize(buttonWidth, buttonWidth)); removeButton->SetToolTip(TR("Remove the selected path")); // general tab fGeneralView = new BView(TR("General"), B_WILL_DRAW); fGeneralView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); BLayoutBuilder::Group<>(fGeneralView, B_VERTICAL, 0) .AddGrid(B_USE_DEFAULT_SPACING, B_USE_SMALL_SPACING) .Add(fTargetText->CreateLabelLayoutItem(), 0, 0) .Add(fTargetText->CreateTextViewLayoutItem(), 1, 0) .Add(fTypeField->CreateLabelLayoutItem(), 0, 1) .AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING, 1, 1) .Add(fTypeField->CreateMenuBarLayoutItem()) .AddGlue() .End() .End() .AddStrut(B_USE_DEFAULT_SPACING) .AddGroup(B_VERTICAL, 2.0f) .Add(new BStringView("include paths", TR("Include paths:"))) .AddGroup(B_HORIZONTAL, B_USE_SMALL_SPACING) .Add(includeScrollView) .AddGroup(B_VERTICAL, B_USE_SMALL_SPACING) .Add(addButton) .Add(removeButton) .AddGlue() .End() .End() .End() .SetInsets(B_USE_DEFAULT_SPACING) .End(); BPopUpMenu* optimizationMenu = new BPopUpMenu(TR("Optimization")); optimizationMenu->AddItem(new BMenuItem(TR("None"), new BMessage(M_SET_OP_VALUE))); optimizationMenu->AddItem(new BMenuItem(TR("Some"), new BMessage(M_SET_OP_VALUE))); optimizationMenu->AddItem(new BMenuItem(TR("More"), new BMessage(M_SET_OP_VALUE))); optimizationMenu->AddItem(new BMenuItem(TR("Full"), new BMessage(M_SET_OP_VALUE))); fOpField = new BMenuField("optimize", TR("Optimize:"), optimizationMenu); SetToolTip(fOpField, TR("Compiler optimization level. " "Disabled when debugging info is checked.")); item = optimizationMenu->ItemAt(fProject->OpLevel()); if (item != NULL) item->SetMarked(true); fOpSizeBox = new BCheckBox("opsizebox", TR("Optimize for size over speed"), new BMessage(M_TOGGLE_OPSIZE)); if (fProject->OpForSize()) fOpSizeBox->SetValue(B_CONTROL_ON); if (fProject->Debug()) { fOpField->SetEnabled(false); fOpSizeBox->SetEnabled(false); } fDebugBox = new BCheckBox("debugbox", TR("Build debugging information"), new BMessage(M_TOGGLE_DEBUG)); SetToolTip(fDebugBox, TR("Check this if you want to use your program in a debugger " "during development. You'll want to rebuild your project " "after change this.")); if (fProject->Debug()) fDebugBox->SetValue(B_CONTROL_ON); fProfileBox = new BCheckBox("profilebox", TR("Build profiling information"), new BMessage(M_TOGGLE_PROFILE)); SetToolTip(fProfileBox, TR("Check this if you want to use your program " "with gprof or bprof for profiling.")); if (fProject->Profiling()) fProfileBox->SetValue(B_CONTROL_ON); fCompileText = new AutoTextControl("extracc", "Extra compiler options:", fProject->ExtraCompilerOptions(), new BMessage(M_CCOPTS_CHANGED)); SetToolTip(fCompileText, TR("Extra GCC flags you wish included when each file is compiled.")); fLinkText = new AutoTextControl("extrald" ,TR("Extra linker options:"), fProject->ExtraLinkerOptions(), new BMessage(M_LDOPTS_CHANGED)); SetToolTip(fLinkText, TR("Extra GCC linker flags you wish included when your project " "is linked.")); // build tab fBuildView = new BView("Build", B_WILL_DRAW); fBuildView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); BLayoutBuilder::Group<>(fBuildView, B_VERTICAL) .AddGrid(B_USE_DEFAULT_SPACING, B_USE_SMALL_SPACING) .Add(fOpField->CreateLabelLayoutItem(), 0, 0) .AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING, 1, 0) .Add(fOpField->CreateMenuBarLayoutItem()) .AddGlue() .End() .AddGroup(B_VERTICAL, 0.0f, 1, 2) .Add(fOpSizeBox) .AddStrut(B_USE_SMALL_SPACING) .Add(fDebugBox) .Add(fProfileBox) .End() .End() .AddGlue() .AddGroup(B_VERTICAL, 0) .Add(fCompileText->CreateLabelLayoutItem()) .Add(fCompileText->CreateTextViewLayoutItem()) .End() .AddGroup(B_VERTICAL, 0) .Add(fLinkText->CreateLabelLayoutItem()) .Add(fLinkText->CreateTextViewLayoutItem()) .End() .SetInsets(B_USE_DEFAULT_SPACING) .End(); fTabView = new BTabView("tabview", B_WIDTH_FROM_LABEL); fTabView->SetBorder(B_NO_BORDER); fTabView->AddTab(fGeneralView); fTabView->AddTab(fBuildView); fTabView->Select(0L); BLayoutBuilder::Group<>(this, B_VERTICAL, 0) .AddStrut(B_USE_SMALL_SPACING) .Add(fTabView) .End(); targetTypeMenu->SetTargetForItems(this); optimizationMenu->SetTargetForItems(this); fIncludeList->Select(0); fTargetText->MakeFocus(true); }
PrefsWindow::PrefsWindow(BRect frame) : BWindow(frame, TR("Program settings"), B_TITLED_WINDOW, B_NOT_V_RESIZABLE | B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS) { AddShortcut('1', B_COMMAND_KEY, new BMessage(M_SET_TAB_0)); AddShortcut('2', B_COMMAND_KEY, new BMessage(M_SET_TAB_1)); // general fProjectFolder = new PathBox("projectfolder", gProjectPath.GetFullPath(), ""); fProjectFolder->MakeValidating(true); SetToolTip(fProjectFolder, TR("The default path for new projects.")); fShowProjectFolder = new BCheckBox("showfolder", TR("Show project folder on open"), new BMessage); SetToolTip(fShowProjectFolder, TR("When checked, a project's folder is " "shown in Tracker when it is opened.")); if (gShowFolderOnOpen) fShowProjectFolder->SetValue(B_CONTROL_ON); fDontAddHeaders = new BCheckBox("dontaddheaders", TR("Omit header files from projects"), NULL); SetToolTip(fDontAddHeaders, TR("If checked, header files are not automatically " "added to projects.")); if (gDontManageHeaders) fDontAddHeaders->SetValue(B_CONTROL_ON); fSlowBuilds = new BCheckBox("slowbuilds", TR("Use single thread"), NULL); SetToolTip(fSlowBuilds, TR("Build with just one thread instead of one thread " "per processor")); if (gSingleThreadedBuild) fSlowBuilds->SetValue(B_CONTROL_ON); fCCache = new BCheckBox("ccache", TR("Use ccache to build faster"), NULL); SetToolTip(fCCache, TR("Compiler caching is another way to speed up builds")); if (gCCacheAvailable) { if (gUseCCache) fCCache->SetValue(B_CONTROL_ON); } else { BString label = fCCache->Label(); label << " -- " << TR("unavailable"); fCCache->SetLabel(label.String()); fCCache->SetEnabled(false); } fFastDep = new BCheckBox("fastdep", TR("Use fastdep dependency checker"), NULL); SetToolTip(fFastDep, TR("Use the fastdep dependency checker instead of gcc")); if (gFastDepAvailable) { if (gUseFastDep) fFastDep->SetValue(B_CONTROL_ON); } else { BString label = fFastDep->Label(); label << " -- " << TR("unavailable"); fFastDep->SetLabel(label.String()); fFastDep->SetEnabled(false); } BBox* buildBox = new BBox(B_FANCY_BORDER, BLayoutBuilder::Group<>(B_VERTICAL, 0) .Add(fSlowBuilds) .Add(fCCache) .Add(fFastDep) .SetInsets(B_USE_DEFAULT_SPACING, B_USE_SMALL_SPACING, B_USE_DEFAULT_SPACING, B_USE_SMALL_SPACING) .View()); buildBox->SetLabel(TR("Build")); fAutoSyncModules = new BCheckBox("autosync", TR("Automatically synchronize modules"), NULL); SetToolTip(fAutoSyncModules, TR("Automatically synchronize modules in your " "projects with the those in the code library")); if (gAutoSyncModules) fAutoSyncModules->SetValue(B_CONTROL_ON); fBackupFolder = new PathBox("backupfolder", gBackupPath.GetFullPath(), ""); fBackupFolder->MakeValidating(true); SetToolTip(fBackupFolder, TR("Sets the location for project backups")); fTabs[0] = BLayoutBuilder::Grid<>(B_USE_DEFAULT_SPACING, B_USE_SMALL_SPACING) .Add(new BStringView("projects folder label", TR("Projects folder:")), 0, 0) .Add(fProjectFolder, 1, 0) .AddGroup(B_VERTICAL, 0.0f, 1, 1) .Add(fShowProjectFolder) .Add(fDontAddHeaders) .End() .Add(buildBox, 1, 2) .Add(fAutoSyncModules, 1, 3) .Add(new BStringView("backups folder label", TR("Backups folder:")), 0, 4) .Add(fBackupFolder, 1, 4) .SetInsets(B_USE_DEFAULT_SPACING) .View(); fTabs[0]->SetName(TR("General")); fTabs[0]->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); #ifndef BUILD_CODE_LIBRARY fAutoSyncModules->Hide(); #endif // source control BPopUpMenu* scmMenu = new BPopUpMenu("SCM Chooser"); scmMenu->AddItem(new BMenuItem(TR("None"), NULL)); scmMenu->AddSeparatorItem(); scmMenu->AddItem(new BMenuItem(TR("Git"), NULL)); scmMenu->AddItem(new BMenuItem(TR("Mercurial"), NULL)); scmMenu->AddItem(new BMenuItem(TR("Subversion"), NULL)); fSCMChooser = new BMenuField("scmchooser", TR("Preferred source control:"), scmMenu); #ifdef DISABLE_GIT_SUPPORT scmMenu->ItemAt(2)->SetEnabled(false); #endif BMenuItem* marked = scmMenu->ItemAt(gDefaultSCM); if (marked != NULL) marked->SetMarked(true); else scmMenu->ItemAt(0)->SetMarked(true); if (!marked->IsEnabled()) { // if the default SCM is disabled unmark it and mark the first one that // is enabled. marked->SetMarked(false); for (int32 i = 0; i < scmMenu->CountItems(); i++) { if (scmMenu->ItemAt(i)->IsEnabled()) { scmMenu->ItemAt(i)->SetMarked(true); break; } } } fSVNRepoFolder = new PathBox("svnrepofolder", gSVNRepoPath.GetFullPath(), ""); fSVNRepoFolder->MakeValidating(true); SetToolTip(fSVNRepoFolder, TR("Sets the location for the 'server' side of " "local Subversion repositories.")); fTabs[1] = BLayoutBuilder::Group<>(B_VERTICAL) .AddGrid(B_USE_DEFAULT_SPACING, B_USE_SMALL_SPACING) .Add(fSCMChooser->CreateLabelLayoutItem(), 0, 0) .AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING, 1, 0) .Add(fSCMChooser->CreateMenuBarLayoutItem()) .AddGlue() .End() .Add(new BStringView("svn repo folder label", TR("Subversion repository folder:")), 0, 1) .Add(fSVNRepoFolder, 1, 1) .End() .AddGlue() .SetInsets(B_USE_DEFAULT_SPACING) .View(); fTabs[1]->SetName(TR("Source control")); fTabs[1]->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); // tab view fTabView = new BTabView("tabview", B_WIDTH_FROM_LABEL); fTabView->SetBorder(B_NO_BORDER); fTabView->AddTab(fTabs[0]); fTabView->AddTab(fTabs[1]); fTabView->Select(0L); BLayoutBuilder::Group<>(this, B_VERTICAL, 0) .AddStrut(B_USE_SMALL_SPACING) .Add(fTabView) .End(); fProjectFolder->MakeFocus(true); CenterOnScreen(); }
ResizeWindow::ResizeWindow (CanvasWindow *target, const char *title, int32 _h, int32 _w) : BWindow (BRect (100, 100, 300, 248), title, B_TITLED_WINDOW, B_NOT_RESIZABLE) { char hS[16], wS[16], rD[16]; fTarget = target; fRez = 72; fH = _w; fV = _h; fHUnit = UNIT_PIXELS; fVUnit = UNIT_PIXELS; BRect bgFrame, cancelFrame, openFrame, textFrame, heightFrame, widthFrame, rezFrame; bgFrame = Bounds(); BView *bg = new BView (bgFrame, "SW bg", B_FOLLOW_ALL, B_WILL_DRAW); bg->SetViewColor (LightGrey); AddChild (bg); textFrame.Set (8, 8, 192, 102); BBox *text = new BBox (textFrame, "SW box"); text->SetLabel (lstring (180, "Canvas Size")); bg->AddChild (text); #if 0 textFrame.Set (8, 80, 192, 120); BBox *rez = new BBox (textFrame, "SW r box"); rez->SetLabel (lstring (186, "Resolution")); bg->AddChild (rez); #endif sprintf (hS, "%li", _h); sprintf (wS, "%li", _w); sprintf (rD, "%li", fRez); widthFrame.Set (8, 15, 120, 33); heightFrame.Set (8, 39, 120, 57); rezFrame.Set (8, 63, 120, 81); newWidth = new BTextControl (widthFrame, "NewWidth", lstring (181, "Width"), wS, new BMessage ('Swdt')); newHeight = new BTextControl (heightFrame, "NewHeight", lstring (182, "Height"), hS, new BMessage ('Shgt')); rDPI = new BTextControl (rezFrame, "rez", lstring (186, "Resolution"), rD, new BMessage ('Srez')); newHeight->SetAlignment (B_ALIGN_RIGHT, B_ALIGN_LEFT); newWidth->SetAlignment (B_ALIGN_RIGHT, B_ALIGN_LEFT); rDPI->SetAlignment (B_ALIGN_RIGHT, B_ALIGN_LEFT); BStringView *dpiV = new BStringView (BRect (rezFrame.right + 4, rezFrame.top, rezFrame.right + 40, rezFrame.bottom), "dpiV", "dpi"); BPopUpMenu *hPU = new BPopUpMenu (""); hPU->AddItem (new BMenuItem (lstring (187, "pixels"), new BMessage ('h_px'))); hPU->AddItem (new BMenuItem (lstring (188, "in"), new BMessage ('h_in'))); hPU->AddItem (new BMenuItem (lstring (189, "cm"), new BMessage ('h_cm'))); hPU->ItemAt(0)->SetMarked (true); BMenuField *hMF = new BMenuField (BRect (124, 14, 180, 30), "hUnit", NULL, hPU); BPopUpMenu *vPU = new BPopUpMenu (""); vPU->AddItem (new BMenuItem (lstring (187, "pixels"), new BMessage ('v_px'))); vPU->AddItem (new BMenuItem (lstring (188, "in"), new BMessage ('v_in'))); vPU->AddItem (new BMenuItem (lstring (189, "cm"), new BMessage ('v_cm'))); vPU->ItemAt(0)->SetMarked (true); BMenuField *vMF = new BMenuField (BRect (124, 38, 180, 54), "vUnit", NULL, vPU); text->AddChild (newWidth); text->AddChild (hMF); text->AddChild (newHeight); text->AddChild (vMF); text->AddChild (rDPI); text->AddChild (dpiV); cancelFrame.Set (82, 112, 134, 136); openFrame.Set (140, 112, 192, 136); BButton *cancel = new BButton (cancelFrame, "RSW cancel", lstring (131, "Cancel"), new BMessage ('RScn')); BButton *open = new BButton (openFrame, "RSW ok", lstring (136, "OK"), new BMessage ('RSok')); open->MakeDefault (true); bg->AddChild (cancel); bg->AddChild (open); fStatus = 0; }
QScopeWindow::QScopeWindow() : BWindow(BRect(0, 0, SCOPE_WIDTH+200-1, SCOPE_HEIGHT-1), "QScope", B_TITLED_WINDOW, B_NOT_RESIZABLE) { // Move window to right position Lock(); MoveTo(80, 60); BRect b = Bounds(); // Look up colors for scope { BScreen scr(this); illumination = false; c_black = scr.IndexForColor(0, 0, 0); c_dark_green = scr.IndexForColor(0, 32, 16); for (int i=0; i<16; i++) c_beam[i] = scr.IndexForColor(0, 255 - i * 8, 128 - i * 4); } // Light gray background BView *top = new BView(BRect(0, 0, b.right, b.bottom), "top", B_FOLLOW_NONE, B_WILL_DRAW); AddChild(top); top->SetViewColor(fill_color); // Allocate bitmap the_bitmap = new BBitmap(BRect(0, 0, SCOPE_WIDTH-1, SCOPE_HEIGHT-1), B_COLOR_8_BIT); // Create bitmap view main_view = new BitmapView(BRect(0, 0, SCOPE_WIDTH-1, SCOPE_HEIGHT-1), the_bitmap); top->AddChild(main_view); // Create interface elements { BBox *box = new BBox(BRect(SCOPE_WIDTH + 4, 4, SCOPE_WIDTH + 196, 62)); top->AddChild(box); box->SetLabel("Input"); BPopUpMenu *popup = new BPopUpMenu("stream popup", true, true); popup->AddItem(new BMenuItem("DAC", new BMessage(MSG_DAC_STREAM))); popup->AddItem(new BMenuItem("ADC", new BMessage(MSG_ADC_STREAM))); popup->SetTargetForItems(this); popup->ItemAt(0)->SetMarked(true); BMenuField *menu_field = new BMenuField(BRect(4, 14, 188, 34), "stream", "Stream", popup); box->AddChild(menu_field); popup = new BPopUpMenu("channel popup", true, true); popup->AddItem(new BMenuItem("Left", new BMessage(MSG_LEFT_CHANNEL))); popup->AddItem(new BMenuItem("Right", new BMessage(MSG_RIGHT_CHANNEL))); popup->AddItem(new BMenuItem("Stereo", new BMessage(MSG_STEREO_CHANNELS))); popup->SetTargetForItems(this); popup->ItemAt(0)->SetMarked(true); menu_field = new BMenuField(BRect(4, 34, 188, 54), "channel", "Channel", popup); box->AddChild(menu_field); } { BBox *box = new BBox(BRect(SCOPE_WIDTH + 4, 66, SCOPE_WIDTH + 196, 104)); top->AddChild(box); box->SetLabel("Time"); BPopUpMenu *popup = new BPopUpMenu("time/div popup", true, true); popup->AddItem(new BMenuItem("0.1ms", new BMessage(MSG_TIME_DIV_100us))); popup->AddItem(new BMenuItem("0.2ms", new BMessage(MSG_TIME_DIV_200us))); popup->AddItem(new BMenuItem("0.5ms", new BMessage(MSG_TIME_DIV_500us))); popup->AddItem(new BMenuItem("1ms", new BMessage(MSG_TIME_DIV_1ms))); popup->AddItem(new BMenuItem("2ms", new BMessage(MSG_TIME_DIV_2ms))); popup->AddItem(new BMenuItem("5ms", new BMessage(MSG_TIME_DIV_5ms))); popup->AddItem(new BMenuItem("10ms", new BMessage(MSG_TIME_DIV_10ms))); popup->SetTargetForItems(this); popup->ItemAt(4)->SetMarked(true); BMenuField *menu_field = new BMenuField(BRect(4, 14, 188, 34), "time/div", "Time/Div.", popup); box->AddChild(menu_field); } { BBox *box = new BBox(BRect(SCOPE_WIDTH + 4, 108, SCOPE_WIDTH + 196, 230)); top->AddChild(box); box->SetLabel("Trigger"); BPopUpMenu *popup = new BPopUpMenu("trigger channel popup", true, true); popup->AddItem(new BMenuItem("Left", new BMessage(MSG_TRIGGER_LEFT))); popup->AddItem(new BMenuItem("Right", new BMessage(MSG_TRIGGER_RIGHT))); popup->SetTargetForItems(this); popup->ItemAt(0)->SetMarked(true); BMenuField *menu_field = new BMenuField(BRect(4, 14, 188, 34), "trigger_channel", "Channel", popup); box->AddChild(menu_field); popup = new BPopUpMenu("trigger mode popup", true, true); popup->AddItem(new BMenuItem("Off", new BMessage(MSG_TRIGGER_OFF))); popup->AddItem(new BMenuItem("Level", new BMessage(MSG_TRIGGER_LEVEL))); popup->AddItem(new BMenuItem("Peak", new BMessage(MSG_TRIGGER_PEAK))); popup->SetTargetForItems(this); popup->ItemAt(1)->SetMarked(true); menu_field = new BMenuField(BRect(4, 34, 188, 54), "trigger_mode", "Trigger Mode", popup); box->AddChild(menu_field); BStringView *label = new BStringView(BRect(5, 54, 97, 73), "", "Level"); box->AddChild(label); TSliderView *the_slider = new TSliderView(BRect(98, 58, 188, 76), "level", 0.5, trigger_level_callback, this); box->AddChild(the_slider); popup = new BPopUpMenu("slope popup", true, true); popup->AddItem(new BMenuItem("pos", new BMessage(MSG_SLOPE_POS))); popup->AddItem(new BMenuItem("neg", new BMessage(MSG_SLOPE_NEG))); popup->SetTargetForItems(this); popup->ItemAt(0)->SetMarked(true); menu_field = new BMenuField(BRect(4, 76, 188, 96), "slope", "Slope", popup); box->AddChild(menu_field); label = new BStringView(BRect(5, 96, 97, 115), "", "Hold off"); box->AddChild(label); the_slider = new TSliderView(BRect(98, 100, 188, 118), "hold_off", 0.0, hold_off_callback, this); box->AddChild(the_slider); } BCheckBox *check_box = new BCheckBox(BRect(SCOPE_WIDTH + 10, 234, SCOPE_WIDTH + 190, 254), "illumination", "Illumination", new BMessage(MSG_ILLUMINATION)); top->AddChild(check_box); Unlock(); // Create drawing looper the_looper = new DrawLooper(main_view, the_bitmap); // Create stream objects dac_stream = new BDACStream(); adc_stream = new BADCStream(); // Create subscriber and attach it to the stream the_subscriber = new QScopeSubscriber(the_looper); the_subscriber->Enter(dac_stream); // Show the window Show(); }
ChatWindow::ChatWindow(entry_ref & ref) : BWindow( BRect(100,100,400,300), "unknown contact - unknown status", B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_AVOID_FOCUS ), fEntry(ref), fMan( new IM::Manager(BMessenger(this))), fChangedNotActivated(false), fStatusBar(NULL), fSendButton(NULL), fProtocolHack(NULL) { bool command, sendButton; int32 iconBarSize; BMessage chatSettings; im_load_client_settings("im_emoclient", &chatSettings); if ( chatSettings.FindBool("command_sends", &command) != B_OK ) command = true; if ( chatSettings.FindBool("show_send_button", &sendButton) != B_OK ) sendButton = true; if ( chatSettings.FindInt32("icon_size", &iconBarSize) != B_OK ) iconBarSize = kLargeIcon; if ( iconBarSize <= 0 ) iconBarSize = kLargeIcon; if (chatSettings.FindString("people_handler", &fPeopleHandler) != B_OK) { fPeopleHandler = kDefaultPeopleHandler; }; if (chatSettings.FindString("other", &fOtherText) != B_OK ) { fOtherText.SetTo( "$name$ ($nickname$) ($protocol$) "); } // Set window size limits SetSizeLimits( 220, 8000, // width, 150, 8000 // height ); // get the size of various things font_height height; be_plain_font->GetHeight(&height); fFontHeight = height.ascent + height.descent + height.leading; // default window size BRect windowRect(100, 100, 400, 300); BPoint inputDivider(0, 150); // load window size if possible if (LoadSettings() == B_OK) { bool was_ok = true; if (fWindowSettings.FindRect("windowrect", &windowRect) != B_OK) { was_ok = false; } if (fWindowSettings.FindPoint("inputdivider", &inputDivider) != B_OK) { was_ok = false; } if ( !was_ok ) { windowRect = BRect(100, 100, 400, 300); inputDivider = BPoint(0, 200); } } // sanity check for divider location if ( inputDivider.y > windowRect.Height() - 50 ) { LOG("im_emoclient", liLow, "Insane divider, fixed."); inputDivider.y = windowRect.Height() - 50; }; // set size and position MoveTo(windowRect.left, windowRect.top); ResizeTo(windowRect.Width(), windowRect.Height()); // create views BRect textRect = Bounds(); BRect inputRect = Bounds(); BRect dockRect = Bounds(); dockRect.bottom = iconBarSize + kDockPadding; fDock = new IconBar(dockRect); #if B_BEOS_VERSION > B_BEOS_VERSION_5 fDock->SetViewUIColor(B_UI_PANEL_BACKGROUND_COLOR); fDock->SetLowUIColor(B_UI_PANEL_BACKGROUND_COLOR); fDock->SetHighUIColor(B_UI_PANEL_TEXT_COLOR); #else fDock->SetViewColor( ui_color(B_PANEL_BACKGROUND_COLOR) ); fDock->SetLowColor( ui_color(B_PANEL_BACKGROUND_COLOR) ); fDock->SetHighColor(0, 0, 0, 0); #endif AddChild(fDock); // add buttons ImageButton * btn; BBitmap * icon; // long err = 0; BPath iconDir; BPath iconPath; BRect buttonRect(0,0,iconBarSize+8,iconBarSize+8); find_directory(B_USER_SETTINGS_DIRECTORY, &iconDir, true); iconDir.Append("im_kit/icons"); // People Button icon = IconForHandler(fPeopleHandler.String(), iconBarSize); btn = MakeButton(icon, "Show contact in People", new BMessage(SHOW_INFO), buttonRect); fDock->AddItem(btn); // Email button icon = IconForHandler("text/x-email", iconBarSize); btn = MakeButton(icon, "Send email to contact", new BMessage(EMAIL), buttonRect); fDock->AddItem(btn); // Block Button iconPath = iconDir; iconPath.Append("Block"); icon = ReadNodeIcon(iconPath.Path(), iconBarSize, true); btn = MakeButton(icon, "Block messages from contact", new BMessage(BLOCK), buttonRect); fDock->AddItem(btn); // Log Button icon = IconForHandler("application/x-vnd.BeClan.im_binlog_viewer", iconBarSize); btn = MakeButton(icon, "View chat history for contact", new BMessage(VIEW_LOG), buttonRect); fDock->AddItem(btn); // Webpage Button icon = IconForHandler("text/html", iconBarSize); btn = MakeButton(icon, "View contact's web page", new BMessage(VIEW_WEBPAGE), buttonRect); fDock->AddItem(btn); // Emoticons iconPath = iconDir; iconPath.Append("emoticons"); icon = ReadNodeIcon(iconPath.Path(), iconBarSize); btn = MakeButton(icon, "Emoticons", new BMessage(VIEW_EMOTICONS), buttonRect); fDock->AddItem(btn); textRect.top = fDock->Bounds().bottom+1; textRect.InsetBy(2,2); textRect.bottom = inputDivider.y; textRect.right -= B_V_SCROLL_BAR_WIDTH; float sendButtonWidth = sendButton ? 50 : 0; inputRect.InsetBy(2.0, 2.0); inputRect.top = inputDivider.y + 7; inputRect.right -= B_V_SCROLL_BAR_WIDTH + sendButtonWidth; inputRect.bottom -= fFontHeight + (kPadding * 4); BRect inputTextRect = inputRect; inputTextRect.OffsetTo(kPadding, kPadding); inputTextRect.InsetBy(kPadding * 2, kPadding * 2); fInput = new BTextView(inputRect, "input", inputTextRect, B_FOLLOW_ALL, B_WILL_DRAW); #if B_BEOS_VERSION > B_BEOS_VERSION_5 fInput->SetViewUIColor(B_UI_DOCUMENT_BACKGROUND_COLOR); fInput->SetLowUIColor(B_UI_DOCUMENT_BACKGROUND_COLOR); fInput->SetHighUIColor(B_UI_DOCUMENT_TEXT_COLOR); #else fInput->SetViewColor(245, 245, 245, 0); fInput->SetLowColor(245, 245, 245, 0); fInput->SetHighColor(0, 0, 0, 0); #endif fInputScroll = new BScrollView( "input_scroller", fInput, B_FOLLOW_LEFT_RIGHT | B_FOLLOW_BOTTOM, 0, false, true, B_PLAIN_BORDER ); AddChild(fInputScroll); fInput->SetWordWrap(true); fInput->SetStylable(false); fInput->MakeSelectable(true); if ( sendButton ) { BRect sendRect = fInputScroll->Frame(); sendRect.left = sendRect.right+1; sendRect.right = Bounds().right; fSendButton = new BButton( sendRect, "sendButton", _T("Send"), new BMessage(SEND_MESSAGE), B_FOLLOW_RIGHT|B_FOLLOW_BOTTOM ); AddChild( fSendButton ); } BRect statusRect = Bounds(); statusRect.top = inputRect.bottom + kPadding; fStatusBar = new StatusBar(statusRect); AddChild(fStatusBar); #if B_BEOS_VERSION > B_BEOS_VERSION_5 fStatusBar->SetViewUIColor(B_UI_PANEL_BACKGROUND_COLOR); fStatusBar->SetLowUIColor(B_UI_PANEL_BACKGROUND_COLOR); fStatusBar->SetHighUIColor(B_UI_PANEL_TEXT_COLOR); #else fStatusBar->SetViewColor(245, 245, 245, 0); fStatusBar->SetLowColor(245, 245, 245, 0); fStatusBar->SetHighColor(0, 0, 0, 0); #endif BPopUpMenu *pop = new BPopUpMenu("Protocols", true, true); fProtocolMenu = new BMenuField( BRect(kPadding, kPadding, Bounds().bottom - kPadding, 100), "Field", NULL, pop); fStatusBar->AddItem(fProtocolMenu); // fInfoView must be the LAST thing added to fStatusBar, otherwise the // resizing of it will be all bonkers. fInfoView = new BStringView(BRect(fProtocolMenu->Frame().right+5, 2, fStatusBar->Bounds().right - kPadding, fStatusBar->Bounds().bottom - kPadding), "infoView", "", B_FOLLOW_LEFT_RIGHT | B_FOLLOW_BOTTOM, B_WILL_DRAW); fStatusBar->AddItem(fInfoView); #if B_BEOS_VERSION > B_BEOS_VERSION_5 fInfoView->SetViewUIColor(B_UI_PANEL_BACKGROUND_COLOR); fInfoView->SetLowUIColor(B_UI_PANEL_BACKGROUND_COLOR); fInfoView->SetHighUIColor(B_UI_PANEL_TEXT_COLOR); #else fInfoView->SetViewColor(245, 245, 245, 0); fInfoView->SetLowColor(245, 245, 245, 0); fInfoView->SetHighColor(0, 0, 0, 0); #endif // need to build the menu here since it fiddles with fInfoView BuildProtocolMenu(); BMenuItem *first = pop->ItemAt(0); if (first) first->SetMarked(true); BRect resizeRect = Bounds(); resizeRect.top = inputDivider.y + 1; resizeRect.bottom = inputDivider.y + 4; fResize = new ResizeView(fInputScroll, resizeRect, "resizer", B_FOLLOW_BOTTOM | B_FOLLOW_LEFT_RIGHT); AddChild(fResize); Theme::TimestampFore = C_TIMESTAMP_DUMMY; Theme::TimestampBack = C_TIMESTAMP_DUMMY; Theme::TimespaceFore = MAX_COLORS; Theme::TimespaceBack = MAX_COLORS; Theme::TimespaceFont = MAX_FONTS; Theme::TimestampFont = F_TIMESTAMP_DUMMY; Theme::NormalFore = C_TEXT; Theme::NormalBack = C_TEXT; Theme::NormalFont = F_TEXT; Theme::SelectionBack = C_SELECTION; fTheme = new Theme("ChatWindow", MAX_COLORS + 1, MAX_COLORS + 1, MAX_FONTS + 1); //NormalTextRender *ntr=new NormalTextRender(be_plain_font); fTheme->WriteLock(); fTheme->SetForeground(C_URL, 5, 5, 150); fTheme->SetBackground(C_URL, 255, 255, 255); //fTheme->SetTextRender(C_URL, ntr); fTheme->SetForeground(C_TIMESTAMP, 130, 130, 130); fTheme->SetBackground(C_TIMESTAMP, 255, 255, 255); //fTheme->SetTextRender(F_TIMESTAMP, ntr); fTheme->SetForeground(C_TEXT, 0, 0, 0); fTheme->SetBackground(C_TEXT, 255, 255, 255); //fTheme->SetTextRender(F_TEXT, ntr); fTheme->SetForeground(C_ACTION, 0, 0, 0); fTheme->SetBackground(C_ACTION, 255, 255, 255); //fTheme->SetTextRender(F_ACTION, ntr); fTheme->SetForeground(C_SELECTION, 255, 255, 255); fTheme->SetBackground(C_SELECTION, 0, 0, 0); fTheme->SetForeground(C_OWNNICK, 0, 0, 255); fTheme->SetBackground(C_OWNNICK, 255, 255, 255); fTheme->SetForeground(C_OTHERNICK, 255, 0, 0); fTheme->SetBackground(C_OTHERNICK, 255, 255, 255); //SmileTextRender *str=new SmileTextRender(); fTheme->SetTextRender(F_EMOTICON,&str); fTheme->WriteUnlock(); // IM::Contact con(&fEntry); // char id[256]; // con.ConnectionAt(0, id); fText = ((ChatApp *)be_app)->GetRunView(/*id*/ fEntry); if (fText == NULL) { fText = new RunView( textRect, "text", fTheme, B_FOLLOW_ALL, B_WILL_DRAW ); #if B_BEOS_VERSION > B_BEOS_VERSION_5 fText->SetViewUIColor(B_UI_DOCUMENT_BACKGROUND_COLOR); fText->SetLowUIColor(B_UI_DOCUMENT_BACKGROUND_COLOR); fText->SetHighUIColor(B_UI_DOCUMENT_TEXT_COLOR); #else fText->SetViewColor(245, 245, 245, 0); fText->SetLowColor(245, 245, 245, 0); fText->SetHighColor(0, 0, 0, 0); #endif fText->SetTimeStampFormat(NULL); }; fTextScroll = new BScrollView( "scroller", fText, B_FOLLOW_ALL, 0, false, // horiz true, // vert B_PLAIN_BORDER ); AddChild(fTextScroll); fTextScroll->MoveTo(0,fDock->Bounds().bottom+1); if ( fText->IsHidden() ) fText->Show(); fText->ScrollToBottom(); fInput->MakeFocus(); // add input filter that generates "user typing" messages and routes copy-commands fFilter = new InputFilter(fInput, new BMessage(SEND_MESSAGE), command, fText, kTypingSendRate); fInput->AddFilter((BMessageFilter *)fFilter); // monitor node so we get updates to status etc BEntry entry(&ref); node_ref node; entry.GetNodeRef(&node); watch_node( &node, B_WATCH_ALL, BMessenger(this) ); // get contact info reloadContact(); // set up timer for clearing typing view fTypingTimer = NULL; fTypingTimerSelf = NULL; // this message runner needed to fix a BMenuField bug. BMessage protoHack(PROTOCOL_SELECTED2); fProtocolHack = new BMessageRunner( BMessenger(this), &protoHack, 10000, 1 ); }
TemplateWindow::TemplateWindow(const BRect& frame) : BWindow(frame, TR("Choose a project type"), B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS) { RegisterWindow(); CheckTemplates(); DPath templatePath(gAppPath.GetFolder()); templatePath << TR("Templates"); fTempList.ScanFolder(templatePath.GetFullPath()); // project type BPopUpMenu* projectTypeMenu = new BPopUpMenu("Project type"); for (int32 i = 0; i < fTempList.CountTemplates(); i++) { ProjectTemplate* ptemp = fTempList.TemplateAt(i); entry_ref ref = ptemp->GetRef(); projectTypeMenu->AddItem(new BMenuItem(ref.name, new BMessage(M_TEMPLATE_SELECTED))); } projectTypeMenu->ItemAt(0L)->SetMarked(true); fTemplateField = new BMenuField("templatefield", TR("Project type: "), projectTypeMenu); fTemplateField->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); // project name fNameBox = new AutoTextControl("namebox", TR("Project name:"), "", new BMessage(M_NAME_CHANGED)); SetToolTip(fNameBox, TR("The name of your project. " "It can be the same as the Target name, but it does not have to be.")); // target name fTargetBox = new AutoTextControl("targetbox", TR("Target name:"), "BeApp", new BMessage(M_TARGET_CHANGED)); SetToolTip(fTargetBox, TR("The name of the compiled application or library")); // project path fPathBox = new PathBox("pathbox", gProjectPath.GetFullPath(), ""); fPathBox->SetExplicitMinSize(BSize(be_plain_font->StringWidth("M") * 36, B_SIZE_UNSET)), SetToolTip(fPathBox, TR("Set the location for your project.")); // source control BPopUpMenu* scmMenu = new BPopUpMenu("SCM Chooser"); scmMenu->AddItem(new BMenuItem(TR("Mercurial"), new BMessage())); scmMenu->AddItem(new BMenuItem(TR("Git"), new BMessage())); scmMenu->AddItem(new BMenuItem(TR("Subversion"), new BMessage())); scmMenu->AddItem(new BMenuItem(TR("None"), new BMessage())); if (!gHgAvailable) { scmMenu->ItemAt(0)->SetEnabled(false); scmMenu->ItemAt(0)->SetLabel(TR("Mercurial unavailable")); } if (!gGitAvailable) { scmMenu->ItemAt(1)->SetEnabled(false); scmMenu->ItemAt(1)->SetLabel(TR("Git unavailable")); } if (!gSvnAvailable) { scmMenu->ItemAt(2)->SetEnabled(false); scmMenu->ItemAt(2)->SetLabel(TR("Subversion unavailable")); } fSCMChooser = new BMenuField("scmchooser", TR("Source control: "), scmMenu); fSCMChooser->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); SetToolTip(fSCMChooser, TR("Choose the source control manager for your project, if any.")); scmMenu->ItemAt(gDefaultSCM)->SetMarked(true); BMenuItem* item = scmMenu->FindMarked(); if (!item->IsEnabled()) { item->SetMarked(false); for (int32 i = 0; i < scmMenu->CountItems(); i++) { if (scmMenu->ItemAt(i)->IsEnabled()) { scmMenu->ItemAt(i)->SetMarked(true); break; } } } // create folder check box fCreateFolder = new BCheckBox(TR("Create project folder")); fCreateFolder->SetValue(B_CONTROL_ON); SetToolTip(fCreateFolder, TR("If checked, a folder for your project will be created " "in the folder in the Location box above.")); // create project button fCreateProjectButton = new BButton("ok", TR("Create project") B_UTF8_ELLIPSIS, new BMessage(M_CREATE_PROJECT)); fCreateProjectButton->SetEnabled(false); fCreateProjectButton->MakeDefault(true); // layout BLayoutBuilder::Group<>(this, B_VERTICAL) .AddGrid(B_USE_DEFAULT_SPACING, B_USE_SMALL_SPACING) .Add(fTemplateField->CreateLabelLayoutItem(), 0, 0) .AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING, 1, 0) .Add(fTemplateField->CreateMenuBarLayoutItem()) .AddGlue() .End() .Add(fNameBox->CreateLabelLayoutItem(), 0, 1) .Add(fNameBox->CreateTextViewLayoutItem(), 1, 1) .Add(fTargetBox->CreateLabelLayoutItem(), 0, 2) .Add(fTargetBox->CreateTextViewLayoutItem(), 1, 2) .Add(new BStringView("location", TR("Location:")), 0, 3) .Add(fPathBox, 1, 3) .Add(fSCMChooser->CreateLabelLayoutItem(), 0, 4) .AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING, 1, 4) .Add(fSCMChooser->CreateMenuBarLayoutItem()) .AddGlue() .End() .Add(fCreateFolder, 1, 5) .End() .AddGlue() .AddGroup(B_HORIZONTAL) .AddGlue() .Add(fCreateProjectButton) .End() .SetInsets(B_USE_DEFAULT_SPACING) .End(); fNameBox->MakeFocus(true); CenterOnScreen(); }
/*! \brief Updates targets of all controls currently in the view. * \details BView::AttachToWindow(), among other things, modifies the targets * of controls to point to main looper of the application. This is * not desirable way. This function corrects it. */ void CalendarModulePreferencesView::UpdateTargetting( void ) { BCheckBox* tempCheckBox = NULL; int i, limit; // Updating calendar chooser part BMenuItem* menuItem = NULL; if ( calendarModules ) { limit = calendarModules->CountItems(); for ( i = 0; i < limit; ++i ) { menuItem = dynamic_cast< BMenuItem* >( calendarModules->ItemAt( i ) ); if ( menuItem ) menuItem->SetTarget( this ); } } // Update Weekends selector box BBox* tempBBox = ( BBox* )this->FindView( "Weekend selector" ); if ( tempBBox ) { limit = tempBBox->CountChildren(); for ( i = 0; i < limit; ++i ) { tempCheckBox = dynamic_cast< BCheckBox* >( tempBBox->ChildAt( i ) ); if ( tempCheckBox ) tempCheckBox->SetTarget( this ); } } // Update First day of week chooser BPopUpMenu* tempMenu = ( BPopUpMenu* )this->FindView( "First day of week" ); if ( tempMenu ) { limit = tempMenu->CountItems(); for ( i = 0; i < limit; ++i ) { menuItem = dynamic_cast< BMenuItem* >( tempMenu->ItemAt( i ) ); if ( menuItem ) menuItem->SetTarget( this ); } } // Update day-month-year order chooser tempMenu = ( BPopUpMenu* )this->FindView( "DmyOrderChooser" ); if ( tempMenu ) { limit = tempMenu->CountItems(); for ( i = 0; i < limit; ++i ) { menuItem = dynamic_cast< BMenuItem* >( tempMenu->ItemAt( i ) ); if ( menuItem ) menuItem->SetTarget( this ); } } // Update the target of Color selector CategoryListView* catListView = ( CategoryListView* )this->FindView("Colors list view"); if ( catListView ) { catListView->SetTarget( this ); } } // <-- end of function CalendarModulePreferencesView::UpdateTargetting
/*! * \brief Create a menu to select the module user is setting up. * \note This is an internal function. */ BPopUpMenu* CalendarModulePreferencesView::PopulateModulesMenu( void ) { BPopUpMenu* toReturn = NULL; BMenuItem* toAdd = NULL; BMessage* toSend = NULL; BString moduleId; // Note: this is not a pointer! CalendarModule* currentCalModule = NULL; toReturn = new BPopUpMenu("Calendar Modules"); if ( ! toReturn ) { /* Panic! */ exit (1); } // Looping on all calendar modules available in the system. for ( uint i=0; i < NUMBER_OF_CALENDAR_MODULES; ++i ) { // Obtain the next calendar module currentCalModule = (CalendarModule *)global_ListOfCalendarModules.ItemAt( i ); if ( !currentCalModule ) { continue; // Skipping unavailable ones } // Create the message toSend = new BMessage( kCalendarModuleChosen ); if ( !toSend ) { /* Panic! */ exit(1); } // Add the ID of the module to the message moduleId = currentCalModule->Identify(); toSend->AddString( "Module ID", moduleId ); // Create the menu item toAdd = new BMenuItem( moduleId.String(), toSend ); if ( ! toAdd ) { /* Panic! */ exit(1); } toAdd->SetTarget( this ); // Add the newly created item to the menu toReturn->AddItem( toAdd ); // Gregorian calendar module is the default one if ( moduleId == "Gregorian" ) { toAdd->SetMarked( true ); } } /* <-- end of "for ( every calendar module )" */ // At least something should be marked. if ( ( ! toReturn->FindMarked() ) && ( toReturn->CountItems() > 0 ) ) { toReturn->ItemAt( 0 )->SetMarked( true ); } return toReturn; } // <-- end of function "CalendarModulePreferencesView::PopulateModulesMenu"
RatePackageWindow::RatePackageWindow(BWindow* parent, BRect frame, Model& model) : BWindow(frame, B_TRANSLATE("Rate package"), B_FLOATING_WINDOW_LOOK, B_FLOATING_SUBSET_WINDOW_FEEL, B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS), fModel(model), fRatingText(), fTextEditor(new TextEditor(), true), fRating(-1.0f), fCommentLanguage(fModel.PreferredLanguage()), fWorkerThread(-1) { AddToSubset(parent); BStringView* ratingLabel = new BStringView("rating label", B_TRANSLATE("Your rating:")); fSetRatingView = new SetRatingView(); fTextView = new TextDocumentView(); ScrollView* textScrollView = new ScrollView( "rating scroll view", fTextView); // Get a TextDocument with default paragraph and character style MarkupParser parser; fRatingText = parser.CreateDocumentFromMarkup(""); fTextView->SetInsets(10.0f); fTextView->SetTextDocument(fRatingText); fTextView->SetTextEditor(fTextEditor); // Construct stability rating popup BPopUpMenu* stabilityMenu = new BPopUpMenu(B_TRANSLATE("Stability")); fStabilityField = new BMenuField("stability", B_TRANSLATE("Stability:"), stabilityMenu); fStabilityCodes.Add(StabilityRating( B_TRANSLATE("Not specified"), "unspecified")); fStabilityCodes.Add(StabilityRating( B_TRANSLATE("Stable"), "stable")); fStabilityCodes.Add(StabilityRating( B_TRANSLATE("Mostly stable"), "mostlystable")); fStabilityCodes.Add(StabilityRating( B_TRANSLATE("Unstable but usable"), "unstablebutusable")); fStabilityCodes.Add(StabilityRating( B_TRANSLATE("Very unstable"), "veryunstable")); fStabilityCodes.Add(StabilityRating( B_TRANSLATE("Does not start"), "nostart")); add_stabilities_to_menu(fStabilityCodes, stabilityMenu); stabilityMenu->SetTargetForItems(this); fStability = fStabilityCodes.ItemAt(0).Name(); stabilityMenu->ItemAt(0)->SetMarked(true); // Construct languages popup BPopUpMenu* languagesMenu = new BPopUpMenu(B_TRANSLATE("Language")); fCommentLanguageField = new BMenuField("language", B_TRANSLATE("Comment language:"), languagesMenu); add_languages_to_menu(fModel.SupportedLanguages(), languagesMenu); languagesMenu->SetTargetForItems(this); BMenuItem* defaultItem = languagesMenu->ItemAt( fModel.SupportedLanguages().IndexOf(fCommentLanguage)); if (defaultItem != NULL) defaultItem->SetMarked(true); fRatingActiveCheckBox = new BCheckBox("rating active", B_TRANSLATE("Other users can see this rating"), new BMessage(MSG_RATING_ACTIVE_CHANGED)); // Hide the check mark by default, it will be made visible when // the user already made a rating and it is loaded fRatingActiveCheckBox->Hide(); // Construct buttons fCancelButton = new BButton("cancel", B_TRANSLATE("Cancel"), new BMessage(B_QUIT_REQUESTED)); fSendButton = new BButton("send", B_TRANSLATE("Send"), new BMessage(MSG_SEND)); // Build layout BLayoutBuilder::Group<>(this, B_VERTICAL) .AddGrid() .Add(ratingLabel, 0, 0) .Add(fSetRatingView, 1, 0) .AddMenuField(fStabilityField, 0, 1) .AddMenuField(fCommentLanguageField, 0, 2) .End() .Add(textScrollView) .AddGroup(B_HORIZONTAL) .Add(fRatingActiveCheckBox) .AddGlue() .Add(fCancelButton) .Add(fSendButton) .End() .SetInsets(B_USE_WINDOW_INSETS) ; // NOTE: Do not make Send the default button. The user might want // to type line-breaks instead of sending when hitting RETURN. CenterIn(parent->Frame()); }
void TestView::MessageReceived(BMessage *msg) { switch (msg->what) { case M_TEST_CHOSEN: { SetTest(msg); break; } case M_MODE_CHOSEN: { BString mode; if (msg->FindString("mode",&mode) != B_OK) break; SetMode(mode.String()); break; } case M_VALUE_CHANGED: { BString str; if (fTest->FindString("value",&str) == B_OK) fTest->ReplaceString("value",fValueBox->Text()); else fTest->AddString("value",fValueBox->Text()); break; } case M_SHOW_TEST_MENU: { BPopUpMenu *menu = (BPopUpMenu*)BPopUpMenu::Instantiate(&fArchivedTestMenu); menu->SetTargetForItems(this); for (int32 i = 0; i < menu->CountItems(); i++) { BMenuItem *item = menu->ItemAt(i); if (item->Submenu()) item->Submenu()->SetTargetForItems(this); } BPoint pt; uint32 buttons; GetMouse(&pt,&buttons); ConvertToScreen(&pt); pt.x -= 10.0; if (pt.x < 0.0) pt.x = 0.0; pt.y -= 10.0; if (pt.y < 0.0) pt.y = 0.0; menu->SetAsyncAutoDestruct(true); menu->Go(pt,true,true,true); break; } case M_SHOW_TYPE_MENU: { BPopUpMenu *menu = (BPopUpMenu*)BPopUpMenu::Instantiate(&gArchivedTypeMenu); menu->SetTargetForItems(this); for (int32 i = 0; i < menu->CountItems(); i++) { BMenuItem *item = menu->ItemAt(i); if (item->Submenu()) item->Submenu()->SetTargetForItems(this); } BPoint pt; uint32 buttons; GetMouse(&pt,&buttons); ConvertToScreen(&pt); pt.x -= 10.0; if (pt.x < 0.0) pt.x = 0.0; pt.y -= 10.0; if (pt.y < 0.0) pt.y = 0.0; menu->SetAsyncAutoDestruct(true); menu->Go(pt,true,true,true); break; } case M_SHOW_MODE_MENU: { ShowModeMenu(); break; } default: { BView::MessageReceived(msg); break; } } }