Exemple #1
0
void OpenUserDataRec::EventProcCBEventMouseDown(NavCBRecPtr callBackParms)
{
    EventRecord *evt = callBackParms->eventData.eventDataParms.event;
    Point where = evt->where;
    QDGlobalToLocalPoint(GetWindowPort(callBackParms->window), &where);

    ControlRef whichControl = FindControlUnderMouse(where, callBackParms->window, NULL);
    if (whichControl != NULL)
    {
        ControlKind theKind;
        GetControlKind(whichControl, &theKind);

        // Moving the focus if we clicked in an focusable control
        if ((theKind.kind == kControlKindEditUnicodeText) ||
            (theKind.kind == kControlKindEditText) ||
            (theKind.kind == kControlKindDataBrowser) ||
            (theKind.kind == kControlKindListBox))
        {
            ControlRef currentlyFocusedControl;
            GetKeyboardFocus(callBackParms->window, &currentlyFocusedControl);
            if (currentlyFocusedControl != whichControl)
                SetKeyboardFocus(callBackParms->window, whichControl, kControlFocusNextPart);
        }
        HandleControlClick(whichControl, where, evt->modifiers, NULL);
    }
}
static void HandleCustomMouseDown(NavCBRecPtr callBackParms, CustomData *data)
{
	EventRecord *evt = callBackParms->eventData.eventDataParms.event;
	Point where = evt->where;
   
	GlobalToLocal(&where);
   
	ControlRef control = FindControlUnderMouse(where, callBackParms->window, NULL);
	if (control != NULL)
   {
      HandleControlClick(control, where, evt->modifiers, (ControlActionUPP)-1L);
                  NavCustomControl(callBackParms->context, kNavCtlBrowserRedraw, NULL);
               }
}
Exemple #3
0
void doInContent(EventRecord *eventStrucPtr,WindowRef windowRef)
{
    ControlPartCode controlPartCode;
    ControlRef      controlRef;

    SetPortWindowPort(windowRef);
    GlobalToLocal(&eventStrucPtr->where);

    if(controlRef = FindControlUnderMouse(eventStrucPtr->where,windowRef,&controlPartCode))
    {
#if TARGET_API_MAC_CARBON
        TrackControl(controlRef,eventStrucPtr->where,(ControlActionUPP) -1);
#else
        if (controlPartCode == kControlIndicatorPart)
            TrackControl(controlRef,eventStrucPtr->where,NULL);
        else
            TrackControl(controlRef,eventStrucPtr->where,gActionFunctionScrollUPP);
#endif

        window_invalidate(windowRef);
    }
}
Exemple #4
0
pascal OSErr wxMacWindowDragTrackingHandler(
    DragTrackingMessage theMessage, WindowPtr theWindow,
    void *handlerRefCon, DragReference theDrag )
{
    MacTrackingGlobals* trackingGlobals = (MacTrackingGlobals*) handlerRefCon;

    Point mouse, localMouse;
    DragAttributes attributes;

    GetDragAttributes( theDrag, &attributes );
    PasteboardRef   pasteboard = 0;
    GetDragPasteboard( theDrag, &pasteboard );
    wxNonOwnedWindow* toplevel = wxNonOwnedWindow::GetFromWXWindow( (WXWindow) theWindow );

    bool optionDown = GetCurrentKeyModifiers() & optionKey;
    wxDragResult result = optionDown ? wxDragCopy : wxDragMove;

    switch (theMessage)
    {
        case kDragTrackingEnterHandler:
        case kDragTrackingLeaveHandler:
            break;

        case kDragTrackingEnterWindow:
            if (trackingGlobals != NULL)
            {
                trackingGlobals->m_currentTargetWindow = NULL;
                trackingGlobals->m_currentTarget = NULL;
            }
            break;

        case kDragTrackingInWindow:
            if (trackingGlobals == NULL)
                break;
            if (toplevel == NULL)
                break;

            GetDragMouse( theDrag, &mouse, 0L );
            {
                int x = mouse.h ;
                int y = mouse.v ;
                toplevel->GetNonOwnedPeer()->ScreenToWindow( &x, &y );
                localMouse.h = x;
                localMouse.v = y;

                {
                    wxWindow *win = NULL;
                    ControlPartCode controlPart;
                    ControlRef control = FindControlUnderMouse( localMouse, theWindow, &controlPart );
                    if ( control )
                        win = wxFindWindowFromWXWidget( (WXWidget) control );
                    else
                        win = toplevel;

                    int localx, localy;
                    localx = localMouse.h;
                    localy = localMouse.v;

                    if ( win )
                        win->MacRootWindowToWindow( &localx, &localy );
                    if ( win != trackingGlobals->m_currentTargetWindow )
                    {
                        if ( trackingGlobals->m_currentTargetWindow )
                        {
                            // this window is left
                            if ( trackingGlobals->m_currentTarget )
                            {
                                HideDragHilite( theDrag );
                                trackingGlobals->m_currentTarget->SetCurrentDragPasteboard( pasteboard );
                                trackingGlobals->m_currentTarget->OnLeave();
                                trackingGlobals->m_currentTarget = NULL;
                                trackingGlobals->m_currentTargetWindow = NULL;
                            }
                        }

                        if ( win )
                        {
                            // this window is entered
                            trackingGlobals->m_currentTargetWindow = win;
                            trackingGlobals->m_currentTarget = win->GetDropTarget();
                            {
                                if ( trackingGlobals->m_currentTarget )
                                {
                                    trackingGlobals->m_currentTarget->SetCurrentDragPasteboard( pasteboard );
                                    result = trackingGlobals->m_currentTarget->OnEnter( localx, localy, result );
                                }

                                if ( result != wxDragNone )
                                {
                                    int x, y;

                                    x = y = 0;
                                    win->MacWindowToRootWindow( &x, &y );
                                    RgnHandle hiliteRgn = NewRgn();
                                    Rect r = { y, x, y + win->GetSize().y, x + win->GetSize().x };
                                    RectRgn( hiliteRgn, &r );
                                    ShowDragHilite( theDrag, hiliteRgn, true );
                                    DisposeRgn( hiliteRgn );
                                }
                            }
                        }
                    }
                    else
                    {
                        if ( trackingGlobals->m_currentTarget )
                        {
                            trackingGlobals->m_currentTarget->SetCurrentDragPasteboard( pasteboard );
                            result = trackingGlobals->m_currentTarget->OnDragOver( localx, localy, result );
                        }
                    }

                    // set cursor for OnEnter and OnDragOver
                    if ( trackingGlobals->m_currentSource && !trackingGlobals->m_currentSource->GiveFeedback( result ) )
                    {
                        if ( !trackingGlobals->m_currentSource->MacInstallDefaultCursor( result ) )
                        {
                            wxStockCursor cursorID = wxCURSOR_NONE;

                            switch (result)
                            {
                                case wxDragCopy:
                                    cursorID = wxCURSOR_COPY_ARROW;
                                    break;

                                case wxDragMove:
                                    cursorID = wxCURSOR_ARROW;
                                    break;

                                case wxDragNone:
                                    cursorID = wxCURSOR_NO_ENTRY;
                                    break;

                                case wxDragError:
                                case wxDragLink:
                                case wxDragCancel:
                                default:
                                    // put these here to make gcc happy
                                    ;
                            }

                            if (cursorID != wxCURSOR_NONE)
                            {
                                wxCursor cursor( cursorID );
                                cursor.MacInstall();
                            }
                        }
                    }
                }
            }
            break;

        case kDragTrackingLeaveWindow:
            if (trackingGlobals == NULL)
                break;

            if (trackingGlobals->m_currentTarget)
            {
                trackingGlobals->m_currentTarget->SetCurrentDragPasteboard( pasteboard );
                trackingGlobals->m_currentTarget->OnLeave();
                HideDragHilite( theDrag );
                trackingGlobals->m_currentTarget = NULL;
            }
            trackingGlobals->m_currentTargetWindow = NULL;
            break;

        default:
            break;
    }

    return noErr;
}
static void HandleCustomMouseDown(NavCBRecPtr callBackParms, CustomData *data)
{
	EventRecord *evt = callBackParms->eventData.eventDataParms.event;
	Point where = evt->where;
   
	GlobalToLocal(&where);
   
	ControlRef control = FindControlUnderMouse(where, callBackParms->window, NULL);
   
	if (control != NULL)
   {
      ControlID cid;
      GetControlID(control, &cid);
      
      HandleControlClick(control, where, evt->modifiers, (ControlActionUPP)-1L);
      
      if (cid.signature == kCustom)
      {
         switch (cid.id)
         {
            case kChoice:
            {
               MenuRef menu;
               UInt32 v;
               menu = GetControlPopupMenuRef(control);
               v = GetControl32BitValue(control) - 1;
               const size_t numFilters = data->extensions.GetCount();
               
               if (v < numFilters)
               {
                  data->currentfilter = v;
                  if (data->saveMode)
                  {
                     int i = data->currentfilter;
                     
                     wxString extension =  data->extensions[i].AfterLast('.') ;
                     extension.MakeLower() ;
                     wxString sfilename ;
                     
                     wxMacCFStringHolder cfString(NavDialogGetSaveFileName(callBackParms->context), false);
                     sfilename = cfString.AsString() ;
#if 0
                     int pos = sfilename.Find('.', true) ;
                     if (pos != wxNOT_FOUND)
                     {
                        sfilename = sfilename.Left(pos + 1) + extension;
                        cfString.Assign(sfilename, wxFONTENCODING_DEFAULT);
                        NavDialogSetSaveFileName(callBackParms->context, cfString);
                     }
#endif
                  }
                  NavCustomControl(callBackParms->context, kNavCtlBrowserRedraw, NULL);
               }
               
               break;
            }
               
            case kButton:
            {
               data->me->ClickButton(GetControl32BitValue(data->choice) - 1);
               break;
            }
         }
      }
   }
}