예제 #1
0
파일: WinMain.cpp 프로젝트: sim0629/SWiring
void Refresh(){
	static Point cptOld;
	HDC hdc, hMemDC;
	HBITMAP hOldBit;

	hdc = GetDC(hWndMain);
	if(cpt != cptOld) {
		DeleteObject(hBit);
		hBit = CreateCompatibleBitmap(hdc, cpt.X, cpt.Y);
		cptOld = cpt;
	}
	hMemDC = CreateCompatibleDC(hdc);
	hOldBit = (HBITMAP)SelectObject(hMemDC, hBit);

	//draw begin
	POINT pt;
	GetCursorPos(&pt);
	ScreenToClient(hWndMain, &pt);
	Point pm(pt.x, pt.y), p;
	p = A2L(pm + Point(ppp / 2, -ppp / 2));
	board->draw(hMemDC, p);
	//draw end

	SelectObject(hMemDC, hOldBit);
	DeleteDC(hMemDC);
	ReleaseDC(hWndMain, hdc);

	InvalidateRgn(hWndMain, NULL, FALSE);
}
bool CSorter::operator() (const CTGitPath* entry1 , const CTGitPath* entry2) const
{
#define SGN(x) ((x)==0?0:((x)>0?1:-1))

	int result = 0;
	switch (sortedColumn)
	{
	case 5: //Del Number
		{
			if (result == 0)
			{
//				result = entry1->lock_comment.CompareNoCase(entry2->lock_comment);
				result = A2L(entry1->m_StatDel)-A2L(entry2->m_StatDel);
			}
		}
	case 4: //Add Number
		{
			if (result == 0)
			{
				//result = entry1->lock_owner.CompareNoCase(entry2->lock_owner);
				result = A2L(entry1->m_StatAdd)-A2L(entry2->m_StatAdd);
			}
		}

	case 3: // Status
		{
			if (result == 0)
			{
				result = entry1->GetActionName(entry1->m_Action).CompareNoCase(entry2->GetActionName(entry2->m_Action));
			}
		}
	case 2: //Ext file
		{
			if (result == 0)
			{
				result = entry1->GetFileExtension().CompareNoCase(entry2->GetFileExtension());
			}
		}
	case 1: // File name
		{
			if (result == 0)
			{
				result = entry1->GetFileOrDirectoryName().CompareNoCase(entry2->GetFileOrDirectoryName());
			}
		}
	case 0: // Full path column
		{
			if (result == 0)
			{
				result = CTGitPath::Compare(entry1->GetGitPathString(), entry2->GetGitPathString());
			}
		}
	default:
		if ((result == 0) && (sortedColumn > 0))
		{
			// N/A props are "less than" empty props

//			const CString& propName = columnManager->GetName (sortedColumn);

//			bool entry1HasProp = entry1->present_props.HasProperty (propName);
//			bool entry2HasProp = entry2->present_props.HasProperty (propName);

//			if (entry1HasProp)
//			{
//				result = entry2HasProp
//					? entry1->present_props[propName].Compare
//					(entry2->present_props[propName])
//					: 1;
//			}
//			else
//			{
//				result = entry2HasProp ? -1 : 0;
//			}
		}
	} // switch (m_nSortedColumn)
	if (!ascending)
		result = -result;

	return result < 0;
}
예제 #3
0
파일: WinMain.cpp 프로젝트: sim0629/SWiring
/* WndProc
 * 메시지 처리 루틴
 */
