Example #1
0
static Rboolean Quartz_Locator(double *x, double *y, NewDevDesc *dd)
{
    EventRecord event;
    SInt16 key;
    Boolean gotEvent;
    Boolean mouseClick = false;
    Point myPoint;
    WindowPtr window;
    SInt16 partCode;
    GrafPtr savePort;
    Cursor		arrow ;
    QuartzDesc *xd = (QuartzDesc*)dd->deviceSpecific;
	int useBeep = asLogical(GetOption(install("locatorBell"), 
						      R_NilValue));
	
    GetPort(&savePort);

    SetPortWindowPort(xd->window);
    SetThemeCursor(kThemeCrossCursor);

    while(!mouseClick) {
	
    
	gotEvent = WaitNextEvent( everyEvent, &event, 0, nil);

    CGContextFlush( GetContext(xd) );
   
	if (event.what == mouseDown) {
	    partCode = FindWindow(event.where, &window);
	    if ((window == (xd->window)) && (partCode == inContent)) {
			myPoint = event.where;
			GlobalToLocal(&myPoint);
			*x = (double)(myPoint.h);
			*y = (double)(myPoint.v);
			if(useBeep)
			 SysBeep(1);
			mouseClick = true;
	    }
	}

	if (event.what == keyDown) {
	    key = (event.message & charCodeMask);
	    if (key == 0x1b){ /* exits when the esc key is pressed */
			SetPort(savePort);
			SetThemeCursor(kThemeIBeamCursor);
			return FALSE;
	    }
	}
    }

    SetPort(savePort);
	SetThemeCursor(kThemeIBeamCursor);
    return TRUE;
}
Example #2
0
void AquaGui::setCursor(gnash_cursor_type newcursor)
{

	  switch(newcursor) {
	  	case gnash::CURSOR_HAND:	  		
				SetThemeCursor(kThemePointingHandCursor);
        	break;
      	case gnash::CURSOR_INPUT:
      			SetThemeCursor(kThemeCrossCursor);
      		break;
      	default:
      	        SetThemeCursor(kThemeArrowCursor);
        }        
}
Example #3
0
void chooseFileNative( char *title, char *path, int openingFile, char *okMsg, char *cancelMsg ) {
	if( openingFile ) {
		GetOpenFileFromUser( title, path, okMsg, cancelMsg ); 
	}
	else {
		GetSaveFileFromUser( title, path, okMsg, cancelMsg ); 
	}
	SetThemeCursor( 0 );
}
void IGraphicsCarbon::EndUserInput(bool commit)
{
  if (mTextEntryHandler)
  {
    RemoveEventHandler(mTextEntryHandler);
    mTextEntryHandler = 0;
  }
  else
  {
    return;
  }

  if (commit)
  {
    // Get the text
    CharsHandle textHandle;
    TXNGetDataEncoded(mTextEntryView, kTXNStartOffset, kTXNEndOffset, &textHandle, kTXNTextData);

    // Check that we have some worthwhile data
    if (textHandle != NULL && GetHandleSize(textHandle) > 0)
    {
      const long textLength = GetHandleSize(textHandle);
      char txt[257];
      strncpy(txt, *textHandle, (textLength > 255) ? 255 : textLength);
      txt[(textLength > 255) ? 255 : textLength] = '\0';

      if (mEdParam)
        mGraphicsMac->SetFromStringAfterPrompt(mEdControl, mEdParam, txt);
      else
        mEdControl->TextFromTextEntry(txt);
    }
  }

  if (mTextEntryView)
  {
    TXNFocus(mTextEntryView, false);
    TXNClear(mTextEntryView);
    TXNDeleteObject(mTextEntryView);
    mTextEntryView = 0;
  }

  if (mIsComposited)
  {
    HIViewSetNeedsDisplay(mView, true);
  }
  else
  {
    mEdControl->SetDirty(false);
    mEdControl->Redraw();
  }

  SetThemeCursor(kThemeArrowCursor);
  SetUserFocusWindow(kUserFocusAuto);

  mEdControl = 0;
  mEdParam = 0;
}
Example #5
0
void wxCursor::MacInstall() const
{
    gMacCurrentCursor = *this ;
    if ( m_refData && M_CURSORDATA->m_themeCursor != -1 )
    {
        SetThemeCursor( M_CURSORDATA->m_themeCursor ) ;
    }
    else if ( m_refData && M_CURSORDATA->m_hCursor )
    {
        if ( M_CURSORDATA->m_isColorCursor )
            ::SetCCursor( (CCrsrHandle) M_CURSORDATA->m_hCursor ) ;
        else
            ::SetCursor( * (CursHandle) M_CURSORDATA->m_hCursor ) ;
    }
    else
    {
        SetThemeCursor( kThemeArrowCursor ) ;
    }
}
Example #6
0
void doOSEvent(EventRecord *eventStrucPtr)
{
    switch((eventStrucPtr->message >> 24) & 0x000000FF)
    {
    case suspendResumeMessage:
        if((eventStrucPtr->message & resumeFlag) == 1)
          SetThemeCursor(kThemeArrowCursor);
        break;
    }
}
void IGraphicsCarbon::EndUserInput(bool commit)
{
  RemoveEventHandler(mTextEntryHandler);
  mTextEntryHandler = 0;

  if (commit)
  {
    CFStringRef str;
    if (GetControlData(mTextEntryView, kControlEditTextPart, kControlEditTextCFStringTag, sizeof(str), &str, NULL) == noErr)
    {
      char txt[MAX_PARAM_LEN];
      CFStringGetCString(str, txt, MAX_PARAM_LEN, kCFStringEncodingUTF8);
      CFRelease(str);

      if (mEdParam)
        mGraphicsMac->SetFromStringAfterPrompt(mEdControl, mEdParam, txt);
      else
        mEdControl->TextFromTextEntry(txt);
    }
  }

  HIViewSetVisible(mTextEntryView, false);
  HIViewRemoveFromSuperview(mTextEntryView);

  if (mIsComposited)
  {
    //IRECT* pR = mEdControl->GetRECT();
    //HIViewSetNeedsDisplayInRect(mView, &CGRectMake(pR->L, pR->T, pR->W(), pR->H()), true);
    HIViewSetNeedsDisplay(mView, true);
  }
  else
  {
    if (mEdControl) 
    {
      mEdControl->SetDirty(false);
      mEdControl->Redraw();
    }
  }
  
  SetThemeCursor(kThemeArrowCursor);
  SetUserFocusWindow(kUserFocusAuto);

  mTextEntryView = 0;
  mEdControl = 0;
  mEdParam = 0;
}
Example #8
0
PF_Err
HandleEvent ( 
	PF_InData		*in_data,
	PF_OutData		*out_data,
	PF_ParamDef		*params[],
	PF_LayerDef		*output,
	PF_EventExtra	*extra )
{
	PF_Err		err		= PF_Err_NONE;
	
	if (!err) 
	{
		switch (extra->e_type) 
		{
			case PF_Event_DRAW:
				err =	DrawEvent(in_data, out_data, params, output, extra);
				break;
			
			case PF_Event_DO_CLICK:
				err = DoDialog(in_data, out_data, params, output);
				extra->evt_out_flags = PF_EO_HANDLED_EVENT;
				break;
				
			case PF_Event_ADJUST_CURSOR:
			#if defined(MAC_ENV)
				#if PF_AE_PLUG_IN_VERSION >= PF_AE100_PLUG_IN_VERSION
				SetMickeyCursor(); // the cute mickey mouse hand
				#else
				SetThemeCursor(kThemePointingHandCursor);
				#endif
				extra->u.adjust_cursor.set_cursor = PF_Cursor_CUSTOM;
			#else
				extra->u.adjust_cursor.set_cursor = PF_Cursor_FINGER_POINTER;
			#endif
				extra->evt_out_flags = PF_EO_HANDLED_EVENT;
				break;
		}
	}
	
	return err;
}
Example #9
0
void	LineTool( WindowRef window )
{
	OSStatus			err;
	Point				endPt;
	MouseTrackingResult	trackingResult;
	Point				beginPt;
	Rect				windowRect;
	WindowRef			overlayWindow;
	CGRect				cgRect;
	CGContextRef		cgContext;
	Boolean				isStillDown		= true;

	SetThemeCursor( kThemeCrossCursor );
	
	SetPortWindowPort( window );
	GetWindowPortBounds( window, &windowRect );
	LocalToGlobalRect( &windowRect );

	(void) CreateNewWindow( kOverlayWindowClass, kWindowHideOnSuspendAttribute | kWindowIgnoreClicksAttribute, &windowRect, &overlayWindow );
	SetPortWindowPort( overlayWindow );
	SetWindowGroup( overlayWindow, GetWindowGroup(window) );					//	This assures we draw into the same layer as the window
	ShowWindow( overlayWindow );

	GetMouse( &beginPt );
	cgRect	= CGRectMake( 0, 0, windowRect.right - windowRect.left+1, windowRect.bottom - windowRect.top+1 );
	CreateCGContextForPort( GetWindowPort(overlayWindow), &cgContext );
	
	CGContextSetLineWidth( cgContext, 3 );										//	Line is 3 pixels wide
	CGContextSetRGBStrokeColor( cgContext, 1.0, .45, .3, .4 );					//	Make it orange with alpha = 0.4
	SyncCGContextOriginWithPort( cgContext, GetWindowPort(overlayWindow) );
	CGContextTranslateCTM( cgContext, 0, windowRect.bottom - windowRect.top );	//	Flip & rotate the context to use QD coordinates
	CGContextScaleCTM( cgContext, 1.0, -1.0 );
    do
	{
		err	= TrackMouseLocation( GetWindowPort(window), &endPt, &trackingResult );
		
		switch ( trackingResult )
		{
			case kMouseTrackingMouseDragged:
				CGContextClearRect( cgContext, cgRect );						//	"Erase" the window
				#if ( 1 )
					CGContextMoveToPoint( cgContext, beginPt.h, beginPt.v );	//	Draw the line
					CGContextAddLineToPoint( cgContext, endPt.h, endPt.v );
					CGContextStrokePath( cgContext );
				#else
					MoveTo( beginPt.h, beginPt.v );								//	We could use QuickDraw and draw opaque lines
					LineTo( endPt.h, endPt.v );
				#endif
				CGContextFlush( cgContext );									//	Flush our drawing to the screen
				break;
			case kMouseTrackingMouseDown:
				break;
			case kMouseTrackingMouseUp:
			case kMouseTrackingUserCancelled:
				isStillDown	= false;
				break;
		}
	} while( isStillDown == true );
	
	CGContextRelease( cgContext );
	DisposeWindow( overlayWindow );
	SetThemeCursor( kThemeArrowCursor );
	return;
}