BListView::BListView(BMessage* archive) : BView(archive) { int32 listType; archive->FindInt32("_lv_type", &listType); _InitObject((list_view_type)listType); int32 i = 0; BMessage subData; while (archive->FindMessage("_l_items", i++, &subData) == B_OK) { BArchivable* object = instantiate_object(&subData); if (object == NULL) continue; BListItem* item = dynamic_cast<BListItem*>(object); if (item != NULL) AddItem(item); } if (archive->HasMessage("_msg")) { BMessage* invokationMessage = new BMessage; archive->FindMessage("_msg", invokationMessage); SetInvocationMessage(invokationMessage); } if (archive->HasMessage("_2nd_msg")) { BMessage* selectionMessage = new BMessage; archive->FindMessage("_2nd_msg", selectionMessage); SetSelectionMessage(selectionMessage); } }
/*********************************************************** * Constructor ***********************************************************/ HListView::HListView(BRect rect, BetterScrollView** scroll, const char* title) : ColumnListView(rect, (CLVContainerView**)scroll, title, B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE | B_PULSE_NEEDED, B_MULTIPLE_SELECTION_LIST, true) { int16 cols[6]; HPrefs* prefs = ((HApp*)be_app)->Prefs(); for (int i = 1; i <= 6; i++) { BString name = "col"; name << (int32)i; prefs->GetData(name.String(), &cols[i-1]); } AddColumn(new CLVColumn(NULL, 20, CLV_LOCK_AT_BEGINNING | CLV_NOT_MOVABLE | CLV_NOT_RESIZABLE | CLV_PUSH_PASS | CLV_MERGE_WITH_RIGHT)); AddColumn(new CLVColumn(_("Name"), cols[0], CLV_NOT_MOVABLE | CLV_TELL_ITEMS_WIDTH)); AddColumn(new CLVColumn(_("Total"), cols[1], CLV_NOT_MOVABLE | CLV_TELL_ITEMS_WIDTH)); AddColumn(new CLVColumn(_("Transfered"), cols[2], CLV_NOT_MOVABLE | CLV_TELL_ITEMS_WIDTH)); AddColumn(new CLVColumn(_("Average"), cols[3], CLV_NOT_MOVABLE | CLV_TELL_ITEMS_WIDTH)); AddColumn(new CLVColumn(_("Estimated"), cols[4], CLV_NOT_MOVABLE | CLV_TELL_ITEMS_WIDTH)); AddColumn(new CLVColumn(_("Elapsed"), cols[5], CLV_NOT_MOVABLE | CLV_TELL_ITEMS_WIDTH)); SetSortKey(0); SetFont(be_fixed_font); SetSortFunction(CLVEasyItem::CompareItems); SetInvocationMessage(new BMessage(M_LIST_DBL_CLICKED)); SetSelectionMessage(new BMessage(M_SELECTION_CHANGED)); }
void JobListView::AttachedToWindow() { Inherited::AttachedToWindow(); SetSelectionMessage(new BMessage(kMsgJobSelected)); SetTarget(Window()); }
void ListView1::AllAttached() { // SetEditMode(false); MakeFocus(false); SetColumnFlags((column_flags)(B_ALLOW_COLUMN_MOVE | B_ALLOW_COLUMN_RESIZE | B_ALLOW_COLUMN_POPUP | B_ALLOW_COLUMN_REMOVE)); SetMouseTrackingEnabled(false); SetSelectionMessage(new BMessage('slct')); SetInvocationMessage(new BMessage('mm03')); SetTarget(this, Looper()); }
void RocketView::AttachedToWindow() { SetInvocationMessage(new BMessage(ITEM_MENU_INVOKED_MSG)); SetSelectionMessage(new BMessage(ITEM_MENU_SELECTED_MSG)); SetViewColor(B_TRANSPARENT_32_BIT); //create left-click popup menu // build menu // BMenuItem* item; mnuLeft = new BPopUpMenu("context menu"); mnuLeft->SetRadioMode(false); mnuLeft->AddItem(mnuMime = new BMenu("Mark as...")); mnuMime->AddItem(new BMenuItem("Sourcecode", new BMessage(MNU_LEFT_SET_SOURCE))); mnuMime->AddItem(new BMenuItem("Makefile", new BMessage(MNU_LEFT_SET_MAKEFILE))); mnuMime->AddItem(new BMenuItem("Resource", new BMessage(MNU_LEFT_SET_RESOURCE))); mnuMime->AddSeparatorItem(); mnuMime->AddItem(new BMenuItem("Text", new BMessage(MNU_LEFT_SET_TEXT))); mnuMime->AddItem(new BMenuItem("Image", new BMessage(MNU_LEFT_SET_IMAGE))); mnuMime->AddItem(new BMenuItem("Audio", new BMessage(MNU_LEFT_SET_AUDIO))); mnuMime->AddItem(new BMenuItem("Video", new BMessage(MNU_LEFT_SET_VIDEO))); mnuMime->AddItem(new BMenuItem("Application", new BMessage(MNU_LEFT_SET_APP))); mnuMime->AddItem(new BMenuItem("Archive", new BMessage(MNU_LEFT_SET_ARCHIVE))); // item->SetEnabled(false); mnuLeft->AddSeparatorItem(); mnuLeft->AddItem(new BMenuItem("Open with Tracker", new BMessage(MNU_LEFT_OPEN_MSG))); mnuLeft->AddItem(new BMenuItem("Get info", new BMessage(MNU_LEFT_INFO_MSG))); mnuLeft->AddItem(new BMenuItem("Edit name", new BMessage(MNU_LEFT_NAME_MSG))); mnuLeft->AddItem(new BMenuItem("Duplicate", new BMessage(MNU_LEFT_DUPLICATE_MSG))); mnuLeft->AddItem(new BMenuItem("Remove from project", new BMessage(MNU_LEFT_TRASH_MSG))); mnuLeft->AddSeparatorItem(); mnuLeft->AddItem(new BMenuItem("Copy to…", new BMessage(MNU_LEFT_COPY_MSG))); mnuLeft->AddItem(new BMenuItem("Move to…", new BMessage(MNU_LEFT_MOVE_MSG))); mnuLeft->AddSeparatorItem(); mnuLeft->AddItem(new BMenuItem("View in tracker", new BMessage(MNU_LEFT_TRACKER_MSG))); // set window as target so we get the message mnuLeft->SetTargetForItems(this); mnuMime->SetTargetForItems(this); }
/*********************************************************** * Destructor ***********************************************************/ HListView::~HListView() { HPrefs* prefs = ((HApp*)be_app)->Prefs(); for (int16 i = 1; i <= 6; i++) { CLVColumn* col = ColumnAt(i); BString name = "col"; name << (int32)i; int16 width = static_cast<int16>(col->Width()); prefs->SetData(name.String(), width); } SetInvocationMessage(NULL); SetSelectionMessage(NULL); }
void PrinterListView::AttachedToWindow() { Inherited::AttachedToWindow(); SetSelectionMessage(new BMessage(kMsgPrinterSelected)); SetInvocationMessage(new BMessage(kMsgMakeDefaultPrinter)); SetTarget(Window()); BPath path; if (find_directory(B_USER_PRINTERS_DIRECTORY, &path) != B_OK) return; BDirectory dir(path.Path()); if (dir.InitCheck() != B_OK) { // directory has to exist in order to start watching it if (create_directory(path.Path(), 0777) != B_OK) return; dir.SetTo(path.Path()); } fFolder = new FolderWatcher(Window(), dir, true); fFolder->SetListener(this); BuildPrinterList(); // Select active printer BString activePrinterName(ActivePrinterName()); for (int32 i = 0; i < CountItems(); i ++) { PrinterItem* item = dynamic_cast<PrinterItem*>(ItemAt(i)); if (item != NULL && item->Name() == activePrinterName) { Select(i); fActivePrinter = item; break; } } }
BListView::~BListView() { // NOTE: According to BeBook, BListView does not free the items itself. delete fTrack; SetSelectionMessage(NULL); }