changing row count works \o/
This commit is contained in:
parent
ed688c55b7
commit
2a106f7949
@ -26,8 +26,8 @@ SOCKET clientConnect(SOCKET serverSocket)
|
|||||||
const char *expectedGreeting = clientGreeting;
|
const char *expectedGreeting = clientGreeting;
|
||||||
char recievedGreeting[128];
|
char recievedGreeting[128];
|
||||||
|
|
||||||
while(recv(clientSocket, recievedGreeting, int(strlen(expectedGreeting)), 0) < 0) Sleep(1);
|
recv(clientSocket, recievedGreeting, int(strlen(expectedGreeting)), 0);
|
||||||
|
|
||||||
fprintf(stderr, "got: \"%s\"\n", recievedGreeting);
|
fprintf(stderr, "got: \"%s\"\n", recievedGreeting);
|
||||||
if (strncmp(expectedGreeting, recievedGreeting, strlen(expectedGreeting)) != 0)
|
if (strncmp(expectedGreeting, recievedGreeting, strlen(expectedGreeting)) != 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -4,6 +4,9 @@
|
|||||||
//
|
//
|
||||||
#define IDR_ACCELERATOR 101
|
#define IDR_ACCELERATOR 101
|
||||||
#define IDR_MENU 102
|
#define IDR_MENU 102
|
||||||
|
#define IDD_SETROWS 103
|
||||||
|
#define IDC_EDIT 1002
|
||||||
|
#define IDC_SETROWS_EDIT 1002
|
||||||
#define ID_FILE 40001
|
#define ID_FILE 40001
|
||||||
#define ID_FILE_EXIT 40002
|
#define ID_FILE_EXIT 40002
|
||||||
#define ID_EDIT 40003
|
#define ID_EDIT 40003
|
||||||
@ -13,9 +16,9 @@
|
|||||||
//
|
//
|
||||||
#ifdef APSTUDIO_INVOKED
|
#ifdef APSTUDIO_INVOKED
|
||||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||||
#define _APS_NEXT_RESOURCE_VALUE 103
|
#define _APS_NEXT_RESOURCE_VALUE 104
|
||||||
#define _APS_NEXT_COMMAND_VALUE 40008
|
#define _APS_NEXT_COMMAND_VALUE 40008
|
||||||
#define _APS_NEXT_CONTROL_VALUE 1001
|
#define _APS_NEXT_CONTROL_VALUE 1003
|
||||||
#define _APS_NEXT_SYMED_VALUE 101
|
#define _APS_NEXT_SYMED_VALUE 101
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
10
syncdata.h
10
syncdata.h
@ -37,7 +37,7 @@ public:
|
|||||||
// lerp, bitch
|
// lerp, bitch
|
||||||
float d = (time - lower->first) / (upper->first - lower->first);
|
float d = (time - lower->first) / (upper->first - lower->first);
|
||||||
return lower->second.value + delta * d;
|
return lower->second.value + delta * d;
|
||||||
};
|
}
|
||||||
|
|
||||||
bool isKeyFrame(size_t row) const
|
bool isKeyFrame(size_t row) const
|
||||||
{
|
{
|
||||||
@ -63,7 +63,7 @@ public:
|
|||||||
|
|
||||||
void setKeyFrame(size_t row, const float value)
|
void setKeyFrame(size_t row, const float value)
|
||||||
{
|
{
|
||||||
keyFrames[row] = KeyFrame(value);
|
setKeyFrame(row, KeyFrame(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t getFrameCount() const
|
size_t getFrameCount() const
|
||||||
@ -74,6 +74,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
typedef std::map<size_t, struct KeyFrame> KeyFrameContainer;
|
typedef std::map<size_t, struct KeyFrame> KeyFrameContainer;
|
||||||
KeyFrameContainer keyFrames;
|
KeyFrameContainer keyFrames;
|
||||||
};
|
};
|
||||||
@ -98,9 +99,10 @@ public:
|
|||||||
return trackIter->second;
|
return trackIter->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t getTrackCount() { return tracks.size(); }
|
size_t getTrackCount() const { return tracks.size(); }
|
||||||
|
|
||||||
// private:
|
//private:
|
||||||
typedef std::map<const std::basic_string<TCHAR>, SyncTrack> TrackContainer;
|
typedef std::map<const std::basic_string<TCHAR>, SyncTrack> TrackContainer;
|
||||||
TrackContainer tracks;
|
TrackContainer tracks;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
198
synctracker2.cpp
198
synctracker2.cpp
@ -13,13 +13,62 @@ TrackView *trackView;
|
|||||||
HWND trackViewWin;
|
HWND trackViewWin;
|
||||||
HWND statusBarWin;
|
HWND statusBarWin;
|
||||||
|
|
||||||
|
#define WM_SETROWS (WM_USER+1)
|
||||||
|
|
||||||
#include "network.h"
|
#include "network.h"
|
||||||
|
|
||||||
|
static LRESULT CALLBACK setRowsDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
switch (message)
|
||||||
|
{
|
||||||
|
case WM_INITDIALOG:
|
||||||
|
{
|
||||||
|
int *rows = (int*)lParam;
|
||||||
|
assert(NULL != rows);
|
||||||
|
|
||||||
|
/* create row-string */
|
||||||
|
char temp[256];
|
||||||
|
_snprintf(temp, 256, "%d", *rows);
|
||||||
|
|
||||||
|
/* set initial row count */
|
||||||
|
SetWindowText(GetDlgItem(hDlg, IDC_SETROWS_EDIT), temp);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WM_COMMAND:
|
||||||
|
if (LOWORD(wParam) == IDOK)
|
||||||
|
{
|
||||||
|
/* get value */
|
||||||
|
char temp[256];
|
||||||
|
GetWindowText(GetDlgItem(hDlg, IDC_SETROWS_EDIT), temp, 256);
|
||||||
|
int result = atoi(temp);
|
||||||
|
|
||||||
|
/* update editor */
|
||||||
|
SendMessage(GetParent(hDlg), WM_SETROWS, 0, result);
|
||||||
|
|
||||||
|
/* end dialog */
|
||||||
|
EndDialog(hDlg, LOWORD(wParam));
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
else if(LOWORD(wParam)== IDCANCEL)
|
||||||
|
{
|
||||||
|
EndDialog( hDlg, LOWORD(wParam));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WM_CLOSE:
|
||||||
|
EndDialog(hDlg, LOWORD(wParam));
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
static LRESULT CALLBACK mainWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
static LRESULT CALLBACK mainWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
switch(msg)
|
switch(msg)
|
||||||
{
|
{
|
||||||
case WM_CREATE:
|
case WM_CREATE:
|
||||||
{
|
{
|
||||||
HINSTANCE hInstance = GetModuleHandle(NULL);
|
HINSTANCE hInstance = GetModuleHandle(NULL);
|
||||||
trackViewWin = trackView->create(hInstance, hwnd);
|
trackViewWin = trackView->create(hInstance, hwnd);
|
||||||
@ -42,8 +91,8 @@ static LRESULT CALLBACK mainWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA
|
|||||||
SendMessage(statusBarWin, SB_SETTEXT, 1, (LPARAM)_T("Hi there :)"));
|
SendMessage(statusBarWin, SB_SETTEXT, 1, (LPARAM)_T("Hi there :)"));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_SIZE:
|
case WM_SIZE:
|
||||||
{
|
{
|
||||||
int width = LOWORD(lParam);
|
int width = LOWORD(lParam);
|
||||||
int height = HIWORD(lParam);
|
int height = HIWORD(lParam);
|
||||||
@ -56,62 +105,47 @@ static LRESULT CALLBACK mainWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA
|
|||||||
MoveWindow(statusBarWin, 0, height - statusBarHeight, width, statusBarHeight, TRUE);
|
MoveWindow(statusBarWin, 0, height - statusBarHeight, width, statusBarHeight, TRUE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_SETFOCUS:
|
case WM_SETFOCUS:
|
||||||
SetFocus(trackViewWin); // needed to forward keyboard input
|
SetFocus(trackViewWin); // needed to forward keyboard input
|
||||||
break;
|
|
||||||
|
|
||||||
case WM_COMMAND:
|
|
||||||
switch (LOWORD(wParam))
|
|
||||||
{
|
|
||||||
case ID_FILE_SAVE: /* meh.*/ break;
|
|
||||||
case ID_FILE_EXIT: PostQuitMessage(0); break;
|
|
||||||
case ID_EDIT_UNDO: SendMessage(trackViewWin, WM_UNDO, 0, 0); break;
|
|
||||||
case ID_EDIT_REDO: SendMessage(trackViewWin, WM_REDO, 0, 0); break;
|
|
||||||
case ID_EDIT_COPY: SendMessage(trackViewWin, WM_COPY, 0, 0); break;
|
|
||||||
case ID_EDIT_CUT: SendMessage(trackViewWin, WM_CUT, 0, 0); break;
|
|
||||||
case ID_EDIT_PASTE: SendMessage(trackViewWin, WM_PASTE, 0, 0); break;
|
|
||||||
default:
|
|
||||||
printf("cmd %d %d\n", wParam, lParam);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_USER+1:
|
case WM_SETROWS:
|
||||||
|
printf("rows: %d\n", int(lParam));
|
||||||
|
trackView->setRows(int(lParam));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WM_COMMAND:
|
||||||
|
switch (LOWORD(wParam))
|
||||||
{
|
{
|
||||||
if (WSAGETSELECTERROR(lParam))
|
case ID_FILE_SAVE: /* meh.*/ break;
|
||||||
|
case ID_FILE_EXIT: PostQuitMessage(0); break;
|
||||||
|
case ID_EDIT_UNDO: SendMessage(trackViewWin, WM_UNDO, 0, 0); break;
|
||||||
|
case ID_EDIT_REDO: SendMessage(trackViewWin, WM_REDO, 0, 0); break;
|
||||||
|
case ID_EDIT_COPY: SendMessage(trackViewWin, WM_COPY, 0, 0); break;
|
||||||
|
case ID_EDIT_CUT: SendMessage(trackViewWin, WM_CUT, 0, 0); break;
|
||||||
|
case ID_EDIT_PASTE: SendMessage(trackViewWin, WM_PASTE, 0, 0); break;
|
||||||
|
|
||||||
|
case ID_EDIT_SETROWS:
|
||||||
{
|
{
|
||||||
printf("ERR!\n");
|
HINSTANCE hInstance = GetModuleHandle(NULL);
|
||||||
// error occurred
|
int rows = trackView->getRows();
|
||||||
WSACleanup ();
|
INT_PTR result = DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_SETROWS), hwnd, (DLGPROC)setRowsDialogProc, (LPARAM)&rows);
|
||||||
return 0;
|
if (FAILED(result)) MessageBox(NULL, "unable to create dialog box", NULL, MB_OK);
|
||||||
}
|
if (IDOK == result)
|
||||||
|
|
||||||
printf("tjo %x %x\n", lParam, wParam);
|
|
||||||
SOCKET serverSocket = (SOCKET)wParam;
|
|
||||||
switch (WSAGETSELECTEVENT(lParam))
|
|
||||||
{
|
|
||||||
case FD_ACCEPT:
|
|
||||||
printf("accept\n");
|
|
||||||
{
|
{
|
||||||
SOCKET clientSocket = clientConnect(serverSocket);
|
printf("result: %d\n", result);
|
||||||
if (INVALID_SOCKET != clientSocket)
|
|
||||||
{
|
|
||||||
unsigned char cmd = 0x1;
|
|
||||||
send(clientSocket, (char*)&cmd, 1, 0);
|
|
||||||
closesocket(clientSocket);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
puts("accept failed!");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return DefWindowProc(hwnd, msg, wParam, lParam);
|
printf("cmd %d %d\n", wParam, lParam);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return DefWindowProc(hwnd, msg, wParam, lParam);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -129,7 +163,7 @@ static ATOM registerMainWindowClass(HINSTANCE hInstance)
|
|||||||
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
|
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
|
||||||
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
|
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||||
wc.hbrBackground = (HBRUSH)0;
|
wc.hbrBackground = (HBRUSH)0;
|
||||||
wc.lpszMenuName = (LPCSTR)IDR_MENU;
|
wc.lpszMenuName = MAKEINTRESOURCE(IDR_MENU);
|
||||||
wc.lpszClassName = mainWindowClassName;
|
wc.lpszClassName = mainWindowClassName;
|
||||||
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
|
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
|
||||||
|
|
||||||
@ -138,35 +172,42 @@ static ATOM registerMainWindowClass(HINSTANCE hInstance)
|
|||||||
|
|
||||||
int _tmain(int argc, _TCHAR* argv[])
|
int _tmain(int argc, _TCHAR* argv[])
|
||||||
{
|
{
|
||||||
HWND hwnd;
|
#ifdef _DEBUG
|
||||||
|
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
|
||||||
|
_CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG);
|
||||||
|
_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG);
|
||||||
|
_CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG);
|
||||||
|
/* _CrtSetBreakAlloc(68); */
|
||||||
|
#endif
|
||||||
|
|
||||||
HINSTANCE hInstance = GetModuleHandle(NULL);
|
HINSTANCE hInstance = GetModuleHandle(NULL);
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
if (false == initNetwork())
|
if (false == initNetwork())
|
||||||
{
|
{
|
||||||
fputs("Failed to init WinSock", stderr);
|
fputs("Failed to init WinSock", stderr);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
SOCKET serverSocket = socket( AF_INET, SOCK_STREAM, 0 );
|
SOCKET serverSocket = socket( AF_INET, SOCK_STREAM, 0 );
|
||||||
|
|
||||||
struct sockaddr_in sin;
|
struct sockaddr_in sin;
|
||||||
memset( &sin, 0, sizeof sin );
|
memset( &sin, 0, sizeof sin );
|
||||||
|
|
||||||
sin.sin_family = AF_INET;
|
sin.sin_family = AF_INET;
|
||||||
sin.sin_addr.s_addr = INADDR_ANY;
|
sin.sin_addr.s_addr = INADDR_ANY;
|
||||||
sin.sin_port = htons( 1338 );
|
sin.sin_port = htons( 1338 );
|
||||||
|
|
||||||
puts("binding...");
|
puts("binding...");
|
||||||
if (SOCKET_ERROR == bind( serverSocket, (struct sockaddr *)&sin, sizeof(sin)))
|
if (SOCKET_ERROR == bind( serverSocket, (struct sockaddr *)&sin, sizeof(sin)))
|
||||||
{
|
{
|
||||||
fputs("Coult not start server", stderr);
|
fputs("Coult not start server", stderr);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
puts("listening...");
|
puts("listening...");
|
||||||
while ( listen( serverSocket, SOMAXCONN ) == SOCKET_ERROR );
|
while ( listen( serverSocket, SOMAXCONN ) == SOCKET_ERROR );
|
||||||
|
|
||||||
/* ULONG nonBlock = 1;
|
/* ULONG nonBlock = 1;
|
||||||
if (ioctlsocket(serverSocket, FIONBIO, &nonBlock) == SOCKET_ERROR)
|
if (ioctlsocket(serverSocket, FIONBIO, &nonBlock) == SOCKET_ERROR)
|
||||||
{
|
{
|
||||||
@ -174,26 +215,27 @@ int _tmain(int argc, _TCHAR* argv[])
|
|||||||
return 0;
|
return 0;
|
||||||
} */
|
} */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SyncEditData syncData;
|
SyncEditData syncData;
|
||||||
SyncTrack &camXTrack = syncData.getTrack(_T("cam.x"));
|
SyncTrack &camXTrack = syncData.getTrack(_T("cam.x"));
|
||||||
SyncTrack &camYTrack = syncData.getTrack(_T("cam.y"));
|
SyncTrack &camYTrack = syncData.getTrack(_T("cam.y"));
|
||||||
SyncTrack &camZTrack = syncData.getTrack(_T("cam.z"));
|
SyncTrack &camZTrack = syncData.getTrack(_T("cam.z"));
|
||||||
|
|
||||||
for (int i = 0; i < 2; ++i)
|
for (int i = 0; i < 2; ++i)
|
||||||
{
|
{
|
||||||
char temp[256];
|
char temp[256];
|
||||||
sprintf(temp, "gen %02d", i);
|
_snprintf(temp, 256, "gen %02d", i);
|
||||||
SyncTrack &temp2 = syncData.getTrack(temp);
|
SyncTrack &temp2 = syncData.getTrack(temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
camXTrack.setKeyFrame(1, SyncTrack::KeyFrame(2.0f));
|
camXTrack.setKeyFrame(1, 2.0f);
|
||||||
camXTrack.setKeyFrame(4, SyncTrack::KeyFrame(3.0f));
|
camXTrack.setKeyFrame(4, 3.0f);
|
||||||
|
|
||||||
camYTrack.setKeyFrame(0, SyncTrack::KeyFrame(100.0f));
|
camYTrack.setKeyFrame(0, 100.0f);
|
||||||
camYTrack.setKeyFrame(8, SyncTrack::KeyFrame(999.0f));
|
camYTrack.setKeyFrame(8, 999.0f);
|
||||||
|
|
||||||
camYTrack.setKeyFrame(16, SyncTrack::KeyFrame(float(1E-5)));
|
camYTrack.setKeyFrame(16, SyncTrack::KeyFrame(float(1E-5)));
|
||||||
|
|
||||||
for (int i = 0; i < 5 * 2; ++i)
|
for (int i = 0; i < 5 * 2; ++i)
|
||||||
{
|
{
|
||||||
float time = float(i) / 2;
|
float time = float(i) / 2;
|
||||||
@ -212,7 +254,7 @@ int _tmain(int argc, _TCHAR* argv[])
|
|||||||
trackView->setSyncData(&syncData);
|
trackView->setSyncData(&syncData);
|
||||||
|
|
||||||
// Step 2: Creating the Window
|
// Step 2: Creating the Window
|
||||||
hwnd = CreateWindowEx(
|
HWND hwnd = CreateWindowEx(
|
||||||
0,
|
0,
|
||||||
mainWindowClassName,
|
mainWindowClassName,
|
||||||
_T("SyncTracker 3000"),
|
_T("SyncTracker 3000"),
|
||||||
@ -221,6 +263,7 @@ int _tmain(int argc, _TCHAR* argv[])
|
|||||||
CW_USEDEFAULT, CW_USEDEFAULT, // width, height
|
CW_USEDEFAULT, CW_USEDEFAULT, // width, height
|
||||||
NULL, NULL, hInstance, NULL
|
NULL, NULL, hInstance, NULL
|
||||||
);
|
);
|
||||||
|
printf("main window: %p\n", hwnd);
|
||||||
|
|
||||||
if (NULL == hwnd)
|
if (NULL == hwnd)
|
||||||
{
|
{
|
||||||
@ -228,17 +271,16 @@ int _tmain(int argc, _TCHAR* argv[])
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
HACCEL accel = LoadAccelerators(hInstance, (LPCSTR)IDR_ACCELERATOR);
|
HACCEL accel = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDR_ACCELERATOR));
|
||||||
printf("accel: %p\n", accel);
|
printf("accel: %p\n", accel);
|
||||||
|
|
||||||
ShowWindow(hwnd, TRUE);
|
ShowWindow(hwnd, TRUE);
|
||||||
UpdateWindow(hwnd);
|
UpdateWindow(hwnd);
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
|
|
||||||
printf("server socket %x\n", serverSocket);
|
printf("server socket %x\n", serverSocket);
|
||||||
// WSAAsyncSelect(serverSocket, hwnd, WM_USER+1, FD_ACCEPT);
|
|
||||||
|
|
||||||
bool done = false;
|
bool done = false;
|
||||||
SOCKET clientSocket = INVALID_SOCKET;
|
SOCKET clientSocket = INVALID_SOCKET;
|
||||||
MSG msg;
|
MSG msg;
|
||||||
@ -253,7 +295,7 @@ int _tmain(int argc, _TCHAR* argv[])
|
|||||||
struct timeval timeout;
|
struct timeval timeout;
|
||||||
timeout.tv_sec = 0;
|
timeout.tv_sec = 0;
|
||||||
timeout.tv_usec = 0;
|
timeout.tv_usec = 0;
|
||||||
|
|
||||||
// look for new clients
|
// look for new clients
|
||||||
if (select(0, &fds, NULL, NULL, &timeout) > 0)
|
if (select(0, &fds, NULL, NULL, &timeout) > 0)
|
||||||
{
|
{
|
||||||
@ -288,7 +330,7 @@ int _tmain(int argc, _TCHAR* argv[])
|
|||||||
if (cmd == 1) printf("yes, master!\n");
|
if (cmd == 1) printf("yes, master!\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// terminate connection
|
// terminate connection
|
||||||
/* cmd = 0x0;
|
/* cmd = 0x0;
|
||||||
send(clientSocket, (char*)&cmd, 1, 0);
|
send(clientSocket, (char*)&cmd, 1, 0);
|
||||||
@ -310,7 +352,7 @@ int _tmain(int argc, _TCHAR* argv[])
|
|||||||
|
|
||||||
closesocket(serverSocket);
|
closesocket(serverSocket);
|
||||||
closeNetwork();
|
closeNetwork();
|
||||||
|
|
||||||
#else
|
#else
|
||||||
// Step 3: The Message Loop
|
// Step 3: The Message Loop
|
||||||
while(GetMessage(&msg, NULL, 0, 0) > 0)
|
while(GetMessage(&msg, NULL, 0, 0) > 0)
|
||||||
|
|||||||
@ -90,6 +90,40 @@ BEGIN
|
|||||||
END
|
END
|
||||||
END
|
END
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Dialog
|
||||||
|
//
|
||||||
|
|
||||||
|
IDD_SETROWS DIALOGEX 0, 0, 129, 27
|
||||||
|
STYLE DS_SETFONT | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||||
|
CAPTION "Set Rows"
|
||||||
|
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||||
|
BEGIN
|
||||||
|
EDITTEXT IDC_SETROWS_EDIT,7,6,59,12,ES_AUTOHSCROLL | ES_NUMBER
|
||||||
|
DEFPUSHBUTTON "OK",IDOK,72,6,50,14
|
||||||
|
END
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// DESIGNINFO
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifdef APSTUDIO_INVOKED
|
||||||
|
GUIDELINES DESIGNINFO
|
||||||
|
BEGIN
|
||||||
|
IDD_SETROWS, DIALOG
|
||||||
|
BEGIN
|
||||||
|
LEFTMARGIN, 7
|
||||||
|
RIGHTMARGIN, 122
|
||||||
|
TOPMARGIN, 7
|
||||||
|
BOTTOMMARGIN, 20
|
||||||
|
END
|
||||||
|
END
|
||||||
|
#endif // APSTUDIO_INVOKED
|
||||||
|
|
||||||
#endif // Norwegian (Bokmal) resources
|
#endif // Norwegian (Bokmal) resources
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|||||||
@ -40,7 +40,7 @@
|
|||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="0"
|
Optimization="0"
|
||||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE"
|
||||||
MinimalRebuild="true"
|
MinimalRebuild="true"
|
||||||
BasicRuntimeChecks="3"
|
BasicRuntimeChecks="3"
|
||||||
RuntimeLibrary="3"
|
RuntimeLibrary="3"
|
||||||
|
|||||||
360
trackview.cpp
360
trackview.cpp
@ -82,7 +82,7 @@ LRESULT TrackView::onPaint()
|
|||||||
paintTracks(hdc, ps.rcPaint);
|
paintTracks(hdc, ps.rcPaint);
|
||||||
|
|
||||||
EndPaint(hwnd, &ps);
|
EndPaint(hwnd, &ps);
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,10 +98,10 @@ void TrackView::paintTopMargin(HDC hdc, RECT rcTracks)
|
|||||||
DrawEdge(hdc, &fillRect, BDR_RAISEDINNER | BDR_RAISEDOUTER, BF_ADJUST | BF_BOTTOM);
|
DrawEdge(hdc, &fillRect, BDR_RAISEDINNER | BDR_RAISEDOUTER, BF_ADJUST | BF_BOTTOM);
|
||||||
FillRect(hdc, &fillRect, GetSysColorBrush(COLOR_3DFACE));
|
FillRect(hdc, &fillRect, GetSysColorBrush(COLOR_3DFACE));
|
||||||
ExcludeClipRect(hdc, topLeftMargin.left, topLeftMargin.top, topLeftMargin.right, topLeftMargin.bottom);
|
ExcludeClipRect(hdc, topLeftMargin.left, topLeftMargin.top, topLeftMargin.right, topLeftMargin.bottom);
|
||||||
|
|
||||||
int firstTrack = min(max(scrollPosX / trackWidth, 0), getTrackCount() - 1);
|
int firstTrack = min(max(scrollPosX / trackWidth, 0), getTrackCount() - 1);
|
||||||
int lastTrack = min(max(firstTrack + windowTracks + 1, 0), getTrackCount() - 1);
|
int lastTrack = min(max(firstTrack + windowTracks + 1, 0), getTrackCount() - 1);
|
||||||
|
|
||||||
SyncData *syncData = getSyncData();
|
SyncData *syncData = getSyncData();
|
||||||
if (NULL == syncData) return;
|
if (NULL == syncData) return;
|
||||||
|
|
||||||
@ -110,25 +110,25 @@ void TrackView::paintTopMargin(HDC hdc, RECT rcTracks)
|
|||||||
{
|
{
|
||||||
ASSERT(trackIter != syncData->tracks.end());
|
ASSERT(trackIter != syncData->tracks.end());
|
||||||
if (track < firstTrack) continue;
|
if (track < firstTrack) continue;
|
||||||
|
|
||||||
RECT topMargin;
|
RECT topMargin;
|
||||||
|
|
||||||
topMargin.top = 0;
|
topMargin.top = 0;
|
||||||
topMargin.bottom = topMarginHeight;
|
topMargin.bottom = topMarginHeight;
|
||||||
|
|
||||||
topMargin.left = getScreenX(track);
|
topMargin.left = getScreenX(track);
|
||||||
topMargin.right = topMargin.left + trackWidth;
|
topMargin.right = topMargin.left + trackWidth;
|
||||||
|
|
||||||
if (!RectVisible(hdc, &topMargin)) continue;
|
if (!RectVisible(hdc, &topMargin)) continue;
|
||||||
|
|
||||||
RECT fillRect = topMargin;
|
RECT fillRect = topMargin;
|
||||||
|
|
||||||
HBRUSH bgBrush = GetSysColorBrush(COLOR_3DFACE);
|
HBRUSH bgBrush = GetSysColorBrush(COLOR_3DFACE);
|
||||||
if (track == editTrack) bgBrush = editBrush;
|
if (track == editTrack) bgBrush = editBrush;
|
||||||
|
|
||||||
DrawEdge(hdc, &fillRect, BDR_RAISEDINNER | BDR_RAISEDOUTER, BF_ADJUST | BF_LEFT | BF_RIGHT | BF_BOTTOM);
|
DrawEdge(hdc, &fillRect, BDR_RAISEDINNER | BDR_RAISEDOUTER, BF_ADJUST | BF_LEFT | BF_RIGHT | BF_BOTTOM);
|
||||||
FillRect(hdc, &fillRect, bgBrush);
|
FillRect(hdc, &fillRect, bgBrush);
|
||||||
|
|
||||||
const std::basic_string<TCHAR> &trackName = trackIter->first;
|
const std::basic_string<TCHAR> &trackName = trackIter->first;
|
||||||
TextOut(hdc,
|
TextOut(hdc,
|
||||||
fillRect.left, 0,
|
fillRect.left, 0,
|
||||||
@ -136,7 +136,7 @@ void TrackView::paintTopMargin(HDC hdc, RECT rcTracks)
|
|||||||
);
|
);
|
||||||
ExcludeClipRect(hdc, topMargin.left, topMargin.top, topMargin.right, topMargin.bottom);
|
ExcludeClipRect(hdc, topMargin.left, topMargin.top, topMargin.right, topMargin.bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
RECT topRightMargin;
|
RECT topRightMargin;
|
||||||
topRightMargin.top = 0;
|
topRightMargin.top = 0;
|
||||||
topRightMargin.bottom = topMarginHeight;
|
topRightMargin.bottom = topMarginHeight;
|
||||||
@ -146,13 +146,12 @@ void TrackView::paintTopMargin(HDC hdc, RECT rcTracks)
|
|||||||
DrawEdge(hdc, &fillRect, BDR_RAISEDINNER | BDR_RAISEDOUTER, BF_ADJUST | BF_BOTTOM);
|
DrawEdge(hdc, &fillRect, BDR_RAISEDINNER | BDR_RAISEDOUTER, BF_ADJUST | BF_BOTTOM);
|
||||||
FillRect(hdc, &fillRect, GetSysColorBrush(COLOR_3DFACE));
|
FillRect(hdc, &fillRect, GetSysColorBrush(COLOR_3DFACE));
|
||||||
ExcludeClipRect(hdc, topRightMargin.left, topRightMargin.top, topRightMargin.right, topRightMargin.bottom);
|
ExcludeClipRect(hdc, topRightMargin.left, topRightMargin.top, topRightMargin.right, topRightMargin.bottom);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackView::paintTracks(HDC hdc, RECT rcTracks)
|
void TrackView::paintTracks(HDC hdc, RECT rcTracks)
|
||||||
{
|
{
|
||||||
TCHAR temp[256];
|
TCHAR temp[256];
|
||||||
|
|
||||||
int firstTrack = min(max(scrollPosX / trackWidth, 0), getTrackCount() - 1);
|
int firstTrack = min(max(scrollPosX / trackWidth, 0), getTrackCount() - 1);
|
||||||
int lastTrack = min(max(firstTrack + windowTracks + 1, 0), getTrackCount() - 1);
|
int lastTrack = min(max(firstTrack + windowTracks + 1, 0), getTrackCount() - 1);
|
||||||
|
|
||||||
@ -161,9 +160,9 @@ void TrackView::paintTracks(HDC hdc, RECT rcTracks)
|
|||||||
/* clamp first & last row */
|
/* clamp first & last row */
|
||||||
firstRow = min(max(firstRow, 0), rows - 1);
|
firstRow = min(max(firstRow, 0), rows - 1);
|
||||||
lastRow = min(max(lastRow, 0), rows - 1);
|
lastRow = min(max(lastRow, 0), rows - 1);
|
||||||
|
|
||||||
SetBkMode(hdc, TRANSPARENT);
|
SetBkMode(hdc, TRANSPARENT);
|
||||||
|
|
||||||
// SelectObject(hdc, editBrush);
|
// SelectObject(hdc, editBrush);
|
||||||
|
|
||||||
paintTopMargin(hdc, rcTracks);
|
paintTopMargin(hdc, rcTracks);
|
||||||
@ -195,7 +194,7 @@ void TrackView::paintTracks(HDC hdc, RECT rcTracks)
|
|||||||
leftMargin.left, leftMargin.top,
|
leftMargin.left, leftMargin.top,
|
||||||
temp, int(_tcslen(temp))
|
temp, int(_tcslen(temp))
|
||||||
);
|
);
|
||||||
|
|
||||||
ExcludeClipRect(hdc, leftMargin.left, leftMargin.top, leftMargin.right, leftMargin.bottom);
|
ExcludeClipRect(hdc, leftMargin.left, leftMargin.top, leftMargin.right, leftMargin.bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -203,7 +202,7 @@ void TrackView::paintTracks(HDC hdc, RECT rcTracks)
|
|||||||
|
|
||||||
SyncData *syncData = getSyncData();
|
SyncData *syncData = getSyncData();
|
||||||
if (NULL == syncData) return;
|
if (NULL == syncData) return;
|
||||||
|
|
||||||
int selectLeft = min(selectStartTrack, selectStopTrack);
|
int selectLeft = min(selectStartTrack, selectStopTrack);
|
||||||
int selectRight = max(selectStartTrack, selectStopTrack);
|
int selectRight = max(selectStartTrack, selectStopTrack);
|
||||||
int selectTop = min(selectStartRow, selectStopRow);
|
int selectTop = min(selectStartRow, selectStopRow);
|
||||||
@ -214,7 +213,7 @@ void TrackView::paintTracks(HDC hdc, RECT rcTracks)
|
|||||||
{
|
{
|
||||||
ASSERT(trackIter != syncData->tracks.end());
|
ASSERT(trackIter != syncData->tracks.end());
|
||||||
if (track < firstTrack) continue;
|
if (track < firstTrack) continue;
|
||||||
|
|
||||||
for (int row = firstRow; row <= lastRow; ++row)
|
for (int row = firstRow; row <= lastRow; ++row)
|
||||||
{
|
{
|
||||||
RECT patternDataRect;
|
RECT patternDataRect;
|
||||||
@ -222,11 +221,11 @@ void TrackView::paintTracks(HDC hdc, RECT rcTracks)
|
|||||||
patternDataRect.right = patternDataRect.left + trackWidth;
|
patternDataRect.right = patternDataRect.left + trackWidth;
|
||||||
patternDataRect.top = getScreenY(row);
|
patternDataRect.top = getScreenY(row);
|
||||||
patternDataRect.bottom = patternDataRect.top + fontHeight;
|
patternDataRect.bottom = patternDataRect.top + fontHeight;
|
||||||
|
|
||||||
if (!RectVisible(hdc, &patternDataRect)) continue;
|
if (!RectVisible(hdc, &patternDataRect)) continue;
|
||||||
|
|
||||||
bool selected = selectActive && (track >= selectLeft && track <= selectRight) && (row >= selectTop && row <= selectBottom);
|
bool selected = selectActive && (track >= selectLeft && track <= selectRight) && (row >= selectTop && row <= selectBottom);
|
||||||
|
|
||||||
HBRUSH baseBrush = bgBaseBrush;
|
HBRUSH baseBrush = bgBaseBrush;
|
||||||
HBRUSH darkBrush = bgDarkBrush;
|
HBRUSH darkBrush = bgDarkBrush;
|
||||||
if (selected)
|
if (selected)
|
||||||
@ -234,10 +233,10 @@ void TrackView::paintTracks(HDC hdc, RECT rcTracks)
|
|||||||
baseBrush = selectBaseBrush;
|
baseBrush = selectBaseBrush;
|
||||||
darkBrush = selectDarkBrush;
|
darkBrush = selectDarkBrush;
|
||||||
}
|
}
|
||||||
|
|
||||||
HBRUSH bgBrush = baseBrush;
|
HBRUSH bgBrush = baseBrush;
|
||||||
if (row % 8 == 0) bgBrush = darkBrush;
|
if (row % 8 == 0) bgBrush = darkBrush;
|
||||||
|
|
||||||
RECT fillRect = patternDataRect;
|
RECT fillRect = patternDataRect;
|
||||||
// if (row == editRow && track == editTrack) DrawEdge(hdc, &fillRect, BDR_RAISEDINNER | BDR_SUNKENOUTER, BF_ADJUST | BF_TOP | BF_BOTTOM | BF_LEFT | BF_RIGHT);
|
// if (row == editRow && track == editTrack) DrawEdge(hdc, &fillRect, BDR_RAISEDINNER | BDR_SUNKENOUTER, BF_ADJUST | BF_TOP | BF_BOTTOM | BF_LEFT | BF_RIGHT);
|
||||||
FillRect( hdc, &fillRect, bgBrush);
|
FillRect( hdc, &fillRect, bgBrush);
|
||||||
@ -246,7 +245,7 @@ void TrackView::paintTracks(HDC hdc, RECT rcTracks)
|
|||||||
MoveToEx(hdc, patternDataRect.left, patternDataRect.top, (LPPOINT) NULL);
|
MoveToEx(hdc, patternDataRect.left, patternDataRect.top, (LPPOINT) NULL);
|
||||||
LineTo(hdc, patternDataRect.right, patternDataRect.top);
|
LineTo(hdc, patternDataRect.right, patternDataRect.top);
|
||||||
} */
|
} */
|
||||||
|
|
||||||
bool drawEditString = false;
|
bool drawEditString = false;
|
||||||
if (row == editRow && track == editTrack)
|
if (row == editRow && track == editTrack)
|
||||||
{
|
{
|
||||||
@ -255,7 +254,7 @@ void TrackView::paintTracks(HDC hdc, RECT rcTracks)
|
|||||||
// Rectangle(hdc, fillRect.left, fillRect.top, fillRect.right, fillRect.bottom);
|
// Rectangle(hdc, fillRect.left, fillRect.top, fillRect.right, fillRect.bottom);
|
||||||
if (editString.size() > 0) drawEditString = true;
|
if (editString.size() > 0) drawEditString = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// InvertRect(hdc, &fillRect);
|
// InvertRect(hdc, &fillRect);
|
||||||
|
|
||||||
const SyncTrack &track = trackIter->second;
|
const SyncTrack &track = trackIter->second;
|
||||||
@ -279,7 +278,7 @@ void TrackView::paintTracks(HDC hdc, RECT rcTracks)
|
|||||||
if (selected) SetTextColor(hdc, oldCol);
|
if (selected) SetTextColor(hdc, oldCol);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* right margin */
|
/* right margin */
|
||||||
{
|
{
|
||||||
RECT rightMargin;
|
RECT rightMargin;
|
||||||
@ -289,7 +288,7 @@ void TrackView::paintTracks(HDC hdc, RECT rcTracks)
|
|||||||
rightMargin.right = rcTracks.right;
|
rightMargin.right = rcTracks.right;
|
||||||
FillRect( hdc, &rightMargin, GetSysColorBrush(COLOR_APPWORKSPACE));
|
FillRect( hdc, &rightMargin, GetSysColorBrush(COLOR_APPWORKSPACE));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
RECT bottomPadding;
|
RECT bottomPadding;
|
||||||
bottomPadding.top = getScreenY(rows);
|
bottomPadding.top = getScreenY(rows);
|
||||||
@ -367,7 +366,7 @@ void TrackView::copy()
|
|||||||
SetClipboardData(clipboardFormat, hmem);
|
SetClipboardData(clipboardFormat, hmem);
|
||||||
SetClipboardData(CF_TEXT, hmem_text);
|
SetClipboardData(CF_TEXT, hmem_text);
|
||||||
CloseClipboard();
|
CloseClipboard();
|
||||||
|
|
||||||
// should this memory be free'd or not? freeing seems to cause some hick-ups some times...
|
// should this memory be free'd or not? freeing seems to cause some hick-ups some times...
|
||||||
// GlobalFree(hmem);
|
// GlobalFree(hmem);
|
||||||
// GlobalFree(hmem_text);
|
// GlobalFree(hmem_text);
|
||||||
@ -515,7 +514,7 @@ void TrackView::setEditTrack(int newEditTrack)
|
|||||||
|
|
||||||
int firstTrack = scrollPosX / trackWidth;
|
int firstTrack = scrollPosX / trackWidth;
|
||||||
int lastTrack = firstTrack + windowTracks;
|
int lastTrack = firstTrack + windowTracks;
|
||||||
|
|
||||||
int newFirstTrack = firstTrack;
|
int newFirstTrack = firstTrack;
|
||||||
if (editTrack >= lastTrack) newFirstTrack = editTrack - (lastTrack - firstTrack - 1);
|
if (editTrack >= lastTrack) newFirstTrack = editTrack - (lastTrack - firstTrack - 1);
|
||||||
if (editTrack < firstTrack) newFirstTrack = editTrack;
|
if (editTrack < firstTrack) newFirstTrack = editTrack;
|
||||||
@ -529,34 +528,43 @@ static int getScrollPos(HWND hwnd, int bar)
|
|||||||
return int(si.nTrackPos);
|
return int(si.nTrackPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TrackView::setRows(int rows)
|
||||||
|
{
|
||||||
|
int oldRows = getRows();
|
||||||
|
this->rows = rows;
|
||||||
|
InvalidateRect(getWin(), NULL, FALSE);
|
||||||
|
setEditRow(min(editRow, rows - 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
LRESULT TrackView::onVScroll(UINT sbCode, int newPos)
|
LRESULT TrackView::onVScroll(UINT sbCode, int newPos)
|
||||||
{
|
{
|
||||||
switch (sbCode)
|
switch (sbCode)
|
||||||
{
|
{
|
||||||
case SB_TOP:
|
case SB_TOP:
|
||||||
setEditRow(0);
|
setEditRow(0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SB_LINEUP:
|
case SB_LINEUP:
|
||||||
setEditRow(editRow - 1);
|
setEditRow(editRow - 1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SB_LINEDOWN:
|
case SB_LINEDOWN:
|
||||||
setEditRow(editRow + 1);
|
setEditRow(editRow + 1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SB_PAGEUP:
|
case SB_PAGEUP:
|
||||||
setEditRow(editRow - windowRows / 2);
|
setEditRow(editRow - windowRows / 2);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SB_PAGEDOWN:
|
case SB_PAGEDOWN:
|
||||||
setEditRow(editRow + windowRows / 2);
|
setEditRow(editRow + windowRows / 2);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SB_THUMBPOSITION:
|
case SB_THUMBPOSITION:
|
||||||
case SB_THUMBTRACK:
|
case SB_THUMBTRACK:
|
||||||
setEditRow(getScrollPos(hwnd, SB_VERT));
|
setEditRow(getScrollPos(hwnd, SB_VERT));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -568,32 +576,32 @@ LRESULT TrackView::onHScroll(UINT sbCode, int newPos)
|
|||||||
{
|
{
|
||||||
case SB_LEFT:
|
case SB_LEFT:
|
||||||
setEditTrack(0);
|
setEditTrack(0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SB_RIGHT:
|
case SB_RIGHT:
|
||||||
setEditTrack(getTrackCount() - 1);
|
setEditTrack(getTrackCount() - 1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SB_LINELEFT:
|
case SB_LINELEFT:
|
||||||
setEditTrack(editTrack - 1);
|
setEditTrack(editTrack - 1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SB_LINERIGHT:
|
case SB_LINERIGHT:
|
||||||
setEditTrack(editTrack + 1);
|
setEditTrack(editTrack + 1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SB_PAGELEFT:
|
case SB_PAGELEFT:
|
||||||
setEditTrack(editTrack - windowTracks);
|
setEditTrack(editTrack - windowTracks);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SB_PAGEDOWN:
|
case SB_PAGEDOWN:
|
||||||
setEditTrack(editTrack + windowTracks);
|
setEditTrack(editTrack + windowTracks);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SB_THUMBPOSITION:
|
case SB_THUMBPOSITION:
|
||||||
case SB_THUMBTRACK:
|
case SB_THUMBTRACK:
|
||||||
setEditTrack(getScrollPos(hwnd, SB_HORZ));
|
setEditTrack(getScrollPos(hwnd, SB_HORZ));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -605,56 +613,54 @@ LRESULT TrackView::onKeyDown(UINT keyCode, UINT flags)
|
|||||||
bool ctrlDown = GetKeyState(VK_CONTROL) < 0 ? true : false;
|
bool ctrlDown = GetKeyState(VK_CONTROL) < 0 ? true : false;
|
||||||
bool shiftDown = GetKeyState(VK_SHIFT) < 0 ? true : false;
|
bool shiftDown = GetKeyState(VK_SHIFT) < 0 ? true : false;
|
||||||
bool altDown = GetKeyState(VK_MENU) < 0 ? true : false;
|
bool altDown = GetKeyState(VK_MENU) < 0 ? true : false;
|
||||||
|
|
||||||
if (editString.empty())
|
if (editString.empty())
|
||||||
{
|
{
|
||||||
switch (keyCode)
|
switch (keyCode)
|
||||||
{
|
{
|
||||||
case VK_UP: setEditRow(editRow - 1); break;
|
case VK_UP: setEditRow(editRow - 1); break;
|
||||||
case VK_DOWN: setEditRow(editRow + 1); break;
|
case VK_DOWN: setEditRow(editRow + 1); break;
|
||||||
|
|
||||||
case VK_LEFT: setEditTrack(editTrack - 1); break;
|
case VK_LEFT: setEditTrack(editTrack - 1); break;
|
||||||
case VK_RIGHT: setEditTrack(editTrack + 1); break;
|
case VK_RIGHT: setEditTrack(editTrack + 1); break;
|
||||||
|
|
||||||
case VK_PRIOR: setEditRow(editRow - windowRows / 2); break;
|
case VK_PRIOR: setEditRow(editRow - windowRows / 2); break;
|
||||||
case VK_NEXT: setEditRow(editRow + windowRows / 2); break;
|
case VK_NEXT: setEditRow(editRow + windowRows / 2); break;
|
||||||
|
|
||||||
case VK_SHIFT:
|
case VK_SHIFT:
|
||||||
// if (selectActive) invalidateRange(selectStartTrack, selectStopTrack, selectStartRow, selectStopRow);
|
// if (selectActive) invalidateRange(selectStartTrack, selectStopTrack, selectStartRow, selectStopRow);
|
||||||
if (!selectActive)
|
if (!selectActive)
|
||||||
{
|
{
|
||||||
selectStartTrack = selectStopTrack = editTrack;
|
selectStartTrack = selectStopTrack = editTrack;
|
||||||
selectStartRow = selectStopRow = editRow;
|
selectStartRow = selectStopRow = editRow;
|
||||||
// selectActive = true;
|
// selectActive = true;
|
||||||
// printf("select active\n");
|
// printf("select active\n");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (keyCode)
|
switch (keyCode)
|
||||||
{
|
{
|
||||||
case VK_RETURN:
|
case VK_RETURN:
|
||||||
|
if (editString.size() > 0)
|
||||||
{
|
{
|
||||||
if (editString.size() > 0)
|
SyncEditData::EditCommand *cmd = new SyncEditData::EditCommand(
|
||||||
{
|
editTrack, editRow,
|
||||||
SyncEditData::EditCommand *cmd = new SyncEditData::EditCommand(
|
true, float(_tstof(editString.c_str()))
|
||||||
editTrack, editRow,
|
);
|
||||||
true, float(_tstof(editString.c_str()))
|
syncData->exec(cmd);
|
||||||
);
|
|
||||||
syncData->exec(cmd);
|
editString.clear();
|
||||||
|
invalidatePos(editTrack, editRow);
|
||||||
editString.clear();
|
|
||||||
invalidatePos(editTrack, editRow);
|
|
||||||
}
|
|
||||||
else MessageBeep(0);
|
|
||||||
}
|
}
|
||||||
|
else MessageBeep(0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VK_DELETE:
|
case VK_DELETE:
|
||||||
{
|
{
|
||||||
SyncEditData::EditCommand *cmd = new SyncEditData::EditCommand(
|
SyncEditData::EditCommand *cmd = new SyncEditData::EditCommand(
|
||||||
editTrack, editRow,
|
editTrack, editRow,
|
||||||
@ -664,30 +670,30 @@ LRESULT TrackView::onKeyDown(UINT keyCode, UINT flags)
|
|||||||
invalidatePos(editTrack, editRow);
|
invalidatePos(editTrack, editRow);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VK_BACK:
|
case VK_BACK:
|
||||||
if (editString.size() > 0)
|
if (editString.size() > 0)
|
||||||
{
|
{
|
||||||
editString.resize(editString.size() - 1);
|
editString.resize(editString.size() - 1);
|
||||||
invalidatePos(editTrack, editRow);
|
invalidatePos(editTrack, editRow);
|
||||||
}
|
}
|
||||||
else MessageBeep(0);
|
else MessageBeep(0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VK_CANCEL:
|
case VK_CANCEL:
|
||||||
case VK_ESCAPE:
|
case VK_ESCAPE:
|
||||||
if (selectActive)
|
if (selectActive)
|
||||||
{
|
{
|
||||||
selectActive = false;
|
selectActive = false;
|
||||||
invalidateRange(selectStartTrack, selectStopTrack, selectStartRow, selectStopRow);
|
invalidateRange(selectStartTrack, selectStopTrack, selectStartRow, selectStopRow);
|
||||||
}
|
}
|
||||||
if (editString.size() > 0)
|
if (editString.size() > 0)
|
||||||
{
|
{
|
||||||
// return to old value (i.e don't clear)
|
// return to old value (i.e don't clear)
|
||||||
editString.clear();
|
editString.clear();
|
||||||
invalidatePos(editTrack, editRow);
|
invalidatePos(editTrack, editRow);
|
||||||
MessageBeep(0);
|
MessageBeep(0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -698,26 +704,27 @@ LRESULT TrackView::onChar(UINT keyCode, UINT flags)
|
|||||||
printf("char: \"%c\" (%d) - flags: %x\n", (char)keyCode, keyCode, flags);
|
printf("char: \"%c\" (%d) - flags: %x\n", (char)keyCode, keyCode, flags);
|
||||||
switch ((char)keyCode)
|
switch ((char)keyCode)
|
||||||
{
|
{
|
||||||
case '.':
|
case '.':
|
||||||
// only one '.' allowed
|
// only one '.' allowed
|
||||||
if (std::string::npos != editString.find('.'))
|
if (std::string::npos != editString.find('.'))
|
||||||
{
|
{
|
||||||
MessageBeep(0);
|
MessageBeep(0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case '0':
|
|
||||||
case '1':
|
case '0':
|
||||||
case '2':
|
case '1':
|
||||||
case '3':
|
case '2':
|
||||||
case '4':
|
case '3':
|
||||||
case '5':
|
case '4':
|
||||||
case '6':
|
case '5':
|
||||||
case '7':
|
case '6':
|
||||||
case '8':
|
case '7':
|
||||||
case '9':
|
case '8':
|
||||||
editString.push_back(keyCode);
|
case '9':
|
||||||
printf("accepted: %c - %s\n", (char)keyCode, editString.c_str());
|
editString.push_back(keyCode);
|
||||||
invalidatePos(editTrack, editRow);
|
printf("accepted: %c - %s\n", (char)keyCode, editString.c_str());
|
||||||
|
invalidatePos(editTrack, editRow);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -727,10 +734,10 @@ LRESULT TrackView::onSize(int width, int height)
|
|||||||
{
|
{
|
||||||
const int oldWindowWidth = windowWidth;
|
const int oldWindowWidth = windowWidth;
|
||||||
const int oldWindowHeight = windowHeight;
|
const int oldWindowHeight = windowHeight;
|
||||||
|
|
||||||
windowWidth = width;
|
windowWidth = width;
|
||||||
windowHeight = height;
|
windowHeight = height;
|
||||||
|
|
||||||
windowRows = (height - topMarginHeight) / fontHeight;
|
windowRows = (height - topMarginHeight) / fontHeight;
|
||||||
windowTracks = (width - leftMarginWidth) / trackWidth;
|
windowTracks = (width - leftMarginWidth) / trackWidth;
|
||||||
|
|
||||||
@ -745,41 +752,41 @@ LRESULT TrackView::windowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|||||||
|
|
||||||
switch(msg)
|
switch(msg)
|
||||||
{
|
{
|
||||||
case WM_CREATE: return onCreate();
|
case WM_CREATE: return onCreate();
|
||||||
|
|
||||||
case WM_CLOSE:
|
case WM_CLOSE:
|
||||||
DestroyWindow(hwnd);
|
DestroyWindow(hwnd);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_DESTROY:
|
case WM_DESTROY:
|
||||||
PostQuitMessage(0);
|
PostQuitMessage(0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_SIZE: return onSize(LOWORD(lParam), HIWORD(lParam));
|
case WM_SIZE: return onSize(LOWORD(lParam), HIWORD(lParam));
|
||||||
case WM_VSCROLL: return onVScroll(LOWORD(wParam), getScrollPos(hwnd, SB_VERT));
|
case WM_VSCROLL: return onVScroll(LOWORD(wParam), getScrollPos(hwnd, SB_VERT));
|
||||||
case WM_HSCROLL: return onHScroll(LOWORD(wParam), getScrollPos(hwnd, SB_HORZ));
|
case WM_HSCROLL: return onHScroll(LOWORD(wParam), getScrollPos(hwnd, SB_HORZ));
|
||||||
case WM_PAINT: return onPaint();
|
case WM_PAINT: return onPaint();
|
||||||
case WM_KEYDOWN: return onKeyDown((UINT)wParam, (UINT)lParam);
|
case WM_KEYDOWN: return onKeyDown((UINT)wParam, (UINT)lParam);
|
||||||
case WM_CHAR: return onChar((UINT)wParam, (UINT)lParam);
|
case WM_CHAR: return onChar((UINT)wParam, (UINT)lParam);
|
||||||
|
|
||||||
case WM_COPY: copy(); break;
|
case WM_COPY: copy(); break;
|
||||||
case WM_CUT: cut(); break;
|
case WM_CUT: cut(); break;
|
||||||
case WM_PASTE: paste(); break;
|
case WM_PASTE: paste(); break;
|
||||||
|
|
||||||
case WM_UNDO:
|
case WM_UNDO:
|
||||||
if (!syncData->undo()) MessageBeep(0);
|
if (!syncData->undo()) MessageBeep(0);
|
||||||
// unfortunately, we don't know how much to invalidate... so we'll just invalidate it all.
|
// unfortunately, we don't know how much to invalidate... so we'll just invalidate it all.
|
||||||
InvalidateRect(hwnd, NULL, TRUE);
|
InvalidateRect(hwnd, NULL, TRUE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_REDO:
|
case WM_REDO:
|
||||||
if (!syncData->redo()) MessageBeep(0);
|
if (!syncData->redo()) MessageBeep(0);
|
||||||
// unfortunately, we don't know how much to invalidate... so we'll just invalidate it all.
|
// unfortunately, we don't know how much to invalidate... so we'll just invalidate it all.
|
||||||
InvalidateRect(hwnd, NULL, TRUE);
|
InvalidateRect(hwnd, NULL, TRUE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return DefWindowProc(hwnd, msg, wParam, lParam);
|
return DefWindowProc(hwnd, msg, wParam, lParam);
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -792,38 +799,37 @@ static LRESULT CALLBACK trackViewWindowProc(HWND hwnd, UINT msg, WPARAM wParam,
|
|||||||
|
|
||||||
switch(msg)
|
switch(msg)
|
||||||
{
|
{
|
||||||
case WM_NCCREATE:
|
case WM_NCCREATE:
|
||||||
// Get TrackView from createstruct
|
// Get TrackView from createstruct
|
||||||
trackView = (TrackView*)((CREATESTRUCT*)lParam)->lpCreateParams;
|
trackView = (TrackView*)((CREATESTRUCT*)lParam)->lpCreateParams;
|
||||||
trackView->hwnd = hwnd;
|
trackView->hwnd = hwnd;
|
||||||
|
|
||||||
// Set the TrackView instance
|
|
||||||
#pragma warning(suppress:4244) /* remove a pointless warning */
|
|
||||||
SetWindowLongPtr(hwnd, 0, (LONG_PTR)trackView);
|
|
||||||
|
|
||||||
// call the proper window procedure
|
|
||||||
return trackView->windowProc(hwnd, msg, wParam, lParam);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WM_NCDESTROY:
|
// Set the TrackView instance
|
||||||
|
#pragma warning(suppress:4244) /* remove a pointless warning */
|
||||||
|
SetWindowLongPtr(hwnd, 0, (LONG_PTR)trackView);
|
||||||
|
|
||||||
|
// call the proper window procedure
|
||||||
|
return trackView->windowProc(hwnd, msg, wParam, lParam);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WM_NCDESTROY:
|
||||||
|
ASSERT(NULL != trackView);
|
||||||
{
|
{
|
||||||
ASSERT(NULL != trackView);
|
|
||||||
|
|
||||||
// call the window proc and store away the return code
|
// call the window proc and store away the return code
|
||||||
LRESULT res = trackView->windowProc(hwnd, msg, wParam, lParam);
|
LRESULT res = trackView->windowProc(hwnd, msg, wParam, lParam);
|
||||||
|
|
||||||
// get rid of the TrackView instance
|
// get rid of the TrackView instance
|
||||||
trackView = NULL;
|
trackView = NULL;
|
||||||
SetWindowLongPtr(hwnd, 0, (LONG_PTR)NULL);
|
SetWindowLongPtr(hwnd, 0, (LONG_PTR)NULL);
|
||||||
|
|
||||||
// return the stored return code
|
// return the stored return code
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
ASSERT(NULL != trackView);
|
ASSERT(NULL != trackView);
|
||||||
return trackView->windowProc(hwnd, msg, wParam, lParam);
|
return trackView->windowProc(hwnd, msg, wParam, lParam);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,6 +21,9 @@ public:
|
|||||||
void setSyncData(SyncEditData *syncData) { this->syncData = syncData; }
|
void setSyncData(SyncEditData *syncData) { this->syncData = syncData; }
|
||||||
SyncEditData *getSyncData() { return syncData; }
|
SyncEditData *getSyncData() { return syncData; }
|
||||||
|
|
||||||
|
void setRows(int rows);
|
||||||
|
int getRows() const { return rows; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// some nasty hackery to forward the window messages
|
// some nasty hackery to forward the window messages
|
||||||
friend static LRESULT CALLBACK trackViewWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
friend static LRESULT CALLBACK trackViewWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||||
@ -47,7 +50,7 @@ private:
|
|||||||
void setupScrollBars();
|
void setupScrollBars();
|
||||||
void setScrollPos(int newScrollPosX, int newScrollPosY);
|
void setScrollPos(int newScrollPosX, int newScrollPosY);
|
||||||
void scrollWindow(int newScrollPosX, int newScrollPosY);
|
void scrollWindow(int newScrollPosX, int newScrollPosY);
|
||||||
|
|
||||||
void invalidateRange(int startTrack, int stopTrack, int startRow, int stopRow)
|
void invalidateRange(int startTrack, int stopTrack, int startRow, int stopRow)
|
||||||
{
|
{
|
||||||
RECT rect;
|
RECT rect;
|
||||||
@ -124,8 +127,6 @@ private:
|
|||||||
int windowWidth, windowHeight;
|
int windowWidth, windowHeight;
|
||||||
int windowRows, windowTracks;
|
int windowRows, windowTracks;
|
||||||
|
|
||||||
int rows;
|
|
||||||
|
|
||||||
SyncEditData *syncData;
|
SyncEditData *syncData;
|
||||||
|
|
||||||
std::basic_string<TCHAR> editString;
|
std::basic_string<TCHAR> editString;
|
||||||
@ -134,6 +135,7 @@ private:
|
|||||||
HBRUSH editBrush;
|
HBRUSH editBrush;
|
||||||
|
|
||||||
UINT clipboardFormat;
|
UINT clipboardFormat;
|
||||||
|
int rows;
|
||||||
};
|
};
|
||||||
|
|
||||||
ATOM registerTrackViewWindowClass(HINSTANCE hInstance);
|
ATOM registerTrackViewWindowClass(HINSTANCE hInstance);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user