Browse Source

tags/2021-05-28
jules 17 years ago
parent
commit
ad0e8ae105
14 changed files with 2651 additions and 2306 deletions
  1. +1291
    -1291
      build/macosx/platform_specific_code/juce_mac_CoreAudio.cpp
  2. +592
    -592
      build/macosx/platform_specific_code/juce_mac_CoreMidi.cpp
  3. +1
    -11
      build/macosx/platform_specific_code/juce_mac_FileChooser.mm
  4. +503
    -344
      build/macosx/platform_specific_code/juce_mac_Messaging.mm
  5. +12
    -1
      build/macosx/platform_specific_code/juce_mac_NativeHeaders.h
  6. +2
    -1
      build/macosx/platform_specific_code/juce_mac_SystemStats.mm
  7. +6
    -2
      build/macosx/platform_specific_code/juce_mac_Windowing.mm
  8. +227
    -60
      juce_amalgamated.cpp
  9. +4
    -2
      juce_amalgamated.h
  10. +1
    -1
      src/juce_appframework/gui/components/controls/juce_Slider.h
  11. +6
    -0
      src/juce_appframework/gui/components/filebrowser/juce_FileListComponent.cpp
  12. +2
    -0
      src/juce_appframework/gui/components/filebrowser/juce_FileListComponent.h
  13. +3
    -0
      src/juce_appframework/gui/components/special/juce_QuickTimeMovieComponent.cpp
  14. +1
    -1
      src/juce_core/basics/juce_SystemStats.h

+ 1291
- 1291
build/macosx/platform_specific_code/juce_mac_CoreAudio.cpp
File diff suppressed because it is too large
View File


+ 592
- 592
build/macosx/platform_specific_code/juce_mac_CoreMidi.cpp
File diff suppressed because it is too large
View File


+ 1
- 11
build/macosx/platform_specific_code/juce_mac_FileChooser.mm View File

@@ -36,15 +36,6 @@ BEGIN_JUCE_NAMESPACE
#include "../../../src/juce_appframework/gui/components/filebrowser/juce_FileChooser.h"
END_JUCE_NAMESPACE

static const JUCE_NAMESPACE::String nsStringToJuce (NSString* s)
{
return JUCE_NAMESPACE::String::fromUTF8 ((JUCE_NAMESPACE::uint8*) [s UTF8String]);
}

static NSString* juceStringToNS (const JUCE_NAMESPACE::String& s)
{
return [NSString stringWithUTF8String: (const char*) s.toUTF8()];
}

//==============================================================================
@interface JuceFileChooserDelegate : NSObject
@@ -84,8 +75,7 @@ static NSString* juceStringToNS (const JUCE_NAMESPACE::String& s)
return true;
}

return JUCE_NAMESPACE::File (JUCE_NAMESPACE::String::fromUTF8 ((const uint8*) filenameUTF8))
.isDirectory();
return JUCE_NAMESPACE::File (nsStringToJuce (filename)).isDirectory();
}
@end



+ 503
- 344
build/macosx/platform_specific_code/juce_mac_Messaging.mm View File

