コード例 #1
0
int CHeaderCtrlExt::IndexToOrder(int nIndex)
{
	int nOrder = -1;
	const int nCount = GetItemCount();
	if(nCount > 0)
	{
        int* piColOrder = new int[nCount];
        ASSERT(piColOrder);

		GetOrderArray(piColOrder, nCount);
		for(int i = 0;i < nCount;++i)
		{
			if(piColOrder[i] == nIndex)
			{
				nOrder = i;
				break;
			}
		}
        delete []piColOrder;
	}

	return nOrder;
}
コード例 #2
0
ファイル: ListCtrlEx.cpp プロジェクト: albertzeng/eRadQueue
void CListCtrlEx::QuickSort(int nSortColumn)
{
	if (this->m_pColumnMap[abs(nSortColumn) - 1] > 0)
	{
		this->m_nSortColumn = nSortColumn;
		this->m_nCompareType = this->m_pColumnArray[abs(nSortColumn) - 1].compare;
	}
	else
		return;

	QuickSort(0, GetItemCount()-1);

	CHeaderCtrl* pHeaderCtrl = GetHeaderCtrl();
	pHeaderCtrl->SetImageList(&this->m_nArrowList);

	HDITEM hdrItem;
	int nColumns = pHeaderCtrl->GetItemCount();
	for (int index = 0; index < nColumns; index++)
	{
		hdrItem.mask = HDI_FORMAT | HDI_IMAGE | HDI_LPARAM;
		pHeaderCtrl->GetItem(index, &hdrItem);
		if (abs(this->m_nSortColumn) - 1 ==  hdrItem.lParam && this->m_nSortColumn > 0)
		{
			hdrItem.iImage = 0;
			hdrItem.fmt = hdrItem.fmt & HDF_JUSTIFYMASK | HDF_IMAGE | HDF_STRING | HDF_BITMAP_ON_RIGHT;
		}
		else if (abs(this->m_nSortColumn) - 1 == hdrItem.lParam && this->m_nSortColumn < 0)
		{
			hdrItem.iImage = 1;
			hdrItem.fmt = hdrItem.fmt & HDF_JUSTIFYMASK | HDF_IMAGE | HDF_STRING | HDF_BITMAP_ON_RIGHT;
		}
		else
			hdrItem.fmt = hdrItem.fmt & HDF_JUSTIFYMASK | HDF_STRING;

		pHeaderCtrl->SetItem(index, &hdrItem);
	}
}
コード例 #3
0
ファイル: MyListCtrl.cpp プロジェクト: 2Dou/PlayBox
BOOL CMyListCtrl::PreTranslateMessage(MSG* pMsg)
{
	if( pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_CONTROL )
	{
		mkey1 = VK_CONTROL;
	}
	if( pMsg->message == WM_KEYDOWN && pMsg->wParam == 'A' )
	{
		if( mkey1 != 0 )
		{
			if( mkey2 == 0 )
			{
				mkey2 = 'A';
				for (int i=0;i<GetItemCount();++i)
				{
					SetItemState( i,LVIS_SELECTED,LVIS_SELECTED);		
				}
				return TRUE;
			}
		}
	}
	if( pMsg->message == WM_KEYUP )
	{
		mkey2 = 0;
		if(pMsg->wParam == VK_CONTROL)
			mkey1 = 0;
	}
	if( pMsg->hwnd == m_hWnd && mkey1 == 0
		&& pMsg->message == WM_KEYDOWN 
		&& (((pMsg->wParam > 0X40)&&(pMsg->wParam < 0X5B))||((pMsg->wParam > 0X60)&&(pMsg->wParam < 0X7B))) )
	{
		//Ctrol_a_z_KeyDown( short(pMsg->wParam) );
		return TRUE;
	}

	return __super::PreTranslateMessage(pMsg);
}
コード例 #4
0
ファイル: richtextstyles.cpp プロジェクト: hgwells/tive
/// Updates the list
void wxRichTextStyleListBox::UpdateStyles()
{
    if (GetStyleSheet())
    {
        SetSelection(wxNOT_FOUND);

        m_styleNames.Clear();

        size_t i;
        if (GetStyleType() == wxRICHTEXT_STYLE_ALL || GetStyleType() == wxRICHTEXT_STYLE_PARAGRAPH)
        {
            for (i = 0; i < GetStyleSheet()->GetParagraphStyleCount(); i++)
                m_styleNames.Add(GetStyleSheet()->GetParagraphStyle(i)->GetName());
        }
        if (GetStyleType() == wxRICHTEXT_STYLE_ALL || GetStyleType() == wxRICHTEXT_STYLE_CHARACTER)
        {
            for (i = 0; i < GetStyleSheet()->GetCharacterStyleCount(); i++)
                m_styleNames.Add(GetStyleSheet()->GetCharacterStyle(i)->GetName());
        }
        if (GetStyleType() == wxRICHTEXT_STYLE_ALL || GetStyleType() == wxRICHTEXT_STYLE_LIST)
        {
            for (i = 0; i < GetStyleSheet()->GetListStyleCount(); i++)
                m_styleNames.Add(GetStyleSheet()->GetListStyle(i)->GetName());
        }

        m_styleNames.Sort();
        SetItemCount(m_styleNames.GetCount());

        Refresh();

        if (GetItemCount() > 0)
        {
            SetSelection(0);
            SendSelectedEvent();
        }
    }
}
コード例 #5
0
void CRulesList::AddConflict (const CdlConflict &conf)
{
  // set the item column string
  CString strMacroName = (conf)->get_node ()->get_name ().c_str ();
  int nIndex = InsertItem (GetItemCount (), strMacroName);
  SetItemData (nIndex, (DWORD) (conf));
  
  // set the conflict column string
  if (0 != dynamic_cast<CdlConflict_Unresolved> (conf)) {// a conflict of type 'unresolved'
    SetItemText (nIndex, 1, _T("Unresolved"));
  } else if (0 != dynamic_cast<CdlConflict_IllegalValue> (conf)) { // a conflict of type 'illegal value'
    SetItemText (nIndex, 1, _T("Illegal"));
  } else if (0 != dynamic_cast<CdlConflict_EvalException> (conf)) { // a conflict of type 'evaluation exception'
    SetItemText (nIndex, 1, _T("Exception"));
  } else if (0 != dynamic_cast<CdlConflict_Requires> (conf)) { // a conflict of type 'goal unsatisfied'
    SetItemText (nIndex, 1, _T("Unsatisfied"));
  } else if (0 != dynamic_cast<CdlConflict_Data> (conf)) { // a conflict of type 'bad data'
    SetItemText (nIndex, 1, _T("Bad data"));
  } else {
    ASSERT (0);
  }
  
	// set the property column string
	CString strProperty = conf->get_property ()->get_property_name ().c_str ();
	strProperty += _T(" ");
	const std::vector<std::string> & argv = conf->get_property ()->get_argv ();
	std::vector<std::string>::const_iterator argv_i;
  for (argv_i = argv.begin (); argv_i != argv.end (); argv_i++) {// for each property argument...
    if (argv_i != argv.begin ())                              // ...except the first
    {
      strProperty += argv_i->c_str (); // add the argument to the string
      strProperty += _T (" "); // separate arguments by a space character
    }
  }
	strProperty.TrimRight (); // remove the trailing space character
	SetItemText (nIndex, 2, strProperty);
}
コード例 #6
0
ファイル: listviewfile.cpp プロジェクト: hugofvw/wxExtension
void wxExListViewFile::DoFileSave(bool save_as)
{
  wxXmlNode* root = new wxXmlNode(wxXML_ELEMENT_NODE, "files");
  wxXmlNode* comment = new wxXmlNode(
    wxXML_COMMENT_NODE,
    wxEmptyString,
    wxTheApp->GetAppDisplayName() + " project " + GetFileName().GetFullName() + 
      " "  + wxDateTime::Now().Format());

  root->AddChild(comment);

  for (int i = 0; i < GetItemCount(); i++)
  {
    const wxExFileName fn = wxExListItem(this, i).GetFileName();

    wxXmlNode* element = new wxXmlNode(
      wxXML_ELEMENT_NODE,
      (fn.FileExists() ? "file": "folder"));

    if (!fn.FileExists() && fn.DirExists())
    {
      element->AddAttribute("extensions", GetItemText(i, _("Type")));
    }
    
    wxXmlNode* text = new wxXmlNode(
      wxXML_TEXT_NODE, 
      wxEmptyString, 
      fn.GetFullPath());
      
    element->AddChild(text);
    root->AddChild(element);
  }
  
  wxXmlDocument doc;
  doc.SetRoot(root);
  doc.Save(GetFileName().GetFullPath());
}
コード例 #7
0
/******************************************************************************
 Function Name  :   OnRButtonDown

 Description    :   The framework calls this member function when the user
                    right clicks on the list box
 Input(s)       :   nFlags -
                    point -
 Output         :   -
 Functionality  :   Shows a popup menu to remove an entry or to clear entries
 Member of      :   CSignalWatchListBox

 Author(s)      :   Ratnadip Choudhury, Amarnath Shastri
 Date Created   :   03-04-2002
 Modified by    :   Ratnadip Choudhury
 Modified on    :   26-04-2002
 Modified by    :   Raja N
 Modified on    :   22.07.2004, Modified the function call to refer ListCtrl
******************************************************************************/
void CSignalWatchListBox::OnRButtonDown(UINT nFlags, CPoint omPoint)
{
    if (GetItemCount() > 0)
    {
        CMenu* pomContextMenu = new CMenu;
        if (pomContextMenu != NULL)
        {
            // Load the Menu from the resource
            pomContextMenu->DestroyMenu();
            pomContextMenu->LoadMenu(IDM_MENU_SIGNAL_WATCH);
            CMenu* pomSubMenu = pomContextMenu->GetSubMenu(1);

            if (pomSubMenu != NULL)
            {
                CPoint omSrcPt = omPoint;
                ClientToScreen(&omSrcPt);
                UINT unEnable;
                // If no item is selected, make "Delete" menu item disabled
                if (GetSelectedCount() == -1)
                {
                    unEnable = MF_BYCOMMAND | MF_DISABLED | MF_GRAYED;
                }
                else
                {
                    unEnable = MF_BYCOMMAND | MF_ENABLED;
                }
                pomSubMenu->EnableMenuItem(IDM_SG_WATCH_CLEAR, unEnable);
                pomSubMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON,
                                           omSrcPt.x, omSrcPt.y, this, NULL);
            }
            delete pomContextMenu;
            pomContextMenu = NULL;
        }
    }

    CFFListCtrl::OnRButtonDown(nFlags, omPoint);
}
コード例 #8
0
ファイル: propertywin.cpp プロジェクト: 0xCA5A/dd-wrt
int ecPropertyListCtrl::SetItem(const wxString& item, const wxString& value, int nInsertAs, int nRepeat)
{
    wxASSERT( nInsertAs <= GetItemCount() );

/*
    LVFINDINFO info;
    info.flags =LVFI_STRING;
    info.psz   =pszItem;
    info.vkDirection=VK_DOWN;
    int nIndex=-1;
    do {
        nIndex=FindItem(&info,nIndex);
    } while (--nRepeat>0 && nIndex!=-1);
*/
    // NB: wxListCtrl doesn't support reverse search, so could do it explicitly
    // by iterating through the items.
    // But for now, just ignore the nRepeat flag and find the first one.
    int nIndex = -1;
    nIndex = FindItem(0, /* nIndex */ item);
    
    if(-1==nIndex){
        nIndex = InsertItem(nInsertAs, item);
    }
    
    wxListCtrl::SetItem(nIndex, 1, value);

    // TODO
#if 0
    CDC *pDC=GetDC();
    CFont *pOldFont=pDC->SelectObject(GetFont());
    m_nMaxValueWidth=max(m_nMaxValueWidth,pDC->GetTextExtent(pszValue).cx);
    pDC->SelectObject(pOldFont);
    ReleaseDC(pDC);
#endif

    return nIndex;
}
コード例 #9
0
BOOL CTDLFindResultsListCtrl::AddHeaderRow(LPCTSTR szText, BOOL bSpaceAbove)
{
	int nPos = GetItemCount();

	// add space above?
	if (bSpaceAbove)
	{
		int nIndex = InsertItem(nPos, _T(""));
		SetItemData(nIndex, 0);
		nPos++;
	}

	// add result
	int nIndex = InsertItem(nPos, szText);
	SetItemData(nIndex, 0);

	// bold font for rendering
	if (m_fontBold.GetSafeHandle() == NULL)
	{
		GraphicsMisc::CreateFont(m_fontBold, (HFONT)SendMessage(WM_GETFONT), MFS_BOLD);
	}

	return (nIndex != -1);
}
コード例 #10
0
void CPatchListCtrl::OnDropFiles(HDROP hDropInfo)
{
	UINT nNumFiles = DragQueryFile(hDropInfo, 0xFFFFFFFF, nullptr, 0);
	for (UINT i = 0; i < nNumFiles; ++i)
	{
		CString file;
		DragQueryFile(hDropInfo, i, CStrBuf(file, MAX_PATH), MAX_PATH);
		if (PathIsDirectory(file))
			continue;

		// no duplicates
		LVFINDINFO lvInfo;
		lvInfo.flags = LVFI_STRING;
		lvInfo.psz = file;
		if (FindItem(&lvInfo, -1) != -1)
			continue;

		int index = InsertItem(GetItemCount(), file);
		if (index >= 0)
			SetCheck(index, true);
	}
	DragFinish(hDropInfo);
	SetColumnWidth(0, LVSCW_AUTOSIZE);
}
コード例 #11
0
//*********************************************************************************
int CBCGPHeaderCtrl::GetSortColumn () const
{
    ASSERT_VALID (this);

    if (m_bMultipleSort)
    {
        TRACE0("Call CBCGPHeaderCtrl::GetColumnState for muliple sort\n");
        ASSERT (FALSE);
        return -1;
    }

    int nCount = GetItemCount ();
    for (int i = 0; i < nCount; i++)
    {
        int nSortVal = 0;
        if (m_mapColumnsStatus.Lookup (i, nSortVal) &&
                nSortVal != 0)
        {
            return i;
        }
    }

    return -1;
}
コード例 #12
0
void CXTPMDIWndTab::OnMDIActivate(HWND hWnd)
{
	// Loop through all of the tabs to find the view that has activated.
	int iItem;
	for (iItem = 0; iItem < GetItemCount(); ++iItem)
	{
		// Get the item data for this tab.
		TC_ITEM tci;
		tci.mask = TCIF_PARAM;

		if (GetItem(iItem, &tci))
		{
			MDICHILD* pMDIChild = (MDICHILD*)tci.lParam;
			ASSERT(pMDIChild != NULL);

			// If it is the activated window select it and exit loop.
			if (pMDIChild && (hWnd == pMDIChild->hWnd))
			{
				SetCurSel(iItem);
				break;
			}
		}
	}
}
コード例 #13
0
ファイル: SortListCtrl.cpp プロジェクト: myswirl/myworkspace
int CSortListCtrl::AddItem( LPCTSTR pszText, ... )
{
	const int iIndex = InsertItem( GetItemCount(), pszText );
	LPTSTR* arrpsz = new LPTSTR[ m_iNumColumns ];
	COLORREF * clrText = new COLORREF[ m_iNumColumns ];
	COLORREF * clrBak= new COLORREF[ m_iNumColumns ];

	arrpsz[ 0 ] = new TCHAR[ lstrlen( pszText ) + 1 ];
	clrText[ 0 ] = crWindowText;
	clrBak[ 0 ] = crWindow;
	(void)lstrcpy( arrpsz[ 0 ], pszText );
	

 	va_list list;
	va_start( list, pszText );


	//insert sub item  and set subitem data
	for( int iColumn = 1; iColumn < m_iNumColumns; iColumn++ )
	{
		pszText = va_arg( list, LPCTSTR );
		ASSERT_VALID_STRING( pszText );
		VERIFY( CListCtrl::SetItem( iIndex, iColumn, LVIF_TEXT, pszText, 0, 0, 0, 0 ) );

		arrpsz[ iColumn ] = new TCHAR[ lstrlen( pszText ) + 1 ];
		clrText[ iColumn ] = crWindowText;
		clrBak[ iColumn ] = crWindow;
		(void)lstrcpy( arrpsz[ iColumn ], pszText );
	}

	va_end( list );

	VERIFY( SetArray( iIndex, arrpsz,clrText,clrBak ) );

	return iIndex;
}
コード例 #14
0
void CWndLog::OnRClick()
{
	CMenu menu;
	menu.LoadMenu (IDM_LOG);
	CMenu *pPopup = menu.GetSubMenu (0);
	ApplyLanguageToMenu (pPopup);

	if (m_bAutoScroll)
		pPopup->CheckMenuItem (ID_AUTOSCROLL, MF_CHECKED | MF_BYCOMMAND);

	if (GetItemCount () == 0)
	{
		pPopup->EnableMenuItem (ID_CLEAR, MF_BYCOMMAND | MF_GRAYED);
		pPopup->EnableMenuItem (ID_COPY_TO_CB, MF_BYCOMMAND | MF_GRAYED);
	}

	ClientToScreen (&m_rbPt);

	m_odmenu.Attach (&menu, FALSE);
	pPopup->TrackPopupMenu (TPM_RIGHTBUTTON | TPM_TOPALIGN | TPM_LEFTALIGN,	m_rbPt.x, m_rbPt.y, this);
	m_odmenu.Detach ();

	menu.DestroyMenu ();
}
コード例 #15
0
int CEsmSubListCtrl::AddItem (CEsmSubCellRef* pCellRef) {
  esmrecinfo_t*   pRecInfo;
  CEsmSubNameFix* pName;
  int		  ListIndex;
  int		  ImageIndex;
  
	/* Find an existing reference in the list (no duplicates) */
  ListIndex = FindCellRef(pCellRef);
  if (ListIndex >= 0) return (ListIndex);

	/* Initialize the record info */
  if (pCellRef != NULL && pCellRef->GetRecInfo() == NULL) {
    pName = (CEsmSubNameFix *) pCellRef->FindSubRecord(MWESM_SUBREC_NAME);

    if (pName != NULL) {
      pRecInfo = m_pEsmDlgHandler->GetDocument()->FindRecord(pName->GetName());
      pCellRef->SetRecInfo(pRecInfo);
     }
   
   }

  if (pCellRef->GetRecInfo() == NULL)
    ImageIndex = -1;
  else
    ImageIndex = GetImageIndex(pCellRef->GetRecInfo()->pRecord);
  
	/* Add the item to the end of the list */
  ListIndex = InsertItem(GetItemCount(), "", ImageIndex);
  if (ListIndex < 0) return (ListIndex);

	/* Set the item data */
  SetItemData(ListIndex, (DWORD) pCellRef);
  SetItem(ListIndex, pCellRef);

  return (ListIndex);
 }
