void HWindow::Pulse() { HEventRow* row = (HEventRow*)fEventList->CurrentSelection(); BMenuField* menufield = dynamic_cast<BMenuField*>(FindView("filemenu")); BButton* button = dynamic_cast<BButton*>(FindView("play")); BButton* stop = dynamic_cast<BButton*>(FindView("stop")); if (menufield == NULL || button == NULL || stop == NULL) return; if (row != NULL) { menufield->SetEnabled(true); const char* path = row->Path(); if (path != NULL && strcmp(path, "")) button->SetEnabled(true); else button->SetEnabled(false); } else { menufield->SetEnabled(false); button->SetEnabled(false); } if (fPlayer != NULL) { if (fPlayer->IsPlaying()) stop->SetEnabled(true); else stop->SetEnabled(false); } else stop->SetEnabled(false); }
void _EndpointList::SelectionChanged() { inherited::SelectionChanged(); _EndpointRow* row = dynamic_cast<_EndpointRow*>( CurrentSelection() ); if (row && row->mIsValid) { row->SelectionSetup(this); if (mDeviceTarget && !mDeviceTarget->IsEnabled() ) mDeviceTarget->SetEnabled(true); if (mLabelTarget && !mLabelTarget->IsEnabled() ) mLabelTarget->SetEnabled(true); } else { if (mDeviceTarget && mDeviceTarget->IsEnabled() ) mDeviceTarget->SetEnabled(false); if (mLabelTarget && mLabelTarget->IsEnabled() ) mLabelTarget->SetEnabled(false); } }
virtual void Visit(BStringContactField* field) { int count = fOwner->fControls.CountItems(); BGridLayout* layout = fOwner->GridLayout(); if (field->FieldType() != B_CONTACT_SIMPLE_GROUP) { ContactFieldTextControl* control = new ContactFieldTextControl(field); layout->AddItem(control->CreateLabelLayoutItem(), 1, count); layout->AddItem(control->CreateTextViewLayoutItem(), 2, count); fOwner->fControls.AddItem(control); } else { const char* label = BContactField::ExtendedLabel(field); fOwner->fGroups = new BPopUpMenu(label); fOwner->fGroups->SetRadioMode(false); fOwner->BuildGroupMenu(field); BMenuField* field = new BMenuField("", "", fOwner->fGroups); BTextControl* control = new BTextControl("simpleGroup", NULL, NULL, NULL); field->SetEnabled(true); layout->AddItem(field->CreateLabelLayoutItem(), 1, 0, count); layout->AddItem(field->CreateMenuBarLayoutItem(), 1, 1, count); layout->AddItem(control->CreateLabelLayoutItem(), 2, 0, count); layout->AddItem(control->CreateTextViewLayoutItem(), 2, 1, count); } }
// -------------------------------------------------------------- NetworkSetupWindow::NetworkSetupWindow(const char *title) : BWindow(BRect(100, 100, 300, 300), title, B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS), fAddonCount(0) { // ---- Profiles section BMenu *profilesPopup = new BPopUpMenu("<none>"); _BuildProfilesMenu(profilesPopup, kMsgProfileSelected); BMenuField *profilesMenuField = new BMenuField("profiles_menu", B_TRANSLATE("Profile:"), profilesPopup); profilesMenuField->SetFont(be_bold_font); profilesMenuField->SetEnabled(false); // ---- Settings section fPanel = new BTabView("showview_box"); fApplyButton = new BButton("apply", B_TRANSLATE("Apply"), new BMessage(kMsgApply)); SetDefaultButton(fApplyButton); fRevertButton = new BButton("revert", B_TRANSLATE("Revert"), new BMessage(kMsgRevert)); // fRevertButton->SetEnabled(false); // Enable boxes resizing modes //fPanel->SetResizingMode(B_FOLLOW_ALL); // Build the layout SetLayout(new BGroupLayout(B_VERTICAL)); AddChild(BGroupLayoutBuilder(B_VERTICAL, B_USE_SMALL_SPACING) .AddGroup(B_HORIZONTAL, B_USE_SMALL_SPACING) .Add(profilesMenuField) .AddGlue() .End() .Add(fPanel) .AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING) .Add(fRevertButton) .AddGlue() .Add(fApplyButton) .End() .SetInsets(B_USE_SMALL_SPACING, B_USE_SMALL_SPACING, B_USE_SMALL_SPACING, B_USE_SMALL_SPACING) ); _BuildShowTabView(kMsgAddonShow); fPanel->SetExplicitMinSize(BSize(fMinAddonViewRect.Width(), fMinAddonViewRect.Height())); fAddonView = NULL; CenterOnScreen(); }
OpenGLView::OpenGLView() : BGroupView("OpenGLView", B_VERTICAL) { BGLView* glView = new BGLView(BRect(0, 0, 1, 1), "gl info", B_FOLLOW_NONE, 0, BGL_RGB | BGL_DOUBLE); glView->Hide(); AddChild(glView); glView->LockGL(); BMenu* menu = new BMenu(B_TRANSLATE("Automatic")); menu->SetRadioMode(true); menu->SetLabelFromMarked(true); menu->AddItem(new BMenuItem(B_TRANSLATE("Automatic"), new BMessage(MENU_AUTO_MESSAGE))); menu->AddSeparatorItem(); menu->AddItem(new BMenuItem(B_TRANSLATE("Software Rasterizer"), new BMessage(MENU_SWRAST_MESSAGE))); menu->AddItem(new BMenuItem(B_TRANSLATE("Gallium Software Pipe"), new BMessage(MENU_SWPIPE_MESSAGE))); menu->AddItem(new BMenuItem(B_TRANSLATE("Gallium LLVM Pipe"), new BMessage(MENU_SWLLVM_MESSAGE))); BMenuField* menuField = new BMenuField("renderer", B_TRANSLATE("3D Rendering Engine:"), menu); // TODO: Set current Renderer menuField->SetEnabled(false); BTabView *tabView = new BTabView("tab view", B_WIDTH_FROM_LABEL); tabView->AddTab(new InfoView()); tabView->AddTab(new CapabilitiesView()); tabView->AddTab(new ExtensionsView()); glView->UnlockGL(); GroupLayout()->SetSpacing(0); BLayoutBuilder::Group<>(this) .SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING) .Add(menuField) .AddGroup(B_HORIZONTAL) .Add(tabView) .SetInsets(0, B_USE_DEFAULT_SPACING, 0, 0); }
void PersonView::AddAttribute(const char* label, const char* attribute) { // Check if this attribute has already been added. AttributeTextControl* control = NULL; for (int32 i = fControls.CountItems() - 1; i >= 0; i--) { if (fControls.ItemAt(i)->Attribute() == attribute) { return; } } control = new AttributeTextControl(label, attribute); fControls.AddItem(control); BGridLayout* layout = GridLayout(); int32 row = fControls.CountItems(); if (fCategoryAttribute == attribute) { // Special case the category attribute. The Group popup field will // be added as the label instead. fGroups = new BPopUpMenu(label); fGroups->SetRadioMode(false); BuildGroupMenu(); BMenuField* field = new BMenuField("", "", fGroups); field->SetEnabled(true); layout->AddView(field, 1, row); control->SetLabel(""); layout->AddView(control, 2, row); } else { layout->AddItem(control->CreateLabelLayoutItem(), 1, row); layout->AddItem(control->CreateTextViewLayoutItem(), 2, row); } SetAttribute(attribute, true); }
THeaderView::THeaderView(BRect rect, BRect windowRect, bool incoming, bool resending, uint32 defaultCharacterSet, int32 defaultAccount) : BBox(rect, "m_header", B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW, B_NO_BORDER), fAccountMenu(NULL), fEncodingMenu(NULL), fAccountID(defaultAccount), fAccountTo(NULL), fAccount(NULL), fBcc(NULL), fCc(NULL), fSubject(NULL), fTo(NULL), fDateLabel(NULL), fDate(NULL), fIncoming(incoming), fCharacterSetUserSees(defaultCharacterSet), fResending(resending), fBccMenu(NULL), fCcMenu(NULL), fToMenu(NULL), fEmailList(NULL) { BMenuField* field; BMessage* msg; float x = StringWidth( /* The longest title string in the header area */ B_TRANSLATE("Attachments: ")) + 9; float y = TO_FIELD_V; BMenuBar* dummy = new BMenuBar(BRect(0, 0, 100, 15), "Dummy"); AddChild(dummy); float width, menuBarHeight; dummy->GetPreferredSize(&width, &menuBarHeight); dummy->RemoveSelf(); delete dummy; float menuFieldHeight = menuBarHeight + 6; float controlHeight = menuBarHeight + floorf(be_plain_font->Size() / 1.15); if (!fIncoming) { InitEmailCompletion(); InitGroupCompletion(); } // Prepare the character set selection pop-up menu (we tell the user that // it is the Encoding menu, even though it is really the character set). // It may appear in the first line, to the right of the From box if the // user is reading an e-mail. It appears on the second line, to the right // of the e-mail account menu, if the user is composing a message. It lets // the user quickly select a character set different from the application // wide default one, and also shows them which character set is active. If // you are reading a message, you also see an item that says "Automatic" // for automatic decoding character set choice. It can slide around as the // window is resized when viewing a message, but not when composing // (because the adjacent pop-up menu can't resize dynamically due to a BeOS // bug). float widestCharacterSet = 0; bool markedCharSet = false; BMenuItem* item; fEncodingMenu = new BPopUpMenu(B_EMPTY_STRING); BCharacterSetRoster roster; BCharacterSet charset; while (roster.GetNextCharacterSet(&charset) == B_OK) { BString name(charset.GetPrintName()); const char* mime = charset.GetMIMEName(); if (mime) name << " (" << mime << ")"; uint32 convertID; if (mime == NULL || strcasecmp(mime, "UTF-8") != 0) convertID = charset.GetConversionID(); else convertID = B_MAIL_UTF8_CONVERSION; msg = new BMessage(kMsgEncoding); msg->AddInt32("charset", convertID); fEncodingMenu->AddItem(item = new BMenuItem(name.String(), msg)); if (convertID == fCharacterSetUserSees && !markedCharSet) { item->SetMarked(true); markedCharSet = true; } if (StringWidth(name.String()) > widestCharacterSet) widestCharacterSet = StringWidth(name.String()); } msg = new BMessage(kMsgEncoding); msg->AddInt32("charset", B_MAIL_US_ASCII_CONVERSION); fEncodingMenu->AddItem(item = new BMenuItem("US-ASCII", msg)); if (fCharacterSetUserSees == B_MAIL_US_ASCII_CONVERSION && !markedCharSet) { item->SetMarked(true); markedCharSet = true; } if (!resending && fIncoming) { // reading a message, display the Automatic item fEncodingMenu->AddSeparatorItem(); msg = new BMessage(kMsgEncoding); msg->AddInt32("charset", B_MAIL_NULL_CONVERSION); fEncodingMenu->AddItem(item = new BMenuItem(B_TRANSLATE("Automatic"), msg)); if (!markedCharSet) item->SetMarked(true); } // First line of the header, From for reading e-mails (includes the // character set choice at the right), To when composing (nothing else in // the row). BRect r; char string[20]; if (fIncoming && !resending) { // Set up the character set pop-up menu on the right of "To" box. r.Set (windowRect.Width() - widestCharacterSet - StringWidth (B_TRANSLATE("Decoding:")) - 2 * SEPARATOR_MARGIN, y - 2, windowRect.Width() - SEPARATOR_MARGIN, y + menuFieldHeight); field = new BMenuField (r, "decoding", B_TRANSLATE("Decoding:"), fEncodingMenu, true /* fixedSize */, B_FOLLOW_TOP | B_FOLLOW_RIGHT, B_WILL_DRAW | B_NAVIGABLE | B_NAVIGABLE_JUMP); field->SetDivider(field->StringWidth(B_TRANSLATE("Decoding:")) + 5); AddChild(field); r.Set(SEPARATOR_MARGIN, y, field->Frame().left - SEPARATOR_MARGIN, y + menuFieldHeight); sprintf(string, B_TRANSLATE("From:")); } else { r.Set(x - 12, y, windowRect.Width() - SEPARATOR_MARGIN, y + menuFieldHeight); string[0] = 0; } y += controlHeight; fTo = new TTextControl(r, string, new BMessage(TO_FIELD), fIncoming, resending, B_FOLLOW_LEFT_RIGHT); fTo->SetFilter(mail_to_filter); if (!fIncoming || resending) { fTo->SetChoiceList(&fEmailList); fTo->SetAutoComplete(true); } else { fTo->SetDivider(x - 12 - SEPARATOR_MARGIN); fTo->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT); } AddChild(fTo); msg = new BMessage(FIELD_CHANGED); msg->AddInt32("bitmask", FIELD_TO); fTo->SetModificationMessage(msg); if (!fIncoming || resending) { r.right = r.left - 5; r.left = r.right - ceilf(be_plain_font->StringWidth( B_TRANSLATE("To:")) + 25); r.top -= 1; fToMenu = new QPopupMenu(B_TRANSLATE("To:")); field = new BMenuField(r, "", "", fToMenu, true, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW); field->SetDivider(0.0); field->SetEnabled(true); AddChild(field); } // "From:" accounts Menu and Encoding Menu. if (!fIncoming || resending) { // Put the character set box on the right of the From field. r.Set(windowRect.Width() - widestCharacterSet - StringWidth(B_TRANSLATE("Encoding:")) - 2 * SEPARATOR_MARGIN, y - 2, windowRect.Width() - SEPARATOR_MARGIN, y + menuFieldHeight); BMenuField* encodingField = new BMenuField(r, "encoding", B_TRANSLATE("Encoding:"), fEncodingMenu, true /* fixedSize */, B_FOLLOW_TOP | B_FOLLOW_RIGHT, B_WILL_DRAW | B_NAVIGABLE | B_NAVIGABLE_JUMP); encodingField->SetDivider(encodingField->StringWidth( B_TRANSLATE("Encoding:")) + 5); AddChild(encodingField); field = encodingField; // And now the "from account" pop-up menu, on the left side, taking the // remaining space. fAccountMenu = new BPopUpMenu(B_EMPTY_STRING); BMailAccounts accounts; bool marked = false; for (int32 i = 0; i < accounts.CountAccounts(); i++) { BMailAccountSettings* account = accounts.AccountAt(i); BString name = account->Name(); name << ": " << account->RealName() << " <" << account->ReturnAddress() << ">"; msg = new BMessage(kMsgFrom); BMenuItem *item = new BMenuItem(name, msg); msg->AddInt32("id", account->AccountID()); if (defaultAccount == account->AccountID()) { item->SetMarked(true); marked = true; } fAccountMenu->AddItem(item); } if (!marked) { BMenuItem *item = fAccountMenu->ItemAt(0); if (item != NULL) { item->SetMarked(true); fAccountID = item->Message()->FindInt32("id"); } else { fAccountMenu->AddItem( item = new BMenuItem(B_TRANSLATE("<none>"), NULL)); item->SetEnabled(false); fAccountID = ~0UL; } // default account is invalid, set to marked // TODO: do this differently, no casting and knowledge // of TMailApp here.... if (TMailApp* app = dynamic_cast<TMailApp*>(be_app)) app->SetDefaultAccount(fAccountID); } r.Set(SEPARATOR_MARGIN, y - 2, field->Frame().left - SEPARATOR_MARGIN, y + menuFieldHeight); field = new BMenuField(r, "account", B_TRANSLATE("From:"), fAccountMenu, true /* fixedSize */, B_FOLLOW_TOP | B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW | B_NAVIGABLE | B_NAVIGABLE_JUMP); AddChild(field, encodingField); field->SetDivider(x - 12 - SEPARATOR_MARGIN + kMenuFieldDividerOffset); field->SetAlignment(B_ALIGN_RIGHT); y += controlHeight; } else { // To: account bool account = BMailAccounts().CountAccounts() > 0; r.Set(SEPARATOR_MARGIN, y, windowRect.Width() - SEPARATOR_MARGIN, y + menuFieldHeight); if (account) r.right -= SEPARATOR_MARGIN + ACCOUNT_FIELD_WIDTH; fAccountTo = new TTextControl(r, B_TRANSLATE("To:"), NULL, fIncoming, false, B_FOLLOW_LEFT_RIGHT); fAccountTo->SetEnabled(false); fAccountTo->SetDivider(x - 12 - SEPARATOR_MARGIN); fAccountTo->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT); AddChild(fAccountTo); if (account) { r.left = r.right + 6; r.right = windowRect.Width() - SEPARATOR_MARGIN; fAccount = new TTextControl(r, B_TRANSLATE("Account:"), NULL, fIncoming, false, B_FOLLOW_RIGHT | B_FOLLOW_TOP); fAccount->SetEnabled(false); AddChild(fAccount); } y += controlHeight; } if (fIncoming) { --y; r.Set(SEPARATOR_MARGIN, y, windowRect.Width() - SEPARATOR_MARGIN, y + menuFieldHeight); y += controlHeight; fCc = new TTextControl(r, B_TRANSLATE("Cc:"), NULL, fIncoming, false, B_FOLLOW_LEFT_RIGHT); fCc->SetEnabled(false); fCc->SetDivider(x - 12 - SEPARATOR_MARGIN); fCc->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT); AddChild(fCc); } --y; r.Set(SEPARATOR_MARGIN, y, windowRect.Width() - SEPARATOR_MARGIN, y + menuFieldHeight); y += controlHeight; fSubject = new TTextControl(r, B_TRANSLATE("Subject:"), new BMessage(SUBJECT_FIELD),fIncoming, false, B_FOLLOW_LEFT_RIGHT); AddChild(fSubject); (msg = new BMessage(FIELD_CHANGED))->AddInt32("bitmask", FIELD_SUBJECT); fSubject->SetModificationMessage(msg); fSubject->SetDivider(x - 12 - SEPARATOR_MARGIN); fSubject->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT); if (fResending) fSubject->SetEnabled(false); --y; if (!fIncoming) { r.Set(x - 12, y, CC_FIELD_H + CC_FIELD_WIDTH, y + menuFieldHeight); fCc = new TTextControl(r, "", new BMessage(CC_FIELD), fIncoming, false); fCc->SetFilter(mail_to_filter); fCc->SetChoiceList(&fEmailList); fCc->SetAutoComplete(true); AddChild(fCc); (msg = new BMessage(FIELD_CHANGED))->AddInt32("bitmask", FIELD_CC); fCc->SetModificationMessage(msg); r.right = r.left - 5; r.left = r.right - ceilf(be_plain_font->StringWidth( B_TRANSLATE("Cc:")) + 25); r.top -= 1; fCcMenu = new QPopupMenu(B_TRANSLATE("Cc:")); field = new BMenuField(r, "", "", fCcMenu, true, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW); field->SetDivider(0.0); field->SetEnabled(true); AddChild(field); r.Set(BCC_FIELD_H + be_plain_font->StringWidth(B_TRANSLATE("Bcc:")), y, windowRect.Width() - SEPARATOR_MARGIN, y + menuFieldHeight); y += controlHeight; fBcc = new TTextControl(r, "", new BMessage(BCC_FIELD), fIncoming, false, B_FOLLOW_LEFT_RIGHT); fBcc->SetFilter(mail_to_filter); fBcc->SetChoiceList(&fEmailList); fBcc->SetAutoComplete(true); AddChild(fBcc); (msg = new BMessage(FIELD_CHANGED))->AddInt32("bitmask", FIELD_BCC); fBcc->SetModificationMessage(msg); r.right = r.left - 5; r.left = r.right - ceilf(be_plain_font->StringWidth( B_TRANSLATE("Bcc:")) + 25); r.top -= 1; fBccMenu = new QPopupMenu(B_TRANSLATE("Bcc:")); field = new BMenuField(r, "", "", fBccMenu, true, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW); field->SetDivider(0.0); field->SetEnabled(true); AddChild(field); } else { y -= SEPARATOR_MARGIN; r.Set(SEPARATOR_MARGIN, y, x - 12 - 1, y + menuFieldHeight); fDateLabel = new BStringView(r, "", kDateLabel); fDateLabel->SetAlignment(B_ALIGN_RIGHT); AddChild(fDateLabel); fDateLabel->SetHighColor(0, 0, 0); r.Set(r.right + 9, y, windowRect.Width() - SEPARATOR_MARGIN, y + menuFieldHeight); fDate = new BStringView(r, "", ""); AddChild(fDate); fDate->SetHighColor(0, 0, 0); y += controlHeight + 5; } ResizeTo(Bounds().Width(), y); }
void HWindow::MessageReceived(BMessage* message) { switch (message->what) { case M_OTHER_MESSAGE: { BMenuField* menufield = dynamic_cast<BMenuField*>(FindView("filemenu")); if (menufield == NULL) return; BMenu* menu = menufield->Menu(); HEventRow* row = (HEventRow*)fEventList->CurrentSelection(); if (row != NULL) { BPath path(row->Path()); if (path.InitCheck() != B_OK) { BMenuItem* item = menu->FindItem(B_TRANSLATE("<none>")); if (item != NULL) item->SetMarked(true); } else { BMenuItem* item = menu->FindItem(path.Leaf()); if (item != NULL) item->SetMarked(true); } } fFilePanel->Show(); break; } case B_SIMPLE_DATA: case B_REFS_RECEIVED: { entry_ref ref; HEventRow* row = (HEventRow*)fEventList->CurrentSelection(); if (message->FindRef("refs", &ref) == B_OK && row != NULL) { BMenuField* menufield = dynamic_cast<BMenuField*>(FindView("filemenu")); if (menufield == NULL) return; BMenu* menu = menufield->Menu(); // check audio file BNode node(&ref); BNodeInfo ninfo(&node); char type[B_MIME_TYPE_LENGTH + 1]; ninfo.GetType(type); BMimeType mtype(type); BMimeType superType; mtype.GetSupertype(&superType); if (superType.Type() == NULL || strcmp(superType.Type(), "audio") != 0) { beep(); BAlert* alert = new BAlert("", B_TRANSLATE("This is not an audio file."), B_TRANSLATE("OK"), NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->Go(); break; } // add file item BMessage* msg = new BMessage(M_ITEM_MESSAGE); BPath path(&ref); msg->AddRef("refs", &ref); BMenuItem* menuitem = menu->FindItem(path.Leaf()); if (menuitem == NULL) menu->AddItem(menuitem = new BMenuItem(path.Leaf(), msg), 0); // refresh item fEventList->SetPath(BPath(&ref).Path()); // check file menu if (menuitem != NULL) menuitem->SetMarked(true); } break; } case M_PLAY_MESSAGE: { HEventRow* row = (HEventRow*)fEventList->CurrentSelection(); if (row != NULL) { const char* path = row->Path(); if (path != NULL) { entry_ref ref; ::get_ref_for_path(path, &ref); delete fPlayer; fPlayer = new BFileGameSound(&ref, false); fPlayer->StartPlaying(); } } break; } case M_STOP_MESSAGE: { if (fPlayer == NULL) break; if (fPlayer->IsPlaying()) { fPlayer->StopPlaying(); delete fPlayer; fPlayer = NULL; } break; } case M_EVENT_CHANGED: { const char* path; BMenuField* menufield = dynamic_cast<BMenuField*>(FindView("filemenu")); if (menufield == NULL) return; BMenu* menu = menufield->Menu(); if (message->FindString("path", &path) == B_OK) { BPath path(path); if (path.InitCheck() != B_OK) { BMenuItem* item = menu->FindItem(B_TRANSLATE("<none>")); if (item != NULL) item->SetMarked(true); } else { BMenuItem* item = menu->FindItem(path.Leaf()); if (item != NULL) item->SetMarked(true); } HEventRow* row = (HEventRow*)fEventList->CurrentSelection(); BButton* button = dynamic_cast<BButton*>(FindView("play")); if (row != NULL) { menufield->SetEnabled(true); const char* path = row->Path(); if (path != NULL && strcmp(path, "")) button->SetEnabled(true); else button->SetEnabled(false); } else { menufield->SetEnabled(false); button->SetEnabled(false); } } break; } case M_ITEM_MESSAGE: { entry_ref ref; if (message->FindRef("refs", &ref) == B_OK) { fEventList->SetPath(BPath(&ref).Path()); _UpdateZoomLimits(); } break; } case M_NONE_MESSAGE: { fEventList->SetPath(NULL); break; } default: BWindow::MessageReceived(message); } }
NetworkWindow::NetworkWindow() : BWindow(BRect(100, 100, 400, 400), B_TRANSLATE("Network"), B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS), fServicesItem(NULL), fDialUpItem(NULL), fOtherItem(NULL) { // Profiles section #if ENABLE_PROFILES BPopUpMenu* profilesPopup = new BPopUpMenu("<none>"); _BuildProfilesMenu(profilesPopup, kMsgProfileSelected); BMenuField* profilesMenuField = new BMenuField("profiles_menu", B_TRANSLATE("Profile:"), profilesPopup); profilesMenuField->SetFont(be_bold_font); profilesMenuField->SetEnabled(false); #endif // Settings section fRevertButton = new BButton("revert", B_TRANSLATE("Revert"), new BMessage(kMsgRevert)); BMessage* message = new BMessage(kMsgToggleReplicant); BCheckBox* showReplicantCheckBox = new BCheckBox("showReplicantCheckBox", B_TRANSLATE("Show network status in Deskbar"), message); showReplicantCheckBox->SetExplicitMaxSize( BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET)); showReplicantCheckBox->SetValue(_IsReplicantInstalled()); fListView = new BOutlineListView("list", B_SINGLE_SELECTION_LIST, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE | B_FRAME_EVENTS | B_NAVIGABLE); fListView->SetSelectionMessage(new BMessage(kMsgItemSelected)); BScrollView* scrollView = new BScrollView("ScrollView", fListView, 0, false, true); scrollView->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET)); fAddOnShellView = new BView("add-on shell", 0, new BGroupLayout(B_VERTICAL)); fAddOnShellView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); fInterfaceView = new InterfaceView(); // Build the layout BLayoutBuilder::Group<>(this, B_VERTICAL) .SetInsets(B_USE_DEFAULT_SPACING) #if ENABLE_PROFILES .AddGroup(B_HORIZONTAL, B_USE_SMALL_SPACING) .Add(profilesMenuField) .AddGlue() .End() #endif .AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING) .Add(scrollView) .Add(fAddOnShellView) .End() .Add(showReplicantCheckBox) .AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING) .Add(fRevertButton) .AddGlue() .End(); gNetworkWindow = this; _ScanInterfaces(); _ScanAddOns(); _UpdateRevertButton(); fListView->Select(0); _SelectItem(fListView->ItemAt(0)); // Call this manually, so that CenterOnScreen() below already // knows the final window size. // Set size of the list view from its contents float width; float height; fListView->GetPreferredSize(&width, &height); width += 2 * be_control_look->DefaultItemSpacing(); fListView->SetExplicitSize(BSize(width, B_SIZE_UNSET)); fListView->SetExplicitMinSize(BSize(width, std::min(height, 400.f))); CenterOnScreen(); fSettings.StartMonitoring(this); start_watching_network(B_WATCH_NETWORK_INTERFACE_CHANGES | B_WATCH_NETWORK_LINK_CHANGES | B_WATCH_NETWORK_WLAN_CHANGES, this); }
void CharismaWindow::update_proxy_settings() { const long sroffsets[]={ 0, 0, 0, 0, 0, 3600, 3600*6, 3600*12, 0, 3600*24, 3600*24*2, 3600*24*3, 0, 3600*24*7, 3600*24*14, 0, 3600*24*30, 3600*24*30*2, 3600*24*30*6, 0, 3600*24*365, 3600*24*365*2, 0, 3600*24*365*10 }; BMenu *m; int i; struct system_info sinfo; // g_mode m=modemenu->Menu(); g_mode=m->IndexOf(m->FindMarked()); smartrefresh->SetEnabled(g_mode==k_online); // g_extcontrol g_extcontrol=extcontrol_item->IsMarked(); // g_refreshdate m=smartrefresh->Menu(); i=m->IndexOf(m->FindMarked()); switch(i){ case 0: // dumb g_refreshdate=0; break; case 2: // always g_refreshdate=LONG_MAX; break; case 3: // once per session get_system_info(&sinfo); g_refreshdate=sinfo.boot_time/1000000; break; case 23: // never g_refreshdate=-2; break; default: g_refreshdate=-sroffsets[i]; // il faut ajouter time(NULL) à cette valeur ! // (voir proxy.cpp) break; } }
/*********************************************************** * InitGUI ***********************************************************/ void HAddressView::InitGUI() { float divider = StringWidth(_("Subject:")) + 20; divider = max_c(divider , StringWidth(_("From:"))+20); divider = max_c(divider , StringWidth(_("To:"))+20); divider = max_c(divider , StringWidth(_("Bcc:"))+20); BRect rect = Bounds(); rect.top += 5; rect.left += 20 + divider; rect.right = Bounds().right - 5; rect.bottom = rect.top + 25; BTextControl *ctrl; ResourceUtils rutils; const char* name[] = {"to","subject","from","cc","bcc"}; for(int32 i = 0;i < 5;i++) { ctrl = new BTextControl(BRect(rect.left,rect.top ,(i == 1)?rect.right+divider:rect.right ,rect.bottom) ,name[i],"","",NULL ,B_FOLLOW_LEFT_RIGHT|B_FOLLOW_TOP,B_WILL_DRAW|B_NAVIGABLE); if(i == 1) { ctrl->SetLabel(_("Subject:")); ctrl->SetDivider(divider); ctrl->MoveBy(-divider,0); }else{ ctrl->SetDivider(0); } BMessage *msg = new BMessage(M_MODIFIED); msg->AddPointer("pointer",ctrl); ctrl->SetModificationMessage(msg); ctrl->SetEnabled(!fReadOnly); AddChild(ctrl); rect.OffsetBy(0,25); switch(i) { case 0: fTo = ctrl; break; case 1: fSubject = ctrl; break; case 2: fFrom = ctrl; fFrom->SetEnabled(false); fFrom->SetFlags(fFrom->Flags() & ~B_NAVIGABLE); break; case 3: fCc = ctrl; break; case 4: fBcc = ctrl; break; } } // BRect menuRect= Bounds(); menuRect.top += 5; menuRect.left += 22; menuRect.bottom = menuRect.top + 25; menuRect.right = menuRect.left + 16; BMenu *toMenu = new BMenu(_("To:")); BMenu *ccMenu = new BMenu(_("Cc:")); BMenu *bccMenu = new BMenu(_("Bcc:")); BQuery query; BVolume volume; BVolumeRoster().GetBootVolume(&volume); query.SetVolume(&volume); query.SetPredicate("((META:email=*)&&(BEOS:TYPE=application/x-person))"); if(!fReadOnly && query.Fetch() == B_OK) { BString addr[4],name,group,nick; entry_ref ref; BList peopleList; while(query.GetNextRef(&ref) == B_OK) { BNode node(&ref); if(node.InitCheck() != B_OK) continue; ReadNodeAttrString(&node,"META:name",&name); ReadNodeAttrString(&node,"META:email",&addr[0]); ReadNodeAttrString(&node,"META:email2",&addr[1]); ReadNodeAttrString(&node,"META:email3",&addr[2]); ReadNodeAttrString(&node,"META:email4",&addr[3]); ReadNodeAttrString(&node,"META:group",&group); ReadNodeAttrString(&node,"META:nickname",&nick); for(int32 i = 0;i < 4;i++) { if(addr[i].Length() > 0) { if(nick.Length() > 0) { nick += " <"; nick += addr[i]; nick += ">"; fAddrList.AddItem(strdup(nick.String())); } fAddrList.AddItem(strdup(addr[i].String())); BString title = name; title << " <" << addr[i] << ">"; AddPersonToList(peopleList,title.String(),group.String()); } } } // Sort people data peopleList.SortItems(HAddressView::SortPeople); // Build menus BTextControl *control[3] = {fTo,fCc,fBcc}; BMenu *menus[3] = {toMenu,ccMenu,bccMenu}; int32 count = peopleList.CountItems(); PersonData *data; bool needSeparator = false; bool hasSeparator = false; for(int32 k = 0;k < 3;k++) { for(int32 i = 0;i < count;i++) { BMessage *msg = new BMessage(M_ADDR_MSG); msg->AddPointer("pointer",control[k]); data = (PersonData*)peopleList.ItemAt(i); msg->AddString("email",data->email); if(needSeparator && !hasSeparator && strlen(data->group) == 0) { menus[k]->AddSeparatorItem(); hasSeparator = true; }else needSeparator = true; AddPerson(menus[k],data->email,data->group,msg,0,0); } hasSeparator = false; needSeparator = false; } // free all data while(count > 0) { data = (PersonData*)peopleList.RemoveItem(--count); free(data->email); free(data->group); delete data; } } BMenuField *field = new BMenuField(menuRect,"ToMenu","",toMenu, B_FOLLOW_TOP|B_FOLLOW_LEFT,B_WILL_DRAW); field->SetDivider(0); field->SetEnabled(!fReadOnly); AddChild(field); rect = menuRect; rect.OffsetBy(0,28); rect.left = Bounds().left + 5; rect.right = rect.left + 16; rect.top += 26; rect.bottom = rect.top + 16; ArrowButton *arrow = new ArrowButton(rect,"addr_arrow" ,new BMessage(M_EXPAND_ADDRESS)); AddChild(arrow); //==================== From menu BMenu *fromMenu = new BMenu(_("From:")); BPath path; ::find_directory(B_USER_SETTINGS_DIRECTORY,&path); path.Append(APP_NAME); path.Append("Accounts"); BDirectory dir(path.Path()); BEntry entry; status_t err = B_OK; int32 account_count = 0; while(err == B_OK) { if((err = dir.GetNextEntry(&entry)) == B_OK && !entry.IsDirectory()) { char name[B_FILE_NAME_LENGTH+1]; entry.GetName(name); BMessage *msg = new BMessage(M_ACCOUNT_CHANGE); msg->AddString("name",name); BMenuItem *item = new BMenuItem(name,msg); fromMenu->AddItem(item); item->SetTarget(this,Window()); account_count++; } } if(account_count != 0) { int32 smtp_account; ((HApp*)be_app)->Prefs()->GetData("smtp_account",&smtp_account); BMenuItem *item(NULL); if(account_count > smtp_account) item = fromMenu->ItemAt(smtp_account); if(!item) item = fromMenu->ItemAt(0); if(item) { ChangeAccount(item->Label()); item->SetMarked(true); } }else{ (new BAlert("",_("Could not find mail accounts"),_("OK"),NULL,NULL,B_WIDTH_AS_USUAL,B_INFO_ALERT))->Go(); Window()->PostMessage(B_QUIT_REQUESTED); } fromMenu->SetRadioMode(true); menuRect.OffsetBy(0,25*2); field = new BMenuField(menuRect,"FromMenu","",fromMenu, B_FOLLOW_TOP|B_FOLLOW_LEFT,B_WILL_DRAW); field->SetDivider(0); AddChild(field); //=================== CC menu menuRect.OffsetBy(0,25); field = new BMenuField(menuRect,"CcMenu","",ccMenu, B_FOLLOW_TOP|B_FOLLOW_LEFT,B_WILL_DRAW); field->SetDivider(0); field->SetEnabled(!fReadOnly); AddChild(field); //=================== BCC menu menuRect.OffsetBy(0,25); field = new BMenuField(menuRect,"BccMenu","",bccMenu, B_FOLLOW_TOP|B_FOLLOW_LEFT,B_WILL_DRAW); field->SetDivider(0); field->SetEnabled(!fReadOnly); AddChild(field); }