void DataTranslationsWindow::_SetupViews() { fInfoText = NULL; fConfigView = NULL; // This is NULL until a translator is // selected from the listview // Add the translators list view fTranslatorListView = new TranslatorListView("TransList"); fTranslatorListView->SetSelectionMessage( new BMessage(kMsgSelectedTranslator)); BScrollView* scrollView = new BScrollView("scroll_trans", fTranslatorListView, B_WILL_DRAW | B_FRAME_EVENTS, false, true, B_FANCY_BORDER); // Box around the config and info panels fRightBox = new BBox("Right_Side"); fRightBox->SetExplicitAlignment(BAlignment(B_ALIGN_USE_FULL_WIDTH, B_ALIGN_USE_FULL_HEIGHT)); // Add the translator icon view fIconView = new IconView(); // Add the translator info button fButton = new BButton("info", B_TRANSLATE("Info"), new BMessage(kMsgTranslatorInfo), B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE); fButton->SetEnabled(false); // Populate the translators list view _PopulateListView(); // Build the layout BLayoutBuilder::Group<>(this, B_HORIZONTAL) .SetInsets(B_USE_WINDOW_SPACING) .Add(scrollView, 3) .AddGroup(B_VERTICAL) .Add(fRightBox) .AddGroup(B_HORIZONTAL) .Add(fIconView) .AddGlue() .Add(fButton) .End() .End() .End(); fTranslatorListView->MakeFocus(); _ShowInfoView(); }
void DataTranslationsWindow::_SetupViews() { fConfigView = NULL; // This is NULL until a translator is // selected from the listview // Add the translators list view fTranslatorListView = new TranslatorListView("TransList"); fTranslatorListView->SetSelectionMessage( new BMessage(kMsgSelectedTranslator)); BScrollView* scrollView = new BScrollView("scroll_trans", fTranslatorListView, B_WILL_DRAW | B_FRAME_EVENTS, false, true, B_FANCY_BORDER); // Box around the config and info panels fRightBox = new BBox("Right_Side"); fRightBox->SetExplicitAlignment(BAlignment(B_ALIGN_USE_FULL_WIDTH, B_ALIGN_USE_FULL_HEIGHT)); // Add the translator icon view fIconView = new IconView(); // Add the translator info button fButton = new BButton("info", B_TRANSLATE("Info"), new BMessage(kMsgTranslatorInfo), B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE); fButton->SetEnabled(false); // Populate the translators list view _PopulateListView(); // Build the layout float padding = be_control_look->DefaultItemSpacing(); BLayoutBuilder::Group<>(this, B_HORIZONTAL, padding) .SetInsets(padding, padding, padding, padding) .Add(scrollView, 3) .AddGrid(padding, padding, 6) .SetInsets(0, 0, 0, 0) .Add(fRightBox, 0, 0, 3, 1) .Add(fIconView, 0, 1) .Add(fButton, 2, 1); fTranslatorListView->MakeFocus(); _ShowInfoView(); }
void DataTranslationsWindow::MessageReceived(BMessage* message) { switch (message->what) { case kMsgTranslatorInfo: { int32 selected = fTranslatorListView->CurrentSelection(0); if (selected < 0) break; TranslatorItem* item = fTranslatorListView->TranslatorAt(selected); if (item != NULL) _ShowInfoAlert(item->ID()); break; } case kMsgSelectedTranslator: { // Update the icon and translator info panel // to match the new selection int32 selected = fTranslatorListView->CurrentSelection(0); if (selected < 0) { // If none selected, clear the old one fIconView->DrawIcon(false); fButton->SetEnabled(false); fRightBox->RemoveChild(fConfigView); _ShowInfoView(); break; } TranslatorItem* item = fTranslatorListView->TranslatorAt(selected); if (item == NULL) break; _ShowConfigView(item->ID()); const char* name = NULL; const char* info = NULL; int32 version = 0; BPath path; _GetTranslatorInfo(item->ID(), name, info, version, path); fIconView->SetIcon(path); fButton->SetEnabled(true); break; } case B_TRANSLATOR_ADDED: { int32 index = 0, id; while (message->FindInt32("translator_id", index++, &id) == B_OK) { const char* name; const char* info; int32 version; BPath path; if (_GetTranslatorInfo(id, name, info, version, path) == B_OK) fTranslatorListView->AddItem(new TranslatorItem(id, name)); } fTranslatorListView->SortItems(); break; } case B_TRANSLATOR_REMOVED: { int32 index = 0, id; while (message->FindInt32("translator_id", index++, &id) == B_OK) { for (int32 i = 0; i < fTranslatorListView->CountItems(); i++) { TranslatorItem* item = fTranslatorListView->TranslatorAt(i); if (item == NULL) continue; if (item->ID() == (translator_id)id) { fTranslatorListView->RemoveItem(i); delete item; break; } } } break; } default: BWindow::MessageReceived(message); break; } }