⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wxskinnableframe.cpp

📁 Powerful and Portable GPS application -- support Linux, Windows, Windows CE GPS navigation and Map m
💻 CPP
📖 第 1 页 / 共 3 页
字号:
	wxPoint ptBottomRight;	bool bWantVisible;	ptTopLeft = m_coTopLeft.Resolve(wxPoint(szParent.x, szParent.y));	ptBottomRight = m_coBottomRight.Resolve(wxPoint(szParent.x, szParent.y));	if (ptTopLeft.x >= szParent.x)		ptTopLeft.x = szParent.x - 1;	if (ptTopLeft.y >= szParent.y)		ptTopLeft.y = szParent.y - 1;	if (ptBottomRight.x >= szParent.x)		ptBottomRight.x = szParent.x - 1;	if (ptBottomRight.y >= szParent.y)		ptBottomRight.y = szParent.y - 1;			if (m_cCenterWidth >= 0)	{		ptTopLeft.x = (ptBottomRight.x + ptTopLeft.x) / 2 - m_cCenterWidth / 2;		ptBottomRight.x = (ptBottomRight.x + ptTopLeft.x) / 2 + m_cCenterWidth / 2 + 5;	}	m_pControl->SetSize(ptTopLeft.x, ptTopLeft.y, ptBottomRight.x - ptTopLeft.x, ptBottomRight.y - ptTopLeft.y);	bWantVisible = true;		if (szParent.y < m_iShowMinHeight || szParent.x < m_iShowMinWidth)		bWantVisible = false;	if (m_pControl->IsShown() != bWantVisible)		m_pControl->Show(bWantVisible);}//////////////////////////////////////////////////////////////////////////////////// \brief Event table for wxSkinnableTable/////////////////////////////////////////////////////////////////////////////////BEGIN_EVENT_TABLE(wxSkinnableFrame, wxFrame)	EVT_SIZE(wxSkinnableFrame::OnSize)	EVT_TIMER(TIMER_REFRESH, wxSkinnableFrame::OnTimerRefresh)END_EVENT_TABLE()using namespace std;//////////////////////////////////////////////////////////////////////////////////// \brief wxSkinnableFrame constructor - just calls base constructor/////////////////////////////////////////////////////////////////////////////////wxSkinnableFrame::wxSkinnableFrame(	wxWindow* parent, 									wxWindowID id, 									const wxString& title, 									const wxPoint& pos, 									const wxSize& size, 									long style, 									const wxString& name)									: wxFrame(parent, id, title, pos, size, style, name){	m_pTimerRefresh = new wxTimer(this, TIMER_REFRESH);}wxSkinnableFrame::~wxSkinnableFrame(){	delete m_pTimerRefresh;}//////////////////////////////////////////////////////////////////////////////////// \brief Given a filename to a skin data file, generate a complete pathname/////////////////////////////////////////////////////////////////////////////////wxString wxSkinnableFrame::GetDataFilename(wxString strName){	wxFileName fn;	fn.AssignDir(m_strSkinPath);	fn.SetFullName(strName);	return fn.GetFullPath();}//////////////////////////////////////////////////////////////////////////////////// \brief Apply generic window attributes/////////////////////////////////////////////////////////////////////////////////bool wxSkinnableFrame::ApplyWindowCommonAttributes(TiXmlElement * root, wxWindow * pWindow){	const char * pszTmp;	int iX = -1;	int iY = -1;	int iW = -1;	int iH = -1;		pszTmp = root->Attribute("style");	if (pszTmp)		pWindow->SetWindowStyle(ParseWindowStyle(wxString(pszTmp, *wxConvCurrent)));		pszTmp = root->Attribute("x");	if (pszTmp)		iX = atoi(pszTmp);		pszTmp = root->Attribute("y");	if (pszTmp)		iY = atoi(pszTmp);		pszTmp = root->Attribute("w");	if (pszTmp)		iW = atoi(pszTmp);		pszTmp = root->Attribute("h");	if (pszTmp)		iH = atoi(pszTmp);		if (iX >= 0 && iY >= 0 && iW >= -1 && iH >= -1)	{		SetSize(iX, iY, iW, iH);	}	return false;}//////////////////////////////////////////////////////////////////////////////////// \brief Load attributes from an XML element that are common to all of the/// controls like its region, foreground/background color, etc./////////////////////////////////////////////////////////////////////////////////bool wxSkinnableFrame::ApplyControlCommonAttributes(TiXmlElement * root, wxSkinnableFrame_LayoutControl * psLayoutControl, wxControl * pControl){	TiXmlElement * element;	TiXmlElement * child;	const char * pszTmp;	element = root->FirstChildElement("region");	if (!element)		return true;	// top left	child = element->FirstChildElement("topleft");	if (!child)		return true;	psLayoutControl->m_coTopLeft.Load(child);	// bottom right	child = element->FirstChildElement("bottomright");	if (!child)		return true;	psLayoutControl->m_coBottomRight.Load(child);	// font	child = root->FirstChildElement("font");	if (child)	{		wxFont fntThis = LoadFont(child);		pControl->SetFont(fntThis);	}	pszTmp = root->Attribute("bgcolor");	if (pszTmp)		pControl->SetBackgroundColour(ParseColor(wxString(pszTmp, *wxConvCurrent)));	pszTmp = root->Attribute("fgcolor");	if (pszTmp)		pControl->SetForegroundColour(ParseColor(wxString(pszTmp, *wxConvCurrent)));	pszTmp = root->Attribute("showminheight");	if (pszTmp)		psLayoutControl->m_iShowMinHeight = atoi(pszTmp);	pszTmp = root->Attribute("showminwidth");	if (pszTmp)		psLayoutControl->m_iShowMinWidth = atoi(pszTmp);	return false;}//////////////////////////////////////////////////////////////////////////////////// \brief Process the control element in layout/////////////////////////////////////////////////////////////////////////////////bool wxSkinnableFrame::LoadSkinLayoutControl(TiXmlElement * root){	const char * pszAttributeName;	wxSkinnableFrame_LayoutControl sLayoutControl;	// name	pszAttributeName = root->Attribute("name");	if (!pszAttributeName)		return true;	// request the derived class create the control now	// so it appears in the proper place in the z-order	CreateNamedControl(wxString(pszAttributeName, *wxConvCurrent));	// assign the control itself to sLayoutControl	sLayoutControl.m_pControl = m_mapUnassignedControls[pszAttributeName];	sLayoutControl.m_eType = wxSkinnableFrame_LayoutControl::ctControl;	sLayoutControl.m_strName = wxString(pszAttributeName, *wxConvCurrent);	if (!sLayoutControl.m_pControl)		return true;	if (ApplyControlCommonAttributes(root, &sLayoutControl, sLayoutControl.m_pControl))		return true;	m_mapUnassignedControls[pszAttributeName] = NULL;	// store in vector	m_vPositionedControls.push_back(sLayoutControl);	return false;}//////////////////////////////////////////////////////////////////////////////////// \brief Process the button element in layout/////////////////////////////////////////////////////////////////////////////////bool wxSkinnableFrame::LoadSkinLayoutButton(TiXmlElement * root){	wxBitmap bmpDefault;	wxBitmap bmpDepressed;	wxBitmap bmpActive;	const char * pszDefaultFilename;	const char * pszDepressedFilename;	const char * pszActiveFilename;	const char * pszAction;	const char * pszActiveKey;	wxBitmapButtonNoBackground * pCtl;	wxSkinnableFrame_LayoutControl sLayoutControl;	int iID;	pszDefaultFilename = root->Attribute("defaultimage");	pszDepressedFilename = root->Attribute("depressedimage");	pszActiveFilename = root->Attribute("activeimage");	pszActiveKey = root->Attribute("activekey");	pszAction = root->Attribute("action");	if (!pszDefaultFilename || !pszDepressedFilename || !pszAction)		return true;	if (!bmpDefault.LoadFile(GetDataFilename(wxString(pszDefaultFilename, *wxConvCurrent)), wxBITMAP_TYPE_ANY))		return true;	if (!bmpDepressed.LoadFile(GetDataFilename(wxString(pszDepressedFilename, *wxConvCurrent)), wxBITMAP_TYPE_ANY))		return true;	if (pszActiveFilename && pszActiveKey)	{		if (!bmpActive.LoadFile(GetDataFilename(wxString(pszActiveFilename, *wxConvCurrent)), wxBITMAP_TYPE_ANY))			return true;	}	iID = MapNameToID(wxString(pszAction, *wxConvCurrent));	if (iID < 0)		return true;		// control itself	pCtl = new wxBitmapButtonNoBackground(this, iID, bmpDefault, wxPoint(0, 0), wxSize(1, 1), 0);	pCtl->SetBitmapSelected(bmpDepressed);		if (pszActiveFilename && pszActiveKey)		pCtl->SetBitmapActive(bmpActive);	sLayoutControl.m_pControl = pCtl;	sLayoutControl.m_eType = wxSkinnableFrame_LayoutControl::ctButton;	sLayoutControl.m_strName = wxString(pszAction, *wxConvCurrent);	if (pszActiveFilename && pszActiveKey)		sLayoutControl.m_strActiveKey = wxString(pszActiveKey, *wxConvCurrent);	if (ApplyControlCommonAttributes(root, &sLayoutControl, sLayoutControl.m_pControl))	{		delete pCtl;		return true;	}	// store in vector	m_vPositionedControls.push_back(sLayoutControl);	return false;}//////////////////////////////////////////////////////////////////////////////////// \brief Process the button element in layout/////////////////////////////////////////////////////////////////////////////////bool wxSkinnableFrame::LoadSkinLayoutImage(TiXmlElement * root){	wxBitmap bmpDefault;	wxBitmap bmpDepressed;	const char * pszDefaultFilename;#if defined(__WINDOWS__)	wxBitmapControl * pCtl;#else	wxStaticBitmap * pCtl;#endif	wxSkinnableFrame_LayoutControl sLayoutControl;	pszDefaultFilename = root->Attribute("filename");	if (!pszDefaultFilename)		return true;	if (!bmpDefault.LoadFile(GetDataFilename(wxString(pszDefaultFilename, *wxConvCurrent)), wxBITMAP_TYPE_ANY))		return true;	// control itself#if defined(__WINDOWS__)	pCtl = new wxBitmapControl(this, -1, bmpDefault, wxPoint(0, 0), wxSize(1, 1), 0);	pCtl->Enable(false);#else	pCtl = new wxStaticBitmap(this, -1, bmpDefault, wxPoint(0, 0), wxSize(1, 1), 0);#endif	sLayoutControl.m_pControl = pCtl;	sLayoutControl.m_eType = wxSkinnableFrame_LayoutControl::ctImage;	sLayoutControl.m_strName = wxString(pszDefaultFilename, *wxConvCurrent);	if (ApplyControlCommonAttributes(root, &sLayoutControl, sLayoutControl.m_pControl))	{		delete pCtl;		return true;	}	// store in vector	m_vPositionedControls.push_back(sLayoutControl);	return false;}//////////////////////////////////////////////////////////////////////////////////// \brief Process the text element in layout/////////////////////////////////////////////////////////////////////////////////bool wxSkinnableFrame::LoadSkinLayoutText(TiXmlElement * root){	wxBitmap bmpDefault;	wxBitmap bmpDepressed;	const char * pszName;	const char * pszLabel;	const char * pszPrepend;	const char * pszAppend;	wxStaticTextNoBackground * pCtl;	wxSkinnableFrame_LayoutControl sLayoutControl;	pszName = root->Attribute("name");	pszLabel = root->Attribute("label");	pszPrepend = root->Attribute("prepend");	pszAppend = root->Attribute("append");	if (!pszName)		pszName = "";	if (!pszLabel)		pszLabel = "";		if (!pszPrepend)		pszPrepend = "";	if (!pszAppend)		pszAppend = "";	// control itself	pCtl = new wxStaticTextNoBackground(this, -1, wxT("xxx"), wxPoint(0, 0), wxSize(1, 1), wxALIGN_LEFT | wxST_NO_AUTORESIZE);	sLayoutControl.m_pControl = pCtl;	sLayoutControl.m_eType = wxSkinnableFrame_LayoutControl::ctText;	sLayoutControl.m_strName = wxString(pszName, *wxConvCurrent);	sLayoutControl.m_strPrepend = wxString(pszPrepend, *wxConvCurrent);	sLayoutControl.m_strAppend = wxString(pszAppend, *wxConvCurrent);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -