Пример #1
0
void wxTreebook::AssignImageList(wxImageList *imageList)
{
    wxBookCtrlBase::AssignImageList(imageList);
    GetTreeCtrl()->SetImageList(imageList);
}
Пример #2
0
void wxTreebook::DoInternalRemovePageRange(size_t pagePos, size_t subCount)
{
    // Attention: this function is only for a situation when we delete a node
    // with all its children so pagePos is the node's index and subCount is the
    // node children count
    wxASSERT_MSG( pagePos + subCount < m_treeIds.GetCount(),
                    wxT("Ivalid page index") );

    wxTreeItemId pageId = m_treeIds[pagePos];

    m_treeIds.RemoveAt(pagePos, subCount + 1);

    if ( m_selection != wxNOT_FOUND )
    {
        if ( (size_t)m_selection > pagePos + subCount)
        {
            // selection is far after the deleted page, so just update the index and move on
            m_selection -= 1 + subCount;
            if ( m_actualSelection != wxNOT_FOUND)
            {
                m_actualSelection -= subCount + 1;
            }
        }
        else if ( (size_t)m_selection >= pagePos )
        {
            wxTreeCtrl *tree = GetTreeCtrl();

            // as selected page is going to be deleted, try to select the next
            // sibling if exists, if not then the parent
            wxTreeItemId nodeId = tree->GetNextSibling(pageId);

            m_selection = wxNOT_FOUND;
            m_actualSelection = wxNOT_FOUND;

            if ( nodeId.IsOk() )
            {
                // selecting next siblings
                tree->SelectItem(nodeId);
            }
            else // no next sibling, select the parent
            {
                wxTreeItemId parentId = tree->GetItemParent(pageId);

                if ( parentId.IsOk() && parentId != tree->GetRootItem() )
                {
                    tree->SelectItem(parentId);
                }
                else // parent is root
                {
                    // we can't select it as it's hidden
                    DoUpdateSelection(false, wxNOT_FOUND);
                }
            }
        }
        else if ( m_actualSelection != wxNOT_FOUND &&
                    (size_t)m_actualSelection >= pagePos )
        {
            // nothing to do -- selection is before the deleted node, but
            // actually shown page (the first (sub)child with page != NULL) is
            // already deleted
            m_actualSelection = m_selection;

            // send event as documented
            DoSetSelection(m_selection, SetSelection_SendEvent);
        }
        //else: nothing to do -- selection is before the deleted node
    }
    else
    {
        DoUpdateSelection(false, wxNOT_FOUND);
    }
}
Пример #3
0
int wxTreebook::DoSetSelection(size_t pagePos, int flags)
{
    wxCHECK_MSG( IS_VALID_PAGE(pagePos), wxNOT_FOUND,
                 wxT("invalid page index in wxListbook::DoSetSelection()") );
    wxASSERT_MSG( GetPageCount() == DoInternalGetPageCount(),
                  wxT("wxTreebook logic error: m_treeIds and m_pages not in sync!"));

    wxBookCtrlEvent event(wxEVT_TREEBOOK_PAGE_CHANGING, m_windowId);
    const int oldSel = m_selection;
    wxTreeCtrl *tree = GetTreeCtrl();
    bool allowed = false;

    if (flags & SetSelection_SendEvent)
    {
        event.SetEventObject(this);
        event.SetSelection(pagePos);
        event.SetOldSelection(m_selection);

        // don't send the event if the old and new pages are the same; do send it
        // otherwise and be prepared for it to be vetoed
        allowed = (int)pagePos == m_selection ||
                  !GetEventHandler()->ProcessEvent(event) ||
                  event.IsAllowed();
    }

    if ( !(flags & SetSelection_SendEvent) || allowed )
    {
        // hide the previously shown page
        wxTreebookPage * const oldPage = DoGetCurrentPage();
        if ( oldPage )
            oldPage->Hide();

        // then show the new one
        m_selection = pagePos;
        wxTreebookPage *page = wxBookCtrlBase::GetPage(m_selection);
        if ( !page )
        {
            // find the next page suitable to be shown: the first (grand)child
            // of this one with a non-NULL associated page
            wxTreeItemId childId = m_treeIds[pagePos];
            int actualPagePos = pagePos;
            while ( !page && childId.IsOk() )
            {
                wxTreeItemIdValue cookie;
                childId = tree->GetFirstChild( childId, cookie );
                if ( childId.IsOk() )
                {
                    page = wxBookCtrlBase::GetPage(++actualPagePos);
                }
            }

            m_actualSelection = page ? actualPagePos : m_selection;
        }

        if ( page )
            page->Show();

        tree->SelectItem(DoInternalGetPage(pagePos));

        if (flags & SetSelection_SendEvent)
        {
            // notify about the (now completed) page change
            event.SetEventType(wxEVT_TREEBOOK_PAGE_CHANGED);
            (void)GetEventHandler()->ProcessEvent(event);
        }
    }
    else if ( (flags & SetSelection_SendEvent) && !allowed) // page change vetoed
    {
        // tree selection might have already had changed
        if ( oldSel != wxNOT_FOUND )
            tree->SelectItem(DoInternalGetPage(oldSel));
    }

    return oldSel;
}
Пример #4
0
void CvIpmLeft::OnSelchanging(NMHDR* pNMHDR, LRESULT* pResult) 
{
	CTreeCtrl& tree = GetTreeCtrl();
	CdIpmDoc* pDoc = (CdIpmDoc *)GetDocument();
	ASSERT(pDoc);

	*pResult = 0;   // default to allow selchange
	try
	{
		// Manage "update all after load on first action"
		if (!pDoc)
			return;
		if (pDoc->GetPTreeGD()->CurrentlyLoading())
			return;
		if (pDoc->GetLockDisplayRightPane())
			return;
		if (pDoc->ManageMonSpecialState() || m_bProhibitActionOnTreeCtrl)
		{
			*pResult = 1;
			return;
		}

		NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
		HTREEITEM hItem = pNMTreeView->itemNew.hItem;
		CTreeItem *pItem;
		pItem = (CTreeItem *)tree.GetItemData(hItem);
		if (pItem) {
			if (!pItem->CompleteStruct()) { //"Structure Not Completed"
				AfxMessageBox(IDS_E_STRUCTURE, MB_OK | MB_ICONEXCLAMATION);
				*pResult = 1;     // prevent selchange
				return;
			}
			// Manage old item replicator dbevents
			HTREEITEM hOldItem = pNMTreeView->itemOld.hItem;
			if (hOldItem) 
			{
				CTreeItem *pOldItem;
				pOldItem = (CTreeItem *)tree.GetItemData(hOldItem);
				ASSERT (pOldItem);
				if (pOldItem) {
					// Cannot rely on "if (!pOldItem->ItemDisplaysNoPage())"
					// because replication can have been installed/uninstalled since then
					// ---> must terminate or not according to m_ReplMonHandle value
					if (pOldItem->HasReplicMonitor()) 
					{
						pDoc->TerminateReplicator();
					}
				}
			}

			// Notify current page on the right that we are about to leave it
			CfIpmFrame* pFrame = (CfIpmFrame*)GetParentFrame();
			ASSERT (pFrame);
			if (pFrame) 
			{
				if (pFrame->IsAllViewCreated()) 
				{
					CuDlgIpmTabCtrl* pTabDlg  = (CuDlgIpmTabCtrl*)pFrame->GetTabDialog();
					if (pTabDlg)
						pTabDlg->NotifyPageSelChanging();
				}
			}
		}
	}
	catch (...)
	{
		AfxMessageBox (IDS_E_CONSTRUCT_PROPERTY);
	}
}
Пример #5
0
void CvIpmLeft::OnSelchanged(NMHDR* pNMHDR, LRESULT* pResult) 
{
	IPMUPDATEPARAMS ups;
	NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
	CdIpmDoc* pDoc = (CdIpmDoc *)GetDocument();

	try 
	{
		ASSERT(pDoc);
		if (!pDoc)
			return;
		if (pDoc->GetLockDisplayRightPane())
			return;
		CfIpmFrame* pFrame = (CfIpmFrame*)GetParentFrame();
		ASSERT (pFrame);
		if (!pFrame)
			return;
		if (!pFrame->IsAllViewCreated())
			return;

		CuDlgIpmTabCtrl* pTabDlg  = (CuDlgIpmTabCtrl*)pFrame->GetTabDialog();
		if (!pTabDlg)
			return;
		CWaitCursor doWaitCursor ;
		//
		// Notify the container of sel change:
		CIpmCtrl* pIpmCtrl = (CIpmCtrl*)pFrame->GetParent();
		if (pIpmCtrl)
			pIpmCtrl->ContainerNotifySelChange();

		memset (&ups, 0, sizeof (ups));
		CTreeCtrl& treeCtrl = GetTreeCtrl();
		CTreeItem* pItem = (CTreeItem*)treeCtrl.GetItemData (pNMTreeView->itemNew.hItem);
		if (pItem->IsNoItem() || pItem->IsErrorItem())
		{
			pTabDlg->DisplayPage (NULL);
			*pResult = 0;
			return;
		}
		if (pItem->ItemDisplaysNoPage()) {
			CString caption = pItem->ItemNoPageCaption();
			pTabDlg->DisplayPage (NULL, caption);
			*pResult = 0;
			return;
		}

		if (pItem->HasReplicMonitor())
		{
			pDoc->InitializeReplicator(pItem->GetDBName());
		}

		int nImage = -1, nSelectedImage = -1;
		CImageList* pImageList = treeCtrl.GetImageList (TVSIL_NORMAL);
		HICON hIcon = NULL;
		int nImageCount = pImageList? pImageList->GetImageCount(): 0;
		if (pImageList && treeCtrl.GetItemImage(pNMTreeView->itemNew.hItem, nImage, nSelectedImage))
		{
			if (nImage < nImageCount)
				hIcon = pImageList->ExtractIcon(nImage);
		}
		CuPageInformation* pPageInfo = pItem->GetPageInformation();

		CString strItem = pItem->GetRightPaneTitle();
		pItem->UpdateDataWhenSelChange(); // Has an effect only if the class has specialied the method.
		ups.nType   = pItem->GetType();
		ups.pStruct = pItem->GetPTreeItemData()? pItem->GetPTreeItemData()->GetDataPtr(): NULL;
		ups.pSFilter= pDoc->GetPTreeGD()->GetPSFilter();
		pPageInfo->SetUpdateParam (&ups);
		pPageInfo->SetTitle ((LPCTSTR)strItem, pItem, pDoc);

		pPageInfo->SetImage  (hIcon);
		pTabDlg->DisplayPage (pPageInfo);
	}
	catch(CMemoryException* e)
	{
		theApp.OutOfMemoryMessage();
		e->Delete();
	}
	catch(CResourceException* e)
	{
		AfxMessageBox (IDS_E_LOAD_DLG);
		e->Delete();
	}
	catch(...)
	{
		AfxMessageBox (IDS_E_CONSTRUCT_PROPERTY);
	}
	*pResult = 0;
}
Пример #6
0
LONG CvIpmLeft::OnFindReplace(WPARAM wParam, LPARAM lParam)
{
	TRACE0("CvIpmLeft::OnFindReplace\n");
	CString strFind;
	LPFINDREPLACE lpfr = (LPFINDREPLACE) lParam;
	if (!lpfr)
		return 0;
	
	if (lpfr->Flags & FR_DIALOGTERM)
	{
		m_strLastFindWhat = m_pDlgFind->GetFindString();
		m_pDlgFind = NULL;
	}
	else
	if (lpfr->Flags & FR_FINDNEXT)
	{
		//
		// Find Next:
		CString strMsg;
		m_strLastFindWhat = m_pDlgFind->GetFindString();
		
		CdIpmDoc* pDoc = (CdIpmDoc *)GetDocument();
		ASSERT (pDoc);
		if (!pDoc)
			return -1L;
		CTreeCtrl& treeCtrl = GetTreeCtrl();
		HTREEITEM hItem = treeCtrl.GetSelectedItem();
		if (!hItem)
			return -1L;

		HTREEITEM hItemCurSel;
		HTREEITEM hItemNewSel;
		HTREEITEM hItemNextToCurSel;
		BOOL      bFound;
		LPTSTR    pCur, pPrec;
		static    TCHAR tchszWordSeparator[] = _T(" .*[]()\t");

		m_bMatchCase = m_pDlgFind->MatchCase();
		m_bWholeWord = m_pDlgFind->MatchWholeWord();
		strFind    = m_strLastFindWhat;
		if (!m_bMatchCase)
			strFind.MakeUpper();

		//
		// Loop starting from the current selection
		hItemCurSel = treeCtrl.GetSelectedItem();
		hItemNewSel = treeCtrl.GetNextVisibleItem(hItemCurSel);
		hItemNextToCurSel = hItemNewSel;
		while (hItemNewSel) 
		{
			CTreeItem* pItem = (CTreeItem *)treeCtrl.GetItemData(hItemNewSel);
			ASSERT(pItem);
			if (!pItem)
				return -1L;
			CString strItem = pItem->GetDisplayName();
			if (!strItem.IsEmpty()) 
			{
				if (!m_bMatchCase)
					strItem.MakeUpper();

				//
				// search
				if (m_bWholeWord) 
				{
					bFound = FALSE;
					pPrec  = (LPTSTR)(LPCTSTR)strItem;
					while (1) 
					{
						// search substring
						pCur = _tcsstr(pPrec, strFind);
						if (pCur == 0) 
						{
							bFound = FALSE;
							break;    // Not found. Cannot be found anymore. Bueno
						}

						// check previous character is a separator or first in the string
						if (pCur > (LPTSTR)(LPCTSTR)strItem)
						{
							if (_tcschr(tchszWordSeparator, *(pCur-1)) == 0) 
							{
								pPrec = pCur + 1;
								continue;   // try next occurence in the string
							}
						}

						// check ending character is a separator or terminates the string
						if (*(pCur + strFind.GetLength()) != _T('\0'))
						{
							if (_tcschr(tchszWordSeparator, *(pCur + strFind.GetLength())) == 0) 
							{
								pPrec = _tcsinc(pCur);
								continue;   // try next occurence in the string
							}
						}
						// all tests fit
						bFound = TRUE;
						break;
					}
				}
				else
					bFound = ((_tcsstr(strItem, strFind)==NULL) ? FALSE : TRUE);

				// use search result
				if (bFound) 
				{
					// special management if no other than current
					if (hItemNewSel == hItemCurSel)
						break;
					// select item, ensure visibility, and return
					treeCtrl.SelectItem(hItemNewSel);
					treeCtrl.EnsureVisible(hItemNewSel);
					return -1L;
				}
			}

			// Next item, and exit condition for the while() loop
			// Wraparoud managed here!
			hItemNewSel = treeCtrl.GetNextVisibleItem(hItemNewSel);
			if (hItemNewSel==0)
				hItemNewSel = treeCtrl.GetRootItem();
			if (hItemNewSel == hItemNextToCurSel)
				break;      // wrapped around the whole tree : not found
		}

		//
		// Not found : display message box - truncate text if too long
		if (hItemNewSel == hItemCurSel)
			AfxFormatString1(strMsg, IDS_FIND_NO_OCCURENCE, (LPCTSTR)strFind);
		else
			AfxFormatString1(strMsg, IDS_FIND_NOTFOUND, (LPCTSTR)strFind);
		AfxMessageBox (strMsg);
		m_pDlgFind->SetFocus();
	}
	return 0;
}
int look::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CTreeView::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	// TODO: Add your specialized creation code here
	m_TreeCtrl = &GetTreeCtrl();
	m_TreeCtrl->ModifyStyle (0, WS_VISIBLE | TVS_HASBUTTONS|TVS_HASLINES|TVS_LINESATROOT);

	m_Font.CreatePointFont (95, _T("宋体"));
    m_TreeCtrl->SetFont (&m_Font);

	m_ImageList.Create(16, 16, true, 2, 1);
	HICON hIcon;
	
	
	hIcon= AfxGetApp()->LoadIcon (IDI_ICON2);
	m_ImageList.Add (hIcon);
	hIcon= AfxGetApp()->LoadIcon (IDI_ICON3);
	m_ImageList.Add (hIcon);

	m_TreeCtrl->SetImageList( &m_ImageList, TVSIL_NORMAL );
	


	//m_ini.
	
	char buffer[_MAX_PATH]; 
	
	if(_getcwd(buffer,_MAX_PATH)!=NULL){
		
		m_ini.file_path =strcat(buffer,"\\config.ini");
		

		
	}

	//my=(CMainFrame *)AfxGetMainfrm()->;
