示例#1
0
HTREEITEM KGTreeCtrl::CopyItem(
	HTREEITEM hItem, HTREEITEM htiNewParent, HTREEITEM htiAfter
)
{
	int nResult  = false;
	int nRetCode = false;

	TV_INSERTSTRUCT  tvstruct;
	HTREEITEM        hNewItem = NULL;
	CString          sText;

	tvstruct.item.hItem = hItem;
	tvstruct.item.mask  =
		TVIF_CHILDREN | TVIF_HANDLE | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
	GetItem(&tvstruct.item);
	sText = GetItemText(hItem);
	tvstruct.item.cchTextMax = sText.GetLength();
	tvstruct.item.pszText    = sText.LockBuffer();

	tvstruct.hParent         = htiNewParent;
	tvstruct.hInsertAfter    = htiAfter;
	tvstruct.item.mask       = TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_TEXT;
	hNewItem = InsertItem(&tvstruct);
	sText.ReleaseBuffer();

	SetItemData(hNewItem, GetItemData(hItem));
	SetItemState(
		hNewItem, GetItemState(hItem, TVIS_STATEIMAGEMASK), TVIS_STATEIMAGEMASK
	);

	nRetCode = AfterCopyItem(
		hItem, hNewItem, htiNewParent, htiAfter
	);
	KG_PROCESS_ERROR(nRetCode);

	nResult = true;
Exit0:
	return hNewItem;
}
void CComplexSymbolLayerCtrl::ResetItem(int nSelect)
{
	UINT state = GetItemState( nSelect , LVIS_STATEIMAGEMASK );
	LV_ITEM lvi;
	m_nSelect = nSelect;
	lvi.mask =  LVIF_IMAGE|LVIF_STATE;
	lvi.iItem = nSelect;
	lvi.iSubItem = 0;
	lvi.iImage = nSelect;
	lvi.pszText = "";
	lvi.stateMask  = LVIS_STATEIMAGEMASK|LVIS_DROPHILITED;

	switch ( state )
	{
	case  INDEXTOSTATEIMAGEMASK( 1 ):
		{
			lvi.state =INDEXTOSTATEIMAGEMASK( 1 );
			break;
		}
	case INDEXTOSTATEIMAGEMASK( 2 ):
		{
			lvi.state =INDEXTOSTATEIMAGEMASK( 2 ) ;
			break;
		}
	case 	INDEXTOSTATEIMAGEMASK( 3 ):
		{
			lvi.state=INDEXTOSTATEIMAGEMASK( 1 );
			break;
		}
	case  INDEXTOSTATEIMAGEMASK( 4 ):
		{
			lvi.state=INDEXTOSTATEIMAGEMASK( 2 ) ;
			break;
		}
	}

	SetItemState(m_nSelect,&lvi);
}
void CMusikListCtrl::SelectClickedItem(wxMouseEvent &event)
{
	int HitFlags = 0;
	long item = HitTest(event.GetPosition(),HitFlags);
	if(item != -1)
	{
        if((wxLIST_STATE_SELECTED & GetItemState(item,wxLIST_STATE_SELECTED)) != wxLIST_STATE_SELECTED) // bug in MSW GetItemState (mask param is ignored)
        {    
            if(!event.CmdDown())
            {
                int i = -1;
                while ( -1 != (i = GetNextItem(i, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED)))
                {
                    if(i != item)
                        SetItemState( i, 0, wxLIST_STATE_SELECTED );
                }

            }
            SetItemState(item,wxLIST_STATE_SELECTED,wxLIST_STATE_SELECTED);
            wxTheApp->Yield(true);   // call yield to let the SetItemState changes go through the system.
        }
    }
}
示例#4
0
void CLocalListView::SortList_UpdateSelections(bool* selections, int focus)
{
	for (int i = m_hasParent ? 1 : 0; i < GetItemCount(); i++)
	{
		const int state = GetItemState(i, wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);
		const bool selected = (state & wxLIST_STATE_SELECTED) != 0;
		const bool focused = (state & wxLIST_STATE_FOCUSED) != 0;

		int item = m_indexMapping[i];
		if (selections[item] != selected)
			SetItemState(i, selections[item] ? wxLIST_STATE_SELECTED : 0, wxLIST_STATE_SELECTED);
		if (focused)
		{
			if (item != focus)
				SetItemState(i, 0, wxLIST_STATE_FOCUSED);
		}
		else
		{
			if (item == focus)
				SetItemState(i, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED);
		}
	}
}
示例#5
0
void CSListCtrl::GetDrawColors(int nItem, int nSubItem, COLORREF& colorText, COLORREF& colorBkgnd)
{
	DWORD dwStyle    = GetStyle();
	DWORD dwExStyle  = GetExtendedStyle();
	
	COLORREF crText  = colorText;
	COLORREF crBkgnd = colorBkgnd;
	
	if (GetItemState(nItem, LVIS_SELECTED))
	{
		//full row select or the first column
		if( (dwExStyle & LVS_EX_FULLROWSELECT) || nSubItem == 0 )
		{
			// selected?  if so, draw highlight background
			crText  = m_crHighLightText;
			crBkgnd = m_crHighLight;
			
			// has focus?  if not, draw gray background
			if (m_hWnd != ::GetFocus())
			{
				if (dwStyle & LVS_SHOWSELALWAYS)
				{
					crText  = m_crWindowText;
					crBkgnd = m_crBtnFace;
				}
				else
				{
					crText  = colorText;
					crBkgnd = colorBkgnd;
				}
			}
		}
	}
	
	colorText = crText;
	colorBkgnd = crBkgnd;
}
示例#6
0
void CChatSelector::ShowChat()
{
	int	iCurSel = GetCurSel();

	if (iCurSel == -1)
		return;

	bool	bWasChanged = (GetItemState(iCurSel, TCIS_HIGHLIGHTED) & TCIS_HIGHLIGHTED);

	SetItemState(iCurSel, TCIS_HIGHLIGHTED, NULL);

	CChatItem	*pChatItem = GetCurrentChatItem(), *pUpdateItem;

	if (pChatItem == NULL)
		return;

	pChatItem->m_pLog->SetRedraw(false);
	pChatItem->m_pLog->ShowWindow(SW_SHOW);
	if ((pChatItem->m_pLog->m_dwFlags & HTC_ISAUTOSCROLL) != 0 && bWasChanged)
		pChatItem->m_pLog->ScrollToLastLine();
	pChatItem->m_pLog->SetRedraw(true);

	TCITEM	tcitem;
	int		i = 0;

	tcitem.mask = TCIF_PARAM;
	while (GetItem(i++, &tcitem))
	{
		pUpdateItem = (CChatItem*)tcitem.lParam;
		if (pUpdateItem != pChatItem)
			pUpdateItem->m_pLog->ShowWindow(SW_HIDE);
	}

	pChatItem->m_pLog->SetTitle(pChatItem->m_pClient->GetUserName());
	pChatItem->m_bNotify = false;
	g_App.m_pMDlg->m_wndChat.m_ctlInputText.SetFocus();
}
示例#7
0
HTREEITEM CTreeCtrlEx::CopyItem(HTREEITEM hItem, HTREEITEM htiNewParent, HTREEITEM htiAfter)
{
	TV_INSERTSTRUCT tvstruct;
	HTREEITEM hNewItem;
	CString sText;

	tvstruct.item.hItem = hItem;
	tvstruct.item.mask = TVIF_CHILDREN|TVIF_HANDLE|TVIF_IMAGE|TVIF_SELECTEDIMAGE;
	GetItem( &tvstruct.item );
	sText = GetItemText( hItem );
	tvstruct.item.cchTextMax = sText.GetLength ();
	tvstruct.item.pszText = sText.LockBuffer ();

	tvstruct.hParent = htiNewParent;
	tvstruct.hInsertAfter = htiAfter;
	tvstruct.item.mask = TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_TEXT;
	hNewItem = InsertItem( &tvstruct );
	sText.ReleaseBuffer ();

	SetItemData( hNewItem,GetItemData(hItem) );
	SetItemState( hNewItem,GetItemState(hItem,TVIS_STATEIMAGEMASK),TVIS_STATEIMAGEMASK);
	Sort(htiNewParent);
	return hNewItem;
}
示例#8
0
void CSortListCtrl::OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult)
{
	//draw each item.set txt color,bkcolor....
	NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>(pNMHDR);
	
	// Take the default processing unless we set this to something else below.
	*pResult = CDRF_DODEFAULT;
	
	// First thing - check the draw stage. If it's the control's prepaint
	// stage, then tell Windows we want messages for every item.
	
	if (pLVCD->nmcd.dwDrawStage == CDDS_PREPAINT)
	{
		*pResult = CDRF_NOTIFYITEMDRAW;
	}
	else if (pLVCD->nmcd.dwDrawStage == CDDS_ITEMPREPAINT)
	{
		// This is the notification message for an item.  We'll request
		// notifications before each subitem's prepaint stage.
		
		*pResult = CDRF_NOTIFYSUBITEMDRAW;
	}
	else if (pLVCD->nmcd.dwDrawStage == (CDDS_ITEMPREPAINT | CDDS_SUBITEM))
	{
		// This is the prepaint stage for a subitem. Here's where we set the
		// item's text and background colors. Our return value will tell
		// Windows to draw the subitem itself, but it will use the new colors
		// we set here.
		
		int nItem = static_cast<int> (pLVCD->nmcd.dwItemSpec);
		int nSubItem = pLVCD->iSubItem;
		
		ItemData *pXLCD = (ItemData *) pLVCD->nmcd.lItemlParam;
		ASSERT(pXLCD);
		
		COLORREF crText  = crWindowText;
		COLORREF crBkgnd = crWindow;
		
		
		if (pXLCD){
			crText  = (pXLCD->crText)[nSubItem];
			crBkgnd = (pXLCD->crBak)[nSubItem];
		}
								
		
		
		// store the colors back in the NMLVCUSTOMDRAW struct
		pLVCD->clrText = crText;
		pLVCD->clrTextBk = crBkgnd;
		
		CDC* pDC = CDC::FromHandle(pLVCD->nmcd.hdc);
		CRect rect;
		GetSubItemRect(nItem, nSubItem, LVIR_BOUNDS, rect);
		if (GetItemState(nItem, LVIS_SELECTED))
			DrawText(nItem, nSubItem, pDC, crHighLightText, crHighLight , rect);
		else
			DrawText(nItem, nSubItem, pDC, crText, crBkgnd, rect);
				
		*pResult = CDRF_SKIPDEFAULT;	// We've painted everything.
	}
}
示例#9
0
void CLibraryFolderCtrl::OnLButtonDown(UINT nFlags, CPoint point)
{
	UINT nItemFlags = 0;
	HTREEITEM hItem = HitTest( point, &nItemFlags );

	if ( nItemFlags == TVHT_ONITEMBUTTON )
	{
		CTreeCtrl::OnLButtonDown( nFlags, point );
		return;
	}

	if ( ( nFlags & MK_CONTROL ) && m_bMultiSelect )
	{
		if ( hItem )
		{
			UINT nNewState = GetItemState( hItem, TVIS_SELECTED ) & TVIS_SELECTED ?
				0 : TVIS_SELECTED;

			SetItemState( hItem, nNewState,  TVIS_SELECTED );
			m_hFirstSelected = NULL;
			NotifySelectionChanged();
		}
	}
	else if ( ( nFlags & MK_SHIFT ) && m_bMultiSelect )
	{
		hItem = HitTest( point );

		if ( ! m_hFirstSelected ) m_hFirstSelected = GetFirstSelectedItem();

		if ( hItem ) SetItemState( hItem, TVIS_SELECTED, TVIS_SELECTED );

		if ( m_hFirstSelected ) SelectItems( m_hFirstSelected, hItem );

		NotifySelectionChanged();
	}
	else
	{
		BOOL bChanged = FALSE;

		BOOL bSelected = hItem && ( GetItemState( hItem, TVIS_SELECTED ) & TVIS_SELECTED );

		if ( ! bSelected || ( nFlags & MK_RBUTTON ) == 0 )
		{
			if ( m_bFirstClick && hItem != GetRootItem() )
			{
				Select( hItem, TVGN_CARET );
			}

			bChanged = ClearSelection( hItem );
			m_hFirstSelected = NULL;
		}

		if ( hItem )
		{
			if ( ! bSelected )
			{
				SetItemState( hItem, TVIS_SELECTED, TVIS_SELECTED );
				bChanged = TRUE;
			}
		}

		if ( bChanged ) NotifySelectionChanged();
	}

	m_bFirstClick = FALSE;

	SetFocus();
}
示例#10
0
void CGameListCtrl::OnRightClick(wxMouseEvent& event)
{
	// Focus the clicked item.
	int flags;
	long item = HitTest(event.GetPosition(), flags);
	if (item != wxNOT_FOUND)
	{
		if (GetItemState(item, wxLIST_STATE_SELECTED) != wxLIST_STATE_SELECTED)
		{
			UnselectAll();
			SetItemState(item, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
		}
		SetItemState(item, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED);
	}
	if (GetSelectedItemCount() == 1)
	{
		const GameListItem* selected_iso = GetSelectedISO();
		if (selected_iso)
		{
			wxMenu popupMenu;
			DiscIO::IVolume::EPlatform platform = selected_iso->GetPlatform();

			if (platform != DiscIO::IVolume::ELF_DOL)
			{
				popupMenu.Append(IDM_PROPERTIES, _("&Properties"));
				popupMenu.Append(IDM_GAME_WIKI, _("&Wiki"));
				popupMenu.AppendSeparator();
			}
			if (platform == DiscIO::IVolume::WII_DISC || platform == DiscIO::IVolume::WII_WAD)
			{
				popupMenu.Append(IDM_OPEN_SAVE_FOLDER, _("Open Wii &save folder"));
				popupMenu.Append(IDM_EXPORT_SAVE, _("Export Wii save (Experimental)"));
			}
			popupMenu.Append(IDM_OPEN_CONTAINING_FOLDER, _("Open &containing folder"));

			if (platform != DiscIO::IVolume::ELF_DOL)
				popupMenu.AppendCheckItem(IDM_SET_DEFAULT_ISO, _("Set as &default ISO"));

			// First we have to decide a starting value when we append it
			if (platform == SConfig::GetInstance().m_strDefaultISO)
				popupMenu.FindItem(IDM_SET_DEFAULT_ISO)->Check();

			popupMenu.AppendSeparator();
			popupMenu.Append(IDM_DELETE_ISO, _("&Delete File..."));

			if (platform == DiscIO::IVolume::GAMECUBE_DISC || platform == DiscIO::IVolume::WII_DISC)
			{
				if (selected_iso->GetBlobType() == DiscIO::BlobType::GCZ)
					popupMenu.Append(IDM_COMPRESS_ISO, _("Decompress ISO..."));
				else if (selected_iso->GetBlobType() == DiscIO::BlobType::PLAIN)
					popupMenu.Append(IDM_COMPRESS_ISO, _("Compress ISO..."));

				wxMenuItem* changeDiscItem = popupMenu.Append(IDM_LIST_CHANGE_DISC, _("Change &Disc"));
				changeDiscItem->Enable(Core::IsRunning());
			}

			if (platform == DiscIO::IVolume::WII_WAD)
				popupMenu.Append(IDM_LIST_INSTALL_WAD, _("Install to Wii Menu"));

			PopupMenu(&popupMenu);
		}
	}
	else if (GetSelectedItemCount() > 1)
	{
		wxMenu popupMenu;
		popupMenu.Append(IDM_DELETE_ISO, _("&Delete selected ISOs..."));
		popupMenu.AppendSeparator();
		popupMenu.Append(IDM_MULTI_COMPRESS_ISO, _("Compress selected ISOs..."));
		popupMenu.Append(IDM_MULTI_DECOMPRESS_ISO, _("Decompress selected ISOs..."));
		PopupMenu(&popupMenu);
	}
}
示例#11
0
void CLibraryFolderCtrl::Update(CLibraryFolder* pFolder, HTREEITEM hFolder, HTREEITEM hParent, DWORD nUpdateCookie, BOOL bRecurse)
{
	if ( ! hFolder )
	{
		DWORD dwStyle = INDEXTOOVERLAYMASK( pFolder->IsShared() ? 0 : SHI_O_LOCKED );

		if ( pFolder->m_sPath.CompareNoCase( Settings.Downloads.CompletePath ) == 0 ) dwStyle |= TVIS_BOLD;

		if ( m_bMultiSelect && GetFirstSelectedItem() == NULL ) dwStyle |= TVIS_SELECTED;
		if ( pFolder->m_bExpanded ) dwStyle |= TVIS_EXPANDED;

		CString strName = pFolder->m_sName;

		if ( pFolder->m_pParent == NULL )
		{
			CString strDrive;
			if ( pFolder->m_sPath.Find( _T(":\\") ) == 1 || pFolder->m_sPath.GetLength() == 2 )
				strDrive.Format( _T(" (%c:)"), pFolder->m_sPath[0] );
			else
				strDrive = _T(" (Net)");

			strName += strDrive;
			dwStyle |= TVIS_EXPANDED;
		}

		hFolder = InsertItem( TVIF_PARAM|TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_STATE,
			strName, SHI_FOLDER_CLOSED, SHI_FOLDER_CLOSED, dwStyle,
			TVIS_EXPANDED|TVIS_SELECTED|TVIS_OVERLAYMASK, (LPARAM)pFolder, hParent, TVI_SORT );
	}
	else
	{
		DWORD dwMask = TVIS_OVERLAYMASK | TVIS_BOLD;
		DWORD dwStyle = INDEXTOOVERLAYMASK( pFolder->IsShared() ? 0 : SHI_O_LOCKED );

		if ( pFolder->m_sPath.CompareNoCase( Settings.Downloads.CompletePath ) == 0 ) dwStyle |= TVIS_BOLD;

		DWORD dwExisting = GetItemState( hFolder, dwMask ) & dwMask;

		if ( dwExisting != dwStyle ) SetItemState( hFolder, dwStyle, dwMask );
	}

	if ( nUpdateCookie )
	{
		if ( bRecurse || ( GetItemState( hFolder, TVIS_SELECTED ) & TVIS_SELECTED ) )
		{
			pFolder->m_nSelectCookie = nUpdateCookie;
			bRecurse |= ( GetItemState( hFolder, TVIS_EXPANDED ) & TVIS_EXPANDED ) == 0;
		}
	}

	CList< CLibraryFolder* > pAlready;

	for ( HTREEITEM hItem = GetChildItem( hFolder ) ; hItem ; )
	{
		HTREEITEM hNext = GetNextSiblingItem( hItem );

		CLibraryFolder* pChild = (CLibraryFolder*)GetItemData( hItem );

		if ( pFolder->CheckFolder( pChild ) )
		{
			Update( pChild, hItem, NULL, nUpdateCookie, bRecurse );
			pAlready.AddTail( pChild );
		}
		else
		{
			DeleteItem( hItem );
		}

		hItem = hNext;
	}

	for ( POSITION pos = pFolder->GetFolderIterator() ; pos ; )
	{
		CLibraryFolder* pChild = pFolder->GetNextFolder( pos );

		if ( pAlready.Find( pChild ) == NULL )
		{
			Update( pChild, NULL, hFolder, nUpdateCookie, bRecurse );
		}
	}

	int nOldImage1, nOldImage2;
	GetItemImage( hFolder, nOldImage1, nOldImage2 );

	int nImage = ItemHasChildren( hFolder ) && ( GetItemState( hFolder, TVIS_EXPANDED ) & TVIS_EXPANDED );
	nImage = nImage ? SHI_FOLDER_OPEN : SHI_FOLDER_CLOSED;
	if ( nOldImage1 != nImage ) SetItemImage( hFolder, nImage, nImage );
}
BOOL CDragDropTreeCtrl::IsItemExpanded(HTREEITEM hItem)
{
    return GetItemState(hItem, TVIS_EXPANDED) & TVIS_EXPANDED;
}
//绘画子项
VOID CServerItemView::DrawTreeItem(CDC * pDC, CRect & rcClient, CRect & rcClipBox)
{
	//首项判断
	HTREEITEM hItemCurrent=GetFirstVisibleItem();
	if (hItemCurrent==NULL) return;

	//获取属性
	UINT uTreeStyte=GetWindowLong(m_hWnd,GWL_STYLE);

	////获取对象
	//ASSERT(CSkinRenderManager::GetInstance()!=NULL);
	//CSkinRenderManager * pSkinRenderManager=CSkinRenderManager::GetInstance();

	//绘画子项
	do
	{
		//变量定义
		CRect rcItem;
		CRect rcRect;

		//获取状态
		HTREEITEM hParent=GetParentItem(hItemCurrent);
		UINT uItemState=GetItemState(hItemCurrent,TVIF_STATE);

		//获取属性
		bool bDrawChildren=(ItemHasChildren(hItemCurrent)==TRUE);
		bool bDrawSelected=(uItemState&TVIS_SELECTED)&&((this==GetFocus())||(uTreeStyte&TVS_SHOWSELALWAYS));

		//获取区域
		if (GetItemRect(hItemCurrent,rcItem,TRUE))
		{
			//绘画过滤
			if (rcItem.top>=rcClient.bottom)
				break;
			if (rcItem.top>=rcClipBox.bottom)
				continue;

			//设置位置
			rcRect.left=0;
			rcRect.top=rcItem.top+1;
			rcRect.bottom=rcItem.bottom;
			rcRect.right=rcClient.Width();

			//绘画选择
			if (bDrawSelected==true)
			{
				pDC->FillSolidRect(&rcRect,RGB(253,231,161));
			}

			//绘画经过
			if ((bDrawSelected==false)&&(m_hItemMouseHover==hItemCurrent))
			{
				pDC->FillSolidRect(&rcRect,RGB(157,182,249));
			}

			//绘制箭头
			if (bDrawChildren==true)
			{
				//计算位置
				INT nXPos=rcItem.left-m_ImageArrow.GetWidth()/2-25;
				INT nYPos=rcItem.top+1+(rcItem.Height()-m_ImageArrow.GetHeight())/2;

				//绘画图标
				INT nIndex=(uItemState&TVIS_EXPANDED)?1L:0L;
				m_ImageArrow.DrawImage(pDC,nXPos,nYPos,m_ImageArrow.GetWidth()/2,m_ImageArrow.GetHeight(),nIndex*m_ImageArrow.GetWidth()/2,0);
			}

			//绘制列表
			DrawListImage(pDC,rcItem,hItemCurrent);	

			rcItem.right+=20;
			//绘制文本
			DrawItemString(pDC,rcItem,hItemCurrent,bDrawSelected);
		}
	} while ((hItemCurrent=GetNextVisibleItem(hItemCurrent))!= NULL);

	return;
}
示例#14
0
void ProcList::displayList()
{
	theMainWin->setProgress(L"Saving list state...");
	std::unordered_map<Database::Address, int> item_state;
	// TODO: use GetNextItem?
	for (long i=0; i<GetItemCount(); i++)
		if (int state = GetItemState(i, wxLIST_STATE_FOCUSED|wxLIST_STATE_SELECTED))
			item_state[GetItemData(i)] = state;

	theMainWin->setProgress(L"Clearing list...");
	Freeze();
	DeleteAllItems();

	theMainWin->setProgress(L"Populating list...", list.items.size());
	const ViewState *viewstate = theMainWin->getViewState();

	for (auto i = list.items.begin(); i != list.items.end(); ++i)
	{
		const Database::Symbol *sym = i->symbol;

		if (isroot && set_get(viewstate->filtered, sym->address))
			continue;

		long c = GetItemCount();

		wxListItem item;
		item.SetId(c);
		item.SetText(sym->procname);

		if (sym->isCollapseFunction || sym->isCollapseModule)
			item.SetTextColour(wxColor(0,128,0));

		if (set_get(viewstate->highlighted, sym->address))
			item.SetBackgroundColour(wxColor(255,255,0));

		int state = map_get(item_state, sym->address, 0);
		item.SetData(sym->address);
		item.SetState(state);
		item.SetStateMask(wxLIST_STATE_FOCUSED|wxLIST_STATE_SELECTED);

		InsertItem(item);

		wxString inclusive = wxString::Format("%0.2fs", i->inclusive);
		wxString exclusive = wxString::Format("%0.2fs", i->exclusive);
		wxString inclusivepercent = wxString::Format("%0.2f%%", i->inclusive * 100.0f / list.totalcount);
		wxString exclusivepercent = wxString::Format("%0.2f%%", i->exclusive * 100.0f / list.totalcount);

		setColumnValue(c, COL_EXCLUSIVE,	exclusive);
		setColumnValue(c, COL_INCLUSIVE,	inclusive);
		setColumnValue(c, COL_EXCLUSIVEPCT,	exclusivepercent);
		setColumnValue(c, COL_INCLUSIVEPCT,	inclusivepercent);
		setColumnValue(c, COL_SAMPLES,		exclusive);
		setColumnValue(c, COL_CALLSPCT,		exclusivepercent);
		setColumnValue(c, COL_MODULE,		database->getModuleName(sym->module));
		setColumnValue(c, COL_SOURCEFILE,	database->getFileName  (sym->sourcefile));
		setColumnValue(c, COL_SOURCELINE,	::toString((int)database->getAddrInfo(i->address)->sourceline));
		setColumnValue(c, COL_ADDRESS,	    ::toHexString(i->address));

		if (state & wxLIST_STATE_FOCUSED)
			EnsureVisible(c);

		theMainWin->updateProgress(i-list.items.begin());
	}

	Thaw();
	theMainWin->setProgress(NULL);
}
示例#15
0
// Returns bold state for an otem
BOOL CMyTreeCtrl::GetItemBold(HTREEITEM hItem)
{
	return GetItemState( hItem, TVIS_BOLD ) & TVIS_BOLD;
}
bool
TListViewCtrl::IsSelected(int index) const
{
  return GetItemState(index, LVIS_SELECTED);
}
示例#17
0
void CEnListCtrl::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) 
{
	CDC* pDC;
	CRect rText, rItem, rClient, rHeader;
	COLORREF crOldText, crOldBack;
	CSize sizeText;
	LV_COLUMN lvc = { 0 };
//	CPen* pOldPen;
	CImageList* pImageList;
	CImageList* pStateList;
	int nImage = -1;
	BOOL bItemFocused, bListFocused, bSelected, bDropHighlighted, bSelAlways;
	UINT uStyle, uState;
	CSize sizeState(0, 0), sizeImage(0, 0);
	int nIndent = 0;

	// get and prepare device context
	pDC = CDC::FromHandle(lpDrawItemStruct->hDC);//GetDC(); 
	pDC->SelectObject(GetFont());
	pDC->SetROP2(R2_COPYPEN);

	// init helper variables
	int nItem = lpDrawItemStruct->itemID;
	GetItemRect(nItem, rItem, LVIR_BOUNDS);//lpDrawItemStruct->rcItem;
	GetClientRect(&rClient);

	// some problems with drophiliting items during drag and drop
	// so we need to make sure drawing is clipped to client area
	// this fixes it admirably!
	if (GetHeader())
	{
		GetHeader()->GetWindowRect(rHeader);
		ScreenToClient(rHeader);
		rClient.top = max(0, rHeader.bottom);
		pDC->IntersectClipRect(rClient);
	}

	rText = rItem;

	uStyle = GetStyle();
	uState = GetItemState(nItem, LVIS_DROPHILITED | LVIS_SELECTED);
	bDropHighlighted = (uState & LVIS_DROPHILITED);
	bItemFocused = (GetFocusedItem() == nItem);
	bListFocused = (GetFocus() == this);
	bSelected = (uState & LVIS_SELECTED);
	bSelAlways = ((uStyle & LVS_SHOWSELALWAYS) == LVS_SHOWSELALWAYS);
	bSelected = bSelected && (bListFocused || bSelAlways);

	crOldText = pDC->SetTextColor(COLORREF(0)); // this will be overwritten on a per subitem basis
	crOldBack = pDC->SetBkColor(GetItemBackColor(nItem, bSelected, bDropHighlighted, bListFocused));

	// images and indentation
	pImageList = GetImageList(LVSIL_SMALL);

	if (pImageList)
	{
		nImage = GetImageIndex(nItem, 0); 
		ImageList_GetIconSize(pImageList->m_hImageList, (int*)&sizeImage.cx, (int*)&sizeImage.cy);

		nIndent = GetItemIndent(nItem) * sizeImage.cx;

		rText.left += nIndent;
		rItem.left += nIndent;

//		if (pImageList == &s_ilIndent)
//			pImageList = NULL;
	}

	// state
	pStateList = GetImageList(LVSIL_STATE);

	if (pStateList)
		ImageList_GetIconSize(pStateList->m_hImageList, (int*)&sizeState.cx, (int*)&sizeState.cy);

	if (lpDrawItemStruct->itemAction & (ODA_DRAWENTIRE | ODA_SELECT))
	{
		// setup colors and pens
		int nImageStyle = GetImageStyle(bSelected, bDropHighlighted, bListFocused);

		// draw item images if required
		int nImageWidth = 0;

		// make sure there is enough space
		lvc.mask = LVCF_WIDTH | LVCF_FMT;
		int nCol = 0;
		BOOL bRes = GetColumn(nCol, &lvc);
		
		// must paint the background of column 0 before the icons
		if (bRes && (pStateList || pImageList))
			pDC->ExtTextOut(0, rItem.top, ETO_CLIPPED | ETO_OPAQUE, CRect(0, rItem.top, lvc.cx, rItem.bottom), _T(""), NULL);

		// state
		if (pStateList && bRes)
		{
			int nState = (GetItemState(nItem, LVIS_STATEIMAGEMASK) & LVIS_STATEIMAGEMASK);
			nState = nState >> 12;

			if (lvc.cx > sizeState.cx)
				pStateList->Draw(pDC, nState, CPoint(rText.left + 1, rText.top), ILD_TRANSPARENT); 

			nImageWidth = sizeState.cx + 2; // 1 pixel border either side
		}
示例#18
0
VOID CEasySkinTreeCtrl::DrawTreeItem( CDC * pDC, CRect & rcClient, CRect & rcClipBox )
{
	//首项判断
	HTREEITEM hItemCurrent=GetFirstVisibleItem();
	if (hItemCurrent==NULL) return;

	//获取属性
	UINT uTreeStyte = GetStyle();

	//绘画子项
	do
	{
		//变量定义
		CRect rcItem;
		CRect rcRect;

		//获取状态
		HTREEITEM hParent=GetParentItem(hItemCurrent);
		UINT uItemState=GetItemState(hItemCurrent,TVIF_STATE);

		//获取属性
		bool bDrawChildren=(ItemHasChildren(hItemCurrent)==TRUE);
		bool bDrawSelected=(uItemState&TVIS_SELECTED)&&((this==GetFocus())||(uTreeStyte&TVS_SHOWSELALWAYS));

		//获取区域
		if (GetItemRect(hItemCurrent,rcItem,TRUE))
		{
			//绘画过滤
			if (rcItem.top>=rcClient.bottom) break;
			if (rcItem.top>=rcClipBox.bottom) continue;

			//设置位置
			rcRect.left=0;
			rcRect.top=rcItem.top+1;
			rcRect.bottom=rcItem.bottom;
			rcRect.right=rcClient.Width();

			//绘画选择
			if (bDrawSelected)
			{
				if (m_pPressImg != NULL && !m_pPressImg->IsNull())
					m_pPressImg->Draw(pDC,rcRect);
				else
					pDC->FillSolidRect(&rcRect,m_colPress);
			}

			//绘画经过
 			if ((bDrawSelected==false)&&(m_hItemMouseHover==hItemCurrent))
 			{
				if (m_pHovenImg != NULL && !m_pHovenImg->IsNull())
					m_pHovenImg->Draw(pDC,rcRect);
				else
 					pDC->FillSolidRect(&rcRect,m_colHoven);
 			}

			//绘制箭头
 			if (bDrawChildren && (uTreeStyte&TVS_HASBUTTONS) )
 			{
				if (m_pImageButton != NULL && !m_pImageButton->IsNull())
				{
					//计算位置
					INT nXPos=rcItem.left-m_pImageButton->GetWidth()/2;
					INT nYPos=rcItem.top+1+(rcItem.Height()-m_pImageButton->GetHeight())/2;

					//绘画图标
					INT nIndex=(uItemState&TVIS_EXPANDED)?1L:0L;
					m_pImageButton->DrawImage(pDC,nXPos,nYPos,m_pImageButton->GetWidth()/2,m_pImageButton->GetHeight(),nIndex*m_pImageButton->GetWidth()/2,0);
				
					rcItem.left += m_pImageButton->GetWidth();
					rcItem.right += m_pImageButton->GetWidth();;
				}

 			}

			//绘制列表
			DrawListImage(pDC,rcItem,hItemCurrent,bDrawSelected);	

			//绘制文本
			DrawItemString(pDC,rcItem,hItemCurrent,bDrawSelected);
		}
	} while ((hItemCurrent=GetNextVisibleItem(hItemCurrent))!= NULL);
}
示例#19
0
void wxGxContentView::SelectItem(int nChar, bool bShift)
{
    long nSelItemMax = nChar == WXK_DOWN ? GetItemCount() - 1 : 0;
    long nSelItemNext = nChar == WXK_DOWN ? 0 : GetItemCount() - 1;
    long nSelItemNextAdd = nChar == WXK_DOWN ? 1 : -1;
    long nSelItem = GetNextItem(wxNOT_FOUND, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
    if (bShift)
    {
        if (nSelItem == wxNOT_FOUND && m_HighLightItem == wxNOT_FOUND)
        {
            SetItemState(nSelItemNext, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
        }

        bool bSwitchDirection = false;

        if (m_bPrevChar == WXK_UP || m_bPrevChar == WXK_DOWN)
        {
            bSwitchDirection = m_bPrevChar != nChar;
        }

        if (bSwitchDirection)
        {
            nSelItemNextAdd = 0;
        }
        m_bPrevChar = nChar;

        long nSelItemNextNorm;
        if (m_HighLightItem == wxNOT_FOUND)
        {
            nSelItemNextNorm = nSelItem + nSelItemNextAdd;
        }
        else
        {
            nSelItemNextNorm = m_HighLightItem + nSelItemNextAdd;
        }
        m_HighLightItem = nSelItemNextNorm;

        if (nSelItemNextNorm == -1 || nSelItemNextNorm == GetItemCount())
            return;

        int nMask = GetItemState(nSelItemNextNorm, wxLIST_STATE_SELECTED);
        if (nMask == wxLIST_STATE_SELECTED)
        {
            SetItemState(nSelItemNextNorm, wxLIST_STATE_DONTCARE, wxLIST_STATE_SELECTED);
        }
        else
        {
            SetItemState(nSelItemNextNorm, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
        }
    }
    else
    {
        if (nSelItem == wxNOT_FOUND)
        {
            SetItemState(nSelItemNext, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
        }
        else
        {

            if (m_HighLightItem != wxNOT_FOUND)
            {
                for (long item = 0; item < GetItemCount(); ++item)
                    SetItemState(item, wxLIST_STATE_DONTCARE, wxLIST_STATE_SELECTED);
                nSelItem = m_HighLightItem;
                m_HighLightItem = wxNOT_FOUND;
            }

            SetItemState(nSelItem, wxLIST_STATE_DONTCARE, wxLIST_STATE_SELECTED);
            if (nSelItem == nSelItemMax)
            {
                SetItemState(nSelItemNext, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
            }
            else
            {
                SetItemState(nSelItem + nSelItemNextAdd, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
            }
        }
    }
}
示例#20
0
// Draw TreeCtrl Items
void VividTree::DrawItems( CDC *pDC )
{
	// draw items
	HTREEITEM show_item, parent;
	CRect rc_item;
	CString name;
	COLORREF color;
	DWORD tree_style;
	BITMAP bm;
	CDC dc_mem;
	CBitmap *button;
	int count = 0;
	int state;
	bool selected;
	bool has_children;

	show_item = GetFirstVisibleItem();
	if ( show_item == NULL )
		return;

	dc_mem.CreateCompatibleDC(NULL);
	color = pDC->GetTextColor();
	tree_style = ::GetWindowLong( m_hWnd, GWL_STYLE ); 

	do
	{
		state = GetItemState( show_item, TVIF_STATE );
		parent = GetParentItem( show_item );
		has_children = ItemHasChildren( show_item ) || parent == NULL;
		selected = (state & TVIS_SELECTED) && ((this == GetFocus()) || 
				(tree_style & TVS_SHOWSELALWAYS));

		if ( GetItemRect( show_item, rc_item, TRUE ) )
		{
			if( selected)
			{
				CRect rc_all;
				GetItemRect(show_item,&rc_all, FALSE);
				pDC->FillSolidRect(&rc_all, RGB(170,155,119));
			}
			if ( has_children  || selected )
			{
				COLORREF from;
				CRect rect;
				// Show 
				if ( selected )
					from = m_gradient_bkgd_sel;
				else
					from = m_gradient_bkgd_to - (m_gradient_bkgd_from - m_gradient_bkgd_to);
				rect.top = rc_item.top;
				rect.bottom = rc_item.bottom;
				rect.right = m_h_size + m_h_offset;
				if ( !has_children )
					rect.left = rc_item.left + m_h_offset;
				else
					rect.left = m_h_offset;
				//GradientFillRect( pDC, rect, from, m_gradient_bkgd_to, FALSE );
				//pDC->SetTextColor( RGB( 0, 0, 255 ) );
				pDC->SetTextColor(GetSysColor(COLOR_HIGHLIGHTTEXT));

				if ( has_children )
				{
					// Draw an Open/Close button
					if ( state & TVIS_EXPANDED )
						button = &m_bmp_tree_open;
					else
						button = &m_bmp_tree_closed;
					VERIFY(button->GetObject(sizeof(bm), (LPVOID)&bm));
					CBitmap *bmp_old = (CBitmap*)dc_mem.SelectObject(button); 
					pDC->TransparentBlt(rc_item.left - bm.bmWidth - 2, rc_item.top, bm.bmWidth, bm.bmHeight, 
						&dc_mem, 0, 0,bm.bmWidth,bm.bmWidth, GetSysColor(COLOR_HIGHLIGHTTEXT));
					//pDC->BitBlt( rc_item.left - bm.bmWidth - 2, rc_item.top, bm.bmWidth, bm.bmHeight, 
					//	&dc_mem, 0, 0, SRCCOPY );
					// CleanUp
					dc_mem.SelectObject( bmp_old );
				}
			}
			if ( !has_children )
			{
				// lookup the ICON instance (if any) and draw it
				HICON icon;
				icon = GetItemIcon( show_item );
				if ( icon != NULL )
					DrawIconEx( pDC->m_hDC, rc_item.left - 18, rc_item.top, icon, 16, 16,0,0, DI_NORMAL );
			}
			name = GetItemText( show_item );
			rc_item.DeflateRect( 0,1,0,1 );
			if ( selected )
			{
				if ( !has_children  )
					pDC->SetTextColor( GetSysColor(COLOR_HIGHLIGHTTEXT) );
				COLORREF col = pDC->GetBkColor();
				//pDC->SetBkColor( /*GetSysColor(COLOR_HIGHLIGHT)*/RGB(170,155,119) );
				pDC->DrawText( name, rc_item, DT_LEFT );
				pDC->SetTextColor( color );
				pDC->SetBkColor( col );
			}
			else
			{
				pDC->SetTextColor( GetSysColor(COLOR_HIGHLIGHTTEXT) );
				pDC->DrawText( name, rc_item, DT_LEFT );
				pDC->SetTextColor( color );
			}
			//if ( state & TVIS_BOLD )
			//	pDC->SelectObject( font );
		}
	} while ( (show_item = GetNextVisibleItem( show_item )) != NULL );
}
示例#21
0
void CGameListCtrl::OnRightClick(wxMouseEvent& event)
{	
	// Focus the clicked item.
	int flags;
	long item = HitTest(event.GetPosition(), flags);
	if (item != wxNOT_FOUND)
	{
		if (GetItemState(item, wxLIST_STATE_SELECTED) != wxLIST_STATE_SELECTED)
		{
			UnselectAll();
			SetItemState(item, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
		}
		SetItemState(item, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED);
	}
	if (GetSelectedItemCount() == 1)
	{
		const GameListItem *selected_iso = GetSelectedISO();
		if (selected_iso)
		{
			wxMenu* popupMenu = new wxMenu;
			popupMenu->Append(IDM_PROPERTIES, _("&Properties"));
			popupMenu->Append(IDM_GAMEWIKI, _("&Wiki"));
			popupMenu->AppendSeparator();

			if (selected_iso->GetPlatform() != GameListItem::GAMECUBE_DISC)
			{
				popupMenu->Append(IDM_OPENSAVEFOLDER, _("Open Wii &save folder"));
				popupMenu->Append(IDM_EXPORTSAVE, _("Export Wii save (Experimental)"));
			}
			popupMenu->Append(IDM_OPENCONTAININGFOLDER, _("Open &containing folder"));
			popupMenu->AppendCheckItem(IDM_SETDEFAULTGCM, _("Set as &default ISO"));

			// First we have to decide a starting value when we append it
			if(selected_iso->GetFileName() == SConfig::GetInstance().
				m_LocalCoreStartupParameter.m_strDefaultGCM)
				popupMenu->FindItem(IDM_SETDEFAULTGCM)->Check();

			popupMenu->AppendSeparator();
			popupMenu->Append(IDM_DELETEGCM, _("&Delete ISO..."));

			if (selected_iso->GetPlatform() != GameListItem::WII_WAD)
			{
				if (selected_iso->IsCompressed())
					popupMenu->Append(IDM_COMPRESSGCM, _("Decompress ISO..."));
				else if (selected_iso->GetFileName().substr(selected_iso->GetFileName().find_last_of(".")) != ".ciso" 
						 && selected_iso->GetFileName().substr(selected_iso->GetFileName().find_last_of(".")) != ".wbfs")
					popupMenu->Append(IDM_COMPRESSGCM, _("Compress ISO..."));
			} else
				popupMenu->Append(IDM_LIST_INSTALLWAD, _("Install to Wii Menu"));

			PopupMenu(popupMenu);
		}
	}
	else if (GetSelectedItemCount() > 1)
	{
		wxMenu* popupMenu = new wxMenu;
		popupMenu->Append(IDM_DELETEGCM, _("&Delete selected ISOs..."));
		popupMenu->AppendSeparator();
		popupMenu->Append(IDM_MULTICOMPRESSGCM, _("Compress selected ISOs..."));
		popupMenu->Append(IDM_MULTIDECOMPRESSGCM, _("Decompress selected ISOs..."));
		PopupMenu(popupMenu);
	}
}
示例#22
0
void CLocalListView::RefreshFile(const wxString& file)
{
	CLocalFileData data;

	bool wasLink;
	enum CLocalFileSystem::local_fileType type = CLocalFileSystem::GetFileInfo(m_dir + file, wasLink, &data.size, &data.lastModified, &data.attributes);
	if (type == CLocalFileSystem::unknown)
		return;

	data.flags = normal;
	data.icon = -2;
	data.name = file;
#ifdef __WXMSW__
	data.label = file;
#endif
	data.dir = type == CLocalFileSystem::dir;

	CFilterManager filter;
	if (filter.FilenameFiltered(data.name, m_dir, data.dir, data.size, true, data.attributes, data.lastModified))
		return;

	CancelLabelEdit();

	// Look if file data already exists
	unsigned int i = 0;
	for (std::vector<CLocalFileData>::iterator iter = m_fileData.begin(); iter != m_fileData.end(); ++iter, ++i)
	{
		const CLocalFileData& oldData = *iter;
		if (oldData.name != file)
			continue;

		// Update file list status bar
		if (m_pFilelistStatusBar)
		{
#ifndef __WXMSW__
			// GetNextItem is O(n) if nothing is selected, GetSelectedItemCount() is O(1)
			if (GetSelectedItemCount())
#endif
			{
				int item = -1;
				for (;;)
				{
					item = GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
					if (item == -1)
						break;
					if (m_indexMapping[item] != i)
						continue;

					if (oldData.dir)
						m_pFilelistStatusBar->UnselectDirectory();
					else
						m_pFilelistStatusBar->UnselectFile(oldData.size);
					if (data.dir)
						m_pFilelistStatusBar->SelectDirectory();
					else
						m_pFilelistStatusBar->SelectFile(data.size);
					break;
				}
			}

			if (oldData.dir)
				m_pFilelistStatusBar->RemoveDirectory();
			else
				m_pFilelistStatusBar->RemoveFile(oldData.size);
			if (data.dir)
				m_pFilelistStatusBar->AddDirectory();
			else
				m_pFilelistStatusBar->AddFile(data.size);
		}

		// Update the data
		data.fileType = oldData.fileType;

		*iter = data;
		if (IsComparing())
		{
			// Sort order doesn't change
			RefreshComparison();
		}
		else
		{
			if (m_sortColumn)
				SortList();
			RefreshListOnly(false);
		}
		return;
	}

	if (data.dir)
		m_pFilelistStatusBar->AddDirectory();
	else
		m_pFilelistStatusBar->AddFile(data.size);

	wxString focused;
	std::list<wxString> selectedNames;
	if (IsComparing())
	{
		wxASSERT(!m_originalIndexMapping.empty());
		selectedNames = RememberSelectedItems(focused);
		m_indexMapping.clear();
		m_originalIndexMapping.swap(m_indexMapping);
	}

	// Insert new entry
	int index = m_fileData.size();
	m_fileData.push_back(data);

	// Find correct position in index mapping
	std::vector<unsigned int>::iterator start = m_indexMapping.begin();
	if (m_hasParent)
		++start;
	CFileListCtrl<CLocalFileData>::CSortComparisonObject compare = GetSortComparisonObject();
	std::vector<unsigned int>::iterator insertPos = std::lower_bound(start, m_indexMapping.end(), index, compare);
	compare.Destroy();

	const int item = insertPos - m_indexMapping.begin();
	m_indexMapping.insert(insertPos, index);

	if (!IsComparing())
	{
		SetItemCount(m_indexMapping.size());

		// Move selections
		int prevState = 0;
		for (unsigned int i = item; i < m_indexMapping.size(); i++)
		{
			int state = GetItemState(i, wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);
			if (state != prevState)
			{
				SetItemState(i, prevState, wxLIST_STATE_FOCUSED);
				SetSelection(i, (prevState & wxLIST_STATE_SELECTED) != 0);
				prevState = state;
			}
		}
		RefreshListOnly();
	}
	else
	{
		RefreshComparison();
		if (m_pFilelistStatusBar)
			m_pFilelistStatusBar->UnselectAll();
		ReselectItems(selectedNames, focused);
	}
}
void CListCtrlEx::DrawItem(LPDRAWITEMSTRUCT lpDraw)
{try{
	int cCols = GetHeaderCtrl ()->GetItemCount ();
	CDC *dc = CDC::FromHandle (lpDraw->hDC);
	int xStart = lpDraw->rcItem.left;	
	CImageList *pImages = GetImageList (LVSIL_SMALL);
	BOOL bNeedBorder = FALSE;	

	

	CHeaderCtrl* pHdr = GetHeaderCtrl ();

	
	for (int i = 0; i < cCols; i++)
	{
		LVITEM item;
		TCHAR szItem [10000];
		int colWidth = GetColumnWidth (pHdr->OrderToIndex (i));

		xStart += 5;
		colWidth -= 5;

		item.iItem = lpDraw->itemID;
		item.iSubItem = i;
		item.pszText = szItem;
		item.cchTextMax = sizeof (szItem);
		item.mask = LVIF_IMAGE | LVIF_TEXT;

		GetItem (&item);

		
		if (i == 0)
		{
			item.state = GetItemState (lpDraw->itemID, LVIS_SELECTED|LVIS_FOCUSED);

			COLORREF clrBg = m_vInfo [lpDraw->itemID].clrBg;
			COLORREF clrText = m_vInfo [lpDraw->itemID].clrText;
	
			
			
			if (item.state & LVIS_FOCUSED)
				bNeedBorder = TRUE;

			if (item.state & LVIS_SELECTED)
			{
				clrBg = GetSysColor (COLOR_HIGHLIGHT);
				clrText = GetSysColor (COLOR_HIGHLIGHTTEXT);
				if (bNeedBorder == FALSE)
				{
					if (GetSelectionMark () == (int)lpDraw->itemID)
						bNeedBorder = TRUE;
				}
			}
		
			CBrush br;
			CPen pen;
			CBrush *oldBr;
			CPen *oldPen;

			if (RGBIsEqual (clrBg, clrText))
				clrText = (~clrText) & 0x00FFFFFF;

			dc->SetTextColor (clrText);

			br.CreateSolidBrush (clrBg);
			pen.CreatePen (PS_SOLID, 1, clrBg);

			oldBr = dc->SelectObject (&br);
			oldPen = dc->SelectObject (&pen);
			
			dc->Rectangle (&lpDraw->rcItem);

			
			if (m_bGrid)
			{
				CPen pen1 (PS_SOLID, 1, m_clrGrid);
				dc->SelectObject (&pen1);
				dc->MoveTo (lpDraw->rcItem.left, lpDraw->rcItem.bottom-1);
				dc->LineTo (lpDraw->rcItem.right, lpDraw->rcItem.bottom-1);
				dc->SelectObject (oldPen);
			}

			dc->SelectObject (oldBr);
			dc->SelectObject (oldPen);

			if (pImages)
			{
				

				CPoint pt;
				pt.x = xStart;
				pt.y = lpDraw->rcItem.top;
				if (m_pSelImages && (item.state & LVIS_SELECTED))
					m_pSelImages->Draw (dc, item.iImage, pt, ILD_TRANSPARENT);
				else
					pImages->Draw (dc, item.iImage, pt, ILD_TRANSPARENT);

				IMAGEINFO inf;
				pImages->GetImageInfo (item.iImage, &inf);

				xStart += inf.rcImage.right - inf.rcImage.left + 5;
				colWidth -= inf.rcImage.right - inf.rcImage.left + 5;
			}
		}

		if (*item.pszText)
		{
			

			int needX = GetStringWidth (item.pszText);
			BOOL bDrawText = TRUE;

			RECT rcText = lpDraw->rcItem;
			rcText.left = xStart;
			rcText.right = xStart + colWidth - 5;

			
			if (needX > colWidth-5)
			{
				RECT rc = rcText;
				int dx = GetStringWidth ("...");
				if (dx <= colWidth-5)
				{
					rc.left = rc.right - dx;
					dc->DrawText ("...", &rc, DT_SINGLELINE | DT_LEFT | DT_VCENTER);
					rcText.right = rc.left - 5;
				}
				else
					bDrawText = FALSE;
			}

			if (bDrawText)
				dc->DrawText (szItem, &rcText, DT_SINGLELINE | DT_LEFT | DT_VCENTER | DT_NOPREFIX);
		}

		xStart += colWidth;

		
		if (m_bGrid)
		{
			
			CPen pen (PS_SOLID, 1, m_clrGrid);
			CPen *oldPen = dc->SelectObject (&pen);
			dc->MoveTo (xStart-1, lpDraw->rcItem.top);
			dc->LineTo (xStart-1, lpDraw->rcItem.bottom);
			dc->SelectObject (oldPen);
		}
	}

	if (bNeedBorder)
	{
		

		dc->SetTextColor (m_vInfo [lpDraw->itemID].clrText);
		RECT rc = lpDraw->rcItem;
		rc.bottom--; rc.right--;
		dc->DrawFocusRect (&rc);
	}

}catch (...){}
}
示例#24
0
/************************************************************************
customdraw_DrawBkgnd 그리기 요소의 배경 그리기
@PARAM  : 
@RETURN : 
@REMARK : 
@AUTHOR : youngchang ([email protected])
@HISTORY :
    2006/03/21:CREATED
************************************************************************/
void CFishListCtrl::customdraw_DrawBkgnd(CDC* pDC, NMLVCUSTOMDRAW* pLVCD)
{
    enum {  EVEN = 0,   ODD = 1,    };

    CRect clientRT;
    GetClientRect(&clientRT);

    CRect rect;
    GetSubItemRect(pLVCD->nmcd.dwItemSpec, pLVCD->iSubItem, LVIR_LABEL, rect);
    
    // 배경색 지정하기
    if( GetItemState(pLVCD->nmcd.dwItemSpec, LVIS_SELECTED) & LVIS_SELECTED )
    {
        if (pLVCD->iSubItem ==  FISH_VIEWINFO_LISTCTRL_ICON_INDEX)  {
            rect.left   =   0;
            rect.right  =   1024;
        }   
        
        if( GetFocus() == (CWnd*)this)
        {
            if (pLVCD->iSubItem  ==  0)
            {
                int nWidth  =   0;
                for (int it = 0; it < GetHeaderCtrl()->GetItemCount(); it++)
                {
                    nWidth  +=  GetColumnWidth(it);
                }
                
                CClientDC dc(this);
                CRect rt;
                GetClientRect(&rt);
                rt.left =   nWidth;
                rt.top  =   rect.top;
                rt.bottom   =   rect.bottom;
                dc.FillRect( &rt, &CBrush(FISH_VIEWINFO_LISTCTRL_BGCOLOR_S) );
            }

            pDC->FillRect( rect, &CBrush(FISH_VIEWINFO_LISTCTRL_BGCOLOR_S) );
            //                      pDC->FillRect( clientRT, &CBrush(FISH_VIEWINFO_LISTCTRL_SELROW_BGCOLOR) );
            pDC->SetTextColor(FISH_VIEWINFO_LISTCTRL_FGCOLOR_S);
        }   else   {
            if (pLVCD->iSubItem  ==  0)
            {
                int nWidth  =   0;
                for (int it = 0; it < GetHeaderCtrl()->GetItemCount(); it++)
                {
                    nWidth  +=  GetColumnWidth(it);
                }
                
                CClientDC dc(this);
                CRect rt;
                GetClientRect(&rt);
                rt.left =   nWidth;
                rt.top  =   rect.top;
                rt.bottom   =   rect.bottom;
                dc.FillRect( &rt, &CBrush(FISH_VIEWINFO_LISTCTRL_BGCOLOR_NF) );
            }
            
            pDC->FillRect( rect, &CBrush(FISH_VIEWINFO_LISTCTRL_BGCOLOR_NF) );
            //                      pDC->FillRect( itemRT, &CBrush(FISH_VIEWINFO_LISTCTRL_SELROW_BGCOLOR) );
            pDC->SetTextColor(FISH_VIEWINFO_LISTCTRL_FGCOLOR_S);
        }		
    }			 
    else
    {				 
        if (pLVCD->iSubItem ==  FISH_VIEWINFO_LISTCTRL_ICON_INDEX)  {
            rect.left   =   clientRT.left;
            rect.right  =   clientRT.right;
        }        
        if( ( pLVCD->nmcd.dwItemSpec % 2 ) == EVEN ) //짝수 
        {
            if (pLVCD->iSubItem  == 0)
            {
                int nWidth  =   0;
                for (int it = 0; it < GetHeaderCtrl()->GetItemCount(); it++)
                {
                    nWidth  +=  GetColumnWidth(it);
                }
                
                CClientDC dc(this);
                CRect rt;
                GetClientRect(&rt);
                rt.left =   nWidth;
                rt.top  =   rect.top;
                rt.bottom   =   rect.bottom;
                dc.FillRect( &rt, &CBrush(FISH_VIEWINFO_LISTCTRL_EVENROW_BGCOLOR) );
            }
            pDC->FillRect(&rect, &CBrush(FISH_VIEWINFO_LISTCTRL_EVENROW_BGCOLOR) );
        }
        else
        {
            if (pLVCD->iSubItem  == 0)
            {
                int nWidth  =   0;
                for (int it = 0; it < GetHeaderCtrl()->GetItemCount(); it++)
                {
                    nWidth  +=  GetColumnWidth(it);
                }

                CClientDC dc(this);
                CRect rt;
                GetClientRect(&rt);
                rt.left =   nWidth;
                rt.top  =   rect.top;
                rt.bottom   =   rect.bottom;
                dc.FillRect( &rt, &CBrush(FISH_VIEWINFO_LISTCTRL_ODDROW_BGCOLOR) );
            }
            
            pDC->FillRect(&rect, &CBrush(FISH_VIEWINFO_LISTCTRL_ODDROW_BGCOLOR) );				
        }			 
    }

    m_dwPrevItem    =   pLVCD->nmcd.dwItemSpec;
}
示例#25
0
/////////////////////////////////////////////////////////////////////////////
// CSHListCtrl message handlers
void CSHListCtrl::OnLButtonDown(UINT nFlags, CPoint point)
{
	LVHITTESTINFO ht;
	ht.pt = point;
	int rval = SubItemHitTest(&ht);
	
	int oldsubitem = m_CurSubItem;
	m_CurSubItem = IndexToOrder(ht.iSubItem);
	
	CHeaderCtrl* pHeader = (CHeaderCtrl*)GetDlgItem(0);
	// Make the column fully visible.
	// We have to take into account that the columns may be reordered
	MakeColumnVisible(Header_OrderToIndex(pHeader->m_hWnd, m_CurSubItem));
	
	// Store old state of the item.
	int state = GetItemState(ht.iItem, LVIS_FOCUSED);

	if (m_CurSubItem == -1 || ht.iItem == -1)
	{
		if(ht.iItem == -1)
		{
			NMLISTVIEW dispinfo;
			dispinfo.hdr.hwndFrom = m_hWnd;
			dispinfo.hdr.idFrom = GetDlgCtrlID();
			dispinfo.hdr.code = NM_CLICK;
			
			dispinfo.iItem = -1;
			dispinfo.iSubItem = ht.iSubItem;
			
			GetParent()->SendMessage( WM_NOTIFY, GetDlgCtrlID(), 
				(LPARAM)&dispinfo );
		}
		return;
	}
	
	
	// Call default left button click is here just before we might bail.
	// Also updates the state of the item.
	if (m_bClickEdit)
		m_bKeyEvent = FALSE;

	CListCtrl::OnLButtonDown(nFlags, point);
	
	// Bail if the state from before was not focused or the 
	// user has not already clicked on this cell.
	if (!m_bClickEdit)
	{
		if( !state || m_CurSubItem == -1 || oldsubitem != m_CurSubItem )
			return;
	
		int doedit = 0;
		// If we are in column 0 make sure that the user clicked on 
		// the item label.
		if( 0 == ht.iSubItem )
		{
			if (ht.flags & LVHT_ONITEMLABEL)
				doedit = 1;
		}
		else
		{
			doedit = 1;
		}
		if ( !doedit )
			return;
	}	
    // Send Notification to parent of ListView ctrl
	CString str;
	str = GetItemText( ht.iItem, ht.iSubItem );
    LV_DISPINFO dispinfo;
	dispinfo.hdr.hwndFrom = m_hWnd;
	dispinfo.hdr.idFrom = GetDlgCtrlID();
	dispinfo.hdr.code = LVN_BEGINLABELEDIT;
	
	dispinfo.item.mask = LVIF_TEXT;
	dispinfo.item.iItem = ht.iItem;
	dispinfo.item.iSubItem = ht.iSubItem;
	dispinfo.item.pszText = (LPTSTR)((LPCTSTR)str);
	dispinfo.item.cchTextMax = str.GetLength();
	
	GetParent()->SendMessage( WM_NOTIFY, GetDlgCtrlID(), 
		(LPARAM)&dispinfo );
}
示例#26
0
void CLocalListView::RefreshFile(const wxString& file)
{
	if (!wxFileName::FileExists(m_dir + file))
		return;

	t_fileData data;

	data.dir = wxFileName::DirExists(m_dir + file);
	data.icon = -2;
	data.name = file;

	wxStructStat buf;
	int result = wxStat(m_dir + file, &buf);

	if (!result)
	{
		data.hasTime = true;
		data.lastModified = wxDateTime(buf.st_mtime);
	}
	else
		data.hasTime = false;

	if (data.dir)
		data.size = -1;
	else
		data.size = result ? -1 : buf.st_size;

	// Look if file data already exists
	for (std::vector<t_fileData>::iterator iter = m_fileData.begin(); iter != m_fileData.end(); iter++)
	{
		const t_fileData& oldData = *iter;
		if (oldData.name != file)
			continue;

		// It exists, update entry
		data.fileType = oldData.fileType;

		*iter = data;
		if (m_sortColumn)
			SortList();
		Refresh(false);
		return;
	}

	// Insert new entry
	int index = m_fileData.size();
	m_fileData.push_back(data);

	// Find correct position in index mapping
	std::vector<unsigned int>::iterator start = m_indexMapping.begin();
	if (m_hasParent)
		start++;
	CLocalListViewSortObject compare = GetComparisonObject();
	std::vector<unsigned int>::iterator insertPos = std::lower_bound(start, m_indexMapping.end(), index, compare);
	compare.Destroy();

	const int item = insertPos - m_indexMapping.begin();
	m_indexMapping.insert(insertPos, index);
	SetItemCount(m_indexMapping.size());

	// Move selections
	int prevState = 0;
	for (unsigned int i = item; i < m_indexMapping.size(); i++)
	{
		int state = GetItemState(i, wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);
		if (state != prevState)
		{
			SetItemState(i, prevState, wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);
			prevState = state;
		}
	}

	Refresh(false);
}
示例#27
0
bool CListCtrlEx::IsSelected(int index)
{
    return (GetItemState(index, LVIS_SELECTED) & LVIS_SELECTED) != 0;
}
示例#28
0
BOOL COleClientItem::FreezeLink()
{
    ASSERT_VALID(this);
    ASSERT(m_lpObject != NULL);
    ASSERT(m_pDocument != NULL);
    ASSERT(GetType() == OT_LINK);

    // first save & close the item
    Close();

    // get IDataObject interface
    LPDATAOBJECT lpDataObject = QUERYINTERFACE(m_lpObject, IDataObject);
    ASSERT(lpDataObject != NULL);
    COleDataObject dataObject;
    dataObject.Attach(lpDataObject, TRUE);

    // save important state of original item
    LPOLEOBJECT lpObject = m_lpObject;
    LPSTORAGE lpStorage = m_lpStorage;
    LPLOCKBYTES lpLockBytes = m_lpLockBytes;
    LPVIEWOBJECT2 lpViewObject = m_lpViewObject;
    DWORD dwConnection = m_dwConnection;
    DWORD dwItemNumber = m_dwItemNumber;
    m_lpObject = NULL;
    m_lpStorage = NULL;
    m_lpLockBytes = NULL;
    m_lpViewObject = NULL;
    m_dwConnection = 0;

    // attempt to create new object from data
    if (!CreateStaticFromData(&dataObject))
    {
        m_lpObject = lpObject;
        m_lpStorage = lpStorage;
        m_lpLockBytes = lpLockBytes;
        m_lpViewObject = lpViewObject;
        m_dwConnection = dwConnection;
        return FALSE;
    }
#ifdef _DEBUG
    UpdateItemType();
    ASSERT(GetType() == OT_STATIC);
#endif

    // save new state of that item
    LPOLEOBJECT lpNewObject = m_lpObject;
    LPSTORAGE lpNewStorage = m_lpStorage;
    LPLOCKBYTES lpNewLockBytes = m_lpLockBytes;
    LPVIEWOBJECT2 lpNewViewObject = m_lpViewObject;
    DWORD dwNewConnection = m_dwConnection;
    DWORD dwNewItemNumber = m_dwItemNumber;

    // shut down old item
    m_lpObject = lpObject;
    m_lpStorage = lpStorage;
    m_lpLockBytes = lpLockBytes;
    m_lpViewObject = lpViewObject;
    m_dwConnection = dwConnection;
    m_dwItemNumber = dwItemNumber;
#ifdef _DEBUG
    UpdateItemType();
    ASSERT(GetType() == OT_LINK);
#endif
    Delete(FALSE);  // revokes item & removes storage

    // switch to new item
    m_lpObject = lpNewObject;
    m_lpStorage = lpNewStorage;
    m_lpLockBytes = lpNewLockBytes;
    m_lpViewObject = lpNewViewObject;
    m_dwConnection = dwNewConnection;
    m_dwItemNumber = dwNewItemNumber;
    UpdateItemType();
    ASSERT(GetType() == OT_STATIC);

    // send an on changed with same state to invalidate the item
    OnChange(OLE_CHANGED_STATE, (DWORD)GetItemState());
    ASSERT_VALID(m_pDocument);
    m_pDocument->SetModifiedFlag();

    return TRUE;
}
示例#29
0
void CMyTreeCtrl::OnPaint() 
{
	CPaintDC dc(this); // device context for painting

	// Create a memory DC compatible with the paint DC
	CDC memDC;
	memDC.CreateCompatibleDC( &dc );
	
	CRect rcClip, rcClient;
	dc.GetClipBox( &rcClip );
	GetClientRect(&rcClient);

	// Select a compatible bitmap into the memory DC
	CBitmap bitmap;
	bitmap.CreateCompatibleBitmap( &dc, rcClient.Width(), rcClient.Height() );
	CBitmap *pOldBitmap=memDC.SelectObject( &bitmap );

	// Set clip region to be same as that in paint DC
	CRgn rgn;
	rgn.CreateRectRgnIndirect( &rcClip );
	memDC.SelectClipRgn(&rgn);
	rgn.DeleteObject();

	// First let the control do its default drawing.
	CWnd::DefWindowProc( WM_PAINT, (WPARAM)memDC.m_hDC, 0 );

	HTREEITEM hItem = GetFirstVisibleItem();
	
	int n = GetVisibleCount()+1;
	while( hItem && n--)
	{
		CRect rect;

		// Do not meddle with selected items or drop highlighted items
		UINT selflag = TVIS_DROPHILITED | TVIS_SELECTED;
		
		Color_Font cf;	
		if ( !(GetItemState( hItem, selflag ) & selflag ) && m_mapColorFont.Lookup( hItem, cf ))
		{
			CFont *pFontDC;
			CFont fontDC;

			LOGFONT logfont;
			
			if( cf.logfont.lfFaceName[0] != '\0' )
			{
				logfont = cf.logfont;
			}
			else
			{
				// No font specified, so use window font
				CFont *pFont = GetFont();
				pFont->GetLogFont( &logfont );
			}
			
			if( GetItemBold( hItem ) )
			{
				logfont.lfWeight = 700;
			}

			fontDC.CreateFontIndirect( &logfont );
			pFontDC = memDC.SelectObject( &fontDC );
			
			if( cf.color != (COLORREF)-1 )
			{
				memDC.SetTextColor( cf.color );
			}
			
			CString sItem = GetItemText( hItem );
			GetItemRect( hItem, &rect, TRUE );
			memDC.SetBkColor( GetSysColor( COLOR_WINDOW ) );
			memDC.TextOut( rect.left+2, rect.top+1, sItem );			

			memDC.SelectObject( pFontDC );
		}	
		hItem = GetNextVisibleItem( hItem );
	}

	dc.BitBlt( rcClip.left, rcClip.top, rcClip.Width(), rcClip.Height(), &memDC,
			   rcClip.left, rcClip.top, SRCCOPY );

	memDC.SelectObject(pOldBitmap);
	bitmap.DeleteObject();
}
示例#30
0
// Makes a row exchange places
void wxAdvancedListCtrl::FlipRow(long Row, long NextRow)
{
    if(Row == NextRow)
        return;

    // Retrieve data for the next item
    wxListItem Item1, Item2;
    wxListItem Item1Flipped, Item2Flipped;

    Item1.SetId(Row);
    Item1.SetMask(wxLIST_MASK_TEXT | wxLIST_MASK_DATA | wxLIST_MASK_IMAGE);

    Item2.SetId(NextRow);
    Item2.SetMask(wxLIST_MASK_TEXT | wxLIST_MASK_DATA | wxLIST_MASK_IMAGE);

    Item1Flipped.SetId(NextRow);
    Item1Flipped.SetMask(wxLIST_MASK_TEXT | wxLIST_MASK_DATA
                         | wxLIST_MASK_IMAGE);

    Item2Flipped.SetId(Row);
    Item2Flipped.SetMask(wxLIST_MASK_TEXT | wxLIST_MASK_DATA
                         | wxLIST_MASK_IMAGE);

    // Due to bugs/limitations with wxWidgets, certain stuff needs to be
    // physically taken from the list control as GetItem is finicky
    wxColour Item1Colour = GetItemTextColour(Row);
    wxColour Item2Colour = GetItemTextColour(NextRow);
    wxInt32 Item1State = GetItemState(Row, wxLIST_STATE_SELECTED
                                      | wxLIST_STATE_FOCUSED);
    wxInt32 Item2State = GetItemState(NextRow, wxLIST_STATE_SELECTED
                                      | wxLIST_STATE_FOCUSED);

    // Flip the data for columns.
    for (wxInt32 ColumnCounter = 0;
            ColumnCounter < GetColumnCount();
            ++ColumnCounter)
    {
        Item1.SetColumn(ColumnCounter);
        GetItem(Item1);

        Item2.SetColumn(ColumnCounter);
        GetItem(Item2);

        // Do the flip
        // Set data for the first item
        Item2Flipped.SetImage(Item2.GetImage());
        Item2Flipped.SetData(Item2.GetData());
        Item2Flipped.SetText(Item2.GetText());

        // Now the second
        Item1Flipped.SetImage(Item1.GetImage());
        Item1Flipped.SetData(Item1.GetData());
        Item1Flipped.SetText(Item1.GetText());

        // Set them
        Item1Flipped.SetColumn(ColumnCounter);
        SetItem(Item1Flipped);

        Item2Flipped.SetColumn(ColumnCounter);
        SetItem(Item2Flipped);
    }

    // Due to bugs/limitations with wxWidgets, certain stuff needs to be
    // physically taken from the list control as GetItem is finicky
    SetItemState(NextRow, Item1State, wxLIST_STATE_SELECTED
                 | wxLIST_STATE_FOCUSED);
    SetItemState(Row, Item2State, wxLIST_STATE_SELECTED
                 | wxLIST_STATE_FOCUSED);
    SetItemTextColour(NextRow, Item1Colour);
    SetItemTextColour(Row, Item2Colour);
}