//Opens the table that is currently selected using the given view. Or, if the table //is already open, brings it to the front. void BeAccessibleWindow::OpenTable(int view) { DBTabView* tab = (DBTabView*)fTabView->GetCurrentTab(); BStringItem* selectedTable; //Find the currently selected table if (tab->fListView->CurrentSelection() >= 0) { selectedTable = (BStringItem*)tab->fListView->ItemAt( tab->fListView->CurrentSelection() ); } else { //No table is selected return; } if (!WindowExists(selectedTable->Text())) { //Open a new table window if it isn't already fNewGrid = new TableWindow(view, selectedTable->Text()); } else { //If the table is already open, bring it to the front BringWindowToFront(selectedTable->Text()); } }
BStringItem* CookieWindow::_AddDomain(BString domain, bool fake) { BStringItem* parent = NULL; int firstDot = domain.FindFirst('.'); if (firstDot >= 0) { BString parentDomain(domain); parentDomain.Remove(0, firstDot + 1); parent = _AddDomain(parentDomain, true); } else { parent = (BStringItem*)fDomains->FullListItemAt(0); } BListItem* existing; int i = 0; // check that we aren't already there while ((existing = fDomains->ItemUnderAt(parent, true, i++)) != NULL) { DomainItem* stringItem = (DomainItem*)existing; if (stringItem->Text() == domain) { if (fake == false) stringItem->fEmpty = false; return stringItem; } } #if 0 puts("=============================="); for (i = 0; i < fDomains->FullListCountItems(); i++) { BStringItem* t = (BStringItem*)fDomains->FullListItemAt(i); for (unsigned j = 0; j < t->OutlineLevel(); j++) printf(" "); printf("%s\n", t->Text()); } #endif // Insert the new item, keeping the list alphabetically sorted BStringItem* domainItem = new DomainItem(domain, fake); domainItem->SetOutlineLevel(parent->OutlineLevel() + 1); BStringItem* sibling = NULL; int siblingCount = fDomains->CountItemsUnder(parent, true); for (i = 0; i < siblingCount; i++) { sibling = (BStringItem*)fDomains->ItemUnderAt(parent, true, i); if (strcmp(sibling->Text(), domainItem->Text()) > 0) { fDomains->AddItem(domainItem, fDomains->FullListIndexOf(sibling)); return domainItem; } } if (sibling) { // There were siblings, but all smaller than what we try to insert. // Insert after the last one (and its subitems) fDomains->AddItem(domainItem, fDomains->FullListIndexOf(sibling) + fDomains->CountItemsUnder(sibling, false) + 1); } else { // There were no siblings, insert right after the parent fDomains->AddItem(domainItem, fDomains->FullListIndexOf(parent) + 1); } return domainItem; }
static int StringItemComp(const BListItem* first, const BListItem* second) { BStringItem* firstItem = (BStringItem*)first; BStringItem* secondItem = (BStringItem*)second; return BPrivate::NaturalCompare(firstItem->Text(), secondItem->Text()); }
bool CPasteFunctionDialog::OKClicked() { bool result = true; BStringItem *item = (BStringItem *)fList->ItemAt(fList->CurrentSelection()); char *cp; if (item) { BMessage msg(msg_FunctionChosen); const char *s = item->Text(); msg.AddString("string", item->Text()); if (strstr(s, "()") != NULL) ; else if ((cp = strchr(s, '(')) != NULL) { int start; start = cp - s + 1; int end = 0; char *sp; if ((sp = strchr(cp, gListSeparator)) != NULL) { end = sp - cp - 1; } if (!end && (sp = strchr(cp, ')')) != NULL) { end = sp - cp - 1; } if (!end) end = strlen(s) - start - 1; msg.AddInt32("start", start); msg.AddInt32("stop", end); } fOwner->PostMessage(&msg, fOwner->GetEditBox()); } else result = false; return result; } /* CPasteFunctionDialog::OKClicked */
void CookieWindow::MessageReceived(BMessage* message) { switch(message->what) { case DOMAIN_SELECTED: { int32 index = message->FindInt32("index"); BStringItem* item = (BStringItem*)fDomains->ItemAt(index); if (item != NULL) { BString domain = item->Text(); _ShowCookiesForDomain(domain); } return; } case COOKIE_REFRESH: _BuildDomainList(); return; case COOKIE_DELETE: _DeleteCookies(); return; } BWindow::MessageReceived(message); }
// Gets the user's selection, and parses it up to get the server, // then formats a BMessage and sends it to whomever opened the window. void InexactMatchWindow::Save() { const char *selectedText; int selection = cdList->CurrentSelection(); if (selection < 0) { beep(); return; } // Copy the selected string. BStringItem *item; item = (BStringItem *) cdList->ItemAt(selection); selectedText = item->Text(); char *parseStr= new char[strlen(selectedText)+1]; strcpy(parseStr,selectedText); char *disc_id; char *category; // Send the response to the CDDB looper category = strtok(parseStr," "); disc_id = strtok(NULL," "); printf("Category is %s.\n",category); printf("New ID is %s.\n",disc_id); BMessage *msg = new BMessage(CDDB_READ); msg->AddString("category",category); msg->AddString("disc_id",disc_id); replyTo.SendMessage(msg); delete parseStr; PostMessage(B_QUIT_REQUESTED); }
void MidiSettingsView::_LoadSettings() { // TODO: Duplicated code between here // and BSoftSynth::SetDefaultInstrumentsFile char buffer[512]; BPath path; if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK) { path.Append(SETTINGS_FILE); BFile file(path.Path(), B_READ_ONLY); if (file.InitCheck() == B_OK) { file.Read(buffer, sizeof(buffer)); char soundFont[512]; sscanf(buffer, "# Midi Settings\n soundfont = %s\n", soundFont); for (int32 i = 0; i < fListView->CountItems(); i++) { BStringItem* item = (BStringItem*)fListView->ItemAt(i); if (!strcmp(item->Text(), soundFont)) { fListView->Select(i); break; } } } } }
void BrowseView::FindInIndex(bool select, const char *s) { if (s==NULL) s = searchTextView->Text(); BString str(s); if(!containsSearch) { unsigned int nL = linksList->CountItems(); for (unsigned int i=0; i<nL; i++) { BStringItem *it = (BStringItem*)linksList->ItemAt(i); if (str.ICompare(it->Text()) <= 0) { BRect r = linksList->ItemFrame(i); linksList->ScrollTo(r.LeftTop()); if (select) linksList->Select(i); break; } } } else { tasks->GiveUp(); linksList->MakeEmpty(); if (str == "") return; tasks->DoFindInIndex(str,this,select); } }
void GrepWindow::_OnTrimSelection() { if (fSearchResults->CurrentSelection() < 0) { BString text; text << B_TRANSLATE("Please select the files you wish to keep searching."); text << "\n"; text << B_TRANSLATE("The unselected files will be removed from the list."); text << "\n"; BAlert* alert = new BAlert(NULL, text.String(), B_TRANSLATE("OK"), NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->Go(NULL); return; } BMessage message; BString path; for (int32 index = 0; ; index++) { BStringItem* item = dynamic_cast<BStringItem*>( fSearchResults->ItemAt(index)); if (item == NULL) break; if (!item->IsSelected() || item->OutlineLevel() != 0) continue; if (path == item->Text()) continue; path = item->Text(); entry_ref ref; if (get_ref_for_path(path.String(), &ref) == B_OK) message.AddRef("refs", &ref); } fModel->fDirectory = entry_ref(); // invalidated on purpose fModel->fSelectedFiles.MakeEmpty(); fModel->fSelectedFiles = message; PostMessage(MSG_START_CANCEL); _SetWindowTitle(); }
void GrepWindow::_OnCopyText() { bool onlyCopySelection = true; if (fSearchResults->CurrentSelection() < 0) onlyCopySelection = false; BString buffer; for (int32 index = 0; ; index++) { BStringItem* item = dynamic_cast<BStringItem*>( fSearchResults->ItemAt(index)); if (item == NULL) break; if (onlyCopySelection) { if (item->IsSelected()) buffer << item->Text() << "\n"; } else buffer << item->Text() << "\n"; } status_t status = B_OK; BMessage* clip = NULL; if (be_clipboard->Lock()) { be_clipboard->Clear(); clip = be_clipboard->Data(); clip->AddData("text/plain", B_MIME_TYPE, buffer.String(), buffer.Length()); status = be_clipboard->Commit(); if (status != B_OK) { be_clipboard->Unlock(); return; } be_clipboard->Unlock(); } }
void FreqWindow::SetList(){ BStringItem *it = NULL; for (int32 i=0; i<list->CountItems(); i++){ it = (BStringItem*)list->ItemAt(i); it->Deselect(); float frequency = atof( it->Text() ); if (Pool.frequency == frequency){ it->Select(); text->SetValue(Pool.frequency); } } }
/** * @brief Gets a string at specified index from the control. * @param[in] index index * @param[out] text a string value is returned. */ void BeListViewAdapter::GetItemText(SInt32 index, MBCString& text) { BListView* listView = getListView(); BStringItem* listItem = dynamic_cast<BStringItem*>(listView->ItemAt(index)); if (NULL != listItem) { text = listItem->Text(); } else { text.Empty(); } }
void KeymapWindow::_SetListViewSize(BListView* listView) { float minWidth = 0; for (int32 i = 0; i < listView->CountItems(); i++) { BStringItem* item = (BStringItem*)listView->ItemAt(i); float width = listView->StringWidth(item->Text()); if (width > minWidth) minWidth = width; } listView->SetExplicitMinSize(BSize(minWidth + 8, 32)); }
void SearchApp::LaunchFile(BMessage *message) { BListView *searchResults ; int32 index ; message->FindPointer("source", (void**)&searchResults) ; message->FindInt32("index", &index) ; BStringItem *result = (BStringItem*)searchResults->ItemAt(index) ; entry_ref ref ; BEntry entry(result->Text()) ; entry.GetRef(&ref) ; be_roster->Launch(&ref) ; }
bool KeymapWindow::_SelectCurrentMap(BListView* view) { if (fCurrentMapName.Length() <= 0) return false; for (int32 i = 0; i < view->CountItems(); i++) { BStringItem* current = dynamic_cast<BStringItem *>(view->ItemAt(i)); if (current != NULL && fCurrentMapName == current->Text()) { view->Select(i); view->ScrollToSelection(); return true; } } return false; }
void GrepWindow::_OnInvokeItem() { for (int32 selectionIndex = 0; ; selectionIndex++) { int32 itemIndex = fSearchResults->CurrentSelection(selectionIndex); BListItem* item = fSearchResults->ItemAt(itemIndex); if (item == NULL) break; int32 level = item->OutlineLevel(); int32 lineNum = -1; // Get the line number. // only this level has line numbers if (level == 1) { BStringItem* str = dynamic_cast<BStringItem*>(item); if (str != NULL) { lineNum = atol(str->Text()); // fortunately, atol knows when to stop the conversion } } // Get the top-most item and launch its entry_ref. while (level != 0) { item = fSearchResults->Superitem(item); if (item == NULL) break; level = item->OutlineLevel(); } ResultItem* entry = dynamic_cast<ResultItem*>(item); if (entry != NULL) { bool done = false; if (fModel->fInvokePe) done = _OpenInPe(entry->ref, lineNum); if (!done) be_roster->Launch(&entry->ref); } } }
BStringItem * GuideWindow::modifyGuide(BMessage *msg) { int32 point; int32 list; BStringItem *item = getFocusSelectedItem(); if(item) { point = atoi(item->Text()); msg->AddInt32("point", point); list = _tv_gridguides->Selection(); if(list == 0) { msg->AddBool("orientation", true); } else { msg->AddBool("orientation", false); } BMessenger messenger(main_view); messenger.SendMessage(msg); } return item; }
static char* haikuListGetIdValueAttrib(Ihandle* ih, int id) { BView* view = (BView*)ih->handle; BMenuField* menu = dynamic_cast<BMenuField*>(view); if(menu) { UNIMPLEMENTED return NULL; } BListView* listview = iuphaikuGetListView(view); if(listview) { BStringItem* item = (BStringItem*)listview->ItemAt(id - 1); return (char*)item->Text(); } else { fprintf(stderr, "View hierarchy problem\n"); } return NULL; }
void MidiSettingsView::_SaveSettings() { int32 selection = fListView->CurrentSelection(); if (selection < 0) return; BStringItem* item = (BStringItem*)fListView->ItemAt(selection); if (item == NULL) return; char buffer[512]; snprintf(buffer, 512, "# Midi Settings\n soundfont = %s\n", item->Text()); BPath path; if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK) { path.Append(SETTINGS_FILE); BFile file(path.Path(), B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE); if (file.InitCheck() == B_OK) file.Write(buffer, strlen(buffer)); } }
void FreqWindow::MessageReceived(BMessage* msg){ int32 i; BStringItem *item = NULL; switch(msg->what){ case QUIT: Pool.frequency = m_old; Quit(); break; case SET: // set the freq Pool.InitBufferPlayer( Pool.frequency ); Quit(); break; case SELECT: i = list->CurrentSelection(); if(i < 0) break; // nothing selected item = (BStringItem*)list->ItemAt(i); Pool.frequency = atof( item->Text() ); text->SetValue(Pool.frequency); SetList(); list->Invalidate(); break; case SET_TEXT: Pool.frequency = text->Value(); SetList(); list->Invalidate(); break; default: BWindow::MessageReceived(msg); } }
void CPathsBox::ChangeClicked() { if (fList->CurrentSelection() < 0) return; if (fPanel) delete fPanel; BStringItem *item = static_cast<BStringItem*> (fList->ItemAt(fList->CurrentSelection())); entry_ref ref; get_ref_for_path(item->Text(), &ref); // may fail BMessage *msg = new BMessage(msg_ChangePath); msg->AddPointer("item", item); fPanel = new BFilePanel(B_OPEN_PANEL, new BMessenger(this), &ref, B_DIRECTORY_NODE, false, msg); FailNil(fPanel); fPanel->Window()->SetTitle("Change Directory"); fPanel->Show(); } /* CPathsBox::ChangeClicked */
void BreakConditionConfigWindow::MessageReceived(BMessage* message) { switch (message->what) { case MSG_STOP_ON_THROWN_EXCEPTION_CHANGED: { _UpdateThrownBreakpoints(fExceptionThrown->Value() == B_CONTROL_ON); break; } case MSG_STOP_ON_CAUGHT_EXCEPTION_CHANGED: { break; } case MSG_SET_STOP_FOR_ALL_IMAGES: { fListener->SetStopOnImageLoadRequested( fStopOnImageLoad->Value() == B_CONTROL_ON, false); break; } case MSG_SET_STOP_FOR_CUSTOM_IMAGES: { fListener->SetStopOnImageLoadRequested( fStopOnImageLoad->Value() == B_CONTROL_ON, true); break; } case MSG_IMAGE_NAME_SELECTION_CHANGED: { if (!fUseCustomImages) break; fRemoveImageNameButton->SetEnabled( fStopImageNames->CurrentSelection() >= 0); break; } case MSG_IMAGE_NAME_INPUT_CHANGED: { BString imageName(fStopImageNameInput->Text()); imageName.Trim(); fAddImageNameButton->SetEnabled(!imageName.IsEmpty()); break; } case MSG_STOP_ON_IMAGE_LOAD: { fListener->SetStopOnImageLoadRequested( fStopOnImageLoad->Value() == B_CONTROL_ON, fUseCustomImages); break; } case MSG_STOP_IMAGE_SETTINGS_CHANGED: { _UpdateStopImageState(); break; } case MSG_ADD_IMAGE_NAME: { BString imageName(fStopImageNameInput->Text()); imageName.Trim(); AutoLocker< ::Team> teamLocker(fTeam); if (fTeam->StopImageNames().HasString(imageName)) break; fStopImageNameInput->SetText(""); fListener->AddStopImageNameRequested(imageName.String()); break; } case MSG_STOP_IMAGE_NAME_ADDED: { const char* imageName; if (message->FindString("name", &imageName) != B_OK) break; BStringItem* item = new(std::nothrow) BStringItem(imageName); if (item == NULL) break; ObjectDeleter<BStringItem> itemDeleter(item); if (!fStopImageNames->AddItem(item)) { break; } itemDeleter.Detach(); fStopImageNames->SortItems(SortStringItems); break; } case MSG_REMOVE_IMAGE_NAME: { BStringItem* item; int32 selectedIndex; AutoLocker< ::Team> teamLocker(fTeam); int32 i = 0; while ((selectedIndex = fStopImageNames->CurrentSelection(i++)) >= 0) { item = (BStringItem*)fStopImageNames->ItemAt(selectedIndex); fListener->RemoveStopImageNameRequested(item->Text()); } break; } case MSG_STOP_IMAGE_NAME_REMOVED: { const char* imageName; if (message->FindString("name", &imageName) != B_OK) break; for (int32 i = 0; i < fStopImageNames->CountItems(); i++) { BStringItem* item = (BStringItem*)fStopImageNames->ItemAt(i); if (strcmp(item->Text(), imageName) == 0) { fStopImageNames->RemoveItem(i); delete item; } } break; } default: BWindow::MessageReceived(message); break; } }
void TextToolView::MessageReceived(BMessage *message) { char string1[255]; font_family family; font_style style; int32 num_styles,i; uint32 flags; BStringItem *selected; switch(message->what) { case SHEAR_CHANGED: fontview->currentfont.SetShear((float)shearslider->Value()); sprintf(string1,"Shear: %ld",shearslider->Value()); shearslider->SetLabel(string1); fontview->SetFont(&(fontview->currentfont), B_FONT_SHEAR); if(!(shearslider->IsFocus())) shearslider->MakeFocus(); fontview->Invalidate(); break; case ROTATION_CHANGED: fontview->currentfont.SetRotation((float)rotationslider->Value()); sprintf(string1,"Rotation: %ld",rotationslider->Value()); rotationslider->SetLabel(string1); fontview->SetFont(&(fontview->currentfont), B_FONT_ROTATION); if(!(rotationslider->IsFocus())) rotationslider->MakeFocus(); fontview->Invalidate(); break; case SIZE_CHANGED: fontview->currentfont.SetSize((float)sizeslider->Value()); sprintf(string1,"Size: %ld",sizeslider->Value()); sizeslider->SetLabel(string1); fontview->SetFont(&(fontview->currentfont), B_FONT_SIZE); if(!(sizeslider->IsFocus())) sizeslider->MakeFocus(); fontview->Invalidate(); break; case TEXT_CHANGED: sprintf(fontview->text,textedit->Text()); fontview->Invalidate(); break; case FONT_FAMILY_CHANGED: //Delete all styles for the old family stylelist->RemoveItems(0,stylelist->CountItems()); // Determine current family selected=(BStringItem *)fontlist->ItemAt(fontlist->CurrentSelection()); // We can afford to do this only because user can't edit // the font names sprintf((char *)&family,selected->Text()); //Repopulate with all styles for new family num_styles = count_font_styles(family); for (i=0; i < num_styles; i++ ) { if ( get_font_style(family, i, &style, &flags) == B_OK ) stylelist->AddItem(new BStringItem((char *)&style)); } stylelist->Select(0); // break; case FONT_STYLE_CHANGED: // Determine current family selected=(BStringItem *)fontlist->ItemAt(fontlist->CurrentSelection()); sprintf((char *)&family,selected->Text()); // Determine current style selected=(BStringItem *)stylelist->ItemAt(stylelist->CurrentSelection()); sprintf((char *)&style,selected->Text()); // Set text to new font fontview->currentfont.SetFamilyAndStyle(family,style); fontview->SetFont(&(fontview->currentfont)); fontview->Invalidate(); break; case ANTIALIAS_TEXT: if(aacheckbox->Value()==B_CONTROL_ON) fontview->currentfont.SetFlags(B_FORCE_ANTIALIASING); else fontview->currentfont.SetFlags(B_DISABLE_ANTIALIASING); fontview->SetFont(&(fontview->currentfont)); fontview->Invalidate(); break; default: BView::MessageReceived(message); } }
ProjectSettingsWindow::ProjectSettingsWindow(BRect frame, Project *proj) : DWindow(frame,TR("Project Settings"),B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_H_RESIZABLE), fProject(proj), fDirty(false) { if (!fProject) debugger("Bad project given to Project Settings window"); fRefFilter = new TypedRefFilter(NULL,B_DIRECTORY_NODE); BMessenger msgr(this); entry_ref projfolder_ref; BEntry(fProject->GetPath().GetFolder()).GetRef(&projfolder_ref); fFilePanel = new BFilePanel(B_OPEN_PANEL,&msgr,&projfolder_ref,B_DIRECTORY_NODE, true, new BMessage(M_ADD_PATH),fRefFilter); fAutolock = new BAutolock(fProject); AddCommonFilter(new EscapeCancelFilter()); BView *top = GetBackgroundView(); BRect r(Bounds()); fTabView = new BTabView(r,"tabview"); top->AddChild(fTabView); r.InsetBy(5,5); r.bottom -= fTabView->TabHeight(); BRect bounds = r.OffsetToCopy(0,0); fGeneralView = new BView(r,TR("General"),B_FOLLOW_ALL,B_WILL_DRAW); fGeneralView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); fTabView->AddTab(fGeneralView); r.right -= 10.0; fTargetText = new AutoTextControl(r,"targetname",TR("Target Name:"), fProject->GetTargetName(), new BMessage(M_TARGET_NAME_CHANGED), B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP); fGeneralView->AddChild(fTargetText); float pwidth, pheight; fTargetText->GetPreferredSize(&pwidth, &pheight); fTargetText->ResizeTo(r.Width(),pheight); r.bottom = r.top + pheight; fTargetText->SetDivider(fTargetText->StringWidth(TR("Target Name:")) + 5.0); r = fTargetText->Frame(); r.OffsetBy(0,r.Height() + 10.0); BMenu *menu = new BMenu(TR("Target Type")); menu->AddItem(new BMenuItem(TR("Application"),new BMessage(M_SET_TARGET_TYPE))); menu->AddItem(new BMenuItem(TR("Shared Library"),new BMessage(M_SET_TARGET_TYPE))); menu->AddItem(new BMenuItem(TR("Static Library"),new BMessage(M_SET_TARGET_TYPE))); menu->AddItem(new BMenuItem(TR("Device Driver"),new BMessage(M_SET_TARGET_TYPE))); r.right = (bounds.right - 5.0) / 2.0; r.bottom = r.top + 25; fTypeField = new BMenuField(r,"type",TR("Target Type:"),menu); fGeneralView->AddChild(fTypeField); fTypeField->SetDivider(fTypeField->StringWidth(TR("Target Type:")) + 5.0); SetToolTip(fTypeField,TR("The kind of program you want to build")); menu->SetTargetForItems(this); menu->SetLabelFromMarked(true); BMenuItem *item = menu->ItemAt(fProject->TargetType()); if (item) item->SetMarked(true); r.OffsetBy(0,r.Height() + 10.0); BStringView *label = new BStringView(r,"label",TR("Include Paths:")); label->ResizeToPreferred(); fGeneralView->AddChild(label); r = label->Frame(); r.OffsetBy(0,r.Height() + 5.0); // We create a button now so that the list expands to fill the entire window // while leaving space for the two buttons at the bottom. Note that we do not // actually add the button to the window until later to preserve proper // keyboard navigation order BButton *add = new BButton(BRect(0,0,1,1),"addbutton",TR("Add…"), new BMessage(M_SHOW_ADD_PATH), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM); add->ResizeToPreferred(); add->MoveTo(5,fGeneralView->Bounds().bottom - 10.0 - add->Frame().Height()); r.right = bounds.right - 10.0 - B_V_SCROLL_BAR_WIDTH; r.bottom = add->Frame().top - 10.0 - B_H_SCROLL_BAR_HEIGHT; fIncludeList = new IncludeList(r,fProject->GetPath().GetFolder()); BScrollView *scrollView = new BScrollView("scrollview",fIncludeList, B_FOLLOW_ALL,0, true, true); scrollView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); fGeneralView->AddChild(scrollView); float width = 0.0; for (int32 i = 0; i < fProject->CountLocalIncludes(); i++) { BStringItem *item = new BStringItem(fProject->LocalIncludeAt(i).Relative().String()); float strwidth = fIncludeList->StringWidth(item->Text()); width = MAX(width, strwidth); fIncludeList->AddItem(item); } if (width > fIncludeList->Bounds().Width()) { BScrollBar *hbar = scrollView->ScrollBar(B_HORIZONTAL); hbar->SetRange(0.0, width - fIncludeList->Bounds().Width()); } SetToolTip(fIncludeList,TR("The folders you want Paladin to search for header files")); fGeneralView->AddChild(add); BButton *remove = new BButton(BRect(0,0,1,1),"removebutton",TR("Remove"), new BMessage(M_REMOVE_PATH), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM); remove->ResizeToPreferred(); remove->MoveTo(add->Frame().right + 10.0, add->Frame().top); fGeneralView->AddChild(remove); r = bounds; fBuildView = new BView(bounds.OffsetByCopy(5,5),TR("Build"),B_FOLLOW_ALL,B_WILL_DRAW); fBuildView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); fTabView->AddTab(fBuildView); menu = new BMenu(TR("Optimization")); menu->AddItem(new BMenuItem(TR("None"),new BMessage(M_SET_OP_VALUE))); menu->AddItem(new BMenuItem(TR("Some"),new BMessage(M_SET_OP_VALUE))); menu->AddItem(new BMenuItem(TR("More"),new BMessage(M_SET_OP_VALUE))); menu->AddItem(new BMenuItem(TR("Full"),new BMessage(M_SET_OP_VALUE))); r.right = (bounds.right - 5.0) / 2.0; r.bottom = r.top + 25; fOpField = new BMenuField(r,"optimize",TR("Optimize"),menu); fBuildView->AddChild(fOpField); fOpField->SetDivider(fOpField->StringWidth(TR("Optimize")) + 5.0); SetToolTip(fOpField,TR("Compiler optimization level. Disabled when debugging info is checked.")); menu->SetTargetForItems(this); menu->SetLabelFromMarked(true); item = menu->ItemAt(fProject->OpLevel()); if (item) item->SetMarked(true); r.right = bounds.right - 10.0; r.OffsetTo(5, fOpField->Frame().bottom + 5); fOpSizeBox = new BCheckBox(r,"opsizebox",TR("Optimize for size over speed"), new BMessage(M_TOGGLE_OPSIZE)); fOpSizeBox->ResizeToPreferred(); fBuildView->AddChild(fOpSizeBox); r = fOpSizeBox->Frame(); if (fProject->OpForSize()) fOpSizeBox->SetValue(B_CONTROL_ON); if (fProject->Debug()) { fOpField->SetEnabled(false); fOpSizeBox->SetEnabled(false); } r.OffsetBy(0, r.Height() + 10); fDebugBox = new BCheckBox(r,"debugbox",TR("Build debugging information"), new BMessage(M_TOGGLE_DEBUG)); fDebugBox->ResizeToPreferred(); if (fProject->Debug()) fDebugBox->SetValue(B_CONTROL_ON); fBuildView->AddChild(fDebugBox); SetToolTip(fDebugBox,TR("Check this if you want to use your program in a debugger during development." "You'll want to rebuild your project after change this.")); r.OffsetBy(0, r.Height()); fProfileBox = new BCheckBox(r,"profilebox",TR("Build profiling information"), new BMessage(M_TOGGLE_PROFILE)); fProfileBox->ResizeToPreferred(); if (fProject->Profiling()) fProfileBox->SetValue(B_CONTROL_ON); fBuildView->AddChild(fProfileBox); SetToolTip(fProfileBox,TR("Check this if you want to use your program " "with gprof or bprof for profiling.")); r.OffsetBy(0, r.Height() + 10.0); r.right = bounds.right - 10.0; fCompileText = new AutoTextControl(r,"extracc","Extra Compiler Options:", fProject->ExtraCompilerOptions(), new BMessage(M_CCOPTS_CHANGED), B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP); fBuildView->AddChild(fCompileText); fCompileText->SetDivider(fCompileText->StringWidth(fCompileText->Label()) + 5.0); SetToolTip(fCompileText,TR("Extra GCC flags you wish included when each file is compiled.")); r = fCompileText->Frame(); r.OffsetBy(0,r.Height() + 10); fLinkText = new AutoTextControl(r,"extrald",TR("Extra Linker Options:"), fProject->ExtraLinkerOptions(), new BMessage(M_LDOPTS_CHANGED), B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP); fBuildView->AddChild(fLinkText); fLinkText->SetDivider(fCompileText->Divider()); SetToolTip(fLinkText,TR("Extra GCC linker flags you wish included when your project is linked.")); fTabView->Select(0L); fBuildView->ResizeTo(fGeneralView->Bounds().Width(),fGeneralView->Bounds().Height()); fTargetText->MakeFocus(true); }
void FileTypesWindow::MessageReceived(BMessage* message) { switch (message->what) { case B_SIMPLE_DATA: type_code type; if (message->GetInfo("refs", &type) == B_OK && type == B_REF_TYPE) { be_app->PostMessage(message); } break; case kMsgToggleIcons: { BMenuItem* item; if (message->FindPointer("source", (void **)&item) != B_OK) break; item->SetMarked(!fTypeListView->IsShowingIcons()); fTypeListView->ShowIcons(item->IsMarked()); // update settings BMessage update(kMsgSettingsChanged); update.AddBool("show_icons", item->IsMarked()); be_app_messenger.SendMessage(&update); break; } case kMsgToggleRule: { BMenuItem* item; if (message->FindPointer("source", (void **)&item) != B_OK) break; item->SetMarked(fRuleControl->IsHidden()); _ShowSnifferRule(item->IsMarked()); // update settings BMessage update(kMsgSettingsChanged); update.AddBool("show_rule", item->IsMarked()); be_app_messenger.SendMessage(&update); break; } case kMsgTypeSelected: { int32 index; if (message->FindInt32("index", &index) == B_OK) { MimeTypeItem* item = (MimeTypeItem*)fTypeListView->ItemAt(index); if (item != NULL) { BMimeType type(item->Type()); _SetType(&type); } else _SetType(NULL); } break; } case kMsgAddType: { if (fNewTypeWindow == NULL) { fNewTypeWindow = new NewFileTypeWindow(this, fCurrentType.Type()); fNewTypeWindow->Show(); } else fNewTypeWindow->Activate(); break; } case kMsgNewTypeWindowClosed: fNewTypeWindow = NULL; break; case kMsgRemoveType: { if (fCurrentType.Type() == NULL) break; BAlert* alert; if (fCurrentType.IsSupertypeOnly()) { alert = new BPrivate::OverrideAlert("FileTypes Request", "Removing a super type cannot be reverted.\n" "All file types that belong to this super type " "will be lost!\n\n" "Are you sure you want to do this? To remove the whole " "group, hold down the Shift key and press \"Remove\".", "Remove", B_SHIFT_KEY, "Cancel", 0, NULL, 0, B_WIDTH_AS_USUAL, B_STOP_ALERT); } else { alert = new BAlert("FileTypes Request", "Removing a file type cannot be reverted.\n" "Are you sure you want to remove it?", "Remove", "Cancel", NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT); } if (alert->Go()) break; status_t status = fCurrentType.Delete(); if (status != B_OK) fprintf(stderr, "Could not remove file type: %s\n", strerror(status)); break; } case kMsgSelectNewType: { const char* type; if (message->FindString("type", &type) == B_OK) fTypeListView->SelectNewType(type); break; } // File Recognition group case kMsgExtensionSelected: { int32 index; if (message->FindInt32("index", &index) == B_OK) { BStringItem* item = (BStringItem*)fExtensionListView->ItemAt(index); fRemoveExtensionButton->SetEnabled(item != NULL); } break; } case kMsgExtensionInvoked: { if (fCurrentType.Type() == NULL) break; int32 index; if (message->FindInt32("index", &index) == B_OK) { BStringItem* item = (BStringItem*)fExtensionListView->ItemAt(index); if (item == NULL) break; BWindow* window = new ExtensionWindow(this, fCurrentType, item->Text()); window->Show(); } break; } case kMsgAddExtension: { if (fCurrentType.Type() == NULL) break; BWindow* window = new ExtensionWindow(this, fCurrentType, NULL); window->Show(); break; } case kMsgRemoveExtension: { int32 index = fExtensionListView->CurrentSelection(); if (index < 0 || fCurrentType.Type() == NULL) break; BMessage extensions; if (fCurrentType.GetFileExtensions(&extensions) == B_OK) { extensions.RemoveData("extensions", index); fCurrentType.SetFileExtensions(&extensions); } break; } case kMsgRuleEntered: { // check rule BString parseError; if (BMimeType::CheckSnifferRule(fRuleControl->Text(), &parseError) != B_OK) { parseError.Prepend("Recognition rule is not valid:\n\n"); error_alert(parseError.String()); } else fCurrentType.SetSnifferRule(fRuleControl->Text()); break; } // Description group case kMsgTypeEntered: { fCurrentType.SetShortDescription(fTypeNameControl->Text()); break; } case kMsgDescriptionEntered: { fCurrentType.SetLongDescription(fDescriptionControl->Text()); break; } // Preferred Application group case kMsgPreferredAppChosen: { const char* signature; if (message->FindString("signature", &signature) != B_OK) signature = NULL; fCurrentType.SetPreferredApp(signature); break; } case kMsgSelectPreferredApp: { BMessage panel(kMsgOpenFilePanel); panel.AddString("title", "Select preferred application"); panel.AddInt32("message", kMsgPreferredAppOpened); panel.AddMessenger("target", this); be_app_messenger.SendMessage(&panel); break; } case kMsgPreferredAppOpened: _AdoptPreferredApplication(message, false); break; case kMsgSamePreferredAppAs: { BMessage panel(kMsgOpenFilePanel); panel.AddString("title", "Select same preferred application as"); panel.AddInt32("message", kMsgSamePreferredAppAsOpened); panel.AddMessenger("target", this); be_app_messenger.SendMessage(&panel); break; } case kMsgSamePreferredAppAsOpened: _AdoptPreferredApplication(message, true); break; // Extra Attributes group case kMsgAttributeSelected: { int32 index; if (message->FindInt32("index", &index) == B_OK) { AttributeItem* item = (AttributeItem*)fAttributeListView->ItemAt(index); fRemoveAttributeButton->SetEnabled(item != NULL); } break; } case kMsgAttributeInvoked: { if (fCurrentType.Type() == NULL) break; int32 index; if (message->FindInt32("index", &index) == B_OK) { AttributeItem* item = (AttributeItem*)fAttributeListView->ItemAt(index); if (item == NULL) break; BWindow* window = new AttributeWindow(this, fCurrentType, item); window->Show(); } break; } case kMsgAddAttribute: { if (fCurrentType.Type() == NULL) break; BWindow* window = new AttributeWindow(this, fCurrentType, NULL); window->Show(); break; } case kMsgRemoveAttribute: { int32 index = fAttributeListView->CurrentSelection(); if (index < 0 || fCurrentType.Type() == NULL) break; BMessage attributes; if (fCurrentType.GetAttrInfo(&attributes) == B_OK) { const char* kAttributeNames[] = { "attr:public_name", "attr:name", "attr:type", "attr:editable", "attr:viewable", "attr:extra", "attr:alignment", "attr:width", "attr:display_as" }; for (uint32 i = 0; i < sizeof(kAttributeNames) / sizeof(kAttributeNames[0]); i++) { attributes.RemoveData(kAttributeNames[i], index); } fCurrentType.SetAttrInfo(&attributes); } break; } case B_META_MIME_CHANGED: { const char* type; int32 which; if (message->FindString("be:type", &type) != B_OK || message->FindInt32("be:which", &which) != B_OK) break; if (fCurrentType.Type() == NULL) break; if (!strcasecmp(fCurrentType.Type(), type)) { if (which != B_MIME_TYPE_DELETED) _SetType(&fCurrentType, which); else _SetType(NULL); } else { // this change could still affect our current type if (which == B_MIME_TYPE_DELETED #ifdef __ANTARES__ || which == B_SUPPORTED_TYPES_CHANGED #endif || which == B_PREFERRED_APP_CHANGED) _UpdatePreferredApps(&fCurrentType); } break; } default: BWindow::MessageReceived(message); } }
void ProjectSettingsWindow::MessageReceived(BMessage* message) { switch (message->what) { case M_SHOW_ADD_PATH: { fFilePanel->Show(); break; } case M_DROP_PATH: { BString path; if (message->FindString("path",&path) == B_OK) fProject->AddLocalInclude(path.String()); break; } case M_ADD_PATH: { entry_ref ref; int32 i = 0; while (message->FindRef("refs", i++, &ref) == B_OK) { fDirty = true; AddInclude(ref); } break; } case M_REMOVE_PATH: { int32 selection = fIncludeList->CurrentSelection(); if (selection < 0) break; fDirty = true; for (int32 i = fIncludeList->CountItems() - 1; i >= 0; i--) { BStringItem* item = (BStringItem*)fIncludeList->ItemAt(i); if (item->IsSelected()) { fIncludeList->RemoveItem(item); fProject->RemoveLocalInclude(item->Text()); delete item; } } break; } case M_TARGET_NAME_CHANGED: { if (fTargetText->Text() && strlen(fTargetText->Text()) > 0) fProject->SetTargetName(fTargetText->Text()); fDirty = true; } case M_TOGGLE_DEBUG: { if (fDebugBox->Value() == B_CONTROL_ON) { fProject->SetDebug(true); fOpField->SetEnabled(false); fOpSizeBox->SetEnabled(false); } else { fProject->SetDebug(false); fOpField->SetEnabled(true); fOpSizeBox->SetEnabled(true); } fDirty = true; break; } case M_TOGGLE_PROFILE: { if (fProfileBox->Value() == B_CONTROL_ON) fProject->SetProfiling(true); else fProject->SetProfiling(false); fDirty = true; break; } case M_TOGGLE_OPSIZE: { if (fOpSizeBox->Value() == B_CONTROL_ON) fProject->SetOpForSize(true); else fProject->SetOpForSize(false); fDirty = true; break; } case M_SET_OP_VALUE: { BMenuItem *item = fOpField->Menu()->FindMarked(); if (item) fProject->SetOpLevel(fOpField->Menu()->IndexOf(item)); fDirty = true; break; } case M_SET_TARGET_TYPE: { BMenuItem *item = fTypeField->Menu()->FindMarked(); if (item) fProject->SetTargetType(fTypeField->Menu()->IndexOf(item)); fDirty = true; break; } case M_CCOPTS_CHANGED: { fProject->SetExtraCompilerOptions(fCompileText->Text()); fDirty = true; break; } case M_LDOPTS_CHANGED: { fProject->SetExtraLinkerOptions(fLinkText->Text()); fDirty = true; break; } default: BWindow::MessageReceived(message); } }
void GrepWindow::_OnSelectInTracker() { if (fSearchResults->CurrentSelection() < 0) { BAlert* alert = new BAlert("Info", B_TRANSLATE("Please select the files you wish to have selected for you in " "Tracker."), B_TRANSLATE("OK"), NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->Go(NULL); return; } BMessage message; BString filePath; BPath folderPath; BList folderList; BString lastFolderAddedToList; for (int32 index = 0; ; index++) { BStringItem* item = dynamic_cast<BStringItem*>( fSearchResults->ItemAt(index)); if (item == NULL) break; // only open selected and top level (file) items if (!item->IsSelected() || item->OutlineLevel() > 0) continue; // check if this was previously opened if (filePath == item->Text()) continue; filePath = item->Text(); entry_ref file_ref; if (get_ref_for_path(filePath.String(), &file_ref) != B_OK) continue; message.AddRef("refs", &file_ref); // add parent folder to list of folders to open folderPath.SetTo(filePath.String()); if (folderPath.GetParent(&folderPath) == B_OK) { BPath* path = new BPath(folderPath); if (path->Path() != lastFolderAddedToList) { // catches some duplicates folderList.AddItem(path); lastFolderAddedToList = path->Path(); } else delete path; } } _RemoveFolderListDuplicates(&folderList); _OpenFoldersInTracker(&folderList); int32 aShortWhile = 100000; snooze(aShortWhile); if (!_AreAllFoldersOpenInTracker(&folderList)) { for (int32 x = 0; x < 5; x++) { aShortWhile += 100000; snooze(aShortWhile); _OpenFoldersInTracker(&folderList); } } if (!_AreAllFoldersOpenInTracker(&folderList)) { BString str1; str1 << B_TRANSLATE("%APP_NAME couldn't open one or more folders."); str1.ReplaceFirst("%APP_NAME",APP_NAME); BAlert* alert = new BAlert(NULL, str1.String(), B_TRANSLATE("OK"), NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->Go(NULL); goto out; } _SelectFilesInTracker(&folderList, &message); out: // delete folderList contents int32 folderCount = folderList.CountItems(); for (int32 x = 0; x < folderCount; x++) delete static_cast<BPath*>(folderList.ItemAt(x)); }
void NetworkPrefsView::MessageReceived (BMessage * msg) { switch (msg->what) { case M_NETWORK_DEFAULTS: if (fActiveNetwork.HasString ("name")) vision_app->SetNetwork (fActiveNetwork.FindString ("name"), &fActiveNetwork); fActiveNetwork = vision_app->GetNetwork ("defaults"); fNetworkMenu->MenuItem ()->SetLabel ("Defaults"); SetupDefaults (fActiveNetwork); fDupeItem->SetEnabled (false); fRemoveItem->SetEnabled (false); break; case M_CHOOSE_NETWORK: { BMenuItem *item (NULL); msg->FindPointer ("source", reinterpret_cast < void **>(&item)); SaveCurrentNetwork (); fActiveNetwork = vision_app->GetNetwork (item->Label ()); fNetworkMenu->MenuItem ()->SetLabel (item->Label ()); UpdatePersonalData (fActiveNetwork); UpdateNetworkData (fActiveNetwork); if (BMessenger (fServerPrefs).IsValid ()) fServerPrefs->SetNetworkData (&fActiveNetwork); fDupeItem->SetEnabled (true); fRemoveItem->SetEnabled (true); } break; case M_ADD_NEW_NETWORK: { if (msg->HasString ("text")) { fNetPrompt = NULL; BString network (msg->FindString ("text")); network.RemoveAll (" "); BMenu *menu (fNetworkMenu->Menu ()); for (int32 i = 0; i < menu->CountItems (); i++) { BMenuItem *item (menu->ItemAt (i)); if (item && network == item->Label ()) { dynamic_cast < BInvoker * >(item)->Invoke (); return; } } BMessage newNet (VIS_NETWORK_DATA); newNet.AddString ("name", network.String ()); vision_app->SetNetwork (network.String (), &newNet); BMenuItem *item (new BMenuItem (network.String (), new BMessage (M_CHOOSE_NETWORK))); menu->AddItem (item, 0); item->SetTarget (this); dynamic_cast < BInvoker * >(item)->Invoke (); } else { BString promptText = B_TRANSLATE("Network Name"); promptText += ": "; fNetPrompt = new PromptWindow (BPoint (Window ()->Frame ().left + Window ()->Frame ().Width () / 2, Window ()->Frame ().top + Window ()->Frame ().Height () / 2), promptText.String(), B_TRANSLATE("Add Network"), NULL, this, new BMessage (M_ADD_NEW_NETWORK), NULL, false); fNetPrompt->Show (); } } break; case M_REMOVE_CURRENT_NETWORK: { const char *name (fActiveNetwork.FindString ("name")); vision_app->RemoveNetwork (name); BMenu *menu (fNetworkMenu->Menu ()); for (int32 i = 0; i < menu->CountItems (); i++) { BMenuItem *item (menu->ItemAt (i)); if (!strcmp (item->Label (), name)) { delete menu->RemoveItem (i); fActiveNetwork.MakeEmpty (); dynamic_cast < BInvoker * >(menu->ItemAt (0))->Invoke (); break; } } } break; case M_DUPE_CURRENT_NETWORK: { if (msg->HasString ("text")) { fDupePrompt = NULL; BString network (msg->FindString ("text")); network.RemoveAll (" "); BMenu *menu (fNetworkMenu->Menu ()); for (int32 i = 0; i < menu->CountItems (); i++) { BMenuItem *item (menu->ItemAt (i)); if (item && network == item->Label ()) { dynamic_cast < BInvoker * >(item)->Invoke (); return; } } BMessage newNet = fActiveNetwork; newNet.ReplaceString ("name", network.String ()); vision_app->SetNetwork (network.String (), &newNet); BMenuItem *item (new BMenuItem (network.String (), new BMessage (M_CHOOSE_NETWORK))); menu->AddItem (item, 0); item->SetTarget (this); dynamic_cast < BInvoker * >(item)->Invoke (); } else { BString promptText = B_TRANSLATE("Network Name"); promptText += ": "; fDupePrompt = new PromptWindow (BPoint (Window ()->Frame ().left + Window ()->Frame ().Width () / 2, Window ()->Frame ().top + Window ()->Frame ().Height () / 2), promptText.String(), B_TRANSLATE("Duplicate Current Network"), NULL, this, new BMessage (M_DUPE_CURRENT_NETWORK), NULL, false); fDupePrompt->Show (); } } break; case M_SERVER_DATA_CHANGED: { UpdateNetworkData (fActiveNetwork); } break; case M_SERVER_DIALOG: { BMessenger msgr (fServerPrefs); if (msgr.IsValid ()) fServerPrefs->Activate (); else { fServerPrefs = new NetPrefServerWindow (this); fServerPrefs->SetNetworkData (&fActiveNetwork); fServerPrefs->Show (); } } break; case M_NET_CHECK_LAG: { bool value = msg->FindInt32 ("be:value"); if (fActiveNetwork.HasBool ("lagCheck")) fActiveNetwork.ReplaceBool ("lagCheck", value); else fActiveNetwork.AddBool ("lagCheck", value); } break; case M_CONNECT_ON_STARTUP: { bool value = msg->FindInt32 ("be:value"); if (fActiveNetwork.HasBool ("connectOnStartup")) fActiveNetwork.ReplaceBool ("connectOnStartup", value); else fActiveNetwork.AddBool ("connectOnStartup", value); } break; case M_USE_NICK_DEFAULTS: { bool value = msg->FindInt32 ("be:value"); if (fActiveNetwork.HasBool ("useDefaults")) fActiveNetwork.ReplaceBool ("useDefaults", value); else fActiveNetwork.AddBool ("useDefaults", value); UpdatePersonalData (fActiveNetwork); } break; case M_NETPREFS_TEXT_INVOKE: { if (fActiveNetwork.HasString("autoexec")) fActiveNetwork.ReplaceString("autoexec", fTextView->Text()); else fActiveNetwork.AddString("autoexec", fTextView->Text()); } break; case M_ADD_NICK: if (msg->HasString ("text")) { fNickPrompt = NULL; BString nick (msg->FindString ("text")); nick.RemoveAll (" "); for (int32 i = 0; i < fListView->CountItems (); i++) { BStringItem *item ((BStringItem *) fListView->ItemAt (i)); if (item && nick == item->Text ()) return; } fActiveNetwork.AddString ("nick", nick.String ()); fListView->AddItem (new BStringItem (nick.String ())); } else { BString promptString = B_TRANSLATE("Nickname"); promptString += ": "; fNickPrompt = new PromptWindow (BPoint (Window ()->Frame ().left + Window ()->Frame ().Width () / 2, Window ()->Frame ().top + Window ()->Frame ().Height () / 2), promptString.String(), B_TRANSLATE("Add Nickname"), NULL, this, new BMessage (M_ADD_NICK), NULL, false); fNickPrompt->Show (); } break; case M_REMOVE_NICK: { int32 current (fListView->CurrentSelection ()); if (current >= 0) { delete fListView->RemoveItem (current); fActiveNetwork.RemoveData ("nick", current); } } break; case M_NICK_UP: { int32 current (fListView->CurrentSelection ()); BString nick1, nick2; nick1 = fActiveNetwork.FindString ("nick", current); nick2 = fActiveNetwork.FindString ("nick", current - 1); fListView->SwapItems (current, current - 1); fActiveNetwork.ReplaceString ("nick", current - 1, nick1.String ()); fActiveNetwork.ReplaceString ("nick", current, nick2.String ()); current = fListView->CurrentSelection (); Window ()->DisableUpdates (); fListView->DeselectAll (); fListView->Select (current); Window ()->EnableUpdates (); } break; case M_NICK_DOWN: { int32 current (fListView->CurrentSelection ()); BString nick1, nick2; nick1 = fActiveNetwork.FindString ("nick", current); nick2 = fActiveNetwork.FindString ("nick", current + 1); fListView->SwapItems (current, current + 1); fActiveNetwork.ReplaceString ("nick", current + 1, nick1.String ()); fActiveNetwork.ReplaceString ("nick", current, nick2.String ()); current = fListView->CurrentSelection (); Window ()->DisableUpdates (); fListView->DeselectAll (); fListView->Select (current); Window ()->EnableUpdates (); } break; case M_NICK_SELECTED: { int32 index (msg->FindInt32 ("index")); if (index >= 0 && !fNickDefaultsBox->Value ()) { fNickUpButton->SetEnabled (index > 0); fNickDnButton->SetEnabled (index != (fListView->CountItems () - 1)); fNickRemoveButton->SetEnabled (true); } else { fNickUpButton->SetEnabled (false); fNickDnButton->SetEnabled (false); fNickRemoveButton->SetEnabled (false); } } break; default: BView::MessageReceived (msg); break; } }