void CPathsBox::MessageReceived(BMessage *msg) { try { entry_ref ref; BEntry e; BPath p; if (msg->WasDropped() && msg->HasRef("refs")) { FailOSErr(msg->FindRef("refs", &ref)); FailOSErr(e.SetTo(&ref)); FailOSErr(e.GetPath(&p)); fList->AddItem(new BStringItem(p.Path())); ListBoxChanged(); } else switch (msg->what) { case msg_AddPath: case msg_ChangePath: FailOSErr(msg->FindRef("refs", &ref)); FailOSErr(e.SetTo(&ref)); FailOSErr(e.GetPath(&p)); if (msg->what == msg_AddPath) fList->AddItem(new BStringItem(p.Path())); else { BStringItem *item; FailOSErr(msg->FindPointer("item", (void**)&item)); if (fList->IndexOf(item) < 0) THROW(("item was removed from list!")); item->SetText(p.Path()); } delete fPanel; fPanel = NULL; ListBoxChanged(); break; default: CListBox::MessageReceived(msg); break; } } catch (HErr& e) { e.DoError(); } } /* CPathsBox::MessageReceived */
void CMimeBox::AddClicked() { fAdd->SetEnabled(false); fChange->SetEnabled(false); AddType(fEdit->Text()); ListBoxChanged(); } /* CMimeBox::AddClicked */
void CMimeBox::DeleteClicked() { int ix = fList->CurrentSelection(); if (ix >= 0) { CMimeItem *i = static_cast<CMimeItem*>(fList->ItemAt(ix)); fList->RemoveItem(i); delete i; ListBoxChanged(); } } /* CMimeBox::DeleteClicked */
void CMimeBox::ChangeClicked() { fAdd->SetEnabled(false); fChange->SetEnabled(false); int ix = fList->CurrentSelection(); if (ix >= 0) { CMimeItem *i = static_cast<CMimeItem*>(fList->ItemAt(ix)); i->fMime.SetTo(fEdit->Text()); fList->InvalidateItem(ix); ListBoxChanged(); } } /* CMimeBox::ChangeClicked */
void CMimeBox::AddType(const char *type) { CMimeItem *m; for (int i = 0; i < fList->CountItems(); i++) { m = static_cast<CMimeItem*>(fList->ItemAt(i)); if (strcmp(m->fMime.Type(), type) == 0) return; } m = new CMimeItem(type); fList->AddItem(m); m->SetHeight(18); fList->InvalidateItem(fList->IndexOf(m)); ListBoxChanged(); } /* CMimeBox::AddType */
void CPathsBox::DeleteClicked() { delete fList->RemoveItem(fList->CurrentSelection()); ListBoxChanged(); } /* CPathsBox::DeleteClicked */