Beispiel #1
0
void CSketcherDoc::Serialize(CArchive& ar)
{
    if (ar.IsStoring()) {
        ar << m_Color                      // Store the current color
           << static_cast<int>(m_Element)  // the current element type as an integer
           << m_PenWidth                   // and the current pen width
           << m_DocSize;                   // and the current document size

        ar << m_ElementList.size();        // Store the number of elements in the list

        // Now store the elements from the list
        for (auto iter =  m_ElementList.begin() ; iter != m_ElementList.end() ; ++iter)
            ar << *iter;                     // Store the element
    } else {
        int elementType(0);                // Stores element type
        ar >> m_Color                      // Retrieve the current color
           >> elementType                  // the current element type as an integer
           >> m_PenWidth                   // and the current pen width
           >> m_DocSize;                   // and the current document size

        m_Element = static_cast<ElementType>(elementType);

        size_t elementCount(0);            // Count of number of elements
        CElement* pElement(nullptr);       // Element pointer
        ar >> elementCount;                // retrieve the element count
        // Now retrieve all the elements and store in the list
        for (size_t i = 0 ; i < elementCount ; ++i) {
            ar >> pElement;
            m_ElementList.push_back(pElement);
        }
    }
}
    intrusive_ptr<const Value> AccumulatorPush::evaluate(
        const intrusive_ptr<Document> &pDocument) const {
        verify(vpOperand.size() == 1);
        intrusive_ptr<const Value> prhs(vpOperand[0]->evaluate(pDocument));

        if (prhs->getType() == Undefined)
            ; /* nothing to add to the array */
        else if (!pCtx->getInRouter())
            vpValue.push_back(prhs);
        else {
            /*
              If we're in the router, we need to take apart the arrays we
              receive and put their elements into the array we are collecting.
              If we didn't, then we'd get an array of arrays, with one array
              from each shard that responds.
             */
            verify(prhs->getType() == Array);
            
            intrusive_ptr<ValueIterator> pvi(prhs->getArray());
            while(pvi->more()) {
                intrusive_ptr<const Value> pElement(pvi->next());
                vpValue.push_back(pElement);
            }
        }

        return Value::getNull();
    }
