// // FUNCTION: UpdateProperty() // // PURPOSE: Called by the Ribbon framework when a command property (PKEY) needs to be updated. // // COMMENTS: // // This function is used to initialize the contents and selection of the gallery. // // STDMETHODIMP CLayoutHandler::UpdateProperty(UINT nCmdID, __in REFPROPERTYKEY key, __in_opt const PROPVARIANT* ppropvarCurrentValue, __out PROPVARIANT* ppropvarNewValue) { UNREFERENCED_PARAMETER(nCmdID); HRESULT hr = E_FAIL; if (key == UI_PKEY_ItemsSource) { IUICollection* pCollection; hr = ppropvarCurrentValue->punkVal->QueryInterface(IID_PPV_ARGS(&pCollection)); if (FAILED(hr)) { pCollection->Release(); return hr; } int labelIds[] = {IDS_LAYOUT_1, IDS_LAYOUT_2, IDS_LAYOUT_3}; // Populate the combobox with the three layout options. for (int i=0; i<_countof(labelIds); i++) { // Create a new property set for each item. CPropertySet* pItem; hr = CPropertySet::CreateInstance(&pItem); if (FAILED(hr)) { pCollection->Release(); return hr; } // Load the label from the resource file. WCHAR wszLabel[MAX_RESOURCE_LENGTH]; LoadString(GetModuleHandle(NULL), labelIds[i], wszLabel, MAX_RESOURCE_LENGTH); // Initialize the property set with no image, the label that was just loaded, and no category. pItem->InitializeItemProperties(NULL, wszLabel, UI_COLLECTION_INVALIDINDEX); pCollection->Add(pItem); } pCollection->Release(); hr = S_OK; } else if (key == UI_PKEY_Categories) { // A return value of S_FALSE or E_NOTIMPL will result in a gallery with no categories. // If you return any error other than E_NOTIMPL, the contents of the gallery will not display. hr = S_FALSE; } else if (key == UI_PKEY_SelectedItem) { // Use the first layout as the default selection. hr = UIInitPropertyFromUInt32(UI_PKEY_SelectedItem, 0, ppropvarNewValue); } return hr; }
const std::vector<StringPair>* CDXConfibDBImpl::GetNamedProperties(const char* pszName) const { std::string strName(pszName); std::map<std::string, CPropertySet*>::const_iterator it; it = m_mapNameToPropertySet.find(strName); if (it == m_mapNameToPropertySet.end()) { return NULL; } CPropertySet* pSet = (*it).second; return &pSet->GetProperties(); }
// // FUNCTION: UpdateProperty() // // PURPOSE: Called by the Ribbon framework when a command property (PKEY) needs to be updated. // // COMMENTS: // // This function is used to populate the gallery. // // STDMETHODIMP CNewDocumentHandler::UpdateProperty(UINT nCmdID, __in REFPROPERTYKEY key, __in_opt const PROPVARIANT* ppropvarCurrentValue, __out PROPVARIANT* ppropvarNewValue) { HRESULT hr = S_FALSE; if (key == UI_PKEY_ItemsSource) { objectTypes.clear(); IUICollection* pCollection; hr = ppropvarCurrentValue->punkVal->QueryInterface( IID_PPV_ARGS(&pCollection)); pCollection->Clear(); Array docTypes = getAllConcreteDocumentTypes(); for(int i=0; i<docTypes.size(); i++){ Object doc = docTypes[i].getObject(); objectTypes.push_back(doc); // Create a new property set for each item. CPropertySet* pItem; hr = CPropertySet::CreateInstance(&pItem); string key = doc["label"].getString(); wstring wkey = s2ws(key); // Load the label from the resource file. WCHAR wszLabel[MAX_RESOURCE_LENGTH]; wcscpy_s(wszLabel, MAX_RESOURCE_LENGTH, wkey.c_str()); IUIImage* pImg; MAKEINTRESOURCE(IDR_SMALL_ADD_BITMAP); HRESULT a = CreateUIImageFromBitmapResource(MAKEINTRESOURCE(IDR_SMALL_ADD_BITMAP), &pImg); // Initialize the property set with no image, the label that was just // loaded, and no category. pItem->InitializeItemProperties(pImg, wszLabel, UI_COLLECTION_INVALIDINDEX); pCollection->Add(pItem); } pCollection->Release(); hr = S_OK; } return hr; }
BOOL COleControl::SetPropsetData(LPFORMATETC lpFormatEtc, LPSTGMEDIUM lpStgMedium, REFCLSID fmtid) { UNUSED(lpFormatEtc); // unused in release builds ASSERT_VALID(this); ASSERT(AfxIsValidAddress(lpFormatEtc, sizeof(FORMATETC), FALSE)); ASSERT(AfxIsValidAddress(lpStgMedium, sizeof(STGMEDIUM))); // Get the stream that contains the property set. LPSTORAGE lpStorage = NULL; LPSTREAM lpStream = NULL; switch (lpStgMedium->tymed) { case TYMED_ISTORAGE: { lpStorage = lpStgMedium->pstg; ASSERT_POINTER(lpStorage, IStorage); if (FAILED(lpStorage->OpenStream(OLESTR("Contents"), 0, STGM_SHARE_EXCLUSIVE|STGM_READ, 0, &lpStream))) { TRACE0("Failed to open content stream.\n"); return FALSE; } } break; case TYMED_ISTREAM: lpStorage = NULL; lpStream = lpStgMedium->pstm; break; default: TRACE0("Propset only supported for stream or storage.\n"); return FALSE; } ASSERT_POINTER(lpStream, IStream); // Read the property set from the stream. CPropertySet pset; if (!pset.ReadFromStream(lpStream)) { TRACE0("CPropertySet::ReadFromStream failed.\n"); return FALSE; } CPropertySection* ppsec = pset.GetSection(fmtid); if (ppsec == NULL) { TRACE0("CLSID_PersistPropset section not found in property set.\n"); return FALSE; } // Detect whether we're converting a VBX m_bConvertVBX = (BYTE)IsEqualGUID(fmtid, CLSID_ConvertVBX); // Parse the property set. CPropsetPropExchange propx(*ppsec, lpStorage, TRUE); BOOL bPropExchange = FALSE; TRY { DoPropExchange(&propx); bPropExchange = TRUE; } END_TRY // Properties have probably changed BoundPropertyChanged(DISPID_UNKNOWN); InvalidateControl(); m_bConvertVBX = FALSE; // Clear the modified flag. m_bModified = FALSE; // Unless IOleObject::SetClientSite is called after this, we can // count on ambient properties being available while loading. m_bCountOnAmbients = TRUE; // Properties have been initialized m_bInitialized = TRUE; // Cleanup. if (lpStorage != NULL) // If we called OpenStream(), release now. lpStream->Release(); BoundPropertyChanged(DISPID_UNKNOWN); return bPropExchange; }
MainWindow1::MainWindow1() { view = new CMapControl(); setCentralWidget(view); resize(QSize(200, 200)); CPostgresqlDataSrcFactory factory; CPropertySet info; info.setProperty("HOST", "localhost"); info.setProperty("PORT", "5432"); info.setProperty("DBNAME", "ctest"); info.setProperty("USER", "postgres"); info.setProperty("PASSWORD", "198811"); CDataSrc *pDataSrc = factory.open(info); CDataClass *pDataClass1 = pDataSrc->getDataClass("ptest1"); CDataClass *pDataClass2 = pDataSrc->getDataClass("city3"); CDataClass *pDataClass3 = pDataSrc->getDataClass("china"); delete pDataSrc; CFeatureClass *pFeatClass1 = dynamic_cast<CFeatureClass *> (pDataClass1); CFeatureClass *pFeatClass2 = dynamic_cast<CFeatureClass *> (pDataClass2); CFeatureClass *pFeatClass3 = dynamic_cast<CFeatureClass *> (pDataClass3); /*CLineSymbol *pSymbol1 = new CLineSymbol(); pSymbol1->setColor(Qt::darkRed); CLineSymbol *pSymbol2 = new CLineSymbol(); pSymbol2->setColor(Qt::blue); CSimpleRenderer *pRenderer1 = new CSimpleRenderer(); pRenderer1->setSymbol(pSymbol1); CSimpleRenderer *pRenderer2 = new CSimpleRenderer(); pRenderer2->setSymbol(pSymbol2);*/ CMarkerSymbol *pSymbol3 = new CMarkerSymbol(); //pSymbol3->setMarkerStyle(CMarkerSymbol::MARKER_DIAMOND); pSymbol3->setMarkerStyle(CMarkerSymbol::MARKER_CIRCLE); pSymbol3->setSize(3); pSymbol3->setInColor(Qt::yellow); CFillSymbol *pSymbol1 = new CFillSymbol(); pSymbol1->setColor(Qt::darkBlue); pSymbol1->setStyle(Qt::SolidPattern); CLineSymbol *pSymbol2 = new CLineSymbol(); pSymbol2->setColor(Qt::blue); pSymbol1->setOutline(*pSymbol2); CSimpleRenderer *pRenderer1 = new CSimpleRenderer(); pRenderer1->setSymbol(pSymbol1); /* CFeatureLayer *pFeatLayer1 = new CFeatureLayer(); pFeatLayer1->setFeatureClass(pFeatClass1); pFeatLayer1->setRenderer(pRenderer1); view->map->addLayer(pFeatLayer1); */ /* CFeatureLayer *pFeatLayer2 = new CFeatureLayer(); CSimpleRenderer *pRenderer2 = new CSimpleRenderer(); pRenderer2->setSymbol(pSymbol3); pFeatLayer2->setRenderer(pRenderer2); pFeatLayer2->setFeatureClass(pFeatClass2); pFeatLayer2->labelEngine->setEnable(true); pFeatLayer2->labelEngine->setLabelField("name"); view->map->addLayer(pFeatLayer2); */ CFeatureLayer *pFeatLayer3 = new CFeatureLayer(); pFeatLayer3->setFeatureClass(pFeatClass3); view->map->addLayer(pFeatLayer3); createActions(); createMenus(); /*CFeatureCursor cursor; CQueryFilter *filter = new CQueryFilter(); CFeature *pFeat = new CFeature(pFeatClass1); pFeatClass1->search(filter, cursor); while (cursor.NextFeature(*pFeat)) { CGeometry *pg = pFeat->Shape->getGeometry(); CMultiPolygon *pmp = dynamic_cast<CMultiPolygon *> (pg); CPolygon *poly = (CPolygon *) pmp->getGeometryAt(0); CLineString *linestring = poly->getShell(); if (poly->getNumHoles() > 0) { CFillSymbol *pSymbol1 = new CFillSymbol(); pSymbol1->setColor(Qt::blue); pSymbol1->setStyle(Qt::SolidPattern); CPolygonElement *pPolyElement = new CPolygonElement(); pPolyElement->setSymbol(pSymbol1); pPolyElement->setGeometry(poly); view->map->graphicsContainer->addElement(pPolyElement); for (size_t i = 0; i < linestring->getNumPoints(); i++) { CCoordinate co(linestring->getCoordinateAt(i)); CMarkerElement *pMarkElement = new CMarkerElement(); CMarkerSymbol *pSymbol = new CMarkerSymbol(); pSymbol->setSize(2); pSymbol->setInColor(Qt::green); pSymbol->setOutColor(QColor()); pMarkElement->setPos(co.x, co.y); pMarkElement->setSymbol(pSymbol); view->map->graphicsContainer->addElement(pMarkElement); } } } delete pFeat;*/ }
// // FUNCTION: UpdateProperty() // // PURPOSE: Called by the Ribbon framework when a command property (PKEY) needs to be updated. // // COMMENTS: // // This function is used to populate the gallery. // // STDMETHODIMP CSizeAndColorHandler::UpdateProperty(UINT nCmdID, __in REFPROPERTYKEY key, __in_opt const PROPVARIANT* ppropvarCurrentValue, __out PROPVARIANT* ppropvarNewValue) { UNREFERENCED_PARAMETER(nCmdID); UNREFERENCED_PARAMETER(ppropvarNewValue); HRESULT hr = E_FAIL; if(key == UI_PKEY_Categories) { IUICollection* pCollection; hr = ppropvarCurrentValue->punkVal->QueryInterface(IID_PPV_ARGS(&pCollection)); if (FAILED(hr)) { return hr; } // Create a property set for the Size category. CPropertySet *pSize; hr = CPropertySet::CreateInstance(&pSize); if (FAILED(hr)) { pCollection->Release(); return hr; } // Load the label for the Size category from the resource file. WCHAR wszSizeLabel[MAX_RESOURCE_LENGTH]; LoadString(GetModuleHandle(NULL), IDS_SIZE_CATEGORY, wszSizeLabel, MAX_RESOURCE_LENGTH); // Initialize the property set with the label that was just loaded and a category id of 0. pSize->InitializeCategoryProperties(wszSizeLabel, 0); // Add the newly-created property set to the collection supplied by the framework. pCollection->Add(pSize); pSize->Release(); // Create a property set for the Color category. CPropertySet *pColor; hr = CPropertySet::CreateInstance(&pColor); if (FAILED(hr)) { pCollection->Release(); return hr; } // Load the label for the Color category from the resource file. WCHAR wszColorLabel[MAX_RESOURCE_LENGTH]; LoadString(GetModuleHandle(NULL), IDS_COLOR_CATEGORY, wszColorLabel, MAX_RESOURCE_LENGTH); // Initialize the property set with the label that was just loaded and a category id of 1. pColor->InitializeCategoryProperties(wszColorLabel, 1); // Add the newly-created property set to the collection supplied by the framework. pCollection->Add(pColor); pColor->Release(); pCollection->Release(); hr = S_OK; } else if(key == UI_PKEY_ItemsSource) { IUICollection* pCollection; hr = ppropvarCurrentValue->punkVal->QueryInterface(IID_PPV_ARGS(&pCollection)); if (FAILED(hr)) { return hr; } int commandIds[] = {IDR_CMD_SMALL, IDR_CMD_MEDIUM, IDR_CMD_LARGE, IDR_CMD_RED, IDR_CMD_GREEN, IDR_CMD_BLUE}; int categoryIds[] = {0, 0, 0, 1, 1, 1}; // Populate the gallery with the three size and three colors in two separate categories. for (int i=0; i<_countof(commandIds); i++) { // Create a new property set for each item. CPropertySet* pCommand; hr = CPropertySet::CreateInstance(&pCommand); if (FAILED(hr)) { pCollection->Release(); return hr; } // Initialize the property set with the appropriate command id and category id and type Boolean (which makes these appear as ToggleButtons). pCommand->InitializeCommandProperties(categoryIds[i], commandIds[i], UI_COMMANDTYPE_BOOLEAN); // Add the newly-created property set to the collection supplied by the framework. pCollection->Add(pCommand); pCommand->Release(); } pCollection->Release(); hr = S_OK; } return hr; }
bool CDXConfibDBImpl::DoPropertySet( CPropertySet* pPropertySet ) { // // Now add flags until break is found const int k_MaxNestedIf = 256; // Max levels of nesting int NestedIf[k_MaxNestedIf]; int IfPointer=0; // Depth of IF's int SkippingIF=0; // 0=Not in an IF, 1=In True if, 2=In false IF bool first = true; do { if( first ) first = false; else SkipToNextLine(); // // Check for unexpected keywords if( NextStringIs(kDBKwDisplayVendor) || NextStringIs(kDBKwRequirements) ) return true; SkipSpace(); if( *m_pchCurrent!=13 && *(WORD*)m_pchCurrent!='//' ) { // Ignore comments and blank lines if( *m_pchCurrent>='0' && *m_pchCurrent<='9' ) // Or the start of another device continue; if( NextStringIs(kDBKwUnknown) ) // Or unknown device clause continue; if( NextStringIs(kDBKwBreak) ) break; if( NextStringIs(kDBKwMaxOverallGraphicDetail) ) { m_pchCurrent += strlen(kDBKwMaxOverallGraphicDetail); // This should be in the format: MaxOGD = N // Skip spaces, '='s. SkipSpace(); if (*m_pchCurrent == '=') { m_pchCurrent++; } else { SyntaxError("Expecting \'=\', didn\'t get it"); return false; } SkipSpace(); // We have the value in string format in m_pchCurrent and we need the // value in both string and numeric format. Doing a GetNumber then a // sprintf works best because it will keep extra spaces or comments out // of the string version. DWORD dwMaxOGD = GetNumber(); if (dwMaxOGD != (DWORD)-1) { char maxValue[16]; char curValue[16] = "0"; sprintf(maxValue, "%d", dwMaxOGD); if (m_pDevice->Get(kDBKwOverallGraphicDetail, curValue, sizeof(curValue))) { DWORD dwOGD = atoi(curValue); if (dwOGD > dwMaxOGD) { // Check the current graphic detail level. If its // higher than the max, apply the max. std::map<std::string, CPropertySet*>::iterator it; it = m_mapOGDToPropertySet.find(maxValue); if (it == m_mapOGDToPropertySet.end()) { SyntaxError("Unrecognized graphic detail"); return false; } CPropertySet* pSet = (*it).second; ApplyPropertySet(m_pDevice, pSet); } } } else { SyntaxError("MaxOverallGraphicDetail did not specify a number!"); return false; } continue; } if (NextStringIs(kDBKwIf)) { m_pchCurrent+=2; char* condition=GetCondition(); NestedIf[IfPointer++]=SkippingIF; if( IfPointer==16 ) { SyntaxError( "IF's nested too deep" ); return false; } if( condition==(char*)1 ) // True? { if( SkippingIF!=2 ) { SkippingIF=1; // If inside false if, keep skipping } } else { if( condition==(char*)0 ) // False? { SkippingIF=2; } else { if( condition ) // m_fError { SyntaxError( condition ); return false; } } } } else { if (NextStringIs(kDBKwEndif)) { if( IfPointer==0 ) { SyntaxError( "Unexpected ENDIF" ); return false; } SkippingIF=NestedIf[--IfPointer]; } else { if( 0==SkippingIF || 1==SkippingIF ) // Add flag if not skipping in a IF { if ( NextStringIs(kDBKwPropertySet)) { m_pchCurrent+=11; SkipSpace(); if ( *m_pchCurrent=='=' ) { m_pchCurrent++; char* pszName = GetString(); if (!pszName) { return false; } std::string strName = pszName; std::map<std::string, CPropertySet*>::iterator it; it = m_mapNameToPropertySet.find(strName); if (it == m_mapNameToPropertySet.end()) { SyntaxError("Unrecognized property set"); return false; } CPropertySet* pSet = (*it).second; ApplyPropertySet(pPropertySet, pSet); } else { SyntaxError("Missing ="); return false; } } else { char* strErr=AddFlag(pPropertySet); // Add this flag, check for duplicates if (strErr) { SyntaxError( strErr ); return false; } } } } } } } while( m_pchCurrent<m_pchEndOfFile ); // // Check for hanging endif // if( SkippingIF!=0 || IfPointer!=0 ) { SyntaxError( "Bad IF/ENDIF" ); return false; } return true; }