Esempio n. 1
0
/*
	Position the contentView (presumed to be a subview of the frameView) by
	asking the content view for its metrics and positioning it appropriately.
*/
OSStatus PositionContentViewWithMetrics(HIViewRef frameView, HIViewRef contentView)
{
	HIViewFrameMetrics metrics = { 0, 0, 0, 0 };
	EventRef getMetricsEvent = NULL;

	// First we check the frame metrics of the content view by asking it (politely) for the
	// metrics it wants
	verify_noerr(CreateEvent(NULL, kEventClassControl, kEventControlGetFrameMetrics, GetCurrentEventTime(), 0, &getMetricsEvent));
	if(NULL != getMetricsEvent) {
		SetEventParameter(getMetricsEvent, kEventParamDirectObject, typeControlRef, sizeof(contentView), &contentView);
		SetEventParameter(getMetricsEvent, kEventParamControlFrameMetrics, typeControlFrameMetrics, sizeof(metrics), &metrics);

		OSStatus result = SendEventToEventTarget(getMetricsEvent, HIObjectGetEventTarget((HIObjectRef)contentView));
		if(result == noErr) {
			verify_noerr(GetEventParameter(getMetricsEvent, kEventParamControlFrameMetrics, typeControlFrameMetrics, NULL, sizeof(metrics), NULL, &metrics));
		}

		ReleaseEvent(getMetricsEvent);
		getMetricsEvent = NULL;
	}

	// Now we reposition the content view based on the metrics we got from it.
	HIRect bounds, contentRect;
	HIViewGetBounds(frameView, &bounds);

	contentRect.origin.x = metrics.left;
	contentRect.origin.y = metrics.top;
	contentRect.size.width = bounds.size.width - (metrics.left + metrics.right);
	contentRect.size.height = bounds.size.height - (metrics.top + metrics.bottom);

	HIViewSetFrame(contentView, &contentRect);

	return noErr;
}
//-----------------------------------------------------------------------------
//	CreateCustomToolbarItem
//-----------------------------------------------------------------------------
//	Our 'public' API to create our custom URL item.
//
HIToolbarItemRef
CreateCustomToolbarItem( CFStringRef inIdentifier, CFTypeRef inURL )
{
	OSStatus			err;
	EventRef			event;
	UInt32				options = kHIToolbarItemAllowDuplicates;
	HIToolbarItemRef	result = NULL;
	
	RegisterCustomToolbarItemClass();
	
	err = CreateEvent( NULL, kEventClassHIObject, kEventHIObjectInitialize,
			GetCurrentEventTime(), 0, &event );
	require_noerr( err, CantCreateEvent );

	SetEventParameter( event, kEventParamToolbarItemIdentifier, typeCFStringRef, sizeof( CFStringRef ), &inIdentifier );
	SetEventParameter( event, kEventParamAttributes, typeUInt32, sizeof( UInt32 ), &options );

	if ( inURL )
		SetEventParameter( event, kEventParamToolbarItemConfigData, typeCFTypeRef, sizeof( CFTypeRef ), &inURL );
	
	err = HIObjectCreate( kCustomToolbarItemClassID, event, (HIObjectRef*)&result );
	check_noerr( err );

	ReleaseEvent( event );
	
CantCreateEvent:
	return result;
}
Esempio n. 3
0
extern OSStatus
HICreateScrollingTextBox(
	const HIRect * inBounds,                   /* can be NULL */
	CFStringRef    inScrollingText,
	Boolean        inAutoScroll,
	UInt32         inDelayBeforeAutoScroll,
	UInt32         inDelayBetweenAutoScroll,
	UInt16         inAutoScrollAmount,
	HIViewRef *    outHIView)
	{
	*outHIView = NULL;
	EventRef theInitializeEvent = NULL;
	HIViewRef scrollView;
	OSStatus status;

	status = CreateEvent(NULL, kEventClassHIObject, kEventHIObjectInitialize, GetCurrentEventTime(), kEventAttributeUserEvent, &theInitializeEvent);

	// settings
	SetEventParameter(theInitializeEvent, kEventParamScrollingText, typeCFStringRef, sizeof(inScrollingText), &inScrollingText);
	SetEventParameter(theInitializeEvent, kEventParamAutoScroll, typeBoolean, sizeof(inAutoScroll), &inAutoScroll);
	SetEventParameter(theInitializeEvent, kEventParamDelayBeforeAutoScroll, typeUInt32, sizeof(inDelayBeforeAutoScroll), &inDelayBeforeAutoScroll);
	SetEventParameter(theInitializeEvent, kEventParamDelayBetweenAutoScroll, typeUInt32, sizeof(inDelayBetweenAutoScroll), &inDelayBetweenAutoScroll);
	SetEventParameter(theInitializeEvent, kEventParamAutoScrollAmount, typeSInt16, sizeof(inAutoScrollAmount), &inAutoScrollAmount);

	HIObjectRef hiObject;
	status = HIObjectCreate(GetScrollingTextBoxClass(), theInitializeEvent, &hiObject);

	HIViewSetVisible((HIViewRef)hiObject, true);

	if (!inAutoScroll)
		{
		//
		// Manual scrolling, we need to be embedded in a scroll view
		//
		status = HIScrollViewCreate(kHIScrollViewOptionsVertScroll, &scrollView);
		status = HIViewAddSubview(scrollView, (HIViewRef)hiObject);
		if (inBounds != NULL)
			HIViewSetFrame(scrollView, inBounds);
		EventTypeSpec event = {kEventClassControl, kEventControlDraw};
		InstallEventHandler(GetControlEventTarget(scrollView), FrameView, 1, &event, NULL, NULL);
		*outHIView = scrollView;
		}
	else
		{
		if (inBounds != NULL)
			HIViewSetFrame((HIViewRef)hiObject, inBounds);
		*outHIView = (HIViewRef)hiObject;
		}

	return status;
	}
