void StaticShape::Read( TextReader *_in, bool _dynamic )
{
    Building::Read( _in, _dynamic );

    m_scale = atof( _in->GetNextToken() );

    SetShapeName( _in->GetNextToken() );
}
void StaticShape::Initialise( Building *_template )
{
    Building::Initialise( _template );

    StaticShape *staticShape = (StaticShape *) _template;

    m_scale = staticShape->m_scale;
    SetShapeName( staticShape->m_shapeName );
}
void CToolsCtlPanelGraphics::UpdateControls()
{
	CDocWindow* pDocWindow = m_pCtp->GetDocWindow();
	CAGDoc* pAGDoc = (!pDocWindow ? NULL : pDocWindow->GetDoc());

	CAGSym* pSym = m_pCtp->m_pDocWindow->GetSelectedItem();
	if (!pSym)
		return;

	if (pSym->IsGraphic())
	{
		CAGSymGraphic* pGraphicSym = (CAGSymGraphic*)pSym;

		if (pSym->IsRectangle())
			SetShapeName("Rectangle");
		else
		if (pSym->IsEllipse())
			SetShapeName("Circle/Ellipse");
		else
		if (pSym->IsLine())
			SetShapeName("Line");
		else
		if (pSym->IsShape())
		{
			SetShapeName(((CAGSymDrawing*)pSym)->GetShapeName());
		}

		// Update the Fill controls
		SetFillType(pGraphicSym->GetFillType());
		SetFillColor(pGraphicSym->GetFillColor());
		SetFillColor2(pGraphicSym->GetFillColor2());

		// Update the Line control
		SetLineWidth(pGraphicSym->GetLineWidth());
		SetLineColor(pGraphicSym->GetLineColor());

		//UpdateFillCtrls();
		//UpdateLineCtrls();
		ShowHideColors();
	}
}
BOOL CGumpEditorDoc::OnNewDocument()
{
	if (!CDialogEditorDemoDoc::OnNewDocument())
		return FALSE;

	// TODO: add reinitialization code here
	// (SDI documents will reuse this document)
	SetName("");
	SetAlpha(0);
	SetFade(0,0);
	SetEventHandler("","","","","");
	SetShapeName("");
	
	m_objs.Clear();
	m_objs.SetVirtualSize(CSize(m_iDefWidth,m_iDefHeight));

	return TRUE;
}
void CGumpEditorDoc::OnSettings()
{
	CGumpEditorView* pView = (CGumpEditorView*)FindView(RUNTIME_CLASS(CGumpEditorView));
	if (!pView) return;

	CDEditor& editor = pView->GetDEditor();

	CDialogSettings	dlg;

	dlg.m_width = editor.GetVirtualSize().cx;
	dlg.m_height = editor.GetVirtualSize().cy;
	dlg.m_gridWidth = editor.GetGridSize().cx;
	dlg.m_gridHeight = editor.GetGridSize().cy;
	editor.GetMargins( dlg.m_marginLeft, dlg.m_marginTop, dlg.m_marginRight, dlg.m_marginBottom );
	
	dlg.m_strName = GetName();
	dlg.m_iAlpha = GetAlpha();
	dlg.m_iFlags = GetFlags();
	dlg.m_iFadeAlpha = GetFadeAlpha();
	dlg.m_iFadeTime = GetFadeTime();
	dlg.m_strShapeName = GetShapeName();
	GetEventHandler(dlg.m_strEvClick, dlg.m_strEvClose, dlg.m_strEvMouseUp, dlg.m_strEvMouseDown, dlg.m_strEvKeyPressed);

	if( dlg.DoModal() == IDOK )
	{
		editor.SetGridSize( CSize( dlg.m_gridWidth, dlg.m_gridHeight ) );
		editor.SetVirtualSize( CSize( dlg.m_width, dlg.m_height ) );
		editor.SetMargins( dlg.m_marginLeft, dlg.m_marginTop, dlg.m_marginRight, dlg.m_marginBottom );
		
		SetName(dlg.m_strName);
		SetAlpha(dlg.m_iAlpha);
		SetFlags(dlg.m_iFlags);
		SetFade(dlg.m_iFadeAlpha, dlg.m_iFadeTime);
		SetShapeName(dlg.m_strShapeName);
		SetEventHandler(dlg.m_strEvClick, dlg.m_strEvClose, dlg.m_strEvMouseUp, dlg.m_strEvMouseDown, dlg.m_strEvKeyPressed);
		
		editor.RedrawWindow();
	}
}
BOOL CGumpEditorDoc::OnOpenDocument(LPCTSTR lpszPathName)
{
	XML::Parser parser;
	XML::Node* form=NULL,* document=NULL;
	XML::Node* section = NULL,* value = NULL;
	CSize sizeForm(m_iDefWidth,m_iDefHeight);
	
	try	{
		parser.loadData(lpszPathName);
		document = parser.parseDocument();

		form = document->findNode("form");
		if(!form ) throw;
		form->lookupAttribute("width",  (int&)sizeForm.cx);
		form->lookupAttribute("height", (int&)sizeForm.cy);

		int alpha=0,flags=0;
		std::string shape;

		form->lookupAttribute("alpha", alpha);
		form->lookupAttribute("flags", flags);
		form->lookupAttribute("shape", shape);

		m_objs.Clear();
		m_objs.SetVirtualSize(sizeForm);

		SetAlpha(alpha);
		SetFlags(flags);
		SetShapeName(shape.c_str());
	} catch (...) {
		return FALSE;
	}

	
	int alpha=0,time=0;
	std::string onclick, onclose, onmouseup, onmousedown, onkeypressed;
	
	XML::Node* fade_node = form->findNode("fade");
	if (fade_node) {
		fade_node->lookupAttribute("alpha", alpha);
		fade_node->lookupAttribute("time", time);
	}

	XML::Node* event_node = form->findNode("event");
	if (event_node) {
		event_node->lookupAttribute("onclick", onclick);
		event_node->lookupAttribute("onclose", onclose);
		event_node->lookupAttribute("onmouseup", onmouseup);
		event_node->lookupAttribute("onmousedown", onmousedown);
		event_node->lookupAttribute("onkeypressed", onkeypressed);
	}

	SetFade(alpha, time);
	SetEventHandler(onclick.c_str(), onclose.c_str(), onmouseup.c_str(), onmousedown.c_str(), onkeypressed.c_str());

	int idx=0;
	XML::Node* control = NULL;	

	while (control = form->findNode("control", idx++)) {
		CDiagramEntity* obj = CDiagramControlFactory::CreateFromString(control);
		if (obj) m_objs.Add(obj);
	}
	
	m_objs.SetModified( FALSE );
	
	delete document; document=NULL;

	return TRUE;
}