#define SUDDY
//	my=my_connection;
//	char *
#ifdef PEARL
	my=con.connect ("192.168.0.10", "root","3123", "caixia", 0, "csi04", 0 );
#endif	//my=con.connect ("192.168.0.10", "root","3123", "wangyu", 0, "csi04", 0 );
#ifdef SUDDY
	my=con.connect (m_ini.getvalue ("mysql","host"), m_ini.getvalue ("mysql","user"),m_ini.getvalue ("mysql","password"), m_ini.getvalue ("mysql","database"), 0, "csi04", 0 );
#endif

	if (my==NULL) 
	{
	
		MessageBox("连接失败!请和管理员[email protected] 联系,\nPlease Contact to Adimistrator [email protected]");
		AfxGetMainWnd()->PostMessage (WM_CLOSE);
		return FALSE;
	}

	CString sql;
	sql="select distinct type from help order by type";
	//MessageBox(sql);

	if(con.mysql_exec(my,sql)!=0) 
	{
		char *s=(char *)malloc(1024);
		
		
		sprintf(s,"发生错误:%s",con.error(my));
		//s=con.error(my);

		MessageBox(s);
		free(s);
		return 0;
	}
	rs_dad=con.store_result (my);
	while((row=mysql_fetch_row(rs_dad))!=NULL) 

	{
		
		dad=m_TreeCtrl->InsertItem (row[0],1,0);
		sql="select title from help where type=\'"+(CString)row[0]+"\'";

	//MessageBox(sql);

		if(con.mysql_exec(my,sql)!=0) 
		{
		//MessageBox("服务器可能已经关闭,请重试,如果问题仍然存在,请联系[email protected]");
		
			return 0;
		}
		
		rs_son=con.store_result (my);
		while((row_son=mysql_fetch_row(rs_son))!=NULL)
		{
		
			m_TreeCtrl->InsertItem (row_son[0],1,0,dad);
		
		
		}
		con.free_result (rs_son);

		
	}
	con.free_result (rs_dad);
	
	return 0;
}
Пример #8
0
void CLeftView::DeleteFirstChild(HTREEITEM hItem)
{
	HTREEITEM hChildItem;
	if ((hChildItem = GetTreeCtrl().GetChildItem(hItem)) != NULL)
		GetTreeCtrl().DeleteItem(hChildItem);
}