Esempio n. 4
0
void MCRevolutionStackViewRelink(WindowRef p_window, MCStack *p_new_stack)
{
	EventRef t_event;
	CreateEvent(NULL, 'revo', 'rlnk', GetCurrentEventTime(), 0, &t_event);
	SetEventParameter(t_event, 'Stak', typeVoidPtr, sizeof(void *), &p_new_stack);
	
	HIViewRef t_root;
	GetRootControl(p_window, &t_root);
	
	HIViewRef t_view;
	GetIndexedSubControl(t_root, 1, &t_view);
	SendEventToEventTarget(t_event, GetControlEventTarget(t_view));
	ReleaseEvent(t_event);
}
Esempio n. 5
0
void TabbedWindow::Terminate( void )
{
    EventQueueRef eventQueue = GetMainEventQueue();
    EventRef event;
    OSStatus status;
    
    status = CreateEvent( kCFAllocatorDefault, kEventClassApplication, kEventAppQuit,
                            GetCurrentEventTime(), kEventAttributeNone, &event );
    
    if ( status == noErr )
        status = PostEventToQueue( eventQueue, event, kEventPriorityStandard );
    
    ReleaseEvent( event );
}
Esempio n. 6
0
QSize FilterWidget::sizeHint (void) const
{
	HIRect optimalBounds;
	EventRef event;
	CreateEvent(0, kEventClassControl, kEventControlGetOptimalBounds,
		GetCurrentEventTime(), kEventAttributeUserEvent, &event);
	SendEventToEventTargetWithOptions(event,
		HIObjectGetEventTarget(HIObjectRef(winId())),
		kEventTargetDontPropagate);
	GetEventParameter(event, kEventParamControlOptimalBounds, typeHIRect,
		0, sizeof(HIRect), 0, &optimalBounds);
	ReleaseEvent(event);
	return QSize(optimalBounds.size.width + 200, optimalBounds.size.height - 4);
}
static void IdleMovie()
{
    if (mMovieController)
    {
        EventRecord	myEvent;
        
        myEvent.what = nullEvent;
        myEvent.message = 0;
        myEvent.modifiers = 0;
        myEvent.when = EventTimeToTicks(GetCurrentEventTime());
        
        MCIsPlayerEvent(mMovieController, &myEvent);
    }
}
Esempio n. 8
0
/*----------------------------------------------------------------------------------------------------------*/
void myScrollingTextTimeProc(EventLoopTimerRef inTimer, void *inUserData)
	{
	ScrollingTextBoxData* myData = (ScrollingTextBoxData*)inUserData;
	HIPoint where = {0.0, myData->originPoint.y + myData->autoScrollAmount};

	// If we reached the end of our text, let's start again
	if (where.y >= myData->height - 10.0) where.y = 0.0;

	// Creating and sending our ScrollTo event
	EventRef theEvent;
	CreateEvent(NULL, kEventClassScrollable, kEventScrollableScrollTo, GetCurrentEventTime(), kEventAttributeUserEvent, &theEvent);
	SetEventParameter(theEvent, kEventParamOrigin, typeHIPoint, sizeof(where), &where);
	SendEventToEventTarget(theEvent, GetControlEventTarget(myData->view));
	ReleaseEvent(theEvent);
	}
