bool CServerListCtrl::Init(CServerList* in_list)
{
	server_list = in_list;
	ModifyStyle(0,LVS_SINGLESEL|LVS_REPORT);
	ModifyStyle(LVS_SINGLESEL|LVS_LIST|LVS_ICON|LVS_SMALLICON,LVS_REPORT); //here the CListCtrl is set to report-style
	SetExtendedStyle(GetExtendedStyle() | LVS_EX_INFOTIP);

	InsertColumn(0, GetResString(IDS_SL_SERVERNAME),LVCFMT_LEFT, 150);
	InsertColumn(1, GetResString(IDS_IP),			LVCFMT_LEFT, 140);
	InsertColumn(2, GetResString(IDS_DESCRIPTION),	LVCFMT_LEFT, 150);
	InsertColumn(3, GetResString(IDS_PING),			LVCFMT_RIGHT, 50);
	InsertColumn(4, GetResString(IDS_UUSERS),		LVCFMT_RIGHT, 50);
	InsertColumn(5, GetResString(IDS_MAXCLIENT),	LVCFMT_RIGHT, 50);
	InsertColumn(6, GetResString(IDS_PW_FILES) ,	LVCFMT_RIGHT, 50);
	InsertColumn(7, GetResString(IDS_PREFERENCE),	LVCFMT_LEFT,  60);
	InsertColumn(8, GetResString(IDS_UFAILED),		LVCFMT_RIGHT, 50);
//==> simplify Serverwindow [shadow2004]
#if defined(SRVWND1)
	InsertColumn(9, GetResString(IDS_STATICSERVER),	LVCFMT_LEFT,  50);
	InsertColumn(10,GetResString(IDS_SOFTFILES),	LVCFMT_RIGHT, 50);
	InsertColumn(11,GetResString(IDS_HARDFILES),	LVCFMT_RIGHT, 50);
	InsertColumn(12,GetResString(IDS_VERSION),		LVCFMT_LEFT,  50);
	InsertColumn(13,GetResString(IDS_IDLOW),		LVCFMT_RIGHT, 50);
#else //SRVWND1
	InsertColumn(9,GetResString(IDS_IDLOW),		LVCFMT_RIGHT, 50);
#endif //SRVWND1
//<== simplify Serverwindow [shadow2004]
	SetAllIcons();
	Localize();
	LoadSettings(CPreferences::tableServer);

	// Barry - Use preferred sort order from preferences
	int iSortItem = thePrefs.GetColumnSortItem(CPreferences::tableServer);
	bool bSortAscending = thePrefs.GetColumnSortAscending(CPreferences::tableServer);
	SetSortArrow(iSortItem, bSortAscending);
	SortItems(SortProc, MAKELONG(iSortItem, (bSortAscending ? 0 : 0x0001)));

	ShowServerCount();

	return true;
} 
Esempio n. 2
0
bool CServerListCtrl::Init()
{
	SetPrefsKey(_T("ServerListCtrl"));
	SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP);

	CToolTipCtrl* tooltip = GetToolTips();
	if (tooltip) {
		m_tooltip->SubclassWindow(*tooltip);
		tooltip->ModifyStyle(0, TTS_NOPREFIX);
		tooltip->SetDelayTime(TTDT_AUTOPOP, 20000);
		//tooltip->SetDelayTime(TTDT_INITIAL, thePrefs.GetToolTipDelay()*1000);
	}

	InsertColumn(0, GetResString(IDS_SL_SERVERNAME),LVCFMT_LEFT, 150);
	InsertColumn(1, GetResString(IDS_IP),			LVCFMT_LEFT, 140);
	InsertColumn(2, GetResString(IDS_DESCRIPTION),	LVCFMT_LEFT, 150);
	InsertColumn(3, GetResString(IDS_PING),			LVCFMT_RIGHT, 50);
	InsertColumn(4, GetResString(IDS_UUSERS),		LVCFMT_RIGHT, 60);
	InsertColumn(5, GetResString(IDS_MAXCLIENT),	LVCFMT_RIGHT, 60);
	InsertColumn(6, GetResString(IDS_PW_FILES) ,	LVCFMT_RIGHT, 60);
	InsertColumn(7, GetResString(IDS_PREFERENCE),	LVCFMT_LEFT,  50);
	InsertColumn(8, GetResString(IDS_UFAILED),		LVCFMT_RIGHT, 50);
	InsertColumn(9, GetResString(IDS_STATICSERVER),	LVCFMT_LEFT,  50);
	InsertColumn(10,GetResString(IDS_SOFTFILES),	LVCFMT_RIGHT, 60);
	InsertColumn(11,GetResString(IDS_HARDFILES),	LVCFMT_RIGHT, 60, -1, true);
	InsertColumn(12,GetResString(IDS_VERSION),		LVCFMT_LEFT,  50, -1, true);
	InsertColumn(13,GetResString(IDS_IDLOW),		LVCFMT_RIGHT, 60);
	InsertColumn(14,GetResString(IDS_OBFUSCATION),  LVCFMT_RIGHT, 50);

	SetAllIcons();
	Localize();
	LoadSettings();

	// Barry - Use preferred sort order from preferences
	SetSortArrow();
	SortItems(SortProc, MAKELONG(GetSortItem(), (GetSortAscending() ? 0 : 0x0001)));

	ShowServerCount();

	return true;
} 
void CQueueListCtrl::Init()
{
	SetPrefsKey(_T("QueueListCtrl"));
	SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP);

	InsertColumn(0, GetResString(IDS_QL_USERNAME),	LVCFMT_LEFT, DFLT_CLIENTNAME_COL_WIDTH);
	InsertColumn(1, GetResString(IDS_FILE),			LVCFMT_LEFT, DFLT_FILENAME_COL_WIDTH);
	InsertColumn(2, GetResString(IDS_FILEPRIO),		LVCFMT_LEFT, DFLT_PRIORITY_COL_WIDTH);
	InsertColumn(3, GetResString(IDS_QL_RATING),	LVCFMT_LEFT,  60);
	InsertColumn(4, GetResString(IDS_SCORE),		LVCFMT_LEFT,  60);
	InsertColumn(5, GetResString(IDS_ASKED),		LVCFMT_LEFT,  60);
	InsertColumn(6, GetResString(IDS_LASTSEEN),		LVCFMT_LEFT, 110);
	InsertColumn(7, GetResString(IDS_ENTERQUEUE),	LVCFMT_LEFT, 110);
	InsertColumn(8, GetResString(IDS_BANNED),		LVCFMT_LEFT,  60);
	InsertColumn(9, GetResString(IDS_UPSTATUS),		LVCFMT_LEFT, DFLT_PARTSTATUS_COL_WIDTH);
	InsertColumn(10,GetResString(IDS_CD_CSOFT),		LVCFMT_LEFT,  90);	//Xman version see clientversion in every window
	InsertColumn(11, GetResString(IDS_UPDOWNUPLOADLIST),	LVCFMT_LEFT,  90); //Xman show complete up/down in queuelist

	// ==> push small files [sivka] - Stulle
	InsertColumn(12,GetResString(IDS_SMALL),LVCFMT_LEFT,40,12);
	// <== push small files [sivka] - Stulle

	// ==> push rare file - Stulle
	InsertColumn(13,GetResString(IDS_RARE),LVCFMT_LEFT,40,13);
	// <== push rare file - Stulle

	SetAllIcons();
	Localize();
	LoadSettings();

	//Xman client percentage
	CFont* pFont = GetFont();
	LOGFONT lfFont = {0};
	pFont->GetLogFont(&lfFont);
	lfFont.lfHeight = 11;
	m_fontBoldSmaller.CreateFontIndirect(&lfFont);
	//Xman end

	SetSortArrow();
	SortItems(SortProc, GetSortItem() + (GetSortAscending() ? 0 : 100));
}
Esempio n. 4
0
//点击列消息
void CHappyGoDlg::OnColumnclick(NMHDR * pNMHDR, LRESULT * pResult) 
{
	NM_LISTVIEW * pNMListView=(NM_LISTVIEW *)pNMHDR;

	if (m_pItemKind!=NULL)
	{
		//排列数据
		ListSortInfoStruct SortInfo;
		SortInfo.bAsc=m_bAsc;
		SortInfo.pListCtrl=this;
		SortInfo.uSubItem=pNMListView->iSubItem;
		SortInfo.uItemKind=m_pItemKind[pNMListView->iSubItem];
		SortItems(SortFun,(LPARAM)&SortInfo);

		//设置数据
		*pResult=0;
		m_bAsc=!m_bAsc;
	}

	return;
}
Esempio n. 5
0
void CKadSearchListCtrl::Init()
{
	SetPrefsKey(_T("KadSearchListCtrl"));
	SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP);

	InsertColumn(colNum,			GetResString(IDS_NUMBER),		LVCFMT_LEFT,  60);
	InsertColumn(colKey,			GetResString(IDS_KEY),			LVCFMT_LEFT, DFLT_HASH_COL_WIDTH);
	InsertColumn(colType,			GetResString(IDS_TYPE),			LVCFMT_LEFT, 100);
	InsertColumn(colName,			GetResString(IDS_SW_NAME),		LVCFMT_LEFT, DFLT_FILENAME_COL_WIDTH);
	InsertColumn(colStop,			GetResString(IDS_STATUS),		LVCFMT_LEFT, 100);
	InsertColumn(colLoad,			GetResString(IDS_THELOAD),		LVCFMT_LEFT, 100);
	InsertColumn(colPacketsSent,	GetResString(IDS_PACKSENT),		LVCFMT_LEFT, 100);
	InsertColumn(colResponses,		GetResString(IDS_RESPONSES),	LVCFMT_LEFT, 100);
	
	SetAllIcons();
	Localize();

	LoadSettings();
	SetSortArrow();
	SortItems(SortProc, MAKELONG(GetSortItem(), (GetSortAscending() ? 0 : 0x0001)));
}
Esempio n. 6
0
//点击列消息
void CUserListView::OnColumnclick(NMHDR * pNMHDR, LRESULT * pResult) 
{
	NM_LISTVIEW * pNMListView=(NM_LISTVIEW *)pNMHDR;

	if (m_wColumnCount!=0)
	{
		//构造数据
		tagListSortInfo SortInfo;
		int iSubItem=pNMListView->iSubItem;
		SortInfo.cbAscendSort=m_cbAscendSort;
		SortInfo.pRoomListCtrl=this;
		SortInfo.nItemIndex=iSubItem;
		SortInfo.cbFieldKind=m_wDataDescribe[iSubItem];

		//排列列表
		SortItems(SortFun,(LPARAM)&SortInfo);
		m_cbAscendSort=!m_cbAscendSort;
	}

	return;
}
Esempio n. 7
0
/*===========================================================================
 *
 * Class CSrBatchListCtrl Event - void OnColumnclick (pNMHDR, pResult);
 *
 *=========================================================================*/
