1d1360823SMatthew Wilber /*****************************************************************************/ 2d1360823SMatthew Wilber // ActiveTranslatorsWindow 3d1360823SMatthew Wilber // Written by Michael Wilber, OBOS Translation Kit Team 4d1360823SMatthew Wilber // 5d1360823SMatthew Wilber // ActiveTranslatorsWindow.cpp 6d1360823SMatthew Wilber // 7d1360823SMatthew Wilber // BWindow class for displaying information about the currently open 8d1360823SMatthew Wilber // document 9d1360823SMatthew Wilber // 10d1360823SMatthew Wilber // 11d1360823SMatthew Wilber // Copyright (c) 2003 OpenBeOS Project 12d1360823SMatthew Wilber // 13d1360823SMatthew Wilber // Permission is hereby granted, free of charge, to any person obtaining a 14d1360823SMatthew Wilber // copy of this software and associated documentation files (the "Software"), 15d1360823SMatthew Wilber // to deal in the Software without restriction, including without limitation 16d1360823SMatthew Wilber // the rights to use, copy, modify, merge, publish, distribute, sublicense, 17d1360823SMatthew Wilber // and/or sell copies of the Software, and to permit persons to whom the 18d1360823SMatthew Wilber // Software is furnished to do so, subject to the following conditions: 19d1360823SMatthew Wilber // 20d1360823SMatthew Wilber // The above copyright notice and this permission notice shall be included 21d1360823SMatthew Wilber // in all copies or substantial portions of the Software. 22d1360823SMatthew Wilber // 23d1360823SMatthew Wilber // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 24d1360823SMatthew Wilber // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25d1360823SMatthew Wilber // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 26d1360823SMatthew Wilber // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27d1360823SMatthew Wilber // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 28d1360823SMatthew Wilber // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 29d1360823SMatthew Wilber // DEALINGS IN THE SOFTWARE. 30d1360823SMatthew Wilber /*****************************************************************************/ 31d1360823SMatthew Wilber 32d1360823SMatthew Wilber #include "Constants.h" 33d1360823SMatthew Wilber #include "ActiveTranslatorsWindow.h" 34e5ef5305SMatthew Wilber #include "TranslatorItem.h" 35d1360823SMatthew Wilber #include <Application.h> 36*6e608fa5SAdrien Destugues #include <Catalog.h> 37d1360823SMatthew Wilber #include <ScrollView.h> 38*6e608fa5SAdrien Destugues #include <Locale.h> 39d1360823SMatthew Wilber #include <Message.h> 40d1360823SMatthew Wilber #include <String.h> 41d1360823SMatthew Wilber #include <stdlib.h> 42d1360823SMatthew Wilber #include <string.h> 43d1360823SMatthew Wilber #include <dirent.h> 44d1360823SMatthew Wilber #include <unistd.h> 45d1360823SMatthew Wilber #include <sys/stat.h> 46d1360823SMatthew Wilber 47*6e608fa5SAdrien Destugues #define B_TRANSLATE_CONTEXT "ActiveTranslatorsWindow" 48*6e608fa5SAdrien Destugues 49*6e608fa5SAdrien Destugues 50e5ef5305SMatthew Wilber ActiveTranslatorsWindow::ActiveTranslatorsWindow(BRect rect, const char *name, 51e5ef5305SMatthew Wilber BList *plist) 525e821a67SNiels Sascha Reedijk : BWindow(rect, name, B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE) 53d1360823SMatthew Wilber { 54d1360823SMatthew Wilber BRect rctframe = Bounds(); 55d1360823SMatthew Wilber rctframe.right -= B_V_SCROLL_BAR_WIDTH; 56d1360823SMatthew Wilber 57e5ef5305SMatthew Wilber fpListView = new BOutlineListView(rctframe, "translators_list", 58d1360823SMatthew Wilber B_MULTIPLE_SELECTION_LIST); 59d1360823SMatthew Wilber 60*6e608fa5SAdrien Destugues fpListView->AddItem(fpUserItem = new BStringItem(B_TRANSLATE("User Translators"))); 61e5ef5305SMatthew Wilber fpUserItem->SetEnabled(false); 62*6e608fa5SAdrien Destugues fpListView->AddItem(fpSystemItem = new BStringItem(B_TRANSLATE("System Translators"))); 63e5ef5305SMatthew Wilber fpSystemItem->SetEnabled(false); 64e5ef5305SMatthew Wilber AddTranslatorsToList(plist, USER_TRANSLATOR, fpUserItem); 65e5ef5305SMatthew Wilber AddTranslatorsToList(plist, SYSTEM_TRANSLATOR, fpSystemItem); 66d1360823SMatthew Wilber 67e5ef5305SMatthew Wilber AddChild(new BScrollView("scroll_list", fpListView, B_FOLLOW_LEFT | B_FOLLOW_TOP, 68d1360823SMatthew Wilber 0, false, true)); 69d1360823SMatthew Wilber 70d1360823SMatthew Wilber SetSizeLimits(100, 10000, 100, 10000); 71d1360823SMatthew Wilber 72d1360823SMatthew Wilber Show(); 73d1360823SMatthew Wilber } 74d1360823SMatthew Wilber 75d1360823SMatthew Wilber void 76e5ef5305SMatthew Wilber ActiveTranslatorsWindow::AddTranslatorsToList(BList *plist, int32 group, 77d1360823SMatthew Wilber BStringItem *pparent) 78d1360823SMatthew Wilber { 79e5ef5305SMatthew Wilber BTranslatorItem *pitem; 80e5ef5305SMatthew Wilber for (int32 i = 0; i < plist->CountItems(); i++) { 81e5ef5305SMatthew Wilber pitem = static_cast<BTranslatorItem *>(plist->ItemAt(i)); 82e5ef5305SMatthew Wilber if (pitem->Group() == group) 83e5ef5305SMatthew Wilber fpListView->AddUnder(pitem, pparent); 84d1360823SMatthew Wilber } 85d1360823SMatthew Wilber } 86d1360823SMatthew Wilber 87d1360823SMatthew Wilber ActiveTranslatorsWindow::~ActiveTranslatorsWindow() 88d1360823SMatthew Wilber { 89d1360823SMatthew Wilber } 90d1360823SMatthew Wilber 91d1360823SMatthew Wilber void 92d1360823SMatthew Wilber ActiveTranslatorsWindow::FrameResized(float width, float height) 93d1360823SMatthew Wilber { 94d1360823SMatthew Wilber } 95d1360823SMatthew Wilber 96d1360823SMatthew Wilber void 97d1360823SMatthew Wilber ActiveTranslatorsWindow::MessageReceived(BMessage *pmsg) 98d1360823SMatthew Wilber { 99d1360823SMatthew Wilber switch (pmsg->what) { 100d1360823SMatthew Wilber default: 101d1360823SMatthew Wilber BWindow::MessageReceived(pmsg); 102d1360823SMatthew Wilber break; 103d1360823SMatthew Wilber } 104d1360823SMatthew Wilber } 105d1360823SMatthew Wilber 106d1360823SMatthew Wilber void 107d1360823SMatthew Wilber ActiveTranslatorsWindow::Quit() 108d1360823SMatthew Wilber { 109d1360823SMatthew Wilber // tell the app to forget about this window 110d1360823SMatthew Wilber be_app->PostMessage(M_ACTIVE_TRANSLATORS_WINDOW_QUIT); 111d1360823SMatthew Wilber BWindow::Quit(); 112d1360823SMatthew Wilber } 113