Example #1
0
/**
      \brief Retrieve info from window, needed for accel layer
*/
void UI_getWindowInfo(void *draw, GUI_WindowInfo *xinfo)
{
    ADM_assert(videoWindow);
    QWidget* widget = videoWindow->parentWidget();
    xinfo->widget = videoWindow;
    xinfo->systemWindowId = 0;

#if defined(_WIN32)
	xinfo->display=(void *)videoWindow->winId();
        xinfo->systemWindowId=videoWindow->winId();
#elif defined(__APPLE__)
	#if defined(ADM_CPU_X86_64)
		xinfo->display = (void*)videoWindow->winId();
                xinfo->systemWindowId=videoWindow->winId();
	#else
		xinfo->display = HIViewGetWindow(HIViewRef(widget->winId()));
                xinfo->systemWindowId= HIViewGetWindow(HIViewRef(widget->winId()));
	#endif
#else
        #if QT_VERSION < QT_VERSION_CHECK(5,0,0) 
                const QX11Info &info=videoWindow->x11Info();
                xinfo->display=info.display();
        #else
                xinfo->display=XOpenDisplay(NULL);
        #endif
        xinfo->systemWindowId=videoWindow->winId();
#endif
        QPoint localPoint(0,0);
        QPoint windowPoint = videoWindow->mapToGlobal(localPoint);        
	xinfo->x = windowPoint.x();
	xinfo->y = windowPoint.y();
	xinfo->width  = displayW;
	xinfo->height = displayH;
}
Example #2
0
OSStatus
TextViewReadCFURL( HIViewRef textView, CFURLRef cfURL )
{
	OSStatus status = paramErr;
	CFDictionaryRef dataOptions = NULL;
	static const CFStringRef taskCFStr = CFSTR("TaskReadCFURL");
	static const CFStringRef taskErrorCFStr = CFSTR("TaskReadCFURLError");

	status = TXNReadFromCFURL( HITextViewGetTXNObject(textView),
							kTXNStartOffset, kTXNEndOffset,
							dataOptions,
							cfURL,
							NULL /*docAttributes*/ );
	if( status != noErr )
	{
		WarnStatusString( "TXNReadFromCFURL returned: %lu ", status );
		SignalHelpMessage( HIViewGetWindow( textView ), taskErrorCFStr );
	}
	else
	{
		CMLTEViewData* mlteData = NULL;
		SignalHelpMessage( HIViewGetWindow( textView ), taskCFStr );
		HIViewSetNeedsDisplay( textView, true );
	
		// in some scenarios, it is useful to remember where we got the file
		// data from at a later time, so save the URL in our custom instance data object
		mlteData = TextViewRetrieveMLTEInstanceData( textView );
		if( mlteData != NULL )
			mlteData->SetURL( cfURL );
	}
	
	return status;
}
Example #3
0
OSStatus
TextViewSpellingSupport( HIViewRef textView, Boolean on )
{
	OSStatus status = noErr;
	TXNCommandEventSupportOptions options = 0;
	TXNObject txnObj =  HITextViewGetTXNObject(textView);
	
	// Got TXNObject?
	require( txnObj != NULL, EXIT );

	// Get existing option settings...
	status = TXNGetCommandEventSupport( txnObj, &options );
	require_noerr( status, EXIT );
	
	// add or subtract spelling support as requested
	// (and enable/disable menu items appropriately)
	if( on )	
	{
		options |= kTXNSupportSpellCheckCommandProcessing;
		options |= kTXNSupportSpellCheckCommandUpdating;
		EnableMenuCommand(NULL, kHICommandShowSpellingPanel);
		EnableMenuCommand(NULL, kToggleAutoSpellcheckCommand);
		verify_noerr( SignalHelpMessage( HIViewGetWindow( textView ), CFSTR("SpellSupportEnable") ));
	}
	else
	{
		if( options & kTXNSupportSpellCheckCommandProcessing )
			options ^= kTXNSupportSpellCheckCommandProcessing;
		if( options & kTXNSupportSpellCheckCommandUpdating )
			options ^= kTXNSupportSpellCheckCommandUpdating;
		DisableMenuCommand(NULL, kHICommandShowSpellingPanel);
		DisableMenuCommand(NULL, kToggleAutoSpellcheckCommand);
		verify_noerr( SignalHelpMessage( HIViewGetWindow( textView ), CFSTR("SpellSupportDisable") ));
	}

	// Set auto spell check state accordingly
	status = TextViewSpellCheckAsYouType(textView, on);
	verify_noerr( status );

	// reset modified options
	status = TXNSetCommandEventSupport(txnObj, options);
	verify_noerr( status );
	
	HIViewSetNeedsDisplay( textView, true );

	EXIT:
	;
	return status;
}
Example #4
0
OSStatus
TextViewDefaultSettings( HIViewRef textView )
{
	OSStatus status = paramErr;
	static const CFStringRef taskCFStr = CFSTR("TaskDefault");
	WindowRef window;
	
	status = AddTextToTheTextView( textView );
	check_noerr( status );
	status = TextViewEditCommandSupport( textView, true );
	check_noerr( status );
	status = TextViewFontPanelSupport( textView, false );
	check_noerr( status );
	status = TextViewSpellingSupport( textView, false );
	check_noerr( status );
	status = TextViewScrollingOptions( textView, (UInt32)kTXNAutoScrollInsertionIntoView );
	check_noerr( status );
	status = TXNSetSelection(HITextViewGetTXNObject(textView), kTXNStartOffset, kTXNStartOffset);
	check_noerr( status );
	status = HIScrollViewNavigate(HIViewGetSuperview(textView),kHIScrollViewScrollToTop) ;
	check_noerr( status );

	status = SignalHelpMessage( HIViewGetWindow( textView ), taskCFStr );

	return status;
}
Example #5
0
void QDockWidgetPrivate::setWindowState(bool floating, bool unplug, const QRect &rect)
{
    Q_Q(QDockWidget);

    if (!floating && parent) {
        QMainWindowLayout *mwlayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget()));
        if (mwlayout && mwlayout->dockWidgetArea(q) == Qt::NoDockWidgetArea)
            return; // this dockwidget can't be redocked
    }

    bool wasFloating = q->isFloating();
    bool hidden = q->isHidden();

    if (q->isVisible())
        q->hide();

    Qt::WindowFlags flags = floating ? Qt::Tool : Qt::Widget;

    QDockWidgetLayout *dwLayout = qobject_cast<QDockWidgetLayout*>(layout);
    const bool nativeDeco = dwLayout->nativeWindowDeco(floating);

    if (nativeDeco) {
        flags |= Qt::CustomizeWindowHint | Qt::WindowTitleHint;
        if (hasFeature(this, QDockWidget::DockWidgetClosable))
            flags |= Qt::WindowCloseButtonHint;
    } else {
        flags |= Qt::FramelessWindowHint;
    }

    if (unplug)
        flags |= Qt::X11BypassWindowManagerHint;

    q->setWindowFlags(flags);

