BOOL COXChildFrameState::OpenDocument(CDocTemplate* pDocTemplate, LPCTSTR pszDocPath, 
	CDocument*& pDoc, CFrameWnd*& pFrameWnd, CView*& pView)
	// --- In  : pDocTemplate : The document template to use
	//			 pszDocPath : The file path of the document to open
	// --- Out : pDoc : The document that is opened
	//			 pFrameWnd : The associated MDI child frame window
	//			 pView : The associated view (the first one)
	// --- Returns : Whether it succeeded or not
	// --- Effect : Uses the specified doc template the open a document with the
	//				spcified file path
	{
	ASSERT(pDocTemplate != NULL);

	// ... Initialize output parameters
	pDoc = NULL;
	pFrameWnd = NULL;
	pView = NULL;

	// ... Check whether the document has already been opened
	pDoc = SearchDocument(pszDocPath);
	if (pDoc != NULL)
		{
		// Document has already been opened, attach a new view to it
		pFrameWnd = pDocTemplate->CreateNewFrame(pDoc, NULL);
		if (pFrameWnd == NULL)
			{
			TRACE0("COXChildFrameState::OpenDocument : Failed to create new frame for existing document.\n");
			pDoc = NULL;
			return FALSE;
			}
		
		// ... Frame is initially visible, this is necessary to send
		//     WM_INITIALUPDATE to the view
		pDocTemplate->InitialUpdateFrame(pFrameWnd, pDoc, TRUE);
		pView = GetFirstView(pFrameWnd);
		ASSERT(pView != NULL);
		}
	else
		{
		// Document has not yet been opened, open it now
		// ... Frame is initially visible, this is necessary to send
		//     WM_INITIALUPDATE to the view
		pDoc = pDocTemplate->OpenDocumentFile(pszDocPath, TRUE);
		if (pDoc == NULL)
			{
			TRACE0("COXChildFrameState::OpenDocument : Failed to open document, failing\n");
			return FALSE;
			}

		pView = GetFirstView(pDoc);
		ASSERT(pView != NULL);
		pFrameWnd = pView->GetParentFrame();
		ASSERT(pFrameWnd != NULL);
		}


	return TRUE;
	}
