// parser functions sBool _Doc() { while (!Scan->Errors && Scan->Token!=sTOK_END) { if (Scan->IfName(L"defaults")) _Defaults(); else if (Scan->IfName(L"keys")) _Keys(); } return !Scan->Errors; }
void LocaleWindow::MessageReceived(BMessage* message) { switch (message->what) { case kMsgDefaults: _Defaults(); break; case kMsgRevert: be_app_messenger.SendMessage(message); _UpdatePreferredFromLocaleRoster(); break; case kMsgLanguageDragged: { void* target = NULL; if (message->FindPointer("drop_target", &target) != B_OK || target != fPreferredListView) break; // Add from available languages to preferred languages int32 dropIndex; if (message->FindInt32("drop_index", &dropIndex) != B_OK) dropIndex = fPreferredListView->CountItems(); int32 index = 0; for (int32 i = 0; message->FindInt32("index", i, &index) == B_OK; i++) { LanguageListItem* item = static_cast<LanguageListItem*>( fLanguageListView->FullListItemAt(index)); _InsertPreferredLanguage(item, dropIndex++); } break; } case kMsgLanguageInvoked: { int32 index = 0; for (int32 i = 0; message->FindInt32("index", i, &index) == B_OK; i++) { LanguageListItem* item = static_cast<LanguageListItem*>( fLanguageListView->ItemAt(index)); _InsertPreferredLanguage(item); } break; } case kMsgPreferredLanguageDragged: { void* target = NULL; if (fPreferredListView->CountItems() == 1 || message->FindPointer("drop_target", &target) != B_OK) break; if (target == fPreferredListView) { // change ordering int32 dropIndex = message->FindInt32("drop_index"); int32 index = 0; if (message->FindInt32("index", &index) == B_OK && dropIndex != index) { BListItem* item = fPreferredListView->RemoveItem(index); if (dropIndex > index) index--; fPreferredListView->AddItem(item, dropIndex); _PreferredLanguagesChanged(); } break; } // supposed to fall through - remove item } case kMsgPreferredLanguageDeleted: case kMsgPreferredLanguageInvoked: { if (fPreferredListView->CountItems() == 1) break; // Remove from preferred languages int32 index = 0; if (message->FindInt32("index", &index) == B_OK) { delete fPreferredListView->RemoveItem(index); _PreferredLanguagesChanged(); if (message->what == kMsgPreferredLanguageDeleted) fPreferredListView->Select(index); } break; } case kMsgCountrySelection: { // Country selection changed. // Get the new selected country from the ListView and send it to the // main app event handler. void* listView; if (message->FindPointer("source", &listView) != B_OK) break; BListView* countryList = static_cast<BListView*>(listView); LanguageListItem* item = static_cast<LanguageListItem*> (countryList->ItemAt(countryList->CurrentSelection())); BMessage newMessage(kMsgSettingsChanged); newMessage.AddString("country", item->ID()); be_app_messenger.SendMessage(&newMessage); SettingsChanged(); BCountry* country = new BCountry(item->ID()); fFormatView->SetCountry(country); break; } default: BWindow::MessageReceived(message); break; } }