Exemplo n.º 1
0
//[-------------------------------------------------------]
//[ Protected virtual PLGui::GuiApplication functions     ]
//[-------------------------------------------------------]
void Application::OnCreateMainWindow()
{
	// [sbusch]
//	String sDir = Url(sFilename).CutFilename();
//	System::GetInstance()->SetCurrentDir(sDir);
//	LoadableManager::GetInstance()->AddBaseDir(sDir);

	// Get GUI
	Gui *pGui = Gui::GetSystemGui();

	// List screens
	System::GetInstance()->GetConsole().Print("Screens:\n");
	for (uint32 i=0; i<pGui->GetScreens().GetNumOfElements(); i++) {
		Screen *pScreen = pGui->GetScreens().Get(i);
		String sName	= pScreen->GetName();
		Vector2i vSize	= pScreen->GetSize();
		Vector2i vPos	= pScreen->GetPos();
		bool bDefault	= pScreen->IsDefault();
		System::GetInstance()->GetConsole().Print(
			String("- ") + sName +
			" [" + vSize.x + 'x' + vSize.y +']' +
			" (" + vPos .x + ',' + vPos .y + ')' +
			(bDefault ? " (*)" : "") +
			'\n');
	}

	// Create window
	TestWindow *pWindow = new TestWindow();
//	pWindow->SetFullscreenEnabled(true);
	pWindow->SetPos(Vector2i(0, 0));
	pWindow->SetSize(Vector2i(640, 480));
	pWindow->Center(CenterScreen);
	pWindow->SetVisible(true);

	// Add modifiers
	pWindow->AddModifier("PLGui::ModClose", "ExitApplication=1");
//	pWindow->AddModifier("PLGui::ModBlend", "");

	// Set main window
	SetMainWindow(pWindow);
}
Exemplo n.º 2
0
/**
*  @brief
*    Constructor
*/
Gui::Gui(const String &sGui) :
	m_pGuiImpl(nullptr),
	m_bShutdown(false),
	m_pTheme(nullptr),
	m_nHoverTime(2000),
	m_cFontManager(*this),
	m_cCursorManager(*this),
	m_cClipBoard(*this),
	m_bActive(true),
	m_nNextWidgetID(1),
	m_pDefaultScreen(nullptr),
	m_bMouseVisible(true),
	m_pRootWidget(nullptr),
	m_pMouseOverWidget(nullptr),
	m_pMouseOverWidgetNew(nullptr),
	m_pHoverTimer(nullptr),
	m_pFocusWidget(nullptr),
	m_pFocusWidgetNew(nullptr),
	m_pTooltip(nullptr),
	EventHandlerOnHoverTimer(&Gui::OnHoverTimer, this)
{
	// Check name of GUI backend
	if (sGui.GetLength()) {
		// Find GUI class
		const Class *pClass = ClassManager::GetInstance()->GetClass(sGui);
		if (pClass && pClass->IsDerivedFrom("PLGui::GuiImpl")) {
			// Create the specified GUI implementation
			m_pGuiImpl = static_cast<GuiImpl*>(pClass->Create(Params<Object*, Gui*>(this)));
		}
	} else {
		// Create system GUI
		#if defined(WIN32)
			m_pGuiImpl = new GuiWindows(this);
		#elif defined(ANDROID)
			m_pGuiImpl = new GuiAndroid(this);
		#elif defined(LINUX)
			m_pGuiImpl = new GuiLinux(this);
		#else
			// Unknown system
			#error "Unsupported platform"
		#endif
	}

	// Get list of screens
	m_pGuiImpl->EnumerateScreens(m_lstScreens);
	for (uint32 i=0; i<m_lstScreens.GetNumOfElements(); i++) {
		// Save default screen
		Screen *pScreen = m_lstScreens[i];
		if (pScreen->IsDefault()) {
			m_pDefaultScreen = pScreen;
		}
	}

	// Create dummy root widget
	m_pRootWidget = new Widget(this);

	// Initialize ClipBoard
	m_cClipBoard.InitClipBoard();

	// Create theme
	m_pTheme = new ThemeDesktop(*this);
}