#if defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA)
    if (floating && nativeDeco && (q->features() & QDockWidget::DockWidgetVerticalTitleBar)) {
        ChangeWindowAttributes(HIViewGetWindow(HIViewRef(q->winId())), kWindowSideTitlebarAttribute, 0);
    }
#endif

    if (!rect.isNull())
        q->setGeometry(rect);

    updateButtons();

    if (!hidden)
        q->show();

    if (floating != wasFloating) {
        emit q->topLevelChanged(floating);
        if (!floating && parent) {
            QMainWindowLayout *mwlayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget()));
            if (mwlayout)
                emit q->dockLocationChanged(mwlayout->dockWidgetArea(q));
        }
    }

    resizer->setActive(QWidgetResizeHandler::Resize, !unplug && floating && !nativeDeco);
}
Example #6
0
OSStatus
TextViewFontPanelSupport( HIViewRef textView, Boolean on )
{
	OSStatus status = noErr;
	TXNCommandEventSupportOptions options = 0;
	TXNObject txnObj =  HITextViewGetTXNObject(textView);
	
	// Got TXNObject?
	require( txnObj != NULL, EXIT );

	// Get existing option settings...
	status = TXNGetCommandEventSupport( txnObj, &options );
	require_noerr( status, EXIT );
	
	// Add or subract font command support as requested,
	// (and enable/disable menu items appropriately)
	if( on )	
	{
		options |= kTXNSupportFontCommandProcessing;
		options |= kTXNSupportFontCommandUpdating;
		EnableMenuCommand(NULL, kHICommandShowHideFontPanel);
		if ( ! FPIsFontPanelVisible() )
			verify_noerr( FPShowHideFontPanel() );
		verify_noerr( SignalHelpMessage( HIViewGetWindow( textView ), CFSTR("FontPanelEnable") ));
	}
	else
	{
		if( options & kTXNSupportFontCommandProcessing )
			options ^= kTXNSupportFontCommandProcessing;
		if( options & kTXNSupportFontCommandUpdating )
			options ^= kTXNSupportFontCommandUpdating;
		DisableMenuCommand(NULL, kHICommandShowHideFontPanel);
		if ( FPIsFontPanelVisible() )
			verify_noerr( FPShowHideFontPanel() );
		verify_noerr( SignalHelpMessage( HIViewGetWindow( textView ), CFSTR("FontPanelDisable") ));
	}
	// reset modified options
	status = TXNSetCommandEventSupport(txnObj, options );
	verify_noerr( status );
	
	EXIT:
	;
	return status;
}
void getMainWindowHandles(intptr_t *handle, intptr_t *nativeHandle)
{
	*handle = (intptr_t)QuiMainWindows;

#if defined(__APPLE__) && !defined(ADM_CPU_X86_64)
	*nativeHandle = (intptr_t)HIViewGetWindow(HIViewRef(QuiMainWindows->winId()));
#else
	*nativeHandle = (intptr_t)QuiMainWindows->winId();
#endif
}
Example #8
0
OSStatus
TextViewProcessHICommand( HIViewRef textView, const HICommand& hiCommand )
{
	char buffer[255];
    OSStatus status = eventNotHandledErr;
	static const CFStringRef exampleCFStr = CFSTR("Example Action Group");
    switch( hiCommand.commandID )
    {
		case kToggleAutoSpellcheckCommand:
		{
			static const CFStringRef taskONCFStr = CFSTR("SpellcheckON");
			static const CFStringRef taskOFFCFStr = CFSTR("SpellcheckOFF");
			CFStringRef taskCFStr = NULL;
			
			Boolean spellState = TextViewToggleSpellCheckAsYouType( textView );
			
			taskCFStr = spellState?taskONCFStr:taskOFFCFStr;

			SignalHelpMessage( HIViewGetWindow( textView ), taskCFStr );
			status = noErr;
		}
			break;
			
		case kBeginUndoActionGroupCommand:
		{
			static const CFStringRef taskCFStr = CFSTR("ActionGroupBEGIN");
			SignalHelpMessage( HIViewGetWindow( textView ), taskCFStr );
			status = TextViewBeginActionGroup( textView, exampleCFStr );
		}
			break;
		case kEndUndoActionGroupCommand:
		{
			static const CFStringRef taskCFStr = CFSTR("ActionGroupEND");
			SignalHelpMessage( HIViewGetWindow( textView ), taskCFStr );
			status = TextViewEndActionGroup( textView );
		}
			break;
        default:
            ;
    }
    return status;
}
Example #9
0
OSStatus
TextViewDemoSpellingSupport( HIViewRef textView )
{
	OSStatus status = paramErr;
	static const CFStringRef taskCFStr = CFSTR("TaskSpellcheck");

	status = TextViewSpellingSupport( textView, true );

	MyShowSpellCheckPanel();

	verify_noerr( SignalHelpMessage( HIViewGetWindow( textView ), taskCFStr ) );
	return status; 
}
Example #10
0
void QDockWidgetPrivate::setWindowState(bool floating, bool unplug, const QRect &rect)
{
    Q_Q(QDockWidget);

    bool wasFloating = q->isFloating();
    bool hidden = q->isHidden();

    if (q->isVisible())
        q->hide();

    Qt::WindowFlags flags = floating ? Qt::Tool : Qt::Widget;

    QDockWidgetLayout *layout = qobject_cast<QDockWidgetLayout*>(q->layout());
    bool nativeDeco = floating && layout->widget(QDockWidgetLayout::TitleBar) == 0;
#if defined(Q_WS_X11) || defined(Q_WS_QWS)
    nativeDeco = false;
#endif

    if (nativeDeco) {
        flags |= Qt::CustomizeWindowHint | Qt::WindowTitleHint;
        if (hasFeature(q, QDockWidget::DockWidgetClosable))
            flags |= Qt::WindowSystemMenuHint;
    } else {
        flags |= Qt::FramelessWindowHint;
    }

    if (unplug)
        flags |= Qt::X11BypassWindowManagerHint;

    q->setWindowFlags(flags);

#ifdef Q_WS_MAC
    if (floating && nativeDeco && (q->features() & QDockWidget::DockWidgetVerticalTitleBar)) {
        ChangeWindowAttributes(HIViewGetWindow(HIViewRef(q->winId())), kWindowSideTitlebarAttribute, 0);
    }
#endif

    if (!rect.isNull())
        q->setGeometry(rect);

    updateButtons();

    if (!hidden)
        q->show();

    if (floating != wasFloating)
        emit q->topLevelChanged(floating);

    resizer->setActive(QWidgetResizeHandler::Resize, !unplug && floating && !nativeDeco);
}
Example #11
0
OSStatus
TextViewDemoFontPanelSupport( HIViewRef textView )
{
	OSStatus status = paramErr;
	static const CFStringRef taskCFStr = CFSTR("TaskFontPanel");

	status = TextViewFontPanelSupport( textView, true );

	if ( ! FPIsFontPanelVisible() )
		verify_noerr( FPShowHideFontPanel() );

	verify_noerr( SignalHelpMessage( HIViewGetWindow( textView ), taskCFStr ) );
	return status; 
}
Example #12
0
OSStatus
TextViewDemoActionGroup( HIViewRef textView )
{
	const char* sampleText = "bigger...\n";
	static const CFStringRef taskCFStr = CFSTR("TaskActionGroup");

	static const CFStringRef actionLabel = CFSTR("Example Action Group");
	
	TXNObject txnObj = HITextViewGetTXNObject(textView);
	
    TXNTypeAttributes	typeAttr[] = {{kTXNQDFontSizeAttribute,
									   kTXNQDFontSizeAttributeSize,
										{0}}};
	typeAttr[0].data.dataValue = (24 << 16);
	
	TXNBeginActionGroup( txnObj, actionLabel);
	
	TXNSetData( txnObj, kTXNTextData, sampleText, strlen( sampleText ), kTXNStartOffset, kTXNEndOffset );

	TXNSetTypeAttributes( txnObj, 1, typeAttr, kTXNStartOffset, kTXNEndOffset );
					  
	typeAttr[0].data.dataValue = (36 << 16);
	TXNSetTypeAttributes( txnObj, 1, typeAttr, kTXNEndOffset, kTXNEndOffset );
	
	TXNSetData( txnObj, kTXNTextData, sampleText, strlen( sampleText ), kTXNEndOffset, kTXNEndOffset );
				  
	typeAttr[0].data.dataValue = (48 << 16);
	TXNSetTypeAttributes( txnObj, 1, typeAttr, kTXNEndOffset, kTXNEndOffset );
	
	TXNSetData( txnObj, kTXNTextData, sampleText, strlen( sampleText ), kTXNEndOffset, kTXNEndOffset );
	
	typeAttr[0].data.dataValue = (72 << 16);
	TXNSetTypeAttributes( txnObj, 1, typeAttr, kTXNEndOffset, kTXNEndOffset );
	
	TXNSetData( txnObj, kTXNTextData, sampleText, strlen( sampleText ), kTXNEndOffset, kTXNEndOffset );
	
	typeAttr[0].data.dataValue = (96 << 16);
	TXNSetTypeAttributes( txnObj, 1, typeAttr, kTXNEndOffset, kTXNEndOffset );
	
	TXNSetData( txnObj, kTXNTextData, sampleText, strlen( sampleText ) - 1 /*don't set last line return*/, 
				kTXNEndOffset, kTXNEndOffset );
	
	TXNEndActionGroup( txnObj );  
	SignalHelpMessage( HIViewGetWindow( textView ), taskCFStr );
	return noErr;
}
    //-------------------------------------------------------------------------------------------------//
    void OSXCarbonWindow::windowMovedOrResized()
    {
        // External windows will call this method.
        if(mView != NULL)
        {
            // Determine the AGL_BUFFER_RECT for the view. The coordinate 
            // system for this rectangle is relative to the owning window, with 
            // the origin at the bottom left corner and the y-axis inverted.
            
            // Also, when leaving fullscreen, the display properties are not guaranteed to be
            // the same as when we were windowed previously.  So resize the window and views back
            // to their original dimensions.
            HIRect newFrame = CGRectMake(mLeft, mTop+22, mWidth, mHeight);
            HIRect viewBounds = CGRectZero, winBounds = CGRectZero;

            SizeWindow(mWindow, mWidth, mHeight, true);
            HIViewSetFrame(mView, &newFrame);

            HIViewGetBounds(mView, &viewBounds);
            HIViewRef root = HIViewGetRoot(HIViewGetWindow(mView));

            HIViewGetBounds(root, &winBounds);
            HIViewConvertRect(&viewBounds, mView, root);

            // Set the AGL buffer rectangle (i.e. the bounds that we will use) 
            GLint bufferRect[4]; 
            bufferRect[0] = viewBounds.origin.x; // 0 = left edge 
            bufferRect[1] = winBounds.size.height - (viewBounds.origin.y + viewBounds.size.height); // 0 = bottom edge 
            bufferRect[2] = viewBounds.size.width; // width of buffer rect 
            bufferRect[3] = viewBounds.size.height; // height of buffer rect 
            
            aglSetInteger(mAGLContext, AGL_BUFFER_RECT, bufferRect); 
            aglEnable(mAGLContext, AGL_BUFFER_RECT); 
            aglUpdateContext(mAGLContext);
            
            mLeft = viewBounds.origin.x; 
            mTop = bufferRect[1];
        }
        
        for (ViewportList::iterator it = mViewportList.begin(); it != mViewportList.end(); ++it) 
        { 
            (*it).second->_updateDimensions(); 
        }
    }
    //-------------------------------------------------------------------------------------------------//
    void OSXCarbonWindow::windowResized()
    {
        // Ensure the context is current
        if(!mIsFullScreen)
        {
            // Determine the AGL_BUFFER_RECT for the view. The coordinate 
            // system for this rectangle is relative to the owning window, with 
            // the origin at the bottom left corner and the y-axis inverted. 
            HIRect newFrame = CGRectMake(mLeft, mTop+22, mWidth, mHeight);
            HIRect viewBounds = CGRectZero, winBounds = CGRectZero;

            SizeWindow(mWindow, mWidth, mHeight, true);
            HIViewSetFrame(mView, &newFrame);

            HIViewGetBounds(mView, &viewBounds);
            HIViewRef root = HIViewGetRoot(HIViewGetWindow(mView));

            HIViewGetBounds(root, &winBounds);
            HIViewConvertRect(&viewBounds, mView, root);

            // Set the AGL buffer rectangle (i.e. the bounds that we will use) 
            GLint bufferRect[4]; 
            bufferRect[0] = viewBounds.origin.x; // 0 = left edge 
            bufferRect[1] = winBounds.size.height - (viewBounds.origin.y + viewBounds.size.height); // 0 = bottom edge 
            bufferRect[2] = viewBounds.size.width; // width of buffer rect 
            bufferRect[3] = viewBounds.size.height; // height of buffer rect 

            aglSetInteger(mAGLContext, AGL_BUFFER_RECT, bufferRect); 
            aglEnable(mAGLContext, AGL_BUFFER_RECT); 
            aglUpdateContext(mAGLContext);

            mLeft = viewBounds.origin.x; 
            mTop = bufferRect[1]; 
        }
        else
        {
            swapCGLBuffers();
        }
        
        for (ViewportList::iterator it = mViewportList.begin(); it != mViewportList.end(); ++it) 
        { 
            (*it).second->_updateDimensions(); 
        }
    }