Esempio n. 9
0
//
// Build a custom event to send to our window handler when movie audio extraction 
// completes for the current movie (without the user pressing the "Stop" button
// to stop it before it runs to the end). We'll then update our button title to 
// reflect this.
//
OSStatus SendExtractionStatusEventToWindow(Boolean extractionPaused)
{
    OSStatus	err		= noErr;
    EventRef    event	= NULL;
		
	err = CreateEvent( NULL,  kEventClassMovieExtractState, kEventKQueue, GetCurrentEventTime(), kEventAttributeNone, &event );
	if ( err != noErr ) goto Bail;
	
	err = SetEventParameter( event, kEventParamDirectObject, typeKEvent, sizeof(Boolean), &extractionPaused );	//  Send the event
	if ( err != noErr ) goto Bail;

	err = SendEventToEventTarget (event, GetWindowEventTarget(mWindow));	// Post the event for our window handler
Bail:
	if ( event != NULL )	(void) ReleaseEvent( event );
	return( err );
}
Esempio n. 10
0
OSStatus MCRevolutionStackViewCreate(MCStack *p_stack, ControlRef* r_control)
{
	HIRevolutionStackViewRegister();
	
	EventRef t_event;
	CreateEvent(NULL, kEventClassHIObject, kEventHIObjectInitialize, GetCurrentEventTime(), 0, &t_event);
	SetEventParameter(t_event, 'Stak', typeVoidPtr, sizeof(void *), &p_stack);
	
	ControlRef t_control;
	HIObjectCreate(kHIRevolutionStackViewClassID, t_event, (HIObjectRef *)&t_control);
	
	ReleaseEvent(t_event);
	
	*r_control = t_control;
	
	return noErr;
}
OSStatus 
CreateMouseTrackingView(HIViewRef parentView, const Rect* inBounds, HIViewID* inViewID)
{
    #define kCanvasClassID	CFSTR( "com.apple.sample.canvasview" )

    OSStatus	err;
    EventRef	event;
    HIViewRef	theView;
	
    // Register this class
    err = MyMTViewRegister(kCanvasClassID); 
    require_noerr( err, CantRegister );
	
    // Make an initialization event
    err = CreateEvent( NULL, kEventClassHIObject, kEventHIObjectInitialize, GetCurrentEventTime(), 0, &event ); 
    require_noerr( err, CantCreateEvent );
        
    // If bounds were specified, push them into the initialization event
    // so that they can be used in the initialization handler.
    if ( inBounds != NULL )
    {
        err = SetEventParameter(event, kCanvasBoundsParam, typeQDRectangle, sizeof(Rect), inBounds);
        require_noerr( err, CantSetParameter );
    }
    err = HIObjectCreate(kCanvasClassID, event, (HIObjectRef*)&theView);
    require_noerr(err, CantCreate);
	
    if (parentView != NULL) 
    {
        err = HIViewAddSubview(parentView, theView);
    }

    SetControlID(theView, inViewID);	// useful if a handler needs to call GetControlByID()
    HIViewSetVisible(theView, true);
	
CantCreate:
CantSetParameter:
CantCreateEvent:
    ReleaseEvent( event );
	
CantRegister:
    return err;
}
Esempio n. 12
0
int _glfwPlatformInit( void )
{
    _glfwWin.MacWindow = NULL;
    _glfwWin.AGLContext = NULL;
    _glfwWin.WindowFunctions = NULL;
    _glfwWin.MouseUPP = NULL;
    _glfwWin.CommandUPP = NULL;
    _glfwWin.KeyboardUPP = NULL;
    _glfwWin.WindowUPP = NULL;
    
    _glfwInput.Modifiers = 0;
    
    _glfwLibs.OpenGLFramework
        = CFBundleGetBundleWithIdentifier( CFSTR( "com.apple.opengl" ) );
    if ( _glfwLibs.OpenGLFramework == NULL )
    {
        return GL_FALSE;
    }

    _glfwDesktopVideoMode = CGDisplayCurrentMode( kCGDirectMainDisplay );
    if ( _glfwDesktopVideoMode == NULL )
    {
        return GL_FALSE;
    }

    _glfwInitThreads();

    if ( !_glfwChangeToResourcesDirectory() )
    {
        return GL_FALSE;
    }

    if ( !_glfwInstallEventHandlers() )
    {
    	_glfwPlatformTerminate();
        return GL_FALSE;
    }

    _glfwTimer.t0 = GetCurrentEventTime();

    return GL_TRUE;
}
Esempio n. 13
0
OSStatus HIOpenGLViewCreate (WindowRef inWindow, const Rect* inBounds, ControlRef* outControl)
{
    // Register this class
    OSStatus err = HIOpenGLViewRegister();
    require_noerr(err, CantRegister);

    // Make an initialization event
    EventRef event;
    err = CreateEvent(nil, kEventClassHIObject, kEventHIObjectInitialize, GetCurrentEventTime(), 0, &event);
    require_noerr(err, CantCreateEvent);
    
    // If bounds were specified, push the them into the initialization
    // event so that they can be used in the initialization handler.
    if (inBounds != nil)
    {
        err = SetEventParameter(event, 'Boun', typeQDRectangle, sizeof(Rect), inBounds);
        require_noerr(err, CantSetParameter);
    }

    // Make a new instantiation of this class
    err = HIObjectCreate(kHIOpenGLViewClassID, event, (HIObjectRef*)outControl);
    require_noerr(err, CantCreate);
    
    // If a parent window was specified, place the new view into the parent window.
    if (inWindow != nil)
    {
        ControlRef root = nil;
        err = GetRootControl(inWindow, &root);
        require_noerr(err, CantGetRootControl);
        err = HIViewAddSubview(root, *outControl);
    }

    CantCreate:
    CantGetRootControl:
    CantSetParameter:
    CantCreateEvent:
        ReleaseEvent(event);
    
    CantRegister:
        return err;
}
Esempio n. 14
0
void
temp_run_application_event_loop(void)
{
	OSStatus	err;
	EventRef	dummy_event;
	EventHandlerRef	install_handler;
	EventTypeSpec	event_spec = { 'KWIN', 'KWIN' };
	
	// Create UPP for dummy_event_handler and for quit_event_handler
	err = noErr;
	dummy_event = 0;
	
	g_dummy_event_handler_UPP = NewEventHandlerUPP(dummy_event_handler);
	g_quit_handler_UPP = NewEventHandlerUPP(quit_event_handler);
	if((g_dummy_event_handler_UPP == 0) || (g_quit_handler_UPP == 0)) {
		err = memFullErr;
	}
	
	if(err == noErr) {
		err = InstallApplicationEventHandler(g_dummy_event_handler_UPP,
											 1, &event_spec, 0, &install_handler);
		if(err == noErr) {
			err = MacCreateEvent(NULL, 'KWIN', 'KWIN',
								 GetCurrentEventTime(), kEventAttributeNone,
								 &dummy_event);
			if(err == noErr) {
				err = PostEventToQueue(GetMainEventQueue(),
									   dummy_event, kEventPriorityHigh);
			}
			if(err == noErr) {
				RunApplicationEventLoop();
			}
			
			(void)RemoveEventHandler(install_handler);
		}
	}
	
	if(dummy_event != NULL) {
		ReleaseEvent(dummy_event);
	}
}
Esempio n. 15
0
OSStatus	PostKQueueEvent( struct kevent *kevp )
{
	OSStatus				err				= noErr;
    EventRef                event			= NULL;
	MPControlInfo			*mpControl		= kevp->udata;
		
	err = CreateEvent( NULL,  kEventClassMP, kEventKQueue, GetCurrentEventTime(), kEventAttributeNone, &event );
	if ( err != noErr ) goto Bail;
	
	err = SetEventParameter( event, kEventParamDirectObject, typeKEvent, sizeof(struct kevent), kevp );		//  Send the kevent
	if ( err != noErr ) goto Bail;
	err = SetEventParameter( event, kEventParamPostTarget, typeEventTargetRef, sizeof(void*), &mpControl->eventTarget );	//  Target the date control
	if ( err != noErr ) goto Bail;
	err = SetEventParameter( event, kEventParamControlRef, typeControlRef, sizeof(ControlRef), &mpControl->dateControl );   //  ControlRef to update
	if ( err != noErr ) goto Bail;
	
	err = PostEventToQueue( GetMainEventQueue(), event, kEventPriorityStandard );						//  Post the event to the main event queue on the main thread
	
Bail:
	if ( event != NULL )	(void) ReleaseEvent( event );
	return( err );
}
Esempio n. 16
0
void
CreateAddItemEvent()
{
    EventRef event;
    OSStatus err;
        
    err = MacCreateEvent(NULL, kEventClassApplication, kAddItemToBrowser, GetCurrentEventTime(), kEventAttributeNone, &event);
    if (err == noErr)
    {	
    	err = PostEventToQueue(GetMainEventQueue(), event, kEventPriorityHigh);
    	if (err != noErr)
    	{
    	    gEventHandled = true;
    	}
    	
    	ReleaseEvent(event);
    }
    else
    {
    	gEventHandled = true;
    }
}
/*****************************************************
*
* Handle_TextInputEvent(inHandlerCallRef, inEvent, inUserData) 
*
* Purpose:  called to intercept keystrokes which are destined for a control
*
* Inputs:   inHandlerCallRef    - reference to the current handler call chain
*           inEvent             - the event
*           inUserData          - app-specified data you passed in the call to InstallEventHandler
*
* Returns:  OSStatus            - noErr indicates the event was handled
*                                 eventNotHandledErr indicates the event was not handled and the Toolbox should take over
*/
static pascal OSStatus Handle_TextInputEvent(EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void *inUserData)
	{
	OSStatus status;
	
	UniChar ch = 0;
	status = GetEventParameter(inEvent, kEventParamTextInputSendText, typeUnicodeText, NULL, sizeof(ch), NULL, &ch);
	require_noerr(status, ExitTextInput);
	
	if ((ch == kReturnCharCode) || (ch == kEnterCharCode))
		{
		//
		// we got return or enter so we validate the edit text control by sending a command
		//
		EventRef theEvent;
		CreateEvent(NULL, kEventClassCommand, kEventCommandProcess, GetCurrentEventTime(), kEventAttributeUserEvent, &theEvent);
		HICommandExtended theCommand;
		theCommand.attributes = kHICommandFromControl;
		theCommand.commandID = 'SVet';
		theCommand.source.control = (ControlRef)inUserData;
		SetEventParameter(theEvent, kEventParamDirectObject, typeHICommand, sizeof(theCommand), &theCommand);
		SendEventToEventTarget(theEvent, GetWindowEventTarget(GetControlOwner((ControlRef)inUserData)));
		ReleaseEvent(theEvent);
		status = noErr;
		}
	if (	((ch >= '0') && (ch <= '9'))	||
			(ch == kBackspaceCharCode)		||
			(ch == kLeftArrowCharCode)		||
			(ch == kRightArrowCharCode)		||
			(ch == kUpArrowCharCode)		||
			(ch == kDownArrowCharCode)		)
		status = eventNotHandledErr;
	else
		status = noErr;

ExitTextInput:

	return status;
	}   // Handle_TextInputEvent
