Logo Search packages:      
Sourcecode: blender version File versions

bool GHOST_SystemCarbon::handleMouseDown ( EventRef  event  )  [protected]

Handles all basic Mac application stuff for a mouse down event.

Parameters:
event A Mac event.
Returns:
Indication whether the event was handled.

Definition at line 826 of file GHOST_SystemCarbon.cpp.

References getMilliSeconds(), handleMenuCommand(), m_ignoreWindowSizedMessages, GHOST_System::pushEvent(), and GHOST_System::validWindow().

Referenced by handleMouseEvent().

{
      WindowPtr               window;
      short                   part;
      BitMap                        screenBits;
    bool                      handled = true;
    GHOST_WindowCarbon* ghostWindow;
    Point                     mousePos = {0 , 0};
      
      ::GetEventParameter(event, kEventParamMouseLocation, typeQDPoint, NULL, sizeof(Point), NULL, &mousePos);
      
      part = ::FindWindow(mousePos, &window);
      ghostWindow = (GHOST_WindowCarbon*) ::GetWRefCon(window);
      
      switch (part) {
            case inMenuBar:
                  handleMenuCommand(::MenuSelect(mousePos));
                  break;
                  
            case inDrag:
                  /*
                   * The DragWindow() routine creates a lot of kEventWindowBoundsChanged
                   * events. By setting m_ignoreWindowSizedMessages these are suppressed.
                   * @see GHOST_SystemCarbon::handleWindowEvent(EventRef event)
                   */
                  GHOST_ASSERT(validWindow(ghostWindow), "GHOST_SystemCarbon::handleMouseDown: invalid window");
                  m_ignoreWindowSizedMessages = true;
                  ::DragWindow(window, mousePos, &GetQDGlobalsScreenBits(&screenBits)->bounds);
                  m_ignoreWindowSizedMessages = false;
                  break;
            
            case inContent:
                  if (window != ::FrontWindow()) {
                        ::SelectWindow(window);
                        /*
                         * We add a mouse down event on the newly actived window
                         */         
                        //GHOST_PRINT("GHOST_SystemCarbon::handleMouseDown(): adding mouse down event, " << ghostWindow << "\n");
                        EventMouseButton button;
                        ::GetEventParameter(event, kEventParamMouseButton, typeMouseButton, NULL, sizeof(button), NULL, &button);
                        pushEvent(new GHOST_EventButton(getMilliSeconds(), GHOST_kEventButtonDown, ghostWindow, convertButton(button)));
                  } else {
                        handled = false;
                  }
                  break;
                  
            case inGoAway:
                  GHOST_ASSERT(ghostWindow, "GHOST_SystemCarbon::handleMouseEvent: ghostWindow==0");
                  if (::TrackGoAway(window, mousePos))
                  {
                        // todo: add option-close, because itěs in the HIG
                        // if (event.modifiers & optionKey) {
                              // Close the clean documents, others will be confirmed one by one.
                        //}
                        // else {
                        pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowClose, ghostWindow));
                        //}
                  }
                  break;
                  
            case inGrow:
                  GHOST_ASSERT(ghostWindow, "GHOST_SystemCarbon::handleMouseEvent: ghostWindow==0");
                  ::ResizeWindow(window, mousePos, NULL, NULL);
                  break;
                  
            case inZoomIn:
            case inZoomOut:
                  GHOST_ASSERT(ghostWindow, "GHOST_SystemCarbon::handleMouseEvent: ghostWindow==0");
                  if (::TrackBox(window, mousePos, part)) {
                        int macState;
                        
                        macState = ghostWindow->getMac_windowState();
                        if ( macState== 0)
                              ::ZoomWindow(window, part, true);
                        else 
                              if (macState == 2) { // always ok
                                          ::ZoomWindow(window, part, true);
                                          ghostWindow->setMac_windowState(1);
                              } else { // need to force size again
                                    GHOST_TUns32 scr_x,scr_y;
                                    Rect outAvailableRect;
                                    
                                    ghostWindow->setMac_windowState(2);
                                    ::GetAvailableWindowPositioningBounds ( GetMainDevice(), &outAvailableRect);
                                    
                                    //this->getMainDisplayDimensions(scr_x,scr_y);
                                    ::SizeWindow (window, outAvailableRect.right-outAvailableRect.left,outAvailableRect.bottom-outAvailableRect.top-1,false);
                                    ::MoveWindow (window, outAvailableRect.left, outAvailableRect.top,true);
                              }
                        
                  }
                  break;

            default:
                  handled = false;
                  break;
      }
      
      return handled;
}


Generated by  Doxygen 1.6.0   Back to index