Exemplo n.º 1
0
OSStatus
OPL_LoginDialog::handleControlHit(ControlRef cntl)
{
    OSStatus err = eventNotHandledErr;

    if (!cntl)
        return err;

    if (cntl == tab_panel)
    {
        int tab_index;

        /* Search which tab is activated */
        tab_index = GetControlValue (tab_panel) - 1;
        DisplayTabControl (tab_index, tab_panel, 2, tabs);

        /* Is the panel has been changed */
        if (tab_number == tab_index)
            return noErr;

        tab_number = tab_index;
        ClearKeyboardFocus (getWindow());
        AdvanceKeyboardFocus (getWindow());
        return noErr;
    }

error:
    return err;
}
Exemplo n.º 2
0
bool	AUCarbonViewBase::HandleEvent(EventRef event)
{
    UInt32 eclass = GetEventClass(event);
    UInt32 ekind = GetEventKind(event);
    ControlRef control;

    switch (eclass) {
    case kEventClassControl:
        switch (ekind) {
        case kEventControlClick:
            GetEventParameter(event, kEventParamDirectObject, typeControlRef, NULL, sizeof(ControlRef), NULL, &control);
            if (control == mCarbonPane) {
                ClearKeyboardFocus(mCarbonWindow);
                return true;
            }
        }
        break;
    case kEventClassWindow:
        switch (ekind) {
        case kEventWindowClosed:
            printf("caught window-closed\n");
            break;
        }
        break;
    }

    return false;
}
Exemplo n.º 3
0
bool wxTopLevelWindowMac::Destroy()
{
    // NB: this will get called during destruction if we don't do it now,
    // and may fire a kill focus event on a control being destroyed
#if wxOSX_USE_CARBON
    if (m_nowpeer && m_nowpeer->GetWXWindow())
        ClearKeyboardFocus( (WindowRef)m_nowpeer->GetWXWindow() );
#endif
    return wxTopLevelWindowBase::Destroy();
}
Exemplo n.º 4
0
bool wxTopLevelWindowMac::Destroy()
{
    // NB: this will get called during destruction if we don't do it now,
    // and may fire a kill focus event on a control being destroyed
#if wxOSX_USE_CARBON
    if (m_nowpeer && m_nowpeer->GetWXWindow())
        ClearKeyboardFocus( (WindowRef)m_nowpeer->GetWXWindow() );
#endif
    // delayed destruction: the tlw will be deleted during the next idle
    // loop iteration
    if ( !wxPendingDelete.Member(this) )
        wxPendingDelete.Append(this);
    
    Hide();
    return true;
}
bool	AUCarbonViewBase::HandleEvent(EventHandlerCallRef inHandlerRef, EventRef event)
{	
#if !__LP64__
	UInt32 eclass = GetEventClass(event);
	UInt32 ekind = GetEventKind(event);
	ControlRef control;
	
	switch (eclass) {
		case kEventClassControl:
		{
			switch (ekind) {
			case kEventControlClick:
				GetEventParameter(event, kEventParamDirectObject, typeControlRef, NULL, sizeof(ControlRef), NULL, &control);
				if (control == mCarbonPane) {
					ClearKeyboardFocus(mCarbonWindow);
					return true;
				}
			}
		}
		break;
		
		case kEventClassScrollable:
		{
			switch (ekind) {
			case kEventScrollableGetInfo:
				{
					// [1/4]
					/*	<--	kEventParamImageSize (out, typeHISize)
					 *		On exit, contains the size of the entire scrollable view.
					 */
					HISize originalSize = { mBottomRight.h, mBottomRight.v };
					verify_noerr(SetEventParameter(event, kEventParamImageSize, typeHISize, sizeof(HISize), &originalSize));
					
					// [2/4]
					/*	<--	kEventParamViewSize (out, typeHISize)
					 *		On exit, contains the amount of the scrollable view that is
					 *		visible.
					 */
					HIViewRef parentView = HIViewGetSuperview(mCarbonPane);
					HIRect parentBounds;
					verify_noerr(HIViewGetBounds(parentView, &parentBounds));
					//HISize windowSize = {	float(windowBounds.right - windowBounds.left),
					//						float(windowBounds.bottom - windowBounds.top) };
					verify_noerr(SetEventParameter(event, kEventParamViewSize, typeHISize, sizeof(HISize), &(parentBounds.size)));
					
					// [3/4]
					/*	<--	kEventParamLineSize (out, typeHISize)
					 *		On exit, contains the amount that should be scrolled in
					 *		response to a single click on a scrollbar arrow.
					 */
					 HISize scrollIncrementSize = { 16.0f, float(20) };
					 verify_noerr(SetEventParameter(event, kEventParamLineSize, typeHISize, sizeof(HISize), &scrollIncrementSize));
					 
					// [4/4]
					/*	<-- kEventParamOrigin (out, typeHIPoint)
					 *		On exit, contains the scrollable viewÕs current origin (the
					 *		view-relative coordinate that is drawn at the top left
					 *		corner of its frame). These coordinates should always be
					 *		greater than or equal to zero. They should be less than or
					 *		equal to the viewÕs image size minus its view size.
					 */
					 verify_noerr(SetEventParameter(event, kEventParamOrigin, typeHIPoint, sizeof(HIPoint), &mCurrentScrollPoint));
				}
				return true;
				
			case kEventScrollableScrollTo:
				{
					/*
					 *  kEventClassScrollable / kEventScrollableScrollTo
					 *  
					 *  Summary:
					 *    Requests that an HIScrollViewÕs scrollable view should scroll to
					 *    a particular origin.
					 */
					
					/*	-->	kEventParamOrigin (in, typeHIPoint)
					 *		The new origin for the scrollable view. The origin
					 *		coordinates will vary from (0,0) to scrollable viewÕs image
					 *		size minus its view size.
					 */
					HIPoint pointToScrollTo;
					verify_noerr(GetEventParameter(event, kEventParamOrigin, typeHIPoint, NULL, sizeof(HIPoint), NULL, &pointToScrollTo));
					
					float xDelta = mCurrentScrollPoint.x - pointToScrollTo.x;
					float yDelta = mCurrentScrollPoint.y - pointToScrollTo.y;
					// move visible portion the appropriate amount
					verify_noerr(HIViewScrollRect(mCarbonPane, NULL, xDelta, yDelta));
					// set new content to be drawn
					verify_noerr(HIViewSetBoundsOrigin(mCarbonPane, pointToScrollTo.x, pointToScrollTo.y));
					
					mCurrentScrollPoint = pointToScrollTo;
				}
				return true;
				
			default:
				break;
			}
		}
		break;
		
		default:
			break;
	}
#endif
	return false;
}
Exemplo n.º 6
0
OSStatus ComboBoxHandler(EventHandlerCallRef next,
                         EventRef event, void *data)
{
    WindowRef window;
    HIViewRef combo;
    CFIndex index;
    UInt32 id;

    // Get the window
    
    window = ActiveNonFloatingWindow();

    // Get the control

    GetEventParameter(event, kEventParamDirectObject,
                      typeControlRef, NULL, sizeof(combo),
                      NULL, &combo);

    // Get the index

    GetEventParameter(event, kEventParamComboBoxListSelectedItemIndex,
                      typeCFIndex, NULL, sizeof(index),
                      NULL, &index);

    // Get the command id

    HIViewGetCommandID(combo, &id);

    // Switch on the command id
        
    switch (id)
    {
        // Instrument

    case kCommandInst:
        instrument = index;
        ChangeInstrument(instrument);
        break;

        // Key

    case kCommandKey:
        key = index;
	type = types[key];
	ChangeDisplay();
        break;

        // Something else

    default:
        return eventNotHandledErr;
    }

    // Clear the keyboard focus, otherwise the focus stays on the
    // combo box and makes it drop down when the user presses a key

    ClearKeyboardFocus(window);

    // Report success

    return noErr;
}
Exemplo n.º 7
0
OSStatus CommandHandler(EventHandlerCallRef next,
                        EventRef event, void *data)
{
    HICommandExtended command;
    WindowRef window;
    UInt32 value;

    // Get the command

    GetEventParameter(event, kEventParamDirectObject,
                      typeHICommand, NULL, sizeof(command),
                      NULL, &command);

    // Get the value

    value = HIViewGetValue(command.source.control);

    // Switch on the command ID

    switch (command.commandID)
    {
        // Key or instrument control

    case kCommandKey:
    case kCommandInst:

	// If the combo box list isn't visible (the user just closed
	// it)

        if (!HIComboBoxIsListVisible(command.source.control))
        {
            // Get the window
    
            window = ActiveNonFloatingWindow();

            // Clear the keyboard focus, otherwise the focus stays on the
            // combo box and makes it drop down when the user presses a key

            ClearKeyboardFocus(window);
        }
        break;

        // Reverse

    case kCommandReverse:
        reverse = value;
	ChangeDisplay();
        break;

        // Volume

    case kCommandVolume:
        volume = value;
        break;

	// Notes

    case kCommandNote:
	shownotes = value;
	ChangeDisplay();
	break;

        // Quit

    case kHICommandQuit:

        // Let the default handler handle it

    default:
        return eventNotHandledErr;
    }

    // Report success

    return noErr;
}
Exemplo n.º 8
0
OSStatus MouseHandler(EventHandlerCallRef next,
		      EventRef event, void *data)
{
    HIViewRef control;
    WindowRef window;
    ControlKind view;
    UInt32 kind;

    // Get the event kind

    kind = GetEventKind(event);

    // Get the window

    GetEventParameter(event, kEventParamWindowRef,
                      typeWindowRef, NULL, sizeof(window),
                      NULL, &window);

    // Get the view

    HIViewGetViewForMouseEvent(HIViewGetRoot(window), event,
			       &control);

    // Get the control kind

    GetControlKind(control, &view);

    // Switch on event kind

    switch (kind)
    {
        // Mouse down

    case kEventMouseDown:

        // Switch on control kind

        switch (view.kind)
        {
            // Combo box

        case kControlKindHIComboBox:

            // Do nothing, let the default event handler do it's thing

            break;

            // Everything else

        default:

            // Clear the keyboard focus, otherwise the focus stays on the
            // combo box and makes it drop down when the user presses a key

            ClearKeyboardFocus(window);
            break;
        }

    default:
        return eventNotHandledErr;
    }

    // Return event not handled so that the default event handler gets
    // to do it's thing

    return eventNotHandledErr;
}
Exemplo n.º 9
0
// static
pascal OSStatus IGraphicsCarbon::TextEntryHandler(EventHandlerCallRef pHandlerCall, EventRef pEvent, void* pGraphicsCarbon)
{
  IGraphicsCarbon* _this = (IGraphicsCarbon*) pGraphicsCarbon;
  UInt32 eventClass = GetEventClass(pEvent);
  UInt32 eventKind = GetEventKind(pEvent);

  switch (eventClass)
  {
    case kEventClassKeyboard:
      switch (eventKind)
      {
        case kEventRawKeyDown:
        case kEventRawKeyRepeat:
        {
          // Get the keys and modifiers
          char c;
          UInt32 k;
          UInt32 modifiers;
          GetEventParameter(pEvent, kEventParamKeyMacCharCodes, typeChar,   NULL, sizeof(char),   NULL, &c);
          GetEventParameter(pEvent, kEventParamKeyCode,         typeUInt32, NULL, sizeof(UInt32), NULL, &k);
          GetEventParameter(pEvent, kEventParamKeyModifiers,    typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers);

          // paste
          if (c == 118 && modifiers == 256)
          {
            if (TXNIsScrapPastable())
            {
              TXNPaste(_this->mTextEntryView);

              return eventNotHandledErr;
            }
          }

          // trap enter keys
          if (c == 3 || c == 13)
          {
            _this->EndUserInput(true);
            return noErr;
          }

          // trap escape key
          if (c == 27)
          {
            _this->EndUserInput(false);
            return noErr;
          }

          // pass arrow keys
          if (k == 125 || k == 126 || k == 123 || k == 124)
            return eventNotHandledErr;

          // pass delete keys
          if (c == 8 || c == 127)
            return eventNotHandledErr;

          if (_this->mEdParam)
          {
            switch ( _this->mEdParam->Type() )
            {
              case IParam::kTypeEnum:
              case IParam::kTypeInt:
              case IParam::kTypeBool:
                if (c >= '0' && c <= '9') break;
                else if (c == '-') break;
                else if (c == '+') break;
                else return noErr;
              case IParam::kTypeDouble:
                if (c >= '0' && c <= '9') break;
                else if (c == '.') break;
                else if (c == '-') break;
                else if (c == '+') break;
                else return noErr;
              default:
                break;
            }
          }

          // Get the text
          CharsHandle textHandle;
          long textLength = 0;
          TXNGetDataEncoded(_this->mTextEntryView, kTXNStartOffset, kTXNEndOffset, &textHandle, kTXNTextData);

          // Check that we have some worthwhile data
          if (textHandle != NULL && GetHandleSize(textHandle) > 0)
          {
            textLength = GetHandleSize(textHandle);
          }

          if(textLength >= _this->mEdControl->GetTextEntryLength())
          {
            return noErr;
          }
          else
          {
            EventRecord eventRecord;

            if (ConvertEventRefToEventRecord(pEvent, &eventRecord))
            {
              TXNKeyDown(_this->mTextEntryView, &eventRecord);
              return noErr;
            }
          }
        }
        break;
      }
      break;
    case kEventClassMouse:
    {
      switch (eventKind)
      {
        case kEventMouseDown:
        case kEventMouseUp:
        {
          // Get the window handle
          WindowRef window;
          GetEventParameter(pEvent, kEventParamWindowRef, typeWindowRef, NULL, sizeof(WindowRef), NULL, &window);

          // Determine the point
          HIPoint p;
          GetEventParameter(pEvent, kEventParamMouseLocation, typeHIPoint, NULL, sizeof(HIPoint), NULL, &p);
          Point point = { (short)p.y, (short)p.x };
          QDGlobalToLocalPoint(GetWindowPort (window), &point);

          // Get the viewable area
          Rect rect;
          TXNGetViewRect (_this->mTextEntryView, &rect);

          //swell collision
          #undef PtInRect
          #define MacPtInRect PtInRect
          // Handle the click as necessary
          if (PtInRect(point, &rect))
          {
            #define PtInRect(r,p) SWELL_PtInRect(r,p)
            EventRecord eventRecord;
            if (eventKind == kEventMouseDown && ConvertEventRefToEventRecord(pEvent, &eventRecord))
            {
              TXNClick(_this->mTextEntryView, &eventRecord);
            }
            return noErr;
          }
          else
          {
            CallNextEventHandler(pHandlerCall, pEvent);
            ClearKeyboardFocus(window);
            _this->EndUserInput(false);
            return noErr;
          }
        }
        break;
        case kEventMouseMoved:
          TXNAdjustCursor(_this->mTextEntryView, NULL);
          return noErr;
        case kEventMouseWheelMoved:
          return noErr;
      }
      break;
    }
    case kEventClassWindow:
    {
      WindowRef window;
      GetEventParameter (pEvent, kEventParamDirectObject, typeWindowRef, NULL, sizeof(WindowRef), NULL, &window);
      switch (eventKind)
      {
        case kEventWindowFocusRelinquish:
        case kEventWindowClosed:
        case kEventWindowDeactivated:
          CallNextEventHandler(pHandlerCall, pEvent);
          ClearKeyboardFocus(window);
          _this->EndUserInput(false);
          return noErr;
      }
      break;
    }
  }

  return eventNotHandledErr;
}
Exemplo n.º 10
0
pascal OSStatus TextControlProc(EventHandlerCallRef inHandlerCallRef,
                                EventRef inEvent, void *inUserData) {
	OSStatus result = eventNotHandledErr;
	UInt32 eventClass = GetEventClass(inEvent);
	UInt32 eventKind = GetEventKind(inEvent);
	cBitmapFontEditable* control = (cBitmapFontEditable*)inUserData;
  
	switch(eventClass) {
		case kEventClassKeyboard:
		{
			switch(eventKind) {
				case kEventRawKeyDown:
				case kEventRawKeyRepeat:
				{
					char macCharCode;
					UInt32 keyCode;
					UInt32 modifiers;
					GetEventParameter(inEvent, kEventParamKeyMacCharCodes, typeChar, NULL, sizeof (char), NULL, &macCharCode);
					GetEventParameter(inEvent, kEventParamKeyCode, typeUInt32, NULL, sizeof (UInt32), NULL, &keyCode);
					GetEventParameter(inEvent, kEventParamKeyModifiers, typeUInt32, NULL, sizeof (UInt32), NULL, &modifiers);

          VstKeyCode key;
          key.character = macCharCode;
          ((cBitmapFontEditable*)control)->onKeyDown(key);
          break;
				}
			}
			break;
		}
		case kEventClassMouse:
		{
			switch (eventKind)
			{
				case kEventMouseDown:
				{
					WindowRef window;
					GetEventParameter(inEvent, kEventParamWindowRef, typeWindowRef, NULL, sizeof(WindowRef), NULL, &window);
					HIPoint p;
					GetEventParameter(inEvent, kEventParamMouseLocation, typeHIPoint, NULL, sizeof(HIPoint), NULL, &p);
					Point point = { (short)p.y, (short)p.x };
					QDGlobalToLocalPoint(GetWindowPort(window), &point);
					CRect crect;
          control->getViewSize(crect);
          Rect rect;
          rect.top = crect.top;
          rect.left = crect.left;
          rect.right = crect.right;
          rect.bottom = crect.bottom;
					//TXNGetViewRect((cBitmap)textEdit->platformControl, &rect);
					if(PtInRect(point, &rect)) {
						EventRecord eventRecord;
						if(eventKind == kEventMouseDown && ConvertEventRefToEventRecord(inEvent, &eventRecord)) {
              // Mouse click received
            }
            else {
              VstKeyCode key;
              key.character = KEY_ESC;
              control->onKeyDown(key);
            }
            result = noErr;
					}
					break;
				}
			}
			break;
		}      
		case kEventClassWindow:
		{
			WindowRef window;
			if(GetEventParameter(inEvent, kEventParamDirectObject, typeWindowRef, NULL,
                           sizeof (WindowRef), NULL, &window) != noErr) {
				break;
      }
			switch(eventKind) {
				case kEventWindowDeactivated:
				{
					result = CallNextEventHandler(inHandlerCallRef, inEvent);
					ClearKeyboardFocus(window);
          
					// set up the correct drawing port for the window
					GrafPtr	savedPort;
					bool portChanged = QDSwapPort(GetWindowPort (window), &savedPort);
          
					// remember the current resource map ID
					short currentResID = CurResFile();
					short vstResFileID = control->pluginResID;
					// if it's different (and if it's valid), set the current resource map ID to our plugin's resource map
					if((vstResFileID != currentResID) && (vstResFileID > 0)) {
						UseResFile(vstResFileID);
          }
          
					VstKeyCode key;
          key.character = KEY_ESC;
          ((cBitmapFontEditable*)control)->onKeyDown(key);
          
					// revert the window port, if we changed it
					if(portChanged) {
						QDSwapPort(savedPort, NULL);
          }
          
					// revert the current resource map, if we changed it
					if((currentResID > 0) && (vstResFileID != currentResID) && (vstResFileID > 0)) {
						UseResFile(currentResID);
          }
          
					break;
				}
			}
			break;
		}
	}
	return result;
}