Changeset 20000

Show
Ignore:
Timestamp:
04/22/07 16:19:34 (2 years ago)
Author:
patrick
Message:

MFT r19995: Added the ability for users to change the NSApplication delegate

class by modifying vrjuggler.plist in the application bundle. I
came up with the idea for this while thinking about the
documentation for VR Juggler applications that want to interact
with Cocoa. Originally, my plan was for users to disable the use
of vrj::CocoaWrapper? in the kernel and use their own bridging
code instead, but the work done by vrj::CocoaWrapper? is so simple,
and it really shouldn't be done any other way. The much more
interesting aspect is being able to change the NSApplication
delegate since that is what gets hooked up to menu events and
such. Thanks to the dynamic nature of Objective-C, it turned out
to be not only feasible, but simple to do this.

Bumped version to 2.1.23.

Wow, 20,000 revisions…

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • juggler/branches/2.2/modules/vrjuggler/ChangeLog

    r19910 r20000  
    11DATE        AUTHOR      CHANGE 
    22----------- ----------- ------------------------------------------------------- 
     3Apr-22-2007 patrick     Application programmers can now choose to use an 
     4                        NSApplication delegate other than VrjMainController. 
     5                        NEW VERSION: 2.1.23 
    36Apr-07-2007 patrick     Made the number of sample buffers and samples per 
    47                        buffer configurable when using multisampling. 
  • juggler/branches/2.2/modules/vrjuggler/VERSION

    r19910 r20000  
     12.1.23-0 @04/22/2007 21:20:00 UTC@ 
    122.1.22-0 @04/07/2007 18:00:00 UTC@ 
    232.1.21-0 @04/05/2007 22:20:00 UTC@ 
  • juggler/branches/2.2/modules/vrjuggler/data/bundle/vrjuggler.plist

    r19884 r20000  
    55        <key>VRJConfigHandling</key> 
    66        <false/> 
     7        <key>VRJControllerClass</key> 
     8        <string>VrjMainController</string> 
    79</dict> 
    810</plist> 
  • juggler/branches/2.2/modules/vrjuggler/vrj/Kernel/CocoaWrapper.mm

    r19997 r20000  
    2929#include <assert.h> 
    3030#include <boost/bind.hpp> 
     31#include <objc/objc-runtime.h> 
    3132 
    3233#import <Foundation/NSValue.h> 
     
    428429   // application:openFile: and application:openFiles: messages. 
    429430   BOOL load_cfg_files = YES; 
     431   NSString* ctrl_class_name = @"VrjMainController"; 
    430432 
    431433   if ( vrj_dict ) 
     
    437439         load_cfg_files = [cfg_handling boolValue]; 
    438440      } 
    439    } 
    440  
    441    VrjMainController* main_controller = 
    442       [[[VrjMainController alloc] init] autorelease]; 
     441 
     442      NSString* name = [vrj_dict objectForKey:@"VRJControllerClass"]; 
     443 
     444      if ( nil != name ) 
     445      { 
     446         ctrl_class_name = name; 
     447      } 
     448   } 
     449 
     450   id controller_class = objc_getClass([ctrl_class_name UTF8String]); 
     451 
     452   if ( nil == controller_class ) 
     453   { 
     454      NSLog(@"WARNING: Could not find declaration of %@!\n", ctrl_class_name); 
     455      NSLog(@"         Falling back on VrjMainController\n"); 
     456      controller_class = [VrjMainController class]; 
     457   } 
     458 
     459   id main_controller = [[[controller_class alloc] init] autorelease]; 
    443460   [main_controller setLoadConfigs:load_cfg_files]; 
    444461