Esempio n. 18
0
void MCStack::syncscroll(void)
{
	// If we have no window, no need to adjust the HIView.
	if (window == nil)
		return;
	
	// And tweak the HIView's location...
	ControlRef t_root_control;
	GetRootControl((WindowPtr)window -> handle . window, &t_root_control);
	ControlRef t_subcontrol;
	if (GetIndexedSubControl(t_root_control, 1, &t_subcontrol) == noErr)
	{
		Rect t_bounds;
		t_bounds . left = 0;
		t_bounds . top = -m_scroll;
		t_bounds . right = rect . width;
		t_bounds . bottom = rect . height;
		SetControlBounds(t_subcontrol, &t_bounds);
	}
	
	// MW-2011-11-30: [[ Bug 9887 ]] Make sure all the player objects on this
	//   stack are adjusted as appropriate.
	for(MCPlayer *t_player = MCplayers; t_player != nil; t_player = t_player -> getnextplayer())
		if (!t_player -> isbuffering() && t_player -> getstack() == this)
			t_player -> setrect(t_player -> getrect());
			
	// MW-2012-10-08: [[ Bug 10442 ]] Set the scroll window property so revBrowser
	//   works properly.
	SetWindowProperty((WindowPtr)window -> handle . window, 'revo', 'scrl', 4, &m_scroll);
	
	// Now send a sync event so revBrowser picks it up.
	EventRef t_event;
	CreateEvent(NULL, 'revo', 'sync', GetCurrentEventTime(), 0, &t_event);
	SendEventToEventTarget(t_event, GetWindowEventTarget((WindowPtr)window -> handle . window));
	ReleaseEvent(t_event);
}
Esempio n. 19
0
/**
	ui_sync : callb:(void -> void) -> void
	<doc>
	Queue a method call [callb] to be executed by the main thread while running the UI event
	loop. This can be used to perform UI updates in the UI thread using results processed by
	another thread.
	</doc>
**/
static value ui_sync( value f ) {
	value *r;
	val_check_function(f,0);
	r = alloc_root(1);
	*r = f;
#	if defined(NEKO_WINDOWS)
	while( !PostMessage(data.wnd,WM_SYNC_CALL,0,(LPARAM)r) )
		Sleep(100);
#	elif defined(NEKO_MAC)
	EventRef e;
	CreateEvent(NULL,UIEvent,eCall,GetCurrentEventTime(),kEventAttributeUserEvent,&e);
	SetEventParameter(e,pFunc,typeVoidPtr,sizeof(void*),&r);
	PostEventToQueue(GetMainEventQueue(),e,kEventPriorityStandard);
	ReleaseEvent(e);
#	elif defined(NEKO_LINUX)
	// the lock should not be needed because GTK is MT-safe
	// however the GTK lock mechanism is a LOT slower than
	// using a pthread_mutex
	pthread_mutex_lock(&data.lock);
	gtk_timeout_add( 0, onSyncCall, (gpointer)r );
	pthread_mutex_unlock(&data.lock);
#	endif
	return val_null;
}
Esempio n. 20
0
// ---------------------------------------------------------------------------
// 
// ------------
void bVirtualStyle::draw(bStdWait& wt){
_bTrace_("bVirtualStyle::draw",false);
_tm_("drawing "+_name);

	if(!_vis){
//_tm_("style not visible");
		return;
	}
int				i,ri=1;
unsigned int	t1,t0=EventTimeToTicks(GetCurrentEventTime());
bScreenObj*		scr;
	
	_scale=scalemgr->get()->coef();
	_ctx->setScaleRef(_scaleref);
	_ctx->setUnitCoef(_unitcoef);
	_ctx->setElement(NULL);

_tm_("applyglobals");
	if(!applyglobals()){
//_tm_("globals not applied");
		return;
	}

//_tm_("loop");
//int	x;
//#warning _valbounds->count()-1 ou _valbounds->count()
	for(i=1;i<=_nbpass;i++){
		if(_sort>=0){
// ********************
// TRI CROISSANT
// ********************
			
				_ctx->reset();
				_ctx->setElement(NULL);
				findgoodstylesruns(i,1);

				
					t1=EventTimeToTicks(GetCurrentEventTime());
					if(t1-t0>60){
						_ctx->flush();
						t0=t1;
					}
					
// 15/05/2009 -> PLUS DE FLUIDITE EN METTANT LE PROGRESS EN DEHORS DU TEST FLUSH
					wt.set_progress(0);
					if(!wt.get_progress()){
						break;
					}
					
					if(!_screenobjs->get(1,&scr)){
						break;
					}
					_ctx->setElement(scr);
/* CONDITION 20/01/09
					if(!applyconditions()){
						continue;
					}
*/
					for(ri=1;ri<=_goodstyleruns->count();ri++){
						if(!applystylesruns(ri)){
							continue;
						}
						if(!applystylesruns(scr,ri)){
							continue;
						}
						(*_drawp)(_ctx);
					}
				
			
		}
		else{
// ********************
// TRI DECROISSANT
// ********************
			
				_ctx->reset();
				_ctx->setElement(NULL);
				findgoodstylesruns(i,1);
				
					t1=EventTimeToTicks(GetCurrentEventTime());
					if(t1-t0>60){
						_ctx->flush();
						t0=t1;
					}

// 15/05/2009 -> PLUS DE FLUIDITE EN METTANT LE PROGRESS EN DEHORS DU TEST FLUSH
					wt.set_progress(0);
					if(!wt.get_progress()){
						break;
					}

					if(!_screenobjs->get(1,&scr)){
						break;
					}
					_ctx->setElement(scr);
/* CONDITION 20/01/09
					if(!applyconditions()){
						continue;
					}
*/
					for(ri=_goodstyleruns->count();ri>0;ri--){
						if(!applystylesruns(ri)){
							continue;
						}
						if(!applystylesruns(scr,ri)){
							continue;
						}
						(*_drawp)(_ctx);
					}
				
			
		}
	}
	_ctx->reset();
}
Esempio n. 21
0
bool
QvisApplication::macEventFilter(EventHandlerCallRef er, EventRef event)
{
    UInt32 ekind = GetEventKind(event), eclass = GetEventClass(event);
    bool ret = false;

    switch(eclass)
    {
    case kEventClassWindow:
      { // new scope
        //qDebug("macEventFilter: kEventClassWindow");
        WindowRef wid;
        GetEventParameter(event, kEventParamDirectObject, typeWindowRef, NULL,
                          sizeof(WindowRef), NULL, &wid);
        QWidget *widget = QWidget::find((WId)wid);
        if(widget)
        {
            if(ekind == kEventWindowShown)
            {
                QString mainWindowName(QString("VisIt ") + QString(VISIT_VERSION));
                if(mainWindowName == QString(widget->windowTitle()))
                    emit showApplication();
                //qDebug("ekind = kEventWindowShown");
            }
            else if(ekind == kEventWindowHidden)
            {
                QString mainWindowName(QString("VisIt ") + QString(VISIT_VERSION));
                if(mainWindowName == QString(widget->windowTitle()))
                    emit hideApplication();            
                //qDebug("ekind = kEventWindowHidden");
            }
#ifdef PRINT_CARBON_EVENTS
            else if(ekind == kEventWindowClose)
                qDebug("\tkEventWindowClose");
            else if(ekind == kEventWindowDrawContent)
                qDebug("\tkEventWindowDrawContent");
            else if(ekind == kEventWindowBoundsChanged)
                qDebug("\tkEventWindowBoundsChanged");
#endif
        }        
        break;
      }
    // Trap for other Carbon events.
    case kEventClassApplication:
        if(ekind == kEventAppDeactivated)
        {
            //qDebug("\tkEventAppDeactivated");

            // We're deactivating the application so the next time we activate it
            // via the menu, we need to make it active.
            needToMakeActive = true;
        }
        else if(ekind == kEventAppActivated)
        {
            //qDebug("\tkEventAppActivated");
            needToMakeActive = false;
        }
#ifdef PRINT_CARBON_EVENTS
        else if(ekind == kEventAppQuit)
            qDebug("\tkEventAppQuit");
        else if(ekind == kEventAppLaunchNotification)
            qDebug("\tkEventAppLaunchNotification");
        else if(ekind == kEventAppLaunched)
            qDebug("\tkEventAppLaunched");
        else if(ekind == kEventAppTerminated)
            qDebug("\tkEventAppTerminated");
        else if(ekind == kEventAppFrontSwitched)
            qDebug("\tkEventAppFrontSwitched");
        else if(ekind == kEventAppFocusMenuBar)
            qDebug("\tkEventAppFocusMenuBar");
        else if(ekind == kEventAppFocusNextDocumentWindow)
            qDebug("\tkEventAppFocusNextDocumentWindow");
        else if(ekind == kEventAppFocusNextFloatingWindow)
            qDebug("\tkEventAppFocusNextFloatingWindow");
        else if(ekind == kEventAppFocusToolbar)
            qDebug("\tkEventAppFocusToolbar");
        else if(ekind == kEventAppFocusDrawer)
            qDebug("\tkEventAppFocusDrawer");
        else if(ekind == kEventAppGetDockTileMenu)
            qDebug("\tkEventAppGetDockTileMenu");
        else if(ekind == kEventAppIsEventInInstantMouser)
            qDebug("\tkEventAppIsEventInInstantMouser");
        else if(ekind == kEventAppHidden)
            qDebug("\tkEventAppHidden");
        else if(ekind == kEventAppShown)
            qDebug("\tkEventAppShown");
        else if(ekind == kEventAppSystemUIModeChanged)
            qDebug("\tkEventAppSystemUIModeChanged");
        else if(ekind == kEventAppAvailableWindowBoundsChanged)
            qDebug("\tkEventAppAvailableWindowBoundsChanged");
        else if(ekind == kEventAppActiveWindowChanged)
            qDebug("\tkEventAppActiveWindowChanged");
        break;
    case kEventClassCommand:
        qDebug("kEventClassCommand");
        break;
    case kEventClassControl:
        qDebug("kEventClassControl");
        break;
    case kEventClassKeyboard:
        qDebug("kEventClassKeyboard");
        break;
#endif
    case kEventClassMenu:
#ifdef PRINT_CARBON_EVENTS
        qDebug("kEventClassMenu");
        if(ekind == kEventMenuBeginTracking)
            qDebug("\tkEventMenuBeginTracking");
        else if(ekind == kEventMenuEndTracking)
            qDebug("\tkEventMenuEndTracking");
        else if(ekind == kEventMenuChangeTrackingMode)
            qDebug("\tkEventMenuChangeTrackingMode");
        else if(ekind == kEventMenuClosed)
            qDebug("\tkEventMenuClosed");
        else if(ekind == kEventMenuTargetItem)
            qDebug("\tkEventMenuTargetItem");
        else if(ekind == kEventMenuMatchKey)
            qDebug("\tkEventMenuMatchKey");
        else if(ekind == kEventMenuEnableItems)
            qDebug("\tkEventMenuEnableItems");
        else
#endif
        if(ekind == kEventMenuOpening)
        {
            //qDebug("\tkEventMenuOpening");

            if(needToMakeActive)
            {
                // If we got here then it's from making the menu active after having
                // left the application for the viewer. In this case, we pull some 
                // tricks on Qt to make it execute the AppActivated event before the
                // current event.
                needToMakeActive = false;

                // Inject a Carbon event to make the application active.
                CreateEvent(NULL, kEventClassApplication, kEventAppActivated, GetCurrentEventTime(),
                     NULL, &request_make_app_active);
                PostEventToQueue(GetCurrentEventQueue(), request_make_app_active, kEventPriorityHigh);
                // Inject a directive to exit a sub-event loop that we'll be creating.
                QTimer::singleShot(10, this, SLOT(exitTheLoop()));

                // Start a new event loop to make the app active and then quit
                // the sub-event loop.
                eventLoop = new QEventLoop(0);
                eventLoop->exec();
            }
        }
        break;
#ifdef PRINT_CARBON_EVENTS
    case kEventClassMouse:
        qDebug("kEventClassMouse");
        break;
#endif
    }

    return ret;
}
/*****************************************************
*
* Handle_TextShouldChangeInRange(inHandlerCallRef, inEvent, inUserData) 
*
* Purpose:  called to intercept text changes which are destined for a text control
*
* Inputs:   inHandlerCallRef    - reference to the current handler call chain
*           inEvent             - the event
*           inUserData          - app-specified data you passed in the call to InstallEventHandler
*
* Returns:  OSStatus            - noErr indicates the event was handled
*                                 eventNotHandledErr indicates the event was not handled and the Toolbox should take over
*/
static pascal OSStatus Handle_TextShouldChangeInRange(EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void *inUserData)
	{
	OSStatus status;

	CFStringRef theCFString = NULL;
	status = GetEventParameter(inEvent, kEventParamCandidateText, typeCFStringRef, NULL, sizeof(theCFString), NULL, &theCFString);
	require_noerr(status, ExitShouldChange);
	require_action(theCFString != NULL, ExitShouldChange, status = userCanceledErr);
	
	UniChar *buffer = NULL;
	CFIndex i, j, len = CFStringGetLength(theCFString);
	if (len == 0) goto ExitShouldChange; // there's nothing to filter
	
	// Grabbing the characters as Unicode chars
	buffer = (UniChar *)malloc(len * sizeof(UniChar));
	require(buffer != NULL, ExitShouldChange);
	CFStringGetCharacters(theCFString, CFRangeMake(0, len), buffer);
	
	// Checking if we just have the return code
	if ((len == 1) && (buffer[0] == kReturnCharCode))
		{
		EventRef theEvent;
		CreateEvent(NULL, kEventClassCommand, kEventCommandProcess, GetCurrentEventTime(), kEventAttributeUserEvent, &theEvent);
		HICommandExtended theCommand;
		theCommand.attributes = kHICommandFromControl;
		theCommand.commandID = 'SVet';
		theCommand.source.control = (ControlRef)inUserData;
		SetEventParameter(theEvent, kEventParamDirectObject, typeHICommand, sizeof(theCommand), &theCommand);
		SendEventToEventTarget(theEvent, GetWindowEventTarget(GetControlOwner((ControlRef)inUserData)));
		ReleaseEvent(theEvent);
		// we don't want the return character to be added to the text so we abort the input
		status = userCanceledErr;
		}
	else
		{
		// Checking to see if we have only digits
		Boolean ok = true;
		for (i = 0; (i < len) && ok; i++)
			ok = (buffer[i] >= '0') && (buffer[i] <= '9');
		
		if (!ok)
			{
			// if not, we remove the offending characters
			for (i = 0, j = 0; i < len; i++)
				if ((buffer[i] >= '0') && (buffer[i] <= '9')) buffer[j++] = buffer[i];
			
			if (j == 0)
				// not a single digit in the candidate text, we abort the inout
				status = userCanceledErr;
			else
				{
				theCFString = CFStringCreateWithCharacters(NULL, buffer, j);
				require_action(theCFString != NULL, ExitShouldChange, status = userCanceledErr);

				status = SetEventParameter(inEvent, kEventParamReplacementText, typeCFStringRef, sizeof(theCFString), &theCFString);
				require_noerr(status, ExitShouldChange);
				// if we reach here, status is already set to noErr so we don't set it again
				}
			}
		else
			// only digits, we just let the HIToolbox do its job
			status = eventNotHandledErr;
		}

ExitShouldChange:

	if (buffer != NULL) free(buffer);

	return status;
	}   // Handle_TextShouldChangeInRange