コード例 #16
0
ファイル: FileClipBoardDlg.cpp プロジェクト: cdesjardins/DCom
void CMyListCtrl::OnLvnEndlabeledit(NMHDR *pNMHDR, LRESULT *pResult)
{
    NMLVDISPINFO *pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR);
    *pResult = 0;
    
    if (pDispInfo->item.mask & LVIF_TEXT)
    {
        if (pDispInfo->item.iItem == (GetItemCount() - 1))
        {
            InsertItem(pDispInfo->item.iItem, pDispInfo->item.pszText);
        }
        else
        {
            if (strlen(pDispInfo->item.pszText) > 0)
            {
                SetItemText(pDispInfo->item.iItem, 0, pDispInfo->item.pszText);
            }
            else
            {
                GetParent()->PostMessage(WM_COMMAND, MAKEWPARAM(ID_FILE_CLIPBOARD_REMOVE, BN_CLICKED));
            }
        }
    }
}
コード例 #17
0
int CXTPTaskPanelGroup::GetOffsetItem() const
{
	if (m_nScrollOffset == 0)
		return 0;

	if (m_nScrollOffset < GetItemCount())
	{
		CXTPTaskPanelGroupItem* pItem = GetAt(m_nScrollOffset);

		if (pItem->IsVisible())
			return m_nScrollOffset;

		int nScrollOffset = m_pItems->GetNextVisibleIndex(m_nScrollOffset, +1);

		if (nScrollOffset != -1)
			return nScrollOffset;

		nScrollOffset = m_pItems->GetNextVisibleIndex(m_nScrollOffset, -1);
		if (nScrollOffset != -1)
			return nScrollOffset;
	}

	return 0;
}
コード例 #18
0
ファイル: ListDocs.cpp プロジェクト: BeL1kOFF/SHATE
/*void CListDocs::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
   if(lpDrawItemStruct->itemData<0)
		return;
	
   CDC* pDC=CDC::FromHandle(lpDrawItemStruct->hDC);
   CRect rcItem(lpDrawItemStruct->rcItem);
   UINT uiFlags=ILD_TRANSPARENT;
   
   int nItem=lpDrawItemStruct->itemID;
   BOOL bFocus=(GetFocus()==this);
   
   static _TCHAR szBuff[MAX_PATH];
   
   COLORREF  BkText;
   if(lSelRow==lpDrawItemStruct->itemID)
   {
	   BkText = ::GetSysColor(COLOR_HIGHLIGHT);
	   pDC->SetTextColor(RGB(255,255,255));
   }
   else
   {
	   BkText = RGB(255,255,255);	
	   pDC->SetTextColor(RGB(0,0,0));
   }
   CRect rcLabel;
   
   GetItemRect(nItem,rcLabel,LVIR_LABEL);
   UINT nJustify=DT_LEFT;
   

   CBrush b(BkText);
   CRect rcAllLabels;
   GetItemRect(nItem,rcAllLabels,LVIR_BOUNDS);

   LV_ITEM lvi;
          lvi.mask=LVIF_TEXT | LVIF_IMAGE | LVIF_STATE;
          lvi.iItem=nItem;
          lvi.iSubItem=0;
          lvi.pszText=szBuff;
          lvi.cchTextMax=sizeof(szBuff);
          lvi.stateMask=0xFFFF;       // get all state flags
          GetItem(&lvi);
       
          BOOL bSelected=(bFocus || (GetStyle() & LVS_SHOWSELALWAYS)) && lvi.state & LVIS_SELECTED;
          bSelected=bSelected || (lvi.state & LVIS_DROPHILITED);

	
	
	pDC->FillRect(rcAllLabels,&b);
	
	long lCount;
	lCount = GetHeaderCtrl()->GetItemCount();
	for(int i = 0;i<lCount;i++)
	{
		CString sName = GetItemText(nItem,i);
		GetSubItemRect(nItem,i,LVIR_BOUNDS,rcLabel);
		rcLabel.left = rcLabel.left + 2;
		pDC->DrawText(sName,-1,rcLabel,nJustify | DT_SINGLELINE | DT_NOPREFIX | DT_NOCLIP | DT_VCENTER);
	}
	
}
*/
void CListDocs::SelectItem(long lItem)
{
	if((lItem>-1)&&(lItem<GetItemCount()))
	{
		if(lSelRow != lItem)
		{
			if(lSelRow>-1)
			{
				RedrawItems(lSelRow,lSelRow);
			}
			
			lSelRow = lItem;
			RedrawItems(lSelRow,lSelRow);
			SendMessageToParent(NCLD_SELECTED);
		}
	}
	else
	{
		if(lSelRow>-1)
				RedrawItems(lSelRow,lSelRow);
		lSelRow = -1;
		SendMessageToParent(NCLD_SELECTED);
	}
}
コード例 #19
0
void CFVDownloads_Tasks::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) 
{
	BOOL bShift = GetKeyState (VK_SHIFT) & 0x8000;
	BOOL bCtrl = GetKeyState (VK_CONTROL) & 0x8000;

	switch (nChar)
	{
		case 'S':
			if (bShift)
			{
				OnFvdldStart ();
				return;
			}
			break;

		case 'O':
			if (bShift)
			{
				OnFvdldStop ();
				return;
			}
			break;

		case 'A':
			if (bCtrl)
			{
				int cItems = GetItemCount ();
				for (int i = cItems-1; i >= 0; i--)
					SetItemState (i, LVIS_SELECTED, LVIS_SELECTED);
				return;
			}
			break;
	}
	
	CListCtrl::OnKeyDown(nChar, nRepCnt, nFlags);
}
コード例 #20
0
ファイル: Project.cpp プロジェクト: FlyingJester/sphere
void
CProject::RefreshItems()
{
  m_Groups.clear();
  // store the old directory
  char old_directory[MAX_PATH];
  GetCurrentDirectory(MAX_PATH, old_directory);
  if (SetCurrentDirectory(m_Directory.c_str()) != 0)
  {
    UpdateGroupItems(m_Groups);
    if (m_GameScript.empty())
    {
      if (GetItemCount(GT_SCRIPTS) == 1) {
        m_GameScript = GetItem(GT_SCRIPTS, 0);
      }
      if (!m_Filename.empty()) {
        Save();
      }
      SetCurrentDirectory(m_Directory.c_str());
    }
  }
  // restore the old directory
  SetCurrentDirectory(old_directory);
}
コード例 #21
0
ファイル: IrcChannelListCtrl.cpp プロジェクト: acat/emule
bool CIrcChannelListCtrl::AddChannelToList(const CString& sName, const CString& sUsers, const CString& sDesc)
{
	UINT uUsers = _tstoi(sUsers);
	if (thePrefs.GetIRCUseChannelFilter())
	{
		if (uUsers < thePrefs.GetIRCChannelUserFilter())
			return false;
		// was already filters with "/LIST" command
		//if (!thePrefs.GetIRCChannelFilter().IsEmpty())
		//{
		//	if (stristr(sName, thePrefs.GetIRCChannelFilter()) == NULL)
		//		return false;
		//}
	}

	ChannelName* pChannel = new ChannelName(sName, uUsers, m_pParent->StripMessageOfFontCodes(sDesc));
	m_lstChannelNames.AddTail(pChannel);
	int iItem = InsertItem(LVIF_TEXT | LVIF_PARAM, GetItemCount(), pChannel->m_sName, 0, 0, 0, (LPARAM)pChannel);
	if (iItem < 0)
		return false;
	SetItemText(iItem, 1, 0);
	SetItemText(iItem, 2, 0);
	return true;
}
コード例 #22
0
ファイル: GraphListCtrl.cpp プロジェクト: kanbang/SVN
CRect CGraphListCtrl::GetVirtualRect()
{
	int nMinItem = 0;
	int nMaxItem = GetItemCount() - 1;
	CSize szItem = GetItemSizeWithCaption();

	CRect rcResult;
	if (!m_bSortByFixedRow)
	{
		rcResult.top = (nMinItem / m_nFixedColNum) * szItem.cy;
		rcResult.bottom = (nMaxItem / m_nFixedColNum + 1) * szItem.cy;
		rcResult.left = 0;
		rcResult.right = m_nFixedColNum * szItem.cx;
	}
	else
	{
		rcResult.top = 0;
		rcResult.bottom = m_nFixedRowNum * szItem.cy;
		rcResult.left = (nMinItem / m_nFixedRowNum) * szItem.cx;
		rcResult.right = (nMaxItem / m_nFixedRowNum + 1) * szItem.cx;
	}

	return rcResult;
}
コード例 #23
0
void CCustomTabCtrl::UpdateNumberFrom(int idx)
{
	int c = GetItemCount();
	BOOL addnum = AppConfig.tab_add_number;
	while (c > idx)
	{
		TCITEM item;
		item.mask = TCIF_PARAM;
		GetItem(c - 1, &item);
		CTelnetConn* telnet = (CTelnetConn*)item.lParam;
		CString name;
		if (addnum)
		{
			name.Format("%d.%s", c, telnet->name);
			item.pszText = (LPSTR)(LPCTSTR)name;
		}
		else
			item.pszText = (LPSTR)(LPCTSTR)telnet->name;

		item.mask = TCIF_TEXT;
		SetItem(c - 1, &item);
		c--;
	}
}
コード例 #24
0
ファイル: ComboBox.cpp プロジェクト: Cruel/SFGUI
sf::Vector2f ComboBox::CalculateRequisition() {
	float padding( Context::Get().GetEngine().GetProperty<float>( "ItemPadding", shared_from_this() ) );
	const std::string& font_name( Context::Get().GetEngine().GetProperty<std::string>( "FontName", shared_from_this() ) );
	unsigned int font_size( Context::Get().GetEngine().GetProperty<unsigned int>( "FontSize", shared_from_this() ) );
	const sf::Font& font( *Context::Get().GetEngine().GetResourceManager().GetFont( font_name ) );

	// Determine highest needed width of all items.
	sf::Vector2f metrics( 0.f, 0.f );
	for ( IndexType item = 0; item < GetItemCount(); ++item ) {
		metrics.x = std::max( metrics.x, Context::Get().GetEngine().GetTextStringMetrics( m_entries[static_cast<std::size_t>( item )], font, font_size ).x );
	}

	metrics.y = Context::Get().GetEngine().GetFontLineHeight( font, font_size );

	// This is needed for the arrow.
	metrics.x += metrics.y;

	sf::Vector2f requisition(
		metrics.x + 3 * padding,
		metrics.y + 2 * padding
	);

	return requisition;
}
コード例 #25
0
void CIrcChannelTabCtrl::SetActivity( CString sChannel, bool bFlag)
{
    Channel* pRefresh = FindChannelByName( sChannel );
    if( !pRefresh )
    {
        pRefresh = (Channel*)m_ptrlistChannel.GetHead();
        if( !pRefresh )
            return;
    }
    TCITEM item;
    item.mask = TCIF_PARAM;
    item.lParam = -1;
    int iIndex;
    for (iIndex = 0; iIndex < GetItemCount(); iIndex++)
    {
        GetItem(iIndex,&item);
        if (((Channel*)item.lParam) == pRefresh)
            break;
    }
    if (((Channel*)item.lParam) != pRefresh)
        return;
    if( bFlag )
    {
        item.mask = TCIF_IMAGE;
        item.iImage = 2; // 'MessagePending'
        SetItem( iIndex, &item );
        HighlightItem(iIndex, TRUE);
    }
    else
    {
        item.mask = TCIF_IMAGE;
        item.iImage = 1; // 'Message'
        SetItem( iIndex, &item );
        HighlightItem(iIndex, FALSE);
    }
}
コード例 #26
0
ファイル: DropListCtrl.cpp プロジェクト: saladyears/Sea3D
/////////////////////////////////////////////////////////////////////////////
// data processing
/////////////////////////////////////////////////////////////////////////////
void CDropListCtrl::ProcessData(CString strData)
{
	int idx;
	int iIns;
	int iTab;
	int iIndex;
	CDropStatic *pButton;

	//get the button in question
	pButton = ((CNewGameDialog *) GetParent())->getDropButton();

	//remove the data from the button
	if(pButton) pButton->dropItem();

	//unformat the text
	iTab = strData.ReverseFind('\t');

	//get the index
	idx = atoi(strData.Right(strData.GetLength() - iTab - 1));

	//chop it off
	strData = strData.Left(iTab);
	
	//get the id
	iIndex = atoi(strData);

	//insert the text in
	iIns = InsertItem(GetItemCount(), PLAYERS->getPlayer(iIndex).getCommaName());
	SetItemData(iIns, iIndex);

	//reset the selection
	setSelection();

	//call the sort function
	sort();
}
コード例 #27
0
ファイル: listeditctrl.cpp プロジェクト: wfmdyh/wecan
// **************************************************************************
// HitTestEx ()
//
// Description:
//	Determine which item or subitem was hit.
//
// Parameters:
//  CPoint		&cPoint		Current locaction of mouse cursor
//	int			*pCol		Gets set to column hit was in.
//
// Returns:
//  int - Row hit was in, or -1 if hit was not on a cell.
// **************************************************************************
int CKListEditCtrl::HitTestEx (CPoint &cPoint, int *pCol)
	{	
	int nCol = 0;
	int nRow = HitTest (cPoint, NULL);		
	int nBottom = 0;
	int cnColumns = 0;
	
	// Initialize returned column number to zero:
	if (pCol) 
		*pCol = 0;

	// Make sure that the ListView is in LVS_REPORT format:
	if ((GetWindowLong (m_hWnd, GWL_STYLE) & LVS_TYPEMASK) != LVS_REPORT)
		return (nRow);	
	
	// Get the top and bottom visible rows:
	nRow = GetTopIndex ();
	nBottom = nRow + GetCountPerPage ();	
	
	// Make sure bottom index is valid:
	if (nBottom > GetItemCount ())
		nBottom = GetItemCount ();		
	
	// Get the number of columns:
	CHeaderCtrl* pHeader = (CHeaderCtrl*) GetDlgItem (0);
	cnColumns = pHeader->GetItemCount ();	

	// Determine which row the hit occurred:
	for (; nRow <= nBottom; nRow++)	
		{
		// Get bounding rect of item:
		CRect rect;
		GetItemRect (nRow, &rect, LVIR_BOUNDS);		
		
		// Check to see if the point falls in bounds of that row:
		if (rect.PtInRect (cPoint))		
			{
			// Hit was in this row.  Now find the column:
			for (nCol = 0; nCol < cnColumns; nCol++)
				{				
				int nColWidth = GetColumnWidth (nCol);				
				
				// If hit is within this column, return:
				if (cPoint.x >= rect.left && cPoint.x <= (rect.left + nColWidth))				
					{					
					if (pCol) 
						*pCol = nCol;

					return (nRow);				
					}				
				
				// Adjust left side of row's rectangle so we will look at 
				// next column ntext time around loop:
				rect.left += nColWidth;			
				}		
			}	
		}

	// If we make it here, then the hit was not on a cell.  Return -1
	// to indicate failure:
	return (-1);
	}
