예제 #1
0
void
TMagnify::KeyDown(const char *key, int32 numBytes)
{
	if (!fShowSelection)
		BView::KeyDown(key, numBytes);

	uint32 mods = modifiers();

	switch (key[0]) {
		case B_TAB:
			if (fShowCrossHair1) {
				fSelection++;

				if (fShowCrossHair2) {
					if (fSelection > 2)
						fSelection = 0;
				} else if (fShowCrossHair1) {
					if (fSelection > 1)
						fSelection = 0;
				}
				fNeedToUpdate = true;
				Invalidate();
			}
			break;

		case B_LEFT_ARROW:
			if (mods & B_OPTION_KEY)
				NudgeMouse(-1,0);
			else
				MoveSelection(-1,0);
			break;
		case B_RIGHT_ARROW:
			if (mods & B_OPTION_KEY)
				NudgeMouse(1, 0);
			else
				MoveSelection(1,0);
			break;
		case B_UP_ARROW:
			if (mods & B_OPTION_KEY)
				NudgeMouse(0, -1);
			else
				MoveSelection(0,-1);
			break;
		case B_DOWN_ARROW:
			if (mods & B_OPTION_KEY)
				NudgeMouse(0, 1);
			else
				MoveSelection(0,1);
			break;

		default:
			BView::KeyDown(key,numBytes);
			break;
	}
}
예제 #2
0
void MenuState::OnKeyPressed(sf::Key::Code key, bool alt, bool ctrl, bool shift)
{
	if (key == sf::Key::Up)
	{
		MoveSelection(Direction::Up);
	}
	else if (key == sf::Key::Down)
	{
		MoveSelection(Direction::Down);
	}
	else if (key == sf::Key::Return)
	{
		Select(entries_[selection_].get_id());
	}
}
BOOL CTextEditor::MoveSelectionAtPoint(POINT pt)
{
    BOOL bRet = FALSE;
    UINT nSel = _layout.CharPosFromPoint(pt);
    if (nSel != (UINT)-1)
    {
        MoveSelection(nSel, nSel);
        bRet = TRUE;
    }
    return bRet;
}
예제 #4
0
dword ListPage::OnKey( dword key, dword extKey )
{
	HandleKey(RKEY_Exit, Close());
	if ((m_dwFlags & LF_ONE_ITEM_ONLY) == 0)
	{
		HandleExtKey2(RKEY_ChUp, RKEY_ChUp, RAWKEY_Up, MoveSelection(-1));
		HandleExtKey2(RKEY_ChDown, RKEY_ChDown, RAWKEY_Down, MoveSelection(1));
		HandleKey(RKEY_Forward, MoveSelection(CountItemsInView(), false));
		HandleKey(RKEY_Rewind, MoveSelection(-CountItemsInView(), false));
	}

	ListItem* pSelItem = ListPage::GetSelectedItem();
	if (pSelItem)
	{
		dword dwRet = pSelItem->OnKey(key, extKey);
		if ((dwRet == 0) && Tapplication::GetTheApplication() && !Tapplication::GetTheApplication()->IsClosing()
			&& Tapplication::GetTheApplication()->IsTopPage(this))
			Draw();
		return dwRet;
	}

	return key;
}
예제 #5
0
/*
================
Drag_MouseMoved
================
*/
void Drag_MouseMoved(int x, int y, int buttons) {
	idVec3	move, delta;
	int		i;

	if (!buttons || !drag_ok) {
		drag_ok = false;
		return;
	}

	// clear along one axis
	if (buttons & MK_SHIFT) {
		drag_first = false;
		if (abs(x - pressx) > abs(y - pressy)) {
			y = pressy;
		}
		else {
			x = pressx;
		}
	}

	for (i = 0; i < 3; i++) {
		move[i] = drag_xvec[i] * (x - pressx) + drag_yvec[i] * (y - pressy);
		if (!g_PrefsDlg.m_bNoClamp) {
			move[i] = floor(move[i] / g_qeglobals.d_gridsize + 0.5) * g_qeglobals.d_gridsize;
		}
	}

	VectorSubtract(move, pressdelta, delta);
	VectorCopy(move, pressdelta);

	if (buttons & MK_CONTROL && g_pParentWnd->ActiveXY()->RotateMode()) {
		for (i = 0; i < 3; i++) {
			if (delta[i] != 0) {
				if (delta[i] > 0) {
					delta[i] = 15;
				}
				else {
					delta[i] = -15;
				}
			}
		}
	}

	MoveSelection(delta);
}
예제 #6
0
bool C4Menu::Control(BYTE byCom, int32_t iData)
{
	if (!IsActive()) return false;

	switch (byCom)
	{
	case COM_MenuEnter: Enter(); break;
	case COM_MenuEnterAll: Enter(true); break;
	case COM_MenuClose: TryClose(false, true); break;

		// organize with nicer subfunction...
	case COM_MenuLeft:
		// Top wrap-around
		if (Selection-1 < 0)
			MoveSelection(ItemCount - 1 - Selection, true, true);
		else
			MoveSelection(-1, true, true);
		break;
	case COM_MenuRight:
		// Bottom wrap-around
		if (Selection+1 >= ItemCount)
			MoveSelection(-Selection, true, true);
		else
			MoveSelection(+1, true, true);
		break;
	case COM_MenuUp:
		iData = -Columns;
		// Top wrap-around
		if (Selection + iData < 0)
			while (Selection + iData + Columns < ItemCount)
				iData += Columns;
		MoveSelection(iData, true, true);
		break;
	case COM_MenuDown:
		iData = +Columns;
		// Bottom wrap-around
		if (Selection+iData >= ItemCount)
			while (Selection+iData-Columns >= 0)
				iData-=Columns;
		MoveSelection(iData, true, true);
		break;
	case COM_MenuSelect:
		if (ItemCount)
			SetSelection(iData & (~C4MN_AdjustPosition), !!(iData & C4MN_AdjustPosition), true);
		break;
	case COM_MenuShowText:
		SetTextProgress(-1, false);
		break;
	}

	return true;
}
예제 #7
0
/*
	DefaultName - имя элемента на которое позиционируемся.
	Closed - панель закрывается, если в PrevDataList что-то есть - восстанавливаемчся оттуда.
	UsePrev - если востанавливаемся из PrevDataList, элемент для позиционирования брать оттуда же.
	Position - надо ли вообще устанавливать текущий элемент.
*/
void FileList::PopPrevData(const string& DefaultName,bool Closed,bool UsePrev,bool Position,bool SetDirectorySuccess)
{
    string strName(DefaultName);
	if (Closed && !PrevDataList.Empty())
	{
		PrevDataItem* Item=*PrevDataList.Last();
		PrevDataList.Delete(PrevDataList.Last());
		if (Item->PrevFileCount>0)
		{
			MoveSelection(ListData,FileCount,Item->PrevListData,Item->PrevFileCount);
			UpperFolderTopFile = Item->PrevTopFile;

			if (UsePrev)
				strName = Item->strPrevName;

			DeleteListData(Item->PrevListData,Item->PrevFileCount);
			delete Item;

			if (SelectedFirst)
				SortFileList(FALSE);
			else if (FileCount>0)
				SortFileList(TRUE);
		}
	}
	if (Position)
	{
		long Pos=FindFile(PointToName(strName));

		if (Pos!=-1)
			CurFile=Pos;
		else
			GoToFile(strName);

		CurTopFile=UpperFolderTopFile;
		UpperFolderTopFile=0;
		CorrectPosition();
	}
	/* $ 26.04.2001 DJ
	   доделка про несброс выделения при неудаче SetDirectory
	*/
	else if (SetDirectorySuccess)
		CurFile=CurTopFile=0;
}
BOOL CTextEditor::MoveSelectionToLineFirstEnd(BOOL bFirst)
{
    BOOL bRet = FALSE;
    UINT nSel;

    if (bFirst)
    {
        nSel = _layout.FineFirstEndCharPosInLine(_nSelStart, TRUE);
    }
    else
    {
        nSel = _layout.FineFirstEndCharPosInLine(_nSelEnd, FALSE);
    }

    if (nSel != (UINT)-1)
    {
        MoveSelection(nSel, nSel);
        bRet = TRUE;
    }
    return bRet;
}
예제 #9
0
파일: drag.cpp 프로젝트: FS-NulL/Q3Radiant
/*
===========
Drag_MouseMoved
===========
*/
void Drag_MouseMoved (int x, int y, int buttons)
{
	vec3_t	move, delta;
	int		i;

	if (!buttons)
	{
		drag_ok = false;
		return;
	}
	if (!drag_ok)
		return;

	// clear along one axis
	if (buttons & MK_SHIFT)
	{
		drag_first = false;
		if (abs(x-pressx) > abs(y-pressy))
			y = pressy;
		else
			x = pressx;
	}


	for (i=0 ; i<3 ; i++)
	{
		move[i] = drag_xvec[i]*(x - pressx)	+ drag_yvec[i]*(y - pressy);
    if (!g_PrefsDlg.m_bNoClamp)
    {
		  move[i] = floor(move[i]/g_qeglobals.d_gridsize+0.5)*g_qeglobals.d_gridsize;
    }
	}

	VectorSubtract (move, pressdelta, delta);
	VectorCopy (move, pressdelta);

  MoveSelection (delta);

}
예제 #10
0
dword AutoStartPage::OnKey( dword key, dword extKey )
{
	switch ( key )
	{
	case RKEY_Exit:
		if ( CanExit() )
			Close();
		return 0;
	case RKEY_Mute:
		// pass Mute to the firmware
		return key;
	case RKEY_Menu:
	{
		if (menuActivates)
		{
			Close();
			return key;
		}
		Replace(new ConfigPage());
		return 0;
	}
	case RKEY_PlayList:
		if ( CanExit() )
			Replace(new LoadedTAPPage());
		return 0;
	case RKEY_VolUp:
	{
		int index = GetSelectedIndex();
		if ( index < (int)m_taps.size()-1 )
		{
			// swap the filenames
			AutoStartTAP t = m_taps[index];
			m_taps[index] = m_taps[index+1];
			m_taps[index+1] = t;
			// move the selection
			MoveSelection( 1, false );
			m_dirty = true;
		}
		return 0;
	}
	case RKEY_VolDown:
	{
		int index = GetSelectedIndex();
		if ( index > 0 && index < (int)m_taps.size() )
		{
			// swap the filenames
			AutoStartTAP t = m_taps[index];
			m_taps[index] = m_taps[index-1];
			m_taps[index-1] = t;
			// move the selection
			MoveSelection( -1, false );
			m_dirty = true;
		}
		return 0;
	}
	case RKEY_NewF1:
	{
		// enable/disable TAP
		int index = GetSelectedIndex();
		EnableTAP( index, !m_taps[index].enabled );
		return 0;
	}
	case RKEY_F2:
	{
		int index = GetSelectedIndex();
		if ( index < (int)m_taps.size() )
		{
			bool enable = !m_taps[index].enabled;
			for ( unsigned int i = 0; i < m_taps.size(); ++i )
				EnableTAP( i, enable );
		}
		return 0;
	}
	// Discard changes
	case RKEY_Recall:
		// get rid of the list items, then the 
		DiscardItems();
		AddItem(new SimpleTextListItem(this, 0, "", "Loading..."));
		Draw();
		PopulateList();
		m_dirty = false;
		return 0;
	// Save Changes
	case RKEY_Record:
		Save();
		Close();
		return 0;
	}
	ListPage::OnKey( key, extKey );

	return 0;
}
예제 #11
0
void FileList::UpdatePlugin(int KeepSelection, int IgnoreVisible)
{
	_ALGO(CleverSysLog clv(L"FileList::UpdatePlugin"));
	_ALGO(SysLog(L"(KeepSelection=%d, IgnoreVisible=%d)",KeepSelection,IgnoreVisible));

	if (!IsVisible() && !IgnoreVisible)
	{
		UpdateRequired=TRUE;
		UpdateRequiredMode=KeepSelection;
		return;
	}

	DizRead=FALSE;
	FileListItem *CurPtr, **OldData=0;
	string strCurName, strNextCurName;
	int OldFileCount=0;
	StopFSWatcher();
	LastCurFile=-1;
	OpenPanelInfo Info;
	CtrlObject->Plugins->GetOpenPanelInfo(hPlugin,&Info);

	FreeDiskSize=0;
	if (Opt.ShowPanelFree)
	{
		if (Info.Flags & OPIF_REALNAMES)
		{
			unsigned __int64 TotalSize,TotalFree;
			if (!apiGetDiskSize(strCurDir,&TotalSize,&TotalFree,&FreeDiskSize))
				FreeDiskSize=0;
		}
		else if (Info.Flags & OPIF_USEFREESIZE)
			FreeDiskSize=Info.FreeSize;
	}

	PluginPanelItem *PanelData=nullptr;
	size_t PluginFileCount;

	if (!CtrlObject->Plugins->GetFindData(hPlugin,&PanelData,&PluginFileCount,0))
	{
		DeleteListData(ListData,FileCount);
		PopPlugin(TRUE);
		Update(KeepSelection);

		// WARP> явный хак, но очень способствует - восстанавливает позицию на панели при ошибке чтения архива.
		if (!PrevDataList.Empty())
			GoToFile((*PrevDataList.Last())->strPrevName);

		return;
	}

	size_t PrevSelFileCount=SelFileCount;
	SelFileCount=0;
	SelFileSize=0;
	TotalFileCount=0;
	TotalFileSize=0;
	CacheSelIndex=-1;
	CacheSelClearIndex=-1;
	strPluginDizName.Clear();

	if (FileCount>0)
	{
		CurPtr=ListData[CurFile];
		strCurName = CurPtr->strName;

		if (CurPtr->Selected)
		{
			for (int i=CurFile+1; i < FileCount; i++)
			{
				CurPtr = ListData[i];

				if (!CurPtr->Selected)
				{
					strNextCurName = CurPtr->strName;
					break;
				}
			}
		}
	}
	else if (Info.Flags & OPIF_ADDDOTS)
	{
		strCurName = L"..";
	}

	if (KeepSelection || PrevSelFileCount>0)
	{
		OldData=ListData;
		OldFileCount=FileCount;
	}
	else
	{
		DeleteListData(ListData,FileCount);
	}

	FileCount=static_cast<int>(PluginFileCount);
	ListData=(FileListItem**)xf_malloc(sizeof(FileListItem*)*(FileCount+1));

	if (!ListData)
	{
		FileCount=0;
		return;
	}

	if (!Filter)
		Filter=new FileFilter(this,FFT_PANEL);

	//Рефреш текущему времени для фильтра перед началом операции
	Filter->UpdateCurrentTime();
	CtrlObject->HiFiles->UpdateCurrentTime();
	int DotsPresent=FALSE;
	int FileListCount=0;
	bool UseFilter=Filter->IsEnabledOnPanel();

	for (int i=0; i < FileCount; i++)
	{
		ListData[FileListCount] = new FileListItem;
		FileListItem *CurListData=ListData[FileListCount];
		CurListData->Clear();

		if (UseFilter && !(Info.Flags & OPIF_DISABLEFILTER))
		{
			//if (!(CurPanelData->FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
			if (!Filter->FileInFilter(PanelData[i]))
				continue;
		}

		if (!Opt.ShowHidden && (PanelData[i].FileAttributes & (FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM)))
			continue;

		//ClearStruct(*CurListData);
		PluginToFileListItem(&PanelData[i],CurListData);
		CurListData->Position=i;

		if (!(Info.Flags & OPIF_DISABLESORTGROUPS)/* && !(CurListData->FileAttr & FILE_ATTRIBUTE_DIRECTORY)*/)
			CurListData->SortGroup=CtrlObject->HiFiles->GetGroup(CurListData);
		else
			CurListData->SortGroup=DEFAULT_SORT_GROUP;

		if (!CurListData->DizText)
		{
			CurListData->DeleteDiz=FALSE;
			//CurListData->DizText=nullptr;
		}

		if (TestParentFolderName(CurListData->strName))
		{
			DotsPresent=TRUE;
			CurListData->FileAttr|=FILE_ATTRIBUTE_DIRECTORY;
		}
		else if (!(CurListData->FileAttr & FILE_ATTRIBUTE_DIRECTORY))
		{
			TotalFileCount++;
		}

		TotalFileSize += CurListData->FileSize;
		FileListCount++;
	}

	if (!(Info.Flags & OPIF_DISABLEHIGHLIGHTING) || (Info.Flags & OPIF_USEATTRHIGHLIGHTING))
		CtrlObject->HiFiles->GetHiColor(ListData,FileListCount,(Info.Flags&OPIF_USEATTRHIGHLIGHTING)!=0);

	FileCount=FileListCount;

	if ((Info.Flags & OPIF_ADDDOTS) && !DotsPresent)
	{
		ListData[FileCount] = new FileListItem;
		CurPtr = ListData[FileCount];
		CurPtr->Clear();
		AddParentPoint(CurPtr,FileCount);

		if (!(Info.Flags & OPIF_DISABLEHIGHLIGHTING) || (Info.Flags & OPIF_USEATTRHIGHLIGHTING))
			CtrlObject->HiFiles->GetHiColor(&CurPtr,1,(Info.Flags&OPIF_USEATTRHIGHLIGHTING)!=0);

		if (Info.HostFile && *Info.HostFile)
		{
			FAR_FIND_DATA_EX FindData;

			if (apiGetFindDataEx(Info.HostFile, FindData))
			{
				CurPtr->WriteTime=FindData.ftLastWriteTime;
				CurPtr->CreationTime=FindData.ftCreationTime;
				CurPtr->AccessTime=FindData.ftLastAccessTime;
				CurPtr->ChangeTime=FindData.ftChangeTime;
			}
		}

		FileCount++;
	}

	if (CurFile >= FileCount)
		CurFile = FileCount ? FileCount-1 : 0;

	/* $ 25.02.2001 VVM
	    ! Не считывать повторно список файлов с панели плагина */
	if (IsColumnDisplayed(DIZ_COLUMN))
		ReadDiz(PanelData,static_cast<int>(PluginFileCount),RDF_NO_UPDATE);

	CorrectPosition();
	CtrlObject->Plugins->FreeFindData(hPlugin,PanelData,PluginFileCount);

	if (KeepSelection || PrevSelFileCount>0)
	{
		MoveSelection(ListData,FileCount,OldData,OldFileCount);
		DeleteListData(OldData,OldFileCount);
	}

	if (!KeepSelection && PrevSelFileCount>0)
	{
		SaveSelection();
		ClearSelection();
	}

	SortFileList(FALSE);

	if (CurFile>=FileCount || StrCmpI(ListData[CurFile]->strName,strCurName))
		if (!GoToFile(strCurName) && !strNextCurName.IsEmpty())
			GoToFile(strNextCurName);

	SetTitle();
}
예제 #12
0
void FileList::ReadFileNames(int KeepSelection, int IgnoreVisible, int DrawMessage)
{
	TPreRedrawFuncGuard preRedrawFuncGuard(PR_ReadFileNamesMsg);
	TaskBar TB(false);

	strOriginalCurDir=strCurDir;

	if (!IsVisible() && !IgnoreVisible)
	{
		UpdateRequired=TRUE;
		UpdateRequiredMode=KeepSelection;
		return;
	}

	UpdateRequired=FALSE;
	AccessTimeUpdateRequired=FALSE;
	DizRead=FALSE;
	FAR_FIND_DATA_EX fdata;
	FileListItem *CurPtr=0,**OldData=0;
	string strCurName, strNextCurName;
	int OldFileCount=0;
	StopFSWatcher();

	if (this!=CtrlObject->Cp()->LeftPanel && this!=CtrlObject->Cp()->RightPanel)
		return;

	string strSaveDir;
	apiGetCurrentDirectory(strSaveDir);
	{
		string strOldCurDir = strCurDir;

		if (!SetCurPath())
		{
			FlushInputBuffer(); // Очистим буффер ввода, т.к. мы уже можем быть в другом месте...

			if (!StrCmp(strCurDir, strOldCurDir)) //?? i??
			{
				GetPathRoot(strOldCurDir,strOldCurDir);

				if (!apiIsDiskInDrive(strOldCurDir))
					IfGoHome(strOldCurDir.At(0));

				/* При смене каталога путь не изменился */
			}

			return;
		}
	}
	SortGroupsRead=FALSE;

	if (GetFocus())
		CtrlObject->CmdLine->SetCurDir(strCurDir);

	LastCurFile=-1;
	Panel *AnotherPanel=CtrlObject->Cp()->GetAnotherPanel(this);
	AnotherPanel->QViewDelTempName();
	size_t PrevSelFileCount=SelFileCount;
	SelFileCount=0;
	SelFileSize=0;
	TotalFileCount=0;
	TotalFileSize=0;
	CacheSelIndex=-1;
	CacheSelClearIndex=-1;

	if (Opt.ShowPanelFree)
	{
		unsigned __int64 TotalSize,TotalFree;

		if (!apiGetDiskSize(strCurDir,&TotalSize,&TotalFree,&FreeDiskSize))
			FreeDiskSize=0;
	}

	if (FileCount>0)
	{
		strCurName = ListData[CurFile]->strName;

		if (ListData[CurFile]->Selected)
		{
			for (int i=CurFile+1; i < FileCount; i++)
			{
				CurPtr = ListData[i];

				if (!CurPtr->Selected)
				{
					strNextCurName = CurPtr->strName;
					break;
				}
			}
		}
	}

	if (KeepSelection || PrevSelFileCount>0)
	{
		OldData=ListData;
		OldFileCount=FileCount;
	}
	else
		DeleteListData(ListData,FileCount);

	ListData=nullptr;
	int ReadOwners=IsColumnDisplayed(OWNER_COLUMN);
	int ReadNumLinks=IsColumnDisplayed(NUMLINK_COLUMN);
	int ReadNumStreams=IsColumnDisplayed(NUMSTREAMS_COLUMN);
	int ReadStreamsSize=IsColumnDisplayed(STREAMSSIZE_COLUMN);
	string strComputerName;

	if (ReadOwners)
	{
		CurPath2ComputerName(strCurDir, strComputerName);
		// сбросим кэш SID`ов
		SIDCacheFlush();
	}

	SetLastError(ERROR_SUCCESS);
	int AllocatedCount=0;
	FileListItem *NewPtr;
	// сформируем заголовок вне цикла
	wchar_t Title[2048];
	int TitleLength=Min((int)X2-X1-1,(int)(ARRAYSIZE(Title))-1);
	//wmemset(Title,0x0CD,TitleLength); //BUGBUG
	//Title[TitleLength]=0;
	MakeSeparator(TitleLength, Title, 9, nullptr);
	BOOL IsShowTitle=FALSE;
	BOOL NeedHighlight=Opt.Highlight && PanelMode != PLUGIN_PANEL;

	if (!Filter)
		Filter=new FileFilter(this,FFT_PANEL);

	//Рефреш текущему времени для фильтра перед началом операции
	Filter->UpdateCurrentTime();
	CtrlObject->HiFiles->UpdateCurrentTime();
	bool bCurDirRoot = false;
	ParsePath(strCurDir, nullptr, &bCurDirRoot);
	PATH_TYPE Type = ParsePath(strCurDir, nullptr, &bCurDirRoot);
	bool NetRoot = bCurDirRoot && (Type == PATH_REMOTE || Type == PATH_REMOTEUNC);

	FileCount = 0;
	string strFind = strCurDir;
	AddEndSlash(strFind);
	strFind+=L'*';
	::FindFile Find(strFind, true);
	DWORD FindErrorCode = ERROR_SUCCESS;
	bool UseFilter=Filter->IsEnabledOnPanel();
	bool ReadCustomData=IsColumnDisplayed(CUSTOM_COLUMN0)!=0;

	DWORD StartTime = GetTickCount();

	while (Find.Get(fdata))
	{
		FindErrorCode = GetLastError();

		if ((Opt.ShowHidden || !(fdata.dwFileAttributes & (FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM))) && (!UseFilter || Filter->FileInFilter(fdata, nullptr, &fdata.strFileName)))
		{
			if (FileCount>=AllocatedCount)
			{
				AllocatedCount+=4096;
				FileListItem **pTemp;

				if (!(pTemp=(FileListItem **)xf_realloc(ListData,AllocatedCount*sizeof(*ListData))))
					break;

				ListData=pTemp;
			}

			ListData[FileCount] = new FileListItem;
			ListData[FileCount]->Clear();
			NewPtr=ListData[FileCount];
			NewPtr->FileAttr = fdata.dwFileAttributes;
			NewPtr->CreationTime = fdata.ftCreationTime;
			NewPtr->AccessTime = fdata.ftLastAccessTime;
			NewPtr->WriteTime = fdata.ftLastWriteTime;
			NewPtr->ChangeTime = fdata.ftChangeTime;
			NewPtr->FileSize = fdata.nFileSize;
			NewPtr->AllocationSize = fdata.nAllocationSize;
			NewPtr->strName = fdata.strFileName;
			NewPtr->strShortName = fdata.strAlternateFileName;
			NewPtr->Position=FileCount++;
			NewPtr->NumberOfLinks=1;

			if (fdata.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)
			{
				NewPtr->ReparseTag=fdata.dwReserved0; //MSDN
			}
			if (!(fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
			{
				TotalFileSize += NewPtr->FileSize;

				if (ReadNumLinks)
					NewPtr->NumberOfLinks=GetNumberOfLinks(fdata.strFileName);
			}
			else
			{
				NewPtr->AllocationSize = 0;
			}

			NewPtr->SortGroup=DEFAULT_SORT_GROUP;

			if (ReadOwners)
			{
				string strOwner;
				GetFileOwner(strComputerName, NewPtr->strName,strOwner);
				NewPtr->strOwner = strOwner;
			}

			NewPtr->NumberOfStreams=NewPtr->FileAttr&FILE_ATTRIBUTE_DIRECTORY?0:1;
			NewPtr->StreamsSize=NewPtr->FileSize;

			if (ReadNumStreams||ReadStreamsSize)
			{
				EnumStreams(TestParentFolderName(fdata.strFileName)?strCurDir:fdata.strFileName,NewPtr->StreamsSize,NewPtr->NumberOfStreams);
			}

			if (ReadCustomData)
				CtrlObject->Plugins->GetCustomData(NewPtr);

			if (!(fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
				TotalFileCount++;

			//memcpy(ListData+FileCount,&NewPtr,sizeof(NewPtr));
//      FileCount++;

			DWORD CurTime = GetTickCount();
			if (CurTime - StartTime > RedrawTimeout)
			{
				StartTime = CurTime;
				if (IsVisible())
				{
					if (!IsShowTitle)
					{
						if (!DrawMessage)
						{
							Text(X1+1,Y1,ColorIndexToColor(COL_PANELBOX),Title);
							IsShowTitle=TRUE;
							SetColor(Focus ? COL_PANELSELECTEDTITLE:COL_PANELTITLE);
						}
					}

					LangString strReadMsg(MReadingFiles);
					strReadMsg << FileCount;

					if (DrawMessage)
					{
						ReadFileNamesMsg(strReadMsg);
					}
					else
					{
						TruncStr(strReadMsg,TitleLength-2);
						int MsgLength=(int)strReadMsg.GetLength();
						GotoXY(X1+1+(TitleLength-MsgLength-1)/2,Y1);
						FS<<L" "<<strReadMsg<<L" ";
					}
				}

				if (CheckForEsc())
				{
					break;
				}
			}
		}
	}

	if (!(FindErrorCode==ERROR_SUCCESS || FindErrorCode==ERROR_NO_MORE_FILES || FindErrorCode==ERROR_FILE_NOT_FOUND))
		Message(MSG_WARNING|MSG_ERRORTYPE,1,MSG(MError),MSG(MReadFolderError),MSG(MOk));

	if ((Opt.ShowDotsInRoot || !bCurDirRoot) || (NetRoot && CtrlObject->Plugins->FindPlugin(Opt.KnownIDs.Network))) // NetWork Plugin
	{
		if (FileCount>=AllocatedCount)
		{
			FileListItem **pTemp;

			if ((pTemp=(FileListItem **)xf_realloc(ListData,(FileCount+1)*sizeof(*ListData))))
				ListData=pTemp;
		}

		if (ListData)
		{
			ListData[FileCount] = new FileListItem;

			string TwoDotsOwner;
			if (ReadOwners)
			{
				GetFileOwner(strComputerName,strCurDir,TwoDotsOwner);
			}

			FILETIME TwoDotsTimes[4]={};
			if(apiGetFindDataEx(strCurDir,fdata))
			{
				TwoDotsTimes[0]=fdata.ftCreationTime;
				TwoDotsTimes[1]=fdata.ftLastAccessTime;
				TwoDotsTimes[2]=fdata.ftLastWriteTime;
				TwoDotsTimes[3]=fdata.ftChangeTime;
			}

			AddParentPoint(ListData[FileCount],FileCount,TwoDotsTimes,TwoDotsOwner);

			FileCount++;
		}
	}

	if (IsColumnDisplayed(DIZ_COLUMN))
		ReadDiz();

	if (NeedHighlight)
	{
		CtrlObject->HiFiles->GetHiColor(ListData, FileCount);
	}

	if (AnotherPanel->GetMode()==PLUGIN_PANEL)
	{
		HANDLE hAnotherPlugin=AnotherPanel->GetPluginHandle();
		PluginPanelItem *PanelData=nullptr;
		string strPath;
		size_t PanelCount=0;
		strPath = strCurDir;
		AddEndSlash(strPath);

		if (CtrlObject->Plugins->GetVirtualFindData(hAnotherPlugin,&PanelData,&PanelCount,strPath))
		{
			FileListItem **pTemp;

			if ((pTemp=(FileListItem **)xf_realloc(ListData,(FileCount+PanelCount)*sizeof(*ListData))))
			{
				ListData=pTemp;

				for (size_t i=0; i < PanelCount; i++)
				{
					CurPtr = ListData[FileCount+i];
					PluginPanelItem &pfdata=PanelData[i];
					PluginToFileListItem(&PanelData[i],CurPtr);
					CurPtr->Position=FileCount;
					TotalFileSize += pfdata.FileSize;
					CurPtr->PrevSelected=CurPtr->Selected=0;
					CurPtr->ShowFolderSize=0;
					CurPtr->SortGroup=CtrlObject->HiFiles->GetGroup(CurPtr);

					if (!TestParentFolderName(pfdata.FileName) && !(CurPtr->FileAttr & FILE_ATTRIBUTE_DIRECTORY))
						TotalFileCount++;
				}

				// цветовую боевую раскраску в самом конце, за один раз
				CtrlObject->HiFiles->GetHiColor(&ListData[FileCount],PanelCount);
				FileCount+=static_cast<int>(PanelCount);
			}

			CtrlObject->Plugins->FreeVirtualFindData(hAnotherPlugin,PanelData,PanelCount);
		}
	}

	InitFSWatcher(false);
	CorrectPosition();

	if (KeepSelection || PrevSelFileCount>0)
	{
		MoveSelection(ListData,FileCount,OldData,OldFileCount);
		DeleteListData(OldData,OldFileCount);
	}

	if (SortGroups)
		ReadSortGroups(false);

	if (!KeepSelection && PrevSelFileCount>0)
	{
		SaveSelection();
		ClearSelection();
	}

	SortFileList(FALSE);

	if (CurFile>=FileCount || StrCmpI(ListData[CurFile]->strName,strCurName))
		if (!GoToFile(strCurName) && !strNextCurName.IsEmpty())
			GoToFile(strNextCurName);

	/* $ 13.02.2002 DJ
		SetTitle() - только если мы текущий фрейм!
	*/
	if (CtrlObject->Cp() == FrameManager->GetCurrentFrame())
		SetTitle();

	FarChDir(strSaveDir); //???
}
예제 #13
0
void TB_StageSelect::HandleInput()
{
	bool button_down = false;

	if (textbox.YesNoPrompt.IsVisible() || fMadeSelection)
		return;
	
#ifdef CONFIG_USE_TAPS
	// taps control
	{
		int nslots = CountActiveSlots();
		int total_spacing = ((nslots - 1) * LOCS_SPACING);
		int total_width = total_spacing + (nslots * sprites[SPR_STAGEIMAGE].w);
		int x = (Graphics::SCREEN_WIDTH / 2) - (total_width / 2);
		
		for (int i = 0; i < nslots; ++i)
		{
			RectI rect = Sprites::get_sprite_rect(x, LOCS_Y, SPR_STAGEIMAGE);
			if (VJoy::ModeAware::wasTap(rect))
			{
				if (fSelectionIndex == i)
				{
					button_down = true;
					fLastButtonDown = false;
					
					VJoy::ModeAware::specScreenChanged(VJoy::ModeAware::EStageSelect1, false);
					VJoy::ModeAware::specScreenChanged(VJoy::ModeAware::EStageSelect2, true);
				}
				else
				{
					fSelectionIndex = i;
					sound(SND_MENU_MOVE);
					UpdateText();
				}
				
				break;
			}
			
			x += (sprites[SPR_STAGEIMAGE].w + LOCS_SPACING);
		}
	}
#endif 
	
	// pad control
	{
		if (justpushed(LEFTKEY))
		{
			MoveSelection(LEFT);
		}
		else if (justpushed(RIGHTKEY))
		{
			MoveSelection(RIGHT);
		}
		
		// when user picks a location return the new script to execute
		button_down = button_down || buttondown();
	}
	
	if (button_down && !fLastButtonDown)
	{
		int scriptno;
		if (!GetSlotByIndex(fSelectionIndex, NULL, &scriptno))
		{
			stat("StageSelect: starting activation script %d", scriptno);
			JumpScript(scriptno, SP_MAP);
		}
		else
		{	// dismiss "no permission to teleport"
			StopScripts();
		}
		
		fMadeSelection = true;
	}
	
	fLastButtonDown = button_down;
}
bool C4EditCursor::Move(float iX, float iY, DWORD dwKeyState)
{
	// alt check
	bool fAltIsDown = (dwKeyState & MK_ALT) != 0;
	if (fAltIsDown != fAltWasDown)
	{
		if ((fAltWasDown = fAltIsDown))
			AltDown();
		else
			AltUp();
	}

	// shift check
	bool fShiftIsDown = (dwKeyState & MK_SHIFT) != 0;
	if(fShiftIsDown != fShiftWasDown)
		fShiftWasDown = fShiftIsDown;

	// Offset movement
	float xoff = iX-X; float yoff = iY-Y;
	X=iX; Y=iY;

	switch (Mode)
	{
		// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	case C4CNS_ModeEdit:
		// Hold
		if (!DragFrame && Hold)
		{
			MoveSelection(ftofix(xoff),ftofix(yoff));
			UpdateDropTarget(dwKeyState);
		}
		// Update target
		// Shift always indicates a target outside the current selection
		else
		{
			Target = ((dwKeyState & MK_SHIFT) && Selection.Last) ? Selection.Last->Obj : NULL;
			do
			{
				Target = Game.FindObject(C4ID::None,X,Y,0,0,OCF_NotContained, Target);
			}
			while ((dwKeyState & MK_SHIFT) && Target && Selection.GetLink(Target));
		}
		break;
		// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	case C4CNS_ModeDraw:
		switch (Console.ToolsDlg.Tool)
		{
		case C4TLS_Brush:
			if (Hold) ApplyToolBrush();
			break;
		case C4TLS_Line: case C4TLS_Rect:
			break;
		}
		break;
		// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	}

	// Update
	UpdateStatusBar();
	return true;
}
예제 #15
0
void DisassemblyView::keyPressEvent(QKeyEvent * evt)
{
  bool InvView = false;

  // Move cursor
  if (evt->matches(QKeySequence::MoveToNextChar))
  { MoveCursor(+1, 0, InvView); ResetSelection(); }
  if (evt->matches(QKeySequence::MoveToPreviousChar))
  { MoveCursor(-1, 0, InvView); ResetSelection(); }

  if (evt->matches(QKeySequence::MoveToStartOfLine))
  { SetCursor(_addrLen, -1); ResetSelection(); }
  if (evt->matches(QKeySequence::MoveToEndOfLine))
  {
    medusa::LineData Line;
    if (m_PrintData.GetLine(m_Cursor.m_Address, m_Cursor.m_yAddressOffset, Line))
    {
      auto TextLen = static_cast<medusa::u32>(Line.GetText().length());
      if (TextLen != 0)
        --TextLen;
      SetCursor(TextLen, -1);
    }
  }

  if (evt->matches(QKeySequence::MoveToNextLine))
  { moveCursorPosition(0, +1); ResetSelection(); }
  if (evt->matches(QKeySequence::MoveToPreviousLine))
  { moveCursorPosition(0, -1); ResetSelection(); }

  if (evt->matches(QKeySequence::MoveToNextPage))
  { MoveCursor(0, +m_Height, InvView); ResetSelection(); }
  if (evt->matches(QKeySequence::MoveToPreviousPage))
  { MoveCursor(0, -static_cast<medusa::s32>(m_Height), InvView); ResetSelection(); }

  if (evt->matches(QKeySequence::MoveToStartOfDocument))
  {
    medusa::Address FirstAddr = m_rDoc.GetFirstAddress();
    m_Cursor.m_Address = FirstAddr;
    m_Cursor.m_yAddressOffset = 0;
    m_Top = m_Cursor;
    m_Format(FirstAddr, m_FormatFlags, m_Height);
    ResetSelection();
  }
  if (evt->matches(QKeySequence::MoveToEndOfDocument))
  {
    medusa::Address LastAddr = m_rDoc.GetLastAddress();
    m_Cursor.m_Address = LastAddr;
    m_Cursor.m_yAddressOffset = 0;
    m_Top = m_Cursor;
    m_Format(LastAddr, m_FormatFlags, m_Height);
    ResetSelection();
  }

  if (evt->matches(QKeySequence::MoveToNextWord))
  {
    medusa::LineData Line;
    if (m_PrintData.GetLine(m_Cursor.m_Address, m_Cursor.m_yAddressOffset, Line))
    {
      auto const& rText = Line.GetText();
      auto Pos = rText.find_first_not_of(" \n", m_Cursor.m_xAddressOffset);
      Pos = rText.find_first_of(" \n", Pos);
      if (Pos != std::string::npos)
        SetCursor(static_cast<medusa::u32>(Pos), -1);
      else
        SetCursor(static_cast<medusa::u32>(rText.length()), -1);
    }
  }

  if (evt->matches(QKeySequence::MoveToPreviousWord))
  {
    medusa::LineData Line;
    if (m_PrintData.GetLine(m_Cursor.m_Address, m_Cursor.m_yAddressOffset, Line))
    {
      auto const& rText = Line.GetText();
      auto Pos = rText.find_last_not_of(" \n", m_Cursor.m_xAddressOffset ? m_Cursor.m_xAddressOffset - 1 : 0);
      Pos = rText.find_last_of(" \n", Pos);
      if (Pos != std::string::npos)
        SetCursor(static_cast<medusa::u32>(Pos) + 1, -1);
      else
        SetCursor(0, -1);
    }
  }

  // Move selection
  if (evt->matches(QKeySequence::SelectNextChar))
    MoveSelection(+1, 0, InvView);
  if (evt->matches(QKeySequence::SelectPreviousChar))
    MoveSelection(-1, 0, InvView);

  if (evt->matches(QKeySequence::SelectStartOfLine))
    SetSelection(_addrLen, -1);
  if (evt->matches(QKeySequence::SelectEndOfLine))
  {
    medusa::LineData Line;
    if (m_PrintData.GetLine(m_Cursor.m_Address, m_Cursor.m_yAddressOffset, Line))
    {
      auto TextLen = static_cast<medusa::u32>(Line.GetText().length());
      if (TextLen != 0)
        --TextLen;
      SetSelection(TextLen, -1);
    }
  }

  if (evt->matches(QKeySequence::SelectNextLine))
    MoveSelection(0, +1, InvView);
  if (evt->matches(QKeySequence::SelectPreviousLine))
    MoveSelection(0, -1, InvView);

  if (evt->matches(QKeySequence::SelectNextPage))
    MoveSelection(0, +m_Height, InvView);
  if (evt->matches(QKeySequence::SelectPreviousPage))
    MoveSelection(0, -static_cast<medusa::s32>(m_Height), InvView);

  if (evt->matches(QKeySequence::SelectStartOfDocument))
  {
    m_Cursor.m_Address        = m_rDoc.GetFirstAddress();
    m_Cursor.m_xAddressOffset = 0;
    m_Cursor.m_yAddressOffset = 0;
    m_Format(m_Cursor.m_Address, m_FormatFlags, m_Height);
    m_SelectionEnd = m_Top = m_Cursor;
  }
  if (evt->matches(QKeySequence::SelectEndOfDocument))
  {
    m_Cursor.m_Address        = m_rDoc.GetLastAddress();
    m_Cursor.m_xAddressOffset = 0;
    m_Cursor.m_yAddressOffset = 0;
    m_Format(m_Cursor.m_Address, m_FormatFlags, m_Height);
    m_SelectionEnd = m_Top = m_Cursor;
  }

  if (evt->matches(QKeySequence::SelectNextWord))
  {
    medusa::LineData Line;
    if (m_PrintData.GetLine(m_Cursor.m_Address, m_Cursor.m_yAddressOffset, Line))
    {
      auto const& rText = Line.GetText();
      auto Pos = rText.find_first_not_of(" \n", m_Cursor.m_xAddressOffset);
      Pos = rText.find_first_of(" \n", Pos);
      if (Pos != std::string::npos)
        SetSelection(static_cast<medusa::u32>(Pos), -1);
      else
        SetSelection(static_cast<medusa::u32>(rText.length()), -1);
    }
  }

  if (evt->matches(QKeySequence::SelectPreviousWord))
  {
    medusa::LineData Line;
    if (m_PrintData.GetLine(m_Cursor.m_Address, m_Cursor.m_yAddressOffset, Line))
    {
      auto const& rText = Line.GetText();
      auto Pos = rText.find_last_not_of(" \n", m_Cursor.m_xAddressOffset ? m_Cursor.m_xAddressOffset - 1 : 0);
      Pos = rText.find_last_of(" \n", Pos);
      if (Pos != std::string::npos)
        SetSelection(static_cast<medusa::u32>(Pos) + 1, -1);
      else
        SetSelection(0, -1);
    }
  }

  if (evt->matches(QKeySequence::SelectAll))
  {
    medusa::Address FirstAddr = m_rDoc.GetFirstAddress();
    medusa::Address LastAddr  = m_rDoc.GetLastAddress();

    m_SelectionBegin.m_Address = FirstAddr;
    m_SelectionBegin.m_xAddressOffset = 0;
    m_SelectionBegin.m_yAddressOffset = 0;
    m_SelectionEnd.m_Address = LastAddr;
    m_SelectionEnd.m_xAddressOffset = 1; // TODO
    m_SelectionEnd.m_yAddressOffset = 1; // TODO
  }

  // Copy
  if (evt->matches(QKeySequence::Copy))
  {
    auto Start = m_SelectionBegin;
    auto Last  = m_SelectionEnd;

    if (Start.m_Address > Last.m_Address)
      std::swap(Start, Last);

    medusa::PrintData Print;
    medusa::FormatDisassembly FmtDisasm(m_rCore, Print);

    FmtDisasm(std::make_pair(Start.m_Address, Last.m_Address), m_FormatFlags);
    // TODO trim it!
    //auto& rLines = Print.GetTextLines();
    //rLines.erase();
    //rLines.erase();
    QApplication::clipboard()->setText(QString::fromStdString(Print.GetTexts()));
  }

  emit viewUpdated();

  QAbstractScrollArea::keyPressEvent(evt);
}