Beispiel #1
0
LRESULT CEmbedComboBox::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
	LRESULT lResult(0);
	lResult = CComboBox::WindowProc(message, wParam, lParam);
	switch (message) {
	case WM_DESTROY:
		if (mEmbedEditControl != NULL) {
			delete mEmbedEditControl;
			mEmbedEditControl = NULL;
		}
		break;
	case WM_SHOWWINDOW:
		if (!mEmbedEditControl) {
			CWnd *pChild(GetWindow(GW_CHILD));
			if (pChild) {
				mEmbedEditControl = new CEmbedEditControl();
				mEmbedEditControl->SubclassWindow(pChild->m_hWnd);
			}
		}
		if (wParam)
			ShowDropDown();
		break;
	case WM_KILLFOCUS:
		{
			CWnd *pChild(GetWindow(GW_CHILD));
			if (!pChild || pChild->m_hWnd != (HWND)wParam)
				GetParent()->SendMessage(WM_ENABLE_EMBED_CONTROL, 0, 0);
		}
		break;
	case WM_ENABLE_EMBED_CONTROL:
		GetParent()->SendMessage(WM_ENABLE_EMBED_CONTROL, wParam, lParam);
		break;
	case WM_KEYDOWN:
		{
			int commit(0);
			switch (wParam) {
			case VK_ESCAPE:
			case VK_CLEAR:
				commit = ECF_DONOT_COMMIT; // No commit
			case VK_ACCEPT:
			case VK_RETURN:
				GetParent()->SendMessage(WM_ENABLE_EMBED_CONTROL, commit, 0);
			}
		}
		break;
	}
	return lResult;
}
Beispiel #2
0
	//-------------------------------------------------------------------------
	// Function Name    :CreateNode
	// Parameter(s)     :LPCTSTR lpszName			node local name
	//					:LPCTSTR lpszPrefix			node prefix
	//					:LPCTSTR lpszNamespaceURI	namespace URI
	// Return           :CXmlNodePtr
	// Create			:2007-8-2 9:59 Jerry.Wang
	//-------------------------------------------------------------------------
	CXmlNodePtr CXml::CreateNode(LPCTSTR lpszName
		, LPCTSTR lpszPrefix /* = _T("") */
		, LPCTSTR lpszNamespaceURI /* = _T("") */
		)
	{
		ASSERT( m_pDoc != NULL );
		
		CXmlNodePtr pChild( new CXmlNode() );

		CString strName;
		strName.Format( _tcslen(lpszPrefix) > 0 ? _T("%s:%s") : _T("%s%s"), lpszPrefix, lpszName);
		try
		{	
			MSXML2::IXMLDOMNodePtr pChildNode = NULL;
			pChildNode = m_pDoc->createNode(_variant_t(_T("element")), _bstr_t(strName), _bstr_t(lpszNamespaceURI) );
			ASSERT( pChildNode != NULL );
			pChild->m_pNode = pChildNode;
			RELEASE_PTR(pChildNode);
		}
		catch ( _com_error e )
		{
			TRACE( _T("CXml::CreateNode( %s, %s, %s) failed:%s\n"), lpszName, lpszPrefix, lpszNamespaceURI, e.ErrorMessage());
			ASSERT( FALSE );
		}
		return pChild;
	}
