xref: /haiku/src/apps/midiplayer/MidiPlayerApp.cpp (revision 612dd0044715fe2eb776758a42186197ffe9340a)
10fe1abb5Smahlzeit /*
20fe1abb5Smahlzeit  * Copyright (c) 2004 Matthijs Hollemans
30fe1abb5Smahlzeit  *
40fe1abb5Smahlzeit  * Permission is hereby granted, free of charge, to any person obtaining a
50fe1abb5Smahlzeit  * copy of this software and associated documentation files (the "Software"),
60fe1abb5Smahlzeit  * to deal in the Software without restriction, including without limitation
70fe1abb5Smahlzeit  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
80fe1abb5Smahlzeit  * and/or sell copies of the Software, and to permit persons to whom the
90fe1abb5Smahlzeit  * Software is furnished to do so, subject to the following conditions:
100fe1abb5Smahlzeit  *
110fe1abb5Smahlzeit  * The above copyright notice and this permission notice shall be included in
120fe1abb5Smahlzeit  * all copies or substantial portions of the Software.
130fe1abb5Smahlzeit  *
140fe1abb5Smahlzeit  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
150fe1abb5Smahlzeit  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
160fe1abb5Smahlzeit  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
170fe1abb5Smahlzeit  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
180fe1abb5Smahlzeit  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
190fe1abb5Smahlzeit  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
200fe1abb5Smahlzeit  * DEALINGS IN THE SOFTWARE.
210fe1abb5Smahlzeit  */
220fe1abb5Smahlzeit 
230fe1abb5Smahlzeit #include <Alert.h>
240fe1abb5Smahlzeit #include <StorageKit.h>
250fe1abb5Smahlzeit 
260fe1abb5Smahlzeit #include "MidiPlayerApp.h"
270fe1abb5Smahlzeit #include "MidiPlayerWindow.h"
280fe1abb5Smahlzeit 
290fe1abb5Smahlzeit //------------------------------------------------------------------------------
300fe1abb5Smahlzeit 
310fe1abb5Smahlzeit MidiPlayerApp::MidiPlayerApp()
320fe1abb5Smahlzeit 	: BApplication(MIDI_PLAYER_SIGNATURE)
330fe1abb5Smahlzeit {
340fe1abb5Smahlzeit 	window = new MidiPlayerWindow;
350fe1abb5Smahlzeit }
360fe1abb5Smahlzeit 
370fe1abb5Smahlzeit //------------------------------------------------------------------------------
380fe1abb5Smahlzeit 
390fe1abb5Smahlzeit void MidiPlayerApp::ReadyToRun()
400fe1abb5Smahlzeit {
410fe1abb5Smahlzeit 	window->Show();
420fe1abb5Smahlzeit }
430fe1abb5Smahlzeit 
440fe1abb5Smahlzeit //------------------------------------------------------------------------------
450fe1abb5Smahlzeit 
460fe1abb5Smahlzeit void MidiPlayerApp::AboutRequested()
470fe1abb5Smahlzeit {
480fe1abb5Smahlzeit 	(new BAlert(
49*612dd004Smahlzeit 		NULL,
50*612dd004Smahlzeit 		"Haiku MIDI Player\n\n"
51*612dd004Smahlzeit 		"This tiny program\n"
52*612dd004Smahlzeit 		"Knows how to play thousands of\n"
53*612dd004Smahlzeit 		"Cheesy sounding songs",
54*612dd004Smahlzeit 		"Okay", NULL, NULL,
550fe1abb5Smahlzeit 		B_WIDTH_AS_USUAL, B_INFO_ALERT))->Go();
560fe1abb5Smahlzeit }
570fe1abb5Smahlzeit 
580fe1abb5Smahlzeit //------------------------------------------------------------------------------
590fe1abb5Smahlzeit 
600fe1abb5Smahlzeit void MidiPlayerApp::RefsReceived(BMessage* msg)
610fe1abb5Smahlzeit {
620fe1abb5Smahlzeit 	msg->what = B_SIMPLE_DATA;
630fe1abb5Smahlzeit 	window->PostMessage(msg);
640fe1abb5Smahlzeit }
650fe1abb5Smahlzeit 
660fe1abb5Smahlzeit //------------------------------------------------------------------------------
670fe1abb5Smahlzeit 
680fe1abb5Smahlzeit void MidiPlayerApp::ArgvReceived(int32 argc, char** argv)
690fe1abb5Smahlzeit {
700fe1abb5Smahlzeit 	// Note: we only load the first file, even if more than one is specified.
710fe1abb5Smahlzeit 	// For some reason, BeOS R5 MidiPlayer loads them all but will only play
720fe1abb5Smahlzeit 	// the last one. That's not very useful.
730fe1abb5Smahlzeit 
740fe1abb5Smahlzeit 	if (argc > 1)
750fe1abb5Smahlzeit 	{
760fe1abb5Smahlzeit 		BMessage msg;
770fe1abb5Smahlzeit 		msg.what = B_SIMPLE_DATA;
780fe1abb5Smahlzeit 
790fe1abb5Smahlzeit 		BEntry entry(argv[1]);
800fe1abb5Smahlzeit 		entry_ref ref;
810fe1abb5Smahlzeit 		entry.GetRef(&ref);
820fe1abb5Smahlzeit 		msg.AddRef("refs", &ref);
830fe1abb5Smahlzeit 
840fe1abb5Smahlzeit 		window->PostMessage(&msg);
850fe1abb5Smahlzeit 	}
860fe1abb5Smahlzeit }
870fe1abb5Smahlzeit 
880fe1abb5Smahlzeit //------------------------------------------------------------------------------
890fe1abb5Smahlzeit 
900fe1abb5Smahlzeit int main()
910fe1abb5Smahlzeit {
920fe1abb5Smahlzeit 	MidiPlayerApp app;
930fe1abb5Smahlzeit 	app.Run();
940fe1abb5Smahlzeit 	return 0;
950fe1abb5Smahlzeit }
960fe1abb5Smahlzeit 
970fe1abb5Smahlzeit //------------------------------------------------------------------------------
98