Beispiel #3
0
SVGElementPtr SVG::getElement(const UTF8String& sElementID)
{
    map<UTF8String, SVGElementPtr>::iterator pos = m_ElementMap.find(sElementID);
    if (pos == m_ElementMap.end()) {
        SVGElementPtr pElement(new SVGElement(m_pRSVG, m_sFilename, sElementID, 
                m_bUnescapeIllustratorIDs));
        m_ElementMap[sElementID] = pElement;
        return pElement;
    } else {
        return pos->second;
    }
}
Beispiel #4
0
void CSketcherView::OnDraw(CDC* pDC)
{
	CSketcherDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	if (!pDoc)
		return;

  CElement* pElement(0);
  for(auto iter = pDoc->begin() ; iter != pDoc->end() ; ++iter)
  {
    pElement = *iter;
    if(pDC->RectVisible(pElement->GetBoundRect())) // If the element is visible
         pElement->Draw(pDC, m_pSelected);         // ...draw it
  }
}
Beispiel #5
0
void CMDIView::OnDraw(CDC* pDC)
{
	CMDIDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	if (!pDoc)
		return;

  // Draw the sketch
  for(auto iter = pDoc->begin() ; iter != pDoc->end() ; ++iter)
  {
    std::shared_ptr<CElement> pElement(*iter);
    if(pDC->RectVisible(pElement->GetEnclosingRect()))                 // Element visible?
      pElement->Draw(pDC);                                             // Yes, draw it.
  }
}
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
bool
XMLConfiguration::parse(const boost::filesystem::path& _configFile)
{
    xmlDocPtr const pDoc = xmlParseFile(_configFile.string().c_str());

    // Check to see if the config file could be parsed.
    if (pDoc == NULL)
    {
        // TODO Thrown an exception or something?  
        return false;
    }

    xmlNodePtr pNode = xmlDocGetRootElement(pDoc);

    if (pNode == NULL)
    {
	    xmlFreeDoc(pDoc);
        return false;
    }

    // Loop through all of the nodes
    while(pNode != NULL)
    {
        // Create a configuration element out of this node
        config_element_ptr_type pElement(new XMLConfigurationElement(*this, NULL, pNode));

        m_config.insert(config_pair_type(pElement->getName(), pElement));

        // Call the callback function passing the new element
        //_function(pElement);

        // Dispatch event if necessary
        dispatchEvent(pElement);

        pNode = pNode->next;
    }

	xmlFreeDoc(pDoc);

    return true;
}
void CTemplateWizardDialog::DocumentComplete(LPDISPATCH pDisp, VARIANT* URL)
{
	UNUSED_ALWAYS(pDisp);
//	ASSERT(V_VT(URL) == VT_BSTR);

	CString str(V_BSTR(URL));

	// Load in the new file...
    HRESULT       hr;
    LPUNKNOWN     pUnkContainedBrowser = NULL;
    LPUNKNOWN     pUnkDispParam = NULL;
    IStream       *pStream = NULL;
    HGLOBAL       hHTMLText;
	CComPtr<IDispatch> pDispDocument;
//	HWND shellWnd;
//	HWND ieWnd;

    // Test for valid pointers.
    if (!m_pBrowserApp || !pDisp)
        goto CleanUp;

    // To test object equality, use COM identity rules: query both 
    // pointers for IUnknown and compare them.
    hr = m_pBrowserApp->QueryInterface(IID_IUnknown, 
        (void**)&pUnkContainedBrowser);
    if (hr)
        goto CleanUp;

    // Query the passed-in IDispatch for IUnknown.
    hr = pDisp->QueryInterface(IID_IUnknown, 
        (void**)&pUnkDispParam);
    if (hr)
        goto CleanUp;

    // If they're unequal, the event is for a subframe and we're not
    // interested.
    if (pUnkContainedBrowser != pUnkDispParam)
        goto CleanUp;

    // As a further check, make sure the URL is "about:blank".
    if (str == "about:blank")
	{
		// The string is about:blank.  This means load the correct page.
		LONG len = (LONG)m_htmlFile.GetLength();
		BYTE* data = m_htmlFile.Detach();
		hHTMLText = GlobalAlloc(GPTR, len + 1);
		if (!hHTMLText)
			goto CleanUp;

		memcpy((CHAR *)hHTMLText, (char*)data, len);
		*(char*)((char*)hHTMLText + len) = 0;

		free(data);

		hr = ::CreateStreamOnHGlobal(hHTMLText, TRUE, &pStream);
		if (hr)
			goto CleanUp;

		// Call the helper function to load the WebOC from the stream.
		//
		hr = LoadWebOCFromStream(m_pBrowserApp, pStream);

		goto CleanUp;
	}
	
/*	// Set the focus to the right window.
	shellWnd = ::FindWindowEx(m_wndBrowser.GetSafeHwnd(), NULL, "Shell DocObject View", NULL);
	ieWnd = ::FindWindowEx(shellWnd, NULL, "Internet Explorer_Server", NULL);
	::SetFocus(ieWnd);
*/
	// Set to the first available input field.
	m_pBrowserApp->get_Document(&pDispDocument);

	if (pDispDocument)
	{
		CComQIPtr<IHTMLDocument2, &IID_IHTMLDocument2> pDocument(pDispDocument);

		// Get all of the HTML elements.
		CComPtr<IHTMLElementCollection> pElements;
		pDocument->get_all(&pElements);

		CComVariant nullVariant;
		CComPtr<IDispatch> pDispFirstElement;

		// Now get the INPUT elements.
		CComPtr<IDispatch> pDispInputElements;
		pElements->tags(CComVariant("INPUT"), &pDispInputElements);
		if (pDispInputElements)
		{
			CComQIPtr<IHTMLElementCollection, &IID_IHTMLElementCollection> pInputElements(pDispInputElements);
			if (pInputElements)
			{
				long count;
				pInputElements->get_length(&count);

				for (int i = 0; i < count; i++)
				{
					// Get the element, if it exists.
					CComPtr<IDispatch> pDispElement;
					pInputElements->item(CComVariant(i), nullVariant, &pDispElement);
					if (!pDispElement)
						continue;

					CComQIPtr<IHTMLElement, &IID_IHTMLElement> pElement(pDispElement);
					if (!pElement)
						continue;		//??

					CComBSTR bstrID;
					pElement->get_id(&bstrID);

					CComQIPtr<IHTMLInputElement, &IID_IHTMLInputElement> pInputElement(pElement);
					if (!pInputElement)
						continue;		//??

					// Get the type.
					CComBSTR bstrType;
					pInputElement->get_type(&bstrType);
					CString strType(bstrType);
					
					CString id(bstrID);
					CString value;
					if (!m_params.Lookup(id, value))
					{
						value = m_code.GetEntry(id);
					}

					if (strType == "text")
					{
						value = g_wwhizTemplateManager->ParseCode(value, NULL, &m_code);
						pInputElement->put_value(CComBSTR(value));

						if (!pDispFirstElement)
							pDispFirstElement = pDispElement;
					}
					else if (strType == "checkbox")
					{
						pInputElement->put_checked(value == "1" ? VARIANT_TRUE : VARIANT_FALSE);
					}
					else if (strType == "radio")
					{
						pInputElement->put_checked(value == "1" ? VARIANT_TRUE : VARIANT_FALSE);
					}
					else if (strType == "file")
					{
						CComQIPtr<IHTMLInputFileElement,
							&IID_IHTMLInputFileElement> pInputFileElement(pElement);
						if (!pInputFileElement)
							continue;		//??

						value = g_wwhizTemplateManager->ParseCode(value, NULL, &m_code);
						pInputFileElement->put_value(CComBSTR(value));

						if (!pDispFirstElement)
							pDispFirstElement = pDispElement;
					}
				}
			}
		}

		// Now get the SELECT elements.
		CComPtr<IDispatch> pDispSelectElements;
		pElements->tags(CComVariant("SELECT"), &pDispSelectElements);
		if (pDispSelectElements)
		{
			CComQIPtr<IHTMLElementCollection, &IID_IHTMLElementCollection> pSelectElements(pDispSelectElements);
			if (pSelectElements)
			{
				long count;
				pSelectElements->get_length(&count);

				for (int i = 0; i < count; i++)
				{
					// Get the element, if it exists.
					CComPtr<IDispatch> pDispElement;
					pSelectElements->item(CComVariant(i), nullVariant, &pDispElement);
					if (!pDispElement)
						continue;

					CComQIPtr<IHTMLElement, &IID_IHTMLElement> pElement(pDispElement);
					if (!pElement)
						continue;		//??

					CComBSTR bstrID;
					pElement->get_id(&bstrID);

					CComQIPtr<IHTMLSelectElement, &IID_IHTMLSelectElement> pSelectElement(pElement);
					if (!pSelectElement)
						continue;		//??

					// Get the type.
					CComBSTR bstrType;
					pSelectElement->get_type(&bstrType);
					CString strType(bstrType);
					
					CString id(bstrID);
					CString value;
					if (!m_params.Lookup(id, value))
					{
						value = m_code.GetEntry(id);
					}

					// This is the only way I can figure out to do this!

					// Match the name.
					long optionCount;
					pSelectElement->get_length(&optionCount);
					int j;
					for (j = 0; j < optionCount; j++)
					{
						// Get the item at the index.
						CComPtr<IDispatch> pDispOptionElement;
						pSelectElement->item(CComVariant(j), nullVariant, &pDispOptionElement);
						if (pDispOptionElement)
						{
							CComQIPtr<IHTMLOptionElement, &IID_IHTMLOptionElement> pOptionElement(pDispOptionElement);

							CComBSTR bstrItem;
							pOptionElement->get_text(&bstrItem);
							CString strItem(bstrItem);
							if (value == strItem)
							{
								pSelectElement->put_selectedIndex(j);
								break;
							}
						}
					}

					if (j == optionCount)
					{
						pSelectElement->put_selectedIndex(0);
					}
				}
			}
		}

		if (pDispFirstElement)
		{
			CComQIPtr<IHTMLControlElement, &IID_IHTMLControlElement> pHtmlElement(pDispFirstElement);
			pHtmlElement->focus();
			CComQIPtr<IHTMLInputTextElement, &IID_IHTMLInputTextElement> pElement(pDispFirstElement);
			if (pElement)
			{
				pElement->select();
			}
		}
	}

CleanUp:
    if (pStream)
        pStream->Release();
    if (pUnkContainedBrowser)
        pUnkContainedBrowser->Release();
    if (pUnkDispParam)
        pUnkDispParam->Release();

	if (!m_asciiFilename.IsEmpty())
	{
		_unlink(m_asciiFilename);
		m_asciiFilename.Empty();
	}
}
void CTemplateWizardDialog::UpdateFromHtml()
{
	CComPtr<IDispatch> pDispDocument;
	m_pBrowserApp->get_Document(&pDispDocument);
	if (!pDispDocument)
		return;

	CComQIPtr<IHTMLDocument2, &IID_IHTMLDocument2> pDocument(pDispDocument);

	CComPtr<IHTMLElementCollection> pElements;
	pDocument->get_all(&pElements);

	CComVariant nullVariant;

	// Now get the INPUT elements.
	CComPtr<IDispatch> pDispInputElements;
	pElements->tags(CComVariant("INPUT"), &pDispInputElements);
	if (pDispInputElements)
	{
		CComQIPtr<IHTMLElementCollection, &IID_IHTMLElementCollection> pInputElements(pDispInputElements);
		if (pInputElements)
		{
			long count;
			pInputElements->get_length(&count);

			for (int i = 0; i < count; i++)
			{
				// Get the element, if it exists.
				CComPtr<IDispatch> pDispElement;
				pInputElements->item(CComVariant(i), nullVariant, &pDispElement);
				if (!pDispElement)
					continue;

				CComQIPtr<IHTMLElement, &IID_IHTMLElement> pElement(pDispElement);
				if (!pElement)
					continue;		//??

				CComBSTR bstrID;
				pElement->get_id(&bstrID);

				CComQIPtr<IHTMLInputElement, &IID_IHTMLInputElement> pInputElement(pDispElement);
				if (!pInputElement)
					continue;		//??

				// Get the type.
				CComBSTR bstrType;
				pInputElement->get_type(&bstrType);
				CString strType(bstrType);

				CString id(bstrID);
				if (strType == "text"  ||  strType == "file")
				{
					CComBSTR bstrValue;
					pInputElement->get_value(&bstrValue);
					CString value(bstrValue);
					value = g_wwhizTemplateManager->ParseCode(value, NULL, &m_code);

					m_params[id] = value;
				}
				else if (strType == "checkbox")
				{
					short variant;
					pInputElement->get_checked(&variant);
					if (variant == VARIANT_FALSE)
						m_params[id] = "0";
					else
						m_params[id] = "1";
				}
				else if (strType == "radio")
				{
					short variant;
					pInputElement->get_checked(&variant);
					if (variant == VARIANT_FALSE)
						m_params[id] = "0";
					else
						m_params[id] = "1";
				}
			}
		}
	}

	// Now get the SELECT elements.
	CComPtr<IDispatch> pDispSelectElements;
	pElements->tags(CComVariant("SELECT"), &pDispSelectElements);
	if (pDispSelectElements)
	{
		CComQIPtr<IHTMLElementCollection, &IID_IHTMLElementCollection> pSelectElements(pDispSelectElements);
		if (pSelectElements)
		{
			long count;
			pSelectElements->get_length(&count);

			for (int i = 0; i < count; i++)
			{
				// Get the element, if it exists.
				CComPtr<IDispatch> pDispElement;
				pSelectElements->item(CComVariant(i), nullVariant, &pDispElement);
				if (!pDispElement)
					continue;

				CComQIPtr<IHTMLElement, &IID_IHTMLElement> pElement(pDispElement);
				if (!pElement)
					continue;		//??

				CComBSTR bstrID;
				pElement->get_id(&bstrID);
				CString id(bstrID);
				if (id.IsEmpty())
					continue;

				CComQIPtr<IHTMLSelectElement, &IID_IHTMLSelectElement> pSelectElement(pElement);
				if (!pSelectElement)
					continue;		//??

				// Get the type.
				CComBSTR bstrType;
				pSelectElement->get_type(&bstrType);
				CString strType(bstrType);
				
				// Get the current selection index.
				long curSel;
				pSelectElement->get_selectedIndex(&curSel);

				// Get the item at the index.
				CComPtr<IDispatch> pDispOptionElement;
				pSelectElement->item(CComVariant(curSel), nullVariant, &pDispOptionElement);
				if (pDispOptionElement)
				{
					CComQIPtr<IHTMLOptionElement, &IID_IHTMLOptionElement> pOptionElement(pDispOptionElement);

					CComBSTR bstrItem;
					pOptionElement->get_text(&bstrItem);
					m_params[id] = bstrItem;
				}
			}
		}
	}
}
bool UpdateManager::CheckForUpdate(string MasterUpdateFile)
{
	MyThread.m_Data.State = ThreadData::CHECKING_FOR_UPDATE;
	MyThread.m_Data.Message = "";

	bool Report( false );

	URLManager* pURLManager = m_pWiiManager->GetURLManager();

	if (pURLManager->m_Initialised)
	{

#define TEST_FROM_FILE (0)
#if (TEST_FROM_FILE==1)
#warning *** DONT FORGET TO CHANGE 'TEST_FROM_FILE' DEFINE FOR RELEASE BUILDS ***
		// TEST CODE - usefull when testing from emulator (from file rather than http site)
		FILE* pFile( WiiFile::FileOpenForRead( WiiFile::GetGamePath() +  "LatestVersion.xml" )  );
		fseek (pFile , 0, SEEK_END);
		uint FileSize( ftell (pFile) );
		rewind(pFile); 
		u8* ptestdata = (u8*) malloc (sizeof(char) * FileSize);
		size_t TestSize = fread (ptestdata,1,FileSize,pFile);
#else
		if ( MasterUpdateFile != "LatestVersion_FAKE")
		{
			m_ReleaseNotes = "";
			m_MessageVersionReport = ""; // setup later in this section
			// Tally online
			pURLManager->GetFromURI( Util_GA::CreateGoogleAnalyticsRequest(MasterUpdateFile) ); // google analytics

			MyThread.m_Data.Message = MasterUpdateFile+ ".xml : tally";

		}
		else
		{	m_ReleaseNotes = "FAKE";  // fake test running
			m_MessageVersionReport = "FAKE"; // fake test running
		}

		// pURLManager->SaveURI("http://wii-bolt-thrower.googlecode.com/hg/LatestVersion.xml",WiiFile::GetGamePath() );
		MemoryInfo* pData(pURLManager->GetFromURI("http://wii-bolt-thrower.googlecode.com/hg/" + MasterUpdateFile + ".xml"));

		MyThread.m_Data.Message = MasterUpdateFile + ".xml : new file updates";

#endif

		TiXmlDocument doc;
#if (TEST_FROM_FILE==1)
		if ( doc.LoadMem( (char*) ptestdata, TestSize ) )
#else
		if ( ( pData!=NULL ) && 
			 ( doc.LoadMem( (char*)pData->GetData(), pData->GetSize() ) ) )   // from file test 
#endif
		{
			//Check version number
			TiXmlHandle docHandle( &doc );
			TiXmlHandle Data( docHandle.FirstChild( "Data" ) );
			if (Data.Element() != NULL)  // check for valid xml root
			{

				//-----------------------------------------------------------------------------------------
				TiXmlElement* Updates =  Data.FirstChild( "Updates" ).FirstChildElement().ToElement();
				for( TiXmlElement* pElement(Updates); pElement!=NULL; pElement=pElement->NextSiblingElement() )
				{
					string Key(pElement->Value());
					if (Key=="AddFile") 
					{		
						if ( (pElement->Attribute("URI")!=0) && (pElement->Attribute("FullDownloadPath")!=0) )
						{
							FileInfo Info( pElement->Attribute("URI"), Util::urlDecode( pElement->Attribute("URI") ) );
							Info.FullDownloadPath = pElement->Attribute("FullDownloadPath");
							Info.OverwriteExistingFile = "YES";
							if ( pElement->Attribute("OverwriteExistingFile") != 0 ) 
								Info.OverwriteExistingFile = pElement->Attribute("OverwriteExistingFile");

							m_ApplicationSpecificUpdatesForDownloadFileInfoContainer.push_back( Info );
						}
					}
				}
				//-----------------------------------------------------------------------------------------
				//string ReleaseNotesText;
				TiXmlElement* Notes =  Data.FirstChild( "ReleaseNotes" ).ToElement();
				if (Notes != NULL) {
					m_ReleaseNotes += Notes->GetText();
				}
				//-----------------------------------------------------------------------------------------
				TiXmlElement* pElem=Data.FirstChild("LatestReleaseAvailable").Element();
				if (pElem != NULL)
				{
					m_LatestReleaseAvailable = pElem->GetText();
					float fLatestReleaseAvailable =  atof(m_LatestReleaseAvailable.c_str());
					if ( fLatestReleaseAvailable > s_fVersion )
					{
						Report = true;
						m_MessageVersionReport += "ver " + m_LatestReleaseAvailable + " now available, visit http://wiibrew.org/wiki/BoltThrower";
					}
					else
					{
						// will be used by the bottom Bar Text in the menu menu
						SetMessageVersionReport( m_pWiiManager->GetText("RunningLatestVersion")  + s_ReleaseVersion + " - " + s_DateOfRelease );
					}
				}
				//-----------------------------------------------------------------------------------------
			}
		}
//	else
//	ExitPrintf(doc.ErrorDesc());
	}

	return Report;
}