LRESULT CALLBACK WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam) {
	HDC hdc;
	PAINTSTRUCT ps;
	Point p;

	switch(iMessage) {
	case WM_CREATE:
		hWndMain = hWnd;
		
		CreateWindow(TEXT("button"), TEXT("NONE"),
			WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON | WS_GROUP,
			0, NONE * 15, 75, 15, hWnd, (HMENU)NONE, g_hInst, NULL);
		CreateWindow(TEXT("button"), TEXT("INV"),
			WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
			0, INV * 15, 75, 15, hWnd, (HMENU)INV, g_hInst, NULL);
		CreateWindow(TEXT("button"), TEXT("AND2"),
			WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
			0, AND2 * 15, 75, 15, hWnd, (HMENU)AND2, g_hInst, NULL);
		CreateWindow(TEXT("button"), TEXT("OR2"),
			WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
			0, OR2 * 15, 75, 15, hWnd, (HMENU)OR2, g_hInst, NULL);
		CreateWindow(TEXT("button"), TEXT("NAND2"),
			WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
			0, NAND2 * 15, 75, 15, hWnd, (HMENU)NAND2, g_hInst, NULL);
		CreateWindow(TEXT("button"), TEXT("NOR2"),
			WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
			0, NOR2 * 15, 75, 15, hWnd, (HMENU)NOR2, g_hInst, NULL);
		CreateWindow(TEXT("button"), TEXT("XOR2"),
			WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
			0, XOR2 * 15, 75, 15, hWnd, (HMENU)XOR2, g_hInst, NULL);
		CreateWindow(TEXT("button"), TEXT("AND3"),
			WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
			0, AND3 * 15, 75, 15, hWnd, (HMENU)AND3, g_hInst, NULL);
		CreateWindow(TEXT("button"), TEXT("NAND3"),
			WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
			0, NAND3 * 15, 75, 15, hWnd, (HMENU)NAND3, g_hInst, NULL);
		CreateWindow(TEXT("button"), TEXT("AND4"),
			WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
			0, AND4 * 15, 75, 15, hWnd, (HMENU)AND4, g_hInst, NULL);
		CreateWindow(TEXT("button"), TEXT("NAND4"),
			WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
			0, NAND4 * 15, 75, 15, hWnd, (HMENU)NAND4, g_hInst, NULL);
		CreateWindow(TEXT("button"), TEXT("MUX2"),
			WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
			0, MUX2 * 15, 75, 15, hWnd, (HMENU)MUX2, g_hInst, NULL);
		CreateWindow(TEXT("button"), TEXT("CPLD"),
			WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
			0, CPLD * 15, 75, 15, hWnd, (HMENU)CPLD, g_hInst, NULL);
		CreateWindow(TEXT("button"), TEXT("CLK"),
			WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
			0, CLK * 15, 75, 15, hWnd, (HMENU)CLK, g_hInst, NULL);
		CreateWindow(TEXT("button"), TEXT("DEC"),
			WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
			0, DEC * 15, 75, 15, hWnd, (HMENU)DEC, g_hInst, NULL);

		CheckRadioButton(hWnd, NONE, DUMMY - 1, NONE);

		open("open.swr.txt");	// initial file
		
		SetTimer(hWnd, 0, 20, NULL);
		return 0;

	case WM_TIMER:
		Refresh();
		return 0;

	case WM_SIZE:
		cpt.X = LOWORD(lParam); cpt.Y = HIWORD(lParam);
		if(ppp == 0) {	// ppp 한 번만 초기화
			ppp = 15;
			origin.X = 0; origin.Y = cpt.Y;
		}
		return 0;

	case WM_MOUSEMOVE:
		// wParam에 MK_들 필요할 때 처리
		if(!Chip::tool) board->mouse(0, Point(LOWORD(lParam), HIWORD(lParam)));
		return 0;

	case WM_LBUTTONDOWN:
		// wParam에 MK_들 필요할 때 처리
		p.X = LOWORD(lParam); p.Y = HIWORD(lParam);
		p = p + Point(ppp / 2, -ppp / 2);
		p = A2L(p);
		if(!Chip::tool) {
			if(GetKeyState(VK_CONTROL) >> 1) board->setPin(p, 1);
			else {
				if(GetKeyState(VK_SHIFT) >> 1) {
					board->mouse(2, Point(LOWORD(lParam), HIWORD(lParam)));
				}else if(GetKeyState(VK_MENU) >> 1) {
					board->mouse(4, Point(LOWORD(lParam), HIWORD(lParam)));
				}else {
					board->mouse(1, Point(LOWORD(lParam), HIWORD(lParam)));
				}
			}
bool CSorter::operator() (const CTGitPath* entry1 , const CTGitPath* entry2) const
{
#define SGN(x) ((x)==0?0:((x)>0?1:-1))

	int result = 0;
	switch (sortedColumn)
	{
	case 7: // File size
		{
			if (result == 0)
			{
				__int64 fileSize1 = entry1->IsDirectory() ? 0 : entry1->GetFileSize();
				__int64 fileSize2 = entry2->IsDirectory() ? 0 : entry2->GetFileSize();

				result = int(fileSize1 - fileSize2);
			}
			break;
		}
	case 6: //Last Modification Date
		{
			if (result == 0)
			{
				__int64 writetime1 = entry1->GetLastWriteTime();
				__int64 writetime2 = entry2->GetLastWriteTime();

				FILETIME* filetime1 = (FILETIME*)(__int64*)&writetime1;
				FILETIME* filetime2 = (FILETIME*)(__int64*)&writetime2;

				result = CompareFileTime(filetime1, filetime2);
			}
			break;
		}
	case 5: //Del Number
		{
			if (result == 0)
			{
//				result = entry1->lock_comment.CompareNoCase(entry2->lock_comment);
				result = A2L(entry1->m_StatDel)-A2L(entry2->m_StatDel);
			}
			break;
		}
	case 4: //Add Number
		{
			if (result == 0)
			{
				//result = entry1->lock_owner.CompareNoCase(entry2->lock_owner);
				result = A2L(entry1->m_StatAdd)-A2L(entry2->m_StatAdd);
			}
			break;
		}

	case 3: // Status
		{
			if (result == 0)
			{
				result = entry1->GetActionName(entry1->m_Action).CompareNoCase(entry2->GetActionName(entry2->m_Action));
			}
			break;
		}
	case 2: //Ext file
		{
			if (result == 0)
			{
				result = entry1->GetFileExtension().CompareNoCase(entry2->GetFileExtension());
			}
			break;
		}
	case 1: // File name
		{
			if (result == 0)
			{
				result = entry1->GetFileOrDirectoryName().CompareNoCase(entry2->GetFileOrDirectoryName());
			}
			break;
		}
	case 0: // Full path column
		{
			if (result == 0)
			{
				result = CTGitPath::Compare(entry1->GetGitPathString(), entry2->GetGitPathString());
			}
			break;
		}
	} // switch (m_nSortedColumn)
	// sort by path name as second priority
	if (sortedColumn > 0 && result == 0)
		result = CTGitPath::Compare(entry1->GetGitPathString(), entry2->GetGitPathString());
	if (!ascending)
		result = -result;

	return result < 0;
}