PreviewView::PreviewView(const char* name) : BView(name, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE), fSaverView(NULL), fNoPreview(NULL) { SetViewUIColor(B_PANEL_BACKGROUND_COLOR); BGroupLayout* layout = new BGroupLayout(B_VERTICAL); // We draw the "monitor" around the preview, hence the strange insets. layout->SetInsets(7, 6, 8, 12); SetLayout(layout); // A BStringView would be enough, if only it handled word wrapping. fNoPreview = new BTextView("no preview"); fNoPreview->SetText(B_TRANSLATE("No preview available")); fNoPreview->SetFontAndColor(be_plain_font, B_FONT_ALL, &kWhite); fNoPreview->MakeEditable(false); fNoPreview->MakeResizable(false); fNoPreview->MakeSelectable(false); fNoPreview->SetViewColor(0, 0, 0); fNoPreview->SetLowColor(0, 0, 0); fNoPreview->Hide(); BView* container = new BView("preview container", 0); container->SetLayout(new BCardLayout()); AddChild(container); container->SetViewColor(0, 0, 0); container->SetLowColor(0, 0, 0); container->AddChild(fNoPreview); fNoPreview->SetHighColor(255, 255, 255); fNoPreview->SetAlignment(B_ALIGN_CENTER); }
TeamDescriptionView::TeamDescriptionView() : BView("description view", B_WILL_DRAW), fItem(NULL), fSeconds(4), fRebootRunner(NULL) { fInfoString = B_TRANSLATE( "Select an application from the list above and click one of " "the buttons 'Kill application' and 'Quit application' " "in order to close it.\n\n" "Hold CONTROL+ALT+DELETE for %ld seconds to reboot."); fTeamName = new BStringView("team name", "team name"); fSysComponent = new BStringView("system component", B_TRANSLATE( "(This team is a system component)")); fQuitOverdue = new BStringView("quit overdue", B_TRANSLATE( "If the application will not quit you may have to kill it.")); fQuitOverdue->SetFont(be_bold_font); fInfoTextView = new AllShowingTextView("info text"); BGroupView* group = new BGroupView(B_VERTICAL); BGroupLayoutBuilder(group) .Add(fInfoTextView) .AddGlue(); fIconView = new IconView(); fIconView->SetExplicitAlignment( BAlignment(B_ALIGN_HORIZONTAL_UNSET, B_ALIGN_VERTICAL_CENTER)); BView* teamPropertiesView = new BView("team properties", B_WILL_DRAW); teamPropertiesView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); BGroupLayout* layout = new BGroupLayout(B_HORIZONTAL); teamPropertiesView->SetLayout(layout); BGroupLayoutBuilder(layout) .Add(fIconView) .AddGroup(B_VERTICAL) .Add(fTeamName) .Add(fSysComponent) .Add(fQuitOverdue) .End() .AddGlue(); fLayout = new BCardLayout(); SetLayout(fLayout); fLayout->AddView(group); fLayout->AddView(teamPropertiesView); SetItem(NULL); }
MusicCollectionWindow::MusicCollectionWindow(BRect frame, const char* title) : BWindow(frame, title, B_DOCUMENT_WINDOW, B_AVOID_FRONT) { BView* rootView = new BView(Bounds(), NULL, B_FOLLOW_ALL, B_WILL_DRAW); AddChild(rootView); rootView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); fQueryField = new BTextControl("Search: ", "", NULL); fQueryField->SetExplicitAlignment(BAlignment(B_ALIGN_HORIZONTAL_CENTER, B_ALIGN_USE_FULL_HEIGHT)); fQueryField->SetModificationMessage(new BMessage(kMsgQueryInput)); fCountView = new BStringView("Count View", "Count:"); fFileListView = new MusicFileListView("File List View"); fFileListView->SetInvocationMessage(new BMessage(kMsgItemInvoked)); BScrollView* scrollView = new BScrollView("list scroll", fFileListView, 0, true, true, B_PLAIN_BORDER); float spacing = be_control_look->DefaultItemSpacing() / 2; BALMLayout* layout = new BALMLayout(spacing); layout->SetInset(spacing); rootView->SetLayout(layout); layout->AddView(fQueryField, layout->Left(), layout->Top()); layout->AddViewToRight(fCountView, layout->Right()); layout->AddView(scrollView, layout->Left(), layout->AreaFor(fQueryField)->Bottom(), layout->Right(), layout->Bottom()); Area* area = layout->AreaFor(scrollView); area->SetLeftInset(0); area->SetRightInset(0); area->SetBottomInset(0); BSize min = layout->MinSize(); BSize max = layout->MaxSize(); SetSizeLimits(min.Width(), max.Width(), min.Height(), max.Height()); fEntryViewInterface = new ListViewListener<FileListItem>(fFileListView, fCountView); fQueryHandler = new QueryHandler(fEntryViewInterface); AddHandler(fQueryHandler); fQueryReader = new QueryReader(fQueryHandler); fQueryHandler->SetReadThread(fQueryReader); // start initial query PostMessage(kMsgQueryInput); }
FolderConfigWindow::FolderConfigWindow(BRect parent, const BMessage& settings) : BWindow(BRect(0, 0, 300, 300), B_TRANSLATE("IMAP Folders"), B_TITLED_WINDOW_LOOK, B_MODAL_APP_WINDOW_FEEL, B_NO_WORKSPACE_ACTIVATION | B_NOT_ZOOMABLE | B_AVOID_FRONT), fSettings(settings) { BView* rootView = new BView(Bounds(), "root", B_FOLLOW_ALL, B_WILL_DRAW); AddChild(rootView); rootView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); float spacing = be_control_look->DefaultItemSpacing(); BALMLayout* layout = new BALMLayout(spacing); rootView->SetLayout(layout); layout->SetInset(spacing); fFolderListView = new EditListView(B_TRANSLATE("IMAP Folders")); fFolderListView->SetExplicitPreferredSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED)); fApplyButton = new BButton("Apply", B_TRANSLATE("Apply"), new BMessage(kMsgApplyButton)); fQuotaView = new BStringView("quota view", B_TRANSLATE("Failed to fetch available storage.")); fQuotaView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_CENTER)); layout->AddView(fFolderListView, layout->Left(), layout->Top(), layout->Right(), layout->Bottom()); GroupItem item = GroupItem(fQuotaView) / GroupItem(fFolderListView) / (GroupItem(BSpaceLayoutItem::CreateGlue()) | GroupItem(fApplyButton)); layout->BuildLayout(item); PostMessage(kMsgInit); BSize min = layout->MinSize(); BSize max = layout->MaxSize(); SetSizeLimits(min.Width(), max.Width(), min.Height(), max.Height()); CenterIn(parent); }
StatusWindow(const char* text) : BWindow(BRect(0, 0, 10, 10), B_TRANSLATE("status"), B_MODAL_WINDOW_LOOK, B_MODAL_APP_WINDOW_FEEL, B_NO_WORKSPACE_ACTIVATION | B_NOT_ZOOMABLE | B_AVOID_FRONT | B_NOT_RESIZABLE) { BView* rootView = new BView(Bounds(), "root", B_FOLLOW_ALL, B_WILL_DRAW); AddChild(rootView); rootView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); float spacing = be_control_look->DefaultItemSpacing(); BALMLayout* layout = new BALMLayout(spacing); rootView->SetLayout(layout); layout->SetInset(spacing); BStringView* string = new BStringView("text", text); layout->AddView(string, layout->Left(), layout->Top(), layout->Right(), layout->Bottom()); BSize min = layout->MinSize(); ResizeTo(min.Width(), min.Height()); CenterOnScreen(); }
/*! \function ColorUpdateWindow::ColorUpdateWindow * \brief Constructor. * \param[in] corner One of the corners of the window IN SCREEN COORDINATES! * \param[in] label Label of the color. (Usually name of the category). * \param[in] enableEditingLabel If "true", label can be edited. If "false", it's constant. * \param[in] title Title of the window * \param[in] defaultColor Original color. Defaults to black. * \param[in] targetLooper The target which receives message with the results. * \param[in] currentScreen Defines the screen the program runs in. Usually it's * B_MAIN_SCREEN_ID. * \param[in] message The template message to be used. If this parameter is NULL, * a new message is constructed. */ ColorUpdateWindow::ColorUpdateWindow( BPoint corner, BString& label, rgb_color &defaultColor, bool enableEditingLabel, BString title, BHandler *targetHandler, screen_id currentScreen, BMessage* message ) : BWindow( BRect( 100, 100, 300, 500 ), title.String(), B_MODAL_WINDOW, B_NOT_CLOSABLE | B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_NOT_MINIMIZABLE | B_ASYNCHRONOUS_CONTROLS | B_WILL_ACCEPT_FIRST_CLICK ), originalString( label ), originalColor( defaultColor), labelView( NULL ), okButton( NULL ), revertButton( NULL ), messageToSend( NULL ), target( targetHandler ), dirty( false ) { BSize layoutSize; BLayoutItem* item = NULL; float width, height, dontCare; BView* background = new BView( this->Bounds(), "Background", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_FRAME_EVENTS | B_WILL_DRAW ); if ( !background ) { /* Panic! */ exit(1); } background->SetViewColor( ui_color( B_PANEL_BACKGROUND_COLOR ) ); this->enableEditingLabel = enableEditingLabel; /* There are three parts in the interface of the control. * Upmost is the label, which, according to the user's settings, * can be editable or not. * Next is the color control. * Last is the row of two buttons, Revert and Ok. */ // Debugging printf( "Color Selected = %u, Color Reverted = %u.\n", kColorSelected, kColorReverted ); // Construct background view and layout BGridLayout* layout = new BGridLayout( B_VERTICAL ); if ( !layout ) { /* Panic! */ exit(1); } layout->SetInsets( 5, 5, 5, 5 ); background->SetLayout( layout ); this->AddChild( background ); // Constructing the name label, editable or not. if ( enableEditingLabel ) { labelView = new BTextControl( BRect(0, 0, 1, 1), "Label", NULL, label.String(), NULL ); } else { labelView = new BStringView( BRect (0, 0, 1, 1), "Label", label.String() ); } if ( !labelView ) { /* Panic! */ exit(1); } labelView->ResizeToPreferred(); item = layout->AddView( labelView, 0, 0, 3, 1 ); if ( !item ) { /* Panic! */ exit(1); } item->SetExplicitAlignment( BAlignment( B_ALIGN_USE_FULL_WIDTH, B_ALIGN_VERTICAL_CENTER ) ); // item->SetExplicitMinSize( BSize( width, height ) ); // Construct color control BMessage* toSend = new BMessage( kColorChanged ); if ( !toSend ) { /* Panic! */ exit(1); } colorControl = new BColorControl( BPoint( 0, 0 ), B_CELLS_32x8, 4.0, "Color Control", toSend ); if ( !colorControl ) { /* Panic! */ exit(1); } colorControl->GetPreferredSize( &width, &height ); colorControl->ResizeTo( width, height ); colorControl->SetTarget( this ); item = layout->AddView( colorControl, 0, 1, 3, 1 ); if ( !item ) { /* Panic! */ exit(1); } item->SetExplicitAlignment( BAlignment( B_ALIGN_USE_FULL_WIDTH, B_ALIGN_TOP ) ); // Construct last two buttons // Revert button toSend = new BMessage( kColorReverted ); if ( !toSend ) { /* Panic! */ exit(1); } revertButton = new BButton( BRect( 0, 0, 1, 1), "Revert button", "Revert", toSend ); if ( !revertButton ) { /* Panic! */ exit(1); } revertButton->ResizeToPreferred(); // Ok button toSend = new BMessage( kColorSelected ); if ( !toSend ) { /* Panic! */ exit(1); } okButton = new BButton( BRect( 0, 0, 1, 1), "Ok button", "Ok", toSend, B_FOLLOW_RIGHT | B_FOLLOW_TOP ); if ( !okButton ) { /* Panic! */ exit(1); } okButton->ResizeToPreferred(); // Attach the buttons to current layout item = layout->AddView( revertButton, 0, 2 ); if ( ! item ) { /* Panic! */ exit(1); } item->SetExplicitAlignment( BAlignment( B_ALIGN_LEFT, B_ALIGN_MIDDLE ) ); // Note I'm skipping one cell - this is for showing current color! item = layout->AddView( okButton, 2, 2 ); if ( ! item ) { /* Panic! */ exit(1); } item->SetExplicitAlignment( BAlignment( B_ALIGN_RIGHT, B_ALIGN_MIDDLE ) ); // Make "Ok" button the default okButton->MakeDefault( true ); // Now, find the correct place for this window. // We have one of the corners from constructor, we need to position the window // in such manner that it will be fully visible and keep one of the corners in // the specified point. layout->Relayout( true ); layoutSize = layout->PreferredSize(); this->ResizeTo( layoutSize.width, layoutSize.height ); background->ResizeTo( layoutSize.width, layoutSize.height ); float windowWidth = layoutSize.width, windowHeight = layoutSize.height; BScreen* mainScreen = new BScreen( currentScreen ); // Get access to current screen display_mode currentDisplayMode; mainScreen->GetMode( ¤tDisplayMode ); // Obtain the width and height of screen // The following booleans uniquely define where the window be located regarding // given corner. bool leftFromCorner = false, upFromCorner = false; // Check where the window should span regarding to the corner if ( corner.x + windowWidth >= currentDisplayMode.virtual_width ) { if ( corner.x - windowWidth < 0 ) { corner.x = 0; leftFromCorner = false; } else { leftFromCorner = true; } } if ( corner.y + windowHeight >= currentDisplayMode.virtual_height ) { if ( corner.y - windowHeight < 0 ) { corner.y = 0; upFromCorner = false; } else { upFromCorner = true; } } // Calculate new top-left corner of the window if ( leftFromCorner ) { corner.x -= windowWidth; } if ( upFromCorner ) { corner.y -= windowHeight; } // Move the window to calculated position this->MoveTo( corner ); // Show the window this->Show(); colorControl->Invoke(); } // <-- end of constructor for ColorUpdateWindow
ExtendedInfoWindow::ExtendedInfoWindow(PowerStatusDriverInterface* interface) : BWindow(BRect(100, 150, 500, 500), "Extended battery info", B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_AVOID_FRONT | B_ASYNCHRONOUS_CONTROLS), fDriverInterface(interface), fSelectedView(NULL) { fDriverInterface->AcquireReference(); BView *view = new BView(Bounds(), "view", B_FOLLOW_ALL, 0); view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); AddChild(view); BGroupLayout* mainLayout = new BGroupLayout(B_VERTICAL); mainLayout->SetSpacing(10); mainLayout->SetInsets(10, 10, 10, 10); view->SetLayout(mainLayout); BRect rect = Bounds(); rect.InsetBy(5, 5); BBox *infoBox = new BBox(rect, "Power status box"); infoBox->SetLabel("Battery info"); BGroupLayout* infoLayout = new BGroupLayout(B_HORIZONTAL); infoLayout->SetInsets(10, infoBox->TopBorderOffset() * 2 + 10, 10, 10); infoLayout->SetSpacing(10); infoBox->SetLayout(infoLayout); mainLayout->AddView(infoBox); BGroupView* batteryView = new BGroupView(B_VERTICAL); batteryView->GroupLayout()->SetSpacing(10); infoLayout->AddView(batteryView); // create before the battery views fBatteryInfoView = new BatteryInfoView(); BGroupLayout* batteryLayout = batteryView->GroupLayout(); BRect batteryRect(0, 0, 50, 30); for (int i = 0; i < interface->GetBatteryCount(); i++) { ExtPowerStatusView* view = new ExtPowerStatusView(interface, batteryRect, B_FOLLOW_NONE, i, this); view->SetExplicitMaxSize(BSize(70, 80)); view->SetExplicitMinSize(BSize(70, 80)); batteryLayout->AddView(view); fBatteryViewList.AddItem(view); fDriverInterface->StartWatching(view); if (!view->IsCritical()) fSelectedView = view; } batteryLayout->AddItem(BSpaceLayoutItem::CreateGlue()); infoLayout->AddView(fBatteryInfoView); if (!fSelectedView && fBatteryViewList.CountItems() > 0) fSelectedView = fBatteryViewList.ItemAt(0); fSelectedView->Select(); BSize size = mainLayout->PreferredSize(); ResizeTo(size.width, size.height); }
MainWindow::MainWindow(const BMessage& settings) : BWindow(BRect(50, 50, 650, 550), B_TRANSLATE_SYSTEM_NAME("HaikuDepot"), B_DOCUMENT_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS), fScreenshotWindow(NULL), fUserMenu(NULL), fLogInItem(NULL), fLogOutItem(NULL), fModelListener(new MessageModelListener(BMessenger(this)), true), fTerminating(false), fSinglePackageMode(false), fModelWorker(B_BAD_THREAD_ID) { BMenuBar* menuBar = new BMenuBar(B_TRANSLATE("Main Menu")); _BuildMenu(menuBar); BMenuBar* userMenuBar = new BMenuBar(B_TRANSLATE("User Menu")); _BuildUserMenu(userMenuBar); set_small_font(userMenuBar); userMenuBar->SetExplicitMaxSize(BSize(B_SIZE_UNSET, menuBar->MaxSize().height)); fFilterView = new FilterView(); fFeaturedPackagesView = new FeaturedPackagesView(); fPackageListView = new PackageListView(fModel.Lock()); fPackageInfoView = new PackageInfoView(fModel.Lock(), this); fSplitView = new BSplitView(B_VERTICAL, 5.0f); BGroupView* featuredPackagesGroup = new BGroupView(B_VERTICAL); BStringView* featuredPackagesTitle = new BStringView( "featured packages title", B_TRANSLATE("Featured packages")); BFont font(be_bold_font); font.SetSize(font.Size() * 1.3f); featuredPackagesTitle->SetFont(&font); featuredPackagesGroup->SetExplicitMaxSize( BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET)); BLayoutBuilder::Group<>(featuredPackagesGroup) .Add(featuredPackagesTitle) .Add(fFeaturedPackagesView) ; BView* listArea = new BView("list area", 0); fListLayout = new BCardLayout(); listArea->SetLayout(fListLayout); listArea->AddChild(featuredPackagesGroup); listArea->AddChild(fPackageListView); BLayoutBuilder::Group<>(this, B_VERTICAL, 0.0f) .AddGroup(B_HORIZONTAL, 0.0f) .Add(menuBar, 1.0f) .Add(userMenuBar, 0.0f) .End() .Add(fFilterView) .AddSplit(fSplitView) .AddGroup(B_VERTICAL) .Add(listArea) .SetInsets( B_USE_DEFAULT_SPACING, 0.0f, B_USE_DEFAULT_SPACING, 0.0f) .End() .Add(fPackageInfoView) .End() ; fSplitView->SetCollapsible(0, false); fSplitView->SetCollapsible(1, false); fModel.AddListener(fModelListener); // Restore settings BMessage columnSettings; if (settings.FindMessage("column settings", &columnSettings) == B_OK) fPackageListView->LoadState(&columnSettings); bool showOption; if (settings.FindBool("show featured packages", &showOption) == B_OK) fModel.SetShowFeaturedPackages(showOption); if (settings.FindBool("show available packages", &showOption) == B_OK) fModel.SetShowAvailablePackages(showOption); if (settings.FindBool("show installed packages", &showOption) == B_OK) fModel.SetShowInstalledPackages(showOption); if (settings.FindBool("show develop packages", &showOption) == B_OK) fModel.SetShowDevelopPackages(showOption); if (settings.FindBool("show source packages", &showOption) == B_OK) fModel.SetShowSourcePackages(showOption); if (fModel.ShowFeaturedPackages()) fListLayout->SetVisibleItem((int32)0); else fListLayout->SetVisibleItem(1); _RestoreUserName(settings); _RestoreWindowFrame(settings); // start worker threads BPackageRoster().StartWatching(this, B_WATCH_PACKAGE_INSTALLATION_LOCATIONS); _StartRefreshWorker(); _InitWorkerThreads(); }
/*! \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
LocaleWindow::LocaleWindow() : BWindow(BRect(0, 0, 0, 0), B_TRANSLATE_SYSTEM_NAME("Locale"), B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE | B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS), fInitialConventionsItem(NULL), fDefaultConventionsItem(NULL), fFilesystemTranslationCheckbox(NULL) { SetLayout(new BGroupLayout(B_HORIZONTAL)); float spacing = be_control_look->DefaultItemSpacing(); BTabView* tabView = new BTabView("tabview"); BGroupView* languageTab = new BGroupView(B_TRANSLATE("Language"), B_HORIZONTAL, spacing); // first list: available languages fLanguageListView = new LanguageListView("available", B_MULTIPLE_SELECTION_LIST); BScrollView* scrollView = new BScrollView("scroller", fLanguageListView, B_WILL_DRAW | B_FRAME_EVENTS, true, true); fLanguageListView->SetInvocationMessage(new BMessage(kMsgLanguageInvoked)); fLanguageListView->SetDragMessage(new BMessage(kMsgLanguageDragged)); BFont font; fLanguageListView->GetFont(&font); // Fill the language list from the LocaleRoster data BMessage availableLanguages; if (BLocaleRoster::Default()->GetAvailableLanguages(&availableLanguages) == B_OK) { BString currentID; LanguageListItem* lastAddedCountryItem = NULL; for (int i = 0; availableLanguages.FindString("language", i, ¤tID) == B_OK; i++) { // Now get the human-readable, native name for each language BString name; BLanguage currentLanguage(currentID.String()); currentLanguage.GetNativeName(name); // TODO: the following block fails to detect a couple of language // names as containing glyphs we can't render. Why's that? bool hasGlyphs[name.CountChars()]; font.GetHasGlyphs(name.String(), name.CountChars(), hasGlyphs); for (int32 i = 0; i < name.CountChars(); ++i) { if (!hasGlyphs[i]) { // replace by name translated to current language currentLanguage.GetName(name); break; } } LanguageListItem* item = new LanguageListItem(name, currentID.String(), currentLanguage.Code(), currentLanguage.CountryCode()); if (currentLanguage.IsCountrySpecific() && lastAddedCountryItem != NULL && lastAddedCountryItem->Code() == item->Code()) { fLanguageListView->AddUnder(item, lastAddedCountryItem); } else { // This is a language variant, add it at top-level fLanguageListView->AddItem(item); if (!currentLanguage.IsCountrySpecific()) { item->SetExpanded(false); lastAddedCountryItem = item; } } } fLanguageListView->FullListSortItems(compare_typed_list_items); } else { BAlert* alert = new BAlert("Error", B_TRANSLATE("Unable to find the available languages! You can't " "use this preflet!"), B_TRANSLATE("OK"), NULL, NULL, B_WIDTH_AS_USUAL, B_OFFSET_SPACING, B_STOP_ALERT); alert->Go(); } // Second list: active languages fPreferredListView = new LanguageListView("preferred", B_MULTIPLE_SELECTION_LIST); BScrollView* scrollViewEnabled = new BScrollView("scroller", fPreferredListView, B_WILL_DRAW | B_FRAME_EVENTS, true, true); fPreferredListView->SetInvocationMessage( new BMessage(kMsgPreferredLanguageInvoked)); fPreferredListView->SetDeleteMessage( new BMessage(kMsgPreferredLanguageDeleted)); fPreferredListView->SetDragMessage( new BMessage(kMsgPreferredLanguageDragged)); BLayoutBuilder::Group<>(languageTab) .AddGroup(B_VERTICAL, spacing) .Add(new BStringView("", B_TRANSLATE("Available languages"))) .Add(scrollView) .End() .AddGroup(B_VERTICAL, spacing) .Add(new BStringView("", B_TRANSLATE("Preferred languages"))) .Add(scrollViewEnabled) .End() .SetInsets(spacing, spacing, spacing, spacing); BView* countryTab = new BView(B_TRANSLATE("Formatting"), B_WILL_DRAW); countryTab->SetLayout(new BGroupLayout(B_VERTICAL, 0)); fConventionsListView = new LanguageListView("formatting", B_SINGLE_SELECTION_LIST); scrollView = new BScrollView("scroller", fConventionsListView, B_WILL_DRAW | B_FRAME_EVENTS, true, true); fConventionsListView->SetSelectionMessage( new BMessage(kMsgConventionsSelection)); // get all available formatting conventions (by language) BFormattingConventions defaultConventions; BLocale::Default()->GetFormattingConventions(&defaultConventions); BString conventionID; fInitialConventionsItem = NULL; LanguageListItem* lastAddedConventionsItem = NULL; for (int i = 0; availableLanguages.FindString("language", i, &conventionID) == B_OK; i++) { BFormattingConventions convention(conventionID); BString conventionName; convention.GetName(conventionName); LanguageListItem* item = new LanguageListItem(conventionName, conventionID, convention.LanguageCode(), convention.CountryCode()); if (!strcmp(conventionID, "en_US")) fDefaultConventionsItem = item; if (conventionID.FindFirst('_') >= 0 && lastAddedConventionsItem != NULL && lastAddedConventionsItem->Code() == item->Code()) { if (!strcmp(conventionID, defaultConventions.ID())) { fConventionsListView->Expand(lastAddedConventionsItem); fInitialConventionsItem = item; } fConventionsListView->AddUnder(item, lastAddedConventionsItem); } else { // This conventions-item isn't country-specific, add it at top-level fConventionsListView->AddItem(item); if (conventionID.FindFirst('_') < 0) { item->SetExpanded(false); lastAddedConventionsItem = item; } if (!strcmp(conventionID, defaultConventions.ID())) fInitialConventionsItem = item; } } fConventionsListView->FullListSortItems(compare_typed_list_items); if (fInitialConventionsItem != NULL) { fConventionsListView->Select(fConventionsListView->IndexOf( fInitialConventionsItem)); } fConventionsListView->SetExplicitMinSize(BSize(20 * be_plain_font->Size(), B_SIZE_UNSET)); fFormatView = new FormatSettingsView(); countryTab->AddChild(BLayoutBuilder::Group<>(B_HORIZONTAL, spacing) .AddGroup(B_VERTICAL, 3) .Add(scrollView) .End() .Add(fFormatView) .SetInsets(spacing, spacing, spacing, spacing)); BView* optionsTab = new BView(B_TRANSLATE("Options"), B_WILL_DRAW); optionsTab->SetLayout(new BGroupLayout(B_VERTICAL, 0)); fFilesystemTranslationCheckbox = new BCheckBox("filesystemTranslation", B_TRANSLATE("Translate application and folder names in Deskbar and Tracker."), new BMessage(kMsgFilesystemTranslationChanged)); fFilesystemTranslationCheckbox->SetValue( BLocaleRoster::Default()->IsFilesystemTranslationPreferred()); optionsTab->AddChild(BLayoutBuilder::Group<>(B_VERTICAL, spacing) .Add(fFilesystemTranslationCheckbox) .AddGlue() .SetInsets(spacing, spacing, spacing, spacing)); tabView->AddTab(languageTab); tabView->AddTab(countryTab); tabView->AddTab(optionsTab); BButton* button = new BButton(B_TRANSLATE("Defaults"), new BMessage(kMsgDefaults)); fRevertButton = new BButton(B_TRANSLATE("Revert"), new BMessage(kMsgRevert)); fRevertButton->SetEnabled(false); BLayoutBuilder::Group<>(this, B_VERTICAL, spacing) .Add(tabView) .AddGroup(B_HORIZONTAL, spacing) .Add(button) .Add(fRevertButton) .AddGlue() .End() .SetInsets(spacing, spacing, spacing, spacing) .End(); _Refresh(true); _SettingsReverted(); CenterOnScreen(); }
void DataTranslationsWindow::_SetupViews() { fConfigView = NULL; // This is NULL until a translator is // selected from the listview // Window box BView* mainView = new BView(Bounds(), "", B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS); mainView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); AddChild(mainView); // Add the translators list view fTranslatorListView = new TranslatorListView(BRect(0, 0, 1, 1), "TransList", B_SINGLE_SELECTION_LIST); fTranslatorListView->SetSelectionMessage(new BMessage(kMsgSelectedTranslator)); BScrollView *scrollView = new BScrollView("scroll_trans", fTranslatorListView, B_FOLLOW_LEFT | B_FOLLOW_TOP_BOTTOM, B_WILL_DRAW | B_FRAME_EVENTS, false, true, B_FANCY_BORDER); // Box around the config and info panels fRightBox = new BBox("Right_Side"); // Add the translator icon view fIconView = new IconView(BRect(0, 0, 31, 31), "Icon", B_FOLLOW_LEFT | B_FOLLOW_BOTTOM, B_WILL_DRAW | B_FRAME_EVENTS); // Add the translator info button BButton *button = new BButton("STD", "Info" B_UTF8_ELLIPSIS, new BMessage(kMsgTranslatorInfo), B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE); // Add the translator name view fTranslatorNameView = new BStringView("TranName", "None"); // Populate the translators list view _PopulateListView(); // Build the layout BALMLayout *layout = new BALMLayout(); mainView->SetLayout(layout); XTab *x1 = layout->AddXTab(); XTab *x2 = layout->AddXTab(); XTab *x3 = layout->AddXTab(); YTab *y1 = layout->AddYTab(); Area *leftArea = layout->AddArea(layout->Left(), layout->Top(), x1, layout->Bottom(), scrollView); leftArea->SetLeftInset(10); leftArea->SetTopInset(10); leftArea->SetBottomInset(10); Area *rightArea = layout->AddArea(x1, layout->Top(), layout->Right(), y1, fRightBox); rightArea->SetLeftInset(10); rightArea->SetTopInset(10); rightArea->SetRightInset(10); rightArea->SetBottomInset(10); Area *iconArea = layout->AddArea(x1, y1, x2, layout->Bottom(), fIconView); iconArea->SetLeftInset(10); iconArea->SetBottomInset(10); Area *infoButtonArea = layout->AddArea(x3, y1, layout->Right(), layout->Bottom(), button); infoButtonArea->SetRightInset(10); infoButtonArea->SetBottomInset(10); layout->AddConstraint(3.0, x1, -1.0, layout->Right(), OperatorType(EQ), 0.0); fTranslatorListView->MakeFocus(); fTranslatorListView->Select(0); }
PAccountDialog::PAccountDialog(const char *title, const char *protocol, const char *account, BMessage settingsTemplate, BMessage settings, BMessenger *target, BMessage save, BMessage cancel) : BWindow(WINDOW_RECT, title, B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS | B_CLOSE_ON_ESCAPE), fOriginalAccount(account), fTemplate(settingsTemplate), fSettings(settings), fTarget(target), fSave(save), fCancel(cancel) { BRect frame(0, 0, 1, 1); #ifndef __HAIKU__ frame = Bounds(); #endif BView *view = ViewFactory::Create<BView>(frame, "top", B_FOLLOW_ALL_SIDES, B_WILL_DRAW | B_FRAME_EVENTS); // Account name fAccountName = ViewFactory::Create<BTextControl>(frame, "account_name", _T("Account name:"), fOriginalAccount.String(), NULL, B_FOLLOW_ALL_SIDES, B_WILL_DRAW | B_FRAME_EVENTS); fAccountName->SetFont(be_bold_font); fAccountName->MakeFocus(); // Account name divider fAccountNameDivider = new Divider(frame, "AccountNameDivider", B_FOLLOW_ALL_SIDES, B_WILL_DRAW | B_FRAME_EVENTS); fAccountNameDivider->ResizeToPreferred(); fProtocolControl = new PClientView(frame, "ProtocolControls", NULL, fTemplate, fSettings); fCancelButton = ViewFactory::Create<BButton>(frame, "cancel", _T("Cancel"), new BMessage(kAddAccountCancel)); fOKButton = ViewFactory::Create<BButton>(frame, "ok", _T("OK"), new BMessage(kAddAccountOk)); #ifdef __HAIKU__ float inset = ceilf(be_plain_font->Size() * 0.7f); fAccountNameDivider->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, 1)); //fProtocolControl->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED)); view->SetLayout(new BGroupLayout(B_VERTICAL)); view->AddChild(BGroupLayoutBuilder(B_VERTICAL, inset) .AddGroup(B_VERTICAL, inset) .Add(fAccountName) .Add(fAccountNameDivider) .Add(fProtocolControl) .End() .SetInsets(inset, inset, inset, inset) ); view->AddChild(BGroupLayoutBuilder(B_VERTICAL, inset) .AddGroup(B_HORIZONTAL, inset) .AddGlue() .Add(fCancelButton) .Add(fOKButton) .End() .SetInsets(inset, inset, inset, inset) ); SetLayout(new BGroupLayout(B_HORIZONTAL)); GetLayout()->AddView(view); #else view->AddChild(fAccountName); view->AddChild(fAccountNameDivider); view->AddChild(fProtocolControl); view->AddChild(fCancelButton); view->AddChild(fOKButton); AddChild(view); LayoutGUI(); #endif CenterWindowOnScreen(this); };
CapabilitiesView::CapabilitiesView() : BView(TR("Capabilities"), 0, NULL) { SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); SetLayout(new BGroupLayout(B_VERTICAL)); BRect dummyRect(0, 0, 0, 0); const float kInset = 10; int lights = 0; int clippingPlanes = 0; int modelStack = 0; int projectionStack = 0; int textureStack = 0; int maxTex3d = 0; int maxTex2d = 0; int nameStack = 0; int listStack = 0; int maxPoly = 0; int attribStack = 0; int buffers = 0; int convolutionWidth = 0; int convolutionHeight = 0; int maxIndex = 0; int maxVertex = 0; int textureUnits = 0; glGetIntegerv(GL_MAX_LIGHTS, &lights); glGetIntegerv(GL_MAX_CLIP_PLANES, &clippingPlanes); glGetIntegerv(GL_MAX_MODELVIEW_STACK_DEPTH, &modelStack); glGetIntegerv(GL_MAX_PROJECTION_STACK_DEPTH, &projectionStack); glGetIntegerv(GL_MAX_TEXTURE_STACK_DEPTH, &textureStack); glGetIntegerv(GL_MAX_3D_TEXTURE_SIZE, &maxTex3d); glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTex2d); glGetIntegerv(GL_MAX_NAME_STACK_DEPTH, &nameStack); glGetIntegerv(GL_MAX_LIST_NESTING, &listStack); glGetIntegerv(GL_MAX_EVAL_ORDER, &maxPoly); glGetIntegerv(GL_MAX_ATTRIB_STACK_DEPTH, &attribStack); glGetIntegerv(GL_AUX_BUFFERS, &buffers); glGetIntegerv(GL_MAX_CONVOLUTION_WIDTH, &convolutionWidth); glGetIntegerv(GL_MAX_CONVOLUTION_HEIGHT, &convolutionHeight); glGetIntegerv(GL_MAX_ELEMENTS_INDICES, &maxIndex); glGetIntegerv(GL_MAX_ELEMENTS_VERTICES, &maxVertex); glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &textureUnits); BString tempString; BView *rootView = new BView("root view", 0, NULL); rootView->SetLayout(new BGroupLayout(B_VERTICAL)); tempString << (int32) buffers; AddStringView(rootView, "Buffers", TR("Auxiliary buffer(s):"), tempString.String(), true); tempString.SetTo(""); tempString << (int32) modelStack; AddStringView(rootView, "ModelStack", TR("Model stack size:"), tempString.String(), true); tempString.SetTo(""); tempString << (int32) projectionStack; AddStringView(rootView, "ProjectionStack", TR("Projection stack size:"), tempString.String(), true); tempString.SetTo(""); tempString << (int32) textureStack; AddStringView(rootView, "TextureStack", TR("Texture stack size:"), tempString.String(), true); tempString.SetTo(""); tempString << (int32) nameStack; AddStringView(rootView, "NameStack", TR("Name stack size:"), tempString.String(), true); tempString.SetTo(""); tempString << (int32) listStack; AddStringView(rootView, "ListStack", TR("List stack size:"), tempString.String(), true); tempString.SetTo(""); tempString << (int32) attribStack; AddStringView(rootView, "AttribStack", TR("Attributes stack size:"), tempString.String(), true); tempString.SetTo(""); tempString << (int32) maxTex3d; AddStringView(rootView, "MaxTex3D", TR("Max. 3D texture size:"), tempString.String(), true); tempString.SetTo(""); tempString << (int32) maxTex2d; AddStringView(rootView, "MaxTex2D", TR("Max. 2D texture size:"), tempString.String(), true); tempString.SetTo(""); tempString << (int32) textureUnits; AddStringView(rootView, "MaxTexUnits", TR("Max. texture units:"), tempString.String(), true); tempString.SetTo(""); tempString << (int32) lights; AddStringView(rootView, "MaxLights", TR("Max. lights:"), tempString.String(), true); tempString.SetTo(""); tempString << (int32) clippingPlanes; AddStringView(rootView, "MaxClippingPlanes", TR("Max. clipping planes:"), tempString.String(), true); tempString.SetTo(""); tempString << (int32) maxPoly; AddStringView(rootView, "MaxPoly", TR("Max. evaluators equation order:"), tempString.String(), true); tempString.SetTo(""); tempString << (int32) convolutionWidth << "x" << convolutionHeight; AddStringView(rootView, "MaxConvultion", TR("Max. convolution:"), tempString.String(), true); tempString.SetTo(""); tempString << (int32) maxIndex; AddStringView(rootView, "MaxIndex", TR("Max. recommended index elements:"), tempString.String(), true); tempString.SetTo(""); tempString << (int32) maxVertex; AddStringView(rootView, "MaxVertex", TR("Max. recommended vertex elements:"), tempString.String(), true); AddChild(BGroupLayoutBuilder(B_VERTICAL) .Add(rootView) .SetInsets(kInset, kInset, kInset, kInset) ); }
LocaleWindow::LocaleWindow() : BWindow(BRect(0, 0, 0, 0), "Locale", B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE | B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS) { BCountry* defaultCountry; be_locale_roster->GetDefaultCountry(&defaultCountry); SetLayout(new BGroupLayout(B_HORIZONTAL)); float spacing = be_control_look->DefaultItemSpacing(); BTabView* tabView = new BTabView("tabview"); BGroupView* languageTab = new BGroupView(B_TRANSLATE("Language"), B_HORIZONTAL, spacing); // first list: available languages fLanguageListView = new LanguageListView("available", B_MULTIPLE_SELECTION_LIST); BScrollView* scrollView = new BScrollView("scroller", fLanguageListView, B_WILL_DRAW | B_FRAME_EVENTS, false, true); fLanguageListView->SetInvocationMessage(new BMessage(kMsgLanguageInvoked)); fLanguageListView->SetDragMessage(new BMessage(kMsgLanguageDragged)); // Fill the language list from the LocaleRoster data BMessage installedLanguages; if (be_locale_roster->GetInstalledLanguages(&installedLanguages) == B_OK) { BString currentID; LanguageListItem* lastAddedCountryItem = NULL; for (int i = 0; installedLanguages.FindString("langs", i, ¤tID) == B_OK; i++) { // Now get an human-readable, localized name for each language BLanguage* currentLanguage; be_locale_roster->GetLanguage(currentID.String(), ¤tLanguage); BString name; currentLanguage->GetName(name); // TODO: as long as the app_server doesn't support font overlays, // use the translated name if problematic characters are used... const char* string = name.String(); while (uint32 code = BUnicodeChar::FromUTF8(&string)) { if (code > 1424) { currentLanguage->GetTranslatedName(name); break; } } LanguageListItem* item = new LanguageListItem(name, currentID.String(), currentLanguage->Code()); if (currentLanguage->IsCountrySpecific() && lastAddedCountryItem != NULL && lastAddedCountryItem->Code() == item->Code()) { fLanguageListView->AddUnder(item, lastAddedCountryItem); } else { // This is a language variant, add it at top-level fLanguageListView->AddItem(item); if (!currentLanguage->IsCountrySpecific()) { item->SetExpanded(false); lastAddedCountryItem = item; } } delete currentLanguage; } fLanguageListView->FullListSortItems(compare_typed_list_items); } else { BAlert* alert = new BAlert("Error", B_TRANSLATE("Unable to find the available languages! You can't " "use this preflet!"), B_TRANSLATE("OK"), NULL, NULL, B_WIDTH_AS_USUAL, B_OFFSET_SPACING, B_STOP_ALERT); alert->Go(); } // Second list: active languages fPreferredListView = new LanguageListView("preferred", B_MULTIPLE_SELECTION_LIST); BScrollView* scrollViewEnabled = new BScrollView("scroller", fPreferredListView, B_WILL_DRAW | B_FRAME_EVENTS, false, true); fPreferredListView->SetInvocationMessage( new BMessage(kMsgPreferredLanguageInvoked)); fPreferredListView->SetDeleteMessage( new BMessage(kMsgPreferredLanguageDeleted)); fPreferredListView->SetDragMessage( new BMessage(kMsgPreferredLanguageDragged)); BLayoutBuilder::Group<>(languageTab) .AddGroup(B_VERTICAL, spacing) .Add(new BStringView("", B_TRANSLATE("Available languages"))) .Add(scrollView) .End() .AddGroup(B_VERTICAL, spacing) .Add(new BStringView("", B_TRANSLATE("Preferred languages"))) .Add(scrollViewEnabled) .End() .SetInsets(spacing, spacing, spacing, spacing); BView* countryTab = new BView(B_TRANSLATE("Country"), B_WILL_DRAW); countryTab->SetLayout(new BGroupLayout(B_VERTICAL, 0)); BListView* listView = new BListView("country", B_SINGLE_SELECTION_LIST); scrollView = new BScrollView("scroller", listView, B_WILL_DRAW | B_FRAME_EVENTS, false, true); listView->SetSelectionMessage(new BMessage(kMsgCountrySelection)); // get all available countries from ICU // Use DateFormat::getAvailableLocale so we get only the one we can // use. Maybe check the NumberFormat one and see if there is more. int32_t localeCount; const Locale* currentLocale = Locale::getAvailableLocales(localeCount); for (int index = 0; index < localeCount; index++) { UnicodeString countryFullName; BString string; BStringByteSink sink(&string); currentLocale[index].getDisplayName(countryFullName); countryFullName.toUTF8(sink); LanguageListItem* item = new LanguageListItem(string, currentLocale[index].getName(), NULL); listView->AddItem(item); if (!strcmp(currentLocale[index].getName(), defaultCountry->Code())) listView->Select(listView->CountItems() - 1); } // TODO: find a real solution intead of this hack listView->SetExplicitMinSize( BSize(25 * be_plain_font->Size(), B_SIZE_UNSET)); fFormatView = new FormatView(defaultCountry); countryTab->AddChild(BLayoutBuilder::Group<>(B_HORIZONTAL, spacing) .AddGroup(B_VERTICAL, 3) .Add(scrollView) .End() .Add(fFormatView) .SetInsets(spacing, spacing, spacing, spacing)); listView->ScrollToSelection(); tabView->AddTab(languageTab); tabView->AddTab(countryTab); BButton* button = new BButton(B_TRANSLATE("Defaults"), new BMessage(kMsgDefaults)); fRevertButton = new BButton(B_TRANSLATE("Revert"), new BMessage(kMsgRevert)); fRevertButton->SetEnabled(false); BLayoutBuilder::Group<>(this, B_VERTICAL, spacing) .Add(tabView) .AddGroup(B_HORIZONTAL, spacing) .Add(button) .Add(fRevertButton) .AddGlue() .End() .SetInsets(spacing, spacing, spacing, spacing) .End(); _UpdatePreferredFromLocaleRoster(); SettingsReverted(); CenterOnScreen(); }