/**
      \brief Retrieve info from window, needed for accel layer
*/
void UI_getWindowInfo(void *draw, GUI_WindowInfo *xinfo)
{
#if defined(__WIN32)
	xinfo->display=videoWindow->winId();
#elif defined(__APPLE__)
	QWidget* widget = videoWindow->parentWidget();

	xinfo->display = HIViewGetWindow(HIViewRef(widget->winId()));
	xinfo->window = 0;
	xinfo->x = widget->x();
	xinfo->y = widget->parentWidget()->height() - (widget->y() + displayH);
	xinfo->width = displayW;
	xinfo->height = displayH;
#else
    const QX11Info &info=videoWindow->x11Info();
    xinfo->display=info.display();
    xinfo->window=videoWindow->winId();
#endif 
}
Example #16
0
// invoke navigation services code to pick where to save a file
// When the user confirms the Navigation Services dialog, the
// WriteFileCallback will be called with the info obtained from Nav Services.
OSStatus
TextViewDemoWriteToCFURL( HIViewRef textView )
{
	WindowRef window = HIViewGetWindow( textView );
	
	if( window != NULL )
	{
		if( gNewFileSaver == NULL )
		{
			gNewFileSaver = new CNavSaveDialog();
			gNewFileSaver->Init( window );
			
			// Look for a return to the TextView in the WriteFileCallback() function
			// function when the Navigation Services dialog is confirmed
			gNewFileSaver->SetSaveCallback( WriteFileCallback, textView );
		}
		else
			gNewFileSaver->ReInit( window );
		gNewFileSaver->Run();
	}
	return noErr;
}
 //-------------------------------------------------------------------------------------------------//
 void OSXCarbonWindow::resize(unsigned int width, unsigned int height)
 {
     if(!mWindow)
         return;
     
     // Check if the window size really changed
     if(mWidth == width && mHeight == height)
         return;
     mWidth = width;
     mHeight = height;
     if (mIsExternal)
     {
         HIRect viewBounds = CGRectZero, winBounds = CGRectZero;
         HIViewGetBounds(mView, &viewBounds);
         HIViewRef root = HIViewGetRoot(HIViewGetWindow(mView));
         HIViewGetBounds(root, &winBounds);
         HIViewConvertRect(&viewBounds, mView, root);
         mLeft = viewBounds.origin.x;
         mTop = winBounds.size.height - (viewBounds.origin.y + viewBounds.size.height);
         
         // Set the AGL buffer rectangle (i.e. the bounds that we will use) 
         GLint bufferRect[4];      
         bufferRect[0] = mLeft; // 0 = left edge 
         bufferRect[1] = mTop; // 0 = bottom edge 
         bufferRect[2] = mWidth; // width of buffer rect 
         bufferRect[3] = mHeight; // height of buffer rect 
         aglSetInteger(mAGLContext, AGL_BUFFER_RECT, bufferRect);
         for (ViewportList::iterator it = mViewportList.begin(); it != mViewportList.end(); ++it) 
         { 
             (*it).second->_updateDimensions(); 
         }
     }
     else
     {
         SizeWindow(mWindow, width, height, true);
     }
 }
