LoginAlert::LoginAlert(nserror (*callback)(const char *username, const char *password, void *pw), void *callbackpw, nsurl *url, const char *host, const char *realm, const char *text) : BAlert("Login", text, "Cancel", "Ok", NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT) { fCallback = callback; fCallbackPw = callbackpw; fUrl = url; fHost = host; fRealm = realm; SetFeel(B_MODAL_SUBSET_WINDOW_FEEL); /* // XXX: can't do that anymore nsbeos_scaffolding *s = nsbeos_get_scaffold(bw->window); if (s) { NSBrowserWindow *w = nsbeos_get_bwindow_for_scaffolding(s); if (w) AddToSubset(w); }*/ // make space for controls ResizeBy(0, 2 * TC_H); MoveTo(AlertPosition(Frame().Width() + 1, Frame().Height() + 1)); BTextView *tv = TextView(); BRect r(TC_MARGIN, tv->Bounds().bottom - 2 * TC_H, tv->Bounds().right - TC_MARGIN, tv->Bounds().bottom - TC_H); fUserControl = new BTextControl(r, "user", "Username", "", new BMessage(), B_FOLLOW_BOTTOM | B_FOLLOW_RIGHT); fUserControl->SetDivider(60); tv->AddChild(fUserControl); r.OffsetBySelf(0, TC_H); fPassControl = new BTextControl(r, "pass", "Password", "", new BMessage(), B_FOLLOW_BOTTOM | B_FOLLOW_RIGHT); fPassControl->TextView()->HideTyping(true); fPassControl->SetDivider(60); tv->AddChild(fPassControl); SetShortcut(0, B_ESCAPE); }
void ConfigWindow::MakeHowToView() { BResources *resources = BApplication::AppResources(); if (resources) { size_t length; char *buffer = (char *)resources->FindResource('ICON',101,&length); if (buffer) { BBitmap *bitmap = new BBitmap(BRect(0,0,63,63),B_CMAP8); if (bitmap && bitmap->InitCheck() == B_OK) { // copy and enlarge a 32x32 8-bit bitmap char *bits = (char *)bitmap->Bits(); for (int32 i = 0,j = -64;i < length;i++) { if ((i % 32) == 0) j += 64; char *b = bits + (i << 1) + j; b[0] = b[1] = b[64] = b[65] = buffer[i]; } fConfigView->AddChild(new BitmapView(bitmap)); } else delete bitmap; } } BRect rect = fConfigView->Bounds(); BTextView *text = new BTextView(rect,NULL,rect,B_FOLLOW_NONE,B_WILL_DRAW); text->SetViewColor(fConfigView->Parent()->ViewColor()); text->SetAlignment(B_ALIGN_CENTER); text->SetText( MDR_DIALECT_CHOICE ("\n\nCreate a new account using the \"Add\" button.\n\n" "Delete accounts (or only the inbound/outbound) by using the \"Remove\" button on the selected item.\n\n" "Select an item in the list to edit its configuration.", "\n\nアカウントの新規作成は\"追加\"ボタンを\n使います。" "\n\nアカウント自体またはアカウントの\n送受信設定を削除するには\n項目を選択して\"削除\"ボタンを使います。" "\n\nアカウント内容の変更は、\nマウスで項目をクリックしてください。")); rect = text->Bounds(); text->ResizeTo(rect.Width(),text->TextHeight(0,42)); text->SetTextRect(rect); text->MakeEditable(false); text->MakeSelectable(false); fConfigView->AddChild(text); static_cast<CenterContainer *>(fConfigView)->Layout(); }
void ArpTextControl::FrameResized(float new_width, float new_height) { ArpD(cdb << ADH << "ArpTextControl: FrameResized(" << new_width << ", " << new_height << ")" << endl); BTextView* text = dynamic_cast<BTextView*>(ChildAt(0)); if( !text ) ArpD(cdb << ADH << "!!! No BTextView !!!" << endl); if( text ) { ArpD(cdb << ADH << "BTextView: Initial Bounds=" << text->Bounds() << ", TextRect=" << text->TextRect() << endl); } BTextControl::FrameResized(new_width, new_height); BRect textBounds(text->Bounds()); BRect textRect(text->TextRect()); textRect.right = textRect.left + text->LineWidth(0)-1; if( textRect.Width() < textBounds.Width() ) { textRect.right = textRect.left + textBounds.Width()-1; } text->SetTextRect(textRect); if( text ) { ArpD(cdb << ADH << "BTextView: Finish Bounds=" << text->Bounds() << ", TextRect=" << text->TextRect() << endl); } }
void ConfigWindow::_MakeHowToView() { app_info info; if (be_app->GetAppInfo(&info) == B_OK) { BFile appFile(&info.ref, B_READ_ONLY); BAppFileInfo appFileInfo(&appFile); if (appFileInfo.InitCheck() == B_OK) { BBitmap *bitmap = new (nothrow) BBitmap(BRect(0, 0, 63, 63), B_RGBA32); if (appFileInfo.GetIcon(bitmap, B_LARGE_ICON) == B_OK) { fConfigView->AddChild(new BitmapView(bitmap)); } else delete bitmap; } } BRect rect = fConfigView->Bounds(); BTextView *text = new BTextView(rect, NULL, rect, B_FOLLOW_NONE, B_WILL_DRAW); text->SetViewColor(fConfigView->Parent()->ViewColor()); text->SetAlignment(B_ALIGN_CENTER); text->SetText(B_TRANSLATE( "\n\nCreate a new account with the Add button.\n\n" "Remove an account with the Remove button on the selected item.\n\n" "Select an item in the list to change its settings.")); rect = text->Bounds(); text->ResizeTo(rect.Width(), text->TextHeight(0, 42)); text->SetTextRect(rect); text->MakeEditable(false); text->MakeSelectable(false); fConfigView->AddChild(text); fConfigView->Layout(); }
void ConfigWindow::MakeHowToView() { #ifndef HAIKU_TARGET_PLATFORM_HAIKU BResources *resources = BApplication::AppResources(); if (resources) { size_t length; char *buffer = (char *)resources->FindResource(B_LARGE_ICON_TYPE, 101, &length); if (buffer) { BBitmap *bitmap = new (nothrow) BBitmap(BRect(0, 0, 63, 63), B_CMAP8); if (bitmap && bitmap->InitCheck() == B_OK) { // copy and enlarge a 32x32 8-bit bitmap char *bits = (char *)bitmap->Bits(); for (int32 i = 0, j = -64; i < (int32)length; i++) { if ((i % 32) == 0) j += 64; char *b = bits + (i << 1) + j; b[0] = b[1] = b[64] = b[65] = buffer[i]; } fConfigView->AddChild(new BitmapView(bitmap)); } else delete bitmap; } } #else app_info info; if (be_app->GetAppInfo(&info) == B_OK) { BFile appFile(&info.ref, B_READ_ONLY); BAppFileInfo appFileInfo(&appFile); if (appFileInfo.InitCheck() == B_OK) { BBitmap *bitmap = new (nothrow) BBitmap(BRect(0, 0, 63, 63), B_RGBA32); if (appFileInfo.GetIcon(bitmap, B_LARGE_ICON) == B_OK) { fConfigView->AddChild(new BitmapView(bitmap)); } else delete bitmap; } } #endif // HAIKU_TARGET_PLATFORM_HAIKU BRect rect = fConfigView->Bounds(); BTextView *text = new BTextView(rect, NULL, rect, B_FOLLOW_NONE, B_WILL_DRAW); text->SetViewColor(fConfigView->Parent()->ViewColor()); text->SetAlignment(B_ALIGN_CENTER); text->SetText(B_TRANSLATE( "\n\nCreate a new account with the Add button.\n\n" "Remove an account with the Remove button on the selected item.\n\n" "Select an item in the list to change its settings.")); rect = text->Bounds(); text->ResizeTo(rect.Width(), text->TextHeight(0, 42)); text->SetTextRect(rect); text->MakeEditable(false); text->MakeSelectable(false); fConfigView->AddChild(text); static_cast<CenterContainer *>(fConfigView)->Layout(); }
void AlertTestWindow::Test() { BAlert *pAlert = new BAlert( "alert1", k60X, k20X, "OK", "Cancel", B_WIDTH_AS_USUAL, // widthStyle B_OFFSET_SPACING, B_EMPTY_ALERT // alert_type ); if (fAlertType == 'H') { BView *master = pAlert->ChildAt(0); master->SetViewColor(ui_color(B_MENU_BACKGROUND_COLOR)); } BPoint pt; BString strLabel; BButton *pBtns[3] = { NULL }; pBtns[0] = pAlert->ButtonAt(0); pBtns[1] = pAlert->ButtonAt(1); pBtns[2] = pAlert->ButtonAt(2); BTextView *pTextView = pAlert->TextView(); // Window info printf("wi.width = %.1ff;\n" "wi.height = %.1ff;\n" "ati.SetWinInfo(wi);\n", pAlert->Bounds().Width(), pAlert->Bounds().Height()); // TextView info printf("\n"); which_label(pTextView->Text(), strLabel); pt = pTextView->ConvertToParent(BPoint(0, 0)); printf("ti.label = %s;\n" "ti.width = %.1ff;\n" "ti.height = %.1ff;\n" "ti.topleft.Set(%.1ff, %.1ff);\n" "ati.SetTextViewInfo(ti);\n", strLabel.String(), pTextView->Bounds().Width(), pTextView->Bounds().Height(), pt.x, pt.y); // Button info printf("\n"); int32 i = 0; while (i < 3 && pBtns[i] != NULL) { BButton *pb = pBtns[i]; which_label(pb->Label(), strLabel); pt = pb->ConvertToParent(BPoint(0, 0)); printf("bi.label = %s;\n" "bi.width = %.1ff;\n" "bi.height = %.1ff;\n" "bi.topleft.Set(%.1ff, %.1ff);\n" "ati.SetButtonInfo(%d, bi);\n", strLabel.String(), pb->Bounds().Width(), pb->Bounds().Height(), pt.x, pt.y, (int)i); i++; } int32 result = pAlert->Go(); printf("%c<Clicked: %d\n", fAlertType, static_cast<int>(result)); pAlert = NULL; }
void HDialog::CreateField(int kind, BPositionIO& data, BView*& inside) { dRect r; char name[256]; char label[256]; uint32 cmd; BView *v; switch (kind) { case 'btn ': data >> r >> name >> label >> cmd; inside->AddChild(v = new BButton(r.ToBe(), name, label, new BMessage(cmd))); if (cmd == msg_OK || strcmp(name, "ok") == 0) SetDefaultButton(static_cast<BButton*>(v)); break; case 'radb': data >> r >> name >> label; inside->AddChild(new BRadioButton(r.ToBe(), name, label, new BMessage(msg_FieldChanged))); break; case 'chkb': data >> r >> name >> label; inside->AddChild(new BCheckBox(r.ToBe(), name, label, new BMessage(msg_FieldChanged))); break; case 'edit': { char val[256], allowed[256]; short max, divider; data >> r >> name >> label >> val >> allowed >> max >> divider; BRect b = r.ToBe(); inside->AddChild(v = new BTextControl(b, name, *label ? label : NULL, val, new BMessage(msg_FieldChanged), B_FOLLOW_NONE)); BTextView *tv = static_cast<BTextControl*>(v)->TextView(); if (*allowed) { for (int i = 0; i < 256; i++) if (isprint(i)) { if (strchr(allowed, i)) tv->AllowChar(i); else tv->DisallowChar(i); } } if (max) tv->SetMaxBytes(max); if (divider) static_cast<BTextControl*>(v)->SetDivider(divider * gFactor); if (v->Bounds().Height() < b.Height()) { float d = v->Bounds().Height() - tv->Bounds().Height(); v->ResizeTo(b.Width(), b.Height()); tv->ResizeTo(tv->Bounds().Width(), b.Height() - d); } break; } case 'capt': data >> r >> name >> label; inside->AddChild(v = new BStringView(r.ToBe(), name, label)); v->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); break; case 'popu': { short id, div; data >> r >> name >> label >> id >> div; inside->AddChild(v = new BMenuField(r.ToBe(), name, *label ? label : NULL, HResources::GetMenu(id, true))); if (div) static_cast<BMenuField*>(v)->SetDivider(div * gFactor); break; } case 'tabb': data >> r >> name; inside->AddChild(v = new HTabSheet(r.ToBe(), name)); inside = v; break; case 'tabe': inside = inside->Parent(); break; case 'shet': data >> name >> label; inside = dynamic_cast<HTabSheet*>(inside)->AddSheet(name, label); break; case 'shte': inside = inside->Parent(); break; case 'box ': data >> r >> name; inside->AddChild(v = new BBox(r.ToBe(), name)); if (*name) dynamic_cast<BBox*>(v)->SetLabel(name); v->SetFont(be_plain_font); inside = v; break; case 'boxe': inside = inside->Parent(); break; case 'list': case 'olst': { data >> r >> name; BRect lr = r.ToBe(); lr.right -= B_V_SCROLL_BAR_WIDTH; BListView *lv; if (kind == 'list') lv = new BListView(lr, name); else lv = new BOutlineListView(lr, name); strcat(name, "_scr"); inside->AddChild(new BScrollView(name, lv, B_FOLLOW_LEFT | B_FOLLOW_TOP, 0, false, true)); break; } case 'clct': { data >> r >> name >> label; rgb_color c = { 255, 100, 100, 0 }; inside->AddChild(v = new HColorControl(r.ToBe(), name, label, c)); v->SetViewColor(inside->ViewColor()); break; } case 'line': { HDlogView *dv = dynamic_cast<HDlogView*>(inside); data >> r; if (dv) dv->AddMyLine(r.ToBe()); break; } case 'sldr': { int32 msg, vMin, vMax, thumb; data >> r >> name >> label >> msg >> vMin >> vMax >> thumb; inside->AddChild(new BSlider(r.ToBe(), name, label, new BMessage(msg), vMin, vMax, (thumb_style)thumb)); break; } default: { if (sFieldMap && sFieldMap->find(kind) != sFieldMap->end()) (*sFieldMap)[kind](kind, data, inside); else throw HErr("Unknown type for dialog item (%4.4s)", &kind); } } } /* HDialog::CreateField */