CBCGPLinearGaugeImpl::CBCGPLinearGaugeImpl(CBCGPVisualContainer* pContainer) :
	CBCGPGaugeImpl(pContainer)
{
	m_nFrameSize = 2;
	m_bCacheImage = TRUE;
	m_bInSetValue = FALSE;
	m_bIsVertical = FALSE;
	m_dblMaxRangeSize = 0.;

	LOGFONT lf;
	globalData.fontBold.GetLogFont(&lf);

	m_textFormat.CreateFromLogFont(lf);
	m_textFormat.SetTextVerticalAlignment(CBCGPTextFormat::BCGP_TEXT_ALIGNMENT_CENTER);

	// Add default scale:
	AddScale();
}
Example #2
0
//
//  函数: WndProc(HWND, UINT, WPARAM, LPARAM)
//
//  目的: 处理主窗口的消息。
//
//  WM_COMMAND	- 处理应用程序菜单
//  WM_PAINT	- 绘制主窗口
//  WM_DESTROY	- 发送退出消息并返回
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	int wmId, wmEvent;
	PAINTSTRUCT ps;
	HDC hdc;

	switch (message)
	{
	case WM_CREATE:
		{
			g_hWndMain = hWnd;
			CreateControlButtons(hWnd);
			UpdateButtonStatus();
		}
		break;
	case WM_COMMAND:
		wmId    = LOWORD(wParam);
		wmEvent = HIWORD(wParam);
		// 分析菜单选择:
		switch (wmId)
		{
		case IDM_ABOUT:
			DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
			break;
		case IDM_EXIT:
			DestroyWindow(hWnd);
			break;
		case START_CAPTURE_ID:
			StartRecord();
			break;
		case STOP_CAPTURE_ID:
			StopRecord();
			break;
		case START_PLAY_ID:
			StartPlay();
			break;
		case STOP_PLAY_ID:
			StopPlay();
			break;
		case START_EXTRACT_ID:
			StartExtract();
			break;
		case STOP_EXTRACT_ID:
			StopExtract();
			break;
		case ADD_SCALE_ID:
			AddScale();
			break;
		case SUB_SCALE_ID:
			SubScale();
			break;
		case PAINT_RECORD_ID:
			PaintRecorder();
			break;
		case PAINT_EXTRACT_ID:
			PaintExtractor();
			break;
		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
		}
		break;
	case WM_PAINT:
		hdc = BeginPaint(hWnd, &ps);
		// TODO: 在此添加任意绘图代码...

		if (g_pAudioPainter->IsEnable())
		{
			RECT rect;
			::GetWindowRect(hWnd, &rect);

			rect.right = rect.right - rect.left - 20;
			rect.left = 10;
			rect.bottom = (rect.bottom - rect.top) / 2;
			rect.top = 200;

			g_pAudioPainter->Paint(hWnd, hdc, rect, 10.0f);
		}

		wchar_t buf[20];
		wsprintf(buf, L"Scale: %d%%", (int)(g_pAudioPainter->GetScale() * 100));
		::TextOut(hdc, 0, 0, buf, ::wcslen(buf));

		EndPaint(hWnd, &ps);
		break;
	case WM_DESTROY:
		PostQuitMessage(0);
		break;
	case WM_TIMER:
		if (g_pAudioPainter->IsEnable())
		{
			RECT rect = { 0, 0,  WINDOW_WIDTH, WINDOW_HEIGHT };
			::InvalidateRect(hWnd, &rect, true);
		}
		break;
	default:
		return DefWindowProc(hWnd, message, wParam, lParam);
	}
	return 0;
}
Example #3
0
void UIAnimation::LoadFromXML(tinyxml2::XMLElement* elem)
{
	if (!elem)
		return;

	const char* sz = elem->Attribute("id");
	if (sz)
		mID = StringConverter::ParseInt(sz);

	sz = elem->Attribute("name");
	if (sz)
		mName = sz;

	sz = elem->Attribute("length");
	if (sz)
		mLength = StringConverter::ParseReal(sz);

	sz = elem->Attribute("loop");
	if (sz)
		mLoop = StringConverter::ParseBool(sz);

	{
		tinyxml2::XMLElement* pC = elem->FirstChildElement("TextColor");
		if (pC)
		{
			tinyxml2::XMLElement* k = pC->FirstChildElement("key");
			while (k)
			{
				float time = 0;
				Color color;
				sz = k->Attribute("time");
				if (sz)
					time = StringConverter::ParseReal(sz);
				sz = k->Attribute("color");
				if (sz)
					color = StringMathConverter::ParseColor(sz);
				AddTextColor(time, color);
				k = k->NextSiblingElement("key");
			}
		}
	}

	{
		tinyxml2::XMLElement* pC = elem->FirstChildElement("BackColor");
		if (pC)
		{
			tinyxml2::XMLElement* k = pC->FirstChildElement("key");
			while (k)
			{
				float time = 0;
				Color color;
				sz = k->Attribute("time");
				if (sz)
					time = StringConverter::ParseReal(sz);
				sz = k->Attribute("color");
				if (sz)
					color = StringMathConverter::ParseColor(sz);
				AddBackColor(time, color);
				k = k->NextSiblingElement("key");
			}
		}
	}

	{
		tinyxml2::XMLElement* pC = elem->FirstChildElement("MaterialColor");
		if (pC)
		{
			tinyxml2::XMLElement* k = pC->FirstChildElement("key");
			while (k)
			{
				float time = 0;
				Color color;
				sz = k->Attribute("time");
				if (sz)
					time = StringConverter::ParseReal(sz);
				sz = k->Attribute("color");
				if (sz)
					color = StringMathConverter::ParseColor(sz);
				AddMaterialColor(time, color);
				k = k->NextSiblingElement("key");
			}
		}
	}

	{
		tinyxml2::XMLElement* pC = elem->FirstChildElement("Pos");
		if (pC)
		{
			tinyxml2::XMLElement* k = pC->FirstChildElement("key");
			while (k)
			{
				float time = 0;
				Vec2 pos;
				sz = k->Attribute("time");
				if (sz)
					time = StringConverter::ParseReal(sz);
				sz = k->Attribute("pos");
				if (sz)
					pos = StringMathConverter::ParseVec2(sz);
				AddPos(time, pos);
				k = k->NextSiblingElement("key");
			}
		}
	}

	{
		tinyxml2::XMLElement* pC = elem->FirstChildElement("Scale");
		if (pC)
		{
			tinyxml2::XMLElement* k = pC->FirstChildElement("key");
			while (k)
			{
				float time = 0;
				Vec2 scale;
				sz = k->Attribute("time");
				if (sz)
					time = StringConverter::ParseReal(sz);
				sz = k->Attribute("scale");
				if (sz)
					scale = StringMathConverter::ParseVec2(sz);
				AddScale(time, scale);
				k = k->NextSiblingElement("key");
			}
		}
	}

	{
		tinyxml2::XMLElement* pC = elem->FirstChildElement("Alpha");
		if (pC)
		{
			tinyxml2::XMLElement* k = pC->FirstChildElement("key");
			while (k)
			{
				float time = 0;
				float alpha;
				sz = k->Attribute("time");
				if (sz)
					time = StringConverter::ParseReal(sz);
				sz = k->Attribute("alpha");
				if (sz)
					alpha = StringConverter::ParseReal(sz);
				AddAlpha(time, alpha);
				k = k->NextSiblingElement("key");
			}
		}
	}
}