bool wxJigsawEditorDocument::AppendChildren(wxJigsawShape * dest, 
		wxJigsawShapeGroup * group, size_t beforeIndex)
{
	do
	{
		if(!dest || !group) break;
		if(dest->GetChildren().GetCount() < beforeIndex) break;
		
		wxJigsawShape * shape(NULL);
		wxJigsawShapeList::Node * firstNode = group->GetShapes().GetFirst();
		wxJigsawShapeList::Node * lastNode = group->GetShapes().GetLast();		
		shape = firstNode->GetData();
		if(!shape || !shape->GetHasBump()) break;
		shape = lastNode->GetData();
		if(!shape || !shape->GetHasNotch()) break;

		size_t realIndex(beforeIndex);
		for(wxJigsawShapeList::Node * node = group->GetShapes().GetFirst(); 
			node; node = group->GetShapes().GetFirst(), realIndex++)
		{
			wxJigsawShape * insertShape = node->GetData();
			if(!insertShape) continue;
			group->Detach(insertShape);
			insertShape->SetParent(dest);
			dest->GetChildren().Insert(realIndex, insertShape);
		}
		GetGroups().DeleteObject(group);
		wxJigsawEditorView * view = wxDynamicCast(GetFirstView(), wxJigsawEditorView);
		RequestSizeRecalculation();
		//UpdateLayout(view->GetScale());
		return true;
	}
	while(false);
	return false;
}
Exemplo n.º 3
0
Arquivo: doc.cpp Projeto: EdgarTx/wx
void TextEditDocument::Modify(bool mod)
{
    TextEditView *view = (TextEditView *)GetFirstView();

    wxDocument::Modify(mod);

    if (!mod && view && view->textsw)
        view->textsw->DiscardEdits();
}
Exemplo n.º 4
0
Arquivo: doc.cpp Projeto: EdgarTx/wx
// Since text windows have their own method for saving to/loading from files,
// we override OnSave/OpenDocument instead of Save/LoadObject
bool TextEditDocument::OnSaveDocument(const wxString& filename)
{
    TextEditView *view = (TextEditView *)GetFirstView();

    if (!view->textsw->SaveFile(filename))
        return false;
    Modify(false);
    return true;
}
Exemplo n.º 5
0
Arquivo: doc.cpp Projeto: EdgarTx/wx
bool TextEditDocument::IsModified(void) const
{
    TextEditView *view = (TextEditView *)GetFirstView();
    if (view)
    {
        return (wxDocument::IsModified() || view->textsw->IsModified());
    }
    else
        return wxDocument::IsModified();
}
Exemplo n.º 6
0
Arquivo: doc.cpp Projeto: EdgarTx/wx
bool TextEditDocument::OnOpenDocument(const wxString& filename)
{
    TextEditView *view = (TextEditView *)GetFirstView();
    if (!view->textsw->LoadFile(filename))
        return false;

    SetFilename(filename, true);
    Modify(false);
    UpdateAllViews();
    return true;
}
Exemplo n.º 7
0
// Since text windows have their own method for saving to/loading from files,
// we override OnSave/OpenDocument instead of Save/LoadObject
bool TextEditDocument::OnSaveDocument(const wxString& filename)
{
    TextEditView *view = (TextEditView *)GetFirstView();

    if (!view->textsw->SaveFile(filename))
        return false;
    Modify(false);
#ifdef __WXMAC__
    wxFileName fn(filename) ;
    fn.MacSetDefaultTypeAndCreator() ;
#endif
    return true;
}
Exemplo n.º 8
0
// Open the document
bool ctConfigToolDoc::OnOpenDocument(const wxString& filename)
{
    wxBusyCursor cursor;

    bool opened = DoOpen(filename);

    if (opened)
    {
        SetFilename(filename);
        wxGetApp().GetSettings().m_lastFilename = filename;

        ((ctConfigToolView*)GetFirstView())->OnChangeFilename();

        RefreshDependencies();

        // ctConfigToolHint hint(NULL, ctFilenameChanged);
        ctConfigToolHint hint(NULL, ctInitialUpdate);
        UpdateAllViews (NULL, & hint);
    }

    SetDocumentSaved(true); // Necessary or it will pop up the Save As dialog

    return opened;
}
BOOL COXChildFrameState::GetDocView(CFrameWnd* pFrameWnd, CDocument*& pDoc, CView*& pView)
	// --- In  : pFrameWnd : The frame window to use
	// --- Out : pDoc : The document attached to this frame window
	//			 pView : The first view attached to this document
	// --- Returns :
	// --- Effect : 
	{
	// Initialize return values
	pDoc = NULL;
	pView = NULL;

	// Check input parameter
	if (pFrameWnd == NULL)
		return FALSE;

	// First get the view (first pane or active)
	pView = GetFirstView(pFrameWnd);

	// Then get the document
	if (pView != NULL)
		pDoc = pView->GetDocument();

	return ((pView != NULL) && (pDoc != NULL));
	}
