// 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); }
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); }
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); }
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 MainWindow::setupUi() { BRect frame(100, 100, 500, 400); _win = new BWindow(frame, "Retrospring for BeOS", B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE); frame.Set(10, 10, 11, 11); BStringView *label = new BStringView(frame, "rs_label", "Welcome to Retrospring!"); label->ResizeToPreferred(); _win->AddChild(label); _win->Show(); }
AlertView::AlertView(BRect frame, const char *name) : BView(frame, name, B_FOLLOW_ALL, B_WILL_DRAW | B_PULSE_NEEDED), // we will wait 12 seconds until we send a message fSeconds(12) { SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); fBitmap = InitIcon(); BRect rect(60, 8, 400, 36); BStringView *stringView = new BStringView(rect, NULL, "Do you wish to keep these settings?"); stringView->SetFont(be_bold_font); stringView->ResizeToPreferred(); AddChild(stringView); rect = stringView->Frame(); rect.OffsetBy(0, rect.Height()); fCountdownView = new BStringView(rect, "countdown", NULL); UpdateCountdownView(); fCountdownView->ResizeToPreferred(); AddChild(fCountdownView); BButton* keepButton = new BButton(rect, "keep", "Keep", new BMessage(BUTTON_KEEP_MSG), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM); keepButton->ResizeToPreferred(); AddChild(keepButton); BButton* button = new BButton(rect, "undo", "Undo", new BMessage(BUTTON_UNDO_MSG), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM); button->ResizeToPreferred(); AddChild(button); // we're resizing ourselves to the right size // (but we're not implementing GetPreferredSize(), bad style!) float width = stringView->Frame().right; if (fCountdownView->Frame().right > width) width = fCountdownView->Frame().right; if (width < Bounds().Width()) width = Bounds().Width(); float height = fCountdownView->Frame().bottom + 24 + button->Bounds().Height(); ResizeTo(width, height); keepButton->MoveTo(Bounds().Width() - 8 - keepButton->Bounds().Width(), Bounds().Height() - 8 - keepButton->Bounds().Height()); button->MoveTo(keepButton->Frame().left - button->Bounds().Width() - 8, keepButton->Frame().top); keepButton->MakeDefault(true); }
BView * LibraryWindow::AddHeader(BPoint location, const char *label) { Lock(); BRect r(location.x,location.y,location.x + 1, location.y + 1); BStringView *header = new BStringView(r,"header",label); fCheckList->AddChild(header); header->SetFont(be_bold_font); header->SetHighColor(0,0,255); header->ResizeToPreferred(); Unlock(); return header; }
void BBox::SetLabel(const char *label) { if (!(label == NULL || *label == 0)) { BStringView *strView = cast_as(fLabelView, BStringView); if (strView != NULL) { strView->SetText(label); strView->ResizeToPreferred(); ReAdjustLabel(); return; } if ((strView = new BStringView(BRect(0, 0, 1, 1), NULL, label, B_FOLLOW_NONE)) == NULL) return; strView->SetFont(be_bold_font); strView->ResizeToPreferred(); if (SetLabel(strView) != B_OK) delete strView; } else if (fLabelView != NULL) { BView *view = fLabelView; fLabelView = NULL; view->RemoveSelf(); delete view; } }
/*! This creates a view that handles all incoming messages itself - that's what is meant with self-hosting. */ BView * DefaultMediaTheme::MakeSelfHostingViewFor(BParameter& parameter, const BRect* hintRect) { if (parameter.Flags() & B_HIDDEN_PARAMETER || parameter_should_be_hidden(parameter)) return NULL; BView *view = MakeViewFor(¶meter, hintRect); if (view == NULL) { // The MakeViewFor() method above returns a BControl - which we // don't need for a null parameter; that's why it returns NULL. // But we want to see something anyway, so we add a string view // here. if (parameter.Type() == BParameter::B_NULL_PARAMETER) { if (parameter.Group()->ParameterAt(0) == ¶meter) { // this is the first parameter in this group, so // let's use a nice title view TitleView *titleView = new TitleView(BRect(0, 0, 10, 10), parameter.Name()); titleView->ResizeToPreferred(); return titleView; } BStringView *stringView = new BStringView(BRect(0, 0, 10, 10), parameter.Name(), parameter.Name()); stringView->SetAlignment(B_ALIGN_CENTER); stringView->ResizeToPreferred(); return stringView; } return NULL; } MessageFilter *filter = MessageFilter::FilterFor(view, parameter); if (filter != NULL) view->AddFilter(filter); return view; }
StringEditor::StringEditor(BRect rect, DataEditor& editor) : TypeEditorView(rect, B_TRANSLATE("String editor"), B_FOLLOW_ALL, 0, editor) { SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); BStringView *stringView = new BStringView(BRect(5, 5, rect.right, 20), B_EMPTY_STRING, B_TRANSLATE("Contents:")); stringView->ResizeToPreferred(); AddChild(stringView); rect = Bounds(); rect.top = stringView->Frame().bottom + 5; rect.right -= B_V_SCROLL_BAR_WIDTH; rect.bottom -= B_H_SCROLL_BAR_HEIGHT; fTextView = new BTextView(rect, B_EMPTY_STRING, rect.OffsetToCopy(B_ORIGIN).InsetByCopy(5, 5), B_FOLLOW_ALL, B_WILL_DRAW); BScrollView* scrollView = new BScrollView("scroller", fTextView, B_FOLLOW_ALL, B_WILL_DRAW, true, true); AddChild(scrollView); }
LibraryWindow::LibraryWindow(BRect frame, const BMessenger &parent, Project *project) : DWindow(frame,NULL,B_TITLED_WINDOW,B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE), fParent(parent), fProject(project) { if (project) { BString title(TR("Libraries: ")); title << project->GetName(); SetTitle(title.String()); } BView *top = GetBackgroundView(); BRect r(10,10,11,11); BStringView *label = new BStringView(r,"label",TR("Choose the system libraries " "for your project.")); label->ResizeToPreferred(); top->AddChild(label); label->SetText(TR("Scanning libraries…")); r = Bounds().InsetByCopy(10,10); r.top = label->Frame().top + 20; r.right -= B_V_SCROLL_BAR_WIDTH; fCheckList = new BView(r,"checklist",B_FOLLOW_ALL,B_WILL_DRAW); BScrollView *scrollView = new BScrollView("scrollView",fCheckList, B_FOLLOW_ALL, 0,false,true); top->AddChild(scrollView); fScanThread = spawn_thread(ScanThread,"libscanthread",B_NORMAL_PRIORITY,this); resume_thread(fScanThread); fCheckList->MakeFocus(true); }
void ChannelOptions::Init(void) { BString temp(S_CHANOPTS_TITLE); temp.Prepend(chan_name); SetTitle(temp.String()); bgView = new BView(Bounds(), "Background", B_FOLLOW_ALL_SIDES, B_WILL_DRAW); bgView->AdoptSystemColors(); AddChild(bgView); BStringView* tempStringView = new BStringView(Bounds(), "temp", "AEIOUglqj", 0, 0); tempStringView->ResizeToPreferred(); float stringHeight = tempStringView->Frame().bottom; delete tempStringView; privilegesView = new BView(BRect(bgView->Frame().left + 2, bgView->Frame().top + 2, bgView->Frame().right - 2, stringHeight + 2), "privilege message", 0, B_WILL_DRAW); privilegesView->SetViewColor(0, 100, 0); bgView->AddChild(privilegesView); BString privString; // this will become dynamic based on the current mode privString += S_CHANOPTS_OPID1; privString += S_CHANOPTS_OPID2; BStringView* privMsgView = new BStringView(BRect(privilegesView->Bounds().left, privilegesView->Bounds().top, privilegesView->Bounds().right, stringHeight), "privMsgView", privString.String(), 0, B_WILL_DRAW); privMsgView->SetHighColor(255, 255, 255); privMsgView->SetAlignment(B_ALIGN_CENTER); privilegesView->ResizeToPreferred(); privilegesView->AddChild(privMsgView); }
/*! \brief Add the interface for configuring colors. * \param[in] frame The frame of the view. * \param[in] id The ID of the interface to configure the colors for. */ BBox* CalendarModulePreferencesView::BuildColorSelectors( BRect frame, const BString& id ) { BBox* toReturn = NULL; BLayoutItem* layoutItem = NULL; BString sb; BRect tempRect = frame; // tempRect.InsetBySelf( 10, 10 ); BMessage* toSend = NULL; // Access the preferences CalendarModulePreferences* prefs = pref_GetPreferencesForCalendarModule( id ); if ( !prefs ) { return NULL; } // Prepare the overall BBox toReturn = new BBox( frame, "Color selector" ); if ( ! toReturn ) return NULL; toReturn->SetLabel( "Set up colors" ); // Set up the layout for this BBox BGroupLayout* groupLayout = new BGroupLayout( B_VERTICAL ); if ( !groupLayout ) { delete toReturn; return NULL; } groupLayout->SetInsets( 10, 15, 10, 5 ); groupLayout->SetSpacing( 2 ); toReturn->SetLayout( groupLayout ); // Label over the CategoryListView for the viewer BStringView* viewerString = new BStringView( BRect( 0, 0, 1, 1 ), "Colors Changer Explanation", "Double-click the color to edit it." ); if ( !viewerString ) { delete toReturn; return NULL; } viewerString->ResizeToPreferred(); layoutItem = groupLayout->AddView( 0, viewerString, 0 ); layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_USE_FULL_WIDTH, B_ALIGN_TOP ) ); toSend = new BMessage( kCategoryInvoked ); if ( !toSend ) { /* Panic! */ exit( 1 ); } toSend->AddString( "Calendar module", id ); CategoryListView* menuColors = new CategoryListView( BRect( 0, 0, tempRect.Width() + B_V_SCROLL_BAR_WIDTH, tempRect.Height() + B_H_SCROLL_BAR_HEIGHT ), "Colors list view" ); if ( !menuColors ) { // menuString->RemoveSelf(); delete menuString; // viewerString->RemoveSelf(); delete viewerString; delete toReturn; return NULL; } menuColors->SetInvocationMessage( toSend ); // Fill the CategoryListView for the menu colors sb.SetTo( "Color for displaying weekdays in the controls" ); CategoryListItem* toAdd = new CategoryListItem( prefs->GetWeekdaysColor( false ), sb ); if ( toAdd ) { menuColors->AddItem( toAdd ); } sb.SetTo( "Color for displaying weekends in the controls" ); toAdd = new CategoryListItem( prefs->GetWeekendsColor( false ), sb ); if ( toAdd ) { menuColors->AddItem( toAdd ); } sb.SetTo( "Color for displaying weekdays in Viewer" ); toAdd = new CategoryListItem( prefs->GetWeekdaysColor( true ), sb ); if ( toAdd ) { menuColors->AddItem( toAdd ); } sb.SetTo( "Color for displaying weekends in Viewer" ); toAdd = new CategoryListItem( prefs->GetWeekendsColor( true ), sb ); if ( toAdd ) { menuColors->AddItem( toAdd ); } sb.SetTo( "Color for displaying service items in the controls" ); toAdd = new CategoryListItem( prefs->GetServiceItemsColor( false ), sb ); if ( toAdd ) { menuColors->AddItem( toAdd ); } sb.SetTo( "Color for displaying service items in the Viewer" ); toAdd = new CategoryListItem( prefs->GetServiceItemsColor( true ), sb ); if ( toAdd ) { menuColors->AddItem( toAdd ); } menuColors->ResizeToPreferred(); // BSize setSize( menuColors->Bounds().Width(), menuColors->Bounds().Height() ); BSize setSize( frame.Width(), menuColors->Bounds().Height()+5 ); layoutItem = groupLayout->AddView( 1, menuColors, 0 ); layoutItem->SetExplicitMaxSize( setSize ); layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_USE_FULL_WIDTH, B_ALIGN_TOP ) ); groupLayout->InvalidateLayout(); return toReturn; } // <-- end of function CalendarModulePreferecesView::BuildColorSelectors
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(); }
ProjectSettingsWindow::ProjectSettingsWindow(BRect frame, Project *proj) : DWindow(frame,TR("Project Settings"),B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_H_RESIZABLE), fProject(proj), fDirty(false) { if (!fProject) debugger("Bad project given to Project Settings window"); fRefFilter = new TypedRefFilter(NULL,B_DIRECTORY_NODE); BMessenger msgr(this); entry_ref projfolder_ref; BEntry(fProject->GetPath().GetFolder()).GetRef(&projfolder_ref); fFilePanel = new BFilePanel(B_OPEN_PANEL,&msgr,&projfolder_ref,B_DIRECTORY_NODE, true, new BMessage(M_ADD_PATH),fRefFilter); fAutolock = new BAutolock(fProject); AddCommonFilter(new EscapeCancelFilter()); BView *top = GetBackgroundView(); BRect r(Bounds()); fTabView = new BTabView(r,"tabview"); top->AddChild(fTabView); r.InsetBy(5,5); r.bottom -= fTabView->TabHeight(); BRect bounds = r.OffsetToCopy(0,0); fGeneralView = new BView(r,TR("General"),B_FOLLOW_ALL,B_WILL_DRAW); fGeneralView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); fTabView->AddTab(fGeneralView); r.right -= 10.0; fTargetText = new AutoTextControl(r,"targetname",TR("Target Name:"), fProject->GetTargetName(), new BMessage(M_TARGET_NAME_CHANGED), B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP); fGeneralView->AddChild(fTargetText); float pwidth, pheight; fTargetText->GetPreferredSize(&pwidth, &pheight); fTargetText->ResizeTo(r.Width(),pheight); r.bottom = r.top + pheight; fTargetText->SetDivider(fTargetText->StringWidth(TR("Target Name:")) + 5.0); r = fTargetText->Frame(); r.OffsetBy(0,r.Height() + 10.0); BMenu *menu = new BMenu(TR("Target Type")); menu->AddItem(new BMenuItem(TR("Application"),new BMessage(M_SET_TARGET_TYPE))); menu->AddItem(new BMenuItem(TR("Shared Library"),new BMessage(M_SET_TARGET_TYPE))); menu->AddItem(new BMenuItem(TR("Static Library"),new BMessage(M_SET_TARGET_TYPE))); menu->AddItem(new BMenuItem(TR("Device Driver"),new BMessage(M_SET_TARGET_TYPE))); r.right = (bounds.right - 5.0) / 2.0; r.bottom = r.top + 25; fTypeField = new BMenuField(r,"type",TR("Target Type:"),menu); fGeneralView->AddChild(fTypeField); fTypeField->SetDivider(fTypeField->StringWidth(TR("Target Type:")) + 5.0); SetToolTip(fTypeField,TR("The kind of program you want to build")); menu->SetTargetForItems(this); menu->SetLabelFromMarked(true); BMenuItem *item = menu->ItemAt(fProject->TargetType()); if (item) item->SetMarked(true); r.OffsetBy(0,r.Height() + 10.0); BStringView *label = new BStringView(r,"label",TR("Include Paths:")); label->ResizeToPreferred(); fGeneralView->AddChild(label); r = label->Frame(); r.OffsetBy(0,r.Height() + 5.0); // We create a button now so that the list expands to fill the entire window // while leaving space for the two buttons at the bottom. Note that we do not // actually add the button to the window until later to preserve proper // keyboard navigation order BButton *add = new BButton(BRect(0,0,1,1),"addbutton",TR("Add…"), new BMessage(M_SHOW_ADD_PATH), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM); add->ResizeToPreferred(); add->MoveTo(5,fGeneralView->Bounds().bottom - 10.0 - add->Frame().Height()); r.right = bounds.right - 10.0 - B_V_SCROLL_BAR_WIDTH; r.bottom = add->Frame().top - 10.0 - B_H_SCROLL_BAR_HEIGHT; fIncludeList = new IncludeList(r,fProject->GetPath().GetFolder()); BScrollView *scrollView = new BScrollView("scrollview",fIncludeList, B_FOLLOW_ALL,0, true, true); scrollView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); fGeneralView->AddChild(scrollView); float width = 0.0; for (int32 i = 0; i < fProject->CountLocalIncludes(); i++) { BStringItem *item = new BStringItem(fProject->LocalIncludeAt(i).Relative().String()); float strwidth = fIncludeList->StringWidth(item->Text()); width = MAX(width, strwidth); fIncludeList->AddItem(item); } if (width > fIncludeList->Bounds().Width()) { BScrollBar *hbar = scrollView->ScrollBar(B_HORIZONTAL); hbar->SetRange(0.0, width - fIncludeList->Bounds().Width()); } SetToolTip(fIncludeList,TR("The folders you want Paladin to search for header files")); fGeneralView->AddChild(add); BButton *remove = new BButton(BRect(0,0,1,1),"removebutton",TR("Remove"), new BMessage(M_REMOVE_PATH), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM); remove->ResizeToPreferred(); remove->MoveTo(add->Frame().right + 10.0, add->Frame().top); fGeneralView->AddChild(remove); r = bounds; fBuildView = new BView(bounds.OffsetByCopy(5,5),TR("Build"),B_FOLLOW_ALL,B_WILL_DRAW); fBuildView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); fTabView->AddTab(fBuildView); menu = new BMenu(TR("Optimization")); menu->AddItem(new BMenuItem(TR("None"),new BMessage(M_SET_OP_VALUE))); menu->AddItem(new BMenuItem(TR("Some"),new BMessage(M_SET_OP_VALUE))); menu->AddItem(new BMenuItem(TR("More"),new BMessage(M_SET_OP_VALUE))); menu->AddItem(new BMenuItem(TR("Full"),new BMessage(M_SET_OP_VALUE))); r.right = (bounds.right - 5.0) / 2.0; r.bottom = r.top + 25; fOpField = new BMenuField(r,"optimize",TR("Optimize"),menu); fBuildView->AddChild(fOpField); fOpField->SetDivider(fOpField->StringWidth(TR("Optimize")) + 5.0); SetToolTip(fOpField,TR("Compiler optimization level. Disabled when debugging info is checked.")); menu->SetTargetForItems(this); menu->SetLabelFromMarked(true); item = menu->ItemAt(fProject->OpLevel()); if (item) item->SetMarked(true); r.right = bounds.right - 10.0; r.OffsetTo(5, fOpField->Frame().bottom + 5); fOpSizeBox = new BCheckBox(r,"opsizebox",TR("Optimize for size over speed"), new BMessage(M_TOGGLE_OPSIZE)); fOpSizeBox->ResizeToPreferred(); fBuildView->AddChild(fOpSizeBox); r = fOpSizeBox->Frame(); if (fProject->OpForSize()) fOpSizeBox->SetValue(B_CONTROL_ON); if (fProject->Debug()) { fOpField->SetEnabled(false); fOpSizeBox->SetEnabled(false); } r.OffsetBy(0, r.Height() + 10); fDebugBox = new BCheckBox(r,"debugbox",TR("Build debugging information"), new BMessage(M_TOGGLE_DEBUG)); fDebugBox->ResizeToPreferred(); if (fProject->Debug()) fDebugBox->SetValue(B_CONTROL_ON); fBuildView->AddChild(fDebugBox); SetToolTip(fDebugBox,TR("Check this if you want to use your program in a debugger during development." "You'll want to rebuild your project after change this.")); r.OffsetBy(0, r.Height()); fProfileBox = new BCheckBox(r,"profilebox",TR("Build profiling information"), new BMessage(M_TOGGLE_PROFILE)); fProfileBox->ResizeToPreferred(); if (fProject->Profiling()) fProfileBox->SetValue(B_CONTROL_ON); fBuildView->AddChild(fProfileBox); SetToolTip(fProfileBox,TR("Check this if you want to use your program " "with gprof or bprof for profiling.")); r.OffsetBy(0, r.Height() + 10.0); r.right = bounds.right - 10.0; fCompileText = new AutoTextControl(r,"extracc","Extra Compiler Options:", fProject->ExtraCompilerOptions(), new BMessage(M_CCOPTS_CHANGED), B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP); fBuildView->AddChild(fCompileText); fCompileText->SetDivider(fCompileText->StringWidth(fCompileText->Label()) + 5.0); SetToolTip(fCompileText,TR("Extra GCC flags you wish included when each file is compiled.")); r = fCompileText->Frame(); r.OffsetBy(0,r.Height() + 10); fLinkText = new AutoTextControl(r,"extrald",TR("Extra Linker Options:"), fProject->ExtraLinkerOptions(), new BMessage(M_LDOPTS_CHANGED), B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP); fBuildView->AddChild(fLinkText); fLinkText->SetDivider(fCompileText->Divider()); SetToolTip(fLinkText,TR("Extra GCC linker flags you wish included when your project is linked.")); fTabView->Select(0L); fBuildView->ResizeTo(fGeneralView->Bounds().Width(),fGeneralView->Bounds().Height()); fTargetText->MakeFocus(true); }
RecipeEditor::RecipeEditor(const BRect &frame, const BMessenger &msgr, const int32 &number, const char *category) : BWindow(frame,"Add Recipe",B_FLOATING_WINDOW_LOOK, B_MODAL_SUBSET_WINDOW_FEEL, B_ASYNCHRONOUS_CONTROLS), fMessenger(msgr), fNumber(number), fCategory(category) { AddShortcut('W', B_COMMAND_KEY, new BMessage(B_QUIT_REQUESTED)); AddShortcut('Q', B_COMMAND_KEY, new BMessage(M_QUIT_APP)); BView *back = new BView(Bounds(),"back",B_FOLLOW_ALL, B_WILL_DRAW); back->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); AddChild(back); fCategories = new BMenu("Categories"); CppSQLite3Query query = DBQuery("select category from categories order by category;", "RecipeEditor:get categories"); while(!query.eof()) { BString cat(DeescapeIllegalCharacters(query.getStringField(0))); BMessage *menumsg = new BMessage(M_CATEGORY_CHANGED); menumsg->AddString("name",cat); fCategories->AddItem(new BMenuItem(cat.String(),menumsg)); query.nextRow(); } fCategories->SetRadioMode(true); fCategories->SetLabelFromMarked(true); if(fCategories->CountItems()>0) fCategories->ItemAt(0)->SetMarked(true); BRect r(10,10,10 + fCategories->MaxContentWidth(),11); BMenuField *field = new BMenuField(r,"field","Category",fCategories, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_NAVIGABLE | B_NAVIGABLE_JUMP); back->AddChild(field); field->ResizeToPreferred(); r = field->Frame(); if(category) { BMenuItem *marked = fCategories->FindItem(category); if(marked) marked->SetMarked(true); } else { BMenuItem *marked = fCategories->ItemAt(0L); if(marked) marked->SetMarked(true); } r.OffsetBy(0,r.Height() + 10); fNameBox = new AutoTextControl(r,"namebox","Name: ",NULL,NULL, B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP, B_WILL_DRAW | B_PULSE_NEEDED | B_NAVIGABLE | B_NAVIGABLE_JUMP); fNameBox->SetEscapeCancel(true); fNameBox->SetDivider(be_plain_font->StringWidth("Name ") + 5); back->AddChild(fNameBox); fNameBox->ResizeToPreferred(); r = fNameBox->Frame(); r.right = Bounds().right - 10; fNameBox->ResizeTo(r.Width(), r.Height()); r.OffsetBy(0,r.Height() + 10); BStringView *label = new BStringView(r,"inglabel","Ingredients:"); back->AddChild(label); r.OffsetBy(0,r.Height() + 10); r.bottom = r.top + 100; r.right -= B_V_SCROLL_BAR_WIDTH; BRect textrect = r.OffsetToCopy(0,0); textrect.InsetBy(10,10); fIngredientBox = new BTextView(r, "ingredients", textrect, B_FOLLOW_ALL, B_WILL_DRAW | B_PULSE_NEEDED | B_NAVIGABLE | B_NAVIGABLE_JUMP); fIngredientBox->SetDoesUndo(true); BScrollView *ingredscroll = new BScrollView("ingredients_scroller",fIngredientBox, B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP,0,false, true); back->AddChild(ingredscroll); r = ingredscroll->Frame(); label = new BStringView(BRect(10,10,11,11),"dirlabel","Directions:"); label->ResizeToPreferred(); label->MoveTo(10, r.bottom + 10); back->AddChild(label); r.OffsetBy(0,r.Height() + 20 + label->Frame().Height()); r.right -= B_V_SCROLL_BAR_WIDTH; textrect = r.OffsetToCopy(0,0); textrect.InsetBy(10,10); fDirectionsBox = new BTextView(r, "directions", textrect, B_FOLLOW_ALL, B_WILL_DRAW | B_PULSE_NEEDED | B_NAVIGABLE | B_NAVIGABLE_JUMP); fDirectionsBox->SetDoesUndo(true); BScrollView *dirscroll = new BScrollView("directions_scroller",fDirectionsBox, B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP,0,false, true); back->AddChild(dirscroll); fOK = new BButton(BRect(10,10,11,11),"ok","Cancel", new BMessage(M_ADD_RECIPE), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM, B_WILL_DRAW); fOK->ResizeToPreferred(); fOK->SetLabel("OK"); fOK->MoveTo(Bounds().right - fOK->Bounds().Width() - 10, Bounds().bottom - fOK->Bounds().Height() - 10); r = fOK->Frame(); back->AddChild(fOK); r.OffsetBy(-r.Width() - 10, 0); fCancel = new BButton(r,"cancel","Cancel",new BMessage(B_QUIT_REQUESTED), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM, B_WILL_DRAW); back->AddChild(fCancel); field->MakeFocus(true); ResizeTo(Bounds().Width(), fDirectionsBox->Parent()->Frame().bottom + 20 + fOK->Bounds().Height()); dirscroll->SetResizingMode(B_FOLLOW_ALL); // This is the part that's different for editing a recipe as opposed to // just adding one to the database if(number >= 0 && category) { SetTitle("Edit Recipe"); BString name, ingredients, directions; if(GetRecipe(number,category,name,ingredients,directions)) { BMenuItem *item = fCategories->FindItem(category); if(item) item->SetMarked(true); fNameBox->SetText(name.String()); fIngredientBox->SetText(ingredients.String()); fDirectionsBox->SetText(directions.String()); fOK->SetMessage(new BMessage(M_EDIT_RECIPE)); } } AddShortcut(B_ENTER, B_COMMAND_KEY, new BMessage(fOK->Command())); }
// -------------------------------------------------- JobSetupWindow::JobSetupWindow(BMessage *msg, const char * printerName) : HWindow(BRect(0, 0, 320, 160), "Job Setup", B_TITLED_WINDOW_LOOK, B_MODAL_APP_WINDOW_FEEL, B_NOT_RESIZABLE | B_NOT_MINIMIZABLE | B_NOT_ZOOMABLE) { fSetupMsg = msg; fExitSem = create_sem(0, "JobSetup"); fResult = B_ERROR; if (printerName) { BString title; title << printerName << " Job Setup"; SetTitle(title.String()); fPrinterName = printerName; } // ---- Ok, build a default job setup user interface BRect r; BBox *panel; BBox *line; BButton *ok; BButton *cancel; BStringView *sv; float x, y, w, h; float indent; int32 copies; int32 firstPage; int32 lastPage; bool allPages; char buffer[80]; // PrinterDriver ensures that property exists fSetupMsg->FindInt32("copies", &copies); fSetupMsg->FindInt32("first_page", &firstPage); fSetupMsg->FindInt32("last_page", &lastPage); BMessage doc_info; if (B_OK != fSetupMsg->FindMessage("doc_info", &doc_info)) { // default fields doc_info.AddString("Author", ""); doc_info.AddString("Subject", ""); doc_info.AddString("Keywords", ""); fSetupMsg->AddMessage("doc_info", &doc_info); } AddFields(&fDocInfo, fSetupMsg, NULL, includeKeys); allPages = firstPage == 1 && lastPage == MAX_INT32; r = Bounds(); // add a *dialog* background panel = new BBox(r, "top_panel", B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP, B_PLAIN_BORDER); const int kMargin = 6; //const char *kCopiesLabel = "Copies:"; const char *kCopiesLabelExtraSpace = "Copies:##"; const char *kPagesRangeLabel = "Pages:"; const char *kAllPagesLabel = "All"; const char *kPagesRangeSelectionLabel = ""; const char *kFromLabel = "From:"; const char *kFromLabelExtraSpace = "From:##"; const char *kToLabel = "To:"; const char *kToLabelExtraSpace = "To:##"; r = panel->Bounds(); x = r.left + kMargin; y = r.top + kMargin; // add a "copies" input field /* Simon: temporarily removed this code sprintf(buffer, "%d", (int)copies); fCopies = new BTextControl(BRect(x, y, x+100, y+20), "copies", kCopiesLabel, buffer, new BMessage(NB_COPIES_MSG)); fCopies->SetAlignment(B_ALIGN_LEFT, B_ALIGN_RIGHT); fCopies->ResizeToPreferred(); fCopies->GetPreferredSize(&w, &h); panel->AddChild(fCopies); y += h + kMargin; // "new line" */ // add a "pages" label sv = new BStringView(BRect(x, y, x+100, y+20), "pages_range", kPagesRangeLabel); panel->AddChild(sv); sv->ResizeToPreferred(); sv->GetPreferredSize(&w, &h); // align "copies" textcontrol field on the "allPages" radiobutton bellow... indent = be_plain_font->StringWidth(kCopiesLabelExtraSpace); w += kMargin; if ( w > indent ) indent = w; // fCopies->SetDivider(indent); x += indent; // add a "all" radiobutton fAll = new BRadioButton(BRect(x, y, x+100, y+20), "all_pages", kAllPagesLabel, new BMessage(ALL_PAGES_MGS)); fAll->ResizeToPreferred(); fAll->GetPreferredSize(&w, &h); fAll->SetValue(allPages); panel->AddChild(fAll); y += h + kMargin; // "new line" // add a range selection raddiobutton fRange = new BRadioButton(BRect(x, y, x+100, y+20), "pages_range_selection", kPagesRangeSelectionLabel, new BMessage(RANGE_SELECTION_MSG)); fRange->ResizeToPreferred(); fRange->GetPreferredSize(&w, &h); fRange->SetValue(!allPages); panel->AddChild(fRange); x += w + kMargin; // add a "from" field if (allPages) { buffer[0] = 0; } else { sprintf(buffer, "%d", (int)firstPage); } fFrom = new BTextControl(BRect(x, y, x+100, y+20), "from_field", kFromLabel, buffer, new BMessage(RANGE_FROM_MSG)); fFrom->SetAlignment(B_ALIGN_LEFT, B_ALIGN_RIGHT); fFrom->SetDivider(be_plain_font->StringWidth(kFromLabelExtraSpace)); fFrom->ResizeToPreferred(); fFrom->GetPreferredSize(&w, &h); panel->AddChild(fFrom); x += w + kMargin; // add a "to" field if (allPages) { buffer[0] = 0; } else { sprintf(buffer, "%d", (int)lastPage); } fTo = new BTextControl(BRect(x, y, x+100, y+20), "to_field", kToLabel, buffer, new BMessage(RANGE_TO_MSG)); fTo->SetAlignment(B_ALIGN_LEFT, B_ALIGN_RIGHT); fTo->SetDivider(be_plain_font->StringWidth(kToLabelExtraSpace)); fTo->ResizeToPreferred(); fTo->GetPreferredSize(&w, &h); panel->AddChild(fTo); y += h + kMargin + kMargin; // "new line" x = r.left + kMargin; // add a separator line... line = new BBox(BRect(r.left, y - 1, r.right, y), NULL, B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP ); panel->AddChild(line); y += 2 + kMargin + kMargin; // "new line" // add a "OK" button, and make it default ok = new BButton(BRect(x, y, x+100, y+20), NULL, "OK", new BMessage(OK_MSG), B_FOLLOW_RIGHT | B_FOLLOW_TOP); ok->MakeDefault(true); ok->ResizeToPreferred(); ok->GetPreferredSize(&w, &h); x = r.right - w - kMargin; ok->MoveTo(x, ok->Frame().top); // put the ok bottom at bottom right corner panel->AddChild(ok); // add a "Cancel" button cancel = new BButton(BRect(x, y, x + 100, y + 20), NULL, "Cancel", new BMessage(CANCEL_MSG), B_FOLLOW_RIGHT | B_FOLLOW_TOP); cancel->ResizeToPreferred(); cancel->GetPreferredSize(&w, &h); cancel->MoveTo(x - w - kMargin, y); // put cancel button left next the ok button panel->AddChild(cancel); // add a "DocInfo" button BButton *button = new BButton(r, NULL, "Doc Info", new BMessage(DOC_INFO_MSG), B_FOLLOW_RIGHT | B_FOLLOW_TOP); button->GetPreferredSize(&w, &h); button->ResizeToPreferred(); button->MoveTo(8, y); panel->AddChild(button); // Finally, add our panel to window AddChild(panel); // Auto resize window ResizeTo(ok->Frame().right + kMargin, ok->Frame().bottom + kMargin); }
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)); }
/*! \brief Constructor for the ActivityWindow class. * \param[in] data The data to be displayed. * \param[in] target The process to be notified about user's choise. * \param[in] name Name of the Event. * \param[in] category Category of the Event. * \param[in] templateMessage The message to be sent to the target. * If \c NULL is passed, then a new message is constructed * with \c kActivityWindowRepsonceMessage value in \c what. * \param[in] reminder \c true if the window is constructed for a reminder, else * \c false. Actually, it matters only for explanation to user. * Default is \c false (it's not a reminder). * \note A note on memory management: * \c data (the ActionData) belongs to the caller, but it's used only for * initialization of this window. I. e., if the user makes changes to the * data while an ActivityWindow is open, the changes won't be reflected. * However, \c target and \c templateMessage belong to this object. User * shouldn't free them or do anything else. */ ActivityWindow::ActivityWindow( ActivityData* data, BMessenger* target, BString name, Category* category, BMessage* templateMessage, bool reminder ) : BWindow( BRect( 0, 0, 400, 500 ), "Event occurred", B_FLOATING_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, B_NOT_MINIMIZABLE | B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS ), fTarget( target ), fData( data ), fTemplateMessage( templateMessage ), bIsReminder( reminder ), fLastError( B_OK ), fEventName( name ), fCategory( category ), fTitle( NULL ), fEventNameView( NULL ), fCategoryView( NULL ), fTextScroller( NULL ), fSnoozeTime( NULL ), fNoteText( NULL ), fSnooze( NULL ), fOk( NULL ) { BFont boldFont( be_bold_font ); BFont plainFont( be_plain_font ); BFont font; // For various font-related activities font_height fh; // For setting the height of the Text View with notification text plainFont.GetHeight( &fh ); int numberOfColumnsInLayout = 2; // Sanity check if ( !data || !target ) { /* Panic! */ fLastError = B_BAD_VALUE; return; } if ( ! fData->GetNotification( NULL ) && ! fData->GetSound( NULL ) && ! fData->GetProgram( NULL, NULL ) ) { // Nothing to do! This is not an error! fLastError = B_NO_INIT; return; } BView* background = new BView( Bounds(), "Background view", B_FOLLOW_ALL_SIDES, B_WILL_DRAW ); if ( !background ) { /* Panic! */ fLastError = B_NO_MEMORY; return; } this->AddChild( background ); BGridLayout* gridLayout = new BGridLayout(); if ( !gridLayout ) { /* Panic! */ fLastError = B_NO_MEMORY; return; } background->SetLayout( gridLayout ); background->SetViewColor( ui_color( B_PANEL_BACKGROUND_COLOR ) ); gridLayout->SetInsets( 5, 5, 5, 5 ); /*------------------------------------------------- * First line - explaining what's happening here *------------------------------------------------*/ BStringView* exp = new BStringView( BRect( 0, 0, 1, 1 ), "Explanation 1", ( bIsReminder ? "A Reminder has occured!" : "An Event has occured!" ) ); if ( ! exp ) { /* Panic! */ fLastError = B_NO_MEMORY; return; } exp->SetFont( &boldFont ); exp->ResizeToPreferred(); BLayoutItem* layoutItem = gridLayout->AddView( exp, 0, 0, numberOfColumnsInLayout, 1 ); if ( layoutItem ) { layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_CENTER, B_ALIGN_TOP ) ); } /*----------------------------------------------------------------- * Second line - event's name on category's color as background *----------------------------------------------------------------*/ // Create background // Note: the pulse is requested for this Window to receive Pulse notifications. fBackground = new BView( BRect( 0, 0, 1, 1 ), "Background", B_FOLLOW_LEFT_RIGHT | B_FOLLOW_V_CENTER | B_PULSE_NEEDED, B_WILL_DRAW ); if ( !fBackground ) { /* Panic! */ fLastError = B_NO_MEMORY; return; } fBackground->SetViewColor( ui_color( B_PANEL_BACKGROUND_COLOR ) ); layoutItem = gridLayout->AddView( fBackground, 0, 1, numberOfColumnsInLayout, 1 ); if ( layoutItem ) { layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_USE_FULL_WIDTH, B_ALIGN_USE_FULL_HEIGHT ) ); } BGroupLayout* bgLayout = new BGroupLayout( B_VERTICAL ); if ( !bgLayout ) { /* Panic! */ fLastError = B_NO_MEMORY; return; } fBackground->SetLayout( bgLayout ); bgLayout->SetInsets( 15, 10, 15, 10 ); fBackground->SetViewColor( fCategory.categoryColor ); BString sb = "Category:\n"; sb << fCategory.categoryName; fBackground->SetToolTip( sb.String() ); // Create Event's name view fTitle = new BStringView( BRect( 0, 0, 1, 1 ), "Event name", fEventName.String(), B_FOLLOW_H_CENTER | B_FOLLOW_V_CENTER ); if ( !fTitle ) { /* Panic! */ fLastError = B_NO_MEMORY; return; } // Use big bold font for Event's name fTitle->SetFont( be_bold_font ); fTitle->GetFont( &font ); font.SetSize( font.Size() + 2 ); fTitle->SetFont( &font, B_FONT_SIZE ); // Add the title and set its tooltip fTitle->ResizeToPreferred(); fTitle->SetToolTip( sb.String() ); bgLayout->AddView( fTitle ); fTitle->SetViewColor( ui_color( B_PANEL_BACKGROUND_COLOR ) ); fTitle->SetToolTip( fEventName.String() ); int nextLineInLayout = 2; /*================================================================ * If the notification was set by the user, display it. *================================================================*/ BString tempString; BPath path; float rectHeight = fh.leading + fh.ascent + fh.descent; float rectWidth = this->Bounds().Width() - 10; // Layout insets BSize size( rectWidth, rectHeight ); if ( fData->GetNotification( &tempString ) ) { /*----------------------------------------------------------------- * Line of explanation *----------------------------------------------------------------*/ exp = new BStringView( BRect( 0, 0, 1, 1 ), "Text view explanation", "You set the following notification:" ); if ( !exp ) { /* Panic! */ fLastError = B_NO_MEMORY; return; } exp->ResizeToPreferred(); layoutItem = gridLayout->AddView( exp, 0, nextLineInLayout++, numberOfColumnsInLayout, 1 ); /*----------------------------------------------------------------- * Text view with notification text *----------------------------------------------------------------*/ BRect tempRect( BPoint( 0, 0 ), size ); tempRect.right -= B_V_SCROLL_BAR_WIDTH; fNoteText = new BTextView( tempRect, "Notification text container", tempRect.InsetByCopy( 1, 1 ), B_FOLLOW_ALL_SIDES, B_WILL_DRAW ); if ( !fNoteText ) { /* Panic! */ fLastError = B_NO_MEMORY; return; } fNoteText->MakeEditable( false ); fNoteText->SetText( tempString.String() ); /*----------------------------------------------------------------- * Scroll view to scroll the notification text *----------------------------------------------------------------*/ fTextScroller = new BScrollView( "Notification text scroller", fNoteText, B_FOLLOW_ALL_SIDES, 0, false, true ); if ( !fTextScroller ) { /* Panic! */ fLastError = B_NO_MEMORY; return; } layoutItem = gridLayout->AddView( fTextScroller, 0, nextLineInLayout++, numberOfColumnsInLayout, 1 ); if ( layoutItem ) { // layoutItem->SetExplicitMaxSize( size ); layoutItem->SetExplicitMinSize( size ); layoutItem->SetExplicitPreferredSize( size ); layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_USE_FULL_WIDTH, B_ALIGN_USE_FULL_HEIGHT ) ); } } // <-- end of adding information about the notification /*================================================================ * If user wanted to play a sound file, notify him about it. *================================================================*/ if ( fData->GetSound( &path ) ) { /*----------------------------------------------------------------- * Line of explanation *----------------------------------------------------------------*/ exp = new BStringView( BRect( 0, 0, 1, 1 ), "Sound file explanation", "You wanted to play the file:", B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP ); if ( !exp ) { /* Panic! */ fLastError = B_NO_MEMORY; return; } exp->ResizeToPreferred(); layoutItem = gridLayout->AddView( exp, 0, nextLineInLayout++, numberOfColumnsInLayout, 1 ); if ( layoutItem ) { layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_CENTER, B_ALIGN_MIDDLE ) ); } /*----------------------------------------------------------------- * Display sound file name *----------------------------------------------------------------*/ // What should we display - full path or just the leaf? if ( ( size.width - 10 ) > plainFont.StringWidth( path.Path() ) ) { tempString.SetTo( path.Path() ); } else { tempString.SetTo( path.Leaf() ); } exp = new BStringView( BRect( 0, 0, 1, 1 ), "Sound file name", tempString.String() ); if ( !exp ) { /* Panic! */ fLastError = B_NO_MEMORY; return; } exp->ResizeToPreferred(); layoutItem = gridLayout->AddView( exp, 0, nextLineInLayout++, numberOfColumnsInLayout, 1 ); if ( layoutItem ) { layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_CENTER, B_ALIGN_MIDDLE ) ); } } // <-- end of displaying information about the sound file /*================================================================ * If user wanted to run a program, notify him about it. *================================================================*/ if ( fData->GetProgram( &path, &tempString ) ) { /*----------------------------------------------------------------- * Line of explanation *----------------------------------------------------------------*/ exp = new BStringView( BRect( 0, 0, 1, 1 ), "Program explanation", "You wanted to run a program:" ); if ( !exp ) { /* Panic! */ fLastError = B_NO_MEMORY; return; } exp->ResizeToPreferred(); layoutItem = gridLayout->AddView( exp, 0, nextLineInLayout++, numberOfColumnsInLayout, 1 ); if ( layoutItem ) { layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_CENTER, B_ALIGN_MIDDLE ) ); } /*----------------------------------------------------------------- * Display path to program file *----------------------------------------------------------------*/ // What should we display - full path or just the leaf? exp = new BStringView( BRect( 0, 0, 1, 1 ), "Program file name", ( ( size.width - 10 ) > plainFont.StringWidth( path.Path() ) ) ? path.Path() : path.Leaf() ); if ( !exp ) { /* Panic! */ fLastError = B_NO_MEMORY; return; } exp->ResizeToPreferred(); layoutItem = gridLayout->AddView( exp, 0, nextLineInLayout++, numberOfColumnsInLayout, 1 ); if ( layoutItem ) { layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_CENTER, B_ALIGN_MIDDLE ) ); } /*----------------------------------------------------------------- * Explanation about the program options *----------------------------------------------------------------*/ if ( tempString.Length() > 0 ) { exp = new BStringView( BRect( 0, 0, 1, 1 ), "Program file options explanation", "With the following parameters:" ); if ( !exp ) { /* Panic! */ fLastError = B_NO_MEMORY; return; } exp->ResizeToPreferred(); layoutItem = gridLayout->AddView( exp, 0, nextLineInLayout++, numberOfColumnsInLayout, 1 ); if ( layoutItem ) { layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_CENTER, B_ALIGN_MIDDLE ) ); } /*----------------------------------------------------------------- * Display the program options *----------------------------------------------------------------*/ // What should we display - full path or just the leaf? exp = new BStringView( BRect( 0, 0, 1, 1 ), "Program file options", tempString.String() ); if ( !exp ) { /* Panic! */ fLastError = B_NO_MEMORY; return; } exp->ResizeToPreferred(); layoutItem = gridLayout->AddView( exp, 0, nextLineInLayout++, numberOfColumnsInLayout, 1 ); if ( layoutItem ) { layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_CENTER, B_ALIGN_MIDDLE ) ); } } // <-- end of diplaying CLI options } // <-- end of displaying information about the program to run /*================================================================ * Now it's time to display the Snooze time selector *================================================================*/ TimePreferences* prefs = pref_GetTimePreferences(); if ( prefs ) { prefs->GetDefaultSnoozeTime( ( int* )&fSnoozeHours, ( int* )&fSnoozeMins ); } else { fSnoozeHours = 0; fSnoozeMins = 10; } BMessage* toSend = new BMessage( kSnoozeTimeControlMessage ); if ( ! toSend ) { /* Panic! */ fLastError = B_NO_MEMORY; return; } fSnoozeTime = new GeneralHourMinControl( BRect( 0, 0, 1, 1 ), "Snooze time selector", "Snooze this Activtiy for:", BString( "" ), // No check box toSend ); if ( !fSnoozeTime ) { /* Panic! */ fLastError = B_NO_MEMORY; return; } fSnoozeTime->SetHoursLimit( 23 ); // Max reminder time delay is 23 hours 55 minutes fSnoozeTime->SetMinutesLimit( 55 ); fSnoozeTime->SetCurrentTime( fSnoozeHours, fSnoozeMins ); layoutItem = gridLayout->AddView( fSnoozeTime, 0, nextLineInLayout++, numberOfColumnsInLayout, 1 ); if ( layoutItem ) { layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_CENTER, B_ALIGN_MIDDLE ) ); } /*================================================================ * Snooze button *================================================================*/ toSend = new BMessage( kSnoozeButtonPressed ); if ( !toSend ) { /* Panic! */ fLastError = B_NO_MEMORY; return; } fSnooze = new BButton( BRect( 0, 0, 1, 1 ), "Snooze button", "Snooze", toSend, B_FOLLOW_LEFT | B_FOLLOW_TOP ); if ( !fSnooze ) { /* Panic! */ fLastError = B_NO_MEMORY; return; } fSnooze->ResizeToPreferred(); layoutItem = gridLayout->AddView( fSnooze, 0, nextLineInLayout ); if ( layoutItem ) { layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_LEFT, B_ALIGN_TOP ) ); } /*================================================================ * Ok button *================================================================*/ toSend = new BMessage( kDismissButtonPressed ); if ( !toSend ) { /* Panic! */ fLastError = B_NO_MEMORY; return; } fOk = new BButton( BRect( 0, 0, 1, 1 ), "Dismiss button", "Dismiss", toSend, B_FOLLOW_RIGHT | B_FOLLOW_TOP ); if ( !fOk ) { /* Panic! */ fLastError = B_NO_MEMORY; return; } fSnooze->ResizeToPreferred(); layoutItem = gridLayout->AddView( fOk, 1, nextLineInLayout ); if ( layoutItem ) { layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_RIGHT, B_ALIGN_TOP ) ); } this->CenterOnScreen(); } // <-- end of constructor for ActivityWindow
//! 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; }
// constructor NavigationInfoPanel::NavigationInfoPanel(BWindow* parent, const BMessage& message, const BMessenger& target) : BWindow(BRect(0, 0, 200, 30), "Navigation Info", B_FLOATING_WINDOW_LOOK, B_FLOATING_SUBSET_WINDOW_FEEL, B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_V_RESIZABLE) , fMessage(message) , fTarget(target) { // create the interface and resize to fit BRect frame = Bounds(); frame.InsetBy(5, 5); frame.bottom = frame.top + 15; // label string view fLabelView = new BStringView(frame, "label", kLabel, B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP); fLabelView->ResizeToPreferred(); frame = fLabelView->Frame(); // target clip text control frame.OffsetBy(0, frame.Height() + 5); fTargetClipTC = new BTextControl(frame, "clip id", "Target Playlist ID", "", new BMessage(MSG_INVOKE), B_FOLLOW_TOP | B_FOLLOW_LEFT_RIGHT); fTargetClipTC->ResizeToPreferred(); frame = fTargetClipTC->Frame(); // help string view frame.OffsetBy(0, frame.Height() + 5); BStringView* helpView = new BStringView(frame, "help", "Drag and drop a playlist clip here.", B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP); BFont font; helpView->GetFont(&font); font.SetFace(B_ITALIC_FACE); font.SetSize(font.Size() * 0.9); helpView->SetFont(&font); helpView->SetAlignment(B_ALIGN_CENTER); helpView->ResizeToPreferred(); // parent view frame = fLabelView->Frame() | fTargetClipTC->Frame() | helpView->Frame(); frame.InsetBy(-5, -5); fInfoView = new InfoView(frame, this); fInfoView->AddChild(fLabelView); fInfoView->AddChild(fTargetClipTC); fInfoView->AddChild(helpView); // resize to fit and adjust size limits ResizeTo(fInfoView->Frame().Width(), fInfoView->Frame().Height()); AddChild(fInfoView); float minWidth, maxWidth, minHeight, maxHeight; GetSizeLimits(&minWidth, &maxWidth, &minHeight, &maxHeight); minWidth = Frame().Width(); minHeight = maxHeight = Frame().Height(); SetSizeLimits(minWidth, maxWidth, minHeight, maxHeight); // modify the high color after the help view is attached to a window helpView->SetHighColor(tint_color(helpView->LowColor(), B_DISABLED_LABEL_TINT)); helpView->SetFlags(helpView->Flags() | B_FULL_UPDATE_ON_RESIZE); // help the buggy BeOS BStringView (when text alignment != left...) fInfoView->SetEventMask(B_POINTER_EVENTS); // resize controls to the same (maximum) width float maxControlWidth = fLabelView->Frame().Width(); maxControlWidth = max_c(maxControlWidth, fTargetClipTC->Frame().Width()); maxControlWidth = max_c(maxControlWidth, helpView->Frame().Width()); fLabelView->ResizeTo(maxControlWidth, fLabelView->Frame().Height()); fTargetClipTC->ResizeTo(maxControlWidth, fTargetClipTC->Frame().Height()); helpView->ResizeTo(maxControlWidth, helpView->Frame().Height()); // center above parent window BAutolock _(parent); frame = Frame(); BRect parentFrame = parent->Frame(); MoveTo((parentFrame.left + parentFrame.right - frame.Width()) / 2, (parentFrame.top + parentFrame.bottom - frame.Height()) / 2); AddToSubset(parent); }
void DateTimeView::_InitView() { font_height fontHeight; be_plain_font->GetHeight(&fontHeight); float textHeight = fontHeight.descent + fontHeight.ascent + fontHeight.leading + 6.0; // 6px border // left side BRect bounds = Bounds(); bounds.InsetBy(10.0, 10.0); bounds.top += textHeight + 10.0; fCalendarView = new BCalendarView(bounds, "calendar"); fCalendarView->SetWeekNumberHeaderVisible(false); fCalendarView->ResizeToPreferred(); fCalendarView->SetSelectionMessage(new BMessage(kDayChanged)); fCalendarView->SetInvocationMessage(new BMessage(kDayChanged)); bounds.top -= textHeight + 10.0; bounds.bottom = bounds.top + textHeight; bounds.right = fCalendarView->Frame().right; fDateEdit = new TDateEdit(bounds, "dateEdit", 3); AddChild(fDateEdit); AddChild(fCalendarView); // right side, 2px extra for separator bounds.OffsetBy(bounds.Width() + 22.0, 0.0); fTimeEdit = new TTimeEdit(bounds, "timeEdit", 4); AddChild(fTimeEdit); bounds = fCalendarView->Frame(); bounds.OffsetBy(bounds.Width() + 22.0, 0.0); fClock = new TAnalogClock(bounds, "analogClock"); AddChild(fClock); BTime time(BTime::CurrentTime(B_LOCAL_TIME)); fClock->SetTime(time.Hour(), time.Minute(), time.Second()); // clock radio buttons bounds.top = fClock->Frame().bottom + 10.0; BStringView *text = new BStringView(bounds, "clockSetTo", "Clock set to:"); AddChild(text); text->ResizeToPreferred(); bounds.left += 10.0f; bounds.top = text->Frame().bottom; fLocalTime = new BRadioButton(bounds, "localTime", "Local time", new BMessage(kRTCUpdate)); AddChild(fLocalTime); fLocalTime->ResizeToPreferred(); bounds.left = fLocalTime->Frame().right + 10.0; fGmtTime = new BRadioButton(bounds, "greenwichMeanTime", "GMT", new BMessage(kRTCUpdate)); AddChild(fGmtTime); fGmtTime->ResizeToPreferred(); if (fUseGmtTime) fGmtTime->SetValue(B_CONTROL_ON); else fLocalTime->SetValue(B_CONTROL_ON); fOldUseGmtTime = fUseGmtTime; ResizeTo(fClock->Frame().right + 10.0, fGmtTime->Frame().bottom + 10.0); }
TimeFormatSettingsView::TimeFormatSettingsView(BRect rect) : SettingsView(rect, "WindowsSettingsView") { rect.OffsetTo(B_ORIGIN); font_height fontHeight; be_bold_font->GetHeight(&fontHeight); rect.bottom = ceilf(fontHeight.ascent + fontHeight.descent) + 10; BBox *clockBox = new BBox(rect, "Clock"); clockBox->SetLabel("Clock"); AddChild(clockBox); rect.left = 8; rect.top = rect.bottom - 8; f24HrRadioButton = new BRadioButton(rect, "", "24 hour", new BMessage(kSettingsContentsModified)); f24HrRadioButton->ResizeToPreferred(); clockBox->AddChild(f24HrRadioButton); const float itemSpacing = f24HrRadioButton->Bounds().Height() + kItemExtraSpacing; rect.OffsetBy(0, itemSpacing); f12HrRadioButton = new BRadioButton(rect, "", "12 hour", new BMessage(kSettingsContentsModified)); f12HrRadioButton->ResizeToPreferred(); clockBox->AddChild(f12HrRadioButton); float width = max_c(f12HrRadioButton->Frame().right, f24HrRadioButton->Frame().right) + 8.0f; clockBox->ResizeTo(width, clockBox->Bounds().Height() + 3 * f12HrRadioButton->Frame().Height()); rect = clockBox->Frame(); rect.OffsetBy(rect.Width() + 8, 0); BBox *dateFormatBox = new BBox(rect, "Date order"); dateFormatBox->SetLabel("Date order"); AddChild(dateFormatBox); rect = f24HrRadioButton->Frame(); fYMDRadioButton = new BRadioButton(rect, "", "Year-month-day", new BMessage(kSettingsContentsModified)); fYMDRadioButton->ResizeToPreferred(); dateFormatBox->AddChild(fYMDRadioButton); rect.OffsetBy(0, itemSpacing); fDMYRadioButton = new BRadioButton(rect, "", "Day-month-year", new BMessage(kSettingsContentsModified)); fDMYRadioButton->ResizeToPreferred(); dateFormatBox->AddChild(fDMYRadioButton); rect.OffsetBy(0, itemSpacing); fMDYRadioButton = new BRadioButton(rect, "", "Month-day-year", new BMessage(kSettingsContentsModified)); fMDYRadioButton->ResizeToPreferred(); dateFormatBox->AddChild(fMDYRadioButton); dateFormatBox->ResizeTo(fYMDRadioButton->Bounds().Width() + 16, dateFormatBox->Bounds().Height()); BPopUpMenu *menu = new BPopUpMenu("Separator"); menu->AddItem(new BMenuItem("None", new BMessage(kSettingsContentsModified))); menu->AddItem(new BMenuItem("Space", new BMessage(kSettingsContentsModified))); menu->AddItem(new BMenuItem("-", new BMessage(kSettingsContentsModified))); menu->AddItem(new BMenuItem("/", new BMessage(kSettingsContentsModified))); menu->AddItem(new BMenuItem("\\", new BMessage(kSettingsContentsModified))); menu->AddItem(new BMenuItem(".", new BMessage(kSettingsContentsModified))); rect.left = 0; rect.top = clockBox->Frame().bottom + 8; rect.right = Bounds().Width() - 8; rect.bottom = rect.top + itemSpacing; fSeparatorMenuField = new BMenuField(rect, "Separator", "Separator:", menu); fSeparatorMenuField->SetDivider(fSeparatorMenuField->StringWidth(fSeparatorMenuField->Label()) + 8.0f); fSeparatorMenuField->SetAlignment(B_ALIGN_LEFT); fSeparatorMenuField->ResizeToPreferred(); AddChild(fSeparatorMenuField); rect.OffsetBy(0, itemSpacing + 10); BStringView *exampleView = new BStringView(rect, "", "Examples:"); exampleView->ResizeToPreferred(); AddChild(exampleView); rect.OffsetBy(0, itemSpacing); fLongDateExampleView = new BStringView(rect, "", ""); fLongDateExampleView->ResizeToPreferred(); AddChild(fLongDateExampleView); rect.OffsetBy(0, itemSpacing); fShortDateExampleView = new BStringView(rect, "", ""); fShortDateExampleView->ResizeToPreferred(); AddChild(fShortDateExampleView); _UpdateExamples(); }