OSErr BIMUpdateActiveInputArea( BIMSessionHandle inSessionHandle, Boolean inFix )
{
    OSErr error;
    long fixLength;
    EventRef event;
    ComponentInstance componentInstance;
    ScriptLanguageRecord scriptLanguageRecord;
    TextRange pinRange;
    TextRangeArrayPtr hiliteRangePtr;
    TextRangeArrayPtr updateRangePtr;

    if (inFix)
        fixLength = (*inSessionHandle)->fInputBufferCount * 2;
    else
        fixLength = 0;

    hiliteRangePtr = nil;
    updateRangePtr = nil;


    //  Create a new Text Input event (a Carbon event of class "kEventClassTextInput" and kind
    //  "kEventTextInputUpdateActiveInputArea").

    error = CreateEvent( NULL, kEventClassTextInput, kEventTextInputUpdateActiveInputArea,
                         GetCurrentEventTime(), kEventAttributeUserEvent, &event );

    //  The first required parameter is a reference to our text service component instance. Add
    //  it to the event.
    
    if( error == noErr ) {
        componentInstance = (*inSessionHandle)->fComponentInstance;
        error = SetEventParameter( event, kEventParamTextInputSendComponentInstance,
                                   typeComponentInstance, sizeof( ComponentInstance ),
                                   &componentInstance );
    }

    //	The second parameter we need is the script information record. This tells what script
    //  and language the text is in.

    if( error == noErr ) {
        scriptLanguageRecord.fScript = smRoman;			// smJapanese
        scriptLanguageRecord.fLanguage = langEnglish;		// langJapanese
        error = SetEventParameter( event, kEventParamTextInputSendSLRec,
                                   typeIntlWritingCode, sizeof( ScriptLanguageRecord ),
                                   &scriptLanguageRecord );
    }

    //  Now put all of the conversion text into the event. Note that some applications will
    //  always replace all of the active inline area text with what's passed to them, so we have
    //  to pass the entire handle, even if all we're doing is moving the insertion point. Bummer.

    if( error == noErr )
        error = SetEventParameter( event, kEventParamTextInputSendText,
                                   typeUnicodeText,
                                   (*inSessionHandle)->fInputBufferCount * sizeof( UniChar ),
                                   (*inSessionHandle)->fInputBuffer );

    //  The fix length, or the length of text that should be dumped from the inline hole when
    //  we're finished.

    if( error == noErr )
        error = SetEventParameter( event, kEventParamTextInputSendFixLen,
                                   typeLongInteger, sizeof( long ),
                                   &fixLength );

    //  If the text hasn't been changed, then we want to pass an update handle that contains no
    //  update regions, otherwise our handle will say that everything has changed.

    if( error == noErr ) {
        updateRangePtr = (TextRangeArrayPtr) NewPtrClear( sizeof( short ) + sizeof( TextRange ) * 2 );
        if (updateRangePtr) {
            updateRangePtr->fNumOfRanges = 2;
            updateRangePtr->fRange [0].fStart = 0;
            updateRangePtr->fRange [0].fEnd = (*inSessionHandle)->fLastUpdateLength * sizeof( UniChar );
            updateRangePtr->fRange [1].fHiliteStyle = 0;
            updateRangePtr->fRange [1].fStart = 0;
            updateRangePtr->fRange [1].fEnd = (*inSessionHandle)->fInputBufferCount * sizeof( UniChar );
            updateRangePtr->fRange [1].fHiliteStyle = 0;

            (*inSessionHandle)->fLastUpdateLength = (*inSessionHandle)->fInputBufferCount;
        }
        else
            error = memFullErr;
    }

    if( error == noErr )
        error = SetEventParameter( event, kEventParamTextInputSendUpdateRng,
                                   typeTextRangeArray, sizeof( short ) + sizeof( TextRange ) * 2,
                                   updateRangePtr );

    //	Specify the hilite range.

    if( error == noErr ) {
        hiliteRangePtr = (TextRangeArrayPtr) NewPtrClear (sizeof( short ) + sizeof( TextRange ) * 2);
        if( hiliteRangePtr ) {
            hiliteRangePtr->fNumOfRanges = 2;
            hiliteRangePtr->fRange [0].fStart = 0;
            hiliteRangePtr->fRange [0].fEnd = (*inSessionHandle)->fInputBufferCount * sizeof( UniChar );
            if (inFix)
                hiliteRangePtr->fRange [0].fHiliteStyle = kConvertedText;
            else
                hiliteRangePtr->fRange [0].fHiliteStyle = kRawText;
            hiliteRangePtr->fRange [1].fStart = (*inSessionHandle)->fInputBufferCount * sizeof( UniChar );
            hiliteRangePtr->fRange [1].fEnd = (*inSessionHandle)->fInputBufferCount * sizeof( UniChar );
            hiliteRangePtr->fRange [1].fHiliteStyle = kCaretPosition;
        }
        else
            error = memFullErr;
    }
    if( error == noErr )
        error = SetEventParameter( event, kEventParamTextInputSendHiliteRng,
                                   typeTextRangeArray, sizeof( short ) + sizeof( TextRange ) * 2,
                                   hiliteRangePtr );

    //	We don't have any clause information.

    pinRange.fStart = 0;
    pinRange.fEnd = (*inSessionHandle)->fInputBufferCount * sizeof( UniChar );
    if( error == noErr )
        error = SetEventParameter( event, kEventParamTextInputSendPinRng,
                                   typeTextRange, sizeof( TextRange ),
                                   &pinRange );

    // The event is all ready to go, so send it off.

    if( error == noErr )
        error = SendTextInputEvent( event );

    //	Dispose of everything.

    DisposePtr( (Ptr) hiliteRangePtr );
    DisposePtr( (Ptr) updateRangePtr );
    return error;
}
void BIMHandleOffsetToPos( BIMSessionHandle inSessionHandle,
                           struct OffsetToPosParams *offsetToPosParams )
{
    OSStatus		status;
    ComponentInstance	componentInstance;
    EventRef		event;
    