Exemplo n.º 10
0
wxTextCtrl* TextEditDocument::GetTextCtrl() const
{
    wxView* view = GetFirstView();
    return view ? wxStaticCast(view, TextEditView)->GetText() : NULL;
}
Exemplo n.º 11
0
bool TextEditDocument::DoOpenDocument(const wxString& filename)
{
    TextEditView *view = (TextEditView *)GetFirstView();
    return view->textsw->LoadFile(filename);
}
Exemplo n.º 12
0
bool wxJigsawEditorDocument::ProcessDrop(wxDC & dc, const wxPoint & pos, 
		wxJigsawShapeGroup * group, const wxSize & hotSpotOffset, double scale)
{
	do
	{
		wxJigsawEditorView * view = wxDynamicCast(GetFirstView(), wxJigsawEditorView);
		if(!view) break;
		if(!group) break;
		if(GetGroups().IndexOf(group) < 0) break;
		wxJigsawShape::wxJigsawShapeHitTestInfo info;
		wxJigsawShape * shape = GetShapeFromPoint(dc, pos, info, group, scale);
		if(!shape) break;
		bool isSingleShape = (group->GetShapes().GetCount() == 1);
		bool isParamShape = false;
		if(isSingleShape)
		{
			wxJigsawShapeList::Node * node = group->GetShapes().GetFirst();
			if(node)
			{
				wxJigsawShape * firstShape = node->GetData();
				if(firstShape)
				{
					isParamShape = (firstShape->GetStyle() != wxJigsawShapeStyle::wxJS_TYPE_DEFAULT);
				}
			}
		}
		/// If user dropped the group on the slot
		if(info.GetResult() == wxJigsawShape::wxJS_HITTEST_SLOT)
		{
			if(!info.GetShape()) break;
			// Group should have conly one element to be added to the slot
			if(group->GetShapes().GetCount() != 1) break;
			wxJigsawInputParameters::Node * paramNode = 
				info.GetShape()->GetInputParameters().Item(info.GetInputParameterIndex());
			if(!paramNode) break;
			wxJigsawInputParameter * param = paramNode->GetData();
			if(!param) break;
			wxJigsawShapeList::Node * insertShapeNode = group->GetShapes().Item(0);
			if(!insertShapeNode) break;
			wxJigsawShape * insertShape = insertShapeNode->GetData();
			if(!insertShape) break;
			if((param->GetStyle() != insertShape->GetStyle()) || 
				(insertShape->GetStyle() == wxJigsawShapeStyle::wxJS_TYPE_NONE)) break;
			group->Detach(insertShape);
			insertShape->SetParent(info.GetShape());
			param->SetShape(insertShape);
			GetGroups().DeleteObject(group);
			//info.GetShape()->RequestSizeRecalculation();
			//UpdateLayout(view->GetScale());
			//wxDELETE(group);
		}
		else if(info.GetResult() == wxJigsawShape::wxJS_HITTEST_C_SHAPE_BUMP)
		{
			if(isParamShape) break;
			AppendChildren(info.GetShape(), group, 0);
		}
		else if(info.GetResult() == wxJigsawShape::wxJS_HITTEST_C_SHAPE_NOTCH)
		{
			if(isParamShape) break;
			AppendChildren(info.GetShape(), group, info.GetShape()->GetChildren().GetCount());
		}
		else if(info.GetResult() == wxJigsawShape::wxJS_HITTEST_CHILD_INSERTION_AREA)
		{
			if(isParamShape) break;
			AppendChildren(info.GetShape(), group, info.GetChildIndex());
		}
		else if(info.GetResult() == wxJigsawShape::wxJS_HITTEST_BUMP_DOCKING_AREA)
		{
			if(isParamShape) break;
			wxJigsawShapeGroup * targetGroup = GetShapeGroup(info.GetShape());
			if(!targetGroup) break;
			if(!InsertGroup(targetGroup, group, 
				targetGroup->GetShapes().IndexOf(info.GetShape())+1))
			{
				break;
			}
			//group->GetShapes().Insert(group->GetShapes().IndexOf(info.GetShape()), info.GetShape())
			GetGroups().DeleteObject(group);
		}
		else if(info.GetResult() == wxJigsawShape::wxJS_HITTEST_NOTCH_DOCKING_AREA)
		{
			if(isParamShape) break;
			wxJigsawShapeGroup * targetGroup = GetShapeGroup(info.GetShape());
			if(!targetGroup) break;
			if(!InsertGroup(targetGroup, group, 
				targetGroup->GetShapes().IndexOf(info.GetShape())))
			{
				break;
			}
			//group->GetShapes().Insert(group->GetShapes().IndexOf(info.GetShape()), info.GetShape())
			GetGroups().DeleteObject(group);
		}
		UpdateLayout(dc, view->GetScale());
		UpdateAllViews();
		return true;
	}
	while(false);
	return false;
}
Exemplo n.º 13
0
// Save the document
bool ctConfigToolDoc::OnSaveDocument(const wxString& filename)
{
    wxBusyCursor cursor;

    const wxString strOldPath(GetFilename());

    // Do some backing up first

    // This is the backup filename
    wxString backupFilename(filename);
    backupFilename += wxT(".bak");

    // This is the temporary copy of the backup
    wxString tempFilename(filename);
    tempFilename += wxT(".tmp");
    if (wxFileExists(tempFilename))
        wxRemoveFile(tempFilename);

    bool leaveBackup = true;

    bool saved = DoSave(tempFilename);

    if (saved)
    {
        // Remove the old .bak file
        if (wxFileExists(backupFilename))
        {
            wxRemoveFile(backupFilename);
        }

        // Copy the old file to the .bak

        if (leaveBackup)
        {
            if (wxFileExists(filename))
            {
                if (!wxRenameFile(filename, backupFilename))
                {
                    wxCopyFile(filename, backupFilename);
                    wxRemoveFile(filename);
                }
            }
        }
        else
        {
            if (wxFileExists(filename))
                wxRemoveFile(filename);
        }

        // Finally, copy the temporary file to the proper filename
        if (!wxRenameFile(tempFilename, filename))
        {
            wxCopyFile(tempFilename, filename);
            wxRemoveFile(tempFilename);
        }

        Modify(false);
        ((ctConfigToolView*)GetFirstView())->OnChangeFilename();
        SetDocumentSaved(true);
        SetFilename(filename);
        wxGetApp().GetSettings().m_lastFilename = filename;
    } else
    {
        SetFilename(strOldPath);
    }
    wxGetApp().GetMainFrame()->UpdateFrameTitle();
    return saved;
}
Exemplo n.º 14
0
wxSTD istream& DrawingDocument::LoadObject(wxSTD istream& stream)
{
    wxDocument::LoadObject(stream);

    wxView *pview = GetFirstView();

    Char strcFxPath[MAX_PATH];
	std::string strFxName;
	Uint32 dwFxPosX, dwFxPosY;
	Uint32 dwFxMaxPosX, dwFxMaxPosY;
	Uint32 dwFxCount;
	FX_HANDLE hFx = NULL;
    FX_HANDLE hFxState = NULL;
	Int32 hr;

    IFxParam* pIFxParam;
    std::string strParamName;
    Uint16 wParamCount;
    Uint8* pbParamValue;
	std::string strParamValue;
    Uint32 dwParamSize;

    Bool is10Version = FALSE;
    Bool is11Version = FALSE;
    Bool is12Version = FALSE;
	Bool is13Version = FALSE;
	Bool is14Version = FALSE;

	//ZeroMemory(strcFxPath, MAX_PATH * sizeof(Char));
	memset(strcFxPath, 0, MAX_PATH * sizeof(Char));

	dwFxMaxPosX = 0;
	dwFxMaxPosY = 0;

	stream.read((Char*)strcFxPath,MAX_PATH);
    if(strcmp("FxEngineEditor", strcFxPath) == 0)
        is10Version = TRUE;
    else if(strcmp("FxEngineEditor1.1", strcFxPath) == 0)
        is11Version = TRUE;
    else if(strcmp("FxEngineEditor1.2", strcFxPath) == 0)
        is12Version = TRUE;
	else if(strcmp("FxEngineEditor1.3", strcFxPath) == 0)
        is13Version = TRUE;
	else if(strcmp("FxEngineEditor1.4", strcFxPath) == 0)
        is14Version = TRUE;

	if( !is14Version && !is13Version && !is12Version && !is11Version && !is10Version)
	{
		wxMessageBox(wxT("Invalid FxEngineEditor file !!"), wxT("FxEngineEditor Error"), wxICON_ERROR);
		return stream;
	}

	/* Fx */
	stream.read((Char*)&dwFxCount,sizeof(Uint32));
    Char* strcFx;
    std::string strFxPath;
	for(Uint32 Idx = 0; Idx < dwFxCount; Idx++)
	{
        hFx = NULL;
        hFxState = NULL;

		if(is12Version || is13Version || is14Version)
        {
            Uint16 wFxPathLenght;
            stream.read((Char*)&wFxPathLenght, sizeof(Uint16));
            strcFx = new Char[wFxPathLenght + 1];
			strcFx[0] = '\0';
            stream.read((Char*)strcFx, wFxPathLenght);
            strcFx[wFxPathLenght] = '\0';
            strFxPath = strcFx;
            SAFE_DELETE_ARRAY(strcFx);
        }
        else
        {
            //ZeroMemory(strcFxPath, MAX_PATH * sizeof(Char));
            memset(strcFxPath, 0, MAX_PATH * sizeof(Char));
		    stream.read((Char*)strcFxPath,MAX_PATH);
            strFxPath = strcFxPath;
        }

        /*! get jump to next Fx */
        Uint32 dwJumpFx = 0;
        if(is14Version)
            stream.read((Char*)&dwJumpFx, sizeof(Uint32));

		/*! Verify the file */
		if (access(strFxPath.c_str(), 0) != 0)
		{
            wxString strErr = wxT("Cannot open: ") + s2ws(strFxPath);
			wxMessageBox(strErr, wxT("FxEngineEditor Error"), wxICON_ERROR);
			if(is14Version) {
				stream.seekg(dwJumpFx, ios::cur);
				continue;
			}
			else
				return stream;
		}
        else {
		    hr = FEF_AddFx(_hFxEngine, strFxPath, &hFx);
		    if(FEF_FAILED(hr))
		    {
			    wxString strErr = wxT("Invalid Fx: ") + s2ws(strFxPath);
			    wxMessageBox(strErr, wxT("FxEngineEditor Error"), wxICON_ERROR);
				if(is14Version){
					stream.seekg(dwJumpFx, ios::cur);
					continue;
				}
				else
					return stream;
		    }
            else {
		        hFxState = ((DrawingView*)pview)->canvas->AttachFxObserver(_hFxEngine, hFx);
		        //hr = FEF_AttachFxObserverEx(_hFxEngine, hFx, FxStateProc, (FX_PTR)this, &hFxState);
		        if(hFxState == NULL)
		        {
			        wxMessageBox(wxT("FEF_AttachFxObserverEx failed !!"), wxT("FxEngineEditor Error"), wxICON_ERROR);
			        if(is14Version){
						stream.seekg(dwJumpFx, ios::cur);
						continue;
					}
					else
						return stream;
		        }
            }
        }

        stream.read((Char*)&dwFxPosX, sizeof(Uint32));
		stream.read((Char*)&dwFxPosY, sizeof(Uint32));
		dwFxMaxPosX = (dwFxPosX > dwFxMaxPosX) ? dwFxPosX : dwFxMaxPosX;
		dwFxMaxPosY = (dwFxPosY > dwFxMaxPosY) ? dwFxPosY : dwFxMaxPosY;

		CFx* pFx = NULL;
        if(is12Version || is13Version || is14Version)
        {
            Uint16 wFxNameLenght;
            stream.read((Char*)&wFxNameLenght, sizeof(Uint16));
            Char* strTemp = new Char[wFxNameLenght + 1];
			strTemp[0] = '\0';
            stream.read((Char*)strTemp, wFxNameLenght);
            strTemp[wFxNameLenght] = '\0';
            strFxName = strTemp;
            SAFE_DELETE_ARRAY(strTemp);
			pFx = new CFx(_hFxEngine, hFx, hFxState, strFxPath, dwFxPosX, dwFxPosY, strFxName);
			pFx->InitFxPin();
        }
        else if(is11Version)
        {
            Char strTemp[60];
            stream.read((Char*)strTemp, 60);
            strFxName = strTemp;
			pFx = new CFx(_hFxEngine, hFx, hFxState, strFxPath, dwFxPosX, dwFxPosY, strFxName);
        }
		else
			pFx = new CFx(_hFxEngine, hFx, hFxState, strFxPath, dwFxPosX, dwFxPosY, NULL);

		if(pFx == NULL)
		{
			wxMessageBox(wxT("Internal Fx Error!!"), wxT("FxEngineEditor Error"), wxICON_ERROR);
			return stream;
		}


		_FxMap.insert(std::make_pair(hFx, pFx));

        if(is11Version || is12Version || is13Version || is14Version)
        {
            /*! read fx parameters */
            hr = FEF_QueryFxParamInterface(_hFxEngine, pFx->GethFxHandle(), &pIFxParam);
			if(FEF_FAILED(hr)) {
                wxMessageBox(wxT("Cannot get Fx Parameter Interface"), wxT("FxEngineEditor Error"), wxICON_ERROR);
				return stream;
			}

            pIFxParam->GetFxParamCount(&wParamCount);
            for(int i = 0; i < wParamCount; i++)
            {
                if(is12Version || is13Version || is14Version) {
                    Uint16 wParamNameLenght;
                    stream.read((Char*)&wParamNameLenght, sizeof(Uint16));
                    Char* strTemp = new Char[wParamNameLenght + 1];
					strTemp[0] = '\0';
                    stream.read((Char*)strTemp, wParamNameLenght);
                    strTemp[wParamNameLenght] = '\0';
                    strParamName = strTemp;
                    SAFE_DELETE_ARRAY(strTemp);
                }
                else if(is11Version) {
                    Char strTemp[60];
                    stream.read((Char*)strTemp, 60);
                    strParamName = strTemp;
                }
                stream.read((Char*)&dwParamSize, sizeof(Uint32));
                pbParamValue = new Uint8[dwParamSize];
				memset(pbParamValue, 0, dwParamSize*sizeof(Uint8));
                stream.read((Char*)pbParamValue, dwParamSize);
                pIFxParam->SetFxParamValue(strParamName, (Void*)pbParamValue);
                SAFE_DELETE_ARRAY(pbParamValue);
            }

			/*! Read string parameters */
			if(is13Version || is14Version) {
				pIFxParam->GetFxParamStringCount(&wParamCount);
				for(int i = 0; i < wParamCount; i++)
				{
					Uint16 wParamNameLenght;
                    stream.read((Char*)&wParamNameLenght, sizeof(Uint16));
                    Char* strTemp = new Char[wParamNameLenght + 1];
					strTemp[0] = '\0';
                    stream.read(strTemp, wParamNameLenght);
                    strTemp[wParamNameLenght] = '\0';
                    strParamName = strTemp;
                    SAFE_DELETE_ARRAY(strTemp);

					stream.read((Char*)&dwParamSize, sizeof(Uint32));
					strTemp = new Char[dwParamSize + 1];
					strTemp[0] = '\0';
                    stream.read(strTemp, dwParamSize);
                    strTemp[dwParamSize] = '\0';
					strParamValue = strTemp;
					pIFxParam->SetFxParamValue(strParamName, strParamValue);
					SAFE_DELETE_ARRAY(strTemp);
				}
			}

            pIFxParam->FxReleaseInterface();
            FEF_UpdateFxParam(_hFxEngine, pFx->GethFxHandle(), "", FX_PARAM_ALL);
        }
    }

    /*((DrawingView*)pview)->canvas->Refresh();
    ((DrawingView*)pview)->canvas->Update();*/

    /* Lines */
	Uint32 dwLineCount;
	Uint32 dwPointCount;
	wxPoint Point;
    int sdwPointType;
    FX_MEDIA_TYPE MediaType;
    MediaType.MainMediaType = MAIN_TYPE_UNDEFINED;
    MediaType.SubMediaType = SUB_TYPE_UNDEFINED;
	stream.read((Char*)&dwLineCount, sizeof(Uint32));
	for(Uint32 IdxLine = 0; IdxLine < dwLineCount; IdxLine++)
	{
        if(is11Version || is12Version || is13Version || is14Version)
        {
            stream.read((Char*)&MediaType.MainMediaType, sizeof(FX_MAIN_MEDIA_TYPE));
            stream.read((Char*)&MediaType.SubMediaType, sizeof(FX_SUB_MEDIA_TYPE));
        }

        CNode* ppNode[6];
		memset(ppNode, NULL, 6*sizeof(CNode*));
		stream.read((Char*)&dwPointCount, sizeof(Uint32));
		for(Uint32 IdxPoint = 0; IdxPoint < dwPointCount; IdxPoint++)
		{
			stream.read((Char*)&Point.x, sizeof(Uint32));
			stream.read((Char*)&Point.y, sizeof(Uint32));
            CNode* pNode = NULL;
            if(is14Version) {
                stream.read((Char*)&sdwPointType, sizeof(int));
			    pNode = new CNode(Point, (NODE_TYPE)sdwPointType);
            }
            else 
                pNode = new CNode(Point);
			if(IdxPoint == 0)
			{
                ppNode[IdxPoint] = pNode;
				//pNode->SetFirst();
				//pFxLine->AddPoint(pNode, TRUE);
				//CNodeManager::Instance()->Link(pNode);
			}
			else if(IdxPoint == (dwPointCount-1))
			{
				if(!is14Version)
					ppNode[5] = pNode;
				else
					ppNode[IdxPoint] = pNode;
            //pNode->SetEnd();
				//pFxLine->AddPoint(pNode, TRUE);
				//CNodeManager::Instance()->Link(pNode);
			}
			else if(is14Version)
			{
				ppNode[IdxPoint] = pNode;
				//pFxLine->AddConnectionPoint(pNode);
				//CNodeManager::Instance()->Link(pNode, FALSE);
			}
         else
				SAFE_DELETE_OBJECT(pNode);
		}
		CFxLine* pFxLine = new CFxLine(ppNode, 6);

		if(is14Version)
			pFxLine->UpdateAdjustedPoints(NULL); //!< set adjusted points

		_FxLineList.push_back(pFxLine);
		//pFxLine->Update();

        if(is11Version || is12Version || is13Version || is14Version)
        {
            pFxLine->SetMediaTypeConnection(MediaType);
            /*if( (MediaType.MainMediaType == MAIN_TYPE_UNDEFINED) &&
                (MediaType.SubMediaType == SUB_TYPE_UNDEFINED) )
		        Connect(pFxLine, NULL);
            else
                Connect(pFxLine, &MediaType);*/
        }
	}

    wxString strTilte = GetTitle();
    ((DrawingView*)pview)->_frame->SetTitle(strTilte);

    ((DrawingView*)pview)->canvas->TryConnection();
  /*((DrawingView*)pview)->canvas->ClearBackground();*/
  ((DrawingView*)pview)->canvas->Refresh();
  ((DrawingView*)pview)->canvas->Update();

  return stream;
}
Exemplo n.º 15
0
wxSTD ostream& DrawingDocument::SaveObject(wxSTD ostream& stream)
{
    wxDocument::SaveObject(stream);

    Int32 hr;

    Char str[MAX_PATH];
	Uint32 dwFxPosX, dwFxPosY;
	Uint32 dwFxCount;
	Uint32 dwLineCount;

	memset(str, 0, MAX_PATH * sizeof(Char));
	sprintf(str, "FxEngineEditor1.4");

	stream.write(str,MAX_PATH);

	/* Fx */
	dwFxCount = _FxMap.size();
	stream.write((Char*)&dwFxCount, sizeof(Uint32));
	FxMap::iterator Itmap;
    IFxParam* pIFxParam;
    const FX_PARAM* pFxParam;
	const FX_PARAM_STRING* pFxstrParam;
    Uint32 dwParamSize;

    Uint16 wParamCount;
    Uint8* pbParamValue;
    std::string strParamValue;
	for ( Itmap = _FxMap.begin( ); Itmap != _FxMap.end( ); Itmap++ )
	{
		CFx* pFx = Itmap->second;
        /*! write fx parameters */
        hr = FEF_QueryFxParamInterface(_hFxEngine, pFx->GethFxHandle(), &pIFxParam);
        if(FEF_FAILED(hr))
            continue;

		/*! 1.2, write fx path name lenght */
        Uint16 wFxPathLenght = pFx->GetstrFxPath().size();
		stream.write((Char*)&wFxPathLenght, sizeof(Uint16));
		stream.write((Char*)pFx->GetstrFxPath().c_str(), wFxPathLenght);

        /*! 1.4, Get jump to the next Fx */
        Uint32 dwJumpSize = 0;
        dwJumpSize += sizeof(Uint32) + sizeof(Uint32);
        dwJumpSize += sizeof(Uint16) + pFx->GetFxName().size();
        pIFxParam->GetFxParamCount(&wParamCount);
        for(int i = 0; i < wParamCount; i++)
        {
            pIFxParam->GetFxParam(&pFxParam, i);
            dwJumpSize += sizeof(Uint16);
            dwJumpSize += pFxParam->strParamName.size();
            dwJumpSize += sizeof(Uint32);
            dwJumpSize += pFxParam->dwParamNumber * g_ParamSize[pFxParam->ParamType];
        }
		/*! string parameter */
		pIFxParam->GetFxParamStringCount(&wParamCount);
        for(int i = 0; i < wParamCount; i++)
        {
            pIFxParam->GetFxParam(&pFxstrParam, i);
            dwJumpSize += sizeof(Uint16);
			dwJumpSize += pFxstrParam->strParamName.size();
            pIFxParam->GetFxParamValue(pFxstrParam->strParamName, strParamValue);
			dwJumpSize += sizeof(Uint32);
			dwJumpSize += strParamValue.size();
        }
        stream.write((Char*)&dwJumpSize, sizeof(Uint32));

		dwFxPosX = pFx->GetFxPosX();
		stream.write((Char*)&dwFxPosX, sizeof(Uint32));
		dwFxPosY = pFx->GetFxPosY();
		stream.write((Char*)&dwFxPosY, sizeof(Uint32));

        /*! 1.2, write fx name lenght */
        Uint16 wFxNameLenght = pFx->GetFxName().size();
        stream.write((Char*)&wFxNameLenght, sizeof(Uint16));
        stream.write((Char*)pFx->GetFxName().c_str(), wFxNameLenght);

        pIFxParam->GetFxParamCount(&wParamCount);
        for(int i = 0; i < wParamCount; i++)
        {
            pIFxParam->GetFxParam(&pFxParam, i);
            /*! 1.2, write param name lenght */
            Uint16 wParamNameLenght = pFxParam->strParamName.size();
            stream.write((Char*)&wParamNameLenght, sizeof(Uint16));
            stream.write((Char*)pFxParam->strParamName.c_str(), wParamNameLenght);
            dwParamSize = pFxParam->dwParamNumber * g_ParamSize[pFxParam->ParamType];
            stream.write((Char*)&dwParamSize, sizeof(Uint32));
            pbParamValue = new Uint8[dwParamSize];
            pIFxParam->GetFxParamValue(pFxParam->strParamName, (Void*)pbParamValue);
            stream.write((Char*)pbParamValue, dwParamSize);
            SAFE_DELETE_ARRAY(pbParamValue);
        }
		/*! write string parameter */
		pIFxParam->GetFxParamStringCount(&wParamCount);
        for(int i = 0; i < wParamCount; i++)
        {
            pIFxParam->GetFxParam(&pFxstrParam, i);
			Uint16 wParamNameLenght = pFxstrParam->strParamName.size();
            stream.write((Char*)&wParamNameLenght, sizeof(Uint16));
            stream.write(pFxstrParam->strParamName.c_str(), wParamNameLenght);
            pIFxParam->GetFxParamValue(pFxstrParam->strParamName, strParamValue);
			Uint32 wLenght = strParamValue.size();
			stream.write((Char*)&wLenght, sizeof(Uint32));
			stream.write(strParamValue.c_str(), wLenght);
        }

        pIFxParam->FxReleaseInterface();
	}

	/* Lines */
	dwLineCount = _FxLineList.size();
	stream.write((Char*)&dwLineCount, sizeof(Uint32));
	lFxLineIter Itlist;
    FX_MEDIA_TYPE MediaType;
	Uint32 dwPointCount;
	for (Itlist = _FxLineList.begin(); (Itlist != _FxLineList.end()) && !(_FxLineList.empty()); Itlist++)
	{
        /*! Save connexion type if it exists */
        IFxPin* pOutIfxPin;
        IFxPin* pInIfxPin;

        (*Itlist)->GetBeginIFxPin(&pOutIfxPin);
        (*Itlist)->GetEndIFxPin(&pInIfxPin);

        if( (pOutIfxPin != NULL) && (pInIfxPin != NULL) )
        {
	        pOutIfxPin->GetConnectionMediaType(&MediaType);
        }
        else
        {
            MediaType.MainMediaType = MAIN_TYPE_UNDEFINED;
            MediaType.SubMediaType = SUB_TYPE_UNDEFINED;
        }
        stream.write((Char*)&MediaType.MainMediaType, sizeof(FX_MAIN_MEDIA_TYPE));
        stream.write((Char*)&MediaType.SubMediaType, sizeof(FX_SUB_MEDIA_TYPE));

		dwPointCount = (*Itlist)->GetPointCount();
		stream.write((Char*)&dwPointCount, sizeof(Uint32));
		(*Itlist)->SavePoints(stream);
	}

    wxString strTilte = GetTitle();
    wxView *pview = GetFirstView();
    ((DrawingView*)pview)->_frame->SetTitle(strTilte);

    return stream;
}