Browse Source

Fixed a mac initialisation problem.

tags/2021-05-28
Julian Storer 15 years ago
parent
commit
c20daf9740
21 changed files with 165 additions and 230 deletions
  1. +1
    -0
      extras/Jucer (experimental)/Source/Utility/jucer_PresetIDs.h
  2. +21
    -32
      extras/juce demo/Source/ApplicationStartup.cpp
  3. +27
    -27
      extras/juce demo/Source/MainDemoWindow.cpp
  4. +1
    -1
      extras/juce demo/Source/demos/AudioDemoSynthPage.cpp
  5. +7
    -7
      extras/juce demo/Source/demos/CameraDemo.cpp
  6. +5
    -5
      extras/juce demo/Source/demos/FontsAndTextDemo.cpp
  7. +1
    -1
      extras/juce demo/Source/demos/OpenGLDemo.cpp
  8. +7
    -7
      extras/juce demo/Source/demos/QuickTimeDemo.cpp
  9. +4
    -4
      extras/juce demo/Source/demos/WidgetsDemo.cpp
  10. +34
    -50
      juce_amalgamated.cpp
  11. +10
    -22
      juce_amalgamated.h
  12. +9
    -16
      src/application/juce_Application.cpp
  13. +6
    -23
      src/application/juce_Application.h
  14. +4
    -0
      src/core/juce_Initialisation.h
  15. +1
    -1
      src/gui/components/windows/juce_AlertWindow.cpp
  16. +1
    -1
      src/gui/components/windows/juce_DialogWindow.cpp
  17. +3
    -3
      src/native/linux/juce_linux_Messaging.cpp
  18. +0
    -7
      src/native/mac/juce_mac_CoreAudio.cpp
  19. +5
    -6
      src/native/mac/juce_mac_MainMenu.mm
  20. +6
    -5
      src/native/mac/juce_mac_MessageManager.mm
  21. +12
    -12
      src/native/mac/juce_mac_NSViewComponentPeer.mm

+ 1
- 0
extras/Jucer (experimental)/Source/Utility/jucer_PresetIDs.h View File

@@ -100,6 +100,7 @@ namespace Ids
DECLARE_ID (className); DECLARE_ID (className);
DECLARE_ID (classDesc); DECLARE_ID (classDesc);
DECLARE_ID (controlPoint); DECLARE_ID (controlPoint);
DECLARE_ID (createCallback);
const Identifier class_ ("class"); const Identifier class_ ("class");
const Identifier id_ ("id"); const Identifier id_ ("id");


+ 21
- 32
extras/juce demo/Source/ApplicationStartup.cpp View File

