status_t BBox::SetLabel(BView *viewLabel) { if (viewLabel != NULL) { if (viewLabel == this || viewLabel->Window() != NULL || viewLabel->Parent() != NULL) return B_ERROR; AddChild(viewLabel, ChildAt(0)); if (viewLabel->Parent() != this) return B_ERROR; viewLabel->SetResizingMode(B_FOLLOW_NONE); } else if (fLabelView == NULL) { return B_OK; } if (fLabelView != NULL) { BView *view = fLabelView; fLabelView = NULL; view->RemoveSelf(); delete view; } fLabelView = viewLabel; ReAdjustLabel(); return B_OK; }
void TrackerSettingsWindow::_HandleChangedSettingsView() { int32 currentSelection = fSettingsTypeListView->CurrentSelection(); if (currentSelection < 0) return; BView* oldView = fSettingsContainerBox->ChildAt(0); if (oldView != NULL) oldView->RemoveSelf(); SettingsItem* selectedItem = dynamic_cast<SettingsItem*>( fSettingsTypeListView->ItemAt(currentSelection)); if (selectedItem != NULL) { fSettingsContainerBox->SetLabel(selectedItem->Text()); BView* view = selectedItem->View(); view->SetViewColor(fSettingsContainerBox->ViewColor()); view->Hide(); fSettingsContainerBox->AddChild(view); view->Show(); } }
void RemoveChildren(BView* view) { if (view != NULL) { BView* child; while ((child = view->ChildAt(0)) != NULL) { child->RemoveSelf(); delete child; } } }
status_t BShelf::_DeleteReplicant(replicant_data* item) { BView *view = item->view; if (view == NULL) view = item->zombie_view; if (view != NULL) view->RemoveSelf(); if (item->dragger != NULL) item->dragger->RemoveSelf(); int32 index = replicant_data::IndexOf(&fReplicants, item->message); ReplicantDeleted(index, item->message, view); fReplicants.RemoveItem(item); if (item->relation == BDragger::TARGET_IS_PARENT || item->relation == BDragger::TARGET_IS_SIBLING) { delete view; } if (item->relation == BDragger::TARGET_IS_CHILD || item->relation == BDragger::TARGET_IS_SIBLING) { delete item->dragger; } // Update use count for image and unload if necessary const char* signature = NULL; if (item->message->FindString("add_on", &signature) == B_OK && signature != NULL) { LoadedImages* loadedImages = LoadedImages::Default(); AutoLock<LoadedImages> lock(loadedImages); if (lock.IsLocked()) { LoadedImageMap::iterator it = loadedImages->images.find( BString(signature)); if (it != loadedImages->images.end()) { (*it).second.second--; if ((*it).second.second <= 0) { unload_add_on((*it).second.first); loadedImages->images.erase(it); } } } } delete item; return B_OK; }
void PrefWindow::MessageReceived(BMessage *message){ BView *tmpV; int32 k; switch (message->what){ case QUIT: Hide(); break; case CHANGE_LANGUAGE: tmpV = ChildAt(0); if (tmpV != NULL){ tmpV->RemoveSelf(); delete tmpV; } BLayoutBuilder::Group<>(this) .AddGroup(B_VERTICAL, B_USE_DEFAULT_SPACING) .Add(new PrefView()); break; case SET_FACTORY: k = (new BAlert(NULL,Language.get("FACTORY_SURE"),Language.get("APPLY"),Language.get("CANCEL")))->Go(); if (k==0){ Prefs.FactorySettings(); KeyBind.InstallDefaults(); tmpV = FindView("Prefs color"); if (tmpV != NULL){ PostMessage(COLOR_SELECT, tmpV); } tmpV = FindView("Prefs keys"); if (tmpV != NULL){ tmpV->LockLooper(); tmpV->Pulse(); tmpV->UnlockLooper(); }else{ be_app->PostMessage(CHANGE_LANGUAGE); } Pool.sample_view_dirty = true; // update the sample-view Pool.update_draw_cache = true; // update the draw cache Pool.update_index = true; // update the index cache Pool.RedrawWindow(); } break; default: BWindow::MessageReceived(message); } }
void BTextWidget::StopEdit(bool saveChanges, BPoint poseLoc, BPoseView* view, BPose* pose, int32 poseIndex) { // find the text editing view BView* scrollView = view->FindView("BorderView"); ASSERT(scrollView != NULL); if (scrollView == NULL) return; BTextView* textView = dynamic_cast<BTextView*>( scrollView->FindView("WidgetTextView")); ASSERT(textView != NULL); if (textView == NULL) return; BColumn* column = view->ColumnFor(fAttrHash); ASSERT(column != NULL); if (column == NULL) return; if (saveChanges && fText->CommitEditedText(textView)) { // we have an actual change, re-sort view->CheckPoseSortOrder(pose, poseIndex); } // make text widget visible again SetVisible(true); view->Invalidate(ColumnRect(poseLoc, column, view)); // force immediate redraw so TEView disappears scrollView->RemoveSelf(); delete scrollView; ASSERT(view->Window() != NULL); view->Window()->UpdateIfNeeded(); view->MakeFocus(); SetActive(false); }
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; } }
// ToolboxWindow::InitWindow -- Initialization Commands here void ToolboxWindow::InitWindow(void) { BRect r; r = Bounds(); // Add Controls // Toolbar //int ToolbarButtonMargin = 2; //int ToolbarButtonWidth = 22; //int ButtonGap = 1; // StringView Button BRect BitmapFrame (BRect(0,0,23,23)); BPicture *tmpBPicture; BPicture *tmpBPicture2; BView *tmpBPictureView = new BView(BitmapFrame, "tmpBPictureView",B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_NAVIGABLE); rgb_color toolbar_button_background = { 255, 255, 255, 0 }; AddChild(tmpBPictureView); BBitmap *stringviewpicture = new BBitmap(BitmapFrame,B_RGB32); stringviewpicture->SetBits(stringviewicon,1728,0,B_RGB32); tmpBPictureView->SetLowColor(toolbar_button_background); tmpBPictureView->BeginPicture(new BPicture); tmpBPictureView->DrawBitmap(stringviewpicture,BPoint(0,0)); tmpBPicture = tmpBPictureView->EndPicture(); tmpBPictureView->RemoveSelf(); AddChild(tmpBPictureView); BBitmap *stringviewpicture_state2 = new BBitmap(BitmapFrame,B_RGB32); stringviewpicture_state2->SetBits(stringviewiconinverse,1728,0,B_RGB32); tmpBPictureView->SetLowColor(toolbar_button_background); tmpBPictureView->BeginPicture(new BPicture); tmpBPictureView->DrawBitmap(stringviewpicture_state2,BPoint(0,0)); tmpBPicture2 = tmpBPictureView->EndPicture(); btnBrieStringViewControl = new BPictureButton(BRect (1,0,24,23),"StringView",tmpBPicture,tmpBPicture2, new BMessage(TOOLBOX_BTN_STRINGVIEWCONTROL),B_ONE_STATE_BUTTON, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_NAVIGABLE); tmpBPictureView->RemoveSelf(); AddChild(tmpBPictureView); //--------------------------------------------------------------------// // TextView Button BBitmap *textviewpicture = new BBitmap(BitmapFrame,B_RGB32); textviewpicture->SetBits(brietextcontrol,1728,0,B_RGB32); tmpBPictureView->SetLowColor(toolbar_button_background); tmpBPictureView->BeginPicture(new BPicture); tmpBPictureView->DrawBitmap(textviewpicture,BPoint(0,0)); tmpBPicture = tmpBPictureView->EndPicture(); tmpBPictureView->RemoveSelf(); AddChild(tmpBPictureView); BBitmap *textviewpicture_state2 = new BBitmap(BitmapFrame,B_RGB32); textviewpicture_state2->SetBits(brietextcontrolinverse,1728,0,B_RGB32); tmpBPictureView->SetLowColor(toolbar_button_background); tmpBPictureView->BeginPicture(new BPicture); tmpBPictureView->DrawBitmap(textviewpicture_state2,BPoint(0,0)); tmpBPicture2 = tmpBPictureView->EndPicture(); btnBrieTextControl = new BPictureButton(BRect (26,0,50,23),"TextControl",tmpBPicture,tmpBPicture2, new BMessage(TOOLBOX_BTN_TEXTCONTROL),B_ONE_STATE_BUTTON, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_NAVIGABLE); tmpBPictureView->RemoveSelf(); AddChild(tmpBPictureView); //--------------------------------------------------------------------// // Button Button BBitmap *buttonpicture = new BBitmap(BitmapFrame,B_RGB32); buttonpicture->SetBits(stringviewicon,1728,0,B_RGB32); tmpBPictureView->SetLowColor(toolbar_button_background); tmpBPictureView->BeginPicture(new BPicture); tmpBPictureView->DrawBitmap(buttonpicture,BPoint(0,0)); tmpBPicture = tmpBPictureView->EndPicture(); tmpBPictureView->RemoveSelf(); AddChild(tmpBPictureView); BBitmap *buttonpicture_state2 = new BBitmap(BitmapFrame,B_RGB32); buttonpicture_state2->SetBits(stringviewiconinverse,1728,0,B_RGB32); tmpBPictureView->SetLowColor(toolbar_button_background); tmpBPictureView->BeginPicture(new BPicture); tmpBPictureView->DrawBitmap(buttonpicture_state2,BPoint(0,0)); tmpBPicture2 = tmpBPictureView->EndPicture(); btnBrieButtonControl = new BPictureButton(BRect (1,25,24,48), "Button",tmpBPicture,tmpBPicture2, new BMessage(TOOLBOX_BTN_BUTTONCONTROL),B_ONE_STATE_BUTTON, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_NAVIGABLE); tmpBPictureView->RemoveSelf(); AddChild(tmpBPictureView); //--------------------------------------------------------------------// // Picture Button BBitmap *picturepicture = new BBitmap(BitmapFrame,B_RGB32); picturepicture->SetBits(stringviewicon,1728,0,B_RGB32); tmpBPictureView->SetLowColor(toolbar_button_background); tmpBPictureView->BeginPicture(new BPicture); tmpBPictureView->DrawBitmap(picturepicture,BPoint(0,0)); tmpBPicture = tmpBPictureView->EndPicture(); tmpBPictureView->RemoveSelf(); AddChild(tmpBPictureView); BBitmap *picturepicture_state2 = new BBitmap(BitmapFrame,B_RGB32); picturepicture_state2->SetBits(stringviewiconinverse,1728,0,B_RGB32); tmpBPictureView->SetLowColor(toolbar_button_background); tmpBPictureView->BeginPicture(new BPicture); tmpBPictureView->DrawBitmap(picturepicture_state2,BPoint(0,0)); tmpBPicture2 = tmpBPictureView->EndPicture(); btnBriePictureControl = new BPictureButton(BRect (26,25,50,48), "TextControl",tmpBPicture,tmpBPicture2, new BMessage(TOOLBOX_BTN_PICTURECONTROL),B_ONE_STATE_BUTTON, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_NAVIGABLE); tmpBPictureView->RemoveSelf(); AddChild(tmpBPictureView); //--------------------------------------------------------------------// AddChild(btnBriePictureControl); AddChild(btnBrieButtonControl); AddChild(btnBrieTextControl); AddChild(btnBrieStringViewControl); // Add the Drawing View AddChild(ptrToolboxWindowView = new ToolboxWindowView(r)); }
PrinterItem::PrinterItem(PrintersWindow* window, const BDirectory& node, PrinterListLayoutData& layoutData) : BListItem(0, false), fFolder(NULL), fNode(node), fLayoutData(layoutData) { BRect rect(0, 0, B_LARGE_ICON - 1, B_LARGE_ICON - 1); if (sIcon == NULL) { #ifdef HAIKU_TARGET_PLATFORM_HAIKU sIcon = new BBitmap(rect, B_RGBA32); #else sIcon = new BBitmap(rect, B_CMAP8); #endif BMimeType type(PSRV_PRINTER_FILETYPE); type.GetIcon(sIcon, B_LARGE_ICON); } if (sIcon && sIcon->IsValid() && sSelectedIcon == NULL) { const float checkMarkIconSize = 20.0; BBitmap *checkMark = _LoadVectorIcon("check_mark_icon", checkMarkIconSize); if (checkMark && checkMark->IsValid()) { sSelectedIcon = new BBitmap(rect, B_RGBA32, true); if (sSelectedIcon && sSelectedIcon->IsValid()) { // draw check mark at bottom left over printer icon BView *view = new BView(rect, "offscreen", B_FOLLOW_ALL, B_WILL_DRAW); float y = rect.Height() - checkMark->Bounds().Height(); sSelectedIcon->Lock(); sSelectedIcon->AddChild(view); view->DrawBitmap(sIcon); view->SetDrawingMode(B_OP_ALPHA); view->DrawBitmap(checkMark, BPoint(0, y)); view->Sync(); view->RemoveSelf(); sSelectedIcon->Unlock(); delete view; } } delete checkMark; } // Get Name of printer _GetStringProperty(PSRV_PRINTER_ATTR_PRT_NAME, fName); _GetStringProperty(PSRV_PRINTER_ATTR_COMMENTS, fComments); _GetStringProperty(PSRV_PRINTER_ATTR_TRANSPORT, fTransport); _GetStringProperty(PSRV_PRINTER_ATTR_TRANSPORT_ADDR, fTransportAddress); _GetStringProperty(PSRV_PRINTER_ATTR_DRV_NAME, fDriverName); BPath path; if (find_directory(B_USER_PRINTERS_DIRECTORY, &path) != B_OK) return; // Setup spool folder path.Append(fName.String()); BDirectory dir(path.Path()); if (dir.InitCheck() == B_OK) { fFolder = new SpoolFolder(window, this, dir); UpdatePendingJobs(); } }
void ActivityWindow::MessageReceived(BMessage* message) { if (message->WasDropped()) { _MessageDropped(message); return; } switch (message->what) { case B_REFS_RECEIVED: case B_SIMPLE_DATA: _MessageDropped(message); break; case kMsgAddView: { #ifdef __HAIKU__ BView* firstView = fLayout->View()->ChildAt(0); _AddDefaultView(); if (firstView != NULL) ResizeBy(0, firstView->Bounds().Height() + fLayout->Spacing()); #endif break; } case kMsgRemoveView: { #ifdef __HAIKU__ BView* view; if (message->FindPointer("view", (void**)&view) != B_OK) break; view->RemoveSelf(); ResizeBy(0, -view->Bounds().Height() - fLayout->Spacing()); delete view; #endif break; } case kMsgShowSettings: { if (fSettingsWindow.IsValid()) { // Just bring the window to front (via scripting) BMessage toFront(B_SET_PROPERTY); toFront.AddSpecifier("Active"); toFront.AddSpecifier("Window", B_TRANSLATE("Settings")); toFront.AddBool("data", true); fSettingsWindow.SendMessage(&toFront); } else { // Open new settings window BWindow* window = new SettingsWindow(this); window->Show(); fSettingsWindow = window; } break; } case kMsgTimeIntervalUpdated: BroadcastToActivityViews(message); break; default: BWindow::MessageReceived(message); break; } }
/*! \brief Destructor for the class ActivityWindow */ ActivityWindow::~ActivityWindow() { BView* toRemove; if ( NULL != ( toRemove = FindView( "Explanation 1" ) ) ) { toRemove->RemoveSelf(); delete toRemove; } if ( NULL != ( toRemove = FindView( "Background" ) ) ) { toRemove->RemoveSelf(); delete toRemove; } if ( NULL != ( toRemove = FindView( "Text view explanation" ) ) ) { toRemove->RemoveSelf(); delete toRemove; } if ( NULL != fTextScroller ) { fTextScroller->RemoveSelf(); delete fTextScroller; } if ( NULL != fNoteText ) { fNoteText->RemoveSelf(); delete fNoteText; } if ( NULL != ( toRemove = FindView( "Sound file explanation" ) ) ) { toRemove->RemoveSelf(); delete toRemove; } if ( NULL != ( toRemove = FindView( "Sound file name" ) ) ) { toRemove->RemoveSelf(); delete toRemove; } if ( NULL != ( toRemove = FindView( "Program explanation" ) ) ) { toRemove->RemoveSelf(); delete toRemove; } if ( NULL != ( toRemove = FindView( "Program file name" ) ) ) { toRemove->RemoveSelf(); delete toRemove; } if ( NULL != ( toRemove = FindView( "Program file options explanation" ) ) ) { toRemove->RemoveSelf(); delete toRemove; } if ( NULL != ( toRemove = FindView( "Program file options" ) ) ) { toRemove->RemoveSelf(); delete toRemove; } if ( NULL != ( toRemove = FindView( "Snooze time selector" ) ) ) { toRemove->RemoveSelf(); delete toRemove; } if ( NULL != ( toRemove = FindView( "Snooze button" ) ) ) { toRemove->RemoveSelf(); delete toRemove; } if ( NULL != ( toRemove = FindView( "Dismiss button" ) ) ) { toRemove->RemoveSelf(); delete toRemove; } } // <-- end of destructor for ActivityWindow