Beispiel #1
0
	graphics_context::graphics_context(const i_surface& aSurface, const font& aDefaultFont) :
		iSurface(aSurface), 
		iNativeGraphicsContext(aSurface.native_surface().create_graphics_context()), 
		iUnitsContext(*this),
		iDefaultFont(aDefaultFont),
		iOrigin(0, 0),
		iExtents(aSurface.extents()),
		iDrawingGlyphs(0)
	{
	}
Beispiel #2
0
	rect surface_manager::desktop_rect(const i_surface& aSurface) const
	{
#ifdef WIN32
		HMONITOR monitor = MonitorFromWindow(reinterpret_cast<HWND>(aSurface.native_surface().native_handle()), MONITOR_DEFAULTTONEAREST);
		MONITORINFOEX mi;
		mi.cbSize = sizeof(mi);
		GetMonitorInfo(monitor, &mi);
		return basic_rect<LONG>{ basic_point<LONG>{ mi.rcWork.left, mi.rcWork.top }, basic_size<LONG>{ mi.rcWork.right - mi.rcWork.left, mi.rcWork.bottom - mi.rcWork.top } };
#else
		/* todo */
		rect rectSurface{ aSurface.surface_position(), aSurface.surface_size() };
		std::multimap<double, uint32_t> matches;
		for (uint32_t i = 0; i < display_count(); ++i)
		{
			rect rectDisplay = desktop_rect(i);
			rect rectIntersection = rectDisplay.intersection(rectSurface);
			if (!rectIntersection.empty())
				matches[rectIntersection.width() * rectIntersection.height()] = i;
		}
		if (matches.empty())
			return desktop_rect(0);
		return desktop_rect(matches.rbegin()->second);
#endif
	}
Beispiel #3
0
	void surface_manager::remove_surface(i_surface& aSurface)
	{
		auto existingSurface = iSurfaces.find(&aSurface);
		if (existingSurface != iSurfaces.end())
		{
			for (auto s = iSurfaces.begin(); s != iSurfaces.end();)
			{
				if (aSurface.is_owner_of(**s))
				{
					auto& childSurface = **s;
					iSurfaces.erase(s);
					childSurface.close();
					s = iSurfaces.begin();
				}
				else
					++s;
			}
			iSurfaces.erase(existingSurface);
		}	
	}