void CSrBatchListCtrl::OnColumnclick (NMHDR* pNMHDR, LRESULT* pResult) {
  NM_LISTVIEW*       pNMListView = (NM_LISTVIEW*)pNMHDR;
  srbatchlistsort_t  SortData;
  int	             SubItem;

  *pResult = 0;
  SubItem  = pNMListView->iSubItem;

  if (SubItem == m_SortSubItem) {
    m_SortReverse = !m_SortReverse;
  }
  else {
    m_SortReverse = false;
    m_SortSubItem = SubItem;
  }

  GetParent()->SendMessage(ID_BATCHEDIT_MSG_UPDATE, -1, 0);

  SortData.iSubItem = m_SortSubItem;
  SortData.Reverse  = m_SortReverse;
  SortItems(s_DefaultBatchListSort, (DWORD) &SortData);
}
Esempio n. 8
0
void wxFileCtrl::OnListColClick( wxListEvent &event )
{
    int col = event.GetColumn();

    switch (col)
    {
    case wxFileData::FileList_Name :
    case wxFileData::FileList_Size :
    case wxFileData::FileList_Type :
    case wxFileData::FileList_Time :
        break;
    default :
        return;
    }

    if ((wxFileData::fileListFieldType)col == m_sort_field)
        m_sort_foward = !m_sort_foward;
    else
        m_sort_field = (wxFileData::fileListFieldType)col;

    SortItems(m_sort_field, m_sort_foward);
}
void wxGISToolExecuteView::RefreshAll(void)
{
    wxBusyCursor wait;
    ResetContents();
    wxGxObject* pGxObject = m_pCatalog->GetRegisterObject(m_nParentGxObjectId);
    wxGxObjectContainer* pObjContainer =  wxDynamicCast(pGxObject, wxGxObjectContainer);
    if( pObjContainer == NULL )
        return;
    if( !pObjContainer->HasChildren() )
        return;

    wxGxObjectList ObjectList = pObjContainer->GetChildren();
    wxGxObjectList::iterator iter;
    for (iter = ObjectList.begin(); iter != ObjectList.end(); ++iter)
    {
        wxGxObject *current = *iter;
        AddObject(current);
    }

    SortItems(GxTaskCompareFunction, 0);
    wxListCtrl::Refresh();
}
Esempio n. 10
0
void wxGxContentView::OnEndLabelEdit(wxListEvent& event)
{
    //event.Skip();
    if ( event.GetLabel().IsEmpty() )
    {
        event.Veto();
		return;
    }

	LPITEMDATA pItemData = (LPITEMDATA)event.GetData();
	if(pItemData == NULL)
	{
		event.Veto();
		return;
	}

    wxGxObject* pGxObject = m_pCatalog->GetRegisterObject(pItemData->nObjectID);
	IGxObjectEdit* pObjEdit =  dynamic_cast<IGxObjectEdit*>(pGxObject);
	if(pObjEdit == NULL)
	{
		event.Veto();
		return;
	}
	if(pObjEdit->Rename(event.GetLabel()))
	{
    	m_pCatalog->ObjectChanged(pGxObject->GetId());
	}
    else
    {
		event.Veto();
		wxMessageBox(_("Rename failed!"), _("Error"), wxICON_ERROR | wxOK );

        SORTDATA sortdata = { m_bSortAsc, m_currentSortCol };
        SortItems(GxObjectCVCompareFunction, (long)&sortdata);
        SetColumnImage(m_currentSortCol, m_bSortAsc ? 0 : 1);

		return;
    }
}
Esempio n. 11
0
BOOL CColumnChooserLC::OnDrop(CWnd* /* pWnd */, COleDataObject* pDataObject,
                              DROPEFFECT /* dropEffect */, CPoint /* point */)
{
  // On Drop of column from Header onto Column Chooser Dialog
  if (!pDataObject->IsDataAvailable(m_ccddCPFID, NULL))
    return FALSE;

  HGLOBAL hGlobal;
  hGlobal = pDataObject->GetGlobalData(m_ccddCPFID);

  LPCWSTR pData = (LPCWSTR)GlobalLock(hGlobal);
  ASSERT(pData != NULL);

  DWORD procID;
  int iDDType, dw_type, iLen;

  swscanf_s(pData, L"%08x%02x%02x%04x", &procID, &iDDType, &dw_type, &iLen);

  // Check if it is ours?
  // - we don't accept drop from other instances of PWS
  // Check if it is from List View HeaderCtrl?
  // - we don't accept drop from anything else
  if ((procID != GetCurrentProcessId()) || (iDDType != FROMHDR)) {
    GlobalUnlock(hGlobal);
    return FALSE;
  }

  // Now add it
  const CString cs_header(pData + 16, iLen);
  int iItem = InsertItem(0, cs_header);
  SetItemData(iItem, dw_type);
  SortItems(CCLCCompareProc, (LPARAM)this);

  GlobalUnlock(hGlobal);

  GetParent()->SetFocus();
  return TRUE;
}
Esempio n. 12
0
void
SupportedTypeListView::MessageReceived(BMessage* message)
{
	if (message->WasDropped() && AcceptsDrag(message)) {
		// Add unique types
		entry_ref ref;
		for (int32 index = 0; message->FindRef("refs", index++, &ref) == B_OK; ) {
			BNode node(&ref);
			BNodeInfo info(&node);
			if (node.InitCheck() != B_OK || info.InitCheck() != B_OK)
				continue;

			// TODO: we could identify the file in case it doesn't have a type...
			char type[B_MIME_TYPE_LENGTH];
			if (info.GetType(type) != B_OK)
				continue;

			// check if that type is already in our list
			bool found = false;
			for (int32 i = CountItems(); i-- > 0;) {
				SupportedTypeItem* item = (SupportedTypeItem*)ItemAt(i);
				if (!strcmp(item->Text(), type)) {
					found = true;
					break;
				}
			}

			if (!found) {
				// add type
				AddItem(new SupportedTypeItem(type));
			}
		}

		SortItems(&SupportedTypeItem::Compare);
	} else
		DropTargetListView::MessageReceived(message);
}
Esempio n. 13
0
void CUploadListCtrl::Init()
{
	SetName(_T("UploadListCtrl"));

	CImageList ilDummyImageList; //dummy list for getting the proper height of listview entries
	ilDummyImageList.Create(1, theApp.GetSmallSytemIconSize().cy,theApp.m_iDfltImageListColorFlags|ILC_MASK, 1, 1); 
	SetImageList(&ilDummyImageList, LVSIL_SMALL);
	ASSERT( (GetStyle() & LVS_SHAREIMAGELISTS) == 0 );
	ilDummyImageList.Detach();

	SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP);

	CToolTipCtrl* tooltip = GetToolTips();
	if (tooltip){
		m_tooltip->SubclassWindow(tooltip->m_hWnd);
		tooltip->ModifyStyle(0, TTS_NOPREFIX);
		tooltip->SetDelayTime(TTDT_AUTOPOP, 20000);
		tooltip->SetDelayTime(TTDT_INITIAL, thePrefs.GetToolTipDelay()*1000);
	}

	InsertColumn(0,GetResString(IDS_QL_USERNAME),LVCFMT_LEFT,150,0);
	InsertColumn(1,GetResString(IDS_FILE),LVCFMT_LEFT,275,1);
	InsertColumn(2,GetResString(IDS_DL_SPEED),LVCFMT_LEFT,60,2);
	InsertColumn(3,GetResString(IDS_DL_TRANSF),LVCFMT_LEFT,65,3);
	InsertColumn(4,GetResString(IDS_WAITED),LVCFMT_LEFT,60,4);
	InsertColumn(5,GetResString(IDS_UPLOADTIME),LVCFMT_LEFT,60,5);
	InsertColumn(6,GetResString(IDS_STATUS),LVCFMT_LEFT,110,6);
	InsertColumn(7,GetResString(IDS_UPSTATUS),LVCFMT_LEFT,100,7);

	SetAllIcons();
	Localize();
	LoadSettings();

	// Barry - Use preferred sort order from preferences
	SetSortArrow();
	SortItems(SortProc, GetSortItem() + (GetSortAscending() ? 0:100));
}
Esempio n. 14
0
void CServerListCtrl::OnColumnClick(NMHDR *pNMHDR, LRESULT *pResult) 
{ 
	NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR; 

	// Barry - Store sort order in preferences
	// Determine ascending based on whether already sorted on this column
	int iSortItem = thePrefs.GetColumnSortItem(CPreferences::tableServer);
	bool bOldSortAscending = thePrefs.GetColumnSortAscending(CPreferences::tableServer);
	bool bSortAscending = (iSortItem != pNMListView->iSubItem) ? true : !bOldSortAscending;

	// Item is column clicked
	iSortItem = pNMListView->iSubItem;

	// Save new preferences
	thePrefs.SetColumnSortItem(CPreferences::tableServer, iSortItem);
	thePrefs.SetColumnSortAscending(CPreferences::tableServer, bSortAscending);

	// Sort table
	SetSortArrow(iSortItem, bSortAscending);
	SortItems(SortProc, MAKELONG(iSortItem, (bSortAscending ? 0 : 0x0001)));

	Invalidate();
	*pResult = 0;
}
Esempio n. 15
0
void ShowProcessList()
{
	static bool Active = false;
	if (Active)
		return;
	Active = true;

	auto ProcList = VMenu2::create(MSG(MProcessListTitle), nullptr, 0, ScrY - 4);
	ProcList->SetMenuFlags(VMENU_WRAPMODE);
	ProcList->SetPosition(-1,-1,0,0);
	static bool bShowImage = false;

	ProcInfo pi = {ProcList.get(), bShowImage};

	if (EnumWindows(EnumWindowsProc,(LPARAM)&pi))
	{
		ProcList->AssignHighlights(FALSE);
		ProcList->SetBottomTitle(MSG(MProcessListBottom));
		ProcList->SortItems(TaskSort);

		ProcList->Run([&](const Manager::Key& RawKey)->int
		{
			const auto Key=RawKey.FarKey();
			int KeyProcessed = 1;
			switch (Key)
			{
				case KEY_F1:
				{
					Help::create(L"TaskList");
					break;
				}

				case KEY_NUMDEL:
				case KEY_DEL:
				{
					auto ProcWnd = *static_cast<HWND*>(ProcList->GetUserData(nullptr, 0));

					if (ProcWnd)
					{
						wchar_t_ptr Title;
						int LenTitle=GetWindowTextLength(ProcWnd);

						if (LenTitle)
						{
							Title.reset(LenTitle + 1);

							if (Title && (LenTitle=GetWindowText(ProcWnd, Title.get(), LenTitle+1)))
								Title[LenTitle]=0;
						}

						DWORD ProcID;
						GetWindowThreadProcessId(ProcWnd,&ProcID);

						if (!Message(MSG_WARNING,2,MSG(MKillProcessTitle),MSG(MAskKillProcess),
									NullToEmpty(Title.get()),MSG(MKillProcessWarning),MSG(MKillProcessKill),MSG(MCancel)))
						{
							if (KillProcess(ProcID))
								Sleep(500);
							else
							{
								Global->CatchError();
								Message(MSG_WARNING|MSG_ERRORTYPE,1,MSG(MKillProcessTitle),MSG(MCannotKillProcess),MSG(MOk));
							}
						}
					}
				}
				case KEY_CTRLR:
				case KEY_RCTRLR:
				{
					ProcList->DeleteItems();

					if (!EnumWindows(EnumWindowsProc,(LPARAM)&pi))
						ProcList->Close(-1);
					else
						ProcList->SortItems(TaskSort);
					break;
				}
				case KEY_F2:
				{
					pi.bShowImage=(bShowImage=!bShowImage);
					int SelectPos=ProcList->GetSelectPos();
					ProcList->DeleteItems();

					if (!EnumWindows(EnumWindowsProc,(LPARAM)&pi))
						ProcList->Close(-1);
					else
					{
						ProcList->SortItems(TaskSort);
						ProcList->SetSelectPos(SelectPos);
					}
					break;
				}


				default:
					KeyProcessed = 0;
			}
			return KeyProcessed;
		});

		if (ProcList->GetExitCode()>=0)
		{
			auto ProcWnd = *static_cast<HWND*>(ProcList->GetUserData(nullptr, 0));

			if (ProcWnd)
			{
				//SetForegroundWindow(ProcWnd);
				// Allow SetForegroundWindow on Win98+.
				DWORD dwMs;
				// Remember the current value.
				BOOL bSPI = SystemParametersInfo(SPI_GETFOREGROUNDLOCKTIMEOUT, 0, &dwMs, 0);

				if (bSPI) // Reset foreground lock timeout
					bSPI = SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, 0, 0);

				SetForegroundWindow(ProcWnd);

				if (bSPI) // Restore old value
					SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, ToPtr(dwMs), 0);

				WINDOWPLACEMENT wp = { sizeof(wp) };
				if (!GetWindowPlacement(ProcWnd,&wp) || wp.showCmd!=SW_SHOWMAXIMIZED)
					ShowWindowAsync(ProcWnd,SW_RESTORE);
			}
		}
	}
	Active = false;
}
Esempio n. 16
0
void wxGxContentView::OnObjectChanged(wxGxCatalogEvent& event)
{
    //wxLogDebug(wxT("ContentView Object %d Change"), event.GetObjectID());
    if(event.GetObjectID() == m_nParentGxObjectID)
	{
        wxGxObject* pGxObject = m_pCatalog->GetRegisterObject(event.GetObjectID());
		wxGxObjectContainer* pObjectContainer = wxDynamicCast(pGxObject, wxGxObjectContainer);
		if(pObjectContainer != NULL)
		{
			wxBusyCursor wait;
			if(GetItemCount() > 0 && !pObjectContainer->HasChildren())
			{
			    ResetContents();
			}
			else if(GetItemCount() == 0 && pObjectContainer->HasChildren())
			{
				RefreshAll();
				return;
			}
		}
	}

    bool bItemsHaveChanges = false;

	for(long i = 0; i < GetItemCount(); ++i)
	{
		LPITEMDATA pItemData = (LPITEMDATA)GetItemData(i);
		if(pItemData == NULL)
			continue;
		if(pItemData->nObjectID != event.GetObjectID())
			continue;

        wxGxObject* pGxObject = m_pCatalog->GetRegisterObject(event.GetObjectID());
		IGxObjectUI* pObjUI =  dynamic_cast<IGxObjectUI*>(pGxObject);
		wxIcon icon_small, icon_large;
		if(pObjUI != NULL)
		{
			icon_small = pObjUI->GetSmallImage();
			icon_large = pObjUI->GetLargeImage();
		}

        bool bChangeIcon = false;
        int pos = GetIconPos(icon_small, icon_large);
        bChangeIcon = pItemData->iImageIndex != pos;
		pItemData->iImageIndex = pos;

		wxString sName;
		if(m_pCatalog->GetShowExt())
			sName = pGxObject->GetName();
		else
			sName = pGxObject->GetBaseName();

		wxString sType = pGxObject->GetCategory();

        if (GetItemText(i, 0) != sName)
        {
		    SetItem(i, 0, sName, pos);
            if (m_currentSortCol == 0)
            {
                bItemsHaveChanges = true;
            }
        }
        else if(bChangeIcon)
        {
            SetItemImage(i, pos);
        }

        if(m_current_style == enumGISCVReport)
	    {
            if (GetItemText(i, 1) != sType)
            {
		        SetItem(i, 1, sType);
                if (m_currentSortCol == 1)
                {
                    bItemsHaveChanges = true;
                }
            }
            IGxDataset* pDSet = dynamic_cast<IGxDataset*>(pGxObject);
            if(pDSet)
            {
                if (pDSet->IsMetadataFilled())
                {
                    if (pDSet->GetSize() > 0)
                        SetItem(i, 2, wxFileName::GetHumanReadableSize(pDSet->GetSize()));
                    if (pDSet->GetModificationDate().IsValid())
                        SetItem(i, 3, pDSet->GetModificationDate().Format());
                }
                else
                {
                    wxCriticalSectionLocker locker(m_CritSectFillMeta);
                    m_anFillMetaIDs.Add(pGxObject->GetId());
                }
            }
	    }
	}

    if(bItemsHaveChanges)
    {
        SORTDATA sortdata = {m_bSortAsc, m_currentSortCol};
	    SortItems(GxObjectCVCompareFunction, (long)&sortdata);
    	SetColumnImage(m_currentSortCol, m_bSortAsc ? 0 : 1);
    }

//	wxListCtrl::Refresh();

}
void CLibraryDetailView::Update()
{
	GET_LIST();
	
	CSchema* pSchema	= SchemaCache.Get( Settings.Library.FilterURI );
	DWORD nCookie		= GetFolderCookie();
	
	if ( Settings.Library.ShowVirtual ) pSchema = NULL;
	
	if ( m_nStyle == LVS_REPORT )
	{
		CLibraryTreeItem* pTree = GetFolderSelection();
		
		if ( pTree != NULL && pTree->m_pVirtual != NULL && pTree->m_pSelNext == NULL &&
			 pTree->m_pVirtual->m_pSchema != NULL )
		{
			CString strURI = pTree->m_pVirtual->m_pSchema->GetContainedURI( CSchema::stFile );
			
			if ( strURI.GetLength() && ( m_pSchema == NULL || m_pSchema->m_sURI != strURI ) )
			{
				if ( CSchema* pSchema = SchemaCache.Get( strURI ) )
				{
					CPtrList pColumns;
					CSchemaColumnsDlg::LoadColumns( pSchema, &pColumns );
					SetViewSchema( pSchema, &pColumns, TRUE, FALSE );
				}
			}
		}
	}

	LDVITEM* pItem = m_pList + m_nList - 1;

	for ( DWORD nCount = m_nList ; nCount ; nCount--, pItem-- )
	{
		CLibraryFile* pFile = Library.LookupFile( pItem->nIndex );
		
		if ( pFile && pFile->m_nSelectCookie == nCookie && pFile->IsAvailable() &&
			 ( ! pSchema || pSchema->Equals( pFile->m_pSchema ) ||
			 ( ! pFile->m_pMetadata && pSchema->FilterType( pFile->m_sName ) ) ) )
		{
			pFile->m_nListCookie = nCookie;
		}
		else
		{
			SelRemove( pItem->nIndex );
			CStringArray* pSaved = pItem->pText;
			CopyMemory( pItem, pItem + 1, sizeof(LDVITEM) * ( m_nList - nCount ) );
			pItem[ m_nList - nCount ].pText = pSaved;
			m_nList--;
		}
	}

	for ( POSITION pos = LibraryMaps.GetFileIterator() ; pos ; )
	{
		CLibraryFile* pFile = LibraryMaps.GetNextFile( pos );

		if ( pFile->m_nSelectCookie == nCookie &&
 			 pFile->m_nListCookie != nCookie &&
			 pFile->IsAvailable() &&
			 ( ! pSchema || pSchema->Equals( pFile->m_pSchema ) ||
			 ( ! pFile->m_pMetadata && pSchema->FilterType( pFile->m_sName ) ) ) )
		{
			if ( m_nList == m_nBuffer )	// MUST EQUAL
			{
				m_nBuffer += 64;
				LDVITEM* pList = new LDVITEM[ m_nBuffer ];
				if ( m_nList ) CopyMemory( pList, m_pList, m_nList * sizeof(LDVITEM) );
				if ( m_pList ) delete [] m_pList;
				ZeroMemory( pList + m_nList, ( m_nBuffer - m_nList ) * sizeof(LDVITEM) );
				m_pList = pList;
			}
			
			m_pList[ m_nList ].nIndex		= pFile->m_nIndex;
			m_pList[ m_nList ].nState		&= ~LDVI_SELECTED;
			m_nList++;
			
			pFile->m_nListCookie = nCookie;
		}
	}
	
	m_nListCookie++;
	
	SortItems();
}
Esempio n. 18
0
void CLogListCtrl::Init(void)
{
	SortItems(SortProc, (LPARAM)this);
}
Esempio n. 19
0
void CUIRecentSessionList::sort()
{
	SortItems(IMListItemCompareFunc, 0);
}
Esempio n. 20
0
void wxFileCtrl::UpdateFiles()
{
    // don't do anything before ShowModal() call which sets m_dirName
    if ( m_dirName == wxT("*") )
        return;

    wxBusyCursor bcur; // this may take a while...

    DeleteAllItems();

    wxListItem item;
    item.m_itemId = 0;
    item.m_col = 0;

#if (defined(__WINDOWS__) || defined(__DOS__) || defined(__WXMAC__) || defined(__OS2__)) && !defined(__WXWINCE__)
    if ( IsTopMostDir(m_dirName) )
    {
        wxArrayString names, paths;
        wxArrayInt icons;
        size_t n, count = wxGetAvailableDrives(paths, names, icons);

        for (n=0; n<count; n++)
        {
            wxFileData *fd = new wxFileData(paths[n], names[n], wxFileData::is_drive, icons[n]);
            if (Add(fd, item) != -1)
                item.m_itemId++;
            else
                delete fd;
        }
    }
    else
#endif // defined(__DOS__) || defined(__WINDOWS__)
    {
        // Real directory...
        if ( !IsTopMostDir(m_dirName) && !m_dirName.empty() )
        {
            wxString p(wxPathOnly(m_dirName));
#if (defined(__UNIX__) || defined(__WXWINCE__)) && !defined(__OS2__)
            if (p.empty()) p = wxT("/");
#endif // __UNIX__
            wxFileData *fd = new wxFileData(p, wxT(".."), wxFileData::is_dir, wxFileIconsTable::folder);
            if (Add(fd, item) != -1)
                item.m_itemId++;
            else
                delete fd;
        }

        wxString dirname(m_dirName);
#if defined(__DOS__) || defined(__WINDOWS__) || defined(__OS2__)
        if (dirname.length() == 2 && dirname[1u] == wxT(':'))
            dirname << wxT('\\');
#endif // defined(__DOS__) || defined(__WINDOWS__) || defined(__OS2__)

        if (dirname.empty())
            dirname = wxFILE_SEP_PATH;

        wxLogNull logNull;
        wxDir dir(dirname);

        if ( dir.IsOpened() )
        {
            wxString dirPrefix(dirname);
            if (dirPrefix.Last() != wxFILE_SEP_PATH)
                dirPrefix += wxFILE_SEP_PATH;

            int hiddenFlag = m_showHidden ? wxDIR_HIDDEN : 0;

            bool cont;
            wxString f;

            // Get the directories first (not matched against wildcards):
            cont = dir.GetFirst(&f, wxEmptyString, wxDIR_DIRS | hiddenFlag);
            while (cont)
            {
                wxFileData *fd = new wxFileData(dirPrefix + f, f, wxFileData::is_dir, wxFileIconsTable::folder);
                if (Add(fd, item) != -1)
                    item.m_itemId++;
                else
                    delete fd;

                cont = dir.GetNext(&f);
            }

            // Tokenize the wildcard string, so we can handle more than 1
            // search pattern in a wildcard.
            wxStringTokenizer tokenWild(m_wild, wxT(";"));
            while ( tokenWild.HasMoreTokens() )
            {
                cont = dir.GetFirst(&f, tokenWild.GetNextToken(),
                                    wxDIR_FILES | hiddenFlag);
                while (cont)
                {
                    wxFileData *fd = new wxFileData(dirPrefix + f, f, wxFileData::is_file, wxFileIconsTable::file);
                    if (Add(fd, item) != -1)
                        item.m_itemId++;
                    else
                        delete fd;

                    cont = dir.GetNext(&f);
                }
            }
        }
    }

    SortItems(m_sort_field, m_sort_foward);
}
Esempio n. 21
0
void ShowProcessList()
{
	static bool Active = false;
	if (Active)
		return;
	Active = true;
	SCOPE_EXIT{ Active = false; };

	const auto ProcList = VMenu2::create(msg(lng::MProcessListTitle), {}, ScrY - 4);
	ProcList->SetMenuFlags(VMENU_WRAPMODE);
	ProcList->SetPosition({ -1, -1, 0, 0 });
	bool ShowImage = false;

	const auto FillProcList = [&]
	{
		ProcList->clear();

		ProcInfo Info{ ProcList.get(), ShowImage };
		if (!EnumWindows(EnumWindowsProc, reinterpret_cast<LPARAM>(&Info)))
		{
			rethrow_if(Info.ExceptionPtr);
			return false;
		}

		ProcList->SortItems([](const MenuItemEx& a, const MenuItemEx& b, SortItemParam&)
		{
			return string_sort::less(std::any_cast<const menu_data&>(a.ComplexUserData).Title, std::any_cast<const menu_data&>(b.ComplexUserData).Title);
		});

		return true;
	};

	if (!FillProcList())
		return;

	ProcList->AssignHighlights(FALSE);
	ProcList->SetBottomTitle(msg(lng::MProcessListBottom));

	ProcList->Run([&](const Manager::Key& RawKey)
	{
		const auto Key=RawKey();
		int KeyProcessed = 1;
		switch (Key)
		{
			case KEY_F1:
				help::show(L"TaskList"sv);
				break;

			case KEY_NUMDEL:
			case KEY_DEL:
			{
				if (const auto MenuData = ProcList->GetComplexUserDataPtr<menu_data>())
				{
					if (Message(MSG_WARNING,
						msg(lng::MKillProcessTitle),
						{
							msg(lng::MAskKillProcess),
							MenuData->Title,
							msg(lng::MKillProcessWarning)
						},
						{ lng::MKillProcessKill, lng::MCancel }) == Message::first_button)
					{
						const os::handle Process(OpenProcess(PROCESS_TERMINATE, FALSE, MenuData->Pid));
						if (!Process || !TerminateProcess(Process.native_handle(), 0xFFFFFFFF))
						{
							const auto ErrorState = error_state::fetch();

							Message(MSG_WARNING, ErrorState,
								msg(lng::MKillProcessTitle),
								{
									msg(lng::MCannotKillProcess)
								},
								{ lng::MOk });
						}
					}
				}
			}
			[[fallthrough]];
			case KEY_CTRLR:
			case KEY_RCTRLR:
			{
				if (!FillProcList())
					ProcList->Close(-1);
				break;
			}

			case KEY_F2:
			{
				// TODO: change titles, don't enumerate again
				ShowImage = !ShowImage;
				const auto SelectPos = ProcList->GetSelectPos();
				if (!FillProcList())
				{
					ProcList->Close(-1);
				}
				else
				{
					ProcList->SetSelectPos(SelectPos);
				}
				break;
			}


			default:
				KeyProcessed = 0;
		}
		return KeyProcessed;
	});

	if (ProcList->GetExitCode() < 0)
		return;

	const auto MenuData = ProcList->GetComplexUserDataPtr<menu_data>();
	if (!MenuData)
		return;

	SwitchToWindow(MenuData->Hwnd);
}
Esempio n. 22
0
bool MaxListCtrl::SetSortCallback() {
	return SortItems(compare, wxPtrToUInt((void*)maxHandle));
}
void CLibraryDetailView::OnColumnClick(NM_LISTVIEW* pNotify, LRESULT* pResult)
{
	*pResult = 0;
	SortItems( pNotify->iSubItem );
}
Esempio n. 24
0
void browsers::topedlay_list::OnSort(wxListEvent& event)
{
    long col = event.GetColumn();
    SortItems(wxListCompareFunction, col);
}
Esempio n. 25
0
void wxFileListCtrl::UpdateFiles()
{
    // don't do anything before ShowModal() call which sets m_dirName
    if ( m_dirName == wxT("*") )
        return;

    wxBusyCursor bcur; // this may take a while...

    DeleteAllItems();

    wxListItem item;
    item.m_itemId = 0;
    item.m_col = 0;

#if (defined(__WINDOWS__) || defined(__DOS__) || defined(__WXMAC__) || defined(__OS2__)) && !defined(__WXWINCE__)
    if ( IsTopMostDir(m_dirName) )
    {
        wxArrayString names, paths;
        wxArrayInt icons;
        const size_t count = wxGetAvailableDrives(paths, names, icons);

        for ( size_t n = 0; n < count; n++ )
        {
            // use paths[n] as the drive name too as our HandleAction() can't
            // deal with the drive names (of the form "System (C:)") currently
            // as it mistakenly treats them as file names
            //
            // it would be preferable to show names, and not paths, in the
            // dialog just as the native dialog does but for this we must:
            //  a) store the item type as item data and modify HandleAction()
            //     to use it instead of wxDirExists() to check whether the item
            //     is a directory
            //  b) store the drives by their drive letters and not their
            //     descriptions as otherwise it's pretty confusing to the user
            wxFileData *fd = new wxFileData(paths[n], paths[n],
                                            wxFileData::is_drive, icons[n]);
            if (Add(fd, item) != -1)
                item.m_itemId++;
            else
                delete fd;
        }
    }
    else
#endif // defined(__DOS__) || defined(__WINDOWS__)
    {
        // Real directory...
        if ( !IsTopMostDir(m_dirName) && !m_dirName.empty() )
        {
            wxString p(wxPathOnly(m_dirName));
#if (defined(__UNIX__) || defined(__WXWINCE__)) && !defined(__OS2__)
            if (p.empty()) p = wxT("/");
#endif // __UNIX__
            wxFileData *fd = new wxFileData(p, wxT(".."), wxFileData::is_dir, wxFileIconsTable::folder);
            if (Add(fd, item) != -1)
                item.m_itemId++;
            else
                delete fd;
        }

        wxString dirname(m_dirName);
#if defined(__DOS__) || defined(__WINDOWS__) || defined(__OS2__)
        if (dirname.length() == 2 && dirname[1u] == wxT(':'))
            dirname << wxT('\\');
#endif // defined(__DOS__) || defined(__WINDOWS__) || defined(__OS2__)

        if (dirname.empty())
            dirname = wxFILE_SEP_PATH;

        wxLogNull logNull;
        wxDir dir(dirname);

        if ( dir.IsOpened() )
        {
            wxString dirPrefix(dirname);
            if (dirPrefix.Last() != wxFILE_SEP_PATH)
                dirPrefix += wxFILE_SEP_PATH;

            int hiddenFlag = m_showHidden ? wxDIR_HIDDEN : 0;

            bool cont;
            wxString f;

            // Get the directories first (not matched against wildcards):
            cont = dir.GetFirst(&f, wxEmptyString, wxDIR_DIRS | hiddenFlag);
            while (cont)
            {
                wxFileData *fd = new wxFileData(dirPrefix + f, f, wxFileData::is_dir, wxFileIconsTable::folder);
                if (Add(fd, item) != -1)
                    item.m_itemId++;
                else
                    delete fd;

                cont = dir.GetNext(&f);
            }

            // Tokenize the wildcard string, so we can handle more than 1
            // search pattern in a wildcard.
            wxStringTokenizer tokenWild(m_wild, wxT(";"));
            while ( tokenWild.HasMoreTokens() )
            {
                cont = dir.GetFirst(&f, tokenWild.GetNextToken(),
                                        wxDIR_FILES | hiddenFlag);
                while (cont)
                {
                    wxFileData *fd = new wxFileData(dirPrefix + f, f, wxFileData::is_file, wxFileIconsTable::file);
                    if (Add(fd, item) != -1)
                        item.m_itemId++;
                    else
                        delete fd;

                    cont = dir.GetNext(&f);
                }
            }
        }
    }

    SortItems(m_sort_field, m_sort_forward);
}
Esempio n. 26
0
void wxGxContentView::Serialize(wxXmlNode* pRootNode, bool bStore)
{
	if(pRootNode == NULL)
		return;

	if(bStore)
	{
        if(pRootNode->HasAttribute(wxT("style")))
            pRootNode->DeleteAttribute(wxT("style"));
        SetDecimalValue(pRootNode, wxT("style"), m_current_style);
        if(pRootNode->HasAttribute(wxT("sort")))
            pRootNode->DeleteAttribute(wxT("sort"));
        SetBoolValue(pRootNode, wxT("sort"), m_bSortAsc);
        if(pRootNode->HasAttribute(wxT("sort_col")))
            pRootNode->DeleteAttribute(wxT("sort_col"));
        SetDecimalValue(pRootNode, wxT("sort_col"), m_currentSortCol);

        if(m_current_style == enumGISCVReport)
        {
            //store values
            m_anWidth.Clear();
            for (int i = 0; i < GetColumnCount(); ++i)
            {
                m_anWidth.Add( GetColumnWidth(i) );
            }
    #ifdef wxHAS_LISTCTRL_COLUMN_ORDER
            m_anOrder = GetColumnsOrder();
    #endif
        }

        wxString sCols;
        for(size_t i = 0; i < m_anWidth.GetCount(); ++i)
        {
            sCols += wxString::Format(wxT("%d"), m_anWidth[i]);
            sCols += wxT("|");
        }
        if(pRootNode->HasAttribute(wxT("cols_width")))
            pRootNode->DeleteAttribute(wxT("cols_width"));
        pRootNode->AddAttribute(wxT("cols_width"), sCols);

#ifdef wxHAS_LISTCTRL_COLUMN_ORDER
        wxString sOrd;
        for(size_t i = 0; i < m_anOrder.GetCount(); ++i)
        {
            sOrd += wxString::Format(wxT("%d"), m_anOrder[i]);
            sOrd += wxT("|");
        }

        if(pRootNode->HasAttribute(wxT("cols_order")))
            pRootNode->DeleteAttribute(wxT("cols_order"));
        pRootNode->AddAttribute(wxT("cols_order"), sOrd);
#endif

	}
	else
	{
		m_bSortAsc = GetBoolValue(pRootNode, wxT("sort"), true);
		m_currentSortCol = GetDecimalValue(pRootNode, wxT("sort_col"), 0);
		wxGISEnumContentsViewStyle style = (wxGISEnumContentsViewStyle)GetDecimalValue(pRootNode, wxT("style"), 0);
        //load col width
        wxString sCol = pRootNode->GetAttribute(wxT("cols_width"));
	    wxStringTokenizer tkz(sCol, wxString(wxT("|")), wxTOKEN_RET_EMPTY );
	    while ( tkz.HasMoreTokens() )
	    {
		    wxString token = tkz.GetNextToken();
		    //token.Replace(wxT("|"), wxT(""));
		    int nWidth = wxAtoi(token); //wxLIST_AUTOSIZE
            m_anWidth.Add(nWidth);
	    }

#ifdef wxHAS_LISTCTRL_COLUMN_ORDER
        //load col order
        wxString sOrd = pRootNode->GetAttribute(wxT("cols_order"));
	    wxStringTokenizer tkz_ord(sOrd, wxString(wxT("|")), wxTOKEN_RET_EMPTY );
	    while ( tkz_ord.HasMoreTokens() )
	    {
		    wxString token = tkz_ord.GetNextToken();
		    //token.Replace(wxT("|"), wxT(""));
		    m_anOrder.Add( wxAtoi(token) );
	    }
#endif

        SetStyle(style);

        SORTDATA sortdata = {m_bSortAsc, m_currentSortCol};
		SortItems(GxObjectCVCompareFunction, (long)&sortdata);
	}
}
Esempio n. 27
0
bool wxGISToolExecuteView::OnDropObjects(wxCoord x, wxCoord y, long nParentPointer, const wxArrayLong& TaskIds)
{
    wxBusyCursor wait;
    SetItemState(m_HighLightItem, 0, wxLIST_STATE_DROPHILITED);
    //SetItemState(m_HighLightItem, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);

    if(nParentPointer != wxThread::GetMainId())
        return false;

    wxPoint pt(x, y);
    unsigned long nFlags(0);
    long nItemId = HitTest(pt, (int &)nFlags);
    long nObjectID(m_nParentGxObjectId);

    if(nItemId == wxNOT_FOUND)
        return false;

    IGxTask* pBeforeTask(NULL);
    int nInsertPoint = GetItemCount() - TaskIds.GetCount(); //the end
    if(nFlags & wxLIST_HITTEST_ONITEM)
    {
        nInsertPoint = nItemId;// - 1;
        pBeforeTask = dynamic_cast<IGxTask*>(m_pCatalog->GetRegisterObject(GetItemData(nInsertPoint)));
    }

    //1. Read all items to map sortig using priority, but not adding moving items
    m_bDropping = true;
    std::map<long, IGxTask*> ItemsMap;
    for(int i = 0; i < GetItemCount(); ++i)
    {
        long nTaskId = GetItemData(i);
        if(TaskIds.Index(nTaskId) == wxNOT_FOUND)
        {
            IGxTask* pTask = dynamic_cast<IGxTask*>(m_pCatalog->GetRegisterObject(nTaskId));
            if(pTask && pTask->GetState() != enumGISTaskDone)
            {
                ItemsMap[pTask->GetPriority()] = pTask;
            }
        }
    }

    //wxWindowUpdateLocker noUpdates(this);

    //get min priority
    if(nInsertPoint < 0)
    {
        long nMinPrio = ItemsMap.begin()->first;
        for(size_t i = 0; i < TaskIds.GetCount(); ++i)
        {
            IGxTask* pTask = dynamic_cast<IGxTask*>(m_pCatalog->GetRegisterObject(TaskIds[i]));
            if(pTask)
            {
                pTask->SetPriority(++nMinPrio);
            }
        }
        for(std::map<long, IGxTask*>::iterator it = ItemsMap.begin(); it != ItemsMap.end(); ++it)
        {
            it->second->SetPriority(++nMinPrio);
        }
    }
    else if(nInsertPoint >= TaskIds.GetCount())
    {
        long nMinPrio = ItemsMap.begin()->first;
        for(std::map<long, IGxTask*>::iterator it = ItemsMap.begin(); it != ItemsMap.end(); ++it)
        {
            it->second->SetPriority(++nMinPrio);
        }

        for(size_t i = 0; i < TaskIds.GetCount(); ++i)
        {
            IGxTask* pTask = dynamic_cast<IGxTask*>(m_pCatalog->GetRegisterObject(TaskIds[i]));
            if(pTask)
            {
                pTask->SetPriority(++nMinPrio);
            }
        }
    }
    else
    {
        //2. Read from map until end for insert to array
        bool bSetPrio(false);
        long nMinPrio = wxNOT_FOUND;
        for(std::map<long, IGxTask*>::iterator it = ItemsMap.begin(); it != ItemsMap.end(); ++it)
        {
            if(pBeforeTask == it->second)
            {
                nMinPrio = pBeforeTask->GetPriority();
                for(size_t i = 0; i < TaskIds.GetCount(); ++i)
                {
                    IGxTask* pTask = dynamic_cast<IGxTask*>(m_pCatalog->GetRegisterObject(TaskIds[i]));
                    if(pTask)
                    {
                        pTask->SetPriority(++nMinPrio);
                    }
                }
                bSetPrio = true;
            }
            if(bSetPrio)
                it->second->SetPriority(++nMinPrio);
        }
    }

    SortItems(GxTaskCompareFunction, 0);

    m_bDropping = false;

    return true;
}
Esempio n. 28
0
//------------------------------------------------------------------------------
//
// 	Function Name:	CMLListCtrl::Sort()
//
//	Parameters:		iColumn - the id of the column to be sorted
//
// 	Return Value:	None
//
// 	Description:	This function is called to sort the list box.
//
//------------------------------------------------------------------------------
void CMLListCtrl::Sort(int iColumn) 
{
	SortItems(DoComparison, iColumn);
}
Esempio n. 29
0
void CMuleListCtrl::SortList()
{
	if (!IsSorting() && (m_sort_func && GetColumnCount())) {

		m_isSorting = true;
	
		MuleSortData sortdata(m_sort_orders, m_sort_func);

		// In many cases control already has correct order, and sorting causes nasty flickering.
		// Make one pass through it to check if sorting is necessary at all.
		int nrItems = GetItemCount();
		bool clean = true;
		long lastItemdata = 0;
		if (nrItems > 1) {
			lastItemdata = GetItemData(0);
		}
		for (int i = 1; i < nrItems; i++) {
			long nextItemdata = GetItemData(i);
			if (SortProc(lastItemdata, nextItemdata, (long int)&sortdata) > 0) {
				// ok - we need to sort
				clean = false;
				break;
			}
			lastItemdata = nextItemdata;
		}
		if (clean) {
			// no need to sort
			m_isSorting = false;
			return;
		}

		// Positions are likely to be invalid after sorting.
		ResetTTS();
		
		// Store the current selected items
		ItemDataList selectedItems = GetSelectedItems();
		// Store the focused item
		long pos = GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_FOCUSED );
		wxUIntPtr focused = (pos == -1) ? 0 : GetItemData(pos);
		
		SortItems(SortProc, (long int)&sortdata);
		
		// Re-select the selected items.
		for (unsigned i = 0; i < selectedItems.size(); ++i) {
			long it_pos = FindItem(-1, selectedItems[i]);
			if (it_pos != -1) {
				SetItemState(it_pos, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
			}
		}
		
		// Set focus on item if any was focused
		if (focused) {
			long it_pos = FindItem(-1, focused);
			if (it_pos != -1) {
				SetItemState(it_pos, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED);
			}
		}

		m_isSorting = false;
	}
}
Esempio n. 30
0
void CFolderListCtrl::RefreshFileList()
{
	std::vector<CFLCItemData *>arrListCache(m_nItemCount);
	int i;
	for (i=0;i<m_nItemCount;i++)
	{
		arrListCache[i] = reinterpret_cast<CFLCItemData *>(GetItemData(i));
		arrListCache[i]->m_bFoundOnRefresh = false;
	}

	SCStringVector::iterator itExt = m_Properties.m_vsExt.begin();
	CSCADString sPath;

	struct _tfinddata_t fd;

	int nLargeIconInd = 0;
	int nSmallIconInd = 0;
	int nItemCount = m_nItemCount;

	for( ; itExt != m_Properties.m_vsExt.end(); ++itExt )
	{
		sPath = m_sFolderPath + _T("\\") + *itExt;

		intptr_t hFindHandle = _tfindfirst( sPath, &fd );

		if( hFindHandle == -1 )
			continue;
		AddFileTypeIcons(fd, nLargeIconInd, nSmallIconInd);
		do
		{
			bool bFileFound = false;
			CSCADString sFileName;
			
			if( m_sFolderPath.GetLength() && 
				( m_sFolderPath[m_sFolderPath.GetLength()-1] == _T('\\') ||
				m_sFolderPath[m_sFolderPath.GetLength()-1] == _T('/') ) )
				sFileName = m_sFolderPath+ fd.name;
			else
				sFileName = m_sFolderPath + (  _T("\\") ) + fd.name;
			for (int k=0; k<nItemCount;k++)
			{
				if (arrListCache[k]->m_sFilePath == sFileName)
				{
					bFileFound = true;
					arrListCache[k]->m_bFoundOnRefresh = true;
					if (fd.time_write != arrListCache[k]->m_tModified)
					{
						arrListCache[k]->m_bProcessed = false;
						if (m_strSelectedPath.CompareNoCase(arrListCache[k]->m_sFilePath)==0)
						{
							CSCAD3DMdlSettings::Get3DS()->SetViewFilePath( arrListCache[k]->m_sFilePath, arrListCache[k]->m_sExt );
						}
						break;
					}
				}
			}
			if (!bFileFound)
			{
				AddFileItem(fd, nLargeIconInd, nSmallIconInd,*itExt);
			}
		} while( _tfindnext( hFindHandle, &fd ) != -1 );
		_findclose( hFindHandle );
	}
	m_nImageBalance = 0;
	for (i=0;i<m_nItemCount;i++)
	{
		CFLCItemData *pData = reinterpret_cast<CFLCItemData *>(GetItemData(i));
		if (!pData->m_bFoundOnRefresh)
		{
			delete pData;
			CListCtrl::DeleteItem(i);
			m_nItemCount--;
		}
		else
		{
			if (!pData->m_bProcessed)
				m_nImageBalance++;
		}

	}

	SortItems( m_flciColumns[m_nCurColumn].m_fnCmp, m_bSortAscending );

	ASSERT(m_nItemCount == GetItemCount());
	UpdateFileCount();
	SetRedrawItemPos( 0, true );

}