void BRadioButton::SetValue(int32 value) { if (value != Value()) { BControl::SetValueNoUpdate(value); Invalidate(_KnobFrame()); } if (value == 0) return; BView* parent = Parent(); BView* child = NULL; if (parent != NULL) { // If the parent is a BBox, the group parent is the parent of the BBox BBox* box = dynamic_cast<BBox*>(parent); if (box != NULL && box->LabelView() == this) parent = box->Parent(); if (parent != NULL) { BBox* box = dynamic_cast<BBox*>(parent); // If the parent is a BBox, skip the label if there is one if (box != NULL && box->LabelView()) child = parent->ChildAt(1); else child = parent->ChildAt(0); } else child = Window()->ChildAt(0); } else if (Window() != NULL) child = Window()->ChildAt(0); while (child != NULL) { BRadioButton* radio = dynamic_cast<BRadioButton*>(child); if (radio != NULL && (radio != this)) radio->SetValue(B_CONTROL_OFF); else { // If the child is a BBox, check if the label is a radiobutton BBox* box = dynamic_cast<BBox*>(child); if (box != NULL && box->LabelView()) { radio = dynamic_cast<BRadioButton*>(box->LabelView()); if (radio != NULL && (radio != this)) radio->SetValue(B_CONTROL_OFF); } } child = child->NextSibling(); } ASSERT(Value() == B_CONTROL_ON); }
void ModulesView::_OpenSaver() { // create new screen saver preview & config BView* view = fPreviewView->AddPreview(); fCurrentName = fSettings.ModuleName(); fSaverRunner = new ScreenSaverRunner(Window(), view, true, fSettings); BScreenSaver* saver = _ScreenSaver(); #ifdef __HAIKU__ BRect rect = fSettingsBox->InnerFrame().InsetByCopy(4, 4); #else BRect rect = fSettingsBox->Bounds().InsetByCopy(4, 4); rect.top += 14; #endif fSettingsView = new BView(rect, "SettingsView", B_FOLLOW_ALL, B_WILL_DRAW); fSettingsView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); fSettingsBox->AddChild(fSettingsView); if (saver != NULL && fSaverRunner->Run() == B_OK) saver->StartConfig(fSettingsView); if (fSettingsView->ChildAt(0) == NULL) { // There are no settings at all, we add the module name here to // let it look a bit better at least. BPrivate::BuildScreenSaverDefaultSettingsView(fSettingsView, fSettings.ModuleName()[0] ? fSettings.ModuleName() : B_TRANSLATE("Blackness"), saver != NULL || !fSettings.ModuleName()[0] ? B_TRANSLATE("No options available") : B_TRANSLATE("Could not load screen saver")); } }
void TMediaTabView::DeactivateView(EChildID which) { // Take away the control buttons BView* view = ChildAt(which); BView* b = view->ChildAt(0); while (b) { BView* next = b->NextSibling(); if (dynamic_cast<TRadioBitmapButton*>(b) != 0) view->RemoveChild(b); b = next; } // Make sure the view is invisible if (!view->IsHidden()) view->Hide(); }
void ModulesView::_OpenSaver() { // create new screen saver preview & config BView* view = fPreviewView->AddPreview(); fCurrentName = fSettings.ModuleName(); fSaverRunner = new ScreenSaverRunner(view->Window(), view, fSettings); #ifdef __HAIKU__ BRect rect = fSettingsBox->InnerFrame().InsetByCopy(4, 4); #else BRect rect = fSettingsBox->Bounds().InsetByCopy(4, 4); rect.top += 14; #endif fSettingsView = new BView(rect, "SettingsView", B_FOLLOW_ALL, B_WILL_DRAW); fSettingsView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); fSettingsBox->AddChild(fSettingsView); BScreenSaver* saver = ScreenSaver(); if (saver != NULL && fSettingsView != NULL) { saver->StartConfig(fSettingsView); if (saver->StartSaver(view, true) == B_OK) { fPreviewView->HideNoPreview(); fSaverRunner->Run(); } else fPreviewView->ShowNoPreview(); } else { // Failed to load OR this is the "Blackness" screensaver. Show a black // preview (this is what will happen in both cases when screen_blanker // runs). fPreviewView->HideNoPreview(); } if (fSettingsView->ChildAt(0) == NULL) { // There are no settings at all, we add the module name here to // let it look a bit better at least. BPrivate::BuildDefaultSettingsView(fSettingsView, fSettings.ModuleName()[0] ? fSettings.ModuleName() : B_TRANSLATE("Blackness"), saver != NULL || !fSettings.ModuleName()[0] ? B_TRANSLATE("No options available") : B_TRANSLATE("Could not load screen saver")); } }
status_t ActivityWindow::_SaveSettings() { BFile file; status_t status = _OpenSettings(file, B_WRITE_ONLY | B_CREATE_FILE | B_ERASE_FILE); if (status < B_OK) return status; BMessage settings('actm'); status = settings.AddRect("window frame", Frame()); if (status != B_OK) return status; status = settings.SetBool("always on top", fAlwaysOnTop->IsMarked()); if (status != B_OK) return status; #ifdef __HAIKU__ BView* top = fLayout->View(); #else BView* top = ChildAt(0); #endif int32 count = top->CountChildren(); for (int32 i = 0; i < count; i++) { ActivityView* view = dynamic_cast<ActivityView*>(top->ChildAt(i)); if (view == NULL) continue; BMessage viewState; status = view->SaveState(viewState); if (status == B_OK) status = settings.AddMessage("activity view", &viewState); if (status != B_OK) break; } if (status == B_OK) status = settings.Flatten(&file); return status; }
void ModulesView::_OpenSaver() { // create new screen saver preview & config BView* view = fPreviewView->AddPreview(); fCurrentName = fSettings.ModuleName(); fSaverRunner = new ScreenSaverRunner(Window(), view, true, fSettings); BScreenSaver* saver = _ScreenSaver(); #ifdef __HAIKU__ BRect rect = fSettingsBox->InnerFrame().InsetByCopy(4, 4); #else BRect rect = fSettingsBox->Bounds().InsetByCopy(4, 4); rect.top += 14; #endif fSettingsView = new BView(rect, "SettingsView", B_FOLLOW_ALL, B_WILL_DRAW); fSettingsView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); fSettingsBox->AddChild(fSettingsView); if (saver != NULL) { fSaverRunner->Run(); saver->StartConfig(fSettingsView); } if (fSettingsView->ChildAt(0) == NULL) { // There are no settings at all, we add the module name here to // let it look a bit better at least. BPrivate::BuildScreenSaverDefaultSettingsView(fSettingsView, fSettings.ModuleName()[0] ? fSettings.ModuleName() : B_TRANSLATE("Blackness"), saver || !fSettings.ModuleName()[0] ? B_TRANSLATE("No options available") : B_TRANSLATE("Could not load screen saver")); } ScreenSaverWindow* window = dynamic_cast<ScreenSaverWindow*>(Window()); if (window == NULL) return; // find the minimal size of the settings view float right = 0, bottom = 0; int32 i = 0; while ((view = fSettingsView->ChildAt(i++)) != NULL) { // very simple heuristic... float viewRight = view->Frame().right; if ((view->ResizingMode() & _rule_(0, 0xf, 0, 0xf)) == B_FOLLOW_LEFT_RIGHT) { float width, height; view->GetPreferredSize(&width, &height); viewRight = view->Frame().left + width / 2; } else if ((view->ResizingMode() & _rule_(0, 0xf, 0, 0xf)) == B_FOLLOW_RIGHT) viewRight = 8 + view->Frame().Width(); float viewBottom = view->Frame().bottom; if ((view->ResizingMode() & _rule_(0xf, 0, 0xf, 0)) == B_FOLLOW_TOP_BOTTOM) { float width, height; view->GetPreferredSize(&width, &height); viewBottom = view->Frame().top + height; } else if ((view->ResizingMode() & _rule_(0xf, 0, 0xf, 0)) == B_FOLLOW_BOTTOM) viewBottom = 8 + view->Frame().Height(); if (viewRight > right) right = viewRight; if (viewBottom > bottom) bottom = viewBottom; } if (right < kMinSettingsWidth) right = kMinSettingsWidth; if (bottom < kMinSettingsHeight) bottom = kMinSettingsHeight; BPoint leftTop = fSettingsView->LeftTop(); fSettingsView->ConvertToScreen(&leftTop); window->ConvertFromScreen(&leftTop); window->SetMinimalSizeLimit(leftTop.x + right + 16, leftTop.y + bottom + 16); }
//------------------------------------------------------------------------------ uint32 WindowEditor::MakeBitmask(void) { uint32 bitmask = 0; for (uint32 i = 0; i < fFlagBoxes.size(); ++i) { if (WindowFlags[i].flag != MSG_WINDOW_ADD_MENU && WindowFlags[i].flip == fFlagBoxes[i]->Value()) { bitmask |= WindowFlags[i].flag; } } return bitmask; #if 0 BView *box = ((BTabView *)(main->FindView("tabs")))->TabAt(1)->View()->FindView("flags"); uint32 bitmask = 0; if (((BCheckBox *)(box->ChildAt(0)))->Value() == B_CONTROL_OFF) bitmask = bitmask | B_NOT_MOVABLE; if (((BCheckBox *)(box->ChildAt(1)))->Value() == B_CONTROL_OFF) bitmask = bitmask | B_NOT_CLOSABLE; if (((BCheckBox *)(box->ChildAt(2)))->Value() == B_CONTROL_OFF) bitmask = bitmask | B_NOT_ZOOMABLE; if (((BCheckBox *)(box->ChildAt(3)))->Value() == B_CONTROL_OFF) bitmask = bitmask | B_NOT_MINIMIZABLE; if (((BCheckBox *)(box->ChildAt(4)))->Value() == B_CONTROL_OFF) bitmask = bitmask | B_NOT_H_RESIZABLE; if (((BCheckBox *)(box->ChildAt(5)))->Value() == B_CONTROL_OFF) bitmask = bitmask | B_NOT_V_RESIZABLE; if (((BCheckBox *)(box->ChildAt(7)))->Value() == B_CONTROL_ON) bitmask = bitmask | B_OUTLINE_RESIZE; if (((BCheckBox *)(box->ChildAt(8)))->Value() == B_CONTROL_ON) bitmask = bitmask | B_WILL_ACCEPT_FIRST_CLICK; if (((BCheckBox *)(box->ChildAt(9)))->Value() == B_CONTROL_ON) bitmask = bitmask | B_AVOID_FRONT; if (((BCheckBox *)(box->ChildAt(10)))->Value() == B_CONTROL_ON) bitmask = bitmask | B_AVOID_FOCUS; if (((BCheckBox *)(box->ChildAt(11)))->Value() == B_CONTROL_ON) bitmask = bitmask | B_NO_WORKSPACE_ACTIVATION; if (((BCheckBox *)(box->ChildAt(12)))->Value() == B_CONTROL_ON) bitmask = bitmask | B_NOT_ANCHORED_ON_ACTIVATE; if (((BCheckBox *)(box->ChildAt(13)))->Value() == B_CONTROL_ON) bitmask = bitmask | B_ASYNCHRONOUS_CONTROLS; return bitmask; #endif }
/*------------------------------------------------------------------------------*\ ( ) - \*------------------------------------------------------------------------------*/ void BmToolbar::UpdateLayout(bool recalcSizes) { if (LockLooper()) { // since we want the background tiles for the complete toolbar to appear // as one piece, we can't simply use the toolbar-background as view-bitmap // in all toolbar-buttons (horizontal wallpapering wouldn't work). // So, we render the complete wallpaper into a special bitmap, which is // then used by each toolbar-button when that creates its pictures. BRect rect = Bounds(); BmBitmapHandle* toolbarBackground = TheResources->IconByName("Toolbar_Background"); if (toolbarBackground) { delete mBackgroundBitmap; BView* view = new BView( rect, NULL, B_FOLLOW_NONE, 0); mBackgroundBitmap = new BBitmap( rect, B_RGBA32, true); mBackgroundBitmap->AddChild( view); mBackgroundBitmap->Lock(); float y=0.0; while(y < rect.Height()) { float x=0.0; while(x < rect.Width()) { view->DrawBitmap(toolbarBackground->bitmap, BPoint(x,y)); x += toolbarBackground->bitmap->Bounds().Width(); } y += toolbarBackground->bitmap->Bounds().Height(); } view->Sync(); mBackgroundBitmap->Unlock(); mBackgroundBitmap->RemoveChild(view); delete view; } // now step through all toolbar-buttons and let them create // their pictures: BView* group = ChildAt(0); if (group) { int32 count = group->CountChildren(); // Get maximum button size... float width=0, height=0; for( int32 c=0; c<count; ++c) { BmToolbarButton* tbb = dynamic_cast<BmToolbarButton*>(group->ChildAt(c)); if (tbb) BmToolbarButton::CalcMaxSize( width, height, tbb->Label().String(), tbb->NeedsLatch() ); } //...and layout all buttons according to this size: for( int32 c=0; c<count; ++c) { BmToolbarButton* tbb = dynamic_cast<BmToolbarButton*>(group->ChildAt(c)); if (tbb) tbb->CreateAllPictures(width, height); } MWindow* win = dynamic_cast<MWindow*>( Window()); if (win && recalcSizes) win->RecalcSize(); for( int32 c=0; c<count; ++c) group->ChildAt(c)->Invalidate(); } // FIXME: a little hackish, but we need to invalidate the whole window // anyway, since icons in other views will have changed, too. // Strangely enough, calling Invalidate() on the topmost child // doesn't work... Window()->ChildAt(0)->Hide(); Window()->ChildAt(0)->Show(); UnlockLooper(); } }
PrefsWindow::PrefsWindow(uint32 msg) : BWindow(BRect(0, 0, 400, 289), GetString(STR_PREFS_TITLE), B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS), this_messenger(this) { int i; ok_message = msg; send_quit_on_close = true; get_system_info(&sys_info); // Move window to right position Lock(); MoveTo(80, 80); // Set up menus BMenuBar *bar = new BMenuBar(Bounds(), "menu"); BMenu *menu = new BMenu(GetString(STR_PREFS_MENU)); menu->AddItem(new BMenuItem(GetString(STR_PREFS_ITEM_ABOUT), new BMessage(B_ABOUT_REQUESTED))); menu->AddItem(new BSeparatorItem); menu->AddItem(new BMenuItem(GetString(STR_PREFS_ITEM_START), new BMessage(MSG_OK))); menu->AddItem(new BMenuItem(GetString(STR_PREFS_ITEM_ZAP_PRAM), new BMessage(MSG_ZAP_PRAM))); menu->AddItem(new BSeparatorItem); menu->AddItem(new BMenuItem(GetString(STR_PREFS_ITEM_QUIT), new BMessage(MSG_CANCEL), 'Q')); bar->AddItem(menu); AddChild(bar); SetKeyMenuBar(bar); int mbar_height = int(bar->Bounds().bottom) + 1; // Resize window to fit menu bar ResizeBy(0, mbar_height); // Light gray background BRect b = Bounds(); top = new BView(BRect(0, mbar_height, b.right, b.bottom), "top", B_FOLLOW_NONE, B_WILL_DRAW); AddChild(top); top->SetViewColor(fill_color); top_frame = top->Bounds(); // Create panes panes[0] = create_volumes_pane(); panes[1] = create_graphics_pane(); panes[2] = create_serial_pane(); panes[3] = create_memory_pane(); // Prefs item tab view pane_tabs = new BTabView(BRect(10, 10, top_frame.right-10, top_frame.bottom-50), "items", B_WIDTH_FROM_LABEL); for (i=0; i<NUM_PANES; i++) pane_tabs->AddTab(panes[i]); top->AddChild(pane_tabs); volume_list->Select(0); // Create volume file panels add_volume_panel = new BFilePanel(B_OPEN_PANEL, &this_messenger, NULL, B_FILE_NODE | B_DIRECTORY_NODE, false, new BMessage(MSG_ADD_VOLUME_PANEL)); add_volume_panel->SetButtonLabel(B_DEFAULT_BUTTON, GetString(STR_ADD_VOLUME_PANEL_BUTTON)); add_volume_panel->Window()->SetTitle(GetString(STR_ADD_VOLUME_TITLE)); create_volume_panel = new BFilePanel(B_SAVE_PANEL, &this_messenger, NULL, B_FILE_NODE | B_DIRECTORY_NODE, false, new BMessage(MSG_CREATE_VOLUME_PANEL)); create_volume_panel->SetButtonLabel(B_DEFAULT_BUTTON, GetString(STR_CREATE_VOLUME_PANEL_BUTTON)); create_volume_panel->Window()->SetTitle(GetString(STR_CREATE_VOLUME_TITLE)); create_volume_panel->Window()->Lock(); BView *background = create_volume_panel->Window()->ChildAt(0); background->FindView("PoseView")->ResizeBy(0, -30); background->FindView("VScrollBar")->ResizeBy(0, -30); background->FindView("CountVw")->MoveBy(0, -30); BView *v = background->FindView("HScrollBar"); if (v) v->MoveBy(0, -30); else { i = 0; while ((v = background->ChildAt(i++)) != NULL) { if (v->Name() == NULL || v->Name()[0] == 0) { v->MoveBy(0, -30); // unnamed horizontal scroll bar break; } } } BView *filename = background->FindView("text view"); BRect fnr(filename->Frame()); fnr.OffsetBy(0, -30); NumberControl *nc = new NumberControl(fnr, 80, "hardfile_size", GetString(STR_HARDFILE_SIZE_CTRL), 40, NULL); background->AddChild(nc); create_volume_panel->Window()->Unlock(); // "Start" button BButton *button = new BButton(BRect(20, top_frame.bottom-35, 90, top_frame.bottom-10), "start", GetString(STR_START_BUTTON), new BMessage(MSG_OK)); top->AddChild(button); SetDefaultButton(button); // "Quit" button top->AddChild(new BButton(BRect(top_frame.right-90, top_frame.bottom-35, top_frame.right-20, top_frame.bottom-10), "cancel", GetString(STR_QUIT_BUTTON), new BMessage(MSG_CANCEL))); Unlock(); Show(); }