1 /*****************************************************************************/ 2 // Expander 3 // Written by Jérôme Duval 4 // 5 // ExpanderApp.cpp 6 // 7 // 8 // Copyright (c) 2004 OpenBeOS Project 9 // 10 // Permission is hereby granted, free of charge, to any person obtaining a 11 // copy of this software and associated documentation files (the "Software"), 12 // to deal in the Software without restriction, including without limitation 13 // the rights to use, copy, modify, merge, publish, distribute, sublicense, 14 // and/or sell copies of the Software, and to permit persons to whom the 15 // Software is furnished to do so, subject to the following conditions: 16 // 17 // The above copyright notice and this permission notice shall be included 18 // in all copies or substantial portions of the Software. 19 // 20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 21 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 23 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 25 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 26 // DEALINGS IN THE SOFTWARE. 27 /*****************************************************************************/ 28 29 #include <Alert.h> 30 #include "ExpanderApp.h" 31 #include "ExpanderWindow.h" 32 33 const char *APP_SIG = "application/x-vnd.obos-Expander"; 34 35 int main(int, char **) 36 { 37 ExpanderApp theApp; 38 theApp.Run(); 39 return 0; 40 } 41 42 ExpanderApp::ExpanderApp() 43 : BApplication(APP_SIG) 44 { 45 BPoint windowPosition = fSettings.Message().FindPoint("window_position"); 46 BRect windowFrame(0,0,450,120); 47 windowFrame.OffsetBy(windowPosition); 48 BMessage settings(fSettings.Message()); 49 fWindow = new ExpanderWindow(windowFrame, NULL, &settings); 50 } 51 52 void 53 ExpanderApp::AboutRequested() 54 { 55 BAlert *alert = new BAlert("about", "Expand-O-Matic\n" 56 "\twritten by Jérôme Duval\n" 57 "\tCopyright 2004, OpenBeOS.\n\n" 58 "original Be version by \n" 59 "Dominic, Hiroshi, Peter, Pavel and Robert\n", "Ok"); 60 BTextView *view = alert->TextView(); 61 BFont font; 62 63 view->SetStylable(true); 64 65 view->GetFont(&font); 66 font.SetSize(18); 67 font.SetFace(B_BOLD_FACE); 68 view->SetFontAndColor(0, 14, &font); 69 70 alert->Go(); 71 72 } 73 74 75 void 76 ExpanderApp::ReadyToRun() 77 { 78 79 } 80 81 82 void 83 ExpanderApp::ArgvReceived(int32 argc, char **argv) 84 { 85 BMessage *msg = NULL; 86 for (int32 i = 1; i < argc; i++) { 87 entry_ref ref; 88 status_t err = get_ref_for_path(argv[i], &ref); 89 if (err == B_OK) { 90 if (!msg) { 91 msg = new BMessage; 92 msg->what = B_REFS_RECEIVED; 93 } 94 msg->AddRef("refs", &ref); 95 } 96 } 97 if (msg) 98 RefsReceived(msg); 99 } 100 101 102 void 103 ExpanderApp::RefsReceived(BMessage *msg) 104 { 105 BMessenger messenger(fWindow); 106 msg->AddBool("fromApp", true); 107 messenger.SendMessage(msg); 108 } 109 110 111 void 112 ExpanderApp::UpdateSettingsFrom(BMessage *message) 113 { 114 fSettings.UpdateFrom(message); 115 } 116