LMMS
Loading...
Searching...
No Matches
juce::JUCEApplication Class Reference

#include <juce_Application.h>

Inheritance diagram for juce::JUCEApplication:
juce::JUCEApplicationBase juce::ApplicationCommandTarget

Public Member Functions

 JUCEApplication ()
 ~JUCEApplication () override
bool moreThanOneInstanceAllowed () override
void anotherInstanceStarted (const String &commandLine) override
void systemRequestedQuit () override
void suspended () override
void resumed () override
void unhandledException (const std::exception *e, const String &sourceFilename, int lineNumber) override
ApplicationCommandTargetgetNextCommandTarget () override
void getCommandInfo (CommandID, ApplicationCommandInfo &) override
void getAllCommands (Array< CommandID > &) override
bool perform (const InvocationInfo &) override
Public Member Functions inherited from juce::JUCEApplicationBase
virtual ~JUCEApplicationBase ()
virtual const String getApplicationName ()=0
virtual const String getApplicationVersion ()=0
virtual void initialise (const String &commandLineParameters)=0
virtual void shutdown ()=0
virtual void memoryWarningReceived ()
virtual bool backButtonPressed ()
void setApplicationReturnValue (int newReturnValue) noexcept
int getApplicationReturnValue () const noexcept
bool isInitialising () const noexcept
int shutdownApp ()
bool sendCommandLineToPreexistingInstance ()
Public Member Functions inherited from juce::ApplicationCommandTarget
 ApplicationCommandTarget ()
virtual ~ApplicationCommandTarget ()
bool invoke (const InvocationInfo &invocationInfo, const bool asynchronously)
bool invokeDirectly (const CommandID commandID, const bool asynchronously)
ApplicationCommandTargetgetTargetForCommand (const CommandID commandID)
bool isCommandActive (const CommandID commandID)
ApplicationCommandTargetfindFirstTargetParentComponent ()

Static Public Member Functions

static JUCEApplication *JUCE_CALLTYPE getInstance () noexcept
Static Public Member Functions inherited from juce::JUCEApplicationBase
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)

Private Member Functions

bool initialiseApp () override

Additional Inherited Members

Public Types inherited from juce::JUCEApplicationBase
using CreateInstanceFunction = JUCEApplicationBase* (*)()
Static Public Attributes inherited from juce::JUCEApplicationBase
static CreateInstanceFunction createInstance = nullptr
Protected Member Functions inherited from juce::JUCEApplicationBase
 JUCEApplicationBase ()

Detailed Description

An instance of this class is used to specify initialisation and shutdown code for the application.

Any application that wants to run an event loop must declare a subclass of JUCEApplicationBase or JUCEApplication, 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.

Note that this class is derived from JUCEApplicationBase, which contains most of the useful methods and functionality. This derived class is here simply as a convenient way to also inherit from an ApplicationCommandTarget, and to implement default versions of some of the pure virtual base class methods. But you can derive your app object directly from JUCEApplicationBase if you want to, and by doing so can avoid having a dependency on the juce_gui_basics module.

e.g.

