OpenShot Audio Library | OpenShotAudio 0.3.2
Loading...
Searching...
No Matches
juce::JUCEApplicationBase Class Referenceabstract

#include <juce_ApplicationBase.h>

Public Types

using CreateInstanceFunction = JUCEApplicationBase *(*)()
 

Public Member Functions

virtual ~JUCEApplicationBase ()
 
virtual const String getApplicationName ()=0
 
virtual const String getApplicationVersion ()=0
 
virtual bool moreThanOneInstanceAllowed ()=0
 
virtual void initialise (const String &commandLineParameters)=0
 
virtual void shutdown ()=0
 
virtual void anotherInstanceStarted (const String &commandLine)=0
 
virtual void systemRequestedQuit ()=0
 
virtual void suspended ()=0
 
virtual void resumed ()=0
 
virtual void unhandledException (const std::exception *, const String &sourceFilename, int lineNumber)=0
 
virtual void memoryWarningReceived ()
 
virtual bool backButtonPressed ()
 
void setApplicationReturnValue (int newReturnValue) noexcept
 
int getApplicationReturnValue () const noexcept
 
bool isInitialising () const noexcept
 
virtual bool initialiseApp ()
 
int shutdownApp ()
 
bool sendCommandLineToPreexistingInstance ()
 

Static Public Member Functions

static JUCEApplicationBasegetInstance () noexcept
 
static void quit ()
 
static StringArray JUCE_CALLTYPE getCommandLineParameterArray ()
 
static String JUCE_CALLTYPE getCommandLineParameters ()
 
static bool isStandaloneApp () noexcept
 
static int main ()
 
static int main (int argc, const char *argv[])
 
static void appWillTerminateByForce ()
 
static void JUCE_CALLTYPE sendUnhandledException (const std::exception *, const char *sourceFile, int lineNumber)
 

Static Public Attributes

static CreateInstanceFunction createInstance = nullptr
 

Detailed Description

Abstract base class for application classes.

Note that in the juce_gui_basics module, there's a utility class JUCEApplication which derives from JUCEApplicationBase, and takes care of a few chores. Most of the time you'll want to derive your class from JUCEApplication rather than using JUCEApplicationBase directly, but if you're not using the juce_gui_basics module then you might need to go straight to this base class.

Any application that wants to run an event loop must declare a subclass of JUCEApplicationBase, and implement its various pure virtual methods.

It then needs to use the START_JUCE_APPLICATION macro somewhere in a CPP file to declare an instance of this class and generate suitable platform-specific boilerplate code to launch the app.

e.g.

class MyJUCEApp : public JUCEApplication
{
public:
MyJUCEApp() {}
void initialise (const String& commandLine) override
{
myMainWindow.reset (new MyApplicationWindow());
myMainWindow->setBounds (100, 100, 400, 500);
myMainWindow->setVisible (true);
}
void shutdown() override
{
myMainWindow = nullptr;
}
const String getApplicationName() override
{
return "Super JUCE-o-matic";
}
const String getApplicationVersion() override
{
return "1.0";
}
private:
std::unique_ptr<MyApplicationWindow> myMainWindow;
};
// this generates boilerplate code to launch our app class:
START_JUCE_APPLICATION (MyJUCEApp)
See also
JUCEApplication, START_JUCE_APPLICATION

Definition at line 84 of file juce_ApplicationBase.h.

Member Typedef Documentation

◆ CreateInstanceFunction

Constructor & Destructor Documentation

◆ JUCEApplicationBase()

juce::JUCEApplicationBase::JUCEApplicationBase ( )
protected

Definition at line 33 of file juce_ApplicationBase.cpp.

◆ ~JUCEApplicationBase()

juce::JUCEApplicationBase::~JUCEApplicationBase ( )
virtual

Destructor.

Definition at line 39 of file juce_ApplicationBase.cpp.

Member Function Documentation

◆ anotherInstanceStarted()

virtual void juce::JUCEApplicationBase::anotherInstanceStarted ( const String commandLine)
pure virtual