    event = NULL;

    //  Create a new Text Input event (a Carbon event of class "kEventClassTextInput" and kind
    //  "kEventTextInputOffsetToPos").

    status = CreateEvent( NULL, kEventClassTextInput, kEventTextInputOffsetToPos,
                          GetCurrentEventTime(), kEventAttributeUserEvent, &event );

    //  The first required parameter is a reference to our text service component instance.

    if( status == noErr ) {
        componentInstance = (*inSessionHandle)->fComponentInstance;
        status = SetEventParameter( event, kEventParamTextInputSendComponentInstance,
                                    typeComponentInstance, sizeof( ComponentInstance ),
                                    &componentInstance );
    }

    //  Add the required refCon parameter.
    
    if( status == noErr )
        status = SetEventParameter( event, kEventParamTextInputSendRefCon, typeLongInteger,
                                    sizeof( long ), &offsetToPosParams->fRefCon );

    //  Add the required text offset parameter.
    
    if( status == noErr )
        status = SetEventParameter( event, kEventParamTextInputSendTextOffset, typeLongInteger,
                                    sizeof( long ), &offsetToPosParams->fTextOffset );

    //  Add the optional script/language parameter.
    
    if( status == noErr )
        status = SetEventParameter( event, kEventParamTextInputSendSLRec, typeIntlWritingCode,
                                    sizeof( ScriptLanguageRecord ), &offsetToPosParams->fSLRec );

