Subversion Repositories svn.mios32

Rev

Rev 1188 | Rev 1759 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
877 tk 1
/* -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*- */
2
// $Id: Main.cpp 1724 2013-03-28 20:23:40Z tk $
3
/*
4
 * MIOS Studio Main
5
 *
6
 * ==========================================================================
7
 *
8
 *  Copyright (C) 2010 Thorsten Klose (tk@midibox.org)
9
 *  Licensed for personal non-commercial use only.
10
 *  All other rights reserved.
11
 *
12
 * ==========================================================================
13
 */
14
 
15
#include "includes.h"
937 tk 16
#include "version.h"
926 tk 17
#include "gui/MiosStudio.h"
877 tk 18
 
1724 tk 19
juce_ImplementSingleton (MiosStudioProperties)
20
 
937 tk 21
class MiosStudioWindow
22
    : public DocumentWindow
877 tk 23
{
24
public:
937 tk 25
 
877 tk 26
    //==============================================================================
27
    MiosStudioWindow()
942 tk 28
        : DocumentWindow(String(T("MIOS Studio ")) + String(T(MIOS_STUDIO_VERSION)),
937 tk 29
                         Colours::lightgrey,
30
                         DocumentWindow::allButtons,
31
                         true)
877 tk 32
    {
33
        // Create an instance of our main content component, and add it 
34
        // to our window.
35
        MiosStudio* const contentComponent = new MiosStudio();
1724 tk 36
        setContentOwned(contentComponent, true);
927 tk 37
        setUsingNativeTitleBar(true);
908 tk 38
        centreWithSize(getWidth(), getHeight());
937 tk 39
        setMenuBar(contentComponent);
877 tk 40
 
908 tk 41
        setVisible(true);
877 tk 42
 
43
    }
44
 
45
    ~MiosStudioWindow()
46
    {
937 tk 47
        setMenuBar(0);
877 tk 48
        // (the content component will be deleted automatically, so no need to do it here)
49
    }
50
 
51
    //==============================================================================
52
    void closeButtonPressed()
53
    {
54
        // When the user presses the close button, we'll tell the app to quit. This 
55
        // window will be deleted by our MiosStudioApplication::shutdown() method
56
        // 
57
        JUCEApplication::quit();
58
    }
59
};
60
 
61
//==============================================================================
62
/** This is the application object that is started up when Juce starts. It handles
63
    the initialisation and shutdown of the whole application.
64
*/
65
class JUCEMiosStudioApplication : public JUCEApplication
66
{
67
    /* Important! NEVER embed objects directly inside your JUCEApplication class! Use
68
       ONLY pointers to objects, which you should create during the initialise() method
69
       (NOT in the constructor!) and delete in the shutdown() method (NOT in the
70
       destructor!)
71
 
72
       This is because the application object gets created before Juce has been properly
73
       initialised, so any embedded objects would also get constructed too soon.
74
   */
886 tk 75
    MiosStudioWindow* miosStudioWindow;
877 tk 76
 
77
public:
78
    //==============================================================================
79
    JUCEMiosStudioApplication()
886 tk 80
        : miosStudioWindow (0)
877 tk 81
    {
82
        // NEVER do anything in here that could involve any Juce function being called
83
        // - leave all your startup tasks until the initialise() method.
84
    }
85
 
86
    ~JUCEMiosStudioApplication()
87
    {
88
        // Your shutdown() method should already have done all the things necessary to
89
        // clean up this app object, so you should never need to put anything in
90
        // the destructor.
91
 
92
        // Making any Juce calls in here could be very dangerous...
93
    }
94
 
95
    //==============================================================================
96
    void initialise (const String& commandLine)
97
    {
908 tk 98
        // create the main window...
886 tk 99
        miosStudioWindow = new MiosStudioWindow();
877 tk 100
 
101
        /*  ..and now return, which will fall into to the main event
102
            dispatch loop, and this will run until something calls
103
            JUCEAppliction::quit().
104
 
105
            In this case, JUCEAppliction::quit() will be called by the
106
            hello world window being clicked.
107
        */
108
    }
109
 
110
    void shutdown()
111
    {
112
        // clear up..
908 tk 113
        if( miosStudioWindow != 0 )
1188 tk 114
            deleteAndZero(miosStudioWindow);
877 tk 115
    }
116
 
908 tk 117
 
877 tk 118
    //==============================================================================
119
    const String getApplicationName()
120
    {
942 tk 121
        return T("MIOS Studio");
877 tk 122
    }
123
 
124
    const String getApplicationVersion()
125
    {
937 tk 126
        return T(MIOS_STUDIO_VERSION);
877 tk 127
    }
128
 
129
    bool moreThanOneInstanceAllowed()
130
    {
131
        return true;
132
    }
133
 
134
    void anotherInstanceStarted (const String& commandLine)
135
    {
136
    }
137
};
138
 
139
 
140
//==============================================================================
141
// This macro creates the application's main() function..
142
START_JUCE_APPLICATION (JUCEMiosStudioApplication)