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 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); }
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); }
/*********************************************************** * 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); }
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); }
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 ); }
Window::Window() : BWindow(BRect(100, 100, 590, 260), "EventMask-Test", B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_NOT_RESIZABLE | B_NOT_ZOOMABLE) { BView* view = new BView(Bounds(), NULL, B_FOLLOW_ALL, B_WILL_DRAW); view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); AddChild(view); BTextControl* textControl = new BTextControl(BRect(10, 10, 290, 30), "text", "Type to test focus suspending:", "", NULL, B_FOLLOW_LEFT_RIGHT); textControl->SetDivider(textControl->StringWidth(textControl->Label()) + 8); view->AddChild(textControl); textControl = new BTextControl(BRect(300, 10, 420, 30), "all", "All keys:", "", NULL, B_FOLLOW_LEFT_RIGHT); textControl->SetDivider(textControl->StringWidth(textControl->Label()) + 8); view->AddChild(textControl); textControl->TextView()->SetEventMask(B_KEYBOARD_EVENTS, 0); BRect rect(10, 40, 120, 120); for (int32 i = 0; i < 4; i++) { uint32 options = 0; switch (i) { case 1: options = B_SUSPEND_VIEW_FOCUS; break; case 2: options = B_LOCK_WINDOW_FOCUS; break; case 3: options = B_SUSPEND_VIEW_FOCUS | B_LOCK_WINDOW_FOCUS; break; } fViews[i] = new PositionView(rect, options); view->AddChild(fViews[i]); rect.OffsetBy(120, 0); } BCheckBox* checkBox = new BCheckBox(BRect(10, 130, 200, 160), "permanent", "Get all pointer events", new BMessage(kMsgPointerEvents)); view->AddChild(checkBox); }
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; }
BView* PrefsWindow::constructGeneralBox(BRect frame) { BBox* generalBox = new BBox(frame); generalBox->SetLabel("General"); float offset = 30.0f, bwidth = 80.0f, bheight = 30.0f, bspacing = 10.0f, cbheight = 14.0f, adjust = 5.0f ; float controlX = (offset * 2.0f / 3.0f); BRect bubbleFrame = BRect(controlX, offset - adjust, offset + 150.0f, offset + cbheight - adjust); ColourButton *bubbleColourButton = new ColourButton(bubbleFrame, GetPrefsMessage(K_BUBBLE_COLOUR), ColourConstants::K_BLACK, "Tooltips"); generalBox->AddChild(bubbleColourButton); BRect recentDocsPathFrame(controlX, 50.0f, controlX + 150.0f, 70.0f); BCheckBox *showRecentDocsPath = new BCheckBox(recentDocsPathFrame, K_IS_RECENT_DOCS_SHOWN, "Show Path in Recent Docs", GetPrefsMessage(K_IS_RECENT_DOCS_SHOWN)); generalBox->AddChild(showRecentDocsPath); BRect isActivationFrame(controlX, 80.0f, controlX + 190.0f, 100.0f); BCheckBox *isActivationOk = new BCheckBox(isActivationFrame, K_IS_ACTIVATION_OK, "Activate Window on Opening Docs", GetPrefsMessage(K_IS_ACTIVATION_OK)); generalBox->AddChild(isActivationOk); BRect recentDocsFrame(controlX, 110.0f, controlX + 150.0f, 120.0f); BTextControl *numRecentDocs = new BTextControl(recentDocsFrame, K_NUM_RECENT_DOCS, "Number of Recent Docs", "", GetPrefsMessage(K_NUM_RECENT_DOCS)); numRecentDocs->SetDivider(120.0f); numRecentDocs->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT); generalBox->AddChild(numRecentDocs); BRect insertDateFrame(controlX, 140.0f, controlX + 200.0f, 150.0f); BTextControl *insertDateFlags = new BTextControl(insertDateFrame, K_DATE_FLAGS, "Insert Date Flags", "", GetPrefsMessage(K_DATE_FLAGS)); generalBox->AddChild(insertDateFlags); BRect generalRect = generalBox->Bounds(); BRect generalbtnRect(generalRect.right - bspacing - bwidth, generalRect.bottom - bspacing - bheight, generalRect.right - bspacing, generalRect.bottom - bspacing); BButton *resetGeneralDefaults = new BButton(generalbtnRect,"fResetGeneralDefaults","Defaults",new BMessage(PrefsConstants::K_PREFS_VIEW_RESET_GENERAL_DEFAULTS)); generalBox->AddChild(resetGeneralDefaults); return generalBox; }
void DocInfoWindow::FrameResized(float newWidth, float newHeight) { BTextControl *textControl = dynamic_cast<BTextControl*> (fTable->ChildAt(0)); if (textControl) { float width, height; textControl->GetPreferredSize(&width, &height); int32 count = fKeyList->CountItems(); float fieldsHeight = (height * count) + (2 * count); _AdjustScrollBar(height, fieldsHeight); while (textControl) { textControl->SetDivider(textControl->Bounds().Width() / 2.0); textControl = dynamic_cast<BTextControl*> (textControl->NextSibling()); } } }
void IppSetupView::AttachedToWindow() { /* url box */ url = new BTextControl(URL_RECT, "", URL_TEXT, "", NULL); AddChild(url); url->SetDivider(StringWidth(URL_TEXT) + 10); /* 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); }
IMAPConfig::IMAPConfig(BMessage *archive) : BMailProtocolConfigView(B_MAIL_PROTOCOL_HAS_USERNAME | B_MAIL_PROTOCOL_HAS_PASSWORD | B_MAIL_PROTOCOL_HAS_HOSTNAME | B_MAIL_PROTOCOL_CAN_LEAVE_MAIL_ON_SERVER #ifdef USE_SSL | B_MAIL_PROTOCOL_HAS_FLAVORS #endif ) { #ifdef USE_SSL AddFlavor("No encryption"); AddFlavor("SSL"); #endif SetTo(archive); ((BControl *)(FindView("leave_mail_remote")))->SetValue(B_CONTROL_ON); ((BControl *)(FindView("leave_mail_remote")))->Hide(); BRect frame = FindView("delete_remote_when_local")->Frame(); ((BControl *)(FindView("delete_remote_when_local")))->SetEnabled(true); ((BControl *)(FindView("delete_remote_when_local")))->MoveBy(0,-25); frame.right -= 10;// FindView("pass")->Frame().right; /*frame.top += 10; frame.bottom += 10;*/ BTextControl *folder = new BTextControl(frame,"root","Top mailbox folder: ","",NULL); folder->SetDivider(be_plain_font->StringWidth("Top mailbox folder: ")); if (archive->HasString("root")) folder->SetText(archive->FindString("root")); AddChild(folder); ResizeToPreferred(); }
CInfoDialog::CInfoDialog(BRect frame, const char *name, window_type type, int flags, BWindow *owner, BPositionIO* data) : HDialog(frame, name, type, flags, owner, data) { fDoc = dynamic_cast<PDoc*>(owner); FailNil(fDoc); SetText("name", owner->Title()); char s[32]; sprintf(s, "%d", fDoc->TextView()->Size()); SetText("docsize", s); sprintf(s, "%d", fDoc->TextView()->LineCount()); SetText("lines", s); BMenuField *mf = dynamic_cast<BMenuField*>(FindView("mime")); FailNil(mf); fTypes = mf->Menu(); const char *p; int i = 0; while ((p = gPrefs->GetIxPrefString(prf_X_Mimetype, i++)) != NULL) fTypes->AddItem(new BMenuItem(p, new BMessage(msg_FieldChanged))); if (i == 1) fTypes->AddItem(new BMenuItem("text/plain", new BMessage(msg_FieldChanged))); const char *mime = fDoc->MimeType(); if (mime && mime[0]) { for (i = 0; i < fTypes->CountItems(); i++) { BMenuItem *item = fTypes->ItemAt(i); if (strcmp(item->Label(), mime) == 0) { item->SetMarked(true); break; } } if (i == fTypes->CountItems()) { fTypes->AddSeparatorItem(); fTypes->AddItem(new BMenuItem(mime, new BMessage(msg_FieldChanged))); fTypes->ItemAt(fTypes->CountItems() - 1)->SetMarked(true); } } else { BMenuItem *item; fTypes->AddSeparatorItem(); fTypes->AddItem(item = new BMenuItem("<undefined>", new BMessage(msg_FieldChanged))); item->SetMarked(true); } if (fDoc->EntryRef()) { BNode node; FailOSErr(node.SetTo(fDoc->EntryRef())); time_t t; node.GetModificationTime(&t); char time[256]; strcpy(time, ctime(&t)); time[strlen(time) - 1] = 0; SetText("time", time); } else { //SetEnabled("mime", false); SetText("time", "Not Saved"); } mf = dynamic_cast<BMenuField*>(FindView("font")); FailNil(mf); fMenu = mf->Menu(); FailNil(fMenu); font_family ff; font_style fs; for (int i = 0; i < count_font_families(); i++) { get_font_family(i, &ff); BMenu *fontItem = new BMenu(ff); FailNil(fontItem); fMenu->AddItem(new BMenuItem(fontItem, new BMessage(msg_FieldChanged))); fontItem->SetFont(be_plain_font); for (int j = 0; j < count_font_styles(ff); j++) { get_font_style(ff, j, &fs); BMessage *msg = new BMessage(msg_FieldChanged); msg->AddString("family", ff); msg->AddString("style", fs); fontItem->AddItem(new BMenuItem(fs, msg)); } } fMenu->SetRadioMode(true); mf = dynamic_cast<BMenuField*>(FindView("encoding")); FailNil(mf); fEncoding = mf->Menu(); FailNil(fEncoding); fEncoding->SetRadioMode(true); mf = dynamic_cast<BMenuField*>(FindView("source encoding")); FailNil(mf); fSourceEncoding = mf->Menu(); FailNil(fSourceEncoding); fSourceEncoding->SetRadioMode(true); mf = dynamic_cast<BMenuField*>(FindView("linebreaks")); FailNil(mf); fLineBreaks = mf->Menu(); FailNil(fLineBreaks); fLineBreaks->SetRadioMode(true); BTextControl *tc = dynamic_cast<BTextControl*>(FindView("tabs")); if (tc) tc->SetDivider(be_plain_font->StringWidth(tc->Label()) + 4); BMenu *lang; mf = dynamic_cast<BMenuField*>(FindView("language")); FailNil(mf); lang = mf->Menu(); CLanguageInterface *intf; int cookie = 0; while ((intf = CLanguageInterface::NextIntf(cookie)) != NULL) lang->AddItem(new BMenuItem(intf->Name(), new BMessage(msg_FieldChanged))); lang->SetRadioMode(true); int curLang = fDoc->TextView()->Language(); SetValue("language", curLang >= 0 ? curLang + 3 : 1); CancelClicked(); } /* CInfoDialog::CInfoDialog */
void DocInfoWindow::_SetupDocInfoView(BBox* panel) { BRect bounds(panel->Bounds()); #if HAVE_FULLVERSION_PDF_LIB bounds.InsetBy(10.0, 10.0); #endif // add list of keys fKeyList = new BMenu("Delete Key"); BMenuField *menu = new BMenuField(bounds, "delete", "", fKeyList, B_FOLLOW_BOTTOM); panel->AddChild(menu); menu->SetDivider(0); #ifdef __HAIKU__ menu->ResizeToPreferred(); menu->MoveTo(bounds.left, bounds.bottom - menu->Bounds().Height()); #else menu->ResizeTo(menu->StringWidth("Delete Key") + 15.0, 25.0); menu->MoveTo(bounds.left, bounds.bottom - 25.0); #endif const char* title[6] = { "Title", "Author", "Subject", "Keywords", "Creator", NULL }; // PDFlib sets these: "Producer", "CreationDate", not "ModDate" BMenu* defaultKeys = new BMenu("Default Keys"); for (int32 i = 0; title[i] != NULL; ++i) defaultKeys->AddItem(new BMenuItem(title[i], new BMessage(DEFAULT_KEY_MSG))); BRect frame(menu->Frame()); menu = new BMenuField(frame, "add", "", defaultKeys, B_FOLLOW_BOTTOM); panel->AddChild(menu); menu->SetDivider(0); #ifdef __HAIKU__ menu->ResizeToPreferred(); menu->MoveBy(frame.Width() + 10.0, 0.0); #else menu->ResizeTo(menu->StringWidth("Default Keys") + 15.0, 25.0); menu->MoveBy(menu->Bounds().Width() + 10.0, 0.0); #endif frame = menu->Frame(); frame.left = frame.right + 10.0; frame.right = bounds.right; BTextControl *add = new BTextControl(frame, "add", "Add Key:", "", new BMessage(ADD_KEY_MSG), B_FOLLOW_LEFT_RIGHT | B_FOLLOW_BOTTOM); panel->AddChild(add); float width, height; add->GetPreferredSize(&width, &height); add->ResizeTo(bounds.right - frame.left, height); add->SetDivider(be_plain_font->StringWidth("Add Key: ")); bounds.bottom = frame.top - 10.0; bounds.right -= B_V_SCROLL_BAR_WIDTH; bounds.InsetBy(2.0, 2.0); fTable = new BView(bounds, "table", B_FOLLOW_ALL, B_WILL_DRAW); fTable->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); fTableScrollView = new BScrollView("scroll_table", fTable, B_FOLLOW_ALL, 0, false, true); panel->AddChild(fTableScrollView); BMessage docInfo; fDocInfo->FindMessage("doc_info", &docInfo); // fill table _BuildTable(docInfo); }
/*********************************************************** * 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); }
void AGMSBayesianSpamFilterConfig::AttachedToWindow () { char numberString [30]; BRect tempRect; char *tempStringPntr; SetViewColor (ui_color (B_PANEL_BACKGROUND_COLOR)); // Make the checkbox for choosing whether the spam is marked by a // modification to the subject of the mail message. tempRect = Bounds (); fAddSpamToSubjectCheckBoxPntr = new BCheckBox ( tempRect, "AddToSubject", "Add spam rating to start of subject", new BMessage (kAddSpamToSubjectPressed)); AddChild (fAddSpamToSubjectCheckBoxPntr); fAddSpamToSubjectCheckBoxPntr->ResizeToPreferred (); fAddSpamToSubjectCheckBoxPntr->SetValue (fAddSpamToSubject); fAddSpamToSubjectCheckBoxPntr->SetTarget (this); tempRect = Bounds (); tempRect.top = fAddSpamToSubjectCheckBoxPntr->Frame().bottom + 1; tempRect.bottom = tempRect.top + 20; // Add the checkbox on the right for the no words means spam option. fNoWordsMeansSpamCheckBoxPntr = new BCheckBox ( tempRect, "NoWordsMeansSpam", "or empty e-mail", new BMessage (kNoWordsMeansSpam)); AddChild (fNoWordsMeansSpamCheckBoxPntr); fNoWordsMeansSpamCheckBoxPntr->ResizeToPreferred (); fNoWordsMeansSpamCheckBoxPntr->MoveBy ( floorf (tempRect.right - fNoWordsMeansSpamCheckBoxPntr->Frame().right), 0.0); fNoWordsMeansSpamCheckBoxPntr->SetValue (fNoWordsMeansSpam); fNoWordsMeansSpamCheckBoxPntr->SetTarget (this); // Add the box displaying the spam cutoff ratio to the left, in the space // remaining between the left edge and the no words checkbox. tempRect.right = fNoWordsMeansSpamCheckBoxPntr->Frame().left - be_plain_font->StringWidth ("a"); tempStringPntr = "Spam above:"; sprintf (numberString, "%06.4f", (double) fSpamCutoffRatio); fSpamCutoffRatioTextBoxPntr = new BTextControl ( tempRect, "spamcutoffratio", tempStringPntr, numberString, NULL /* BMessage */); AddChild (fSpamCutoffRatioTextBoxPntr); fSpamCutoffRatioTextBoxPntr->SetDivider ( be_plain_font->StringWidth (tempStringPntr) + 1 * be_plain_font->StringWidth ("a")); tempRect = Bounds (); tempRect.top = fSpamCutoffRatioTextBoxPntr->Frame().bottom + 1; tempRect.bottom = tempRect.top + 20; // Add the box displaying the genuine cutoff ratio, on a line by itself. tempStringPntr = "Genuine below and uncertain above:"; sprintf (numberString, "%08.6f", (double) fGenuineCutoffRatio); fGenuineCutoffRatioTextBoxPntr = new BTextControl ( tempRect, "genuinecutoffratio", tempStringPntr, numberString, NULL /* BMessage */); AddChild (fGenuineCutoffRatioTextBoxPntr); fGenuineCutoffRatioTextBoxPntr->SetDivider ( be_plain_font->StringWidth (tempStringPntr) + 1 * be_plain_font->StringWidth ("a")); tempRect = Bounds (); tempRect.top = fGenuineCutoffRatioTextBoxPntr->Frame().bottom + 1; tempRect.bottom = tempRect.top + 20; // Checkbox for automatically training on incoming mail. fAutoTrainingCheckBoxPntr = new BCheckBox ( tempRect, "autoTraining", "Learn from all incoming e-mail", new BMessage (kAutoTrainingPressed)); AddChild (fAutoTrainingCheckBoxPntr); fAutoTrainingCheckBoxPntr->ResizeToPreferred (); fAutoTrainingCheckBoxPntr->SetValue (fAutoTraining); fAutoTrainingCheckBoxPntr->SetTarget (this); tempRect = Bounds (); tempRect.top = fAutoTrainingCheckBoxPntr->Frame().bottom + 1; tempRect.bottom = tempRect.top + 20; // Button for editing the server settings. /* fServerSettingsButtonPntr = new BButton ( tempRect, "serverSettings", "Advanced Server Settings…", new BMessage (kServerSettingsPressed)); AddChild (fServerSettingsButtonPntr); fServerSettingsButtonPntr->ResizeToPreferred (); fServerSettingsButtonPntr->SetTarget (this); tempRect = Bounds (); tempRect.top = fServerSettingsButtonPntr->Frame().bottom + 1; tempRect.bottom = tempRect.top + 20; // Checkbox for closing the server when done. fQuitServerWhenFinishedCheckBoxPntr = new BCheckBox ( tempRect, "quitWhenFinished", "Close spam scanner when finished.", new BMessage (kQuitWhenFinishedPressed)); AddChild (fQuitServerWhenFinishedCheckBoxPntr); fQuitServerWhenFinishedCheckBoxPntr->ResizeToPreferred (); fQuitServerWhenFinishedCheckBoxPntr->SetValue (fQuitServerWhenFinished); fQuitServerWhenFinishedCheckBoxPntr->SetTarget (this); tempRect = Bounds (); tempRect.top = fQuitServerWhenFinishedCheckBoxPntr->Frame().bottom + 1; tempRect.bottom = tempRect.top + 20; */ }