quadruplet<BTextControl*, BPopUpMenu*, BMenuField*, BStringView*> CheckView::MakeField(uint16 width, string name, uint16* xpos, uint16* ypos) { BStringView* sv = new BStringView(BRect((*xpos), (*ypos), (*xpos) + width, (*ypos) + 10), (name + "Text").c_str(), name.c_str()); BFont font; sv->GetFont(&font); font.SetSize(10); sv->SetFont(&font); AddChild(sv); BTextControl* tc = new BTextControl(BRect((*xpos) - 5, (*ypos) + 10, (*xpos) + width, (*ypos) + 10), (name + "Field").c_str(), "", "", 0); (*xpos) += width; tc->SetDivider(0); AddChild(tc); BPopUpMenu* pu = new BPopUpMenu("", true, false); BMenuField* mf = new BMenuField(BRect((*xpos) + 2, (*ypos) + 9, (*xpos) + 2, (*ypos) + 9), (name + "Menu").c_str(), "", pu); mf->SetDivider(0); AddChild(mf); (*xpos) += 30; return quadruplet<BTextControl*, BPopUpMenu*, BMenuField*, BStringView*>(tc, pu, mf, sv); }
/*********************************************************** * Constructor. ***********************************************************/ HAddTrackerWindow::HAddTrackerWindow(BRect rect,const char* name) :BWindow(rect,name,B_TITLED_WINDOW_LOOK,B_MODAL_APP_WINDOW_FEEL,B_NOT_RESIZABLE|B_NOT_ZOOMABLE|B_ASYNCHRONOUS_CONTROLS) { InitGUI(); BTextControl *control = cast_as(FindView("name"),BTextControl); control->MakeFocus(true); }
/** * @brief ファイルが選択されたときの処理 * @param[in] fileIndex どっちのファイルか * @param[in] message 選択されたパラメータを含むメッセージ */ void OpenFilesDialog::doFileSelected(OpenFilesDialog::FileIndex fileIndex, BMessage* message) { entry_ref ref; if (B_OK != message->FindRef("refs", &ref)) { return; } BPath path(&ref); const char* viewName; switch (fileIndex) { case LeftFile: viewName = NAME_LEFT_TEXT_CONTROL; break; case RightFile: viewName = NAME_RIGHT_TEXT_CONTROL; break; default: viewName = NULL; // ここには来ない break; } BTextControl* textControl = dynamic_cast<BTextControl*>(FindView(viewName)); if (NULL != textControl) { textControl->SetText(path.Path()); } }
/*********************************************************** * Set up GUIs. ***********************************************************/ void HAddTrackerWindow::InitGUI() { BView *view = new BView(Bounds(),"bgview",0,0); view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); BRect rect = Bounds(); rect.left += 20; rect.right -= 20; rect.top += 10; rect.bottom = rect.top + 20; BTextControl *control = new BTextControl(rect,"name","Name:","",new BMessage(M_END_NAME)); control->SetDivider(50); view->AddChild(control); rect.OffsetBy(0,30); control = new BTextControl(rect,"address","Address:","",NULL); control->SetDivider(50); view->AddChild(control); rect.OffsetBy(0,30); rect.left = rect.right - 70; BButton *btn = new BButton(rect,"ok","OK",new BMessage(M_OK_MSG)); view->AddChild(btn); rect.OffsetBy(-80,0); btn = new BButton(rect,"cancel","Cancel",new BMessage(B_QUIT_REQUESTED)); view->AddChild(btn); this->AddChild(view); }
void LprSetupView::AttachedToWindow() { float width = max(StringWidth(SERVER_TEXT), StringWidth(QUEUE_TEXT)) + 10; /* server name box */ // TODO remember previous value fServer = new BTextControl(SERVER_RECT, "", SERVER_TEXT, "192.168.0.0", NULL); AddChild(fServer); fServer->SetDivider(width); /* queue name box */ // TODO remember previous value fQueue = new BTextControl(QUEUE_RECT, "", QUEUE_TEXT, "LPT1_PASSTHRU", NULL); AddChild(fQueue); fQueue->SetDivider(width); /* cancel */ BButton *button = new BButton(CANCEL_RECT, "", CANCEL_TEXT, new BMessage(M_CANCEL)); AddChild(button); /* ok */ button = new BButton(OK_RECT, "", OK_TEXT, new BMessage(M_OK)); AddChild(button); button->MakeDefault(true); }
void SplitWindow::AddCat() { ResizeBy(0, 25); uint16 xpos = 20; uint16 width = 150; BTextControl* tc = new BTextControl(BRect(xpos - 5, ypos + 10, xpos + width, ypos + 10), "CatField", "", "", 0); xpos += width; tc->SetDivider(0); catTexts.push_back(tc); v->AddChild(tc); BPopUpMenu* pu = new BPopUpMenu("", true, false); BMenuField* mf = new BMenuField(BRect(xpos + 2, ypos + 9, xpos + 2, ypos + 9), "CatMenu", "", pu); mf->SetDivider(0); v->AddChild(mf); xpos += 30; tc = new BTextControl(BRect(xpos - 5, ypos + 10, xpos + 75, ypos + 10), "AmountField", "", "", 0); tc->SetDivider(0); tc->SetAlignment(B_ALIGN_LEFT, B_ALIGN_RIGHT); tc->SetModificationMessage(new BMessage(AmountModifiedMSG)); amtTexts.push_back(tc); v->AddChild(tc); ypos += 25; for (cas::iterator ci = catS->begin(); ci != catS->end(); ci++) { if ((*ci)->IsRoot()) { pu->AddItem(MakeCatMenu(*ci)); } } catnum++; }
void LoginAlert::MessageReceived(BMessage *message) { switch (message->what) { case 'ALTB': { int32 which; if (message->FindInt32("which", &which) < B_OK) break; // not 'Ok' if (which != 1) break; BMessage *m = new BMessage(*message); m->what = 'nsLO'; m->AddPointer("URL", fUrl); m->AddString("Host", fHost.String()); m->AddString("Realm", fRealm.String()); m->AddPointer("callback", (void *)fCallback); m->AddPointer("callback_pw", (void *)fCallbackPw); m->AddString("User", fUserControl->Text()); m->AddString("Pass", fPassControl->Text()); BString auth(fUserControl->Text()); auth << ":" << fPassControl->Text(); m->AddString("Auth", auth.String()); // notify the main thread // the event dispatcher will handle it nsbeos_pipe_message(m, NULL, NULL); } break; default: break; } BAlert::MessageReceived(message); }
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); } }
status_t AGMSBayesianSpamFilterConfig::Archive (BMessage *into, bool deep) const { status_t errorCode; float tempFloat; into->MakeEmpty(); errorCode = into->AddBool ("AddMarkerToSubject", fAddSpamToSubject); if (errorCode == B_OK) errorCode = into->AddBool ("AutoTraining", fAutoTraining); if (errorCode == B_OK) errorCode = into->AddBool ("QuitServerWhenFinished", fQuitServerWhenFinished); if (errorCode == B_OK) errorCode = into->AddBool ("NoWordsMeansSpam", fNoWordsMeansSpam); if (errorCode == B_OK) { tempFloat = fGenuineCutoffRatio; if (fGenuineCutoffRatioTextBoxPntr != NULL) tempFloat = atof (fGenuineCutoffRatioTextBoxPntr->Text()); errorCode = into->AddFloat ("GenuineCutoffRatio", tempFloat); } if (errorCode == B_OK) { tempFloat = fSpamCutoffRatio; if (fSpamCutoffRatioTextBoxPntr != NULL) tempFloat = atof (fSpamCutoffRatioTextBoxPntr->Text()); errorCode = into->AddFloat ("SpamCutoffRatio", tempFloat); } return errorCode; }
/* * Returns 0 if cancel was chose, otherwise * returns the game no * */ unsigned GameByID(int gameno /* default # */) { BTextView *T; BTextControl *tC; register int i; char buffer[256]; if (!gameno) gameno = 1; sprintf(buffer, "%d%c", gameno, 0); tC = new BTextControl( *(new BRect(10, 10, 20, 50)), "Game Number", buffer, NULL); T = tC->TextView(); /* * Make sure only #s can be entered */ for (i = 0; i < 256; i++) T->DisallowChar(i); for (i = '0'; i < '9' + 1; i++) T->AllowChar(i); AddChild(tC) Show(); // start running }
void SetupView::AttachedToWindow() { float width = MAX(StringWidth(SERVER_TEXT), StringWidth(QUEUE_TEXT)) + 10; /* server name box */ fServerAddress = new BTextControl(SERVER_RECT, "", SERVER_TEXT, "<printer's hostname or address>", NULL); AddChild(fServerAddress); fServerAddress->SetDivider(width); /* queue name box */ fQueuePort = new BTextControl(QUEUE_RECT, "", QUEUE_TEXT, "9100", NULL); // 9100 is default HP JetDirect port number AddChild(fQueuePort); fQueuePort->SetDivider(width); /* cancel */ BButton* button = new BButton(CANCEL_RECT, "", CANCEL_TEXT, new BMessage(M_CANCEL)); AddChild(button); /* ok */ button = new BButton(OK_RECT, "", OK_TEXT, new BMessage(M_OK)); AddChild(button); button->MakeDefault(true); }
filter_result DCCFileFilter::HandleButton (BMessage *) { filter_result result (B_DISPATCH_MESSAGE); BTextControl *paneltext (dynamic_cast<BTextControl *>( panel->Window()->FindView ("text view"))); if (paneltext) { BDirectory dir; struct stat s; entry_ref ref; BEntry entry; panel->GetPanelDirectory (&ref); dir.SetTo (&ref); if (entry.SetTo (&dir, paneltext->Text()) == B_NO_ERROR && entry.GetStat (&s) == B_NO_ERROR && S_ISREG (s.st_mode)) { if (vision_app->GetBool ("dccAutoAccept")) { BMessage msg (M_FILE_PANEL_ALERT); msg.AddInt32 ("which", 2); panel->Window()->PostMessage (&msg); result = B_SKIP_MESSAGE; } else { BString buffer; BAlert *alert; buffer << "The file \"" << paneltext->Text() << "\" already exists in the specified folder. " "Do you want to continue the transfer?"; alert = new BAlert ( "DCC Request", buffer.String(), "Cancel", "Replace", "Resume", B_WIDTH_AS_USUAL, B_OFFSET_SPACING, B_WARNING_ALERT); alert->Go (new BInvoker ( new BMessage (M_FILE_PANEL_ALERT), panel->Window())); result = B_SKIP_MESSAGE; } } } return result; }
const char* HDialog::GetText(const char *name) const { BTextControl *t = dynamic_cast<BTextControl *>(FindView(name)); if (t) return t->Text(); else return NULL; } /* HDialog::SetText */
void MimeTypeEditor::CommitChanges() { if (fPreviousText != fTextControl->Text()) { fEditor.Replace(0, (const uint8*)fTextControl->Text(), strlen(fTextControl->Text()) + 1); } }
void MainWindow::DoPriority() { BTextControl *PriorityValue = (BTextControl *)FindView("MainPriorityValue"); if (strcmp("", PriorityValue->Text())) { int32 value; value = atoi(PriorityValue->Text()); DoPriority(value); } }
SMTPConfigView::SMTPConfigView(MailAddonSettings& settings, BMailAccountSettings& accountSettings) : BMailProtocolConfigView(B_MAIL_PROTOCOL_HAS_AUTH_METHODS | B_MAIL_PROTOCOL_HAS_USERNAME | B_MAIL_PROTOCOL_HAS_PASSWORD | B_MAIL_PROTOCOL_HAS_HOSTNAME #ifdef USE_SSL | B_MAIL_PROTOCOL_HAS_FLAVORS #endif ) { #if defined(USE_SSL) || defined(B_COLLECTING_CATKEYS) static const char* kUnencryptedStr = B_TRANSLATE_MARK("Unencrypted"); static const char* kSSLStr = B_TRANSLATE_MARK("SSL"); static const char* kSTARTTLSStr = B_TRANSLATE_MARK("STARTTLS"); #endif #ifdef USE_SSL AddFlavor(B_TRANSLATE_NOCOLLECT(kUnencryptedStr)); AddFlavor(B_TRANSLATE(kSSLStr)); AddFlavor(B_TRANSLATE(kSTARTTLSStr)); #endif AddAuthMethod(B_TRANSLATE("None"), false); AddAuthMethod(B_TRANSLATE("ESMTP")); AddAuthMethod(B_TRANSLATE("POP3 before SMTP"), false); BTextControl *control = (BTextControl *)(FindView("host")); control->SetLabel(B_TRANSLATE("SMTP server:")); // Reset the dividers after changing one float widestLabel = 0; for (int32 i = CountChildren(); i-- > 0;) { if (BTextControl *text = dynamic_cast<BTextControl *>(ChildAt(i))) widestLabel = MAX(widestLabel,text->StringWidth(text->Label()) + 5); } for (int32 i = CountChildren(); i-- > 0;) { if (BTextControl *text = dynamic_cast<BTextControl *>(ChildAt(i))) text->SetDivider(widestLabel); } BMenuField *field = (BMenuField *)(FindView("auth_method")); field->SetDivider(widestLabel); SetTo(settings); fFileView = new BMailFileConfigView(B_TRANSLATE("Destination:"), "path", false, BPrivate::default_mail_out_directory().Path()); fFileView->SetTo(&settings.Settings(), NULL); AddChild(fFileView); float w, h; BMailProtocolConfigView::GetPreferredSize(&w, &h); fFileView->MoveBy(0, h - 10); GetPreferredSize(&w, &h); ResizeTo(w, h); }
BTextControl* PrintOptionsWindow::AddTextControl(const char* name, const char* label, float value, uint32 what) { BTextControl* text; text = new BTextControl(name, label, "", new BMessage(what)); text->SetModificationMessage(new BMessage(what)); SetValue(text, value); return text; }
void DocInfoWindow::_ReadFieldsFromTable(BMessage& docInfo) { docInfo.MakeEmpty(); BView* child; for (int32 i = 0; (child = fTable->ChildAt(i)) != NULL; i++) { BTextControl* textControl = dynamic_cast<BTextControl*>(child); if (textControl) docInfo.AddString(textControl->Label(), textControl->Text()); } }
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); } }
void TFilePanel::SetSaveText(const char* text) { if (text == NULL) return; BTextControl* textControl = dynamic_cast<BTextControl*>(FindView("text view")); if (textControl != NULL) { textControl->SetText(text); if (textControl->TextView() != NULL) textControl->TextView()->SelectAll(); } }
BFIV_PrefWin::BFIV_PrefWin(BRect frame) : BWindow(frame, "Preferences", B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, B_NOT_RESIZABLE|B_NOT_ZOOMABLE) { BRect rect = Bounds(); BView *back; BTextControl *scratchPath; BButton *cancelButton, *okButton, *selectButton; font_height fontHeight; float fontSize, tmp; // private data filePanel = NULL; // some font voodoo be_plain_font->GetHeight(&fontHeight); fontSize = fontHeight.ascent + fontHeight.descent; // the background back = new BView(rect, "background", B_FOLLOW_ALL, 0); back->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); AddChild(back); // the select button tmp = be_plain_font->StringWidth("Select"); rect.Set(frame.Width() - tmp - 20., 5., frame.Width() - 5., 5. + fontSize + 10.); selectButton = new BButton(rect, "select", "Select", new BMessage(SELECT_SCRATCH_PATH)); back->AddChild(selectButton); // the path rect.Set(5.,5., selectButton->Frame().left - 5., 5. + fontSize + 10.); scratchPath = new BTextControl(rect, "path", "Scratch Location", NULL, NULL, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW); back->AddChild(scratchPath); scratchPath->SetText(((BFIV_App *)be_app)->ScratchDirectory()); // current dir scratchPath->TextView()->MakeEditable(false); // only works after AddChild() (!!) // the ok button tmp = be_plain_font->StringWidth("OK"); rect.Set(frame.Width() - tmp - 35., Frame().Height() - fontSize - 20., frame.Width() - 10., Frame().Height() - 10.); okButton = new BButton(rect, "ok", "OK", new BMessage(APPLY_PREFS_CHANGE)); back->AddChild(okButton); okButton->MakeDefault(true); // the cancel button tmp = be_plain_font->StringWidth("Cancel"); rect.Set(okButton->Frame().left - tmp - 20., okButton->Frame().top, okButton->Frame().left - 5., okButton->Frame().bottom); cancelButton = new BButton(rect, "cancel", "Cancel", new BMessage(B_QUIT_REQUESTED)); back->AddChild(cancelButton); }
BTextControl* DocInfoWindow::_AddPasswordControl(BRect r, BView* panel, const char* name, const char* label) { BString text; _DocInfo()->FindString(name, &text); BTextControl* textControl = new BTextControl(r, name, label, "", NULL, B_FOLLOW_LEFT_RIGHT); panel->AddChild(textControl); textControl->ResizeToPreferred(); textControl->TextView()->HideTyping(true); textControl->TextView()->SetText(text.String()); return textControl; }
void RootView::AttachedToWindow() { SetViewColor( 216,216,216 ); mURLView->SetDivider( 40 ); mTopView->show(); AddChild( mURLView ); AddChild( mTopView ); AddChild( mStatusBar ); KHTMLPart *htmlPart = new KHTMLPart( mTopView, "khtmlpart" ); KHTMLView* pcView = htmlPart->view(); BRect rect = mTopView->Bounds(); pcView->SetResizingMode( B_FOLLOW_ALL ); pcView->MoveTo( rect.LeftTop() ); pcView->ResizeTo( rect.Width(), rect.Height() ); // pcView->MakeFocus( true ); pcView->SetTarget( BMessenger( Window() ) ); pcView->show(); BrowserWindow *bw = (BrowserWindow *)Window(); bw->SetPart( htmlPart ); bw->SetStatusBar( mStatusBar ); bw->SetURLView( mURLView ); }
void BrowserWindow::GoHistory( int nStep ) { // if ( nStep != 0 ) { // UpdateHistory(); // } m_nCurHistoryPos += nStep; HistoryEntry* pcCurrent = HistoryCurrent(); if ( pcCurrent != NULL ) { GlobalMutex::PushLooper( this ); m_pcHTMLPart->browserExtension()->restoreState( pcCurrent->m_cState ); m_pcURLView->Set( pcCurrent->m_cURL.c_str(), false ); GlobalMutex::PopLooper(); } if ( m_nCurHistoryPos == 0 ) { m_pcToolBar->EnableButton( BI_BACK, false ); } else { m_pcToolBar->EnableButton( BI_BACK, true ); } if ( m_nCurHistoryPos >= int(m_cHistory.size()) - 1 ) { m_pcToolBar->EnableButton( BI_FORWARD, false ); } else { m_pcToolBar->EnableButton( BI_FORWARD, true ); } }
void BrowserWindow::SetLocationBarURL( const std::string &/*cURL*/ ) { // m_pcURLView->Set( m_pcHTMLPart->url().prettyURL().utf8().data(), false ); m_pcURLView->SetText( m_pcHTMLPart->url().prettyURL().utf8().data() ); //?? m_pcURLView->SetText( cURL.c_str() ); // m_pcURLView->Set( cURL.c_str(), false ); }
BTextControl* DocInfoWindow::_AddFieldToTable(BRect rect, const char* name, const char* value) { BTextControl *textControl = new BTextControl(rect, name, name, value, NULL, B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW | B_NAVIGABLE); fTable->AddChild(textControl); float width, height; textControl->GetPreferredSize(&width, &height); textControl->ResizeTo(rect.Width(), height); textControl->SetDivider(rect.Width() / 2.0); fKeyList->AddItem(new BMenuItem(name, new BMessage(REMOVE_KEY_MSG))); return textControl; }
filter_result DCCFileFilter::HandleAlert (BMessage *msg) { BTextControl *text (dynamic_cast<BTextControl *>( panel->Window()->FindView ("text view"))); int32 which; msg->FindInt32 ("which", &which); if (which == 0 || text == 0) { return B_SKIP_MESSAGE; } entry_ref ref; panel->GetPanelDirectory (&ref); if (which == 2) { BDirectory dir (&ref); BFile file (&dir, text->Text(), B_READ_ONLY); BEntry entry (&dir, text->Text()); BPath path; off_t position; file.GetSize (&position); entry.GetPath (&path); send_msg.AddString ("path", path.Path()); send_msg.AddInt64 ("pos", position); send_msg.what = M_ADD_RESUME_DATA; } else { send_msg.AddRef ("directory", &ref); send_msg.AddString ("name", text->Text()); } panel->Messenger().SendMessage (&send_msg); BMessage cmsg (B_CANCEL); cmsg.AddPointer ("source", panel); panel->Messenger().SendMessage (&cmsg); return B_SKIP_MESSAGE; }
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 MimeTypeEditor::MessageReceived(BMessage *message) { switch (message->what) { case kMsgValueChanged: fEditor.Replace(0, (const uint8 *)fTextControl->Text(), strlen(fTextControl->Text()) + 1); break; case kMsgDataEditorUpdate: _UpdateText(); break; default: BView::MessageReceived(message); } }
void NumberEditor::AttachedToWindow() { fTextControl->SetTarget(this); fEditor.StartWatching(this); _UpdateText(); }