    //  Add the optional leading edge parameter.
    
    if( status == noErr )
        status = SetEventParameter( event, kEventParamTextInputSendLeadingEdge, typeBoolean,
                                    sizeof( Boolean ), &offsetToPosParams->fLeadingEdge );

    //  The event is all ready to go, so send it off.

    if( status == noErr )
        status = SendTextInputEvent( event );

    //  Extract the required point parameter.

    if( status == noErr )
        status = GetEventParameter( event, kEventParamTextInputReplyPoint, typeQDPoint, NULL,
                                    sizeof( Point ), NULL, &offsetToPosParams->fReplyPoint );
                                    
    //  Extract the optional script/language parameter.

    if( status == noErr ) {
        status = GetEventParameter( event, kEventParamTextInputReplySLRec, typeIntlWritingCode,
                                    NULL, sizeof( ScriptLanguageRecord ), NULL,
                                    &offsetToPosParams->fReplySLRec );
        if( status == eventParameterNotFoundErr ) {
            status = noErr;
            offsetToPosParams->fReplySLRecSpecified = TRUE;
        }
        else
            offsetToPosParams->fReplySLRecSpecified = FALSE;
    }
        
    //  Extract the optional font parameter.

    if( status == noErr ) {
        status = GetEventParameter( event, kEventParamTextInputReplyFont, typeLongInteger,
                                    NULL, sizeof( long ), NULL,
                                    &offsetToPosParams->fReplyFont );
        if( status == eventParameterNotFoundErr ) {
            status = noErr;
            offsetToPosParams->fReplyFontSpecified = TRUE;
        }
        else
            offsetToPosParams->fReplyFontSpecified = FALSE;
    }
                                    
    //  Extract the optional point size parameter.

    if( status == noErr ) {
        status = GetEventParameter( event, kEventParamTextInputReplyPointSize, typeFixed,
                                    NULL, sizeof( Fixed ), NULL,
                                    &offsetToPosParams->fReplyPointSize );
        if( status == eventParameterNotFoundErr ) {
            status = noErr;
            offsetToPosParams->fReplyPointSizeSpecified = TRUE;
        }
        else
            offsetToPosParams->fReplyPointSizeSpecified = FALSE;
    }
                                    
    //  Extract the optional line height parameter.

    if( status == noErr ) {
        status = GetEventParameter( event, kEventParamTextInputReplyLineHeight,
                                    typeShortInteger, NULL, sizeof( short ), NULL,
                                    &offsetToPosParams->fReplyLineHeight );
        if( status == eventParameterNotFoundErr ) {
            status = noErr;
            offsetToPosParams->fReplyLineHeightSpecified = TRUE;
        }
        else
            offsetToPosParams->fReplyLineHeightSpecified = FALSE;
    }
                                    
    //  Extract the optional line ascent parameter.

    if( status == noErr ) {
        status = GetEventParameter( event, kEventParamTextInputReplyLineAscent,
                                    typeShortInteger, NULL, sizeof( short ), NULL,
                                    &offsetToPosParams->fReplyLineAscent );
        if( status == eventParameterNotFoundErr ) {
            status = noErr;
            offsetToPosParams->fReplyLineAscentSpecified = TRUE;
        }
        else
            offsetToPosParams->fReplyLineAscentSpecified = FALSE;
    }
                                    