Example #18
0
OSStatus
TextViewScrollingOptions( HIViewRef textView, UInt32 opts )
{
	// kAutoScrollInsertionIntoView  = 0,
	// kAutoScrollNever              = 1,
	// kAutoScrollWhenInsertionVisible = 2
	
	// One of these keys will be used to signal the HelpTextframe with a
	// useful message
	static const CFStringRef autoScrollCFStr = CFSTR("TaskAutoscroll");
	static const CFStringRef scrollNeverCFStr = CFSTR("TaskAutoscrollNever");
	static const CFStringRef scrollIfVisibileCFStr = CFSTR("TaskAutoscrollIfVisible");
	static const CFStringRef scrollUnknownCFStr = CFSTR("TaskAutoscrollUnknown");
	
	CFStringRef taskCFStr = NULL;
	
	switch( opts )
	{
		case kTXNAutoScrollInsertionIntoView:
			taskCFStr = autoScrollCFStr;
			break;
		case kTXNAutoScrollNever:
			taskCFStr = scrollNeverCFStr;
			break;
		case kTXNAutoScrollWhenInsertionVisible:
			taskCFStr = scrollIfVisibileCFStr;
			break;
		default:
			taskCFStr = scrollUnknownCFStr;
	}
	
	if( taskCFStr != NULL )
		SignalHelpMessage( HIViewGetWindow( textView ), taskCFStr );
			
	return TextViewSetObjectControlData( textView, kTXNAutoScrollBehaviorTag, kUnsigned, 0, opts );
}
//-------------------------------------------------------------------------------------------------//
void OSXCarbonWindow::windowMovedOrResized()
{
	// External windows will call this method.
	if(mView != NULL)
	{
		// Determine the AGL_BUFFER_RECT for the view. The coordinate 
        // system for this rectangle is relative to the owning window, with 
        // the origin at the bottom left corner and the y-axis inverted. 
        HIRect viewBounds, winBounds; 
        HIViewGetBounds(mView, &viewBounds); 
        HIViewRef root = HIViewGetRoot(HIViewGetWindow(mView)); 
        
        HIViewGetBounds(root, &winBounds); 
        HIViewConvertRect(&viewBounds, mView, root); 
        
        // Set the AGL buffer rectangle (i.e. the bounds that we will use) 
        GLint bufferRect[4]; 
        bufferRect[0] = viewBounds.origin.x; // 0 = left edge 
        bufferRect[1] = winBounds.size.height - (viewBounds.origin.y + viewBounds.size.height); // 0 = bottom edge 
        bufferRect[2] = viewBounds.size.width; // width of buffer rect 
        bufferRect[3] = viewBounds.size.height; // height of buffer rect 
        
        aglSetInteger(mAGLContext, AGL_BUFFER_RECT, bufferRect); 
        aglEnable (mAGLContext, AGL_BUFFER_RECT); 
        
        mWidth = viewBounds.size.width; 
        mHeight = viewBounds.size.height; 
        mLeft = viewBounds.origin.x; 
        mTop = bufferRect[1]; 
    } 
    
    for (ViewportList::iterator it = mViewportList.begin(); it != mViewportList.end(); ++it) 
    { 
        (*it).second->_updateDimensions(); 
    }
}
    void OSXCarbonWindow::createNewWindow(unsigned int width, unsigned int height, String title)
    {
        if(!mWindow)
        {
            // Create the window rect in global coords
            ::Rect windowRect;
            windowRect.left = 0;
            windowRect.top = 0;
            windowRect.right = width;
            windowRect.bottom = height;
            
            // Set the default attributes for the window
            WindowAttributes windowAttrs = kWindowStandardDocumentAttributes; // default: "resize"

            windowAttrs |= kWindowStandardDocumentAttributes | kWindowStandardHandlerAttribute | kWindowHideOnFullScreenAttribute | kWindowNoShadowAttribute;

            // Create the window
            CreateNewWindow(kDocumentWindowClass, windowAttrs, &windowRect, &mWindow);

            // Color the window background black
            SetThemeWindowBackground(mWindow, kThemeBrushBlack, true);
            
            // Set the title of our window
            CFStringRef titleRef = CFStringCreateWithCString( kCFAllocatorDefault, title.c_str(), kCFStringEncodingASCII );
            SetWindowTitleWithCFString( mWindow, titleRef );
            CFRelease(titleRef);
            mWindowTitle = title;
            
            // Center our window on the screen
            RepositionWindow( mWindow, NULL, kWindowCenterOnMainScreen );
            
            // Get our view
            HIViewFindByID( HIViewGetRoot( mWindow ), kHIViewWindowContentID, &mView );
            
            // Set up our UPP for Window Events
            EventTypeSpec eventSpecs[] = {
                {kEventClassWindow, kEventWindowActivated},
                {kEventClassWindow, kEventWindowDeactivated},
                {kEventClassWindow, kEventWindowShown},
                {kEventClassWindow, kEventWindowHidden},
                {kEventClassWindow, kEventWindowDragCompleted},
                {kEventClassWindow, kEventWindowBoundsChanged},
                {kEventClassWindow, kEventWindowExpanded},
                {kEventClassWindow, kEventWindowCollapsed},
                {kEventClassWindow, kEventWindowClosed},
                {kEventClassWindow, kEventWindowClose}
            };

            EventHandlerUPP handlerUPP = NewEventHandlerUPP(WindowEventUtilities::_CarbonWindowHandler);
            
            // Install the standard event handler for the window
            EventTargetRef target = GetWindowEventTarget(mWindow);
            InstallStandardEventHandler(target);
            
            // We also need to install the WindowEvent Handler, we pass along the window with our requests
            InstallEventHandler(target, handlerUPP, 10, eventSpecs, (void*)this, &mEventHandlerRef);
        }
        HIRect winBounds = CGRectZero;
        HIViewRef root = HIViewGetRoot(HIViewGetWindow(mView)); 
        HIViewGetBounds(root, &winBounds); 

        HIRect viewBounds = CGRectZero;
        HIViewGetBounds(mView, &viewBounds);

        // Display and select our window
        if(!mHidden && mVisible)
        {
            ShowWindow(mWindow);
            SelectWindow(mWindow);
        }

        // Add our window to the window event listener class
        WindowEventUtilities::_addRenderWindow(this);
    }
