Beispiel #1
0
//--------------------------------------------------------------------------
void WindowsWindow::Term()
{
	if (m_hHandle)
	{
		m_kNode.detach();
		m_spParent = nullptr;
		for (auto child : m_kChildList)
		{
			WindowsWindow* pkChild = VeDynamicCast(WindowsWindow, child);
			VE_ASSERT(pkChild);
			pkChild->Term();
		}
		VE_ASSERT(m_kChildList.empty());
		if (!VE_MASK_HAS_ALL(m_u32Flags, VE_WINDOW_FOREIGN))
		{
			if (!DestroyWindow(m_hHandle))
			{
				THROW("Couldn't destory window");
			}
		}
		m_hHandle = nullptr;
		UpdateFlags();
	}
	VE_ASSERT(!m_kNode.is_attach());
}
Beispiel #2
0
//--------------------------------------------------------------------------
bool VeFilePath::HasSubDir(const VeChar8* pcDir) const noexcept
{
	VeChar8 acBuffer[VE_MAX_PATH_LEN];
	PATH_CAT(acBuffer, m_kPath, pcDir);
	PathInfo kInfo;
	if (TestPath(acBuffer, kInfo))
	{
		return VE_MASK_HAS_ALL(kInfo.m_stAttrib, VE_A_SUBDIR);
	}
	return false;
}
Beispiel #3
0
//--------------------------------------------------------------------------
VeBinaryIStreamPtr VeFilePath::CreateStream(const VeChar8* pcPath) noexcept
{
	PathInfo kInfo;
	if (TestPath(pcPath, kInfo))
	{
		if (VE_MASK_HAS_ALL(kInfo.m_stAttrib, VE_A_ARCH))
		{
			return VE_NEW VeFileIStream(pcPath);
		}
	}
	return nullptr;
}
Beispiel #4
0
//--------------------------------------------------------------------------
VeDirectoryPtr VeFilePath::Create(const VeChar8* pcPath,
	bool bTryCreate) noexcept
{
	PathInfo kInfo;
	if (TestPath(pcPath, kInfo))
	{
		if (VE_MASK_HAS_ALL(kInfo.m_stAttrib, VE_A_SUBDIR))
		{
			return VE_NEW VeFilePath(pcPath);
		}
		else if(VE_MASK_HAS_ALL(kInfo.m_stAttrib, VE_A_ARCH))
		{
			return nullptr;
		}
	}
	else if(bTryCreate && CreatePath(pcPath))
	{
		return VE_NEW VeFilePath(pcPath);
	}
	return nullptr;
}
Beispiel #5
0
//--------------------------------------------------------------------------
void VeGraphicsTest::OnKeyReleased(VeKeyboard::InputKey eKey)
{
	if(eKey == VeKeyboard::KEY_C)
	{
		g_pMouse->SetCursorPosF(0.5f, 0.5f);
	}
	else if(eKey == VeKeyboard::KEY_H)
	{
		g_pMouse->SetHide(!g_pMouse->GetStateFlag(VeMouse::CUR_HIDE));
	}
	else if(eKey == VeKeyboard::KEY_L)
	{
		g_pMouse->SetLock(!g_pMouse->GetStateFlag(VeMouse::CUR_LOCK));
	}
	else if(eKey == VeKeyboard::KEY_R)
	{
		//m_spAnimation->MoveBy(0.5f, VeVector2D(50, 50), VeTweenEasing::TYPE_SINE_IN_OUT);
		//m_spAnimation->ScaleBy(0.5f, VeVector2D(2.0f, 2.0f), VeTweenEasing::TYPE_LINEAR);
		//m_spAnimation->RotateBy(0.5f, 8.0f, VeTweenEasing::TYPE_LINEAR);
		//m_spAnimation->ColorBy(0.5f, VeColor(1.0f, 1.0f, 1.0f, 0.8f), VeTweenEasing::TYPE_LINEAR);
	}
	else if(eKey == VeKeyboard::KEY_B)
	{
		//m_spAnimation->MoveBy(0.5f, VeVector2D(-50, -50), VeTweenEasing::TYPE_SINE_IN_OUT);
		//m_spAnimation->ScaleTo(0.5f, VeVector2D(1.0f, 1.0f), VeTweenEasing::TYPE_SINE_IN_OUT);
		//m_spAnimation->RotateTo(0.5f, 0.0f, VeTweenEasing::TYPE_SINE_IN_OUT);
		//m_spAnimation->ColorTo(0.5f, VeColor(1.0f, 1.0f, 1.0f, 0.0f), VeTweenEasing::TYPE_SINE_IN_OUT);
	}
#if defined(VE_PLATFORM_PC)
	else if(eKey == VeKeyboard::KEY_U)
	{
		g_pRenderer->ResizeWindow(1024, 768);
	}
	else if(eKey == VeKeyboard::KEY_I)
	{
		g_pRenderer->ResizeWindow(800, 600);
	}
	else if(VE_MASK_HAS_ALL(g_pKeyboard->GetModifiers(), VeKeyboard::CTRL) && eKey == VeKeyboard::KEY_F)
	{
		//g_pRenderer->SetFullScreen(!g_pStartConfig->IsFullScreen());
	}
#elif defined(VE_PLATFORM_MOBILE_SIM)
	else if(eKey == VeKeyboard::KEY_U)
	{
		g_pRenderer->ResizeWindow(1024, 768);
	}
	else if(eKey == VeKeyboard::KEY_I)
	{
		g_pRenderer->ResizeWindow(960, 640);
	}
#endif
}
Beispiel #6
0
//--------------------------------------------------------------------------
DWORD WindowsWindow::FlagsToWindowStyle(uint32_t u32Flags) noexcept
{
	DWORD dwStyle = 0;
	if (VE_MASK_HAS_ALL(u32Flags, VE_WINDOW_BORDERLESS))
	{
		dwStyle |= (WS_POPUP);
	}
	else
	{
		dwStyle |= (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX);
		if (u32Flags & VE_WINDOW_RESIZABLE)
		{
			dwStyle |= (WS_THICKFRAME | WS_MAXIMIZEBOX);
		}
	}
	return dwStyle;
}
Beispiel #7
0
//--------------------------------------------------------------------------
bool VeAssetPath::Access(VeUInt32 u32Flag) const noexcept
{
	return !VE_MASK_HAS_ALL(u32Flag, VeDirectory::ACCESS_W_OK);
}
Beispiel #8
0
//--------------------------------------------------------------------------
bool PropertyS::IsSynToClient()
{
	return VE_MASK_HAS_ALL(m_u32Attribute, FLAG_CLIENT);
}
Beispiel #9
0
//--------------------------------------------------------------------------
bool PropertyS::IsSaveDatabase()
{
	return VE_MASK_HAS_ALL(m_u32Attribute, FLAG_DATABASE);
}
Beispiel #10
0
//--------------------------------------------------------------------------
void WindowsWindow::Init(WindowsVideo& kVideo, const char* pcTitle,
	int32_t x, int32_t y, int32_t w, int32_t h, uint32_t u32Flags)
{
	Term();
	LPWSTR lpwstrTitle = WindowsVideo::UTF8ToWSTR(pcTitle);
	DWORD dwStyle = FlagsToWindowStyle(u32Flags);

	int32_t flag_x = x >> 28;
	int32_t flag_y = y >> 28;
	x = flag_x ? 0 : x;
	y = flag_y ? 0 : y;
	RECT windowRect = { x, y, w, h };
	AdjustWindowRect(&windowRect, dwStyle, FALSE);

	VE_ASSERT(w > 0 && w < UINT16_MAX && h > 0 && h < UINT16_MAX);
	m_u16Width = (uint16_t)w;
	m_u16Height = (uint16_t)h;

	w = windowRect.right - windowRect.left;
	h = windowRect.bottom - windowRect.top;

	switch (flag_x)
	{
	case 1:
		x = CW_USEDEFAULT;
		break;
	case 2:
		x = (GetSystemMetrics(SM_CXSCREEN) - w) >> 1;
		break;
	default:
		x = windowRect.left;
		break;
	}
	switch (flag_y)
	{
	case 1:
		y = CW_USEDEFAULT;
		break;
	case 2:
		y = (GetSystemMetrics(SM_CYSCREEN) - h) >> 1;
		break;
	default:
		y = windowRect.top;
		break;
	}

	x = x == CW_USEDEFAULT ? x : vtd::max(x, 0);
	y = y == CW_USEDEFAULT ? y : vtd::max(y, 0);

	m_hHandle = CreateWindowW(kVideo.m_wstrClassName, lpwstrTitle, dwStyle,
		x, y, w, h, nullptr, nullptr, kVideo.m_hInstance, this);

	VeFree(lpwstrTitle);

	if (!m_hHandle)
	{
		m_u16Width = 0;
		m_u16Height = 0;
		THROW("Couldn't create window");
	}

	if (VE_MASK_HAS_ALL(u32Flags, VE_WINDOW_SHOWN))
	{
		int32_t i32Show = SW_SHOW;
		if (VE_MASK_HAS_ALL(dwStyle, WS_THICKFRAME))
		{
			switch (u32Flags & 0xF)
			{
			case VE_WINDOW_MINIMIZED:
				i32Show = SW_SHOWMINIMIZED;
				break;
			case VE_WINDOW_MAXIMIZED:
				i32Show = SW_SHOWMAXIMIZED;
				break;
			case VE_WINDOW_DEPSTARTUP:
				i32Show = kVideo.m_i32CmdShow;
				break;
			default:
				break;
			}
		}
		ShowWindow(m_hHandle, i32Show);
	}

	m_u32Flags = u32Flags & (VE_WINDOW_ALLOW_HIGHDPI | VE_WINDOW_FOREIGN);
	UpdateFlags();

	kVideo.m_kWindowList.attach_back(m_kNode);
}