class MyJUCEApp : public JUCEApplication
{
public:
MyJUCEApp() {}
~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:
static void shutdown(void)
Definition adplugdb.cpp:297
Definition String.h:48
JUCEApplication()
Definition juce_Application.cpp:29
#define START_JUCE_APPLICATION(AppClass)
Definition juce_Initialisation.h:159
See also
JUCEApplicationBase, START_JUCE_APPLICATION

@tags{GUI}

Constructor & Destructor Documentation

◆ JUCEApplication()

juce::JUCEApplication::JUCEApplication ( )

Constructs a JUCE app object.

If subclasses implement a constructor or destructor, they shouldn't call any JUCE code in there - put your startup/shutdown code in initialise() and shutdown() instead.

◆ ~JUCEApplication()

juce::JUCEApplication::~JUCEApplication ( )
override

Destructor.

If subclasses implement a constructor or destructor, they shouldn't call any JUCE code in there - put your startup/shutdown code in initialise() and shutdown() instead.

Member Function Documentation

◆ anotherInstanceStarted()

void juce::JUCEApplication::anotherInstanceStarted ( const String & commandLine)
overridevirtual

Indicates that the user has tried to start up another instance of the app. This will get called even if moreThanOneInstanceAllowed() is false.

Implements juce::JUCEApplicationBase.

◆ getAllCommands()

void juce::JUCEApplication::getAllCommands ( Array< CommandID > & commands)
overridevirtual

This must return a complete list of commands that this target can handle.

Your target should add all the command IDs that it handles to the array that is passed-in.

Implements juce::ApplicationCommandTarget.

◆ getCommandInfo()

void juce::JUCEApplication::getCommandInfo ( CommandID commandID,
ApplicationCommandInfo & result )
overridevirtual

This must provide details about one of the commands that this target can perform.

This will be called with one of the command IDs that the target provided in its getAllCommands() methods.

It should fill-in all appropriate fields of the ApplicationCommandInfo structure with suitable information about the command. (The commandID field will already have been filled-in by the caller).

The easiest way to set the info is using the ApplicationCommandInfo::setInfo() method to set all the fields at once.

If the command is currently inactive for some reason, this method must use ApplicationCommandInfo::setActive() to make that clear, (or it should set the isDisabled bit of the ApplicationCommandInfo::flags field).

Any default key-presses for the command should be appended to the ApplicationCommandInfo::defaultKeypresses field.

Note that if you change something that affects the status of the commands that would be returned by this method (e.g. something that makes some commands active or inactive), you should call ApplicationCommandManager::commandStatusChanged() to cause the manager to refresh its status.

Implements juce::ApplicationCommandTarget.

◆ getInstance()

JUCEApplication *JUCE_CALLTYPE juce::JUCEApplication::getInstance ( )
staticnoexcept

Returns the global instance of the application object being run.

◆ getNextCommandTarget()

ApplicationCommandTarget * juce::JUCEApplication::getNextCommandTarget ( )
overridevirtual

This must return the next target to try after this one.

When a command is being sent, and the first target can't handle that command, this method is used to determine the next target that should be tried.

It may return nullptr if it doesn't know of another target.

If your target is a Component, you would usually use the findFirstTargetParentComponent() method to return a parent component that might want to handle it.

See also
invoke

Implements juce::ApplicationCommandTarget.

◆ initialiseApp()

bool juce::JUCEApplication::initialiseApp ( )
overrideprivatevirtual

Reimplemented from juce::JUCEApplicationBase.

◆ moreThanOneInstanceAllowed()

bool juce::JUCEApplication::moreThanOneInstanceAllowed ( )
overridevirtual

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 OSX where the OS automatically stops you launching a second instance of an app without explicitly starting it from the command-line).

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.

Implements juce::JUCEApplicationBase.

◆ perform()

bool juce::JUCEApplication::perform ( const InvocationInfo & info)
overridevirtual

This must actually perform the specified command.

If this target is able to perform the command specified by the commandID field of the InvocationInfo structure, then it should do so, and must return true.

If it can't handle this command, it should return false, which tells the caller to pass the command on to the next target in line.

See also
invoke, ApplicationCommandManager::invoke

Implements juce::ApplicationCommandTarget.

◆ resumed()

void juce::JUCEApplication::resumed ( )
overridevirtual

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

Implements juce::JUCEApplicationBase.

◆ suspended()

void juce::JUCEApplication::suspended ( )
overridevirtual

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

Implements juce::JUCEApplicationBase.

◆ systemRequestedQuit()

void juce::JUCEApplication::systemRequestedQuit ( )
overridevirtual

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.

Implements juce::JUCEApplicationBase.

◆ unhandledException()

void juce::JUCEApplication::unhandledException ( const std::exception * e,
const String & sourceFilename,
int lineNumber )
overridevirtual

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.

Implements juce::JUCEApplicationBase.


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