Beispiel #1
0
bool QuartzWindow::pre_draw(bool incremental) {
  if ( get_graphics_semaphore())  return false;
  if (!_is_open) return false;
  if (_was_closed) {
    TheSpy->deactivate();
    _was_closed = false;
    return false;
  }
  if ( myContext == NULL ) {
    // Self does this for Self windows, so only do it for Spy windows--that's why it's here and not in open
    SetPortWindowPort(my_window());
    QDBeginCGContext( GetWindowPort(my_window()), &myContext);
    setupCTM();
    CGContextSetTextMatrix(myContext, CGAffineTransformMake( 1, 0, 0, -1, 0, 0));
    CGContextSelectFont(myContext, 
      default_fixed_font_name(), default_fixed_font_size(), kCGEncodingMacRoman);
    CGContextSetShouldAntialias(myContext, false);
    
    EventTypeSpec es[] = { 
      {kEventClassWindow, kEventWindowBoundsChanged},
      {kEventClassWindow, kEventWindowClose}
    };
    OSStatus e = AddEventTypesToHandler(_my_spy_event_handler,  sizeof(es) / sizeof(es[0]),  es);
    if (e != noErr) fatal1("could not add types to handler %d\n", e);
  }
  if (_bounds_changed) {
    _bounds_changed = false;
    adjust_after_resize();
  }
  if (!incremental) {
    Rect r;  get_window_region_rect( kWindowContentRgn, &r);
    clear_rectangle(0, 0, r.right - r.left, r.bottom - r.top);
  }
  return true;
}
Beispiel #2
0
OSStatus QuartzWindow::AddHandledEvent_wrap( uint32* eclass, uint ec_len, uint ekind, void* FH) {
  if (ec_len != 1)  { failure( FH, "class needs to have four bytes"); return NULL; }
  EventTypeSpec es;
  es.eventClass = EndianU32_BtoN(*eclass);
  es.eventKind = ekind;
  return AddEventTypesToHandler(_my_event_handler, 1, &es);
}
void	CarbonEventHandler::WantEventTypes(EventTargetRef target, UInt32 inNumTypes, const EventTypeSpec *inList)
{
	if (mHandlers == NULL)
		mHandlers = CFDictionaryCreateMutable(NULL, 0, NULL, NULL);
		
	EventHandlerRef handler;
	
	if (CFDictionaryGetValueIfPresent (mHandlers, target, (const void **)&handler))	// if there is already a handler for the target, add the type
		verify_noerr(AddEventTypesToHandler(handler, inNumTypes, inList));
	else {
		verify_noerr(InstallEventHandler(target, TheEventHandler, inNumTypes, inList, this, &handler));
		CFDictionaryAddValue(mHandlers, target, handler);
	}
}