    //  Extract the optional text angle parameter.

    if( status == noErr ) {
        status = GetEventParameter( event, kEventParamTextInputReplyTextAngle, typeFixed,
                                    NULL, sizeof( Fixed ), NULL,
                                    &offsetToPosParams->fReplyTextAngle );
        if( status == eventParameterNotFoundErr ) {
            status = noErr;
            offsetToPosParams->fReplyTextAngleSpecified = TRUE;
        }
        else
            offsetToPosParams->fReplyTextAngleSpecified = FALSE;
    }

    //	Dispose of everything.

    if( event )
        ReleaseEvent( event );

    offsetToPosParams->fReplyResultCode = status;
}
Esempio n. 25
0
BOOL MacWidgetPainter::DrawProgressbar(const OpRect &drawrect, double percent, INT32 progress_when_total_unknown, OpWidgetString* string, const char *skin_empty, const char *skin_full)
{
	const char *full_skin  = skin_full && *skin_full ? skin_full : "Progress Full Skin";

	OpSkinElement *border_skin = g_skin_manager->GetSkinElement(full_skin);
	if(!g_skin_manager->GetCurrentSkin() || !border_skin || !border_skin->IsNative())
	{
		return IndpWidgetPainter::DrawProgressbar(drawrect, percent, progress_when_total_unknown, string, skin_empty, skin_full);
	}

	UINT32 full_color = g_op_ui_info->GetUICSSColor(CSS_VALUE_HighlightText);

	g_skin_manager->GetTextColor(full_skin, &full_color);
		
	CGRect r = {{0, 0}, {drawrect.width, drawrect.height}};
	
	CGContextRef context;
	OpBitmap* bitmap = NULL;

	int bmpwidth = drawrect.width;
	int bmpheight = drawrect.height;
#ifdef PIXEL_SCALE_RENDERING_SUPPORT
	const PixelScaler& scaler = vd->GetVPScale();
	bmpwidth = TO_DEVICE_PIXEL(scaler, bmpwidth);
	bmpheight = TO_DEVICE_PIXEL(scaler, bmpheight);
#endif // PIXEL_SCALE_RENDERING_SUPPORT

	if(OpStatus::IsSuccess(OpBitmap::Create(&bitmap, bmpwidth, bmpheight, FALSE, TRUE, 0, 0, TRUE)))
	{
		int w = bitmap->Width();
		int h = bitmap->Height();
		int bpl = bitmap->GetBytesPerLine();
		void *image_data = bitmap->GetPointer(OpBitmap::ACCESS_WRITEONLY);
		if (!image_data)
		{
			delete bitmap;
			return FALSE;
		}
		memset(image_data, 0, bpl*h);
		CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
		CGBitmapInfo alpha = kCGBitmapByteOrderVegaInternal;
		context = CGBitmapContextCreate(image_data, w, h, 8, bpl, colorSpace, alpha);
		CGColorSpaceRelease(colorSpace);
		int win_height = drawrect.height;

		float scale = 1.0f;
#ifdef PIXEL_SCALE_RENDERING_SUPPORT
		scale = TO_DEVICE_PIXEL(scaler, scale);
#endif // PIXEL_SCALE_RENDERING_SUPPORT
		CGContextScaleCTM(context, scale, -scale);
		CGContextTranslateCTM(context, 0.0, -win_height);

		if (percent == 0 && progress_when_total_unknown)
		{
			HIThemeTrackDrawInfo drawInfo;
			
			SInt32 thickness = 0;
			SInt32 shadow = 0;
			if	(noErr == GetThemeMetric(kThemeMetricLargeProgressBarThickness, &thickness) &&
				(noErr == GetThemeMetric(kThemeMetricProgressBarShadowOutset, &shadow)))
			{
				SInt32 progressHeight = thickness + shadow;
				
				if((r.size.height) > progressHeight)
				{
					float f = (r.size.height - progressHeight); // / 2;
					r.origin.y += f;
					r.size.height -= f;
				}
			}
			else
			{
				float f = (r.size.height / 4) - 1;
				r.origin.y += f;
				r.size.height -= f;
			}

			drawInfo.version = 0;
			drawInfo.kind = kThemeIndeterminateBarLarge;
			drawInfo.bounds = r;
			drawInfo.min = 0;
			drawInfo.max = 100;
			drawInfo.value = 0;
			drawInfo.attributes = kThemeTrackHorizontal;
			drawInfo.enableState = widget->IsEnabled() ? kThemeTrackActive : kThemeTrackInactive;
			drawInfo.trackInfo.progress.phase = progress_when_total_unknown;
			
			HIThemeDrawTrack(&drawInfo, NULL, context, kHIThemeOrientationNormal);		
		}
		else
		{
			HIThemeTrackDrawInfo drawInfo;
			
			SInt32 thickness = 0;
			SInt32 shadow = 0;
			if	(noErr == GetThemeMetric(kThemeMetricLargeProgressBarThickness, &thickness) &&
				(noErr == GetThemeMetric(kThemeMetricProgressBarShadowOutset, &shadow)))
			{
				SInt32 progressHeight = thickness + shadow;
				
				if((r.size.height) > progressHeight)
				{
					float f = (r.size.height - progressHeight); // / 2;
					r.origin.y += f;
					r.size.height -= f;
				}
			}
			else
			{
				float f = (r.size.height / 4) - 1;
				r.origin.y += f;
				r.size.height -= f;
			}

			drawInfo.version = 0;
			drawInfo.kind = kThemeProgressBarLarge;
			drawInfo.bounds = r;
			drawInfo.min = 0;
			drawInfo.max = 100;
			drawInfo.value = (SInt32)(percent);
			drawInfo.attributes = kThemeTrackHorizontal;
			drawInfo.enableState = widget->IsEnabled() ? kThemeTrackActive : kThemeTrackInactive;
			drawInfo.trackInfo.progress.phase = floorf(GetCurrentEventTime()*16);
			
			HIThemeDrawTrack(&drawInfo, NULL, context, kHIThemeOrientationNormal);
		}
		
		CGContextRelease(context);
		bitmap->ReleasePointer();
		vd->BitmapOut(bitmap, OpRect(0, 0, bitmap->Width(), bitmap->Height()), drawrect);
		delete bitmap;
	}
	
	if (string)
	{
		widget->SetClipRect(drawrect);
		OpRect textRect = drawrect;
		textRect.y -= 1;
		string->Draw(textRect, vd, full_color);
		widget->RemoveClipRect();
	}
	
	return TRUE;
}