1 /* 2 * Copyright 2004-2006, Jérôme DUVAL. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 6 7 #include "ExpanderApp.h" 8 #include "ExpanderWindow.h" 9 10 #include <Alert.h> 11 #include <TextView.h> 12 13 14 ExpanderApp::ExpanderApp() 15 : BApplication("application/x-vnd.Haiku-Expander") 16 { 17 BPoint windowPosition = fSettings.Message().FindPoint("window_position"); 18 BRect windowFrame(0, 0, 450, 120); 19 windowFrame.OffsetBy(windowPosition); 20 BMessage settings(fSettings.Message()); 21 fWindow = new ExpanderWindow(windowFrame, NULL, &settings); 22 } 23 24 25 void 26 ExpanderApp::AboutRequested() 27 { 28 BAlert *alert = new BAlert("about", "Expand-O-Matic\n" 29 "\twritten by Jérôme Duval\n" 30 "\tCopyright 2004-2006, Haiku Inc.\n\n" 31 "original Be version by \n" 32 "Dominic, Hiroshi, Peter, Pavel and Robert\n", "Ok"); 33 BTextView *view = alert->TextView(); 34 BFont font; 35 36 view->SetStylable(true); 37 38 view->GetFont(&font); 39 font.SetSize(18); 40 font.SetFace(B_BOLD_FACE); 41 view->SetFontAndColor(0, 14, &font); 42 43 alert->Go(); 44 } 45 46 47 void 48 ExpanderApp::ReadyToRun() 49 { 50 } 51 52 53 void 54 ExpanderApp::ArgvReceived(int32 argc, char **argv) 55 { 56 BMessage *msg = NULL; 57 for (int32 i = 1; i < argc; i++) { 58 entry_ref ref; 59 status_t err = get_ref_for_path(argv[i], &ref); 60 if (err == B_OK) { 61 if (!msg) { 62 msg = new BMessage; 63 msg->what = B_REFS_RECEIVED; 64 } 65 msg->AddRef("refs", &ref); 66 } 67 } 68 if (msg) 69 RefsReceived(msg); 70 } 71 72 73 void 74 ExpanderApp::RefsReceived(BMessage *msg) 75 { 76 BMessenger messenger(fWindow); 77 msg->AddBool("fromApp", true); 78 messenger.SendMessage(msg); 79 } 80 81 82 void 83 ExpanderApp::UpdateSettingsFrom(BMessage *message) 84 { 85 fSettings.UpdateFrom(message); 86 } 87 88 89 // #pragma mark - 90 91 92 int 93 main(int, char **) 94 { 95 ExpanderApp theApp; 96 theApp.Run(); 97 return 0; 98 } 99