示例#1
0
void CTypeDialog::setPredefToDocument ()
{
	CGeorgesEditDoc *doc = View->GetDocument ();
	if (doc)
	{
		CGeorgesEditDocSub *current = doc->getSelectedObject ();
		CString str;

		// Add the predef
		vector<vector<string> > stringVector;
		stringVector.resize (Predef.ListCtrl.GetItemCount());
		uint predef;
		for (predef=0; predef<(uint)Predef.ListCtrl.GetItemCount(); predef++)
		{
			stringVector[predef].resize (2);

			// Add the label and value
			str = Predef.ListCtrl.GetItemText (predef, 0);
			stringVector[predef][0] = (const char*)str;
			str = Predef.ListCtrl.GetItemText (predef, 1);
			stringVector[predef][1] = (const char*)str;
		}

		doc->modify (new CActionStringVectorVector (IAction::TypePredef, stringVector, *doc, 
			doc->getLeftView ()->getCurrentSelectionId (), 0));
	}
}
// ---------------------------------------------------------------------------
void CGeorgesImpl::PutText (const std::string& _sText)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
	CMainFrame *pWnd = dynamic_cast< CMainFrame* >( theApp.m_pMainWnd );
	CChildFrame *pChild = (CChildFrame*)pWnd->MDIGetActive ();
	if (pChild == NULL) return;
	// Get active document
	CGeorgesEditDoc *doc = (CGeorgesEditDoc *)pChild->GetActiveDocument();
	if (doc)
	{
		// Get the left view
		CLeftView* pView = doc->getLeftView ();

		// Check type
		CGeorgesEditDocSub *subDoc = doc->getSelectedObject ();
		if (subDoc)
		{
			// Get the node
			const CFormDfn *parentDfn;
			uint indexDfn;
			const CFormDfn *nodeDfn;
			const CType *nodeType;
			CFormElm *node;
			UFormDfn::TEntryType type;
			bool array;
			bool parentVDfnArray;
			CForm *form=doc->getFormPtr ();
			CFormElm *elm = doc->getRootNode (subDoc->getSlot ());
			nlverify ( elm->getNodeByName (subDoc->getFormName ().c_str (), &parentDfn, indexDfn, &nodeDfn, &nodeType, &node, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND) );

			// It is an array ?
			if (array&&(type == UFormDfn::EntryType))
			{
				// Modify the node
				doc->modify (new CActionString (IAction::FormTypeValue, _sText.c_str(), *doc, subDoc->getFormName ().c_str (),  "",
					doc->getLeftView ()->getCurrentSelectionId (), subDoc->getSlot ()));
				doc->modify (new CActionString (IAction::FormArrayRename, _sText.c_str(), *doc, subDoc->getFormName ().c_str (), 
					toString (subDoc->getIdInParent ()).c_str (), doc->getLeftView ()->getCurrentSelectionId (), subDoc->getSlot ()));
				doc->updateDocumentStructure ();
				doc->UpdateAllViews (pView);
			}
			else if ((UFormDfn::EntryDfn)&&(!array))
			{
				// Get the right view
				CGeorgesEditView* view = doc->getRightView ();
				if (view->FormDialog.WidgetFocused != 0xffffffff)
				{
					// Set the string
					doc->modify (new CActionString (IAction::FormValue, _sText.c_str(), *doc, 
						view->FormDialog.Widgets[view->FormDialog.WidgetFocused]->getFormName ().c_str (),  "",
						doc->getLeftView ()->getCurrentSelectionId (), subDoc->getSlot ()));
					doc->updateDocumentStructure ();
					doc->UpdateAllViews (pView);
				}
			}
		}
	}
}
示例#3
0
void CTypeDialog::setTypeToDocument ()
{
	CGeorgesEditDoc *doc = View->GetDocument ();
	if (doc)
	{
		CGeorgesEditDocSub *current = doc->getSelectedObject ();
		
		doc->modify (new CActionString (IAction::TypeType, toString (ComboType.GetCurSel ()).c_str (), *doc, 
			"", "", doc->getLeftView ()->getCurrentSelectionId (), 0));
	}
}
示例#4
0
void CTypeDialog::setIncrementToDocument ()
{
	CGeorgesEditDoc *doc = View->GetDocument ();
	if (doc)
	{
		CGeorgesEditDocSub *current = doc->getSelectedObject ();
		CString str;

		Increment.UpdateData ();
		Increment.GetWindowText (str);

		doc->modify (new CActionString (IAction::TypeIncrement, str, *doc, "", "",
			doc->getLeftView ()->getCurrentSelectionId (), 0));
	}
}
示例#5
0
void CTypeDialog::setUIToDocument ()
{
	CGeorgesEditDoc *doc = View->GetDocument ();
	if (doc)
	{
		CGeorgesEditDocSub *current = doc->getSelectedObject ();
		int curSel = ComboUIType.GetCurSel ();
		if (curSel != CB_ERR)
		{
			curSel = (CType::TUI)ComboUIType.GetItemData (curSel);
		}
		else
		{
			curSel = CType::Edit;
		}

		doc->modify (new CActionString (IAction::TypeUI, toString (curSel).c_str (), *doc, "", "", 
			doc->getLeftView ()->getCurrentSelectionId (), 0));
	}
}
// ---------------------------------------------------------------------------
void CGeorgesImpl::LineDown ()
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
	CMainFrame* pWnd = dynamic_cast< CMainFrame* >( theApp.m_pMainWnd );
	CMDIChildWnd *pChild = pWnd->MDIGetActive ();
	if (pChild == NULL) return;

	// Get active document
	CGeorgesEditDoc *doc = (CGeorgesEditDoc *)pChild->GetActiveDocument ();
	if (doc)
	{
		// Get the left view
		CLeftView* pView = doc->getLeftView ();

		// Check type
		CGeorgesEditDocSub *subDoc = doc->getSelectedObject ();
		if (subDoc)
		{
			// Get the node
			const CFormDfn *parentDfn;
			uint indexDfn;
			const CFormDfn *nodeDfn;
			const CType *nodeType;
			CFormElm *node;
			UFormDfn::TEntryType type;
			bool array;
			bool parentVDfnArray;
			CForm *form=doc->getFormPtr ();
			CFormElm *elm = doc->getRootNode (subDoc->getSlot ());
			nlverify ( elm->getNodeByName (subDoc->getFormName ().c_str (), &parentDfn, indexDfn, &nodeDfn, &nodeType, &node, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND) );

			// Is a type entry ?
			if ( (type == UFormDfn::EntryType) && !array )
			{
				// Select next 
				if ((subDoc->getIdInParent ()+1) < subDoc->getParent ()->getChildrenCount ())
					doc->changeSubSelection (subDoc->getParent ()->getChild (subDoc->getIdInParent ()+1), pView);
			}
		}
	}
}
// ---------------------------------------------------------------------------
void CGeorgesImpl::PutGroupText (const std::vector<std::string>& _vText, bool append)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
	CMainFrame *pWnd = dynamic_cast< CMainFrame* >( theApp.m_pMainWnd );
	CChildFrame *pChild = (CChildFrame*)pWnd->MDIGetActive ();
	if (pChild == NULL) return;
	// Get active document
	CGeorgesEditDoc *doc = (CGeorgesEditDoc *)pChild->GetActiveDocument();
	if (doc)
	{
		// Get the left view
		CLeftView* pView = doc->getLeftView ();

		// Check type
		CGeorgesEditDocSub *subDoc = doc->getSelectedObject ();
		if (subDoc)
		{
			// Get the node
			const CFormDfn *parentDfn;
			uint indexDfn;
			const CFormDfn *nodeDfn;
			const CType *nodeType;
			CFormElm *node;
			UFormDfn::TEntryType type;
			bool array;
			bool parentVDfnArray;
			CForm *form=doc->getFormPtr ();
			CFormElm *elm = doc->getRootNode (subDoc->getSlot ());
			nlverify ( elm->getNodeByName (subDoc->getFormName ().c_str (), &parentDfn, indexDfn, &nodeDfn, &nodeType, &node, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND) );

			// Is a type entry ?
			if ((type == UFormDfn::EntryType) && array)
			{
				std::string formName = subDoc->getFormName ();
				uint slot = subDoc->getSlot ();

				// Current node size
				uint size = 0;
				if (node)
				{
					CFormElmArray *arrayPtr = safe_cast<CFormElmArray*>(node);
					nlverify (arrayPtr->getArraySize (size));
				}

				// Modify the size of the array
				char value[512];
				smprintf (value, 512, "%d", _vText.size () + ((append)?size:0));
				doc->modify (new CActionBuffer (IAction::FormArraySize, NULL, 0, *doc, formName.c_str (), 
					value, doc->getLeftView ()->getCurrentSelectionId (), slot));

				uint i;
				for (i=0; i<_vText.size (); i++)
				{
					uint index =  i + ((append)?size:0);
					std::string formNameAtom = formName + "[" + toString (index) + "]";
					doc->modify (new CActionString (IAction::FormTypeValue, _vText[i].c_str (), *doc, formNameAtom.c_str (),  "",
						doc->getLeftView ()->getCurrentSelectionId (), slot));
					doc->modify (new CActionString (IAction::FormArrayRename, _vText[i].c_str(), *doc, formNameAtom.c_str (), 
						toString (index).c_str (), doc->getLeftView ()->getCurrentSelectionId (), slot));
				}
			}
		}
	}
}