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 RosterView::AttachedToWindow() { BOutlineListView::AttachedToWindow(); SetInvocationMessage(new BMessage(JAB_OPEN_CHAT)); _popup = new BPopUpMenu(NULL, false, false); _chat_item = new BMenuItem("Message...", new BMessage(JAB_OPEN_NEW_CHAT)); _chat_item->SetEnabled(true); _change_user_item = new BMenuItem("Edit", new BMessage(JAB_OPEN_EDIT_BUDDY_WINDOW)); _change_user_item->SetEnabled(false); _remove_user_item = new BMenuItem("Remove", new BMessage(JAB_REMOVE_BUDDY)); _remove_user_item->SetEnabled(false); _presence = new BMenu("Presence"); _presence->SetEnabled(false); _subscribe_presence = new BMenuItem("Subscribe", new BMessage(JAB_SUBSCRIBE_PRESENCE)); _unsubscribe_presence = new BMenuItem("Unsubscribe", new BMessage(JAB_UNSUBSCRIBE_PRESENCE)); _revoke_presence = new BMenuItem("Revoke", new BMessage(JAB_REVOKE_PRESENCE)); _resend_presence = new BMenuItem("Resend", new BMessage(JAB_RESEND_PRESENCE)); _presence->AddItem(_subscribe_presence); _presence->AddItem(_unsubscribe_presence); _presence->AddSeparatorItem(); _presence->AddItem(_revoke_presence); _presence->AddItem(_resend_presence); _popup->AddItem(_chat_item); _popup->AddSeparatorItem(); _popup->AddItem(_change_user_item); _popup->AddItem(_remove_user_item); _popup->AddSeparatorItem(); _popup->AddItem(_presence); UpdatePopUpMenu(); _online = new RosterSuperitem("Online"); _offline = new RosterSuperitem("Offline"); _unknown = new RosterSuperitem("No Presence"); _conferences = new RosterSuperitem("Conferences"); _item_to_status_map[_offline] = UserID::OFFLINE; _item_to_status_map[_online] = UserID::ONLINE; _item_to_status_map[_unknown] = UserID::UNKNOWN; _item_to_status_map[_conferences] = UserID::CONF_STATUS; _status_to_item_map[UserID::OFFLINE] = _offline; _status_to_item_map[UserID::ONLINE] = _online; _status_to_item_map[UserID::UNKNOWN] = _unknown; _status_to_item_map[UserID::CONF_STATUS] = _conferences; _presence->SetTargetForItems(Window()); _popup->SetTargetForItems(Window()); CreateRoots(); }
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); }
TeamListView::TeamListView(BRect frame, const char *name, CLVContainerView **s) : ColumnListView(frame, s, name, B_FOLLOW_ALL_SIDES, B_WILL_DRAW|B_NAVIGABLE|B_FRAME_EVENTS, B_MULTIPLE_SELECTION_LIST, true, true, true, false, B_FANCY_BORDER) { // add Columns... AddColumn(new CLVColumn(NULL, 20.0, CLV_EXPANDER|CLV_LOCK_AT_BEGINNING|CLV_NOT_MOVABLE)); AddColumn(new CLVColumn(NULL, 20.0, CLV_LOCK_AT_BEGINNING|CLV_NOT_RESIZABLE| CLV_NOT_MOVABLE|CLV_MERGE_WITH_RIGHT)); AddColumn(new CLVColumn("Name", 100.0, CLV_LOCK_AT_BEGINNING|CLV_NOT_MOVABLE)); AddColumn(new CLVColumn("Id", 40.0)); AddColumn(new CLVColumn("Priority", 50.0)); AddColumn(new CLVColumn("State", 60.0)); AddColumn(new CLVColumn("Memory", 60.0)); AddColumn(new CLVColumn("CPU", 60.0)); SetInvocationMessage(new BMessage(TEAM_INV)); // create the PopUpMenu BMenuItem *inv; operationMenu = new BPopUpMenu("operationMenu", false, false); operationMenu->AddItem((inv = new BMenuItem("Kill", new BMessage(IE_MAINWINDOW_MAINKILL)))); inv->SetTarget(slayer->mainWindow); operationMenu->AddItem((inv = new BMenuItem("Suspend", new BMessage(IE_MAINWINDOW_MAINSUSPEND)))); inv->SetTarget(slayer->mainWindow); operationMenu->AddItem((inv = new BMenuItem("Resume", new BMessage(IE_MAINWINDOW_MAINRESUME)))); inv->SetTarget(slayer->mainWindow); operationMenu->AddSeparatorItem(); priorityMenu = new BMenu("PriorityMenu"); BMenuItem *pr = new BMenuItem(priorityMenu); //, new BMessage('tmpj')); pr->SetLabel("Set priority"); operationMenu->AddItem(pr); ItemsToPopUpPriorityMenu(); // MakeFocus(true); // = new BMenu("Set priority"); // operationMenu->AddItem(setPriorityMenu); // operationMenu->AddSeparator }
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; } } }