@@ -1,344 +1,503 @@
/*
==============================================================================
This file is part of the JUCE library - "Jules' Utility Class Extensions"
Copyright 2004-7 by Raw Material Software ltd.
------------------------------------------------------------------------------
JUCE can be redistributed and/or modified under the terms of the
GNU General Public License, as published by the Free Software Foundation;
either version 2 of the License, or (at your option) any later version.
JUCE is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with JUCE; if not, visit www.gnu.org/licenses or write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
Boston, MA 02111-1307 USA
------------------------------------------------------------------------------
If you'd like to release a closed-source product which uses JUCE, commercial
licenses are also available: visit www.rawmaterialsoftware.com/juce for
more information.
==============================================================================
*/
#include "../../../src/juce_core/basics/juce_StandardHeader.h"
#include <Carbon/Carbon.h>
BEGIN_JUCE_NAMESPACE
#include "../../../src/juce_appframework/events/juce_MessageManager.h"
#include "../../../src/juce_appframework/application/juce_Application.h"
#include "../../../src/juce_appframework/gui/components/juce_Desktop.h"
#include "../../../src/juce_core/text/juce_StringArray.h"
#include "../../../src/juce_core/threads/juce_Thread.h"
#include "../../../src/juce_core/misc/juce_PlatformUtilities.h"
#undef Point
static int kJUCEClass = FOUR_CHAR_CODE ('JUCE');
const int kJUCEKind = 1;
const int kCallbackKind = 2;
extern void juce_HandleProcessFocusChange();
extern void juce_maximiseAllMinimisedWindows();
extern void juce_InvokeMainMenuCommand (const HICommand& command);
extern void juce_MainMenuAboutToBeUsed();
static pascal OSStatus EventHandlerProc (EventHandlerCallRef, EventRef theEvent, void* userData)
{
void* event = 0;
GetEventParameter (theEvent, 'mess', typeVoidPtr, 0, sizeof (void*), 0, &event);
if (event != 0)
MessageManager::getInstance()->deliverMessage (event);
return noErr;
}
struct CallbackMessagePayload
{
MessageCallbackFunction* function;
void* parameter;
void* volatile result;
bool volatile hasBeenExecuted;
};
static pascal OSStatus CallbackHandlerProc (EventHandlerCallRef, EventRef theEvent, void* userData)
{
CallbackMessagePayload* pl = 0;
GetEventParameter (theEvent, 'mess', typeVoidPtr, 0, sizeof(pl), 0, &pl);
if (pl != 0)
{
pl->result = (*pl->function) (pl->parameter);
pl->hasBeenExecuted = true;
}
return noErr;
}
static pascal OSStatus MouseClickHandlerProc (EventHandlerCallRef, EventRef theEvent, void* userData)
{
::Point where;
GetEventParameter (theEvent, kEventParamMouseLocation, typeQDPoint, 0, sizeof(::Point), 0, &where);
WindowRef window;
if (FindWindow (where, &window) == inMenuBar)
{
// turn off the wait cursor before going in here..
const int oldTimeBeforeWaitCursor = MessageManager::getInstance()->getTimeBeforeShowingWaitCursor();
MessageManager::getInstance()->setTimeBeforeShowingWaitCursor (0);
if (Component::getCurrentlyModalComponent() != 0)
Component::getCurrentlyModalComponent()->inputAttemptWhenModal();
juce_MainMenuAboutToBeUsed();
MenuSelect (where);
HiliteMenu (0);
MessageManager::getInstance()->setTimeBeforeShowingWaitCursor (oldTimeBeforeWaitCursor);
return noErr;
}
return eventNotHandledErr;
}
static pascal OSErr QuitAppleEventHandler (const AppleEvent *appleEvt, AppleEvent* reply, long refcon)
{
if (JUCEApplication::getInstance() != 0)
JUCEApplication::getInstance()->systemRequestedQuit();
return noErr;
}
static pascal OSErr OpenDocEventHandler (const AppleEvent *appleEvt, AppleEvent* reply, long refcon)
{
AEDescList docs;
StringArray files;
if (AEGetParamDesc (appleEvt, keyDirectObject, typeAEList, &docs) == noErr)
{
long num;
if (AECountItems (&docs, &num) == noErr)
{
for (int i = 1; i <= num; ++i)
{
FSRef file;
AEKeyword keyword;
DescType type;
Size size;
if (AEGetNthPtr (&docs, i, typeFSRef, &keyword, &type,
&file, sizeof (file), &size) == noErr)
{
const String path (PlatformUtilities::makePathFromFSRef (&file));
if (path.isNotEmpty())
files.add (path.quoted());
}
}
if (files.size() > 0
&& JUCEApplication::getInstance() != 0)
{
JUCE_TRY
{
JUCEApplication::getInstance()
->anotherInstanceStarted (files.joinIntoString (T(" ")));
}
JUCE_CATCH_ALL
}
}
AEDisposeDesc (&docs);
};
return noErr;
}
static pascal OSStatus AppEventHandlerProc (EventHandlerCallRef, EventRef theEvent, void* userData)
{
const UInt32 eventClass = GetEventClass (theEvent);
if (eventClass == kEventClassCommand)
{
HICommand command;
if (GetEventParameter (theEvent, kEventParamHICommand, typeHICommand, 0, sizeof (command), 0, &command) == noErr
|| GetEventParameter (theEvent, kEventParamDirectObject, typeHICommand, 0, sizeof (command), 0, &command) == noErr)
{
if (command.commandID == kHICommandQuit)
{
if (JUCEApplication::getInstance() != 0)
JUCEApplication::getInstance()->systemRequestedQuit();
return noErr;
}
else if (command.commandID == kHICommandMaximizeAll
|| command.commandID == kHICommandMaximizeWindow
|| command.commandID == kHICommandBringAllToFront)
{
juce_maximiseAllMinimisedWindows();
return noErr;
}
else
{
juce_InvokeMainMenuCommand (command);
}
}
}
else if (eventClass == kEventClassApplication)
{
if (GetEventKind (theEvent) == kEventAppFrontSwitched)
{
juce_HandleProcessFocusChange();
}
else if (GetEventKind (theEvent) == kEventAppShown)
{
// this seems to blank the windows, so we need to do a repaint..
for (int i = Desktop::getInstance().getNumComponents(); --i >= 0;)
{
Component* const c = Desktop::getInstance().getComponent (i);
if (c != 0)
c->repaint();
}
}
}
return eventNotHandledErr;
}
static EventQueueRef mainQueue;
static EventHandlerRef juceEventHandler = 0;
static EventHandlerRef callbackEventHandler = 0;
//==============================================================================
void MessageManager::doPlatformSpecificInitialisation()
{
static bool initialised = false;
if (! initialised)
{
initialised = true;
#if MACOS_10_3_OR_EARLIER
// work-around for a bug in MacOS 10.2..
ProcessSerialNumber junkPSN;
(void) GetCurrentProcess (&junkPSN);
#endif
mainQueue = GetMainEventQueue();
// if we're linking a Juce app to one or more dynamic libraries, we'll need different values
// for this so each module doesn't interfere with the others.
UnsignedWide t;
Microseconds (&t);
kJUCEClass ^= t.lo;
}
const EventTypeSpec type1 = { kJUCEClass, kJUCEKind };
InstallApplicationEventHandler (NewEventHandlerUPP (EventHandlerProc), 1, &type1, 0, &juceEventHandler);
const EventTypeSpec type2 = { kJUCEClass, kCallbackKind };
InstallApplicationEventHandler (NewEventHandlerUPP (CallbackHandlerProc), 1, &type2, 0, &callbackEventHandler);
// only do this stuff if we're running as an application rather than a library..
if (JUCEApplication::getInstance() != 0)
{
const EventTypeSpec type3 = { kEventClassMouse, kEventMouseDown };
InstallApplicationEventHandler (NewEventHandlerUPP (MouseClickHandlerProc), 1, &type3, 0, 0);
const EventTypeSpec type4[] = { { kEventClassApplication, kEventAppShown },
{ kEventClassApplication, kEventAppFrontSwitched },
{ kEventClassCommand, kEventProcessCommand } };
InstallApplicationEventHandler (NewEventHandlerUPP (AppEventHandlerProc), 3, type4, 0, 0);
AEInstallEventHandler (kCoreEventClass, kAEQuitApplication,
NewAEEventHandlerUPP (QuitAppleEventHandler), 0, false);
AEInstallEventHandler (kCoreEventClass, kAEOpenDocuments,
NewAEEventHandlerUPP (OpenDocEventHandler), 0, false);
}
}
void MessageManager::doPlatformSpecificShutdown()
{
if (juceEventHandler != 0)
{
RemoveEventHandler (juceEventHandler);
juceEventHandler = 0;
}
if (callbackEventHandler != 0)
{
RemoveEventHandler (callbackEventHandler);
callbackEventHandler = 0;
}
}
bool juce_postMessageToSystemQueue (void* message)
{
jassert (mainQueue == GetMainEventQueue());
EventRef event;
if (CreateEvent (0, kJUCEClass, kJUCEKind, 0, kEventAttributeUserEvent, &event) == noErr)
{
SetEventParameter (event, 'mess', typeVoidPtr, sizeof (void*), &message);
const bool ok = PostEventToQueue (mainQueue, event, kEventPriorityStandard) == noErr;
ReleaseEvent (event);
return ok;
}
return false;
}
void MessageManager::broadcastMessage (const String& value) throw()
{
}
void* MessageManager::callFunctionOnMessageThread (MessageCallbackFunction* callback,
void* data)
{
if (isThisTheMessageThread())
{
return (*callback) (data);
}
else
{
jassert (mainQueue == GetMainEventQueue());
CallbackMessagePayload cmp;
cmp.function = callback;
cmp.parameter = data;
cmp.result = 0;
cmp.hasBeenExecuted = false;
EventRef event;
if (CreateEvent (0, kJUCEClass, kCallbackKind, 0, kEventAttributeUserEvent, &event) == noErr)
{
void* v = &cmp;
SetEventParameter (event, 'mess', typeVoidPtr, sizeof (void*), &v);
if (PostEventToQueue (mainQueue, event, kEventPriorityStandard) == noErr)
{
while (! cmp.hasBeenExecuted)
Thread::yield();
return cmp.result;
}
}
return 0;
}
}
END_JUCE_NAMESPACE
/*
==============================================================================

This file is part of the JUCE library - "Jules' Utility Class Extensions"
Copyright 2004-7 by Raw Material Software ltd.

------------------------------------------------------------------------------

JUCE can be redistributed and/or modified under the terms of the
GNU General Public License, as published by the Free Software Foundation;
either version 2 of the License, or (at your option) any later version.

JUCE is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with JUCE; if not, visit www.gnu.org/licenses or write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
Boston, MA 02111-1307 USA

------------------------------------------------------------------------------

If you'd like to release a closed-source product which uses JUCE, commercial
licenses are also available: visit www.rawmaterialsoftware.com/juce for
more information.

==============================================================================
*/