コード例 #28
0
ファイル: MixereView.cpp プロジェクト: victimofleisure/Mixere
void CMixereView::SaveUndoState(CUndoState& State)
{
	if (State.GetCode() < START_UCODE) {	// if base class undo code
		CFormListView::SaveUndoState(State);	// defer to base class
		return;
	}
	if (State.GetCode() > END_UCODE) {		// if snapshot undo code
		m_Snapshot->SaveUndoState(State);		// defer to snapshot class
		return;
	}
	int	Chans = GetItemCount();
	UValCurPos(State) = m_CurPos;	// do first so handlers can override
	switch (State.GetCode()) {
	case UCODE_TRANSPORT:
		{
			TRANSPORT_UNDO_STATE	*uap;
			if (State.IsEmpty()) {	// if first time
				AllocUndoArray(uap, State, max(m_Selections, 1));
				SetUndoChanIdxs(uap);	// set each element's channel index
			} else
				GetUndoArray(uap, State);
			for (int i = 0; i < UValItems(State); i++, uap++) {
				CChannel	*Chan = GetChan(uap->m_ChanIdx);
				uap->m_Transport = Chan->GetTransport();
				uap->m_Pos = Chan->GetPosition();
			}
		}
		break;
	case UCODE_GO:
		{
			GO_UNDO_STATE	*uap;
			if (State.IsEmpty()) {	// if first time
				AllocUndoArray(uap, State, max(m_Selections, 1));
				SetUndoChanIdxs(uap);	// set each element's channel index
			} else
				GetUndoArray(uap, State);
			for (int i = 0; i < UValItems(State); i++, uap++) {
				CChannel	*Chan = GetChan(uap->m_ChanIdx);
				uap->m_Transport = Chan->GetTransport();
				uap->m_Pos = Chan->GetPosition();
				for (int j = 0; j < CChanInfo::AUTOS; j++) {
					uap->m_Auto[j].m_Transport = Chan->GetAuto(j)->GetTransport();
					uap->m_Auto[j].m_Pos = Chan->GetAuto(j)->GetNormPos();
				}
			}
		}
		break;
	case UCODE_LOOP:
		{
			bool	*uap;
			AllocUndoArray(uap, State, Chans);
			for (int i = 0; i < Chans; i++)
				uap[i] = GetChan(i)->GetLoop();
		}
		break;
	case UCODE_MUTE:
		{
			bool	*uap;
			AllocUndoArray(uap, State, Chans);
			for (int i = 0; i < Chans; i++)
				uap[i] = GetChan(i)->GetMute();
		}
		break;
	case UCODE_SOLO:
	case UCODE_END_SOLO:
		{
			bool	*uap;
			AllocUndoArray(uap, State, Chans);
			for (int i = 0; i < Chans; i++)
				uap[i] = GetChan(i)->GetSolo();
		}
		break;
	case UCODE_KEEP_SOLO:
		{
			BYTE	*uap;
			AllocUndoArray(uap, State, Chans);
			for (int i = 0; i < Chans; i++)
				uap[i] = GetChan(i)->GetMute() + (GetChan(i)->GetSolo() << 1);
		}
		break;
	case UCODE_LOAD_AUDIO:
	case UCODE_INSERT_AUDIO:
		if (!UValFlags(State)) {
			// override current position with pre-insert position
			UValCurPos(State) = m_PrevPos;
			CChanInfo	*uap;
			AllocUndoArray(uap, State, 1);
			GetChan(m_CurPos)->GetInfo(uap);
			UValFlags(State) = UFLAG_DEL;	// first restore will delete
		} else
			UValFlags(State) ^= UFLAG_DIR;	// reverse direction
		break;
	case UCODE_SHOW_VOLUME:
	case UCODE_SHOW_SNAPSHOT:
	case UCODE_SHOW_MS_FADE:
	case UCODE_SHOW_TEMPO:
		if (!UValBarNum(State))	// if first time (zero bar number)
			// assume m_UndoIdx contains notifier's dialog bar index
			UValBarNum(State) = m_UndoIdx + 1;	// zero is reserved for first time
		UValShowBar(State) = IsDlgBarVisible(UValBarNum(State) - 1);
		break;
	case UCODE_SET_DEFAULTS:
		{
			CChanInfo	*uap;
			AllocUndoArray(uap, State, 1);
			*uap = m_ChanDefaults;
		}
		break;
	case UCODE_EDIT_AUTO:
		{
			CEditAutoUndoState	*uap;
			if (State.IsEmpty()) {	// if first time
				AllocUndoArray(uap, State, max(m_Selections, 1));
				SetUndoChanIdxs(uap);	// set each element's channel index
				// assume m_UndoIdx contains notifier's auto slider index
				UValAutoIdx(State) = m_UndoIdx;
			} else
				GetUndoArray(uap, State);
			for (int i = 0; i < UValItems(State); i++, uap++) {
				CChannel	*Chan = GetChan(uap->m_ChanIdx);
				CAutoSliderCtrl	*Auto = Chan->GetAuto(UValAutoIdx(State));
				Auto->GetInfo(*uap);
				uap->m_ChanTransport = Chan->GetTransport();
				uap->m_ChanLoop = Chan->GetLoop();
				uap->m_ChanPos = Chan->GetPosition();
			}
		}
		break;
	default:
		NODEFAULTCASE;		
	}
}
コード例 #29
0
//***************************************************************
// add an item
int CColorListCtrl::AddItem(CStringArray *line, int pos)
{
    int ret_index=LISTCTRL_ERROR;
    if (!line) return ret_index;

	LV_ITEM lvi;
    
	//set List-properties
	lvi.mask = LVIF_TEXT ; 
	lvi.iSubItem = 0;
    lvi.pszText = "";

    int count=GetItemCount();
    int columns=line->GetSize();

    if (m_columnSize!=columns) return ret_index;

    if (DWORD(pos)<=DWORD(count)) count=pos;
	
    lvi.iItem = count;
    //lvi.lParam= count;
	lvi.mask = LVIF_TEXT ; 
	lvi.iSubItem = 0;   //refer to no Item
    // insert an new line
    ret_index=InsertItem(&lvi);
    // set item text for additional columns		
    for (int x=0; x<columns; x++)
    {
        CListCtrl::SetItemText(count,x,(char*)LPCSTR(line->GetAt(x)) );
    }
	lvi.mask = LVIF_STATE;
	lvi.iSubItem = 1;
	lvi.stateMask = 0xFFFFFFFF ; 
	lvi.state = 0;

	if (CListCtrl::SetItem(&lvi)) 
    {
        CMyLParam *p=new CMyLParam(m_columnSize); //init with: DEF_BACKGROUND, def_text

        #ifdef TESTCOLOR
            // only for TEST
            if (ret_index<3)
            {
                p->SetBackColor(ITEM_COLOR(ret_index+BLUE),0);
                p->SetTextColor(ITEM_COLOR(ret_index+RED ),0);
            }
            else
            if (ret_index<=6)
            {
                p->SetBackColor(ITEM_COLOR(ret_index+BLUE),1);
                p->SetTextColor(ITEM_COLOR(ret_index+RED ),1);
            }
            else
            {
                p->SetBackColor(ITEM_COLOR((ret_index+BLUE)&0xF),2);
                p->SetTextColor(ITEM_COLOR((ret_index+RED )&0xF),2);
            }
            // end: only for TEST
        #endif

        CListCtrl::SetItemData( ret_index, DWORD(p) );
        return ret_index;
    }
    return LISTCTRL_ERROR;
}
コード例 #30
0
ファイル: MixereView.cpp プロジェクト: victimofleisure/Mixere
void CMixereView::ApplyColorScheme()
{
	for (int i = 0; i < GetItemCount(); i++)
		GetChan(i)->ApplyColorScheme();
}