Beispiel #3
0
void GetLayer<T>::populateTreeWidgetItem(QTreeWidgetItem* pRoot)
{
   VERIFYNR(pRoot != NULL);
   const std::vector<View*> views = getViews();
   for (std::vector<View*>::const_iterator iter = views.begin(); iter != views.end(); ++iter)
   {
      View* pView = *iter;
      VERIFYNR(pView != NULL);

      std::auto_ptr<QTreeWidgetItem> pChild(new QTreeWidgetItem);
      std::string name = pView->getDisplayName();
      if (name.empty() == true)
      {
         name = pView->getName();
      }

      std::vector<std::string> classList;
      Service<DesktopServices>()->getViewTypes(pView->getObjectType(), classList);
      VERIFYNR(classList.empty() == false);

      pChild->setText(GetSessionItemBase<T>::NameColumn, QString::fromStdString(name));
      pChild->setData(GetSessionItemBase<T>::NameColumn,
         GetSessionItemBase<T>::SessionItemRole, QVariant::fromValue<void*>(pView));
      pChild->setText(GetSessionItemBase<T>::TypeColumn, QString::fromStdString(classList.front()));
      pChild->setFlags(Qt::NoItemFlags);

      populateTreeWidgetItemWithLayers(pChild.get());
      if (pChild->childCount() > 0)
      {
         pRoot->addChild(pChild.release());
      }
   }
}
Beispiel #4
0
//-------------------------------------------------------------------------
// Function Name    :CreateNode
// Parameter(s)     :CString strName	结点名称
// Return           :CXmlNodePtr
// Memo             :创建结点
//-------------------------------------------------------------------------
CXmlNodePtr CXml::CreateNode(LPCTSTR pszName)
{
	ASSERT(m_pDoc != NULL);

	CXmlNodePtr pChild(new CXmlNode());
	
	try
	{	MSXML2::IXMLDOMNodePtr pChildNode = NULL;
		pChildNode = m_pDoc->createElement(_bstr_t(pszName));
		ASSERT(pChildNode != NULL);
		pChild->m_pNode = pChildNode;
		RELEASE_PTR(pChildNode);
	}
	catch (_com_error e)
	{
		TRACE(_T("CXml::CreateNode 发生异常:%s\n"), e.ErrorMessage());
		ASSERT(FALSE);
	}
	return pChild;
}
Beispiel #5
0
void drawChildren(Status *parent, Status *all, int level)
{
    Status *ap = rewindStatus(all);

    while (ap) {

        if (ap->ppid == parent->pid && ap != parent) {

            levelPadding(level);

            if (hasChildren(ap)) {
            	pParent(ap);
                drawChildren(ap, all, level + 1);
            } else {
            	pChild(ap);
            }
        }

        ap = ap->next;
    }
}
Beispiel #6
0
void GetDataElement<T>::populateTreeWidgetItem(QTreeWidgetItem* pRoot)
{
   VERIFYNR(pRoot != NULL);
   QVariant value = pRoot->data(GetSessionItemBase<T>::NameColumn, GetSessionItemBase<T>::SessionItemRole);
   void* pValue = value.value<void*>();
   DataElement* const pRootElement = reinterpret_cast<DataElement*>(pValue);
   const std::vector<DataElement*> elements = Service<ModelServices>()->getElements(pRootElement, std::string());
   for (std::vector<DataElement*>::const_iterator iter = elements.begin(); iter != elements.end(); ++iter)
   {
      DataElement* pChildElement = *iter;
      if (pChildElement == NULL)
      {
         // Disallow NULL elements since that would result in infinite recursion.
         continue;
      }

      std::auto_ptr<QTreeWidgetItem> pChild(new QTreeWidgetItem);
      std::string name = pChildElement->getDisplayName();
      if (name.empty() == true)
      {
         name = pChildElement->getName();
      }

      pChild->setText(GetSessionItemBase<T>::NameColumn, QString::fromStdString(name));
      pChild->setData(GetSessionItemBase<T>::NameColumn,
         GetSessionItemBase<T>::SessionItemRole, QVariant::fromValue<void*>(pChildElement));
      pChild->setText(GetSessionItemBase<T>::TypeColumn, QString::fromStdString(pChildElement->getType()));
      populateTreeWidgetItem(pChild.get());

      const bool isValid = pChildElement->isKindOf(TypeConverter::toString<T>());
      pChild->setFlags(isValid ? Qt::ItemIsEnabled | Qt::ItemIsSelectable : Qt::NoItemFlags);
      if (isValid == true || pChild->childCount() > 0)
      {
         pRoot->addChild(pChild.release());
      }
   }
}