#include "juce_mac_NativeHeaders.h"
#include <Carbon/Carbon.h>

BEGIN_JUCE_NAMESPACE

#include "../../../src/juce_appframework/events/juce_MessageManager.h"
#include "../../../src/juce_appframework/application/juce_Application.h"
#include "../../../src/juce_appframework/gui/components/juce_Desktop.h"
#include "../../../src/juce_core/text/juce_StringArray.h"
#include "../../../src/juce_core/threads/juce_Thread.h"
#include "../../../src/juce_core/misc/juce_PlatformUtilities.h"

#undef Point

extern void juce_HandleProcessFocusChange();
extern void juce_maximiseAllMinimisedWindows();
extern void juce_InvokeMainMenuCommand (const HICommand& command);
extern void juce_MainMenuAboutToBeUsed();

struct CallbackMessagePayload
{
MessageCallbackFunction* function;
void* parameter;
void* volatile result;
bool volatile hasBeenExecuted;
};

END_JUCE_NAMESPACE

#if JUCE_COCOA

NSString* juceMessageName = 0;

@interface JuceAppDelegate : NSObject
id oldDelegate;
- (JuceAppDelegate*) init;
- (void) dealloc;
- (BOOL) application: (NSApplication*) theApplication openFile: (NSString*) filename;
- (void) application: (NSApplication*) sender openFiles: (NSArray*) filenames;
- (NSApplicationTerminateReply) applicationShouldTerminate: (NSApplication*) app;
- (void) applicationDidBecomeActive: (NSNotification*) aNotification;
- (void) applicationDidResignActive: (NSNotification*) aNotification;
- (void) applicationWillUnhide: (NSNotification*) aNotification;
- (void) customEvent: (NSNotification*) aNotification;
- (void) performCallback: (id) info;
@end

@implementation JuceAppDelegate

- (JuceAppDelegate*) init
{
[super init];

NSNotificationCenter* center = [NSNotificationCenter defaultCenter];

if (JUCE_NAMESPACE::JUCEApplication::getInstance() != 0)
{
oldDelegate = [NSApp delegate];
[NSApp setDelegate: self];
}
else
{
oldDelegate = 0;
[center addObserver: self selector: @selector (applicationDidResignActive:)
name: NSApplicationDidResignActiveNotification object: NSApp];

[center addObserver: self selector: @selector (applicationDidBecomeActive:)
name: NSApplicationDidBecomeActiveNotification object: NSApp];

[center addObserver: self selector: @selector (applicationWillUnhide:)
name: NSApplicationWillUnhideNotification object: NSApp];

}

[center addObserver: self selector: @selector (customEvent:)
name: juceMessageName object: nil];

return self;
}

- (void) dealloc
{
if (oldDelegate != 0)
[NSApp setDelegate: oldDelegate];

[[NSNotificationCenter defaultCenter] removeObserver: self];
[super dealloc];
}

- (NSApplicationTerminateReply) applicationShouldTerminate: (NSApplication*) app
{
if (JUCE_NAMESPACE::JUCEApplication::getInstance() != 0)
JUCE_NAMESPACE::JUCEApplication::getInstance()->systemRequestedQuit();

return NSTerminateLater;
}

- (BOOL) application: (NSApplication*) app openFile: (NSString*) filename
{
if (JUCE_NAMESPACE::JUCEApplication::getInstance() != 0)
{
JUCE_NAMESPACE::JUCEApplication::getInstance()->anotherInstanceStarted (nsStringToJuce (filename));
return YES;
}

return NO;
}

- (void) application: (NSApplication*) sender openFiles: (NSArray*) filenames
{
JUCE_NAMESPACE::StringArray files;
for (int i = 0; i < [filenames count]; ++i)
files.add (nsStringToJuce ((NSString*) [filenames objectAtIndex: i]));

if (files.size() > 0 && JUCE_NAMESPACE::JUCEApplication::getInstance() != 0)
JUCE_NAMESPACE::JUCEApplication::getInstance()->anotherInstanceStarted (files.joinIntoString (T(" ")));
}