Indicates that the user has tried to start up another instance of the app.

This will get called even if moreThanOneInstanceAllowed() is false. It is currently only implemented on Windows and Mac.

See also
moreThanOneInstanceAllowed

◆ appWillTerminateByForce()

void juce::JUCEApplicationBase::appWillTerminateByForce ( )
static

Definition at line 51 of file juce_ApplicationBase.cpp.

◆ backButtonPressed()

virtual bool juce::JUCEApplicationBase::backButtonPressed ( )
inlinevirtual

This will be called when the back button on a device is pressed. The return value should be used to indicate whether the back button event has been handled by the application, for example if you want to implement custom navigation instead of the standard behaviour on Android.

This is currently only implemented on Android devices.

Returns
true if the event has been handled, or false if the default OS behaviour should happen

Definition at line 219 of file juce_ApplicationBase.h.

◆ getApplicationName()

virtual const String juce::JUCEApplicationBase::getApplicationName ( )
pure virtual

Returns the application's name.

◆ getApplicationReturnValue()

int juce::JUCEApplicationBase::getApplicationReturnValue ( ) const
inlinenoexcept

Returns the value that has been set as the application's exit code.

See also
setApplicationReturnValue

Definition at line 262 of file juce_ApplicationBase.h.

◆ getApplicationVersion()

virtual const String juce::JUCEApplicationBase::getApplicationVersion ( )
pure virtual

Returns the application's version number.

◆ getCommandLineParameterArray()

StringArray juce::JUCEApplicationBase::getCommandLineParameterArray ( )
static

Returns the application's command line parameters as a set of strings.

See also
getCommandLineParameters

Definition at line 215 of file juce_ApplicationBase.cpp.

◆ getCommandLineParameters()

String juce::JUCEApplicationBase::getCommandLineParameters ( )
static

Returns the application's command line parameters as a single string.

See also
getCommandLineParameterArray

Definition at line 198 of file juce_ApplicationBase.cpp.

◆ getInstance()

static JUCEApplicationBase * juce::JUCEApplicationBase::getInstance ( )
inlinestaticnoexcept

Returns the global instance of the application object that's running.

Definition at line 96 of file juce_ApplicationBase.h.

◆ initialise()

virtual void juce::JUCEApplicationBase::initialise ( const String commandLineParameters)
pure virtual

Called when the application starts.

This will be called once to let the application do whatever initialisation it needs, create its windows, etc.

After the method returns, the normal event-dispatch loop will be run, until the quit() method is called, at which point the shutdown() method will be called to let the application clear up anything it needs to delete.

If during the initialise() method, the application decides not to start-up after all, it can just call the quit() method and the event loop won't be run.

Parameters
commandLineParametersthe line passed in does not include the name of the executable, just the parameter list. To get the parameters as an array, you can call JUCEApplication::getCommandLineParameters()
See also
shutdown, quit

◆ initialiseApp()

bool juce::JUCEApplicationBase::initialiseApp ( )
virtual

Definition at line 272 of file juce_ApplicationBase.cpp.

◆ isInitialising()

bool juce::JUCEApplicationBase::isInitialising ( ) const
inlinenoexcept

Returns true if the application hasn't yet completed its initialise() method and entered the main event loop.

This is handy for things like splash screens to know when the app's up-and-running properly.

Definition at line 275 of file juce_ApplicationBase.h.

◆ isStandaloneApp()

static bool juce::JUCEApplicationBase::isStandaloneApp ( )
inlinestaticnoexcept