Example #21
0
void FilterWidget::activate(void)
{
	SetKeyboardFocus(HIViewGetWindow(searchField), searchField, kControlFocusNoPart);
	SetKeyboardFocus(HIViewGetWindow(searchField), searchField, kControlFocusNextPart);
	setText(text());
}
Example #22
0
// Event handling for HICommand events
pascal OSStatus
CommandProcess(EventHandlerCallRef nextHandler, EventRef theEvent, void* userData)
{
#pragma unused (nextHandler, userData)
	WindowRef window;
	HIViewRef textView;
	HICommandExtended inCommand;
	OSStatus status = noErr;

	status = GetEventParameter(theEvent, kEventParamDirectObject, typeHICommand, NULL, sizeof(HICommandExtended), NULL, &inCommand);
	require_noerr( status, CantGetEventParameter);

	// Check to see if this came from one of the buttons
	if ( inCommand.attributes & kHICommandFromControl ) {
		ControlRef hitControl;

		// Get the control and the window & text view associated with it
		hitControl = inCommand.source.control;
		window = HIViewGetWindow(hitControl);
		status = GetTextViewFromWindow(window, textView);
		if ( status != noErr ) return status;

		// The button controls need the text view to be the active focus
		// in order for the HICommands to be correctly dispatched.
		// So we will just force the TextView to be the focus before handling.
		// the HICommand.
		status = TextViewFocusInWindow( HIViewGetWindow(hitControl) );
		if ( status != noErr ) return status;
		
		switch (inCommand.commandID)
		{
			case kDefaultHITextViewCommand:		// **** Reset button				
				status = TextViewDefaultSettings( textView );
				if (status == noErr)
					status = UpdateControlsFromTextViewWindow(window);
				if (status == noErr)
					status = TextViewFocusInWindow( window );
				break;

			case kFontPanelSupportCommand:		// **** Checkboxes
				if ( GetControl32BitValue(hitControl) == kControlCheckBoxCheckedValue )
					status = TextViewDemoFontPanelSupport( textView );
				else
					status = TextViewFontPanelSupport(textView, false);
				break;
			case kDemoSpellingSupportCommand:
				if ( GetControl32BitValue(hitControl) == kControlCheckBoxCheckedValue )
					status = TextViewDemoSpellingSupport( textView );
				else
					status = TextViewSpellingSupport(textView, false);
				break;
				
			case kDemoAutoScrollCommand:		// **** Radio button
				// The radio button values correspond to the MLTE auto scroll constants
				// plus one (the constants start from zero, the radio button values
				// start from one):
				//
				// (radio button 1)  kTXNAutoScrollInsertionIntoView     == 0
				// (radio button 2)  kTXNAutoScrollNever                 == 1
				// (radio button 3)  kTXNAutoScrollWhenInsertionVisible  == 2
				//
				// See the definition of the type TXNAutoScrollBehavior for
				// more information on each constant and its associated behavior.
				status =  TextViewScrollingOptions( textView, (UInt32)(GetControl32BitValue(hitControl) - 1) );
				break;

			case kDemoActionGrouping:			// **** Demo actions
				status = TextViewDemoActionGroup( textView );
				break;
			case kHICommandSave:
			case kDemoCFURLWriteCommand:
				status = TextViewDemoWriteToCFURL( textView );
				break;
			case kDemoCFURLReadCommand:
				status = TextViewDemoReadFromCFURL( textView );
				break;
			default:
				status = eventNotHandledErr;
				break;
		}
	}
	else {
		switch (inCommand.commandID)
		{
			case kHICommandNew:
				status = NewWindow();
				break;
			case kHICommandOpen:
				window = GetFrontWindowOfClass(kDocumentWindowClass, true);
				if ( window != NULL )
				{
					status = GetTextViewFromWindow(window, textView);
					if ( status == noErr )
						status = TextViewDemoReadFromCFURL( textView );
				}
				break;
			default:
				status = eventNotHandledErr;
				break;
		}
	}

CantGetEventParameter:
	return status;
}
static pascal OSStatus HandlePaneEvents(EventHandlerCallRef handlerRef, EventRef eventRef, void *data)
{
    wxMacCarbonEvent event(eventRef);
    CustomData *dt = (CustomData *) data;
    OSStatus result = eventNotHandledErr;

   switch (event.GetClass())
   {
      case kEventClassControl:
      {
         ControlRef control;
         ControlID cid;

         control = event.GetParameter<ControlRef>(kEventParamDirectObject, typeControlRef);
         if (control == NULL)
         {
            break;
         }

         GetControlID(control, &cid);
         if (cid.signature != kCustom)
         {
            break;
         }

         switch (cid.id)
         {
            case kChoice:
            {
               MenuRef menu = GetControlPopupMenuRef(control);
               UInt32 v = GetControl32BitValue(control) - 1;
               const size_t numFilters = dt->extensions.GetCount();
                   
               if (v < (UInt32) dt->extensions.GetCount())
               {
                  dt->currentfilter = v;

                  NavCustomControl(dt->context, kNavCtlBrowserRedraw, NULL);
               }
            }
            break;
                  
            case kButton:
            {
               dt->me->ClickButton(GetControl32BitValue(dt->choice) - 1);
            }
            break;
         }
      }
      break;

      case kEventClassAccessibility:
      {
    switch (event.GetKind())
    {
        case kEventAccessibleGetNamedAttribute:
        {
            CFStringRef attr;

            require_noerr(event.GetParameter(kEventParamAccessibleAttributeName,
                                             typeCFTypeRef,
                                             sizeof(attr),
                                             &attr), ParameterError);

            if (false)
            {
            }
               else if (CFStringCompare(attr, kAXRoleAttribute, 0) == kCFCompareEqualTo)
               {
                CFStringRef role = kAXGroupRole;
        
                result = event.SetParameter(kEventParamAccessibleAttributeValue,
                                            typeCFStringRef,
                                            sizeof(role),
                                            &role);
        
                require_noerr(result, ParameterError);
            }
               else if (CFStringCompare(attr, kAXRoleDescriptionAttribute, 0) == kCFCompareEqualTo)
               {
                CFStringRef role = kAXGroupRole;
                CFStringRef desc;
        
                desc = HICopyAccessibilityRoleDescription(role, NULL);
                  if (desc)
                  {
                    result = event.SetParameter(kEventParamAccessibleAttributeValue,
                                                typeCFStringRef,
                                                sizeof(desc),
                                                &desc);
        
                    CFRelease(desc);
        
                    require_noerr(result, ParameterError);
                }
            }
               else if (CFStringCompare(attr, kAXParentAttribute, 0) == kCFCompareEqualTo)
               {
                HIViewRef viewRef = HIViewGetSuperview(dt->userpane);
                  if (viewRef)
                  {
                    result = SetElement(event, (HIObjectRef) viewRef, 0,
                                        kEventParamAccessibleAttributeValue);
            
                    require_noerr(result, ParameterError);
                }
            }
               else if (CFStringCompare(attr, kAXWindowAttribute, 0) == kCFCompareEqualTo)
               {
                WindowRef winRef = HIViewGetWindow((HIViewRef) dt->userpane);
        
                  if (winRef)
                  {
                    result = SetElement(event, (HIObjectRef) winRef, 0,
                                        kEventParamAccessibleAttributeValue);
        
                    require_noerr(result, ParameterError);
                }
            }
               else if (CFStringCompare(attr, kAXTopLevelUIElementAttribute, 0) == kCFCompareEqualTo)
               {
                  if (dt->window)
                  {
                    result = SetElement(event, (HIObjectRef) dt->window, 0,
                                        kEventParamAccessibleAttributeValue);
        
                    require_noerr(result, ParameterError);
                }
            }
               else
               {
                result = eventNotHandledErr;
            }
        }
        break;
    }
      }
      break;
   }

ParameterError:
    return result;
}
Example #24
0
OSStatus
TextViewWriteToCFURL( HIViewRef textView, CFURLRef fileURL, OSType type, Boolean replacing )
{
	static const CFStringRef taskCFStr = CFSTR("TaskWriteCFURL");
	static const CFStringRef taskErrorCFStr = CFSTR("TaskWriteCFURLERROR");
	OSStatus status = paramErr;	
	FSRef createdFSRef;
	CFNumberRef encodingNumber = NULL;
	
	// create a file based on the URL provided
	status = CreateFileWithCFURL( fileURL, createdFSRef, type, replacing );

	// specify data type info
	CFStringRef dataKeys[2];   // this array of keys only contains CFStringRefs
	
	const void* dataValues[2]; // this array contains a CFStringRef and an CFNumber
							   // so we will use void* for the array type
	
	dataKeys[0] = kTXNDataOptionDocumentTypeKey;
	
	// set an appropriate document type and encoding
	// we are still using the old Textension file type constants for passing
	// the file type selection from Navigation Services, but please note that
	// these constants are being deprecated in Tiger.
	switch( type )
	{
		case 'RTF ':
			dataValues[0] = kTXNRTFDocumentType;
			encodingNumber = UtilCreateEncodingCFNumberRef( kCFStringEncodingUnicode );
			break;
		case kTXNUnicodeTextFile: // old MLTE Unicode file constant
			dataValues[0] = kTXNPlainTextDocumentType;
			encodingNumber = UtilCreateEncodingCFNumberRef( kCFStringEncodingUnicode );
			break;
		case 'text':
		case kTXNTextFile: // old MLTE text file constant
			dataValues[0] = kTXNPlainTextDocumentType;
			encodingNumber = UtilCreateEncodingCFNumberRef( kCFStringEncodingMacRoman );
			break;
		case kTXNTextensionFile: // old MLTE Textension file format file constant
		default:
			dataValues[0] = kTXNMLTEDocumentType;
			encodingNumber = UtilCreateEncodingCFNumberRef( kCFStringEncodingUnicode );
			break;
	}
	
	dataKeys[1] =	kTXNDataOptionCharacterEncodingKey;
	dataValues[1] = (void*)encodingNumber;
	
	CFDictionaryRef iDataOptionsDict = CFDictionaryCreate( NULL /*allocator*/,
														   (const void**)dataKeys,		
														   (const void**)dataValues, 
														   sizeof(dataKeys) / sizeof(CFStringRef), /*itemCount*/
														   &kCFCopyStringDictionaryKeyCallBacks, 
														   &(kCFTypeDictionaryValueCallBacks));
														   
	// Now make some meta data
	CFStringRef docKeys[6];
	CFStringRef docValues[6];
	
	docKeys[0] = kTXNDocumentAttributeTitleKey;
	docValues[0] = CFSTR("Example File");
	
	docKeys[1] = kTXNDocumentAttributeCompanyNameKey;
	docValues[1] = CFSTR("__MyCompanyName__");
	
	docKeys[2] = kTXNDocumentAttributeSubjectKey;
	docValues[2] = CFSTR("Example of saving a file");
	
	docKeys[3] = kTXNDocumentAttributeAuthorKey;
	docValues[3] = CFSTR("Me");
	
	docKeys[4] = kTXNDocumentAttributeKeywordsKey;
	docValues[4] = CFSTR("Textension, MLTE, File, Save, CFURL");
	
	docKeys[5] = kTXNDocumentAttributeCommentKey;
	docValues[5] = CFSTR("This is just a demonstration.");
	
	CFDictionaryRef iDocAttributesDict = CFDictionaryCreate( NULL							 /*allocator*/,
														    (const void**)docKeys,		
														    (const void**)docValues, 
										  					sizeof(docKeys) / sizeof(CFStringRef), /*itemCount*/
										  					&kCFCopyStringDictionaryKeyCallBacks, 
										  					&(kCFTypeDictionaryValueCallBacks));
	

	// console output
	WarnString( "Call TXNWriteRangeToCFURL with url: ");
	CFShow( fileURL );
	
	status = TXNWriteRangeToCFURL( HITextViewGetTXNObject(textView),
									kTXNStartOffset,
									kTXNEndOffset,
									iDataOptionsDict,
									iDocAttributesDict,
									fileURL );

	// clean up all the CFTypes we made
	if( iDataOptionsDict != NULL )
		CFRelease( iDataOptionsDict );
	if( iDocAttributesDict != NULL )
		CFRelease( iDocAttributesDict );
	
	if( status == noErr )
		SignalHelpMessage( HIViewGetWindow( textView ), taskCFStr );
	else
	{
		// If we fail to write a file, we'll leave the bad / broken file we created
		// to save the data into -- as evidence of the error.
		SignalHelpMessage( HIViewGetWindow( textView ), taskErrorCFStr );
	}
	
	return status;
}
Example #25
0
    Ogre::RenderWindow* ExternalRenderWindow::CreateRenderWindow(const std::string &name,  int width, int height, int left, int top, bool fullscreen)
    {
        bool stealparent 
            ((parentWidget())? true : false);

        QWidget *nativewin 
            ((stealparent)? parentWidget() : this);

        Ogre::NameValuePairList params;
        Ogre::String winhandle;

#ifdef Q_WS_WIN
        // According to Ogre Docs
        // positive integer for W32 (HWND handle)
        winhandle = Ogre::StringConverter::toString 
            ((unsigned int) 
             (nativewin-> winId ()));

        //Add the external window handle parameters to the existing params set.
        params["externalWindowHandle"] = winhandle;

#endif

#ifdef Q_WS_MAC
    // qt docs say it's a HIViewRef on carbon,
    // carbon docs say HIViewGetWindow gets a WindowRef out of it

#if 0
    HIViewRef vref = (HIViewRef) nativewin-> winId ();
    WindowRef wref = HIViewGetWindow(vref);
        winhandle = Ogre::StringConverter::toString(
           (unsigned long) (HIViewGetRoot(wref)));
#else
        // according to
        // http://www.ogre3d.org/forums/viewtopic.php?f=2&t=27027 does
        winhandle = Ogre::StringConverter::toString(
                     (unsigned long) nativewin->winId());
#endif
        //Add the external window handle parameters to the existing params set.
        params["externalWindowHandle"] = winhandle;
#endif

#ifdef Q_WS_X11
        // GLX - According to Ogre Docs:
        // poslong:posint:poslong:poslong (display*:screen:windowHandle:XVisualInfo*)
        QX11Info info =  x11Info ();

        winhandle  = Ogre::StringConverter::toString 
            ((unsigned long)
             (info.display ()));
        winhandle += ":";

        winhandle += Ogre::StringConverter::toString 
            ((unsigned int)
             (info.screen ()));
        winhandle += ":";
        
        winhandle += Ogre::StringConverter::toString 
            ((unsigned long)
             nativewin-> winId());

        //Add the external window handle parameters to the existing params set.
        params["parentWindowHandle"] = winhandle;
#endif

        // Window position to params
        if (left != -1)
            params["left"] = ToString(left);
        if (top != -1)
            params["top"] = ToString(top);

        render_window_ = Ogre::Root::getSingletonPtr()-> createRenderWindow(name, width, height, fullscreen, &params);

        return render_window_;

    }