- (void) applicationDidBecomeActive: (NSNotification*) aNotification
{
JUCE_NAMESPACE::juce_HandleProcessFocusChange();
}

- (void) applicationDidResignActive: (NSNotification*) aNotification
{
JUCE_NAMESPACE::juce_HandleProcessFocusChange();
}

- (void) applicationWillUnhide: (NSNotification*) aNotification
{
JUCE_NAMESPACE::juce_maximiseAllMinimisedWindows();
}

- (void) customEvent: (NSNotification*) n
{
void* message = 0;
[((NSData*) [n object]) getBytes: &message length: sizeof (message)];

if (message != 0)
JUCE_NAMESPACE::MessageManager::getInstance()->deliverMessage (message);
}

- (void) performCallback: (id) info
{
JUCE_NAMESPACE::CallbackMessagePayload* pl = (JUCE_NAMESPACE::CallbackMessagePayload*) info;

if (pl != 0)
{
pl->result = (*pl->function) (pl->parameter);
pl->hasBeenExecuted = true;
}
}

@end
#endif

BEGIN_JUCE_NAMESPACE


#if JUCE_COCOA
static JuceAppDelegate* juceAppDelegate = 0;

#else
static int kJUCEClass = FOUR_CHAR_CODE ('JUCE');
const int kJUCEKind = 1;
const int kCallbackKind = 2;


static pascal OSStatus EventHandlerProc (EventHandlerCallRef, EventRef theEvent, void* userData)
{
void* event = 0;
GetEventParameter (theEvent, 'mess', typeVoidPtr, 0, sizeof (void*), 0, &event);

if (event != 0)
MessageManager::getInstance()->deliverMessage (event);

return noErr;
}

static pascal OSStatus CallbackHandlerProc (EventHandlerCallRef, EventRef theEvent, void* userData)
{
CallbackMessagePayload* pl = 0;
GetEventParameter (theEvent, 'mess', typeVoidPtr, 0, sizeof(pl), 0, &pl);

if (pl != 0)
{
pl->result = (*pl->function) (pl->parameter);
pl->hasBeenExecuted = true;
}

return noErr;
}

static pascal OSStatus MouseClickHandlerProc (EventHandlerCallRef, EventRef theEvent, void* userData)
{
::Point where;
GetEventParameter (theEvent, kEventParamMouseLocation, typeQDPoint, 0, sizeof(::Point), 0, &where);
WindowRef window;
if (FindWindow (where, &window) == inMenuBar)
{
// turn off the wait cursor before going in here..
const int oldTimeBeforeWaitCursor = MessageManager::getInstance()->getTimeBeforeShowingWaitCursor();
MessageManager::getInstance()->setTimeBeforeShowingWaitCursor (0);

if (Component::getCurrentlyModalComponent() != 0)
Component::getCurrentlyModalComponent()->inputAttemptWhenModal();

juce_MainMenuAboutToBeUsed();
MenuSelect (where);
HiliteMenu (0);

MessageManager::getInstance()->setTimeBeforeShowingWaitCursor (oldTimeBeforeWaitCursor);
return noErr;
}

return eventNotHandledErr;
}

static pascal OSErr QuitAppleEventHandler (const AppleEvent *appleEvt, AppleEvent* reply, long refcon)
{
if (JUCEApplication::getInstance() != 0)
JUCEApplication::getInstance()->systemRequestedQuit();

return noErr;
}

static pascal OSErr OpenDocEventHandler (const AppleEvent *appleEvt, AppleEvent* reply, long refcon)
{
AEDescList docs;
StringArray files;

if (AEGetParamDesc (appleEvt, keyDirectObject, typeAEList, &docs) == noErr)
{
long num;
if (AECountItems (&docs, &num) == noErr)
{
for (int i = 1; i <= num; ++i)
{
FSRef file;
AEKeyword keyword;
DescType type;
Size size;

if (AEGetNthPtr (&docs, i, typeFSRef, &keyword, &type,
&file, sizeof (file), &size) == noErr)
{
const String path (PlatformUtilities::makePathFromFSRef (&file));

if (path.isNotEmpty())
files.add (path.quoted());
}
}

if (files.size() > 0
&& JUCEApplication::getInstance() != 0)
{
JUCE_TRY
{
JUCEApplication::getInstance()
->anotherInstanceStarted (files.joinIntoString (T(" ")));
}
JUCE_CATCH_ALL
}
}

AEDisposeDesc (&docs);
};

return noErr;
}

static pascal OSStatus AppEventHandlerProc (EventHandlerCallRef, EventRef theEvent, void* userData)
{
const UInt32 eventClass = GetEventClass (theEvent);

if (eventClass == kEventClassCommand)
{
HICommand command;

if (GetEventParameter (theEvent, kEventParamHICommand, typeHICommand, 0, sizeof (command), 0, &command) == noErr
|| GetEventParameter (theEvent, kEventParamDirectObject, typeHICommand, 0, sizeof (command), 0, &command) == noErr)
{
if (command.commandID == kHICommandQuit)
{
if (JUCEApplication::getInstance() != 0)
JUCEApplication::getInstance()->systemRequestedQuit();

return noErr;
}
else if (command.commandID == kHICommandMaximizeAll
|| command.commandID == kHICommandMaximizeWindow
|| command.commandID == kHICommandBringAllToFront)
{
juce_maximiseAllMinimisedWindows();
return noErr;
}
else
{
juce_InvokeMainMenuCommand (command);
}
}
}
else if (eventClass == kEventClassApplication)
{
if (GetEventKind (theEvent) == kEventAppFrontSwitched)
{
juce_HandleProcessFocusChange();
}
else if (GetEventKind (theEvent) == kEventAppShown)
{
// this seems to blank the windows, so we need to do a repaint..
for (int i = Desktop::getInstance().getNumComponents(); --i >= 0;)
{
Component* const c = Desktop::getInstance().getComponent (i);

if (c != 0)
c->repaint();
}
}
}

return eventNotHandledErr;
}

