static void AddTopology(IXMLDOMDocument* pDoc,IXMLDOMElement* pParent,const TOPOLOGY& t) { HRESULT hr; IXMLDOMElementPtr categories, connection, name, nodes; CreateElement(pDoc,L"ksproperty_topology_categories",&categories); CreateElement(pDoc,L"ksproperty_topology_connections",&connection); CreateElement(pDoc,L"ksproperty_topology_name",&name); CreateElement(pDoc,L"ksproperty_topology_nodes",&nodes); for(size_t n=0;n<t.categories.size();n++) { AddGUID(pDoc,categories,t.categories[n]); } for(size_t n=0;n<t.connection.size();n++) { AddTopologyConnection(pDoc,connection,t.connection[n]); } for(size_t n=0;n<t.name.size();n++) { AddString(pDoc,name,L"name",t.name[n].c_str()); } for(size_t n=0;n<t.nodes.size();n++) { AddGUID(pDoc,nodes,t.nodes[n]); } AppendChild(categories,pParent); AppendChild(connection,pParent); AppendChild(name,pParent); AppendChild(nodes,pParent); }
TEST_F(CustomElementRegistryTest, collectCandidates_shouldOnlyIncludeCandidatesMatchingDescriptor) { CustomElementDescriptor descriptor("hello-world", "hello-world"); // Does not match: namespace is not HTML Element* elementA = CreateElement("hello-world") .inDocument(&document()) .inNamespace("data:text/date,1981-03-10"); // Matches Element* elementB = CreateElement("hello-world").inDocument(&document()); // Does not match: local name is not hello-world Element* elementC = CreateElement("button") .inDocument(&document()) .withIsAttribute("hello-world"); document().documentElement()->appendChild(elementA); elementA->appendChild(elementB); elementA->appendChild(elementC); registry().addCandidate(elementA); registry().addCandidate(elementB); registry().addCandidate(elementC); HeapVector<Member<Element>> elements; collectCandidates(descriptor, &elements); EXPECT_EQ(1u, elements.size()) << "only one candidates should have been found"; EXPECT_EQ(elementB, elements[0]) << "the matching element should have been found"; }
static void AddDevice(IXMLDOMDocument* pDoc,IXMLDOMElement* pParent,const DEVICE& d) { HRESULT hr; IXMLDOMElementPtr bdatopology, topology, pintopology; AddAttribute(pDoc,L"device_path",d.device_path.c_str(),pParent); AddAttribute(pDoc,L"DeviceDesc",d.DeviceDesc.c_str(),pParent); AddAttribute(pDoc,L"Service",d.Service.c_str(),pParent); AddAttribute(pDoc,L"Class",d.Class.c_str(),pParent); AddAttribute(pDoc,L"ClassGUID",d.ClassGUID.c_str(),pParent); AddAttribute(pDoc,L"Driver",d.Driver.c_str(),pParent); AddAttribute(pDoc,L"PhysicalDeviceObjectName",d.PhysicalDeviceObjectName.c_str(),pParent); AddAttribute(pDoc,L"Enumerator_Name",d.Enumerator_Name.c_str(),pParent); AddAttribute(pDoc,L"device_instance_id",d.device_instance_id.c_str(),pParent); CreateElement(pDoc,L"bdatopology",&bdatopology); CreateElement(pDoc,L"topology",&topology); CreateElement(pDoc,L"pintopology",&pintopology); AddBDATopology(pDoc,bdatopology,d.bdatopology); AddTopology(pDoc,topology,d.topology); AddPinTopology(pDoc,pintopology,d.pintopology); AppendChild(bdatopology,pParent); AppendChild(topology,pParent); AppendChild(pintopology,pParent); }
void StreamPipeline::Init(const Song& song) { pipeline_ = gst_pipeline_new("pipeline"); GstElement* uridecodebin = CreateElement("uridecodebin", pipeline_); qLog(Debug) << "Streaming:" << song.url(); g_object_set( G_OBJECT(uridecodebin), "uri", song.url().toString().toUtf8().constData(), NULL); g_signal_connect( G_OBJECT(uridecodebin), "pad-added", G_CALLBACK(NewPadCallback), this); GError* error = NULL; convert_bin_ = gst_parse_bin_from_description(kPipeline, TRUE, &error); gst_bin_add(GST_BIN(pipeline_), convert_bin_); gst_element_set_state(uridecodebin, GST_STATE_PLAYING); app_sink_ = CreateElement("appsink", pipeline_); g_object_set(G_OBJECT(app_sink_), "emit-signals", TRUE, NULL); g_signal_connect( G_OBJECT(app_sink_), "new-buffer", G_CALLBACK(NewBufferCallback), this); qLog(Debug) << "Linking appsink:" << gst_element_link(convert_bin_, app_sink_); gst_bus_set_sync_handler( gst_pipeline_get_bus(GST_PIPELINE(pipeline_)), BusCallbackSync, this); bus_cb_id_ = gst_bus_add_watch( gst_pipeline_get_bus(GST_PIPELINE(pipeline_)), BusCallback, this); }
NS_INTERFACE_MAP_END NS_IMETHODIMP nsXULContextMenuBuilder::OpenContainer(const nsAString& aLabel) { if (!mFragment) { return NS_ERROR_NOT_INITIALIZED; } if (!mCurrentNode) { mCurrentNode = mFragment; } else { nsCOMPtr<nsIContent> menu; nsresult rv = CreateElement(nsGkAtoms::menu, nsnull, getter_AddRefs(menu)); NS_ENSURE_SUCCESS(rv, rv); menu->SetAttr(kNameSpaceID_None, nsGkAtoms::label, aLabel, PR_FALSE); nsCOMPtr<nsIContent> menuPopup; rv = CreateElement(nsGkAtoms::menupopup, nsnull, getter_AddRefs(menuPopup)); NS_ENSURE_SUCCESS(rv, rv); rv = menu->AppendChildTo(menuPopup, PR_FALSE); NS_ENSURE_SUCCESS(rv, rv); rv = mCurrentNode->AppendChildTo(menu, PR_FALSE); NS_ENSURE_SUCCESS(rv, rv); mCurrentNode = menuPopup; } return NS_OK; }
void CBCGPRibbonConstructor::ConstructPanel (CBCGPRibbonPanel& panel, const CBCGPRibbonInfo::XPanel& info) const { panel.SetKeys (info.m_strKeys); panel.SetJustifyColumns (info.m_bJustifyColumns); panel.SetCenterColumnVert (info.m_bCenterColumnVert); ConstructElement (panel.GetLaunchButton (), info.m_btnLaunch); int i = 0; for (i = 0; i < info.m_arElements.GetSize (); i++) { CBCGPBaseRibbonElement* pElement = CreateElement (*(const CBCGPRibbonInfo::XElement*)info.m_arElements[i]); if (pElement != NULL) { ASSERT_VALID (pElement); CBCGPRibbonSeparator* pSeparator = DYNAMIC_DOWNCAST (CBCGPRibbonSeparator, pElement); if (pSeparator) { panel.AddSeparator (); delete pSeparator; } else { panel.Add (pElement); } } } }
void CBCGPRibbonConstructor::ConstructCategory (CBCGPRibbonCategory& category, const CBCGPRibbonInfo::XCategory& info) const { const_cast<CBCGPToolBarImages&>(info.m_SmallImages.m_Image).CopyTo (category.GetSmallImages ()); const_cast<CBCGPToolBarImages&>(info.m_LargeImages.m_Image).CopyTo (category.GetLargeImages ()); category.SetKeys (info.m_strKeys); int i = 0; for (i = 0; i < info.m_arPanels.GetSize (); i++) { const CBCGPRibbonInfo::XPanel& infoPanel = *(const CBCGPRibbonInfo::XPanel*)info.m_arPanels[i]; CBCGPRibbonPanel* pPanel = CreatePanel (category, infoPanel); if (pPanel != NULL) { ASSERT_VALID (pPanel); ConstructPanel (*pPanel, infoPanel); } } for (i = 0; i < info.m_arElements.GetSize (); i++) { CBCGPBaseRibbonElement* pElement = CreateElement (*(const CBCGPRibbonInfo::XElement*)info.m_arElements[i]); if (pElement != NULL) { ASSERT_VALID (pElement); category.AddHidden (pElement); } } category.SetCollapseOrder (info.m_arCollapseOrder); }
TiXmlElement* Base64CreateElement(const string& name,const string& value) { TiXmlElement* e = NULL; if (value != "") { e = CreateElement(name,base64_encode((const unsigned char*)value.c_str(),value.size())); if (e != NULL) e->SetAttribute("encode","base64"); } else { e = CreateElement(name,value); } return e; }
TEST(CustomElementDescriptorTest, matches_customizedBuiltIn_shouldNotMatchAutonomousElement) { CustomElementDescriptor descriptor("a-b", "button"); Element* element = CreateElement("a-b"); EXPECT_FALSE(descriptor.matches(*element)); }
TEST(CustomElementDescriptorTest, matches_autonomous_shouldNotMatchCustomizedBuiltInElement) { CustomElementDescriptor descriptor("a-b", "a-b"); Element* element = CreateElement("futuretag").withIsAttribute("a-b"); EXPECT_FALSE(descriptor.matches(*element)); }
static void CreateInsertEle(ELEMENT **head, LIST_PT *list_pt) { ELEMENT *new_ele; new_ele = CreateElement(list_pt); InsertElement(head, new_ele); }
BOOL CXTPRibbonBuilder::BuildGroupControls(CXTPPropExchange* pPX, CXTPRibbonGroup* pRibbonGroup) { CXTPPropExchangeEnumeratorPtr pEnumerator(pPX->GetEnumerator(_T("ELEMENT"))); POSITION pos = pEnumerator->GetPosition(0); while (pos) { CXTPPropExchangeSection pxControl(pEnumerator->GetNext(pos)); CString strElementName; PX_String(&pxControl, _T("ELEMENT_NAME"), strElementName); CCmdTarget* pElement = CreateElement(strElementName); if (pElement == NULL) continue; CXTPControl* pControl = DYNAMIC_DOWNCAST(CXTPControl, pElement); if (!pControl) { delete pElement; continue; } CXTPPropExchangeSection pxElements(pxControl->GetSection(_T("ELEMENTS"))); BuildControlPopupBar(&pxElements, pControl, RUNTIME_CLASS(CXTPPopupBar)); BuildControl(&pxControl, pControl); pRibbonGroup->Add(pControl, pControl->GetID()); } return TRUE; }
void CSketcherView::OnMouseMove(UINT nFlags, CPoint point) { // Define a Device Context object for the view CClientDC aDC(this); // DC is for this view if((nFlags & MK_LBUTTON) && (this == GetCapture())) { m_SecondPoint = point; // Save the current cursor position if(m_pTempElement) { if(CURVE == GetDocument()->GetElementType()) // Is it a curve? { // We are drawing a curve so add a segment to the existing curve static_cast<CCurve*>(m_pTempElement)->AddSegment(m_SecondPoint); m_pTempElement->Draw(&aDC); // Now draw it return; // We are done } // If we get to here it's not a curve so // redraw the old element so it disappears from the view aDC.SetROP2(R2_NOTXORPEN); // Set the drawing mode m_pTempElement->Draw(&aDC); // Redraw the old element delete m_pTempElement; // Delete the old element m_pTempElement = 0; // Reset the pointer to 0 } // Create a temporary element of the type and color that // is recorded in the document object, and draw it m_pTempElement = CreateElement(); // Create a new element m_pTempElement->Draw(&aDC); // Draw the element } }
TEST_F(CustomElementRegistryTest, disconnectedCallback) { ScriptForbiddenScope doNotRelyOnScript; Element* element = CreateElement("a-a").inDocument(&document()); document().documentElement()->appendChild(element); LogUpgradeBuilder builder; NonThrowableExceptionState shouldNotThrow; { CEReactionsScope reactions; registry().define("a-a", builder, ElementDefinitionOptions(), shouldNotThrow); } LogUpgradeDefinition* definition = static_cast<LogUpgradeDefinition*>(registry().definitionForName("a-a")); definition->clear(); { CEReactionsScope reactions; element->remove(shouldNotThrow); } EXPECT_EQ(LogUpgradeDefinition::DisconnectedCallback, definition->m_logs[0]) << "remove() should invoke disconnectedCallback"; EXPECT_EQ(1u, definition->m_logs.size()) << "remove() should not invoke other callbacks"; }
void CBCGPRibbonConstructor::ConstructCategoryBackstage (CBCGPRibbonBar& bar, const CBCGPRibbonInfo::XCategoryBackstage& info) const { CBCGPRibbonBackstageViewPanel* pPanel = CreateCategoryBackstage (bar, info); ASSERT_VALID (pPanel); CBCGPRibbonCategory* pCategory = bar.GetBackstageCategory (); ASSERT_VALID (pCategory); const_cast<CBCGPToolBarImages&>(info.m_SmallImages.m_Image).CopyTo (pCategory->GetSmallImages ()); int i = 0; for (i = 0; i < info.m_arElements.GetSize (); i++) { if (info.m_arElements[i]->GetElementName ().Compare (CBCGPRibbonInfo::s_szButton_Command) == 0) { CBCGPBaseRibbonElement* pElement = CreateElement (*(const CBCGPRibbonInfo::XElement*)info.m_arElements[i]); if (pElement != NULL) { ASSERT_VALID (pElement); pElement->SetBackstageViewMode (); pPanel->CBCGPRibbonMainPanel::Add (pElement); } } } }
bool SkSVGParser::onStartElementLen(const char name[], size_t len) { if (strncmp(name, "svg", len) == 0) { fInSVG = true; } else if (fInSVG == false) return false; const char* nextColon = strchr(name, ':'); if (nextColon && (size_t)(nextColon - name) < len) return false; SkSVGTypes type = GetType(name, len); // SkASSERT(type >= 0); if (type < 0) { type = SkSVGType_G; // return true; } SkSVGElement* parent = fParents.count() > 0 ? fParents.top() : NULL; SkSVGElement* element = CreateElement(type, parent); bool result = false; if (parent) { element->fParent = parent; result = fParents.top()->onStartElement(element); } else *fChildren.append() = element; if (strncmp(name, "svg", len) != 0) *fParents.append() = element; fCurrElement = element; return result; }
TEST_F(CustomElementRegistryTest, attributeChangedCallback) { ScriptForbiddenScope doNotRelyOnScript; Element* element = CreateElement("a-a").inDocument(&document()); document().documentElement()->appendChild(element); LogUpgradeBuilder builder; NonThrowableExceptionState shouldNotThrow; { CEReactionsScope reactions; registry().define("a-a", builder, ElementDefinitionOptions(), shouldNotThrow); } LogUpgradeDefinition* definition = static_cast<LogUpgradeDefinition*>(registry().definitionForName("a-a")); definition->clear(); { CEReactionsScope reactions; element->setAttribute( QualifiedName(nullAtom, "attr2", HTMLNames::xhtmlNamespaceURI), "v2"); } EXPECT_EQ(LogUpgradeDefinition::AttributeChangedCallback, definition->m_logs[0]) << "Adding an attribute should invoke attributeChangedCallback"; EXPECT_EQ(1u, definition->m_attributeChanged.size()) << "Adding an attribute should invoke attributeChangedCallback"; EXPECT_EQ("attr2", definition->m_attributeChanged[0].name); EXPECT_EQ(nullAtom, definition->m_attributeChanged[0].oldValue); EXPECT_EQ("v2", definition->m_attributeChanged[0].newValue); EXPECT_EQ(1u, definition->m_logs.size()) << "upgrade should not invoke other callbacks"; }
SetHeadPtr ReadSetFromFile(char* relativePath) { FILE* file = fopen(relativePath, "r"); if(file != NULL) { SetHeadPtr newSetHead = CreateEmptySet(); while(!feof(file)) { int value; if(EOF != fscanf_s(file, "%d", &value)) { AddElementToSet(newSetHead, CreateElement(value)); } } fclose(file); return newSetHead; } else { printf("Error occurred while opening file"); return NULL; } }
bool SaveXMLDoc(LPCWSTR file, BDADEVICES& d) { IXMLDOMDocumentPtr Document; IXMLDOMElementPtr root; IXMLDOMElementPtr bda_source; IXMLDOMElementPtr bda_reciever; HRESULT hr; hr = Document.CreateInstance(CLSID_DOMDocument30); if(hr==S_OK) { // these methods should not fail so don't inspect result Document->put_async(VARIANT_FALSE); Document->put_validateOnParse(VARIANT_FALSE); Document->put_resolveExternals(VARIANT_FALSE); CreatePI(Document); CreateElement(Document,L"bdainf",&root); CreateElement(Document,L"kscategory_bda_network_tuner",&bda_source); CreateElement(Document,L"kscategory_bda_receiver_component",&bda_reciever); CreateDeviceList(Document,bda_source,d.bda_source); CreateDeviceList(Document,bda_reciever,d.bda_reciever); AppendChild(bda_source,root); AppendChild(bda_reciever,root); AppendChild(root,Document); hr = Document->save(_variant_t(file)); if(hr==S_OK) { return true; } else { //notify error return false; } } else { //notify error return false; } }
int DicomImageSet::parseFolder(QString folderName) { QStringList fileList = getAllFiles(folderName); HRESULT hr = CoInitialize(NULL); if (!SUCCEEDED(hr)) { return NULL; } hr = S_OK; IXMLDOMDocument *pXMLDom = NULL; IXMLDOMElement *pRoot = NULL; BSTR bstrXML = NULL; VARIANT varFileName; VariantInit(&varFileName); QProgressDialog progress (QString("Parsing all files in %1").arg(folderName), QString("Cancel"), 0, fileList.count()); CHK_HR(CreateAndInitDOM(&pXMLDom)); // Create a processing instruction element. CHK_HR(CreateAndAddPINode(pXMLDom, L"xml", L"version='1.0'")); // Create the root element. CHK_HR(CreateElement(pXMLDom, L"root", &pRoot)); // Create an attribute for the <root> element, with name "created" and value "using dom". CHK_HR(CreateAndAddAttributeNode(pXMLDom, L"path", folderName.toStdWString().c_str(), pRoot)); // Add NEWLINE for identation before </root>. CHK_HR(CreateAndAddTextNode(pXMLDom, L"\n", pRoot)); // add <root> to document CHK_HR(AppendChildToParent(pRoot, pXMLDom)); progress.show(); for (int i=0; i<fileList.count(); ++i) { insertFileItem(pXMLDom, pRoot, folderName, fileList[i]); progress.setValue(i); } CHK_HR(VariantFromString(QDir(folderName).filePath(DATASET_FILE_NAME).toStdWString().c_str(), varFileName)); CHK_HR(pXMLDom->save(varFileName)); CleanUp: SAFE_RELEASE(pRoot); SysFreeString(bstrXML); VariantClear(&varFileName); CoUninitialize(); if (FAILED(hr)) { SAFE_RELEASE(pXMLDom); return 0; } return 1; }
nsresult XULContentSinkImpl::OpenRoot(const PRUnichar** aAttributes, const PRUint32 aAttrLen, nsINodeInfo *aNodeInfo) { NS_ASSERTION(mState == eInProlog, "how'd we get here?"); if (mState != eInProlog) return NS_ERROR_UNEXPECTED; nsresult rv; if (aNodeInfo->Equals(nsGkAtoms::script, kNameSpaceID_XHTML) || aNodeInfo->Equals(nsGkAtoms::script, kNameSpaceID_XUL)) { PR_LOG(gLog, PR_LOG_ERROR, ("xul: script tag not allowed as root content element")); return NS_ERROR_UNEXPECTED; } // Create the element nsXULPrototypeElement* element; rv = CreateElement(aNodeInfo, &element); if (NS_FAILED(rv)) { #ifdef PR_LOGGING if (PR_LOG_TEST(gLog, PR_LOG_ERROR)) { nsAutoString anodeC; aNodeInfo->GetName(anodeC); PR_LOG(gLog, PR_LOG_ERROR, ("xul: unable to create element '%s' at line %d", NS_ConvertUTF16toUTF8(anodeC).get(), -1)); // XXX pass in line number } #endif return rv; } // Set the correct script-type for the element. rv = SetElementScriptType(element, aAttributes, aAttrLen); if (NS_FAILED(rv)) return rv; // Push the element onto the context stack, so that child // containers will hook up to us as their parent. rv = mContextStack.Push(element, mState); if (NS_FAILED(rv)) { element->Release(); return rv; } // Add the attributes rv = AddAttributes(aAttributes, aAttrLen, element); if (NS_FAILED(rv)) return rv; mState = eInDocumentElement; return NS_OK; }
static void AddString(IXMLDOMDocument* pDoc,IXMLDOMElement* pParent,LPCWSTR elementname,LPCWSTR value) { HRESULT hr; IXMLDOMElementPtr name; CreateElement(pDoc,elementname,&name); AddAttribute(pDoc,L"value",value,name); return AppendChild(name,pParent); }
static void AddULong(IXMLDOMDocument* pDoc,IXMLDOMElement* pParent,unsigned long v) { HRESULT hr; IXMLDOMElementPtr value; CreateElement(pDoc,L"value",&value); AddAttribute(pDoc,L"val",_variant_t(v),value); return AppendChild(value,pParent); }
void CBCGPRibbonConstructor::ConstructBaseElement (CBCGPBaseRibbonElement& element, const CBCGPRibbonInfo::XElement& info, BOOL bSubItems) const { element.SetText (info.m_strText); element.SetToolTipText (info.m_strToolTip); element.SetDescription (info.m_strDescription); element.SetKeys (info.m_strKeys, info.m_strMenuKeys); SetID (element, info.m_ID); CBCGPRibbonButton* pButton = DYNAMIC_DOWNCAST (CBCGPRibbonButton, &element); if (pButton != NULL) { const CBCGPRibbonInfo::XElementButton& infoElement = (const CBCGPRibbonInfo::XElementButton&)info; if (pButton->GetIcon (FALSE) == NULL && pButton->GetIcon (TRUE) == NULL) { pButton->SetImageIndex (infoElement.m_nSmallImageIndex, FALSE); pButton->SetImageIndex (infoElement.m_nLargeImageIndex, TRUE); } pButton->SetAlwaysLargeImage (info.m_bIsAlwaysLarge); pButton->SetDefaultCommand (infoElement.m_bIsDefaultCommand); pButton->SetQATType (infoElement.m_QATType); if (bSubItems) { CBCGPRibbonPaletteButton* pButtonPalette = DYNAMIC_DOWNCAST (CBCGPRibbonPaletteButton, pButton); for (int i = 0; i < infoElement.m_arSubItems.GetSize (); i++) { CBCGPBaseRibbonElement* pSubItem = CreateElement (*(const CBCGPRibbonInfo::XElement*)infoElement.m_arSubItems[i]); if (pSubItem == NULL) { continue; } if (pButtonPalette != NULL) { pButtonPalette->AddSubItem (pSubItem, -1, infoElement.m_bIsOnPaletteTop); } else { pButton->AddSubItem (pSubItem); if (pSubItem->GetID() >= AFX_IDM_WINDOW_FIRST && pSubItem->GetID() <= AFX_IDM_WINDOW_LAST) { pButton->m_bIsWindowsMenu = TRUE; } } } } } }
int SetInsertElement (PtSet pset, char pelem) { PtNode NoTmp, NoIns; if (pset == NULL) /* verifica se o conjunto existe - verifies if the set exists */ { Error = NO_SET; return 0; } /* conjunto vazio ou elemento menor do que o primeiro elemento do conjunto */ /* empty set or element "smaller" than the set's first element */ if (pset->Head == NULL || pelem < *pset->Head->PtElem) { /* inserção sem sucesso, porque não é possível criar o elemento */ /* insertion without success due to lack of memory to create the element */ if ((NoTmp = CreateElement (pelem)) == NULL) return 0; /* ligação do elemento à cabeça da lista - linking the element in list's head */ NoTmp->PtNext = pset->Head; pset->Head = NoTmp; if (NoTmp->PtNext != NULL) NoTmp->PtNext->PtPrev = NoTmp; } else { /* procurar se o elemento existe ou a sua posição de inserção caso não exista */ /* search for the element or its insertion position */ if ((NoIns = PosInsert (pset, pelem)) == NULL) return 0; /* inserção sem sucesso, porque o elemento já existe no conjunto */ /* insertion without success because element already exists in the set */ if ((NoTmp = CreateElement (pelem)) == NULL) return 0; /* inserção sem sucesso, porque não é possível criar o elemento */ /* insertion without success due to lack of memory to create the element */ /* inserir à frente de outro nó - insertion in front of another node */ NoTmp->PtNext = NoIns->PtNext; if (NoTmp->PtNext != NULL) NoTmp->PtNext->PtPrev = NoTmp; NoTmp->PtPrev = NoIns; NoIns->PtNext = NoTmp; } pset->Cardinal++; /* incrementa o cardinal do conjunto - cardinal increment */ Error = OK; return 1; /* inserção com sucesso - insertion with success */ }
void CMDIView::OnMouseMove(UINT nFlags, CPoint point) { // Define a Device Context object for the view CClientDC aDC(this); // DC is for this view // Verify the left button is down and mouse messages captured if((nFlags & MK_LBUTTON) && (this == GetCapture())) { m_SecondPoint = point; // Save the current cursor position if(m_pTempElement) { // An element was created previously if(ElementType::CURVE == GetDocument()->GetElementType()) // A curve? { // We are drawing a curve so add a segment to the existing curve std::static_pointer_cast<CCurve>(m_pTempElement)->AddSegment(m_SecondPoint); m_pTempElement->Draw(&aDC); // Now draw it return; // We are done } else { // If we get to here it's not a curve so // redraw the old element so it disappears from the view aDC.SetROP2(R2_NOTXORPEN); // Set the drawing mode m_pTempElement->Draw(&aDC); // Redraw the old element to erase it } } // Create a temporary element of the type and color that // is recorded in the document object, and draw it m_pTempElement.reset(CreateElement()); // Create a new element m_pTempElement->Draw(&aDC); // Draw the element } { CString s; //s.Format(L"X=%d Y=%d", point.x, point.y); s.Format(L"X=%d Y=%d", point.x, point.y); CMainFrame* pFrame = (CMainFrame*)AfxGetApp()->m_pMainWnd; CMDIChildWnd* pActiveChild = pFrame->MDIGetActive(); CStatusBar* pStatus = &pFrame->m_wndStatusBar; //if (pActiveChild && pActiveChild->GetActiveDocument()) // one or more documents open pStatus->SetPaneText(0, s); } }
DiParticleElement* DiEffectManager::CloneElement(DiParticleElement* element) { if (!element) { return 0; } DiParticleElement* clonedTechnique = CreateElement(); element->CopyTo(clonedTechnique); return clonedTechnique; }
void CSketcherView::OnMouseMove(UINT nFlags, CPoint point) { // Define a Device Context object for the view CClientDC aDC(this); // DC is for this view OnPrepareDC(&aDC); // Get origin adjusted aDC.DPtoLP(&point); // convert point to logical coordinates // If we are in move mode, move the selected element and return if(m_MoveMode) { MoveElement(aDC, point); // Move the element return; } if((nFlags & MK_LBUTTON) && (this == GetCapture())) { m_SecondPoint = point; // Save the current cursor position if(m_pTempElement) { if(CURVE == GetDocument()->GetElementType()) // Is it a curve? { // We are drawing a curve so add a segment to the existing curve static_cast<CCurve*>(m_pTempElement)->AddSegment(new CPoint(m_SecondPoint)); m_pTempElement->Draw(&aDC); // Now draw it return; // We are done } // If we get to here it's not a curve so // redraw the old element so it disappears from the view aDC.SetROP2(R2_NOTXORPEN); // Set the drawing mode m_pTempElement->Draw(&aDC); // Redraw the old element delete m_pTempElement; // Delete the old element m_pTempElement = 0; // Reset the pointer to 0 } // Create a temporary element of the type and color that // is recorded in the document object, and draw it m_pTempElement = CreateElement(); // Create a new element m_pTempElement->Draw(&aDC); // Draw the element } else { // We are not creating an element so do highlighting CSketcherDoc* pDoc=GetDocument(); // Get a pointer to the document CElement* pOldSelected(m_pSelected); m_pSelected = pDoc->FindElement(point); // Set selected element if(m_pSelected != pOldSelected) { if(m_pSelected) InvalidateRect(m_pSelected->GetBoundRect(), FALSE); if(pOldSelected) InvalidateRect(pOldSelected->GetBoundRect(), FALSE); pDoc->UpdateAllViews(0); } } }
void Snake::CreateStartingSnake() { //Tworzy wê¿a, jaki zaczyna sê grê. State = SnakeState::GoingUp; RealSnake.push_back(CreateHead(7,2)); for (size_t i = 3; i < 6; i++) { RealSnake.push_back(CreateElement(7,i)); } GrowInSize(); }
static void AddGUID(IXMLDOMDocument* pDoc,IXMLDOMElement* pParent,const GUID& g) { HRESULT hr; IXMLDOMElementPtr guid; std::wstring guidstr; CreateElement(pDoc,L"guid",&guid); guid_to_string(g,guidstr); AddAttribute(pDoc,L"name",guidstr.c_str(),guid); return AppendChild(guid,pParent); }