16ffb6a6eSJérôme Duval /* 2*7ff74a7bSStephan Aßmus * Copyright 2009, Stephan Aßmus <superstippi@gmx.de> 3*7ff74a7bSStephan Aßmus * Copyright 2005, Jérôme DUVAL. 4*7ff74a7bSStephan Aßmus * All rights reserved. Distributed under the terms of the MIT License. 56ffb6a6eSJérôme Duval */ 66ffb6a6eSJérôme Duval 7*7ff74a7bSStephan Aßmus #include "InstallerApp.h" 8*7ff74a7bSStephan Aßmus 96ffb6a6eSJérôme Duval #include <Alert.h> 10*7ff74a7bSStephan Aßmus #include <Button.h> 11*7ff74a7bSStephan Aßmus #include <GroupLayoutBuilder.h> 128b7c3f78SJérôme Duval #include <Screen.h> 1335d3acb2SJérôme Duval #include <ScrollView.h> 146ffb6a6eSJérôme Duval #include <TextView.h> 156ffb6a6eSJérôme Duval 166ffb6a6eSJérôme Duval 17*7ff74a7bSStephan Aßmus static const uint32 kMsgAgree = 'agre'; 18*7ff74a7bSStephan Aßmus 19*7ff74a7bSStephan Aßmus static const char* kEULAText = 20*7ff74a7bSStephan Aßmus "NOTICE: READ THIS BEFORE INSTALLING OR USING HAIKU\n\n" 21*7ff74a7bSStephan Aßmus 22*7ff74a7bSStephan Aßmus "Copyright " B_UTF8_COPYRIGHT " 2001-2009 The Haiku Project. All rights " 23*7ff74a7bSStephan Aßmus "reserved. The copyright to the Haiku code is property of Haiku, Inc. or of " 24*7ff74a7bSStephan Aßmus "the respective authors where expressly noted in the source.\n\n" 25*7ff74a7bSStephan Aßmus 26*7ff74a7bSStephan Aßmus "Permission is hereby granted, free of charge, to any person obtaining a " 27*7ff74a7bSStephan Aßmus "copy of this software and associated documentation files (the \"Software\"), " 28*7ff74a7bSStephan Aßmus "to deal in the Software without restriction, including without limitation " 29*7ff74a7bSStephan Aßmus "the rights to use, copy, modify, merge, publish, distribute, sublicense, " 30*7ff74a7bSStephan Aßmus "and/or sell copies of the Software, and to permit persons to whom the " 31*7ff74a7bSStephan Aßmus "Software is furnished to do so, subject to the following conditions:\n\n" 32*7ff74a7bSStephan Aßmus "The above copyright notice and this permission notice shall be included in " 33*7ff74a7bSStephan Aßmus "all copies or substantial portions of the Software.\n\n" 34*7ff74a7bSStephan Aßmus 35*7ff74a7bSStephan Aßmus "THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS " 36*7ff74a7bSStephan Aßmus "OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, " 37*7ff74a7bSStephan Aßmus "FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE " 38*7ff74a7bSStephan Aßmus "AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER " 39*7ff74a7bSStephan Aßmus "LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING " 40*7ff74a7bSStephan Aßmus "FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS " 41*7ff74a7bSStephan Aßmus "IN THE SOFTWARE."; 42*7ff74a7bSStephan Aßmus 4335d3acb2SJérôme Duval 446ffb6a6eSJérôme Duval int main(int, char **) 456ffb6a6eSJérôme Duval { 466ffb6a6eSJérôme Duval InstallerApp theApp; 476ffb6a6eSJérôme Duval theApp.Run(); 486ffb6a6eSJérôme Duval return 0; 496ffb6a6eSJérôme Duval } 506ffb6a6eSJérôme Duval 51*7ff74a7bSStephan Aßmus 526ffb6a6eSJérôme Duval InstallerApp::InstallerApp() 53*7ff74a7bSStephan Aßmus : BApplication("application/x-vnd.Haiku-Installer") 546ffb6a6eSJérôme Duval { 5553ad1814SJérôme Duval } 5653ad1814SJérôme Duval 57*7ff74a7bSStephan Aßmus 58*7ff74a7bSStephan Aßmus void 59*7ff74a7bSStephan Aßmus InstallerApp::MessageReceived(BMessage* message) 60*7ff74a7bSStephan Aßmus { 61*7ff74a7bSStephan Aßmus switch (message->what) { 62*7ff74a7bSStephan Aßmus case kMsgAgree: 63*7ff74a7bSStephan Aßmus fEULAWindow->Lock(); 64*7ff74a7bSStephan Aßmus fEULAWindow->Quit(); 65*7ff74a7bSStephan Aßmus new InstallerWindow(); 66*7ff74a7bSStephan Aßmus break; 67*7ff74a7bSStephan Aßmus 68*7ff74a7bSStephan Aßmus default: 69*7ff74a7bSStephan Aßmus BApplication::MessageReceived(message); 706ffb6a6eSJérôme Duval } 71*7ff74a7bSStephan Aßmus } 72*7ff74a7bSStephan Aßmus 736ffb6a6eSJérôme Duval 746ffb6a6eSJérôme Duval void 756ffb6a6eSJérôme Duval InstallerApp::AboutRequested() 766ffb6a6eSJérôme Duval { 776ffb6a6eSJérôme Duval BAlert *alert = new BAlert("about", "Installer\n" 786ffb6a6eSJérôme Duval "\twritten by Jérôme Duval\n" 796ffb6a6eSJérôme Duval "\tCopyright 2005, Haiku.\n\n", "Ok"); 806ffb6a6eSJérôme Duval BTextView *view = alert->TextView(); 816ffb6a6eSJérôme Duval BFont font; 826ffb6a6eSJérôme Duval 836ffb6a6eSJérôme Duval view->SetStylable(true); 846ffb6a6eSJérôme Duval 856ffb6a6eSJérôme Duval view->GetFont(&font); 866ffb6a6eSJérôme Duval font.SetSize(18); 876ffb6a6eSJérôme Duval font.SetFace(B_BOLD_FACE); 886ffb6a6eSJérôme Duval view->SetFontAndColor(0, 14, &font); 896ffb6a6eSJérôme Duval 906ffb6a6eSJérôme Duval alert->Go(); 916ffb6a6eSJérôme Duval } 926ffb6a6eSJérôme Duval 936ffb6a6eSJérôme Duval 946ffb6a6eSJérôme Duval void 956ffb6a6eSJérôme Duval InstallerApp::ReadyToRun() 966ffb6a6eSJérôme Duval { 97*7ff74a7bSStephan Aßmus #if 1 98*7ff74a7bSStephan Aßmus // Show the EULA first. 99*7ff74a7bSStephan Aßmus BTextView* textView = new BTextView("eula", be_plain_font, NULL, 100*7ff74a7bSStephan Aßmus B_WILL_DRAW); 101*7ff74a7bSStephan Aßmus textView->SetInsets(10, 10, 10, 10); 102*7ff74a7bSStephan Aßmus textView->MakeEditable(false); 103*7ff74a7bSStephan Aßmus textView->MakeSelectable(false); 104*7ff74a7bSStephan Aßmus textView->SetText(kEULAText); 1056ffb6a6eSJérôme Duval 106*7ff74a7bSStephan Aßmus BScrollView* scrollView = new BScrollView("eulaScroll", 107*7ff74a7bSStephan Aßmus textView, B_WILL_DRAW, false, true); 108*7ff74a7bSStephan Aßmus 109*7ff74a7bSStephan Aßmus BButton* disagreeButton = new BButton("Disagree", 110*7ff74a7bSStephan Aßmus new BMessage(B_QUIT_REQUESTED)); 111*7ff74a7bSStephan Aßmus disagreeButton->SetTarget(this); 112*7ff74a7bSStephan Aßmus 113*7ff74a7bSStephan Aßmus BButton* agreeButton = new BButton("Agree", 114*7ff74a7bSStephan Aßmus new BMessage(kMsgAgree)); 115*7ff74a7bSStephan Aßmus agreeButton->SetTarget(this); 116*7ff74a7bSStephan Aßmus agreeButton->MakeDefault(true); 117*7ff74a7bSStephan Aßmus 118*7ff74a7bSStephan Aßmus BRect eulaFrame = BRect(0, 0, 600, 450); 119*7ff74a7bSStephan Aßmus fEULAWindow = new BWindow(eulaFrame, "EULA", 120*7ff74a7bSStephan Aßmus B_MODAL_WINDOW, B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE 121*7ff74a7bSStephan Aßmus | B_AUTO_UPDATE_SIZE_LIMITS); 122*7ff74a7bSStephan Aßmus 123*7ff74a7bSStephan Aßmus fEULAWindow->SetLayout(new BGroupLayout(B_HORIZONTAL)); 124*7ff74a7bSStephan Aßmus fEULAWindow->AddChild(BGroupLayoutBuilder(B_VERTICAL, 10) 125*7ff74a7bSStephan Aßmus .Add(scrollView) 126*7ff74a7bSStephan Aßmus .Add(BGroupLayoutBuilder(B_HORIZONTAL, 10) 127*7ff74a7bSStephan Aßmus .AddGlue() 128*7ff74a7bSStephan Aßmus .Add(disagreeButton) 129*7ff74a7bSStephan Aßmus .Add(agreeButton) 130*7ff74a7bSStephan Aßmus ) 131*7ff74a7bSStephan Aßmus .SetInsets(10, 10, 10, 10) 132*7ff74a7bSStephan Aßmus ); 133*7ff74a7bSStephan Aßmus 134*7ff74a7bSStephan Aßmus BRect frame = BScreen().Frame(); 135*7ff74a7bSStephan Aßmus fEULAWindow->MoveTo(frame.left + (frame.Width() - eulaFrame.Width()) / 2, 136*7ff74a7bSStephan Aßmus frame.top + (frame.Height() - eulaFrame.Height()) / 2); 137*7ff74a7bSStephan Aßmus 138*7ff74a7bSStephan Aßmus fEULAWindow->Show(); 139*7ff74a7bSStephan Aßmus #else 140*7ff74a7bSStephan Aßmus // Show the installer window without EULA. 141*7ff74a7bSStephan Aßmus new InstallerWindow(); 142*7ff74a7bSStephan Aßmus #endif 1436ffb6a6eSJérôme Duval } 1446ffb6a6eSJérôme Duval 145