void CGUIContainer::InitObject(const char * strObjectName, const char * alignment, int x, int y, int width, int height)
{
	CObjectManager *pOm = &CSingleton<CObjectManager>::Instance();
	if (!pOm->IsExist("default_CGUIContainer")) {
		CGUIContainer::StaticInit();
	}
	pOm->CloneObject("default_CGUIContainer", this);
	CGUIBase::InitObject(strObjectName, alignment, x, y, width, height);
	//initialize scrollbars
	string str;

	str = GetName() + ".vscrollbar";
	// Modified 2007.4.10 LiXizhi, alignment type is changed.
	//m_VScroll->InitObject(str.c_str(),"_rt",-m_nSBWidth-m_nBorder,m_nBorder,m_nSBWidth,RectHeight(m_objResource->GetDrawingRects(0)));
	m_VScroll->InitObject(str.c_str(), "_mr", m_nBorder, m_nBorder, m_nSBWidth, m_nBorder);
	m_VScroll->m_parent = this;
	m_VScroll->SetLinkedObject(this);
	// 	m_VScroll->UpdateRects();

	str = GetName() + ".hscrollbar";
	//m_HScroll->InitObject(str.c_str(),"_lb",m_nBorder,-m_nSBWidth-m_nBorder,RectWidth(m_objResource->GetDrawingRects(0)),m_nSBWidth);
	m_HScroll->InitObject(str.c_str(), "_mb", m_nBorder, m_nBorder, m_nBorder + m_nSBWidth, m_nSBWidth);
	m_HScroll->m_parent = this;
	m_HScroll->SetLinkedObject(this);
	// 	m_HScroll->UpdateRects();
	SetSize(width, height);
}
Exemple #2
0
CCardIssuer* CCardIssuer::FromHandle(ISSUERHANDLE hIssuer)
{
	if ( _objmgr.IsExist( (void*) hIssuer ))
		return (CCardIssuer*) hIssuer;

	return NULL;
}
Exemple #3
0
void CGUIListBox::InitObject(const char * strObjectName, const char * alignment, int x, int y, int width, int height)
{
	CObjectManager *pOm = &CSingleton<CObjectManager>::Instance();
	if (!pOm->IsExist("default_CGUIListBox")) {
		CGUIListBox::StaticInit();
	}
	pOm->CloneObject("default_CGUIListBox", this);
	CGUIBase::InitObject(strObjectName, alignment, x, y, width, height);
	//initialize scrollbars
	string str;

	str = GetName() + ".vscrollbar";
	m_VScroll->InitObject(str.c_str(), "_rt", -m_nSBWidth - m_nBorder, m_nBorder, m_nSBWidth, RectHeight(m_objResource->GetDrawingRects(0)));
	m_VScroll->SetParent(this);
	m_VScroll->SetLinkedObject(this);
	m_VScroll->UpdateRects();

	// 	str=GetName()+".hscrollbar";
	// 	m_HScroll->InitObject(str.c_str(),"_lb",m_nBorder,-m_nSBWidth-m_nBorder,RectWidth(m_objResource->GetDrawingRects(0)),m_nSBWidth);
	// 	m_HScroll->m_parent=this;
	// 	m_HScroll->SetLinkedObject(this);
	// 	m_HScroll->UpdateRects();
}
Exemple #4
0
void CGUIListBox::StaticInit()
{
	CObjectManager *pOm = &CSingleton<CObjectManager>::Instance();
	if (!pOm->IsExist("default_CGUIContainer")) {
		CGUIContainer::StaticInit();
	}
	//load the default CGUIBase object and copy all its value to the new button
	CGUIListBox *pListbox = new CGUIListBox();
	pOm->CloneObject("default_CGUIContainer", pListbox);
	//pListbox->m_objType=CGUIBase::Type_GUIListBox|CGUIBase::GUIContainer;
	pListbox->m_bMultiSelect = false;
	pListbox->m_nSelected = -1;
	pListbox->m_bAllowAdvObject = false;
	pListbox->m_bNeedUpdate = true;
	pListbox->m_deltaX = 0;
	pListbox->m_deltaY = 0;
	pListbox->m_SelBkColor = COLOR_ARGB(255, 40, 50, 92);
	pListbox->m_ItemHeight = 0;
	pListbox->m_nBorder = 2;
	pListbox->m_nMargin = 6;
	pListbox->m_bCanHasFocus = true;
	pListbox->m_bDrag = false;
	pListbox->m_nSelStart = 0;
	pListbox->m_bFastRender = true;
	pListbox->m_bWordBreak = false;
	pListbox->m_bScrollable = true;

	CEventBinding* pBinding = (CEventBinding*)pListbox->m_event->GetEventBindingObj();
	pBinding->EnableKeyboard();
	pBinding->EnableMouse();

	//	pBinding->MapEvent(EM_MOUSE_LEFTDOWN,EM_CTRL_CAPTUREMOUSE);
	//	pBinding->MapEvent(EM_MOUSE_LEFTDOWN,EM_LB_ACTIONBEGIN);
	//	pBinding->MapEvent(EM_MOUSE_LEFTUP,EM_CTRL_RELEASEMOUSE);
	//	pBinding->MapEvent(EM_MOUSE_LEFTUP,EM_LB_ACTIONEND);
	//	pBinding->MapEvent(EM_MOUSE_LEFTCLICK,EM_LB_ACTIONEND);
	//	pBinding->MapEvent(EM_MOUSE_LEFTCLICK,EM_CTRL_RELEASEMOUSE);
	//	pBinding->MapEvent(EM_MOUSE_LEFTDBCLICK,EM_CTRL_CHANGE);
	//	pBinding->MapEvent(EM_KEY_RETURN,EM_CTRL_CHANGE);
	pBinding->MapEvent(EM_KEY_HOME, EM_CTRL_HOLDKEY);
	pBinding->MapEvent(EM_KEY_END, EM_CTRL_HOLDKEY);
	pBinding->MapEvent(EM_KEY_PAGE_DOWN, EM_CTRL_HOLDKEY);
	pBinding->MapEvent(EM_KEY_PAGE_UP, EM_CTRL_HOLDKEY);
	pBinding->MapEvent(EM_KEY_LEFT, EM_CTRL_HOLDKEY);
	pBinding->MapEvent(EM_KEY_RIGHT, EM_CTRL_HOLDKEY);
	pBinding->MapEvent(EM_KEY_DOWN, EM_CTRL_HOLDKEY);
	pBinding->MapEvent(EM_KEY_UP, EM_CTRL_HOLDKEY);
	pBinding->MapEvent(EM_KEY_RETURN, EM_CTRL_HOLDKEY);
	pBinding->EnableEvent(EM_MOUSE_DBCLICK);
	pBinding->EnableEvent(EM_MOUSE_CLICK);

	using namespace ParaInfoCenter;
	CICConfigManager *cm = CGlobals::GetICConfigManager();

	string value0, value1;
	int event0, event1, a;
	DWORD b;
	HRESULT hr;
	hr = cm->GetSize("GUI_listbox_control_mapping", &b);
	if (hr == E_INVALIDARG || hr == E_ACCESSDENIED) {
		//error
	}
	else{
		for (a = 0; a < (int)b; a += 2) {
			hr = cm->GetTextValue("GUI_listbox_control_mapping", value0, a);
			if (FAILED(hr)) {
				break;
			}
			hr = cm->GetTextValue("GUI_listbox_control_mapping", value1, a + 1);
			if (FAILED(hr)) {
				break;
			}
			event0 = CEventBinding::StringToEventValue(value0);
			event1 = CEventBinding::StringToEventValue(value1);
			pBinding->MapEvent(event0, event1);
		}
	}
	int tempint;
	if (cm->GetIntValue("GUI_listbox_control_visible", &tempint) == S_OK) {
		if (tempint == 0) {
			pListbox->m_bIsVisible = false;
		}
		else
			pListbox->m_bIsVisible = true;
	}
	if (cm->GetIntValue("GUI_listbox_control_enable", &tempint) == S_OK) {
		if (tempint == 0) {
			pListbox->m_bIsEnabled = false;
		}
		else
			pListbox->m_bIsEnabled = true;
	}
	if (cm->GetIntValue("GUI_listbox_control_canhasfocus", &tempint) == S_OK) {
		if (tempint == 0) {
			pListbox->m_bCanHasFocus = false;
		}
		else
			pListbox->m_bCanHasFocus = true;
	}
	if (cm->GetIntValue("GUI_listbox_control_candrag", &tempint) == S_OK) {
		if (tempint == 0) {
			pListbox->SetCandrag(false);
		}
		else
			pListbox->SetCandrag(true);
	}
	if (cm->GetIntValue("GUI_listbox_control_lifetime", &tempint) == S_OK) {
		pListbox->m_nLifeTimeCountDown = tempint;
	}
	if (cm->GetIntValue("GUI_listbox_control_multiselect", &tempint) == S_OK) {
		if (tempint == 0) {
			pListbox->m_bMultiSelect = false;
		}
		else
			pListbox->m_bMultiSelect = true;
	}
	if (cm->GetIntValue("GUI_listbox_control_fastrender", &tempint) == S_OK) {
		if (tempint == 0) {
			pListbox->m_bFastRender = false;
		}
		else
			pListbox->m_bFastRender = true;
	}
	if (cm->GetIntValue("GUI_listbox_control_wordbreak", &tempint) == S_OK) {
		if (tempint == 0) {
			pListbox->m_bWordBreak = false;
		}
		else
			pListbox->m_bWordBreak = true;
	}
	if (cm->GetIntValue("GUI_listbox_control_margin", &tempint) == S_OK) {
		pListbox->m_nMargin = tempint;
	}
	if (cm->GetIntValue("GUI_listbox_control_borderwidth", &tempint) == S_OK) {
		pListbox->m_nBorder = tempint;
	}
	if (cm->GetIntValue("GUI_listbox_control_itemheight", &tempint) == S_OK) {
		pListbox->m_ItemHeight = tempint;
	}
	if (cm->GetIntValue("GUI_listbox_control_scrollbarwidth", &tempint) == S_OK) {
		pListbox->m_nSBWidth = tempint;
	}
	if (cm->GetIntValue("GUI_listbox_control_scrollable", &tempint) == S_OK) {
		if (tempint == 0) {
			pListbox->m_bScrollable = false;
		}
		else
			pListbox->m_bScrollable = true;
	}


	//Set the default texture and font of the default scrollbar

	pListbox->m_objResource->SetActiveLayer();
	pListbox->m_objResource->SetCurrentState();
	pListbox->m_objResource->SetLayerType(GUILAYER::ONE_ELEMENT);

	RECT *prect = NULL;
	RECT rect;
	SpriteFontEntity* pFont;
	TextureEntity* pTexture = NULL;
	pFont = CGlobals::GetAssetManager()->GetFont("sys");
	GUIFontElement font_;
	GUIFontElement* pFontElement = &font_;
	GUITextureElement tex_;
	GUITextureElement* pElement = &tex_;

	pListbox->m_objResource->Clear();	//clean all resources;

	pFontElement->SetElement(pFont, COLOR_ARGB(255, 16, 16, 16), DT_LEFT | DT_TOP);
	pListbox->m_objResource->AddElement(pFontElement, "text");
	pFontElement->SetElement(pFont, COLOR_ARGB(255, 255, 255, 255), DT_LEFT | DT_TOP);
	pListbox->m_objResource->AddElement(pFontElement, "selected_text");
	string background, filename;
	bool bLoadDefault = true;
	if (cm->GetTextValue("GUI_listbox_control_background", background) == S_OK) {
		prect = ParaEngine::StringHelper::GetImageAndRect(background, filename, &rect);
		pTexture = CGlobals::GetAssetManager()->LoadTexture(filename.c_str(), filename.c_str(), TextureEntity::StaticTexture);
		if (pTexture != NULL) {
			bLoadDefault = false;
		}
	}
	if (bLoadDefault) {
		//Set the default texture and font of the default button
		pTexture = CGlobals::GetAssetManager()->LoadTexture("__Default_GUI", "Texture/dxutcontrols.dds", TextureEntity::StaticTexture);
		prect = &rect;
		SetRect(prect, 13, 123, 241, 160);
	}
	pElement->SetElement(pTexture, prect, COLOR_ARGB(255, 255, 255, 255));

	pListbox->m_objResource->SetCurrentState(GUIResourceState_Normal);
	pListbox->m_objResource->AddElement(pElement, "background");
	pListbox->m_objResource->SetCurrentState(GUIResourceState_Pressed);
	pListbox->m_objResource->AddElement(pElement, "background");
	pListbox->m_objResource->SetCurrentState(GUIResourceState_Highlight);
	pListbox->m_objResource->AddElement(pElement, "background");
	pListbox->m_objResource->SetCurrentState(GUIResourceState_Disabled);
	pListbox->m_objResource->AddElement(pElement, "background");
	pListbox->m_objResource->SetCurrentState();

	bLoadDefault = true;
	if (cm->GetTextValue("GUI_listbox_control_selection", background) == S_OK) {
		prect = StringHelper::GetImageAndRect(background, filename, &rect);
		pTexture = CGlobals::GetAssetManager()->LoadTexture(filename.c_str(), filename.c_str(), TextureEntity::StaticTexture);
		if (pTexture != NULL)
			bLoadDefault = false;
	}
	if (bLoadDefault) {
		//Set the default texture and font of the default button
		pTexture = CGlobals::GetAssetManager()->LoadTexture("__Default_GUI", "Texture/dxutcontrols.dds", TextureEntity::StaticTexture);
		prect = &rect;
		SetRect(prect, 17, 269, 241, 287);
	}
	pElement->SetElement(pTexture, prect, COLOR_ARGB(255, 255, 255, 255));

	pListbox->m_objResource->SetCurrentState(GUIResourceState_Normal);
	pListbox->m_objResource->AddElement(pElement, "selection");
	pListbox->m_objResource->SetCurrentState(GUIResourceState_Pressed);
	pListbox->m_objResource->AddElement(pElement, "selection");
	pListbox->m_objResource->SetCurrentState(GUIResourceState_Highlight);
	pListbox->m_objResource->AddElement(pElement, "selection");
	pListbox->m_objResource->SetCurrentState(GUIResourceState_Disabled);
	pListbox->m_objResource->AddElement(pElement, "selection");
	pListbox->m_objResource->SetCurrentState();


	pOm->SetObject("default_CGUIListBox", pListbox);
	SAFE_RELEASE(pListbox);

}
void CGUIContainer::StaticInit()
{
	CObjectManager *pOm = &CSingleton<CObjectManager>::Instance();
	if (!pOm->IsExist("default_CGUIBase")) {
		CGUIBase::StaticInit();
	}
	//load the default CGUIBase object and copy all its value to the new button
	CGUIContainer *pContainer = new CGUIContainer();
	pContainer->m_bFastRender = true;
	pContainer->m_bScrollable = false;
	pContainer->m_nMargin = DEFAULT_CONTAINER_MARGIN_SIZE;
	pContainer->m_nSBWidth = 16;
	pContainer->m_nBorder = DEFAULT_CONTAINER_BORDER_SIZE;
	pOm->CloneObject("default_CGUIBase", pContainer);
	pContainer->m_bCanCaptureMouse = false;
	// 	pContainer->m_objType=CGUIBase::GUIContainer;
	CEventBinding* pBinding = pContainer->m_event->GetEventBindingObj();
	//pBinding->DisableKeyboard();
	pBinding->EnableKeyboard();
	pBinding->EnableMouse();
	//in button, i define that a click on the button will get the button key focus
	//	pBinding->MapEvent(EM_MOUSE_LEFTDOWN,EM_CTRL_CAPTUREMOUSE);
	//	pBinding->MapEvent(EM_MOUSE_LEFTUP,EM_CTRL_RELEASEMOUSE);

	pBinding->DisableEvent(EM_MOUSE_DBCLICK);
	pBinding->DisableEvent(EM_MOUSE_CLICK);
	//	pBinding->EnableEvent(EM_KEY);
	//	pBinding->EnableEvent(EM_KEY_PAGE_DOWN);
	//	pBinding->EnableEvent(EM_KEY_PAGE_UP);
	//	pContainer->m_event->SetEventBinding(pBinding);


	if (!pOm->IsExist("default_CGUIScrollbar")) {
		CGUIScrollBar::StaticInit();
	}

	pContainer->m_VScroll = (CGUIScrollBar*)pOm->CloneObject("default_CGUIScrollbar");
	pContainer->m_VScroll->SetName("vscrollbar");
	pContainer->m_HScroll = (CGUIScrollBar*)pOm->CloneObject("default_CGUIScrollbar");
	pContainer->m_HScroll->SetName("hscrollbar");

	// TODO: 2006.8.LXZ: when GUI object is reference counted, the default container should reference the default scroll bar, so that when 
	// the style of default scroll bar is changed, so does the container scroll bar. Right now, we clone the scroll bar. 
	//pContainer->m_VScroll = (CGUIScrollBar*)pOm->GetObject("default_CGUIScrollbar");
	//pContainer->m_HScroll = (CGUIScrollBar*)pContainer->m_VScroll;

	//TODO: we could add default texture or text here, load from config
	using namespace ParaInfoCenter;
	CICConfigManager *cm = CGlobals::GetICConfigManager();
	string value0, value1;
	int event0, event1, a;
	DWORD b;
	HRESULT hr;
	hr = cm->GetSize("GUI_container_control_mapping", &b);
	if (hr == E_INVALIDARG || hr == E_ACCESSDENIED) {
		//error
	}
	else{
		for (a = 0; a < (int)b; a += 2) {
			hr = cm->GetTextValue("GUI_container_control_mapping", value0, a);
			if (FAILED(hr)) {
				break;
			}
			hr = cm->GetTextValue("GUI_container_control_mapping", value1, a + 1);
			if (FAILED(hr)) {
				break;
			}
			event0 = CEventBinding::StringToEventValue(value0);
			event1 = CEventBinding::StringToEventValue(value1);
			pBinding->MapEvent(event0, event1);
		}
	}
	int tempint;;
	if (cm->GetIntValue("GUI_container_control_fastrender", &tempint) == S_OK) {
		if (tempint == 0) {
			pContainer->m_bFastRender = false;
		}
		else
			pContainer->m_bFastRender = true;
	}
	if (cm->GetIntValue("GUI_container_control_canhasfocus", &tempint) == S_OK) {
		if (tempint == 0) {
			pContainer->m_bCanHasFocus = false;
		}
		else
			pContainer->m_bCanHasFocus = true;
	}
	if (cm->GetIntValue("GUI_container_control_visible", &tempint) == S_OK) {
		if (tempint == 0) {
			pContainer->m_bIsVisible = false;
		}
		else
			pContainer->m_bIsVisible = true;
	}
	if (cm->GetIntValue("GUI_container_control_enable", &tempint) == S_OK) {
		if (tempint == 0) {
			pContainer->m_bIsEnabled = false;
		}
		else
			pContainer->m_bIsEnabled = true;
	}
	if (cm->GetIntValue("GUI_container_control_candrag", &tempint) == S_OK) {
		if (tempint == 0) {
			pContainer->SetCandrag(false);
		}
		else
			pContainer->SetCandrag(true);
	}
	if (cm->GetIntValue("GUI_container_control_scrollable", &tempint) == S_OK) {
		if (tempint == 0) {
			pContainer->m_bScrollable = false;
		}
		else
			pContainer->m_bScrollable = true;
	}
	if (cm->GetIntValue("GUI_container_control_lifetime", &tempint) == S_OK) {
		pContainer->m_nLifeTimeCountDown = tempint;
	}
	if (cm->GetIntValue("GUI_container_control_scrollbarwidth", &tempint) == S_OK) {
		pContainer->m_nSBWidth = tempint;
	}
	if (cm->GetIntValue("GUI_container_control_margin", &tempint) == S_OK) {
		pContainer->m_nMargin = tempint;
	}
	if (cm->GetIntValue("GUI_container_control_borderwidth", &tempint) == S_OK) {
		pContainer->m_nBorder = tempint;
	}



	//Set the default texture and font of the default button
	pContainer->m_objResource->SetActiveLayer();
	pContainer->m_objResource->SetCurrentState();
	pContainer->m_objResource->SetLayerType(GUILAYER::ONE_ELEMENT);
	RECT *prect = NULL;
	RECT rect;
	SpriteFontEntity* pFont;
	TextureEntity* pTexture = NULL;
	pFont = CGlobals::GetAssetManager()->GetFont("sys");
	GUIFontElement font_;
	GUIFontElement* pFontElement = &font_;
	GUITextureElement tex_;
	GUITextureElement* pElement = &tex_;
	pFontElement->SetElement(pFont, COLOR_ARGB(255, 0, 0, 0), DT_LEFT | DT_TOP | DT_WORDBREAK);
	pContainer->m_objResource->AddElement(pFontElement, "text");
	string background, filename;
	bool bLoadDefault = true;
	if (cm->GetTextValue("GUI_container_control_background", background) == S_OK) {
		prect = ParaEngine::StringHelper::GetImageAndRect(background, filename, &rect);
		pTexture = CGlobals::GetAssetManager()->LoadTexture(filename.c_str(), filename.c_str(), TextureEntity::StaticTexture);
		if (pTexture != NULL)
			bLoadDefault = false;
	}
	if (bLoadDefault) {
		//Set the default texture and font of the default button
		pTexture = CGlobals::GetAssetManager()->LoadTexture("__Default_GUI", "Texture/dxutcontrols.dds", TextureEntity::StaticTexture);
		prect = &rect;
		SetRect(prect, 13, 124, 241, 265);
	}
	pElement->SetElement(pTexture, prect, COLOR_ARGB(255, 255, 255, 255));
	pContainer->m_objResource->SetCurrentState(GUIResourceState_Normal);
	pContainer->m_objResource->AddElement(pElement, "background");
	pContainer->m_objResource->SetCurrentState(GUIResourceState_Pressed);
	pContainer->m_objResource->AddElement(pElement, "background");
	pContainer->m_objResource->SetCurrentState(GUIResourceState_Highlight);
	pContainer->m_objResource->AddElement(pElement, "background");
	pContainer->m_objResource->SetCurrentState(GUIResourceState_Disabled);
	pContainer->m_objResource->AddElement(pElement, "background");
	pContainer->m_objResource->SetCurrentState();
	pContainer->m_objResource->SetActiveLayer();

	pOm->SetObject("default_CGUIContainer", pContainer);
	SAFE_RELEASE(pContainer);
}