static EventQueueRef mainQueue;
static EventHandlerRef juceEventHandler = 0;
static EventHandlerRef callbackEventHandler = 0;

#endif

//==============================================================================
void MessageManager::doPlatformSpecificInitialisation()
{
static bool initialised = false;

if (! initialised)
{
initialised = true;

#if JUCE_COCOA
// if we're linking a Juce app to one or more dynamic libraries, we'll need different values
// for this so each module doesn't interfere with the others.
UnsignedWide t;
Microseconds (&t);
kJUCEClass ^= t.lo;

juceMessageName = juceStringToNS ("juce_" + String::toHexString ((int) t.lo));

juceAppDelegate = [[JuceAppDelegate alloc] init];
#else
mainQueue = GetMainEventQueue();
#endif
}

#if ! JUCE_COCOA
const EventTypeSpec type1 = { kJUCEClass, kJUCEKind };
InstallApplicationEventHandler (NewEventHandlerUPP (EventHandlerProc), 1, &type1, 0, &juceEventHandler);

const EventTypeSpec type2 = { kJUCEClass, kCallbackKind };
InstallApplicationEventHandler (NewEventHandlerUPP (CallbackHandlerProc), 1, &type2, 0, &callbackEventHandler);

// only do this stuff if we're running as an application rather than a library..
if (JUCEApplication::getInstance() != 0)
{
const EventTypeSpec type3 = { kEventClassMouse, kEventMouseDown };
InstallApplicationEventHandler (NewEventHandlerUPP (MouseClickHandlerProc), 1, &type3, 0, 0);

const EventTypeSpec type4[] = { { kEventClassApplication, kEventAppShown },
{ kEventClassApplication, kEventAppFrontSwitched },
{ kEventClassCommand, kEventProcessCommand } };

InstallApplicationEventHandler (NewEventHandlerUPP (AppEventHandlerProc), 3, type4, 0, 0);

AEInstallEventHandler (kCoreEventClass, kAEQuitApplication,
NewAEEventHandlerUPP (QuitAppleEventHandler), 0, false);

AEInstallEventHandler (kCoreEventClass, kAEOpenDocuments,
NewAEEventHandlerUPP (OpenDocEventHandler), 0, false);
}
#endif
}

void MessageManager::doPlatformSpecificShutdown()
{
if (juceEventHandler != 0)
{
RemoveEventHandler (juceEventHandler);
juceEventHandler = 0;
}

if (callbackEventHandler != 0)
{
RemoveEventHandler (callbackEventHandler);
callbackEventHandler = 0;
}
}

bool juce_postMessageToSystemQueue (void* message)
{
#if JUCE_COCOA
[[NSNotificationCenter defaultCenter] postNotificationName: juceMessageName
object: [NSData dataWithBytes: &message
length: (int) sizeof (message)]];

return true;

#else
jassert (mainQueue == GetMainEventQueue());

EventRef event;
if (CreateEvent (0, kJUCEClass, kJUCEKind, 0, kEventAttributeUserEvent, &event) == noErr)
{
SetEventParameter (event, 'mess', typeVoidPtr, sizeof (void*), &message);
const bool ok = PostEventToQueue (mainQueue, event, kEventPriorityStandard) == noErr;
ReleaseEvent (event);
return ok;
}

return false;
#endif
}

void MessageManager::broadcastMessage (const String& value) throw()
{
}

void* MessageManager::callFunctionOnMessageThread (MessageCallbackFunction* callback,
void* data)
{
if (isThisTheMessageThread())
{
return (*callback) (data);
}
else
{
CallbackMessagePayload cmp;
cmp.function = callback;
cmp.parameter = data;
cmp.result = 0;
cmp.hasBeenExecuted = false;

#if JUCE_COCOA
[juceAppDelegate performSelectorOnMainThread: @selector (performCallback:)
withObject: (id) &cmp
waitUntilDone: YES];

return cmp.result;

#else
jassert (mainQueue == GetMainEventQueue());

EventRef event;
if (CreateEvent (0, kJUCEClass, kCallbackKind, 0, kEventAttributeUserEvent, &event) == noErr)
{
void* v = &cmp;
SetEventParameter (event, 'mess', typeVoidPtr, sizeof (void*), &v);

if (PostEventToQueue (mainQueue, event, kEventPriorityStandard) == noErr)
{
while (! cmp.hasBeenExecuted)
Thread::yield();

return cmp.result;
}
}

return 0;
#endif
}
}

END_JUCE_NAMESPACE

+ 12
- 1
build/macosx/platform_specific_code/juce_mac_NativeHeaders.h View File

@@ -50,7 +50,18 @@ private:
NSAutoreleasePool* pool;
};
END_JUCE_NAMESPACE
//==============================================================================
static const JUCE_NAMESPACE::String nsStringToJuce (NSString* s)
{
return JUCE_NAMESPACE::String::fromUTF8 ((JUCE_NAMESPACE::uint8*) [s UTF8String]);
}
static NSString* juceStringToNS (const JUCE_NAMESPACE::String& s)
{
return [NSString stringWithUTF8String: (const char*) s.toUTF8()];
}
#endif

+ 2
- 1
build/macosx/platform_specific_code/juce_mac_SystemStats.mm View File

@@ -29,7 +29,7 @@
==============================================================================
*/

#include "../../../src/juce_core/basics/juce_StandardHeader.h"
#include "juce_mac_NativeHeaders.h"
#include <AppKit/AppKit.h>
#include <CoreAudio/HostTime.h>
#include <ctime>
@@ -145,6 +145,7 @@ void SystemStats::initialiseStats() throw()
{
initialised = true;

[NSApplication sharedApplication];
NSApplicationLoad();

#if JUCE_INTEL


+ 6
- 2
build/macosx/platform_specific_code/juce_mac_Windowing.mm View File

@@ -29,9 +29,8 @@
==============================================================================
*/

#include "../../../src/juce_core/basics/juce_StandardHeader.h"
#include "juce_mac_NativeHeaders.h"
#include <Carbon/Carbon.h>
#include <Cocoa/Cocoa.h>
#include <IOKit/IOKitLib.h>
#include <IOKit/IOCFPlugIn.h>
#include <IOKit/hid/IOHIDLib.h>
@@ -2139,6 +2138,11 @@ bool juce_dispatchNextMessageOnSystemQueue (bool returnIfNoPendingMessages)
if (juce_currentMouseTrackingPeer != 0)
trackNextMouseEvent();

/* [[NSRunLoop mainRunLoop] acceptInputForMode: NSDefaultRunLoopMode
beforeDate: returnIfNoPendingMessages
? [[NSDate date] addTimeInterval: 0.01]
: [NSDate distantFuture]];
*/
EventRef theEvent;

if (ReceiveNextEvent (0, 0, (returnIfNoPendingMessages) ? kEventDurationNoWait


+ 227
- 60
juce_amalgamated.cpp View File

@@ -51496,6 +51496,12 @@ void FileListComponent::scrollToTop()
void FileListComponent::changeListenerCallback (void*)
{
updateContent();

if (lastDirectory != fileList.getDirectory())
{
lastDirectory = fileList.getDirectory();
deselectAllRows();
}
}

class FileListItemComponent : public Component,
@@ -252706,6 +252712,39 @@ END_JUCE_NAMESPACE

/********* Start of inlined file: juce_mac_SystemStats.mm *********/

/********* Start of inlined file: juce_mac_NativeHeaders.h *********/
#ifndef __JUCE_MAC_NATIVEHEADERS_JUCEHEADER__
#define __JUCE_MAC_NATIVEHEADERS_JUCEHEADER__

#include <Cocoa/Cocoa.h>

BEGIN_JUCE_NAMESPACE

class AutoPool
{
public:
AutoPool() { pool = [[NSAutoreleasePool alloc] init]; }
~AutoPool() { [pool release]; }

private:
NSAutoreleasePool* pool;
};

END_JUCE_NAMESPACE

static const JUCE_NAMESPACE::String nsStringToJuce (NSString* s)
{
return JUCE_NAMESPACE::String::fromUTF8 ((JUCE_NAMESPACE::uint8*) [s UTF8String]);
}

static NSString* juceStringToNS (const JUCE_NAMESPACE::String& s)
{
return [NSString stringWithUTF8String: (const char*) s.toUTF8()];
}

#endif
/********* End of inlined file: juce_mac_NativeHeaders.h *********/

#include <AppKit/AppKit.h>
#include <CoreAudio/HostTime.h>
#include <ctime>
@@ -252813,7 +252852,8 @@ void SystemStats::initialiseStats() throw()
{
initialised = true;

NSApplicationLoad();
[NSApplication sharedApplication];
// NSApplicationLoad();

#if JUCE_INTEL
{
@@ -253113,29 +253153,6 @@ END_JUCE_NAMESPACE

/********* Start of inlined file: juce_mac_Network.mm *********/

/********* Start of inlined file: juce_mac_NativeHeaders.h *********/
#ifndef __JUCE_MAC_NATIVEHEADERS_JUCEHEADER__
#define __JUCE_MAC_NATIVEHEADERS_JUCEHEADER__

#include <Cocoa/Cocoa.h>

BEGIN_JUCE_NAMESPACE

class AutoPool
{
public:
AutoPool() { pool = [[NSAutoreleasePool alloc] init]; }
~AutoPool() { [pool release]; }

private:
NSAutoreleasePool* pool;
};

END_JUCE_NAMESPACE

#endif
/********* End of inlined file: juce_mac_NativeHeaders.h *********/

#include <IOKit/IOKitLib.h>
#include <IOKit/network/IOEthernetInterface.h>
#include <IOKit/network/IONetworkInterface.h>
@@ -255844,16 +255861,6 @@ BEGIN_JUCE_NAMESPACE

END_JUCE_NAMESPACE

static const JUCE_NAMESPACE::String nsStringToJuce (NSString* s)
{
return JUCE_NAMESPACE::String::fromUTF8 ((JUCE_NAMESPACE::uint8*) [s UTF8String]);
}

static NSString* juceStringToNS (const JUCE_NAMESPACE::String& s)
{
return [NSString stringWithUTF8String: (const char*) s.toUTF8()];
}

@interface JuceFileChooserDelegate : NSObject
{
JUCE_NAMESPACE::StringArray* filters;
@@ -255891,8 +255898,7 @@ static NSString* juceStringToNS (const JUCE_NAMESPACE::String& s)
return true;
}

return JUCE_NAMESPACE::File (JUCE_NAMESPACE::String::fromUTF8 ((const uint8*) filenameUTF8))
.isDirectory();
return JUCE_NAMESPACE::File (nsStringToJuce (filename)).isDirectory();
}
@end

@@ -256466,15 +256472,158 @@ BEGIN_JUCE_NAMESPACE

#undef Point

static int kJUCEClass = FOUR_CHAR_CODE ('JUCE');
const int kJUCEKind = 1;
const int kCallbackKind = 2;

extern void juce_HandleProcessFocusChange();
extern void juce_maximiseAllMinimisedWindows();
extern void juce_InvokeMainMenuCommand (const HICommand& command);
extern void juce_MainMenuAboutToBeUsed();

struct CallbackMessagePayload
{
MessageCallbackFunction* function;
void* parameter;
void* volatile result;
bool volatile hasBeenExecuted;
};

END_JUCE_NAMESPACE

#if JUCE_COCOA

NSString* juceMessageName = 0;

@interface JuceAppDelegate : NSObject
id oldDelegate;
- (JuceAppDelegate*) init;
- (void) dealloc;
- (BOOL) application: (NSApplication*) theApplication openFile: (NSString*) filename;
- (void) application: (NSApplication*) sender openFiles: (NSArray*) filenames;
- (NSApplicationTerminateReply) applicationShouldTerminate: (NSApplication*) app;
- (void) applicationDidBecomeActive: (NSNotification*) aNotification;
- (void) applicationDidResignActive: (NSNotification*) aNotification;
- (void) applicationWillUnhide: (NSNotification*) aNotification;
- (void) customEvent: (NSNotification*) aNotification;
- (void) performCallback: (id) info;
@end

@implementation JuceAppDelegate

- (JuceAppDelegate*) init
{
[super init];

NSNotificationCenter* center = [NSNotificationCenter defaultCenter];

if (JUCE_NAMESPACE::JUCEApplication::getInstance() != 0)
{
oldDelegate = [NSApp delegate];
[NSApp setDelegate: self];
}
else
{
oldDelegate = 0;
[center addObserver: self selector: @selector (applicationDidResignActive:)
name: NSApplicationDidResignActiveNotification object: NSApp];

[center addObserver: self selector: @selector (applicationDidBecomeActive:)
name: NSApplicationDidBecomeActiveNotification object: NSApp];

[center addObserver: self selector: @selector (applicationWillUnhide:)
name: NSApplicationWillUnhideNotification object: NSApp];

}

[center addObserver: self selector: @selector (customEvent:)
name: juceMessageName object: nil];

return self;
}

- (void) dealloc
{
if (oldDelegate != 0)
[NSApp setDelegate: oldDelegate];

[[NSNotificationCenter defaultCenter] removeObserver: self];
[super dealloc];
}

- (NSApplicationTerminateReply) applicationShouldTerminate: (NSApplication*) app
{
if (JUCE_NAMESPACE::JUCEApplication::getInstance() != 0)
JUCE_NAMESPACE::JUCEApplication::getInstance()->systemRequestedQuit();

return NSTerminateLater;
}

- (BOOL) application: (NSApplication*) app openFile: (NSString*) filename
{
if (JUCE_NAMESPACE::JUCEApplication::getInstance() != 0)
{
JUCE_NAMESPACE::JUCEApplication::getInstance()->anotherInstanceStarted (nsStringToJuce (filename));
return YES;
}

return NO;
}

- (void) application: (NSApplication*) sender openFiles: (NSArray*) filenames
{
JUCE_NAMESPACE::StringArray files;
for (int i = 0; i < [filenames count]; ++i)
files.add (nsStringToJuce ((NSString*) [filenames objectAtIndex: i]));

if (files.size() > 0 && JUCE_NAMESPACE::JUCEApplication::getInstance() != 0)
JUCE_NAMESPACE::JUCEApplication::getInstance()->anotherInstanceStarted (files.joinIntoString (T(" ")));
}

- (void) applicationDidBecomeActive: (NSNotification*) aNotification
{
JUCE_NAMESPACE::juce_HandleProcessFocusChange();
}

- (void) applicationDidResignActive: (NSNotification*) aNotification
{
JUCE_NAMESPACE::juce_HandleProcessFocusChange();
}

- (void) applicationWillUnhide: (NSNotification*) aNotification
{
JUCE_NAMESPACE::juce_maximiseAllMinimisedWindows();
}

- (void) customEvent: (NSNotification*) n
{
void* message = 0;
[((NSData*) [n object]) getBytes: &message length: sizeof (message)];

if (message != 0)
JUCE_NAMESPACE::MessageManager::getInstance()->deliverMessage (message);
}

- (void) performCallback: (id) info
{
JUCE_NAMESPACE::CallbackMessagePayload* pl = (JUCE_NAMESPACE::CallbackMessagePayload*) info;

if (pl != 0)
{
pl->result = (*pl->function) (pl->parameter);
pl->hasBeenExecuted = true;
}
}

@end
#endif

BEGIN_JUCE_NAMESPACE

#if JUCE_COCOA
static JuceAppDelegate* juceAppDelegate = 0;

#else
static int kJUCEClass = FOUR_CHAR_CODE ('JUCE');
const int kJUCEKind = 1;
const int kCallbackKind = 2;

static pascal OSStatus EventHandlerProc (EventHandlerCallRef, EventRef theEvent, void* userData)
{
void* event = 0;
@@ -256486,14 +256635,6 @@ static pascal OSStatus EventHandlerProc (EventHandlerCallRef, EventRef theEvent,
return noErr;
}

struct CallbackMessagePayload
{
MessageCallbackFunction* function;
void* parameter;
void* volatile result;
bool volatile hasBeenExecuted;
};

static pascal OSStatus CallbackHandlerProc (EventHandlerCallRef, EventRef theEvent, void* userData)
{
CallbackMessagePayload* pl = 0;
@@ -256643,6 +256784,8 @@ static EventQueueRef mainQueue;
static EventHandlerRef juceEventHandler = 0;
static EventHandlerRef callbackEventHandler = 0;

#endif

void MessageManager::doPlatformSpecificInitialisation()
{
static bool initialised = false;
@@ -256651,21 +256794,22 @@ void MessageManager::doPlatformSpecificInitialisation()
{
initialised = true;

#if MACOS_10_3_OR_EARLIER
// work-around for a bug in MacOS 10.2..
ProcessSerialNumber junkPSN;
(void) GetCurrentProcess (&junkPSN);
#endif

mainQueue = GetMainEventQueue();

#if JUCE_COCOA
// if we're linking a Juce app to one or more dynamic libraries, we'll need different values
// for this so each module doesn't interfere with the others.
UnsignedWide t;
Microseconds (&t);
kJUCEClass ^= t.lo;

juceMessageName = juceStringToNS ("juce_" + String::toHexString ((int) t.lo));

juceAppDelegate = [[JuceAppDelegate alloc] init];
#else
mainQueue = GetMainEventQueue();
#endif
}

#if ! JUCE_COCOA
const EventTypeSpec type1 = { kJUCEClass, kJUCEKind };
InstallApplicationEventHandler (NewEventHandlerUPP (EventHandlerProc), 1, &type1, 0, &juceEventHandler);

@@ -256690,6 +256834,7 @@ void MessageManager::doPlatformSpecificInitialisation()
AEInstallEventHandler (kCoreEventClass, kAEOpenDocuments,
NewAEEventHandlerUPP (OpenDocEventHandler), 0, false);
}
#endif
}

void MessageManager::doPlatformSpecificShutdown()
@@ -256709,6 +256854,14 @@ void MessageManager::doPlatformSpecificShutdown()

bool juce_postMessageToSystemQueue (void* message)
{
#if JUCE_COCOA
[[NSNotificationCenter defaultCenter] postNotificationName: juceMessageName
object: [NSData dataWithBytes: &message
length: (int) sizeof (message)]];

return true;

#else
jassert (mainQueue == GetMainEventQueue());

EventRef event;
@@ -256721,6 +256874,7 @@ bool juce_postMessageToSystemQueue (void* message)
}

return false;
#endif
}

void MessageManager::broadcastMessage (const String& value) throw()
@@ -256736,14 +256890,22 @@ void* MessageManager::callFunctionOnMessageThread (MessageCallbackFunction* call
}
else
{
jassert (mainQueue == GetMainEventQueue());

CallbackMessagePayload cmp;
cmp.function = callback;
cmp.parameter = data;
cmp.result = 0;
cmp.hasBeenExecuted = false;

#if JUCE_COCOA
[juceAppDelegate performSelectorOnMainThread: @selector (performCallback:)
withObject: (id) &cmp
waitUntilDone: YES];

return cmp.result;

#else
jassert (mainQueue == GetMainEventQueue());

EventRef event;
if (CreateEvent (0, kJUCEClass, kCallbackKind, 0, kEventAttributeUserEvent, &event) == noErr)
{
@@ -256760,6 +256922,7 @@ void* MessageManager::callFunctionOnMessageThread (MessageCallbackFunction* call
}

return 0;
#endif
}
}

@@ -257176,7 +257339,6 @@ END_JUCE_NAMESPACE
/********* Start of inlined file: juce_mac_Windowing.mm *********/

#include <Carbon/Carbon.h>
#include <Cocoa/Cocoa.h>
#include <IOKit/IOKitLib.h>
#include <IOKit/IOCFPlugIn.h>
#include <IOKit/hid/IOHIDLib.h>
@@ -259233,6 +259395,11 @@ bool juce_dispatchNextMessageOnSystemQueue (bool returnIfNoPendingMessages)
if (juce_currentMouseTrackingPeer != 0)
trackNextMouseEvent();

/* [[NSRunLoop mainRunLoop] acceptInputForMode: NSDefaultRunLoopMode
beforeDate: returnIfNoPendingMessages
? [[NSDate date] addTimeInterval: 0.01]
: [NSDate distantFuture]];
*/
EventRef theEvent;

if (ReceiveNextEvent (0, 0, (returnIfNoPendingMessages) ? kEventDurationNoWait
@@ -259255,7 +259422,7 @@ bool juce_dispatchNextMessageOnSystemQueue (bool returnIfNoPendingMessages)
return true;
}

return false;
return true;
}

ComponentPeer* Component::createNewPeer (int styleFlags, void* windowToAttachTo)


+ 4
- 2
juce_amalgamated.h View File

@@ -7464,7 +7464,7 @@ public:

/** Returns the type of operating system we're running on.

@returns one of the values from the OSType enum.
@returns one of the values from the OperatingSystemType enum.
@see getOperatingSystemName
*/
static OperatingSystemType getOperatingSystemType() throw();
@@ -44393,7 +44393,7 @@ public:
key to toggle velocity-sensitive mode
*/
void setVelocityModeParameters (const double sensitivity = 1.0,
const int threshold = 1.0,
const int threshold = 1,
const double offset = 0.0,
const bool userCanPressKeyToSwapMode = true) throw();

@@ -49163,6 +49163,8 @@ public:
private:
FileListComponent (const FileListComponent&);
const FileListComponent& operator= (const FileListComponent&);

File lastDirectory;
};

#endif // __JUCE_FILELISTCOMPONENT_JUCEHEADER__


+ 1
- 1
src/juce_appframework/gui/components/controls/juce_Slider.h View File

@@ -171,7 +171,7 @@ public:
key to toggle velocity-sensitive mode
*/
void setVelocityModeParameters (const double sensitivity = 1.0,
const int threshold = 1.0,
const int threshold = 1,
const double offset = 0.0,
const bool userCanPressKeyToSwapMode = true) throw();


+ 6
- 0
src/juce_appframework/gui/components/filebrowser/juce_FileListComponent.cpp View File

@@ -70,6 +70,12 @@ void FileListComponent::scrollToTop()
void FileListComponent::changeListenerCallback (void*)
{
updateContent();
if (lastDirectory != fileList.getDirectory())
{
lastDirectory = fileList.getDirectory();
deselectAllRows();
}
}
//==============================================================================


+ 2
- 0
src/juce_appframework/gui/components/filebrowser/juce_FileListComponent.h View File

@@ -96,6 +96,8 @@ public:
private:
FileListComponent (const FileListComponent&);
const FileListComponent& operator= (const FileListComponent&);
File lastDirectory;
};


+ 3
- 0
src/juce_appframework/gui/components/special/juce_QuickTimeMovieComponent.cpp View File

@@ -326,7 +326,10 @@ void QuickTimeMovieComponent::setSpeed (const float newSpeed)
void QuickTimeMovieComponent::setMovieVolume (const float newVolume)
{
if (qtMovie != 0)
{
qtMovie->PutAudioVolume (newVolume);
qtMovie->PutAudioMute (newVolume <= 0);
}
}
float QuickTimeMovieComponent::getMovieVolume() const


+ 1
- 1
src/juce_core/basics/juce_SystemStats.h View File

@@ -75,7 +75,7 @@ public:
/** Returns the type of operating system we're running on.
@returns one of the values from the OSType enum.
@returns one of the values from the OperatingSystemType enum.
@see getOperatingSystemName
*/
static OperatingSystemType getOperatingSystemType() throw();


Loading…
Cancel
Save