GLboolean
renderspu_SystemVBoxCreateWindow(VisualInfo *visual, GLboolean showIt,
                                 WindowInfo *window)
{
    CRASSERT(visual);
    CRASSERT(window);

    WindowAttributes winAttr = kWindowNoShadowAttribute | kWindowCompositingAttribute | kWindowIgnoreClicksAttribute | kWindowStandardHandlerAttribute | kWindowLiveResizeAttribute;
    WindowClass winClass = kOverlayWindowClass;
    Rect windowRect;
    OSStatus status = noErr;

    window->visual = visual;
    window->nativeWindow = NULL;

    if(window->window && IsValidWindowPtr(window->window))
    {
        EventRef evt;
        status = CreateEvent(NULL, kEventClassVBox, kEventVBoxDisposeWindow, 0, kEventAttributeNone, &evt);
        CHECK_CARBON_RC_RETURN (status, "Render SPU (renderspu_SystemVBoxCreateWindow): CreateEvent Failed", false);
        status = SetEventParameter(evt, kEventParamWindowRef, typeWindowRef, sizeof (window->window), &window->window);
        CHECK_CARBON_RC_RETURN (status, "Render SPU (renderspu_SystemVBoxCreateWindow): SetEventParameter Failed", false);
        status = PostEventToQueue(GetMainEventQueue(), evt, kEventPriorityStandard);
        CHECK_CARBON_RC_RETURN (status, "Render SPU (renderspu_SystemVBoxCreateWindow): PostEventToQueue Failed", false);
    }

    windowRect.left = window->x;
    windowRect.top = window->y;
    windowRect.right = window->x + window->BltInfo.width;
    windowRect.bottom = window->y + window->BltInfo.height;

    status = CreateNewWindow(winClass, winAttr, &windowRect, &window->window);
    CHECK_CARBON_RC_RETURN (status, "Render SPU (renderspu_SystemVBoxCreateWindow): CreateNewWindow Failed", GL_FALSE);

    /* We set a title for debugging purposes */
    CFStringRef title_string;
    title_string = CFStringCreateWithCStringNoCopy(NULL, window->title,
                                                   kCFStringEncodingMacRoman, NULL);
    SetWindowTitleWithCFString(window->BltInfo.window, title_string);
    CFRelease(title_string);

    /* The parent has to be in its own group */
    WindowRef parent = NULL;
    if (render_spu_parent_window_id)
    {
        parent = HIViewGetWindow ((HIViewRef)render_spu_parent_window_id);
        SetWindowGroup (parent, render_spu.pParentGroup);

    }

    /* Add the new window to the master group */
    SetWindowGroup(window->window, render_spu.pMasterGroup);

    /* This will be initialized on the first attempt to attach the global
     * context to this new window */
    window->bufferName = -1;
    window->dummyContext = NULL;
    window->hVisibleRegion = 0;

    if(showIt)
        renderspu_SystemShowWindow(window, GL_TRUE);

    crDebug("Render SPU (renderspu_SystemVBoxCreateWindow): actual window (x, y, width, height): %d, %d, %d, %d",
            window->x, window->y, window->BltInfo.width, window->BltInfo.height);

    return GL_TRUE;
}