//! init the window: create the context
void QT4Window::init(GLInitFunctor oFunc)
{
    if(_sfPrivateOSGContext.getValue() == true)
    {
        if(getGlWidget() != NULL)
        {
            getGlWidget()->doMakeCurrent();
        }

#if defined(WIN32)
        if(getGlWidget() != NULL)
        {
            setHwnd(HWND(getGlWidget()->winId()));
        }

        Inherited::setHdc(wglGetCurrentDC());
#elif defined(__APPLE__) && !OSG_APPLE_IOS
        Inherited::setContext(cocoaWrapperCurrentContext());
#elif defined(__APPLE__) && OSG_APPLE_IOS
#else
        Inherited::setDisplay(glXGetCurrentDisplay ());
        Inherited::setWindow (glXGetCurrentDrawable());
#endif

        if(getGlWidget() != NULL)
        {
            getGlWidget()->doDoneCurrent();
        }

        Inherited::init(oFunc);
    }
    else
    {
        Window::init(oFunc);
    }
}
Exemple #2
0
void NativeViewerWin32PPT::embedHwnd()
{
	// adjust parent window
	//NativeViewerWin32::embedHwnd();
#ifdef Q_OS_WIN32
	QRect rect = containerWidget()->geometry();
	QPoint abs = WidgetUtil::absoluteWidgetPosition(containerWidget());
	m_ppt->runShow();
	m_ppt->setWindowRect(abs.x(), abs.y(), rect.width(), rect.height());

	HWND ptr = NULL;
	int count = 0;
	int max = 1000;
	while(!ptr && count++ < max)
	{
		//qApp->processEvents();
		ptr = FindWindow(L"screenClass",  NULL);
	}

	//HWND hwnd = FindWindowEx(hwnd(), NULL, L"paneClassDC", NULL);
	setHwnd(ptr);
	//qDebug() << "NativeViewerWin32PPT::embedHwnd: hwnd:"<<hwnd()<<", count:"<<count;
	//m_numSlides = m_ppt->numSlides();

	//qDebug() << "NativeViewerWin32PPT::embedHwnd: Num slides:"<<m_numSlides;
	NativeViewerWin32::embedHwnd();
	BringWindowToTop(hwnd());
//
	/*

	// now find the actual widget that holds the show and stretch it out
	HWND hwnd2 = FindWindowEx(hwnd(), NULL, L"paneClassDC", NULL);
	setHwnd(FindWindow(L"screenClass",  NULL));

	if(hwnd2)
	{

		//QPoint abs = absoluteWidgetPosition(containerWidget());

		// This is a "magic forumla" for the proper stretch amount -
		// just found through trial and error. Its NOT perfect, and
		// gets more and more inaccurate the further away from 1024x768 or 320x240
		// the size is. But, it's "good enough" for now.
		int xa = ((int)(8.0/1024.0 * ((double)rect.width())));
		int ya = ((int)(67.0/768.0 * ((double)rect.height())));

		// override for known rectangle size
		if(rect.width() == 320 && rect.height() == 240)
		{
			xa = 8;
			ya = 25;
		}

		//MoveWindow(hwnd(), rect.x(), rect.x(), rect.width(), rect.height(), 1);
		qDebug() << "NativeViewerWin32PPT::embedHwnd(): hwnd2:"<<hwnd2<<", orig size:"<<rect.size()<<", xa:"<<xa<<",ya:"<<ya;


		SetWindowPos(hwnd2, 0,
				-xa, -ya,
				rect.width()  + xa*2,
				rect.height() + ya*2,
				SWP_SHOWWINDOW);
		BringWindowToTop(hwnd());
	}
*/
#endif
}