@@ -26,50 +26,30 @@
#include "jucedemo_headers.h" #include "jucedemo_headers.h"
#include "MainDemoWindow.h" #include "MainDemoWindow.h"
//============================================================================== //==============================================================================
class JUCEDemoApplication : public JUCEApplication class JUCEDemoApplication : public JUCEApplication
{ {
/* Important! NEVER embed objects directly inside your JUCEApplication class! Use
ONLY pointers to objects, which you should create during the initialise() method
(NOT in the constructor!) and delete in the shutdown() method (NOT in the
destructor!)
This is because the application object gets created before Juce has been properly
initialised, so any embedded objects would also get constructed too soon.
*/
MainDemoWindow* theMainWindow;
public: public:
//============================================================================== //==============================================================================
JUCEDemoApplication() JUCEDemoApplication()
: theMainWindow (0)
{ {
// NEVER do anything in here that could involve any Juce function being called
// - leave all your startup tasks until the initialise() method.
} }
~JUCEDemoApplication() ~JUCEDemoApplication()
{ {
// Your shutdown() method should already have done all the things necessary to
// clean up this app object, so you should never need to put anything in
// the destructor.
// Making any Juce calls in here could be very dangerous...
} }
//============================================================================== //==============================================================================
void initialise (const String& /*commandLine*/) void initialise (const String& /*commandLine*/)
{ {
// just create the main window...
theMainWindow = new MainDemoWindow();
#if JUCE_IPHONE
theMainWindow->setVisible (true);
theMainWindow->setBounds (0, 20, 320, 460);
#else
theMainWindow->centreWithSize (700, 600);
#endif
theMainWindow->setVisible (true);
#if JUCE_IPHONE
theMainWindow.setVisible (true);
theMainWindow.setBounds (0, 20, 320, 460);
#else
theMainWindow.centreWithSize (700, 600);
theMainWindow.setVisible (true);
#endif
// this little function just demonstrates a few system info calls // this little function just demonstrates a few system info calls
Logger::outputDebugString (collectSomeSystemInfo()); Logger::outputDebugString (collectSomeSystemInfo());
@@ -85,18 +65,24 @@ public:
void shutdown() void shutdown()
{ {
delete theMainWindow;
theMainWindow = 0;
// This method is where your app should do any cleaning-up that's needed
// before being shut down.
} }
//============================================================================== //==============================================================================
const String getApplicationName() const String getApplicationName()
{ {
return T("JUCE Demo");
// When you use the Jucer to auto-generate a project, it puts the project's name and version in
// this constant, so we can use that here as our return value. Alternatively you can return
// your own string here, of course.
return ProjectInfo::projectName;
} }
const String getApplicationVersion() const String getApplicationVersion()
{ {
// When you use the Jucer to auto-generate a project, it puts the project's name and version in
// this constant, so we can use that here as our return value. Alternatively you can return
// your own string here, of course.
return ProjectInfo::versionString; return ProjectInfo::versionString;
} }
@@ -112,6 +98,9 @@ public:
} }
private: private:
// This is the main demo window component.
MainDemoWindow theMainWindow;
//============================================================================== //==============================================================================
// this little function just demonstrates a few system info calls // this little function just demonstrates a few system info calls
static const String collectSomeSystemInfo() static const String collectSomeSystemInfo()
@@ -131,7 +120,7 @@ private:
<< "\nCPU has SSE2: " << (SystemStats::hasSSE2() ? "yes" : "no") << "\nCPU has SSE2: " << (SystemStats::hasSSE2() ? "yes" : "no")
<< "\nCPU has 3DNOW: " << (SystemStats::has3DNow() ? "yes" : "no") << "\nCPU has 3DNOW: " << (SystemStats::has3DNow() ? "yes" : "no")
<< "\nMemory size: " << SystemStats::getMemorySizeInMegabytes() << "MB" << "\nMemory size: " << SystemStats::getMemorySizeInMegabytes() << "MB"
<< "\nFound network card MAC addresses: " << SystemStats::getMACAddressStrings().joinIntoString (T(", "))
<< "\nFound network card MAC addresses: " << SystemStats::getMACAddressStrings().joinIntoString (", ")
<< "\nCurrent executable file: " << File::getSpecialLocation (File::currentExecutableFile).getFullPathName() << "\nCurrent executable file: " << File::getSpecialLocation (File::currentExecutableFile).getFullPathName()
<< "\nCurrent application file: " << File::getSpecialLocation (File::currentApplicationFile).getFullPathName() << "\nCurrent application file: " << File::getSpecialLocation (File::currentApplicationFile).getFullPathName()
<< "\nCurrent working directory: " << File::getCurrentWorkingDirectory().getFullPathName() << "\nCurrent working directory: " << File::getCurrentWorkingDirectory().getFullPathName()


+ 27
- 27
extras/juce demo/Source/MainDemoWindow.cpp View File

@@ -107,9 +107,9 @@ public:
//============================================================================== //==============================================================================
const StringArray getMenuBarNames() const StringArray getMenuBarNames()
{ {
const tchar* const names[] = { T("Demo"), T("Look-and-feel"), 0 };
const char* const names[] = { "Demo", "Look-and-feel", 0 };
return StringArray ((const tchar**) names);
return StringArray (names);
} }
const PopupMenu getMenuForIndex (int menuIndex, const String& /*menuName*/) const PopupMenu getMenuForIndex (int menuIndex, const String& /*menuName*/)
@@ -224,61 +224,61 @@ public:
// that this object can perform.. // that this object can perform..
void getCommandInfo (CommandID commandID, ApplicationCommandInfo& result) void getCommandInfo (CommandID commandID, ApplicationCommandInfo& result)
{ {
const String generalCategory (T("General"));
const String demosCategory (T("Demos"));
const String generalCategory ("General");
const String demosCategory ("Demos");
switch (commandID) switch (commandID)
{ {
case showRendering: case showRendering:
result.setInfo (T("Graphics Rendering"), T("Shows the graphics demo"), demosCategory, 0);
result.setInfo ("Graphics Rendering", "Shows the graphics demo", demosCategory, 0);
result.setTicked (currentDemoId == showRendering); result.setTicked (currentDemoId == showRendering);
result.addDefaultKeypress (T('1'), ModifierKeys::commandModifier); result.addDefaultKeypress (T('1'), ModifierKeys::commandModifier);
break; break;
case showFontsAndText: case showFontsAndText:
result.setInfo (T("Fonts and Text"), T("Shows the fonts & text demo"), demosCategory, 0);
result.setInfo ("Fonts and Text", "Shows the fonts & text demo", demosCategory, 0);
result.setTicked (currentDemoId == showFontsAndText); result.setTicked (currentDemoId == showFontsAndText);
result.addDefaultKeypress (T('2'), ModifierKeys::commandModifier); result.addDefaultKeypress (T('2'), ModifierKeys::commandModifier);
break; break;
case showWidgets: case showWidgets:
result.setInfo (T("Widgets"), T("Shows the widgets demo"), demosCategory, 0);
result.setInfo ("Widgets", "Shows the widgets demo", demosCategory, 0);
result.setTicked (currentDemoId == showWidgets); result.setTicked (currentDemoId == showWidgets);
result.addDefaultKeypress (T('3'), ModifierKeys::commandModifier); result.addDefaultKeypress (T('3'), ModifierKeys::commandModifier);
break; break;
case showThreading: case showThreading:
result.setInfo (T("Multithreading"), T("Shows the threading demo"), demosCategory, 0);
result.setInfo ("Multithreading", "Shows the threading demo", demosCategory, 0);
result.setTicked (currentDemoId == showThreading); result.setTicked (currentDemoId == showThreading);
result.addDefaultKeypress (T('4'), ModifierKeys::commandModifier); result.addDefaultKeypress (T('4'), ModifierKeys::commandModifier);
break; break;
case showTreeView: case showTreeView:
result.setInfo (T("Treeviews"), T("Shows the treeviews demo"), demosCategory, 0);
result.setInfo ("Treeviews", "Shows the treeviews demo", demosCategory, 0);
result.setTicked (currentDemoId == showTreeView); result.setTicked (currentDemoId == showTreeView);
result.addDefaultKeypress (T('5'), ModifierKeys::commandModifier); result.addDefaultKeypress (T('5'), ModifierKeys::commandModifier);
break; break;
case showTable: case showTable:
result.setInfo (T("Table Components"), T("Shows the table component demo"), demosCategory, 0);
result.setInfo ("Table Components", "Shows the table component demo", demosCategory, 0);
result.setTicked (currentDemoId == showTable); result.setTicked (currentDemoId == showTable);
result.addDefaultKeypress (T('6'), ModifierKeys::commandModifier); result.addDefaultKeypress (T('6'), ModifierKeys::commandModifier);
break; break;
case showAudio: case showAudio:
result.setInfo (T("Audio"), T("Shows the audio demo"), demosCategory, 0);
result.setInfo ("Audio", "Shows the audio demo", demosCategory, 0);
result.setTicked (currentDemoId == showAudio); result.setTicked (currentDemoId == showAudio);
result.addDefaultKeypress (T('7'), ModifierKeys::commandModifier); result.addDefaultKeypress (T('7'), ModifierKeys::commandModifier);
break; break;
case showDragAndDrop: case showDragAndDrop:
result.setInfo (T("Drag-and-drop"), T("Shows the drag & drop demo"), demosCategory, 0);
result.setInfo ("Drag-and-drop", "Shows the drag & drop demo", demosCategory, 0);
result.setTicked (currentDemoId == showDragAndDrop); result.setTicked (currentDemoId == showDragAndDrop);
result.addDefaultKeypress (T('8'), ModifierKeys::commandModifier); result.addDefaultKeypress (T('8'), ModifierKeys::commandModifier);
break; break;
case showOpenGL: case showOpenGL:
result.setInfo (T("OpenGL"), T("Shows the OpenGL demo"), demosCategory, 0);
result.setInfo ("OpenGL", "Shows the OpenGL demo", demosCategory, 0);
result.addDefaultKeypress (T('9'), ModifierKeys::commandModifier); result.addDefaultKeypress (T('9'), ModifierKeys::commandModifier);
result.setTicked (currentDemoId == showOpenGL); result.setTicked (currentDemoId == showOpenGL);
#if ! JUCE_OPENGL #if ! JUCE_OPENGL
@@ -287,7 +287,7 @@ public:
break; break;
case showQuicktime: case showQuicktime:
result.setInfo (T("Quicktime"), T("Shows the Quicktime demo"), demosCategory, 0);
result.setInfo ("Quicktime", "Shows the Quicktime demo", demosCategory, 0);
result.addDefaultKeypress (T('b'), ModifierKeys::commandModifier); result.addDefaultKeypress (T('b'), ModifierKeys::commandModifier);
result.setTicked (currentDemoId == showQuicktime); result.setTicked (currentDemoId == showQuicktime);
#if ! (JUCE_QUICKTIME && ! JUCE_LINUX) #if ! (JUCE_QUICKTIME && ! JUCE_LINUX)
@@ -296,7 +296,7 @@ public:
break; break;
case showCamera: case showCamera:
result.setInfo (T("Camera Capture"), T("Shows the camera demo"), demosCategory, 0);
result.setInfo ("Camera Capture", "Shows the camera demo", demosCategory, 0);
result.addDefaultKeypress (T('c'), ModifierKeys::commandModifier); result.addDefaultKeypress (T('c'), ModifierKeys::commandModifier);
result.setTicked (currentDemoId == showCamera); result.setTicked (currentDemoId == showCamera);
#if ! JUCE_USE_CAMERA #if ! JUCE_USE_CAMERA
@@ -305,7 +305,7 @@ public:
break; break;
case showWebBrowser: case showWebBrowser:
result.setInfo (T("Web Browser"), T("Shows the web browser demo"), demosCategory, 0);
result.setInfo ("Web Browser", "Shows the web browser demo", demosCategory, 0);
result.addDefaultKeypress (T('i'), ModifierKeys::commandModifier); result.addDefaultKeypress (T('i'), ModifierKeys::commandModifier);
result.setTicked (currentDemoId == showWebBrowser); result.setTicked (currentDemoId == showWebBrowser);
#if (! JUCE_WEB_BROWSER) || JUCE_LINUX #if (! JUCE_WEB_BROWSER) || JUCE_LINUX
@@ -314,42 +314,42 @@ public:
break; break;
case showCodeEditor: case showCodeEditor:
result.setInfo (T("Code Editor"), T("Shows the code editor demo"), demosCategory, 0);
result.setInfo ("Code Editor", "Shows the code editor demo", demosCategory, 0);
result.addDefaultKeypress (T('e'), ModifierKeys::commandModifier); result.addDefaultKeypress (T('e'), ModifierKeys::commandModifier);
result.setTicked (currentDemoId == showCodeEditor); result.setTicked (currentDemoId == showCodeEditor);
break; break;
case showInterprocessComms: case showInterprocessComms:
result.setInfo (T("Interprocess Comms"), T("Shows the interprocess communications demo"), demosCategory, 0);
result.setInfo ("Interprocess Comms", "Shows the interprocess communications demo", demosCategory, 0);
result.addDefaultKeypress (T('0'), ModifierKeys::commandModifier); result.addDefaultKeypress (T('0'), ModifierKeys::commandModifier);
result.setTicked (currentDemoId == showInterprocessComms); result.setTicked (currentDemoId == showInterprocessComms);
break; break;
case setDefaultLookAndFeel: case setDefaultLookAndFeel:
result.setInfo (T("Use default look-and-feel"), String::empty, generalCategory, 0);
result.setInfo ("Use default look-and-feel", String::empty, generalCategory, 0);
result.setTicked ((typeid (LookAndFeel) == typeid (getLookAndFeel())) != 0); result.setTicked ((typeid (LookAndFeel) == typeid (getLookAndFeel())) != 0);
break; break;
case setOldSchoolLookAndFeel: case setOldSchoolLookAndFeel:
result.setInfo (T("Use the old, original juce look-and-feel"), String::empty, generalCategory, 0);
result.setInfo ("Use the old, original juce look-and-feel", String::empty, generalCategory, 0);
result.setTicked ((typeid (OldSchoolLookAndFeel) == typeid (getLookAndFeel())) != 0); result.setTicked ((typeid (OldSchoolLookAndFeel) == typeid (getLookAndFeel())) != 0);
break; break;
case useNativeTitleBar: case useNativeTitleBar:
result.setInfo (T("Use native window title bar"), String::empty, generalCategory, 0);
result.setInfo ("Use native window title bar", String::empty, generalCategory, 0);
result.setTicked (mainWindow->isUsingNativeTitleBar()); result.setTicked (mainWindow->isUsingNativeTitleBar());
break; break;
#if JUCE_MAC #if JUCE_MAC
case useNativeMenus: case useNativeMenus:
result.setInfo (T("Use the native OSX menu bar"), String::empty, generalCategory, 0);
result.setInfo ("Use the native OSX menu bar", String::empty, generalCategory, 0);
result.setTicked (MenuBarModel::getMacMainMenu() != 0); result.setTicked (MenuBarModel::getMacMainMenu() != 0);
break; break;
#endif #endif
#if ! JUCE_LINUX #if ! JUCE_LINUX
case goToKioskMode: case goToKioskMode:
result.setInfo (T("Show full-screen kiosk mode"), String::empty, generalCategory, 0);
result.setInfo ("Show full-screen kiosk mode", String::empty, generalCategory, 0);
result.setTicked (Desktop::getInstance().getKioskModeComponent() != 0); result.setTicked (Desktop::getInstance().getKioskModeComponent() != 0);
break; break;
#endif #endif
@@ -509,11 +509,11 @@ public:
g.fillAll (Colours::lightblue); g.fillAll (Colours::lightblue);
g.setColour (Colours::black); g.setColour (Colours::black);
g.setFont ((float) icon.getHeight(), Font::bold); g.setFont ((float) icon.getHeight(), Font::bold);
g.drawText (T("j"), 0, 0, icon.getWidth(), icon.getHeight(), Justification::centred, false);
g.drawText ("j", 0, 0, icon.getWidth(), icon.getHeight(), Justification::centred, false);
setIconImage (icon); setIconImage (icon);
setIconTooltip (T("Juce Demo App!"));
setIconTooltip ("Juce Demo App!");
} }
~DemoTaskbarComponent() ~DemoTaskbarComponent()
@@ -523,7 +523,7 @@ public:
void mouseDown (const MouseEvent&) void mouseDown (const MouseEvent&)
{ {
PopupMenu m; PopupMenu m;
m.addItem (1, T("Quit the Juce demo"));
m.addItem (1, "Quit the Juce demo");
const int result = m.show(); const int result = m.show();
@@ -536,7 +536,7 @@ public:
//============================================================================== //==============================================================================
MainDemoWindow::MainDemoWindow() MainDemoWindow::MainDemoWindow()
: DocumentWindow (T("JUCE Demo!"),
: DocumentWindow ("JUCE Demo!",
Colours::azure, Colours::azure,
DocumentWindow::allButtons, DocumentWindow::allButtons,
true) true)


+ 1
- 1
extras/juce demo/Source/demos/AudioDemoSynthPage.cpp View File

@@ -203,7 +203,7 @@ public:
BigInteger allNotes; BigInteger allNotes;
allNotes.setRange (0, 128, true); allNotes.setRange (0, 128, true);
synth.addSound (new SamplerSound (T("demo sound"),
synth.addSound (new SamplerSound ("demo sound",
*audioReader, *audioReader,
allNotes, allNotes,
74, // root midi note 74, // root midi note


+ 7
- 7
extras/juce demo/Source/demos/CameraDemo.cpp View File

@@ -38,22 +38,22 @@ public:
//============================================================================== //==============================================================================
CameraDemo() CameraDemo()
{ {
setName (T("Camera"));
setName ("Camera");
cameraDevice = 0; cameraDevice = 0;
cameraPreviewComp = 0; cameraPreviewComp = 0;
recordingMovie = false; recordingMovie = false;
addAndMakeVisible (cameraSelectorComboBox = new ComboBox (T("Camera")));
addAndMakeVisible (cameraSelectorComboBox = new ComboBox ("Camera"));
createListOfCameras(); createListOfCameras();
cameraSelectorComboBox->setSelectedId (1); cameraSelectorComboBox->setSelectedId (1);
cameraSelectorComboBox->addListener (this); cameraSelectorComboBox->addListener (this);
addAndMakeVisible (snapshotButton = new TextButton (T("Take a snapshot")));
addAndMakeVisible (snapshotButton = new TextButton ("Take a snapshot"));
snapshotButton->addButtonListener (this); snapshotButton->addButtonListener (this);
snapshotButton->setEnabled (false); snapshotButton->setEnabled (false);
addAndMakeVisible (recordMovieButton = new TextButton (T("Record a movie file (to your desktop)...")));
addAndMakeVisible (recordMovieButton = new TextButton ("Record a movie file (to your desktop)..."));
recordMovieButton->addButtonListener (this); recordMovieButton->addButtonListener (this);
recordMovieButton->setEnabled (false); recordMovieButton->setEnabled (false);
@@ -133,18 +133,18 @@ public:
recordingMovie = true; recordingMovie = true;
File file (File::getSpecialLocation (File::userDesktopDirectory) File file (File::getSpecialLocation (File::userDesktopDirectory)
.getNonexistentChildFile (T("JuceCameraDemo"),
.getNonexistentChildFile ("JuceCameraDemo",
CameraDevice::getFileExtension())); CameraDevice::getFileExtension()));
cameraDevice->startRecordingToFile (file); cameraDevice->startRecordingToFile (file);
recordMovieButton->setButtonText (T("Stop Recording"));
recordMovieButton->setButtonText ("Stop Recording");
} }
else else
{ {
// Already recording, so stop... // Already recording, so stop...
recordingMovie = false; recordingMovie = false;
cameraDevice->stopRecording(); cameraDevice->stopRecording();
recordMovieButton->setButtonText (T("Start recording (to a file on your desktop)"));
recordMovieButton->setButtonText ("Start recording (to a file on your desktop)");
} }
} }
else else


+ 5
- 5
extras/juce demo/Source/demos/FontsAndTextDemo.cpp View File

@@ -49,11 +49,11 @@ public:
//============================================================================== //==============================================================================
FontsAndTextDemo() FontsAndTextDemo()
{ {
setName (T("Fonts"));
setName ("Fonts");
Font::findFonts (fonts); Font::findFonts (fonts);
addAndMakeVisible (listBox = new ListBox (T("fonts"), this));
addAndMakeVisible (listBox = new ListBox ("fonts", this));
listBox->setRowHeight (28); listBox->setRowHeight (28);
addAndMakeVisible (textBox = new TextEditor()); addAndMakeVisible (textBox = new TextEditor());
@@ -63,12 +63,12 @@ public:
textBox->setMultiLine (true, true); textBox->setMultiLine (true, true);
textBox->setReturnKeyStartsNewLine (true); textBox->setReturnKeyStartsNewLine (true);
textBox->setText (T("The Quick Brown Fox Jumps Over The Lazy Dog\n\nAa Bb Cc Dd Ee Ff Gg Hh Ii Jj Kk Ll Mm Nn Oo Pp Qq Rr Ss Tt Uu Vv Ww Xx Yy Zz 0123456789"));
textBox->setText ("The Quick Brown Fox Jumps Over The Lazy Dog\n\nAa Bb Cc Dd Ee Ff Gg Hh Ii Jj Kk Ll Mm Nn Oo Pp Qq Rr Ss Tt Uu Vv Ww Xx Yy Zz 0123456789");
addAndMakeVisible (boldButton = new ToggleButton (T("bold")));
addAndMakeVisible (boldButton = new ToggleButton ("bold"));
boldButton->addButtonListener (this); boldButton->addButtonListener (this);
addAndMakeVisible (italicButton = new ToggleButton (T("italic")));
addAndMakeVisible (italicButton = new ToggleButton ("italic"));
italicButton->addButtonListener (this); italicButton->addButtonListener (this);
addAndMakeVisible (sizeSlider = new Slider ("Size")); addAndMakeVisible (sizeSlider = new Slider ("Size"));


+ 1
- 1
extras/juce demo/Source/demos/OpenGLDemo.cpp View File

@@ -271,7 +271,7 @@ public:
//============================================================================== //==============================================================================
OpenGLDemo() OpenGLDemo()
{ {
setName (T("OpenGL"));
setName ("OpenGL");
canvas = new DemoOpenGLCanvas(); canvas = new DemoOpenGLCanvas();
addAndMakeVisible (canvas); addAndMakeVisible (canvas);


+ 7
- 7
extras/juce demo/Source/demos/QuickTimeDemo.cpp View File

@@ -38,14 +38,14 @@ public:
addAndMakeVisible (qtComp = new QuickTimeMovieComponent()); addAndMakeVisible (qtComp = new QuickTimeMovieComponent());
// and a file-chooser.. // and a file-chooser..
addAndMakeVisible (fileChooser = new FilenameComponent (T("movie"),
addAndMakeVisible (fileChooser = new FilenameComponent ("movie",
File::nonexistent, File::nonexistent,
true, false, false, true, false, false,
T("*.*"),
"*.*",
String::empty, String::empty,
T("(choose a video file to play)")));
"(choose a video file to play)"));
fileChooser->addListener (this); fileChooser->addListener (this);
fileChooser->setBrowseButtonText (T("browse"));
fileChooser->setBrowseButtonText ("browse");
} }
~QuickTimeWindowWithFileBrowser() ~QuickTimeWindowWithFileBrowser()
@@ -71,8 +71,8 @@ public:
else else
{ {
AlertWindow::showMessageBox (AlertWindow::WarningIcon, AlertWindow::showMessageBox (AlertWindow::WarningIcon,
T("Couldn't load the file!"),
T("Sorry, QuickTime didn't manage to load that file!"));
"Couldn't load the file!",
"Sorry, QuickTime didn't manage to load that file!");
} }
} }
@@ -89,7 +89,7 @@ public:
//============================================================================== //==============================================================================
QuickTimeDemo() QuickTimeDemo()
{ {
setName (T("QuickTime"));
setName ("QuickTime");
// add a movie component.. // add a movie component..
addAndMakeVisible (qtComp1 = new QuickTimeWindowWithFileBrowser()); addAndMakeVisible (qtComp1 = new QuickTimeWindowWithFileBrowser());


+ 4
- 4
extras/juce demo/Source/demos/WidgetsDemo.cpp View File

@@ -513,7 +513,7 @@ public:
//============================================================================== //==============================================================================
// create an image-only button from these drawables.. // create an image-only button from these drawables..
db = new DrawableButton (T("Button 2"), DrawableButton::ImageFitted);
db = new DrawableButton ("Button 2", DrawableButton::ImageFitted);
db->setImages (&normal, &over, &down); db->setImages (&normal, &over, &down);
db->setClickingTogglesState (true); db->setClickingTogglesState (true);
@@ -524,7 +524,7 @@ public:
//============================================================================== //==============================================================================
// create an image-on-button-shape button from the same drawables.. // create an image-on-button-shape button from the same drawables..
db = new DrawableButton (T("Button 3"), DrawableButton::ImageOnButtonBackground);
db = new DrawableButton ("Button 3", DrawableButton::ImageOnButtonBackground);
db->setImages (&normal, 0, 0); db->setImages (&normal, 0, 0);
addAndMakeVisible (db); addAndMakeVisible (db);
@@ -532,7 +532,7 @@ public:
db->setTooltip ("this is a DrawableButton on a standard button background"); db->setTooltip ("this is a DrawableButton on a standard button background");
//============================================================================== //==============================================================================
db = new DrawableButton (T("Button 4"), DrawableButton::ImageOnButtonBackground);
db = new DrawableButton ("Button 4", DrawableButton::ImageOnButtonBackground);
db->setImages (&normal, &over, &down); db->setImages (&normal, &over, &down);
db->setClickingTogglesState (true); db->setClickingTogglesState (true);
db->setBackgroundColours (Colours::white, Colours::yellow); db->setBackgroundColours (Colours::white, Colours::yellow);
@@ -1144,7 +1144,7 @@ public:
enableButton = new ToggleButton ("enable/disable components"); enableButton = new ToggleButton ("enable/disable components");
addAndMakeVisible (enableButton); addAndMakeVisible (enableButton);
enableButton->setBounds (230, 10, 180, 24); enableButton->setBounds (230, 10, 180, 24);
enableButton->setTooltip (T("toggle button"));
enableButton->setTooltip ("toggle button");
enableButton->setToggleState (true, false); enableButton->setToggleState (true, false);
enableButton->addButtonListener (this); enableButton->addButtonListener (this);
} }


+ 34
- 50
juce_amalgamated.cpp View File

@@ -17274,11 +17274,15 @@ END_JUCE_NAMESPACE
/*** Start of inlined file: juce_Application.cpp ***/ /*** Start of inlined file: juce_Application.cpp ***/
BEGIN_JUCE_NAMESPACE BEGIN_JUCE_NAMESPACE


#if JUCE_MAC
extern void juce_initialiseMacMainMenu();
#endif

JUCEApplication::JUCEApplication() JUCEApplication::JUCEApplication()
: appReturnValue (0), : appReturnValue (0),
stillInitialising (true) stillInitialising (true)
{ {
jassert (appInstance == 0);
jassert (isStandaloneApp && appInstance == 0);
appInstance = this; appInstance = this;
} }


@@ -17294,23 +17298,9 @@ JUCEApplication::~JUCEApplication()
appInstance = 0; appInstance = 0;
} }


bool JUCEApplication::isStandaloneApp = false;
JUCEApplication* JUCEApplication::appInstance = 0; JUCEApplication* JUCEApplication::appInstance = 0;


JUCEApplication* JUCEApplication::getInstance() throw()
{
return appInstance;
}

bool JUCEApplication::isInitialising() const throw()
{
return stillInitialising;
}

const String JUCEApplication::getApplicationVersion()
{
return String::empty;
}

bool JUCEApplication::moreThanOneInstanceAllowed() bool JUCEApplication::moreThanOneInstanceAllowed()
{ {
return true; return true;
@@ -17415,6 +17405,10 @@ bool JUCEApplication::initialiseApp (const String& commandLine)
// let the app do its setting-up.. // let the app do its setting-up..
initialise (commandLineParameters); initialise (commandLineParameters);


#if JUCE_MAC
juce_initialiseMacMainMenu(); // needs to be called after the app object has created, to get its name
#endif

// register for broadcast new app messages // register for broadcast new app messages
MessageManager::getInstance()->registerBroadcastListener (this); MessageManager::getInstance()->registerBroadcastListener (this);


@@ -75819,7 +75813,7 @@ AlertWindow::AlertWindow (const String& title,
} }
} }


if (JUCEApplication::getInstance() == 0)
if (! JUCEApplication::isStandaloneApp)
setAlwaysOnTop (true); // for a plugin, make it always-on-top because the host windows are often top-level setAlwaysOnTop (true); // for a plugin, make it always-on-top because the host windows are often top-level


lookAndFeelChanged(); lookAndFeelChanged();
@@ -77181,7 +77175,7 @@ public:
TempDialogWindow (const String& title, const Colour& colour, const bool escapeCloses) TempDialogWindow (const String& title, const Colour& colour, const bool escapeCloses)
: DialogWindow (title, colour, escapeCloses, true) : DialogWindow (title, colour, escapeCloses, true)
{ {
if (JUCEApplication::getInstance() == 0)
if (! JUCEApplication::isStandaloneApp)
setAlwaysOnTop (true); // for a plugin, make it always-on-top because the host windows are often top-level setAlwaysOnTop (true); // for a plugin, make it always-on-top because the host windows are often top-level
} }


@@ -255222,7 +255216,7 @@ namespace LinuxErrorHandling
{ {
DBG ("ERROR: connection to X server broken.. terminating."); DBG ("ERROR: connection to X server broken.. terminating.");


if (JUCEApplication::getInstance() != 0)
if (JUCEApplication::isStandaloneApp)
MessageManager::getInstance()->stopDispatchLoop(); MessageManager::getInstance()->stopDispatchLoop();


errorOccurred = true; errorOccurred = true;
@@ -255289,7 +255283,7 @@ void MessageManager::doPlatformSpecificInitialisation()
// This is fatal! Print error and closedown // This is fatal! Print error and closedown
Logger::outputDebugString ("Failed to initialise xlib thread support."); Logger::outputDebugString ("Failed to initialise xlib thread support.");


if (JUCEApplication::getInstance() != 0)
if (JUCEApplication::isStandaloneApp)
Process::terminate(); Process::terminate();


return; return;
@@ -255391,7 +255385,7 @@ bool juce_dispatchNextMessageOnSystemQueue (bool returnIfNoPendingMessages)
{ {
LinuxErrorHandling::errorOccurred = true; LinuxErrorHandling::errorOccurred = true;


if (JUCEApplication::getInstance() != 0)
if (JUCEApplication::isStandaloneApp)
Process::terminate(); Process::terminate();


break; break;
@@ -270328,15 +270322,15 @@ END_JUCE_NAMESPACE


- (void) mouseDown: (NSEvent*) ev - (void) mouseDown: (NSEvent*) ev
{ {
// In some host situations, the host will stop modal loops from working
// correctly if they're called from a mouse event, so we'll trigger
// the event asynchronously..
if (JUCEApplication::getInstance() == 0)
if (JUCEApplication::isStandaloneApp)
[self asyncMouseDown: ev];
else
// In some host situations, the host will stop modal loops from working
// correctly if they're called from a mouse event, so we'll trigger
// the event asynchronously..
[self performSelectorOnMainThread: @selector (asyncMouseDown:) [self performSelectorOnMainThread: @selector (asyncMouseDown:)
withObject: ev withObject: ev
waitUntilDone: NO]; waitUntilDone: NO];
else
[self asyncMouseDown: ev];
} }


- (void) asyncMouseDown: (NSEvent*) ev - (void) asyncMouseDown: (NSEvent*) ev
@@ -270347,15 +270341,15 @@ END_JUCE_NAMESPACE


- (void) mouseUp: (NSEvent*) ev - (void) mouseUp: (NSEvent*) ev
{ {
// In some host situations, the host will stop modal loops from working
// correctly if they're called from a mouse event, so we'll trigger
// the event asynchronously..
if (JUCEApplication::getInstance() == 0)
if (! JUCEApplication::isStandaloneApp)
[self asyncMouseUp: ev];
else
// In some host situations, the host will stop modal loops from working
// correctly if they're called from a mouse event, so we'll trigger
// the event asynchronously..
[self performSelectorOnMainThread: @selector (asyncMouseUp:) [self performSelectorOnMainThread: @selector (asyncMouseUp:)
withObject: ev withObject: ev
waitUntilDone: NO]; waitUntilDone: NO];
else
[self asyncMouseUp: ev];
} }


- (void) asyncMouseUp: (NSEvent*) ev - (void) asyncMouseUp: (NSEvent*) ev
@@ -273174,14 +273168,14 @@ static NSMenu* createStandardAppMenu (NSMenu* menu, const String& appName,
[item release]; [item release];


item = [[NSMenuItem alloc] initWithTitle: NSLocalizedString (@"Hide Others", nil) item = [[NSMenuItem alloc] initWithTitle: NSLocalizedString (@"Hide Others", nil)
action: @selector (hideOtherApplications:) keyEquivalent: @"h"];
action: @selector (hideOtherApplications:) keyEquivalent: @"h"];
[item setKeyEquivalentModifierMask: NSCommandKeyMask | NSAlternateKeyMask]; [item setKeyEquivalentModifierMask: NSCommandKeyMask | NSAlternateKeyMask];
[item setTarget: NSApp]; [item setTarget: NSApp];
[menu addItem: item]; [menu addItem: item];
[item release]; [item release];


item = [[NSMenuItem alloc] initWithTitle: NSLocalizedString (@"Show All", nil) item = [[NSMenuItem alloc] initWithTitle: NSLocalizedString (@"Show All", nil)
action: @selector (unhideAllApplications:) keyEquivalent: @""];
action: @selector (unhideAllApplications:) keyEquivalent: @""];
[item setTarget: NSApp]; [item setTarget: NSApp];
[menu addItem: item]; [menu addItem: item];
[item release]; [item release];
@@ -273203,7 +273197,7 @@ static NSMenu* createStandardAppMenu (NSMenu* menu, const String& appName,
static void rebuildMainMenu (const PopupMenu* extraItems) static void rebuildMainMenu (const PopupMenu* extraItems)
{ {
// this can't be used in a plugin! // this can't be used in a plugin!
jassert (JUCEApplication::getInstance() != 0);
jassert (JUCEApplication::isStandaloneApp);


if (JUCEApplication::getInstance() != 0) if (JUCEApplication::getInstance() != 0)
{ {
@@ -273261,9 +273255,9 @@ MenuBarModel* MenuBarModel::getMacMainMenu()
? JuceMainMenuHandler::instance->currentModel : 0; ? JuceMainMenuHandler::instance->currentModel : 0;
} }


void initialiseMainMenu()
void juce_initialiseMacMainMenu()
{ {
if (JUCEApplication::getInstance() != 0) // only needed in an app
if (JuceMainMenuHandler::instance == 0)
rebuildMainMenu (0); rebuildMainMenu (0);
} }


@@ -274676,7 +274670,7 @@ using namespace JUCE_NAMESPACE;


NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; NSNotificationCenter* center = [NSNotificationCenter defaultCenter];


if (JUCEApplication::getInstance() != 0)
if (JUCEApplication::isStandaloneApp)
{ {
oldDelegate = [NSApp delegate]; oldDelegate = [NSApp delegate];
[NSApp setDelegate: self]; [NSApp setDelegate: self];
@@ -274922,8 +274916,6 @@ void MessageManager::doPlatformSpecificInitialisation()
[NSThread detachNewThreadSelector: @selector (dummyMethod) [NSThread detachNewThreadSelector: @selector (dummyMethod)
toTarget: juceAppDelegate toTarget: juceAppDelegate
withObject: nil]; withObject: nil];

initialiseMainMenu();
} }


void MessageManager::doPlatformSpecificShutdown() void MessageManager::doPlatformSpecificShutdown()
@@ -274947,8 +274939,7 @@ void MessageManager::broadcastMessage (const String& value) throw()
{ {
} }


void* MessageManager::callFunctionOnMessageThread (MessageCallbackFunction* callback,
void* data)
void* MessageManager::callFunctionOnMessageThread (MessageCallbackFunction* callback, void* data)
{ {
if (isThisTheMessageThread()) if (isThisTheMessageThread())
{ {
@@ -276402,7 +276393,6 @@ public:


if (OK (AudioObjectGetPropertyData (kAudioObjectSystemObject, &pa, 0, 0, &size, devs))) if (OK (AudioObjectGetPropertyData (kAudioObjectSystemObject, &pa, 0, 0, &size, devs)))
{ {
static bool alreadyLogged = false;
const int num = size / (int) sizeof (AudioDeviceID); const int num = size / (int) sizeof (AudioDeviceID);
for (int i = 0; i < num; ++i) for (int i = 0; i < num; ++i)
{ {
@@ -276413,10 +276403,6 @@ public:
if (OK (AudioObjectGetPropertyData (devs[i], &pa, 0, 0, &size, name))) if (OK (AudioObjectGetPropertyData (devs[i], &pa, 0, 0, &size, name)))
{ {
const String nameString (String::fromUTF8 (name, (int) strlen (name))); const String nameString (String::fromUTF8 (name, (int) strlen (name)));

if (! alreadyLogged)
log ("CoreAudio device: " + nameString);

const int numIns = getNumChannels (devs[i], true); const int numIns = getNumChannels (devs[i], true);
const int numOuts = getNumChannels (devs[i], false); const int numOuts = getNumChannels (devs[i], false);


@@ -276433,8 +276419,6 @@ public:
} }
} }
} }

alreadyLogged = true;
} }
} }




+ 10
- 22
juce_amalgamated.h View File

@@ -13742,6 +13742,7 @@ public:
#define START_JUCE_APPLICATION(AppClass) \ #define START_JUCE_APPLICATION(AppClass) \
int main (int argc, char* argv[]) \ int main (int argc, char* argv[]) \
{ \ { \
JUCE_NAMESPACE::JUCEApplication::isStandaloneApp = true; \
JUCE_NAMESPACE::ScopedJuceInitialiser_GUI libraryInitialiser; \ JUCE_NAMESPACE::ScopedJuceInitialiser_GUI libraryInitialiser; \
return JUCE_NAMESPACE::JUCEApplication::main (argc, (const char**) argv, new AppClass()); \ return JUCE_NAMESPACE::JUCEApplication::main (argc, (const char**) argv, new AppClass()); \
} }
@@ -13752,6 +13753,7 @@ public:
#define START_JUCE_APPLICATION(AppClass) \ #define START_JUCE_APPLICATION(AppClass) \
int main (int, char* argv[]) \ int main (int, char* argv[]) \
{ \ { \
JUCE_NAMESPACE::JUCEApplication::isStandaloneApp = true; \
JUCE_NAMESPACE::ScopedJuceInitialiser_GUI libraryInitialiser; \ JUCE_NAMESPACE::ScopedJuceInitialiser_GUI libraryInitialiser; \
return JUCE_NAMESPACE::JUCEApplication::main (JUCE_NAMESPACE::PlatformUtilities::getCurrentCommandLineParams(), new AppClass()); \ return JUCE_NAMESPACE::JUCEApplication::main (JUCE_NAMESPACE::PlatformUtilities::getCurrentCommandLineParams(), new AppClass()); \
} }
@@ -13760,6 +13762,7 @@ public:
#define START_JUCE_APPLICATION(AppClass) \ #define START_JUCE_APPLICATION(AppClass) \
int WINAPI WinMain (HINSTANCE, HINSTANCE, LPSTR, int) \ int WINAPI WinMain (HINSTANCE, HINSTANCE, LPSTR, int) \
{ \ { \
JUCE_NAMESPACE::JUCEApplication::isStandaloneApp = true; \
JUCE_NAMESPACE::ScopedJuceInitialiser_GUI libraryInitialiser; \ JUCE_NAMESPACE::ScopedJuceInitialiser_GUI libraryInitialiser; \
return JUCE_NAMESPACE::JUCEApplication::main (JUCE_NAMESPACE::PlatformUtilities::getCurrentCommandLineParams(), new AppClass()); \ return JUCE_NAMESPACE::JUCEApplication::main (JUCE_NAMESPACE::PlatformUtilities::getCurrentCommandLineParams(), new AppClass()); \
} }
@@ -13767,6 +13770,7 @@ public:
#define START_JUCE_APPLICATION(AppClass) \ #define START_JUCE_APPLICATION(AppClass) \
int __stdcall WinMain (int, int, const char*, int) \ int __stdcall WinMain (int, int, const char*, int) \
{ \ { \
JUCE_NAMESPACE::JUCEApplication::isStandaloneApp = true; \
JUCE_NAMESPACE::ScopedJuceInitialiser_GUI libraryInitialiser; \ JUCE_NAMESPACE::ScopedJuceInitialiser_GUI libraryInitialiser; \
return JUCE_NAMESPACE::JUCEApplication::main (JUCE_NAMESPACE::PlatformUtilities::getCurrentCommandLineParams(), new AppClass()); \ return JUCE_NAMESPACE::JUCEApplication::main (JUCE_NAMESPACE::PlatformUtilities::getCurrentCommandLineParams(), new AppClass()); \
} }
@@ -27935,22 +27939,16 @@ public:
e.g. @code e.g. @code
class MyJUCEApp : public JUCEApplication class MyJUCEApp : public JUCEApplication
{ {
// NEVER put objects inside a JUCEApplication class - only use pointers to
// objects, which you must create in the initialise() method.
MyApplicationWindow* myMainWindow; MyApplicationWindow* myMainWindow;


public: public:
MyJUCEApp() MyJUCEApp()
: myMainWindow (0) : myMainWindow (0)
{ {
// never create any Juce objects in the constructor - do all your initialisation
// in the initialise() method.
} }


~MyJUCEApp() ~MyJUCEApp()
{ {
// all your shutdown code must have already been done in the shutdown() method -
// nothing should happen in this destructor.
} }


void initialise (const String& commandLine) void initialise (const String& commandLine)
@@ -27980,12 +27978,6 @@ public:
START_JUCE_APPLICATION (MyJUCEApp) START_JUCE_APPLICATION (MyJUCEApp)
@endcode @endcode


Because this object will be created before Juce has properly initialised, you must
NEVER add any member variable objects that will be automatically constructed. Likewise
don't put ANY code in the constructor that could call Juce functions. Any objects that
you want to add to the class must be pointers, which you should instantiate during the
initialise() method, and delete in the shutdown() method.

@see MessageManager, DeletedAtShutdown @see MessageManager, DeletedAtShutdown
*/ */
class JUCE_API JUCEApplication : public ApplicationCommandTarget, class JUCE_API JUCEApplication : public ApplicationCommandTarget,
@@ -28011,7 +28003,7 @@ public:
virtual ~JUCEApplication(); virtual ~JUCEApplication();


/** Returns the global instance of the application object being run. */ /** Returns the global instance of the application object being run. */
static JUCEApplication* getInstance() throw();
static JUCEApplication* getInstance() throw() { return appInstance; }


/** Called when the application starts. /** Called when the application starts.


@@ -28038,7 +28030,7 @@ public:
This is handy for things like splash screens to know when the app's up-and-running This is handy for things like splash screens to know when the app's up-and-running
properly. properly.
*/ */
bool isInitialising() const throw();
bool isInitialising() const throw() { return stillInitialising; }


/* Called to allow the application to clear up before exiting. /* Called to allow the application to clear up before exiting.


@@ -28061,11 +28053,8 @@ public:
virtual const String getApplicationName() = 0; virtual const String getApplicationName() = 0;


/** Returns the application's version number. /** Returns the application's version number.

An application can implement this to give itself a version.
(The default implementation of this just returns an empty string).
*/ */
virtual const String getApplicationVersion();
virtual const String getApplicationVersion() = 0;


/** Checks whether multiple instances of the app are allowed. /** Checks whether multiple instances of the app are allowed.


@@ -28150,11 +28139,8 @@ public:
static int main (const String& commandLine, JUCEApplication* newApp); static int main (const String& commandLine, JUCEApplication* newApp);
/** @internal */ /** @internal */
static int main (int argc, const char* argv[], JUCEApplication* newApp); static int main (int argc, const char* argv[], JUCEApplication* newApp);

/** @internal */ /** @internal */
static void sendUnhandledException (const std::exception* e,
const char* sourceFile,
int lineNumber);
static void sendUnhandledException (const std::exception* e, const char* sourceFile, int lineNumber);


/** @internal */ /** @internal */
ApplicationCommandTarget* getNextCommandTarget(); ApplicationCommandTarget* getNextCommandTarget();
@@ -28170,6 +28156,8 @@ public:
bool initialiseApp (const String& commandLine); bool initialiseApp (const String& commandLine);
/** @internal */ /** @internal */
int shutdownApp(); int shutdownApp();
/** @internal */
static bool isStandaloneApp;


private: private:




+ 9
- 16
src/application/juce_Application.cpp View File

@@ -36,13 +36,16 @@ BEGIN_JUCE_NAMESPACE
#include "../core/juce_PlatformUtilities.h" #include "../core/juce_PlatformUtilities.h"
#include "../text/juce_LocalisedStrings.h" #include "../text/juce_LocalisedStrings.h"
#if JUCE_MAC
extern void juce_initialiseMacMainMenu();
#endif
//============================================================================== //==============================================================================
JUCEApplication::JUCEApplication() JUCEApplication::JUCEApplication()
: appReturnValue (0), : appReturnValue (0),
stillInitialising (true) stillInitialising (true)
{ {
jassert (appInstance == 0);
jassert (isStandaloneApp && appInstance == 0);
appInstance = this; appInstance = this;
} }
@@ -58,24 +61,10 @@ JUCEApplication::~JUCEApplication()
appInstance = 0; appInstance = 0;
} }
bool JUCEApplication::isStandaloneApp = false;
JUCEApplication* JUCEApplication::appInstance = 0; JUCEApplication* JUCEApplication::appInstance = 0;
JUCEApplication* JUCEApplication::getInstance() throw()
{
return appInstance;
}
bool JUCEApplication::isInitialising() const throw()
{
return stillInitialising;
}
//============================================================================== //==============================================================================
const String JUCEApplication::getApplicationVersion()
{
return String::empty;
}
bool JUCEApplication::moreThanOneInstanceAllowed() bool JUCEApplication::moreThanOneInstanceAllowed()
{ {
return true; return true;
@@ -183,6 +172,10 @@ bool JUCEApplication::initialiseApp (const String& commandLine)
// let the app do its setting-up.. // let the app do its setting-up..
initialise (commandLineParameters); initialise (commandLineParameters);
#if JUCE_MAC
juce_initialiseMacMainMenu(); // needs to be called after the app object has created, to get its name
#endif
// register for broadcast new app messages // register for broadcast new app messages
MessageManager::getInstance()->registerBroadcastListener (this); MessageManager::getInstance()->registerBroadcastListener (this);


+ 6
- 23
src/application/juce_Application.h View File

@@ -46,22 +46,16 @@
e.g. @code e.g. @code
class MyJUCEApp : public JUCEApplication class MyJUCEApp : public JUCEApplication
{ {
// NEVER put objects inside a JUCEApplication class - only use pointers to
// objects, which you must create in the initialise() method.
MyApplicationWindow* myMainWindow; MyApplicationWindow* myMainWindow;
public: public:
MyJUCEApp() MyJUCEApp()
: myMainWindow (0) : myMainWindow (0)
{ {
// never create any Juce objects in the constructor - do all your initialisation
// in the initialise() method.
} }
~MyJUCEApp() ~MyJUCEApp()
{ {
// all your shutdown code must have already been done in the shutdown() method -
// nothing should happen in this destructor.
} }
void initialise (const String& commandLine) void initialise (const String& commandLine)
@@ -91,12 +85,6 @@
START_JUCE_APPLICATION (MyJUCEApp) START_JUCE_APPLICATION (MyJUCEApp)
@endcode @endcode
Because this object will be created before Juce has properly initialised, you must
NEVER add any member variable objects that will be automatically constructed. Likewise
don't put ANY code in the constructor that could call Juce functions. Any objects that
you want to add to the class must be pointers, which you should instantiate during the
initialise() method, and delete in the shutdown() method.
@see MessageManager, DeletedAtShutdown @see MessageManager, DeletedAtShutdown
*/ */
class JUCE_API JUCEApplication : public ApplicationCommandTarget, class JUCE_API JUCEApplication : public ApplicationCommandTarget,
@@ -123,7 +111,7 @@ public:
//============================================================================== //==============================================================================
/** Returns the global instance of the application object being run. */ /** Returns the global instance of the application object being run. */
static JUCEApplication* getInstance() throw();
static JUCEApplication* getInstance() throw() { return appInstance; }
//============================================================================== //==============================================================================
/** Called when the application starts. /** Called when the application starts.
@@ -151,7 +139,7 @@ public:
This is handy for things like splash screens to know when the app's up-and-running This is handy for things like splash screens to know when the app's up-and-running
properly. properly.
*/ */
bool isInitialising() const throw();
bool isInitialising() const throw() { return stillInitialising; }
/* Called to allow the application to clear up before exiting. /* Called to allow the application to clear up before exiting.
@@ -175,11 +163,8 @@ public:
virtual const String getApplicationName() = 0; virtual const String getApplicationName() = 0;
/** Returns the application's version number. /** Returns the application's version number.
An application can implement this to give itself a version.
(The default implementation of this just returns an empty string).
*/ */
virtual const String getApplicationVersion();
virtual const String getApplicationVersion() = 0;
/** Checks whether multiple instances of the app are allowed. /** Checks whether multiple instances of the app are allowed.
@@ -266,13 +251,9 @@ public:
static int main (const String& commandLine, JUCEApplication* newApp); static int main (const String& commandLine, JUCEApplication* newApp);
/** @internal */ /** @internal */
static int main (int argc, const char* argv[], JUCEApplication* newApp); static int main (int argc, const char* argv[], JUCEApplication* newApp);
/** @internal */ /** @internal */
static void sendUnhandledException (const std::exception* e,
const char* sourceFile,
int lineNumber);
static void sendUnhandledException (const std::exception* e, const char* sourceFile, int lineNumber);
//==============================================================================
/** @internal */ /** @internal */
ApplicationCommandTarget* getNextCommandTarget(); ApplicationCommandTarget* getNextCommandTarget();
/** @internal */ /** @internal */
@@ -287,6 +268,8 @@ public:
bool initialiseApp (const String& commandLine); bool initialiseApp (const String& commandLine);
/** @internal */ /** @internal */
int shutdownApp(); int shutdownApp();
/** @internal */
static bool isStandaloneApp;
private: private:
//============================================================================== //==============================================================================


+ 4
- 0
src/core/juce_Initialisation.h View File

@@ -139,6 +139,7 @@ public:
#define START_JUCE_APPLICATION(AppClass) \ #define START_JUCE_APPLICATION(AppClass) \
int main (int argc, char* argv[]) \ int main (int argc, char* argv[]) \
{ \ { \
JUCE_NAMESPACE::JUCEApplication::isStandaloneApp = true; \
JUCE_NAMESPACE::ScopedJuceInitialiser_GUI libraryInitialiser; \ JUCE_NAMESPACE::ScopedJuceInitialiser_GUI libraryInitialiser; \
return JUCE_NAMESPACE::JUCEApplication::main (argc, (const char**) argv, new AppClass()); \ return JUCE_NAMESPACE::JUCEApplication::main (argc, (const char**) argv, new AppClass()); \
} }
@@ -149,6 +150,7 @@ public:
#define START_JUCE_APPLICATION(AppClass) \ #define START_JUCE_APPLICATION(AppClass) \
int main (int, char* argv[]) \ int main (int, char* argv[]) \
{ \ { \
JUCE_NAMESPACE::JUCEApplication::isStandaloneApp = true; \
JUCE_NAMESPACE::ScopedJuceInitialiser_GUI libraryInitialiser; \ JUCE_NAMESPACE::ScopedJuceInitialiser_GUI libraryInitialiser; \
return JUCE_NAMESPACE::JUCEApplication::main (JUCE_NAMESPACE::PlatformUtilities::getCurrentCommandLineParams(), new AppClass()); \ return JUCE_NAMESPACE::JUCEApplication::main (JUCE_NAMESPACE::PlatformUtilities::getCurrentCommandLineParams(), new AppClass()); \
} }
@@ -157,6 +159,7 @@ public:
#define START_JUCE_APPLICATION(AppClass) \ #define START_JUCE_APPLICATION(AppClass) \
int WINAPI WinMain (HINSTANCE, HINSTANCE, LPSTR, int) \ int WINAPI WinMain (HINSTANCE, HINSTANCE, LPSTR, int) \
{ \ { \
JUCE_NAMESPACE::JUCEApplication::isStandaloneApp = true; \
JUCE_NAMESPACE::ScopedJuceInitialiser_GUI libraryInitialiser; \ JUCE_NAMESPACE::ScopedJuceInitialiser_GUI libraryInitialiser; \
return JUCE_NAMESPACE::JUCEApplication::main (JUCE_NAMESPACE::PlatformUtilities::getCurrentCommandLineParams(), new AppClass()); \ return JUCE_NAMESPACE::JUCEApplication::main (JUCE_NAMESPACE::PlatformUtilities::getCurrentCommandLineParams(), new AppClass()); \
} }
@@ -164,6 +167,7 @@ public:
#define START_JUCE_APPLICATION(AppClass) \ #define START_JUCE_APPLICATION(AppClass) \
int __stdcall WinMain (int, int, const char*, int) \ int __stdcall WinMain (int, int, const char*, int) \
{ \ { \
JUCE_NAMESPACE::JUCEApplication::isStandaloneApp = true; \
JUCE_NAMESPACE::ScopedJuceInitialiser_GUI libraryInitialiser; \ JUCE_NAMESPACE::ScopedJuceInitialiser_GUI libraryInitialiser; \
return JUCE_NAMESPACE::JUCEApplication::main (JUCE_NAMESPACE::PlatformUtilities::getCurrentCommandLineParams(), new AppClass()); \ return JUCE_NAMESPACE::JUCEApplication::main (JUCE_NAMESPACE::PlatformUtilities::getCurrentCommandLineParams(), new AppClass()); \
} }


+ 1
- 1
src/gui/components/windows/juce_AlertWindow.cpp View File

@@ -106,7 +106,7 @@ AlertWindow::AlertWindow (const String& title,
} }
} }
if (JUCEApplication::getInstance() == 0)
if (! JUCEApplication::isStandaloneApp)
setAlwaysOnTop (true); // for a plugin, make it always-on-top because the host windows are often top-level setAlwaysOnTop (true); // for a plugin, make it always-on-top because the host windows are often top-level
lookAndFeelChanged(); lookAndFeelChanged();


+ 1
- 1
src/gui/components/windows/juce_DialogWindow.cpp View File

@@ -68,7 +68,7 @@ public:
TempDialogWindow (const String& title, const Colour& colour, const bool escapeCloses) TempDialogWindow (const String& title, const Colour& colour, const bool escapeCloses)
: DialogWindow (title, colour, escapeCloses, true) : DialogWindow (title, colour, escapeCloses, true)
{ {
if (JUCEApplication::getInstance() == 0)
if (! JUCEApplication::isStandaloneApp)
setAlwaysOnTop (true); // for a plugin, make it always-on-top because the host windows are often top-level setAlwaysOnTop (true); // for a plugin, make it always-on-top because the host windows are often top-level
} }


+ 3
- 3
src/native/linux/juce_linux_Messaging.cpp View File

@@ -253,7 +253,7 @@ namespace LinuxErrorHandling
{ {
DBG ("ERROR: connection to X server broken.. terminating."); DBG ("ERROR: connection to X server broken.. terminating.");
if (JUCEApplication::getInstance() != 0)
if (JUCEApplication::isStandaloneApp)
MessageManager::getInstance()->stopDispatchLoop(); MessageManager::getInstance()->stopDispatchLoop();
errorOccurred = true; errorOccurred = true;
@@ -322,7 +322,7 @@ void MessageManager::doPlatformSpecificInitialisation()
// This is fatal! Print error and closedown // This is fatal! Print error and closedown
Logger::outputDebugString ("Failed to initialise xlib thread support."); Logger::outputDebugString ("Failed to initialise xlib thread support.");
if (JUCEApplication::getInstance() != 0)
if (JUCEApplication::isStandaloneApp)
Process::terminate(); Process::terminate();
return; return;
@@ -424,7 +424,7 @@ bool juce_dispatchNextMessageOnSystemQueue (bool returnIfNoPendingMessages)
{ {
LinuxErrorHandling::errorOccurred = true; LinuxErrorHandling::errorOccurred = true;
if (JUCEApplication::getInstance() != 0)
if (JUCEApplication::isStandaloneApp)
Process::terminate(); Process::terminate();
break; break;


+ 0
- 7
src/native/mac/juce_mac_CoreAudio.cpp View File

@@ -1145,7 +1145,6 @@ public:
if (OK (AudioObjectGetPropertyData (kAudioObjectSystemObject, &pa, 0, 0, &size, devs))) if (OK (AudioObjectGetPropertyData (kAudioObjectSystemObject, &pa, 0, 0, &size, devs)))
{ {
static bool alreadyLogged = false;
const int num = size / (int) sizeof (AudioDeviceID); const int num = size / (int) sizeof (AudioDeviceID);
for (int i = 0; i < num; ++i) for (int i = 0; i < num; ++i)
{ {
@@ -1156,10 +1155,6 @@ public:
if (OK (AudioObjectGetPropertyData (devs[i], &pa, 0, 0, &size, name))) if (OK (AudioObjectGetPropertyData (devs[i], &pa, 0, 0, &size, name)))
{ {
const String nameString (String::fromUTF8 (name, (int) strlen (name))); const String nameString (String::fromUTF8 (name, (int) strlen (name)));
if (! alreadyLogged)
log ("CoreAudio device: " + nameString);
const int numIns = getNumChannels (devs[i], true); const int numIns = getNumChannels (devs[i], true);
const int numOuts = getNumChannels (devs[i], false); const int numOuts = getNumChannels (devs[i], false);
@@ -1176,8 +1171,6 @@ public:
} }
} }
} }
alreadyLogged = true;
} }
} }


+ 5
- 6
src/native/mac/juce_mac_MainMenu.mm View File

@@ -456,14 +456,14 @@ static NSMenu* createStandardAppMenu (NSMenu* menu, const String& appName,
[item release]; [item release];
item = [[NSMenuItem alloc] initWithTitle: NSLocalizedString (@"Hide Others", nil) item = [[NSMenuItem alloc] initWithTitle: NSLocalizedString (@"Hide Others", nil)
action: @selector (hideOtherApplications:) keyEquivalent: @"h"];
action: @selector (hideOtherApplications:) keyEquivalent: @"h"];
[item setKeyEquivalentModifierMask: NSCommandKeyMask | NSAlternateKeyMask]; [item setKeyEquivalentModifierMask: NSCommandKeyMask | NSAlternateKeyMask];
[item setTarget: NSApp]; [item setTarget: NSApp];
[menu addItem: item]; [menu addItem: item];
[item release]; [item release];
item = [[NSMenuItem alloc] initWithTitle: NSLocalizedString (@"Show All", nil) item = [[NSMenuItem alloc] initWithTitle: NSLocalizedString (@"Show All", nil)
action: @selector (unhideAllApplications:) keyEquivalent: @""];
action: @selector (unhideAllApplications:) keyEquivalent: @""];
[item setTarget: NSApp]; [item setTarget: NSApp];
[menu addItem: item]; [menu addItem: item];
[item release]; [item release];
@@ -485,7 +485,7 @@ static NSMenu* createStandardAppMenu (NSMenu* menu, const String& appName,
static void rebuildMainMenu (const PopupMenu* extraItems) static void rebuildMainMenu (const PopupMenu* extraItems)
{ {
// this can't be used in a plugin! // this can't be used in a plugin!
jassert (JUCEApplication::getInstance() != 0);
jassert (JUCEApplication::isStandaloneApp);
if (JUCEApplication::getInstance() != 0) if (JUCEApplication::getInstance() != 0)
{ {
@@ -543,10 +543,9 @@ MenuBarModel* MenuBarModel::getMacMainMenu()
? JuceMainMenuHandler::instance->currentModel : 0; ? JuceMainMenuHandler::instance->currentModel : 0;
} }
void initialiseMainMenu()
void juce_initialiseMacMainMenu()
{ {
if (JUCEApplication::getInstance() != 0) // only needed in an app
if (JuceMainMenuHandler::instance == 0)
rebuildMainMenu (0); rebuildMainMenu (0);
} }


+ 6
- 5
src/native/mac/juce_mac_MessageManager.mm View File

@@ -27,6 +27,8 @@
// compiled on its own). // compiled on its own).
#if JUCE_INCLUDED_FILE #if JUCE_INCLUDED_FILE
//==============================================================================
/* When you use multiple DLLs which share similarly-named obj-c classes - like /* When you use multiple DLLs which share similarly-named obj-c classes - like
for example having more than one juce plugin loaded into a host, then when a for example having more than one juce plugin loaded into a host, then when a
method is called, the actual code that runs might actually be in a different module method is called, the actual code that runs might actually be in a different module
@@ -170,6 +172,7 @@ using namespace JUCE_NAMESPACE;
#define JuceAppDelegate MakeObjCClassName(JuceAppDelegate) #define JuceAppDelegate MakeObjCClassName(JuceAppDelegate)
//==============================================================================
@interface JuceAppDelegate : NSObject @interface JuceAppDelegate : NSObject
{ {
@private @private
@@ -201,7 +204,7 @@ using namespace JUCE_NAMESPACE;
NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; NSNotificationCenter* center = [NSNotificationCenter defaultCenter];
if (JUCEApplication::getInstance() != 0)
if (JUCEApplication::isStandaloneApp)
{ {
oldDelegate = [NSApp delegate]; oldDelegate = [NSApp delegate];
[NSApp setDelegate: self]; [NSApp setDelegate: self];
@@ -287,6 +290,7 @@ using namespace JUCE_NAMESPACE;
@end @end
//==============================================================================
BEGIN_JUCE_NAMESPACE BEGIN_JUCE_NAMESPACE
static JuceAppDelegate* juceAppDelegate = 0; static JuceAppDelegate* juceAppDelegate = 0;
@@ -448,8 +452,6 @@ void MessageManager::doPlatformSpecificInitialisation()
[NSThread detachNewThreadSelector: @selector (dummyMethod) [NSThread detachNewThreadSelector: @selector (dummyMethod)
toTarget: juceAppDelegate toTarget: juceAppDelegate
withObject: nil]; withObject: nil];
initialiseMainMenu();
} }
void MessageManager::doPlatformSpecificShutdown() void MessageManager::doPlatformSpecificShutdown()
@@ -473,8 +475,7 @@ void MessageManager::broadcastMessage (const String& value) throw()
{ {
} }
void* MessageManager::callFunctionOnMessageThread (MessageCallbackFunction* callback,
void* data)
void* MessageManager::callFunctionOnMessageThread (MessageCallbackFunction* callback, void* data)
{ {
if (isThisTheMessageThread()) if (isThisTheMessageThread())
{ {


+ 12
- 12
src/native/mac/juce_mac_NSViewComponentPeer.mm View File

@@ -328,15 +328,15 @@ END_JUCE_NAMESPACE
//============================================================================== //==============================================================================
- (void) mouseDown: (NSEvent*) ev - (void) mouseDown: (NSEvent*) ev
{ {
// In some host situations, the host will stop modal loops from working
// correctly if they're called from a mouse event, so we'll trigger
// the event asynchronously..
if (JUCEApplication::getInstance() == 0)
if (JUCEApplication::isStandaloneApp)
[self asyncMouseDown: ev];
else
// In some host situations, the host will stop modal loops from working
// correctly if they're called from a mouse event, so we'll trigger
// the event asynchronously..
[self performSelectorOnMainThread: @selector (asyncMouseDown:) [self performSelectorOnMainThread: @selector (asyncMouseDown:)
withObject: ev withObject: ev
waitUntilDone: NO]; waitUntilDone: NO];
else
[self asyncMouseDown: ev];
} }
- (void) asyncMouseDown: (NSEvent*) ev - (void) asyncMouseDown: (NSEvent*) ev
@@ -347,15 +347,15 @@ END_JUCE_NAMESPACE
- (void) mouseUp: (NSEvent*) ev - (void) mouseUp: (NSEvent*) ev
{ {
// In some host situations, the host will stop modal loops from working
// correctly if they're called from a mouse event, so we'll trigger
// the event asynchronously..
if (JUCEApplication::getInstance() == 0)
if (! JUCEApplication::isStandaloneApp)
[self asyncMouseUp: ev];
else
// In some host situations, the host will stop modal loops from working
// correctly if they're called from a mouse event, so we'll trigger
// the event asynchronously..
[self performSelectorOnMainThread: @selector (asyncMouseUp:) [self performSelectorOnMainThread: @selector (asyncMouseUp:)
withObject: ev withObject: ev
waitUntilDone: NO]; waitUntilDone: NO];
else
[self asyncMouseUp: ev];
} }
- (void) asyncMouseUp: (NSEvent*) ev - (void) asyncMouseUp: (NSEvent*) ev


Loading…
Cancel
Save