PPDConfigView::PPDConfigView(BRect bounds, const char *name, uint32 resizeMask, uint32 flags) : BView(bounds, name, resizeMask, flags) , fPPD(NULL) { // add category outline list view bounds.OffsetTo(0, 0); BRect listBounds(bounds.left + kLeftMargin, bounds.top + kTopMargin, bounds.right - kHorizontalSpace, bounds.bottom - kBottomMargin); listBounds.right -= B_V_SCROLL_BAR_WIDTH; listBounds.bottom -= B_H_SCROLL_BAR_HEIGHT; BStringView* label = new BStringView(listBounds, "printer-settings", "Printer Settings:"); AddChild(label); label->ResizeToPreferred(); listBounds.top += label->Bounds().bottom + 5; // add details view fDetails = new BView(listBounds, "details", B_FOLLOW_ALL_SIDES, B_WILL_DRAW); fDetails->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); BScrollView* scrollView = new BScrollView("details-scroll-view", fDetails, B_FOLLOW_ALL_SIDES, 0, true, true); AddChild(scrollView); }
ConfigView::ConfigView(const BRect &frame, uint32 resize, uint32 flags) : BView(frame, B_TRANSLATE("RTF-Translator Settings"), resize, flags) { SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); font_height fontHeight; be_bold_font->GetHeight(&fontHeight); float height = fontHeight.descent + fontHeight.ascent + fontHeight.leading; BRect rect(10, 10, 200, 10 + height); BStringView *stringView = new BStringView(rect, "title", B_TRANSLATE("Rich Text Format (RTF) files")); stringView->SetFont(be_bold_font); stringView->ResizeToPreferred(); AddChild(stringView); float maxWidth = stringView->Bounds().Width(); rect.OffsetBy(0, height + 10); char version[256]; snprintf(version, sizeof(version), B_TRANSLATE("Version %d.%d.%d, %s"), static_cast<int>(B_TRANSLATION_MAJOR_VERSION(RTF_TRANSLATOR_VERSION)), static_cast<int>(B_TRANSLATION_MINOR_VERSION(RTF_TRANSLATOR_VERSION)), static_cast<int>(B_TRANSLATION_REVISION_VERSION( RTF_TRANSLATOR_VERSION)), __DATE__); stringView = new BStringView(rect, "version", version); stringView->ResizeToPreferred(); AddChild(stringView); if (stringView->Bounds().Width() > maxWidth) maxWidth = stringView->Bounds().Width(); GetFontHeight(&fontHeight); height = fontHeight.descent + fontHeight.ascent + fontHeight.leading; rect.OffsetBy(0, height + 5); stringView = new BStringView(rect, "Copyright", B_UTF8_COPYRIGHT "2004-2006 Haiku Inc."); stringView->ResizeToPreferred(); AddChild(stringView); if (maxWidth + 20 > Bounds().Width()) ResizeTo(maxWidth + 20, Bounds().Height()); }
void VisualColorControl::AttachedToWindow() { BPoint *points = new BPoint[3]; points[0] = BPoint(0,0); points[1] = BPoint(-4,-4); points[2] = BPoint(4,-4); // calculate the initial ramps CalcRamps(); // create the arrow-pictures BeginPicture(new BPicture()); SetHighColor(100,100,255); FillPolygon(points,3); SetHighColor(0,0,0); StrokePolygon(points,3); down_arrow = EndPicture(); if (Parent() != NULL) SetViewColor(Parent()->ViewColor()); BStringView *sv = new BStringView(BRect(0,COLOR_HEIGHT/2,1,COLOR_HEIGHT/2),"label view",label1); AddChild(sv); float sv_width = sv->StringWidth(label1); sv_width = max_c(sv_width,sv->StringWidth(label2)); sv_width = max_c(sv_width,sv->StringWidth(label3)); font_height fHeight; sv->GetFontHeight(&fHeight); sv->ResizeTo(sv_width,fHeight.ascent+fHeight.descent); sv->MoveBy(0,-(fHeight.ascent+fHeight.descent)/2.0); BRect sv_frame = sv->Frame(); sv_frame.OffsetBy(0,COLOR_HEIGHT); sv->SetAlignment(B_ALIGN_CENTER); sv = new BStringView(sv_frame,"label view",label2); AddChild(sv); sv->SetAlignment(B_ALIGN_CENTER); sv_frame.OffsetBy(0,COLOR_HEIGHT); sv = new BStringView(sv_frame,"label view",label3); AddChild(sv); sv->SetAlignment(B_ALIGN_CENTER); sv_frame.OffsetBy(0,COLOR_HEIGHT); sv = new BStringView(sv_frame,"label view",label4); AddChild(sv); sv->SetAlignment(B_ALIGN_CENTER); ramp_left_edge = sv->Bounds().IntegerWidth()+2; ResizeBy(ramp_left_edge,0); delete[] points; }
// This is used to provide a consistent look for the settings view for screen // savers without any configuration. void BuildScreenSaverDefaultSettingsView(BView* view, const char* moduleName, const char* info) { BRect rect(15, 15, 20, 20); BStringView* stringView = new BStringView(rect, "module", moduleName); stringView->SetFont(be_bold_font); stringView->ResizeToPreferred(); view->AddChild(stringView); rect.OffsetBy(0, stringView->Bounds().Height() + 4); stringView = new BStringView(rect, "info", info); stringView->ResizeToPreferred(); view->AddChild(stringView); }
PrinterSelectionView::PrinterSelectionView(BRect bounds, const char *name, uint32 resizeMask, uint32 flags) : BView(bounds, name, resizeMask, flags) { // add vendor list view bounds.OffsetTo(0, 0); BRect listBounds(bounds.left + kLeftMargin, bounds.top + kTopMargin, bounds.right / 3.0 - kHorizontalSpace / 2, bounds.bottom - kBottomMargin); listBounds.right -= B_V_SCROLL_BAR_WIDTH; listBounds.bottom -= B_H_SCROLL_BAR_HEIGHT; BStringView* label = new BStringView(listBounds, "vendors-label", "Vendors:"); AddChild(label); label->ResizeToPreferred(); listBounds.top += label->Bounds().bottom + 5; fVendors = new BListView(listBounds, "vendors", B_SINGLE_SELECTION_LIST, B_FOLLOW_ALL); FillVendors(); BScrollView* scrollView = new BScrollView("vendors-scroll-view", fVendors, B_FOLLOW_LEFT | B_FOLLOW_TOP_BOTTOM, 0, true, true); AddChild(scrollView); // add details view BRect printerBounds(listBounds); printerBounds.left = B_V_SCROLL_BAR_WIDTH + printerBounds.right + kHorizontalSpace; printerBounds.right = bounds.right - kRightMargin - B_V_SCROLL_BAR_WIDTH; printerBounds.top = bounds.top + kTopMargin; label = new BStringView(printerBounds, "printers-label", "Printers:"); AddChild(label); label->ResizeToPreferred(); BRect detailBounds(listBounds); detailBounds.left = B_V_SCROLL_BAR_WIDTH + detailBounds.right + kHorizontalSpace; detailBounds.right = bounds.right - kRightMargin - B_V_SCROLL_BAR_WIDTH; fPrinters = new BListView(detailBounds, "printers", B_SINGLE_SELECTION_LIST, B_FOLLOW_ALL); scrollView = new BScrollView("printers-scroll-view", fPrinters, B_FOLLOW_LEFT | B_FOLLOW_TOP_BOTTOM, 0, true, true); AddChild(scrollView); }
ConfigWindow::ConfigWindow() : BWindow(BRect(200.0, 200.0, 640.0, 640.0), "E-mail", B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_RESIZABLE), fLastSelectedAccount(NULL), fSaveSettings(false) { /*** create controls ***/ BRect rect(Bounds()); BView *top = new BView(rect,NULL,B_FOLLOW_ALL,0); top->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); AddChild(top); // determine font height font_height fontHeight; top->GetFontHeight(&fontHeight); int32 height = (int32)(fontHeight.ascent + fontHeight.descent + fontHeight.leading) + 5; rect.InsetBy(5,5); rect.bottom -= 11 + height; BTabView *tabView = new BTabView(rect,NULL); BView *view,*generalView; rect = tabView->Bounds(); rect.bottom -= tabView->TabHeight() + 4; tabView->AddTab(view = new BView(rect,NULL,B_FOLLOW_ALL,0)); tabView->TabAt(0)->SetLabel(MDR_DIALECT_CHOICE ("Accounts","アカウント")); view->SetViewColor(top->ViewColor()); // accounts listview rect = view->Bounds().InsetByCopy(8,8); rect.right = 140 - B_V_SCROLL_BAR_WIDTH; rect.bottom -= height + 12; fAccountsListView = new AccountsListView(rect); view->AddChild(new BScrollView(NULL,fAccountsListView,B_FOLLOW_ALL,0,false,true)); rect.right += B_V_SCROLL_BAR_WIDTH; rect.top = rect.bottom + 8; rect.bottom = rect.top + height; BRect sizeRect = rect; sizeRect.right = sizeRect.left + 30 + view->StringWidth(MDR_DIALECT_CHOICE ("Add","追加")); view->AddChild(new BButton(sizeRect,NULL,MDR_DIALECT_CHOICE ("Add","追加"), new BMessage(kMsgAddAccount),B_FOLLOW_BOTTOM)); sizeRect.left = sizeRect.right+3; sizeRect.right = sizeRect.left + 30 + view->StringWidth(MDR_DIALECT_CHOICE ("Remove","削除")); view->AddChild(fRemoveButton = new BButton(sizeRect,NULL,MDR_DIALECT_CHOICE ("Remove","削除"), new BMessage(kMsgRemoveAccount),B_FOLLOW_BOTTOM)); // accounts config view rect = view->Bounds(); rect.left = fAccountsListView->Frame().right + B_V_SCROLL_BAR_WIDTH + 16; rect.right -= 10; view->AddChild(fConfigView = new CenterContainer(rect)); MakeHowToView(); // general settings rect = tabView->Bounds(); rect.bottom -= tabView->TabHeight() + 4; tabView->AddTab(view = new CenterContainer(rect)); tabView->TabAt(1)->SetLabel(MDR_DIALECT_CHOICE ("General","一般")); rect = view->Bounds().InsetByCopy(8,8); rect.right -= 1; rect.bottom = rect.top + height * 5 + 15; BBox *box = new BBox(rect); box->SetLabel(MDR_DIALECT_CHOICE ("Retrieval Frequency","メールチェック間隔")); view->AddChild(box); rect = box->Bounds().InsetByCopy(8,8); rect.top += 7; rect.bottom = rect.top + height + 5; BRect tile = rect.OffsetByCopy(0,1); int32 labelWidth = (int32)view->StringWidth(MDR_DIALECT_CHOICE ("Check every:","メールチェック間隔:"))+6; tile.right = 80 + labelWidth; fIntervalControl = new BTextControl(tile,"time",MDR_DIALECT_CHOICE ("Check every:","メールチェック間隔:"), NULL,NULL); fIntervalControl->SetDivider(labelWidth); box->AddChild(fIntervalControl); BPopUpMenu *frequencyPopUp = new BPopUpMenu(B_EMPTY_STRING); const char *frequencyStrings[] = { MDR_DIALECT_CHOICE ("Never","チェックしない"), MDR_DIALECT_CHOICE ("Minutes","分毎チェック"), MDR_DIALECT_CHOICE ("Hours","時間毎チェック"), MDR_DIALECT_CHOICE ("Days","日間毎チェック")}; BMenuItem *item; for (int32 i = 0;i < 4;i++) { frequencyPopUp->AddItem(item = new BMenuItem(frequencyStrings[i],new BMessage(kMsgIntervalUnitChanged))); if (i == 1) item->SetMarked(true); } tile.left = tile.right + 5; tile.right = rect.right; tile.OffsetBy(0,-1); fIntervalUnitField = new BMenuField(tile,"frequency", B_EMPTY_STRING, frequencyPopUp); fIntervalUnitField->SetDivider(0.0); box->AddChild(fIntervalUnitField); rect.OffsetBy(0,height + 9); rect.bottom -= 2; fPPPActiveCheckBox = new BCheckBox(rect,"ppp active", MDR_DIALECT_CHOICE ("only when PPP is active","PPP接続中時のみ"), NULL); box->AddChild(fPPPActiveCheckBox); rect.OffsetBy(0,height + 9); rect.bottom -= 2; fPPPActiveSendCheckBox = new BCheckBox(rect,"ppp activesend", MDR_DIALECT_CHOICE ("Queue outgoing mail when PPP is inactive","PPP切断時、送信メールを送信箱に入れる"), NULL); box->AddChild(fPPPActiveSendCheckBox); rect = box->Frame(); rect.bottom = rect.top + 4*height + 20; box = new BBox(rect); box->SetLabel(MDR_DIALECT_CHOICE ("Status Window","送受信状況の表示")); view->AddChild(box); BPopUpMenu *statusPopUp = new BPopUpMenu(B_EMPTY_STRING); const char *statusModes[] = { MDR_DIALECT_CHOICE ("Never","表示しない"), MDR_DIALECT_CHOICE ("While Sending","送信時"), MDR_DIALECT_CHOICE ("While Sending / Fetching","送受信時"), MDR_DIALECT_CHOICE ("Always","常に表示")}; BMessage *msg; for (int32 i = 0;i < 4;i++) { statusPopUp->AddItem(item = new BMenuItem(statusModes[i],msg = new BMessage(kMsgShowStatusWindowChanged))); msg->AddInt32("ShowStatusWindow",i); if (i == 0) item->SetMarked(true); } rect = box->Bounds().InsetByCopy(8,8); rect.top += 7; rect.bottom = rect.top + height + 5; labelWidth = (int32)view->StringWidth( MDR_DIALECT_CHOICE ("Show Status Window:","ステータスの表示:")) + 8; fStatusModeField = new BMenuField(rect,"show status", MDR_DIALECT_CHOICE ("Show Status Window:","ステータスの表示:"), statusPopUp); fStatusModeField->SetDivider(labelWidth); box->AddChild(fStatusModeField); BPopUpMenu *lookPopUp = new BPopUpMenu(B_EMPTY_STRING); const char *windowLookStrings[] = { MDR_DIALECT_CHOICE ("Normal, With Tab","タブ付通常"), MDR_DIALECT_CHOICE ("Normal, Border Only","ボーダーのみ通常"), MDR_DIALECT_CHOICE ("Floating","フローティング"), MDR_DIALECT_CHOICE ("Thin Border","細いボーダー"), MDR_DIALECT_CHOICE ("No Border","ボーダー無し")}; for (int32 i = 0;i < 5;i++) { lookPopUp->AddItem(item = new BMenuItem(windowLookStrings[i],msg = new BMessage(kMsgStatusLookChanged))); msg->AddInt32("StatusWindowLook",i); if (i == 0) item->SetMarked(true); } rect.OffsetBy(0, height + 6); fStatusLookField = new BMenuField(rect,"status look", MDR_DIALECT_CHOICE ("Window Look:","ウィンドウ外観:"),lookPopUp); fStatusLookField->SetDivider(labelWidth); box->AddChild(fStatusLookField); BPopUpMenu *workspacesPopUp = new BPopUpMenu(B_EMPTY_STRING); workspacesPopUp->AddItem(item = new BMenuItem( MDR_DIALECT_CHOICE ("Current Workspace","使用中ワークスペース"), msg = new BMessage(kMsgStatusWorkspaceChanged))); msg->AddInt32("StatusWindowWorkSpace", 0); workspacesPopUp->AddItem(item = new BMenuItem( MDR_DIALECT_CHOICE ("All Workspaces","全てのワークスペース"), msg = new BMessage(kMsgStatusWorkspaceChanged))); msg->AddInt32("StatusWindowWorkSpace", -1); rect.OffsetBy(0,height + 6); fStatusWorkspaceField = new BMenuField(rect,"status workspace", MDR_DIALECT_CHOICE ("Window visible on:","表示場所:"),workspacesPopUp); fStatusWorkspaceField->SetDivider(labelWidth); box->AddChild(fStatusWorkspaceField); rect = box->Frame(); rect.bottom = rect.top + 3*height + 13; box = new BBox(rect); box->SetLabel(MDR_DIALECT_CHOICE ("Deskbar Icon","デスクバーアイコンリンク")); view->AddChild(box); rect = box->Bounds().InsetByCopy(8,8); rect.top += 7; rect.bottom = rect.top + height + 5; BStringView *stringView = new BStringView(rect,B_EMPTY_STRING, MDR_DIALECT_CHOICE ( "The menu links are links to folders in a real folder like the Be menu.", "デスクバーで表示する項目の設定")); box->AddChild(stringView); stringView->SetAlignment(B_ALIGN_CENTER); stringView->ResizeToPreferred(); // BStringView::ResizeToPreferred() changes the width, so that the // alignment has no effect anymore stringView->ResizeTo(rect.Width(), stringView->Bounds().Height()); rect.left += 100; rect.right -= 100; rect.OffsetBy(0,height + 1); BButton *button = new BButton(rect,B_EMPTY_STRING, MDR_DIALECT_CHOICE ("Configure Menu Links","メニューリンクの設定"), msg = new BMessage(B_REFS_RECEIVED)); box->AddChild(button); button->SetTarget(BMessenger("application/x-vnd.Be-TRAK")); BPath path; find_directory(B_USER_SETTINGS_DIRECTORY, &path); path.Append("Mail/Menu Links"); BEntry entry(path.Path()); if (entry.InitCheck() == B_OK && entry.Exists()) { entry_ref ref; entry.GetRef(&ref); msg->AddRef("refs", &ref); } else button->SetEnabled(false); rect = box->Frame(); rect.bottom = rect.top + 2*height + 6; box = new BBox(rect); box->SetLabel(MDR_DIALECT_CHOICE ("Misc.","その他の設定")); view->AddChild(box); rect = box->Bounds().InsetByCopy(8,8); rect.top += 7; rect.bottom = rect.top + height + 5; fAutoStartCheckBox = new BCheckBox(rect,"start daemon", MDR_DIALECT_CHOICE ("Auto-Start Mail Daemon","Mail Daemonを自動起動"),NULL); box->AddChild(fAutoStartCheckBox); // about page rect = tabView->Bounds(); rect.bottom -= tabView->TabHeight() + 4; tabView->AddTab(view = new BView(rect,NULL,B_FOLLOW_ALL,0)); tabView->TabAt(2)->SetLabel(MDR_DIALECT_CHOICE ("About","情報")); view->SetViewColor(top->ViewColor()); AboutTextView *about = new AboutTextView(rect); about->SetViewColor(top->ViewColor()); view->AddChild(about); // save/cancel/revert buttons top->AddChild(tabView); rect = tabView->Frame(); rect.top = rect.bottom + 5; rect.bottom = rect.top + height + 5; BButton *saveButton = new BButton(rect,"save", MDR_DIALECT_CHOICE ("Save","保存"), new BMessage(kMsgSaveSettings)); float w,h; saveButton->GetPreferredSize(&w,&h); saveButton->ResizeTo(w,h); saveButton->MoveTo(rect.right - w, rect.top); top->AddChild(saveButton); BButton *cancelButton = new BButton(rect,"cancel", MDR_DIALECT_CHOICE ("Cancel","中止"), new BMessage(kMsgCancelSettings)); cancelButton->GetPreferredSize(&w,&h); cancelButton->ResizeTo(w,h); #ifdef HAVE_APPLY_BUTTON cancelButton->MoveTo(saveButton->Frame().left - w - 5,rect.top); #else cancelButton->MoveTo(saveButton->Frame().left - w - 20,rect.top); #endif top->AddChild(cancelButton); #ifdef HAVE_APPLY_BUTTON BButton *applyButton = new BButton(rect,"apply", MDR_DIALECT_CHOICE ("Apply","適用"), new BMessage(kMsgApplySettings)); applyButton->GetPreferredSize(&w,&h); applyButton->ResizeTo(w,h); applyButton->MoveTo(cancelButton->Frame().left - w - 20,rect.top); top->AddChild(applyButton); #endif BButton *revertButton = new BButton(rect,"revert", MDR_DIALECT_CHOICE ("Revert","復元"), new BMessage(kMsgRevertSettings)); revertButton->GetPreferredSize(&w,&h); revertButton->ResizeTo(w,h); #ifdef HAVE_APPLY_BUTTON revertButton->MoveTo(applyButton->Frame().left - w - 5,rect.top); #else revertButton->MoveTo(cancelButton->Frame().left - w - 6,rect.top); #endif top->AddChild(revertButton); LoadSettings(); fAccountsListView->SetSelectionMessage(new BMessage(kMsgAccountSelected)); }
void MonthWindowView::AttachedToWindow(void) { SetFont(be_plain_font); SetViewColor(VIEW_COLOR); // Calculate size of cell needed for number of day of month font_height h; be_plain_font->GetHeight(&h); h_cell=(int)(h.ascent+h.descent+h.leading+6); w_cell=StringWidth("4")*4; #ifdef __LANG_RUSSIAN BString s(""); s<<tday; s.Append(" "); switch(tmonth) { case 1: { s.Append("января "); break; } case 2: { s.Append("февраля "); break; } case 3: { s.Append("марта "); break; } case 4: { s.Append("апреля "); break; } case 5: { s.Append("мая "); break; } case 6: { s.Append("июня "); break; } case 7: { s.Append("июля "); break; } case 8: { s.Append("августа "); break; } case 9: { s.Append("сентября "); break; } case 10: { s.Append("октября "); break; } case 11: { s.Append("ноября "); break; } case 12: { s.Append("декабря "); break; } } s<<tyear; s.Append(" г."); #else // localized, english and french BString s(""); s<<tday; s.Append(" "); s.Append(monthNames[tmonth-1]); s.Append(" "); s<<tyear; #endif msng=new BMessenger(this); todayStringView=new MouseSenseStringView(new BMessage('TODA'), msng, BRect(10,10,100,100),"todayMStringViewAViX", s.String()); AddChild(todayStringView); todayStringView->ResizeToPreferred(); todayStringView->SetViewColor(VIEW_COLOR); monthStringView=new BStringView(BRect(10,10,100,100),"monthStringViewAViX", monthNames[8]); monthStringView->SetAlignment(B_ALIGN_CENTER); AddChild(monthStringView); monthStringView->ResizeToPreferred(); monthStringView->SetText(monthNames[cmonth-1]); monthStringView->SetViewColor(VIEW_COLOR); s.SetTo(""); if(cyear<10) s.Append("000"); else if(cyear<100) s.Append("00"); else if(cyear<1000) s.Append("0"); s<<cyear; yearStringView=new BStringView(BRect(10,10,100,100),"yearStringViewAViX", "0000"); AddChild(yearStringView); yearStringView->ResizeToPreferred(); yearStringView->SetText(s.String()); yearStringView->SetViewColor(VIEW_COLOR); ResizeTo(w_cell*7+1,h_cell*7+3+16+yearStringView->Bounds().bottom+todayStringView->Bounds().bottom); Window()->ResizeTo(Bounds().right, Bounds().bottom); yearMStringView[0]=new MouseSenseStringView(new BMessage('YEA0'),msng, BRect(10,10,100,100), "yearMStringViewAViX0", "<<"); AddChild(yearMStringView[0]); yearMStringView[0]->ResizeToPreferred(); yearMStringView[0]->SetViewColor(VIEW_COLOR); yearMStringView[1]=new MouseSenseStringView(new BMessage('YEA1'),msng, BRect(10,10,100,100), "yearMStringViewAViX1", ">>"); AddChild(yearMStringView[1]); yearMStringView[1]->ResizeToPreferred(); yearMStringView[1]->SetViewColor(VIEW_COLOR); monthMStringView[0]=new MouseSenseStringView(new BMessage('MON0'),msng, BRect(10,10,100,100), "monthMStringViewAViX0", "<<"); AddChild(monthMStringView[0]); monthMStringView[0]->ResizeToPreferred(); monthMStringView[0]->SetViewColor(VIEW_COLOR); monthMStringView[1]=new MouseSenseStringView(new BMessage('MON1'),msng, BRect(10,10,100,100), "monthMStringViewAViX1", ">>"); AddChild(monthMStringView[1]); monthMStringView[1]->ResizeToPreferred(); monthMStringView[1]->SetViewColor(VIEW_COLOR); todayStringView->MoveTo((Bounds().right-todayStringView->Bounds().right)/2, Bounds().bottom-todayStringView->Bounds().bottom-2); if(tyear<first_year || tyear>last_year) todayStringView->SetHighColor(NOACTIVE_COLOR); yearMStringView[1]->MoveTo(Bounds().right-yearMStringView[1]->Bounds().right,5); yearStringView->MoveTo(yearMStringView[1]->Frame().left-yearStringView->Bounds().right,5); yearMStringView[0]->MoveTo(yearStringView->Frame().left-yearMStringView[0]->Bounds().right,5); monthStringView->MoveTo((yearMStringView[0]->Frame().left-monthStringView->Bounds().right)/2,5); monthMStringView[0]->MoveTo(monthStringView->Frame().left-monthMStringView[0]->Bounds().right,5); monthMStringView[1]->MoveTo(monthStringView->Frame().right,5); which_focused=2; // days of month Bmp=new BBitmap(BRect(Frame()),B_RGB32,true); BmpView=new BView(Bmp->Bounds(),"BV",0,B_WILL_DRAW); Bmp->AddChild(BmpView); Bmp->Lock(); BmpView->SetHighColor(VIEW_COLOR); BmpView->FillRect(BmpView->Frame()); BmpView->SetHighColor(LINE_COLOR); BmpView->StrokeLine(BPoint(3,todayStringView->Frame().top-5), BPoint(Bounds().right-3,todayStringView->Frame().top-5)); BmpView->StrokeLine(BPoint(3,yearStringView->Frame().bottom+2), BPoint(Bounds().right-3,yearStringView->Frame().bottom+2)); BmpView->SetHighColor(0,0,0,0); float y=yearStringView->Frame().bottom+h_cell; float x=0; for(int i=0;i<7;i++) { BmpView->DrawString(weekdayNames[i],BPoint(x+(w_cell-StringWidth(weekdayNames[i]))/2,y)); x+=w_cell; } BmpView->Sync(); Bmp->Unlock(); DrawMonth(); }
void ImageView::_UpdateImage() { // ToDo: add scroller if necessary?! BAutolock locker(fEditor); // we need all the data... size_t viewSize = fEditor.ViewSize(); // that may need some more memory... if ((off_t)viewSize < fEditor.FileSize()) fEditor.SetViewSize(fEditor.FileSize()); const char *data; if (fEditor.GetViewBuffer((const uint8 **)&data) != B_OK) { fEditor.SetViewSize(viewSize); return; } if (fBitmap != NULL && (fEditor.Type() == B_MINI_ICON_TYPE || fEditor.Type() == B_LARGE_ICON_TYPE)) { // optimize icon update... fBitmap->SetBits(data, fEditor.FileSize(), 0, B_CMAP8); fEditor.SetViewSize(viewSize); return; } #ifdef HAIKU_TARGET_PLATFORM_HAIKU if (fBitmap != NULL && fEditor.Type() == B_VECTOR_ICON_TYPE && fScaleSlider->Value() * 8 - 1 == fBitmap->Bounds().Width()) { if (BIconUtils::GetVectorIcon((const uint8 *)data, (size_t)fEditor.FileSize(), fBitmap) == B_OK) { fEditor.SetViewSize(viewSize); return; } } #endif delete fBitmap; fBitmap = NULL; switch (fEditor.Type()) { case B_MINI_ICON_TYPE: fBitmap = new BBitmap(BRect(0, 0, 15, 15), B_CMAP8); if (fBitmap->InitCheck() == B_OK) fBitmap->SetBits(data, fEditor.FileSize(), 0, B_CMAP8); break; case B_LARGE_ICON_TYPE: fBitmap = new BBitmap(BRect(0, 0, 31, 31), B_CMAP8); if (fBitmap->InitCheck() == B_OK) fBitmap->SetBits(data, fEditor.FileSize(), 0, B_CMAP8); break; #ifdef HAIKU_TARGET_PLATFORM_HAIKU case B_VECTOR_ICON_TYPE: fBitmap = new BBitmap(BRect(0, 0, fScaleSlider->Value() * 8 - 1, fScaleSlider->Value() * 8 - 1), B_RGB32); if (fBitmap->InitCheck() != B_OK || BIconUtils::GetVectorIcon((const uint8 *)data, (size_t)fEditor.FileSize(), fBitmap) != B_OK) { delete fBitmap; fBitmap = NULL; } break; #endif case B_PNG_FORMAT: { BMemoryIO stream(data, fEditor.FileSize()); fBitmap = BTranslationUtils::GetBitmap(&stream); break; } case B_MESSAGE_TYPE: { BMessage message; // ToDo: this could be problematic if the data is not large // enough to contain the message... if (message.Unflatten(data) == B_OK) fBitmap = new BBitmap(&message); break; } } // Update the bitmap description. If no image can be displayed, // we will show our "unsupported" message if (fBitmap != NULL && fBitmap->InitCheck() != B_OK) { delete fBitmap; fBitmap = NULL; } if (fBitmap != NULL) { char buffer[256]; const char *type = B_TRANSLATE("Unknown type"); switch (fEditor.Type()) { case B_MINI_ICON_TYPE: case B_LARGE_ICON_TYPE: #ifdef HAIKU_TARGET_PLATFORM_HAIKU case B_VECTOR_ICON_TYPE: #endif type = B_TRANSLATE("Icon"); break; case B_PNG_FORMAT: type = B_TRANSLATE("PNG format"); break; case B_MESSAGE_TYPE: type = B_TRANSLATE("Flattened bitmap"); break; default: break; } const char *colorSpace; switch (fBitmap->ColorSpace()) { case B_GRAY1: case B_GRAY8: colorSpace = B_TRANSLATE("Grayscale"); break; case B_CMAP8: colorSpace = B_TRANSLATE("8 bit palette"); break; case B_RGB32: case B_RGBA32: case B_RGB32_BIG: case B_RGBA32_BIG: colorSpace = B_TRANSLATE("32 bit"); break; case B_RGB15: case B_RGBA15: case B_RGB15_BIG: case B_RGBA15_BIG: colorSpace = B_TRANSLATE("15 bit"); break; case B_RGB16: case B_RGB16_BIG: colorSpace = B_TRANSLATE("16 bit"); break; default: colorSpace = B_TRANSLATE("Unknown format"); break; } snprintf(buffer, sizeof(buffer), "%s, %g x %g, %s", type, fBitmap->Bounds().Width() + 1, fBitmap->Bounds().Height() + 1, colorSpace); fDescriptionView->SetText(buffer); } else fDescriptionView->SetText(B_TRANSLATE_COMMENT("Could not read image", "Image means here a picture file, not a disk image.")); // Update the view size to match the image and its description float width, height; fDescriptionView->GetPreferredSize(&width, &height); fDescriptionView->ResizeTo(width, height); BRect rect = fDescriptionView->Bounds(); if (fBitmap != NULL) { BRect bounds = fBitmap->Bounds(); rect.bottom += bounds.Height() + 5; if (fScaleSlider != NULL && rect.Width() < fScaleSlider->Bounds().Width()) rect.right = fScaleSlider->Bounds().right; if (bounds.Width() > rect.Width()) rect.right = bounds.right; // center description below the bitmap fDescriptionView->MoveTo((rect.Width() - fDescriptionView->Bounds().Width()) / 2, bounds.Height() + 5); if (fScaleSlider != NULL) { // center slider below description rect.bottom += fScaleSlider->Bounds().Height() + 5; fScaleSlider->MoveTo((rect.Width() - fScaleSlider->Bounds().Width()) / 2, fDescriptionView->Frame().bottom + 5); if (fScaleSlider->IsHidden()) fScaleSlider->Show(); } } else if (fScaleSlider != NULL && !fScaleSlider->IsHidden()) fScaleSlider->Hide(); ResizeTo(rect.Width(), rect.Height()); if (Parent()) { // center within parent view BRect parentBounds = Parent()->Bounds(); MoveTo((parentBounds.Width() - rect.Width()) / 2, (parentBounds.Height() - rect.Height()) / 2); } Invalidate(); // restore old view size fEditor.SetViewSize(viewSize); }
//! Create the controls for the "General" tab void ScreenSaverWindow::_SetupFadeTab(BRect rect) { fFadeView = new FadeView(rect, B_TRANSLATE("General"), fSettings); float StringWidth1 = be_plain_font->StringWidth(B_TRANSLATE ("Start screensaver")); float StringWidth2 = be_plain_font->StringWidth(B_TRANSLATE ("Turn off screen")); float StringWidth3 = be_plain_font->StringWidth(B_TRANSLATE ("Password lock")); float labelWidth = StringWidth1; if (labelWidth < StringWidth2) labelWidth = StringWidth2; if (labelWidth < StringWidth3) labelWidth = StringWidth3; labelWidth += 20.0f; font_height fontHeight; be_plain_font->GetHeight(&fontHeight); float textHeight = ceilf(fontHeight.ascent + fontHeight.descent); // taken from BRadioButton: float radioButtonOffset = 2 * floorf(textHeight / 2 - 2) + floorf(textHeight / 2); fEnableCheckBox = new BCheckBox(BRect(0, 0, 1, 1), "EnableCheckBox", B_TRANSLATE("Enable screensaver"), new BMessage(kMsgEnableScreenSaverBox)); fEnableCheckBox->ResizeToPreferred(); rect.InsetBy(8, 8); BBox* box = new BBox(rect, "EnableScreenSaverBox", B_FOLLOW_ALL); box->SetLabel(fEnableCheckBox); fFadeView->AddChild(box); // Start Screensaver rect.left += radioButtonOffset + 6; rect.top = fEnableCheckBox->Bounds().bottom + 8.0f; rect.right = box->Bounds().right - 8; BStringView* stringView = new BStringView(rect, NULL, B_TRANSLATE("Start screensaver")); stringView->ResizeToPreferred(); box->AddChild(stringView); rect.left += labelWidth - 4; fRunSlider = new TimeSlider(rect, "RunSlider", kMsgRunSliderChanged, kMsgRunSliderUpdate); float width, height; fRunSlider->GetPreferredSize(&width, &height); fRunSlider->ResizeTo(fRunSlider->Bounds().Width(), height); box->AddChild(fRunSlider); // Turn Off rect.left = 10; rect.OffsetBy(0, fRunSlider->Bounds().Height() + 4.0f); fTurnOffCheckBox = new BCheckBox(rect, "TurnOffScreenCheckBox", B_TRANSLATE("Turn off screen"), new BMessage(kMsgTurnOffCheckBox)); fTurnOffCheckBox->ResizeToPreferred(); box->AddChild(fTurnOffCheckBox); rect.top += 3; rect.left += radioButtonOffset + labelWidth; fTurnOffSlider = new TimeSlider(rect, "TurnOffSlider", kMsgTurnOffSliderChanged, kMsgTurnOffSliderUpdate); fTurnOffSlider->ResizeTo(fTurnOffSlider->Bounds().Width(), height); box->AddChild(fTurnOffSlider); rgb_color textColor = tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DISABLED_LABEL_TINT); BRect textRect(0, 0, fTurnOffSlider->Bounds().Width(), height); textRect.InsetBy(0, 3); fTurnOffNotSupported = new BTextView(rect, "not_supported", textRect, be_plain_font, &textColor, B_FOLLOW_ALL, B_WILL_DRAW); fTurnOffNotSupported->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); fTurnOffNotSupported->MakeEditable(false); fTurnOffNotSupported->MakeSelectable(false); fTurnOffNotSupported->SetText( B_TRANSLATE("Display Power Management Signaling not available")); fTurnOffNotSupported->ResizeTo(fTurnOffSlider->Bounds().Width(), height); box->AddChild(fTurnOffNotSupported); // Password rect.left = 10; rect.OffsetBy(0, fTurnOffSlider->Bounds().Height() + 4.0f); fPasswordCheckBox = new BCheckBox(rect, "PasswordCheckbox", B_TRANSLATE("Password lock"), new BMessage(kMsgPasswordCheckBox)); fPasswordCheckBox->ResizeToPreferred(); box->AddChild(fPasswordCheckBox); rect.top += 3; rect.left += radioButtonOffset + labelWidth; fPasswordSlider = new TimeSlider(rect, "PasswordSlider", kMsgPasswordSliderChanged, kMsgPasswordSliderUpdate); fPasswordSlider->ResizeTo(fPasswordSlider->Bounds().Width(), height); box->AddChild(fPasswordSlider); rect.OffsetBy(0, fTurnOffSlider->Bounds().Height() + 4.0f); rect.left = rect.right; fPasswordButton = new BButton(rect, "PasswordButton", B_TRANSLATE("Password" B_UTF8_ELLIPSIS), new BMessage(kMsgChangePassword), B_FOLLOW_TOP | B_FOLLOW_RIGHT); fPasswordButton->ResizeToPreferred(); fPasswordButton->MoveBy(-fPasswordButton->Bounds().Width(), 0); box->AddChild(fPasswordButton); // Bottom float monitorHeight = 10 + textHeight * 3; float monitorWidth = monitorHeight * 4 / 3; rect.left = 11; rect.top = box->Bounds().Height() - 15 - monitorHeight; rect.right = rect.left + monitorWidth; rect.bottom = rect.top + monitorHeight; box->AddChild(fFadeNow = new ScreenCornerSelector(rect, "FadeNow", new BMessage(kMsgFadeCornerChanged), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM)); rect.OffsetBy(monitorWidth + 10, 0); stringView = new BStringView(rect, NULL, B_TRANSLATE("Fade now when"), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM); stringView->ResizeToPreferred(); float maxWidth = stringView->Bounds().Width(); box->AddChild(stringView); rect.OffsetBy(0, stringView->Bounds().Height()); stringView = new BStringView(rect, NULL, B_TRANSLATE("mouse is here"), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM); stringView->ResizeToPreferred(); if (maxWidth < stringView->Bounds().Width()) maxWidth = stringView->Bounds().Width(); box->AddChild(stringView); rect.left += maxWidth + 20; rect.top = box->Bounds().Height() - 15 - monitorHeight; rect.right = rect.left + monitorWidth; rect.bottom = rect.top + monitorHeight; box->AddChild(fFadeNever = new ScreenCornerSelector(rect, "FadeNever", new BMessage(kMsgNeverFadeCornerChanged), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM)); rect.OffsetBy(monitorWidth + 10, 0); stringView = new BStringView(rect, NULL,B_TRANSLATE("Don't fade when"), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM); stringView->ResizeToPreferred(); if (maxWidth < stringView->Bounds().Width()) maxWidth = stringView->Bounds().Width(); box->AddChild(stringView); rect.OffsetBy(0, stringView->Bounds().Height()); stringView = new BStringView(rect, NULL, B_TRANSLATE("mouse is here"), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM); stringView->ResizeToPreferred(); if (maxWidth < stringView->Bounds().Width()) maxWidth = stringView->Bounds().Width(); box->AddChild(stringView); float size = rect.left + maxWidth + 40; if (fMinWidth < size) fMinWidth = size; size = fPasswordButton->Frame().bottom + box->Frame().top + monitorHeight + 40 + textHeight * 2; if (fMinHeight < size) fMinHeight = size; }