Show
Ignore:
Timestamp:
03/11/09 11:34:29 (4 years ago)
Author:
robert
Message:

Converted tabs to four spaces

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/src/osgViewer/GraphicsWindowCocoa.mm

    r9879 r9895  
    143143std::ostream& operator<<(std::ostream& os, const NSRect& rect)  
    144144{ 
    145         os << rect.origin.x << "/" << rect.origin.y << " " << rect.size.width << "x" << rect.size.height; 
    146         return os; 
     145    os << rect.origin.x << "/" << rect.origin.y << " " << rect.size.width << "x" << rect.size.height; 
     146    return os; 
    147147} 
    148148 
     
    158158    NSRect frame = [[[NSScreen screens] objectAtIndex: 0] frame]; 
    159159    float y = frame.size.height - rect.origin.y - rect.size.height; 
    160         NSRect converted = NSMakeRect(rect.origin.x, y, rect.size.width, rect.size.height); 
    161          
    162         // std::cout << "converting from Quartz " << rect << " to " << converted << " using screen rect " << frame << std::endl; 
    163          
     160    NSRect converted = NSMakeRect(rect.origin.x, y, rect.size.width, rect.size.height); 
     161     
     162    // std::cout << "converting from Quartz " << rect << " to " << converted << " using screen rect " << frame << std::endl; 
     163     
    164164    return converted; 
    165165} 
     
    170170     
    171171    float y = frame.size.height - (rect.origin.y + rect.size.height); 
    172         NSRect converted = NSMakeRect(rect.origin.x, y, rect.size.width, rect.size.height); 
    173          
    174         // std::cout << "converting To Quartz   " << rect << " to " << converted << " using screen rect " << frame << std::endl; 
    175          
     172    NSRect converted = NSMakeRect(rect.origin.x, y, rect.size.width, rect.size.height); 
     173     
     174    // std::cout << "converting To Quartz   " << rect << " to " << converted << " using screen rect " << frame << std::endl; 
     175     
    176176    return converted; 
    177177} 
     
    245245        BOOL _isUsingCtrlClick, _isUsingOptionClick; 
    246246        unsigned int _cachedModifierFlags; 
    247                 BOOL _handleTabletEvents; 
     247        BOOL _handleTabletEvents; 
    248248         
    249249} 
     
    362362 
    363363- (void)flagsChanged:(NSEvent *)theEvent { 
    364         [self handleModifiers: theEvent]; 
     364    [self handleModifiers: theEvent]; 
    365365} 
    366366 
     
    393393        [self doLeftMouseButtonDown:theEvent]; 
    394394    } 
    395          
    396         if ([theEvent subtype] == NSTabletPointEventSubtype) { 
    397                 _handleTabletEvents = true; 
    398                 [self handleTabletEvents:theEvent]; 
    399         } 
     395     
     396    if ([theEvent subtype] == NSTabletPointEventSubtype) { 
     397        _handleTabletEvents = true; 
     398        [self handleTabletEvents:theEvent]; 
     399    } 
    400400} 
    401401 
     
    405405    NSPoint converted_point = [self getLocalPoint: theEvent];     
    406406    _win->getEventQueue()->mouseMotion(converted_point.x, converted_point.y); 
    407          
    408         if (_handleTabletEvents) 
    409                 [self handleTabletEvents:theEvent]; 
     407     
     408    if (_handleTabletEvents) 
     409        [self handleTabletEvents:theEvent]; 
    410410} 
    411411 
     
    431431        [self doLeftMouseButtonUp:theEvent]; 
    432432    } 
    433         _handleTabletEvents = false; 
     433    _handleTabletEvents = false; 
    434434} 
    435435 
     
    449449{ 
    450450    [self doRightMouseButtonUp:theEvent]; 
    451         _handleTabletEvents = false; 
     451    _handleTabletEvents = false; 
    452452} 
    453453 
     
    638638- (void)tabletPoint:(NSEvent *)theEvent 
    639639{ 
    640         //_handleTabletEvents = YES; 
    641         //[self handleTabletEvents:theEvent]; 
     640    //_handleTabletEvents = YES; 
     641    //[self handleTabletEvents:theEvent]; 
    642642} 
    643643 
    644644-(void)handleTabletEvents:(NSEvent *)theEvent 
    645645{ 
    646         float pressure = [theEvent pressure]; 
    647         _win->getEventQueue()->penPressure(pressure); 
    648         NSPoint tilt = [theEvent tilt]; 
    649          
    650         _win->getEventQueue()->penOrientation (tilt.x, tilt.y, [theEvent rotation]); 
     646    float pressure = [theEvent pressure]; 
     647    _win->getEventQueue()->penPressure(pressure); 
     648    NSPoint tilt = [theEvent tilt]; 
     649     
     650    _win->getEventQueue()->penOrientation (tilt.x, tilt.y, [theEvent rotation]); 
    651651} 
    652652 
     
    654654- (void)tabletProximity:(NSEvent *)theEvent 
    655655{ 
    656         osgGA::GUIEventAdapter::TabletPointerType pt(osgGA::GUIEventAdapter::UNKNOWN); 
    657         switch ([theEvent pointingDeviceType]) { 
    658                 case NSPenPointingDevice: 
    659                         pt = osgGA::GUIEventAdapter::PEN; 
    660                         break; 
    661                 case NSCursorPointingDevice: 
    662                         pt = osgGA::GUIEventAdapter::PUCK; 
    663                         break; 
    664                 case NSEraserPointingDevice: 
    665                         pt = osgGA::GUIEventAdapter::ERASER; 
    666                         break; 
    667                 default: 
    668                         break; 
    669         } 
    670         _win->getEventQueue()->penProximity(pt, [theEvent isEnteringProximity]);  
     656    osgGA::GUIEventAdapter::TabletPointerType pt(osgGA::GUIEventAdapter::UNKNOWN); 
     657    switch ([theEvent pointingDeviceType]) { 
     658        case NSPenPointingDevice: 
     659            pt = osgGA::GUIEventAdapter::PEN; 
     660            break; 
     661        case NSCursorPointingDevice: 
     662            pt = osgGA::GUIEventAdapter::PUCK; 
     663            break; 
     664        case NSEraserPointingDevice: 
     665            pt = osgGA::GUIEventAdapter::ERASER; 
     666            break; 
     667        default: 
     668            break; 
     669    } 
     670    _win->getEventQueue()->penProximity(pt, [theEvent isEnteringProximity]);  
    671671} 
    672672 
     
    762762     
    763763    virtual bool valid() { return (_win.valid() && _win->valid()); } 
    764          
     764     
    765765    virtual void getWindowBounds(CGRect& rect)  
    766766    { 
     
    773773        rect.size.height = nsrect.size.height; 
    774774    } 
    775          
     775     
    776776    virtual osgViewer::GraphicsWindow* getWindow() {return _win.get(); } 
    777777private: 
     
    808808 
    809809    [win setReleasedWhenClosed:NO]; 
    810         [win setDisplaysWhenScreenProfileChanges:YES];   
     810    [win setDisplaysWhenScreenProfileChanges:YES];     
    811811    GraphicsWindowCocoaDelegate* delegate = [[GraphicsWindowCocoaDelegate alloc] initWith: this]; 
    812812    [win setDelegate: delegate ]; 
    813813    //[delegate autorelease]; 
    814              
     814         
    815815    [win makeKeyAndOrderFront:nil]; 
    816816    [win setAcceptsMouseMovedEvents: YES]; 
     
    836836            style |= NSResizableWindowMask; 
    837837    } 
    838          
     838         
    839839    DarwinWindowingSystemInterface* wsi = dynamic_cast<DarwinWindowingSystemInterface*>(osg::GraphicsContext::getWindowingSystemInterface()); 
    840840    int screenLeft(0), screenTop(0); 
     
    843843    } 
    844844     
    845         NSRect rect = NSMakeRect(_traits->x + screenLeft, _traits->y + screenTop, _traits->width, _traits->height); 
    846      
    847         _window = [[GraphicsWindowCocoaWindow alloc] initWithContentRect: rect styleMask: style backing: NSBackingStoreBuffered defer: NO]; 
    848          
     845    NSRect rect = NSMakeRect(_traits->x + screenLeft, _traits->y + screenTop, _traits->width, _traits->height); 
     846     
     847    _window = [[GraphicsWindowCocoaWindow alloc] initWithContentRect: rect styleMask: style backing: NSBackingStoreBuffered defer: NO]; 
     848     
    849849    if (!_window) { 
    850850        osg::notify(osg::WARN) << "GraphicsWindowCocoa::realizeImplementation :: could not create window" << std::endl; 
     
    854854    rect = convertFromQuartzCoordinates(rect); 
    855855    [_window setFrameOrigin: rect.origin]; 
    856          
    857         NSOpenGLPixelFormatAttribute attr[32]; 
     856     
     857    NSOpenGLPixelFormatAttribute attr[32]; 
    858858    int i = 0; 
    859859     
     
    902902        } 
    903903    } 
    904          
    905         NSOpenGLPixelFormat* pixelformat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attr ]; 
     904     
     905    NSOpenGLPixelFormat* pixelformat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attr ]; 
    906906    _context = [[NSOpenGLContext alloc] initWithFormat: pixelformat shareContext: sharedContext]; 
    907907     
     
    910910        return false; 
    911911    } 
    912         GraphicsWindowCocoaGLView* theView = [[ GraphicsWindowCocoaGLView alloc ] initWithFrame:[ _window frame ] ]; 
     912    GraphicsWindowCocoaGLView* theView = [[ GraphicsWindowCocoaGLView alloc ] initWithFrame:[ _window frame ] ]; 
    913913    [theView setAutoresizingMask:  (NSViewWidthSizable | NSViewHeightSizable) ]; 
    914914    [theView setGraphicsWindowCocoa: this]; 
    915915    [theView setOpenGLContext:_context]; 
    916         [_window setContentView: theView]; 
    917          
     916    [_window setContentView: theView]; 
     917     
    918918    setupNSWindow(_window); 
    919919     
    920920    [theView release]; 
    921921    [pool release]; 
    922          
     922     
    923923    MenubarController::instance()->attachWindow( new CocoaWindowAdapter(this) ); 
    924924     
     
    951951    if (mbc) mbc->detachWindow(this); 
    952952     
    953         [_window close]; 
     953    [_window close]; 
    954954    [_window release]; 
    955955} 
     
    962962bool GraphicsWindowCocoa:: makeCurrentImplementation() 
    963963{ 
    964         [_context makeCurrentContext]; 
    965         return true; 
     964    [_context makeCurrentContext]; 
     965    return true; 
    966966} 
    967967 
     
    973973bool GraphicsWindowCocoa::releaseContextImplementation() 
    974974{ 
    975         [NSOpenGLContext clearCurrentContext]; 
    976         return true; 
     975    [NSOpenGLContext clearCurrentContext]; 
     976    return true; 
    977977} 
    978978 
     
    984984void GraphicsWindowCocoa::swapBuffersImplementation() 
    985985{ 
    986         [_context flushBuffer]; 
     986    [_context flushBuffer]; 
    987987} 
    988988 
     
    994994void GraphicsWindowCocoa::checkEvents() 
    995995{ 
    996         NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 
     996    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 
    997997     
    998998    while(1) 
     
    10131013            break; 
    10141014        [[NSApplication sharedApplication] sendEvent: event]; 
    1015     }    
     1015    }     
    10161016     
    10171017    if (_closeRequested) 
     
    10231023    } 
    10241024         
    1025         [pool release]; 
     1025    [pool release]; 
    10261026} 
    10271027 
     
    10381038{ 
    10391039    if (!_realized) return false; 
    1040          
     1040     
    10411041    unsigned int style(NSBorderlessWindowMask); 
    10421042     
     
    10481048            style |= NSResizableWindowMask; 
    10491049    } 
    1050         NSRect rect = [_window contentRectForFrameRect: [_window frame] ]; 
    1051         GraphicsWindowCocoaWindow* new_win = [[GraphicsWindowCocoaWindow alloc] initWithContentRect: rect styleMask: style backing: NSBackingStoreBuffered defer: NO]; 
     1050    NSRect rect = [_window contentRectForFrameRect: [_window frame] ]; 
     1051    GraphicsWindowCocoaWindow* new_win = [[GraphicsWindowCocoaWindow alloc] initWithContentRect: rect styleMask: style backing: NSBackingStoreBuffered defer: NO]; 
    10521052     
    10531053    if (new_win) { 
     
    10621062    } 
    10631063     
    1064         return true; 
     1064    return true; 
    10651065} 
    10661066 
     
    10711071void GraphicsWindowCocoa::grabFocus() 
    10721072{ 
    1073         [_window makeKeyAndOrderFront: nil]; 
     1073    [_window makeKeyAndOrderFront: nil]; 
    10741074} 
    10751075 
     
    10801080void GraphicsWindowCocoa::grabFocusIfPointerInWindow() 
    10811081{ 
    1082         osg::notify(osg::INFO) << "GraphicsWindowCocoa :: grabFocusIfPointerInWindow not implemented yet " << std::endl; 
     1082    osg::notify(osg::INFO) << "GraphicsWindowCocoa :: grabFocusIfPointerInWindow not implemented yet " << std::endl; 
    10831083} 
    10841084 
     
    10901090void GraphicsWindowCocoa::resizedImplementation(int x, int y, int width, int height) 
    10911091{ 
    1092         std::cout << "resized implementation" << x << " " << y << " " << width << " " << height << std::endl;  
    1093         GraphicsContext::resizedImplementation(x, y, width, height); 
     1092    std::cout << "resized implementation" << x << " " << y << " " << width << " " << height << std::endl;  
     1093    GraphicsContext::resizedImplementation(x, y, width, height); 
    10941094    
    10951095    [_context update]; 
    10961096    MenubarController::instance()->update(); 
    1097         getEventQueue()->windowResize(x,y,width, height, getEventQueue()->getTime()); 
     1097    getEventQueue()->windowResize(x,y,width, height, getEventQueue()->getTime()); 
    10981098} 
    10991099 
     
    11061106bool GraphicsWindowCocoa::setWindowRectangleImplementation(int x, int y, int width, int height) 
    11071107{ 
    1108         DarwinWindowingSystemInterface* wsi = dynamic_cast<DarwinWindowingSystemInterface*>(osg::GraphicsContext::getWindowingSystemInterface()); 
     1108    DarwinWindowingSystemInterface* wsi = dynamic_cast<DarwinWindowingSystemInterface*>(osg::GraphicsContext::getWindowingSystemInterface()); 
    11091109    int screenLeft(0), screenTop(0); 
    11101110    if (wsi) { 
     
    11311131{ 
    11321132 
    1133         DarwinWindowingSystemInterface* wsi = dynamic_cast<DarwinWindowingSystemInterface*>(osg::GraphicsContext::getWindowingSystemInterface()); 
     1133    DarwinWindowingSystemInterface* wsi = dynamic_cast<DarwinWindowingSystemInterface*>(osg::GraphicsContext::getWindowingSystemInterface()); 
    11341134    int screenLeft(0), screenTop(0); 
    11351135    if (wsi) { 
    1136                  
    1137                 // get the screen containing the window 
    1138                 unsigned int screenNdx = wsi->getScreenContaining(x,y,w,h); 
    1139                  
    1140                 // update traits 
    1141                 _traits->screenNum = screenNdx; 
    1142                  
    1143                 // get top left of screen 
     1136         
     1137        // get the screen containing the window 
     1138        unsigned int screenNdx = wsi->getScreenContaining(x,y,w,h); 
     1139         
     1140        // update traits 
     1141        _traits->screenNum = screenNdx; 
     1142         
     1143        // get top left of screen 
    11441144        wsi->getScreenTopLeft((*_traits), screenLeft, screenTop); 
    11451145    } 
    1146          
    1147         resized(x-screenLeft,y-screenTop,w,h); 
     1146     
     1147    resized(x-screenLeft,y-screenTop,w,h); 
    11481148} 
    11491149 
     
    11551155void GraphicsWindowCocoa::setWindowName (const std::string & name) 
    11561156{ 
    1157         NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 
     1157    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 
    11581158     
    11591159    NSString* title = [NSString stringWithCString: name.c_str() encoding: NSUTF8StringEncoding]; 
    1160         [_window setTitle: title]; 
    1161         [title release]; 
     1160    [_window setTitle: title]; 
     1161    [title release]; 
    11621162    [pool release]; 
    11631163} 
     
    11701170void GraphicsWindowCocoa::useCursor(bool cursorOn) 
    11711171{ 
    1172         if (_traits.valid()) 
     1172    if (_traits.valid()) 
    11731173        _traits->useCursor = cursorOn; 
    11741174    DarwinWindowingSystemInterface* wsi = dynamic_cast<DarwinWindowingSystemInterface*>(osg::GraphicsContext::getWindowingSystemInterface()); 
     
    12011201void GraphicsWindowCocoa::setCursor(MouseCursor mouseCursor) 
    12021202{ 
    1203         switch (mouseCursor)  
     1203    switch (mouseCursor)  
    12041204    { 
    12051205 
     
    12331233{ 
    12341234    GLint VBL(f?1:0); 
    1235         [_context setValues:&VBL forParameter:NSOpenGLCPSwapInterval]; 
     1235    [_context setValues:&VBL forParameter:NSOpenGLCPSwapInterval]; 
    12361236} 
    12371237 
     
    12541254 
    12551255struct CocoaWindowingSystemInterface : public DarwinWindowingSystemInterface { 
    1256          
    1257         CocoaWindowingSystemInterface() 
    1258         :       DarwinWindowingSystemInterface()  
    1259         { 
    1260                 localPool = [[NSAutoreleasePool alloc] init]; 
     1256     
     1257    CocoaWindowingSystemInterface() 
     1258    :    DarwinWindowingSystemInterface()  
     1259    { 
     1260        localPool = [[NSAutoreleasePool alloc] init]; 
    12611261        [[NSApplication sharedApplication] setDelegate: [[CocoaAppDelegate alloc] init] ]; 
    1262         } 
    1263          
    1264         virtual osg::GraphicsContext* createGraphicsContext(osg::GraphicsContext::Traits* traits)  
    1265         { 
    1266                 return createGraphicsContextImplementation<PixelBufferCocoa, GraphicsWindowCocoa>(traits); 
    1267         } 
    1268          
    1269         virtual ~CocoaWindowingSystemInterface()  
    1270         { 
    1271                 [localPool release]; 
    1272         } 
    1273          
    1274         NSAutoreleasePool *localPool; 
     1262    } 
     1263     
     1264    virtual osg::GraphicsContext* createGraphicsContext(osg::GraphicsContext::Traits* traits)  
     1265    { 
     1266        return createGraphicsContextImplementation<PixelBufferCocoa, GraphicsWindowCocoa>(traits); 
     1267    } 
     1268     
     1269    virtual ~CocoaWindowingSystemInterface()  
     1270    { 
     1271        [localPool release]; 
     1272    } 
     1273     
     1274    NSAutoreleasePool *localPool; 
    12751275 
    12761276};