Returns true if this executable is running as an app (as opposed to being a plugin or other kind of shared library.

Definition at line 267 of file juce_ApplicationBase.h.

◆ main() [1/2]

int juce::JUCEApplicationBase::main ( )
static

Definition at line 248 of file juce_ApplicationBase.cpp.

◆ main() [2/2]

int juce::JUCEApplicationBase::main ( int  argc,
const char argv[] 
)
static

Definition at line 220 of file juce_ApplicationBase.cpp.

◆ memoryWarningReceived()

virtual void juce::JUCEApplicationBase::memoryWarningReceived ( )
inlinevirtual

Called by the operating system to indicate that you should reduce your memory footprint.

You should override this method to free up some memory gracefully, if possible, otherwise the host may forcibly kill your app.

At the moment this method is only called on iOS.

Definition at line 206 of file juce_ApplicationBase.h.

◆ moreThanOneInstanceAllowed()

virtual bool juce::JUCEApplicationBase::moreThanOneInstanceAllowed ( )
pure virtual

Checks whether multiple instances of the app are allowed.

If your application class returns true for this, more than one instance is permitted to run (except on the Mac where this isn't possible).

If it's false, the second instance won't start, but you will still get a callback to anotherInstanceStarted() to tell you about this - which gives you a chance to react to what the user was trying to do.

See also
anotherInstanceStarted

◆ quit()

void juce::JUCEApplicationBase::quit ( )
static

Signals that the main message loop should stop and the application should terminate.

This isn't synchronous, it just posts a quit message to the main queue, and when this message arrives, the message loop will stop, the shutdown() method will be called, and the app will exit.

Note that this will cause an unconditional quit to happen, so if you need an extra level before this, e.g. to give the user the chance to save their work and maybe cancel the quit, you'll need to handle this in the systemRequestedQuit() method - see that method's help for more info.

See also
MessageManager

Definition at line 67 of file juce_ApplicationBase.cpp.

◆ resumed()

virtual void juce::JUCEApplicationBase::resumed ( )
pure virtual

This method is called when the application is being woken from background mode by the operating system.

◆ sendCommandLineToPreexistingInstance()

bool juce::JUCEApplicationBase::sendCommandLineToPreexistingInstance ( )

Definition at line 133 of file juce_ApplicationBase.cpp.

◆ sendUnhandledException()

void juce::JUCEApplicationBase::sendUnhandledException ( const std::exception *  e,
const char sourceFile,
int  lineNumber 
)
static

Definition at line 72 of file juce_ApplicationBase.cpp.

◆ setApplicationReturnValue()

void juce::JUCEApplicationBase::setApplicationReturnValue ( int  newReturnValue)
noexcept

Sets the value that should be returned as the application's exit code when the app quits.

This is the value that's returned by the main() function. Normally you'd leave this as 0 unless you want to indicate an error code.

See also
getApplicationReturnValue

Definition at line 45 of file juce_ApplicationBase.cpp.

◆ shutdownApp()

int juce::JUCEApplicationBase::shutdownApp ( )

Definition at line 312 of file juce_ApplicationBase.cpp.

◆ suspended()

virtual void juce::JUCEApplicationBase::suspended ( )
pure virtual

This method is called when the application is being put into background mode by the operating system.

◆ systemRequestedQuit()

virtual void juce::JUCEApplicationBase::systemRequestedQuit ( )
pure virtual

Called when the operating system is trying to close the application.

The default implementation of this method is to call quit(), but it may be overloaded to ignore the request or do some other special behaviour instead. For example, you might want to offer the user the chance to save their changes before quitting, and give them the chance to cancel.

If you want to send a quit signal to your app, this is the correct method to call, because it means that requests that come from the system get handled in the same way as those from your own application code. So e.g. you'd call this method from a "quit" item on a menu bar.

◆ unhandledException()

virtual void juce::JUCEApplicationBase::unhandledException ( const std::exception *  ,
const String sourceFilename,
int  lineNumber 
)
pure virtual

If any unhandled exceptions make it through to the message dispatch loop, this callback will be triggered, in case you want to log them or do some other type of error-handling.

If the type of exception is derived from the std::exception class, the pointer passed-in will be valid. If the exception is of unknown type, this pointer will be null.

Member Data Documentation

◆ createInstance

JUCEApplicationBase::CreateInstanceFunction juce::JUCEApplicationBase::createInstance = nullptr
static

Definition at line 286 of file juce_ApplicationBase.h.


The documentation for this class was generated from the following files: