refactoring
This commit is contained in:
parent
9bf44409f9
commit
ac84834e1b
14
client.cpp
14
client.cpp
@ -42,12 +42,16 @@ int main(int argc, char *argv[])
|
|||||||
if (0 == ret) done = true;
|
if (0 == ret) done = true;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
printf("cmd: %02x\n", cmd);
|
switch (cmd)
|
||||||
if (cmd == 1)
|
|
||||||
{
|
{
|
||||||
printf("yes, master!\n");
|
case 1:
|
||||||
unsigned char cmd = 0x1;
|
printf("yes, master!\n");
|
||||||
send(serverSocket, (char*)&cmd, 1, 0);
|
unsigned char cmd = 0x1;
|
||||||
|
send(serverSocket, (char*)&cmd, 1, 0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
printf("unknown cmd: %02x\n", cmd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
20
resource.h
Normal file
20
resource.h
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
//{{NO_DEPENDENCIES}}
|
||||||
|
// Microsoft Visual C++ generated include file.
|
||||||
|
// Used by synctracker2.rc
|
||||||
|
//
|
||||||
|
#define IDR_ACCELERATOR 101
|
||||||
|
#define IDR_MENU 102
|
||||||
|
#define ID_FILE 40001
|
||||||
|
#define ID_FILE_EXIT 40002
|
||||||
|
#define ID_EDIT 40003
|
||||||
|
|
||||||
|
// Next default values for new objects
|
||||||
|
//
|
||||||
|
#ifdef APSTUDIO_INVOKED
|
||||||
|
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||||
|
#define _APS_NEXT_RESOURCE_VALUE 103
|
||||||
|
#define _APS_NEXT_COMMAND_VALUE 40004
|
||||||
|
#define _APS_NEXT_CONTROL_VALUE 1001
|
||||||
|
#define _APS_NEXT_SYMED_VALUE 101
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
4
stdafx.h
4
stdafx.h
@ -5,10 +5,12 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
|
#include "afxres.h"
|
||||||
|
#include "resource.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|||||||
@ -19,44 +19,25 @@ static LRESULT CALLBACK mainWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA
|
|||||||
{
|
{
|
||||||
case WM_CREATE:
|
case WM_CREATE:
|
||||||
{
|
{
|
||||||
trackViewWin = trackView->create(GetModuleHandle(NULL), hwnd);
|
HINSTANCE hInstance = GetModuleHandle(NULL);
|
||||||
|
trackViewWin = trackView->create(hInstance, hwnd);
|
||||||
InitCommonControls();
|
InitCommonControls();
|
||||||
statusBarWin = CreateWindowEx(
|
statusBarWin = CreateWindowEx(
|
||||||
0, // no extended styles
|
0, // no extended styles
|
||||||
STATUSCLASSNAME, // status bar
|
STATUSCLASSNAME, // status bar
|
||||||
(LPCTSTR)"mordi", // no text
|
(LPCTSTR)NULL, // no text
|
||||||
SBARS_SIZEGRIP | WS_VISIBLE | WS_CHILD, // styles
|
SBARS_SIZEGRIP | WS_VISIBLE | WS_CHILD, // styles
|
||||||
0, 0, 0, 0, // x, y, cx, cy
|
0, 0, 0, 0, // x, y, cx, cy
|
||||||
hwnd, // parent window
|
hwnd, // parent window
|
||||||
(HMENU)100, // window ID
|
NULL, // menu
|
||||||
GetModuleHandle(NULL), // instance
|
hInstance, // instance
|
||||||
NULL // window data
|
NULL // window data
|
||||||
);
|
);
|
||||||
|
|
||||||
int statwidths[] = {100, -1};
|
int statwidths[] = { 100, -1 };
|
||||||
SendMessage(statusBarWin, SB_SETPARTS, sizeof(statwidths)/sizeof(int), (LPARAM)statwidths);
|
SendMessage(statusBarWin, SB_SETPARTS, sizeof(statwidths) / sizeof(int), (LPARAM)statwidths);
|
||||||
SendMessage(statusBarWin, SB_SETTEXT, 0, (LPARAM)"Hi there :)");
|
SendMessage(statusBarWin, SB_SETTEXT, 0, (LPARAM)"Hi there :)");
|
||||||
|
SendMessage(statusBarWin, SB_SETTEXT, 1, (LPARAM)"Hi there :)");
|
||||||
HMENU fileMenu = CreatePopupMenu();
|
|
||||||
AppendMenu(fileMenu, MF_STRING, 0, _T("&Open\tCtrl+O"));
|
|
||||||
AppendMenu(fileMenu, MF_STRING, 2, _T("&Save\tCtrl+S"));
|
|
||||||
AppendMenu(fileMenu, MF_STRING, 3, _T("Save &As"));
|
|
||||||
AppendMenu(fileMenu, MF_SEPARATOR, 0, NULL);
|
|
||||||
AppendMenu(fileMenu, MF_STRING, 3, _T("&Exit"));
|
|
||||||
|
|
||||||
HMENU editMenu = CreatePopupMenu();
|
|
||||||
AppendMenu(editMenu, MF_STRING, WM_UNDO, _T("&Undo\tCtrl+Z"));
|
|
||||||
AppendMenu(editMenu, MF_STRING, WM_REDO, _T("&Redo\tShift+Ctrl+Z"));
|
|
||||||
AppendMenu(editMenu, MF_SEPARATOR, 0, NULL);
|
|
||||||
AppendMenu(editMenu, MF_STRING, WM_CUT, _T("Cu&t\tCtrl+X"));
|
|
||||||
AppendMenu(editMenu, MF_STRING, WM_COPY, _T("&Copy\tCtrl+C"));
|
|
||||||
AppendMenu(editMenu, MF_STRING, WM_PASTE, _T("&Paste\tCtrl+V"));
|
|
||||||
|
|
||||||
HMENU rootMenu = CreateMenu();
|
|
||||||
AppendMenu(rootMenu, MF_STRING | MF_POPUP, (UINT_PTR)fileMenu, _T("&File"));
|
|
||||||
AppendMenu(rootMenu, MF_STRING | MF_POPUP, (UINT_PTR)editMenu, _T("&Edit"));
|
|
||||||
SetMenu(hwnd, rootMenu);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -81,17 +62,14 @@ static LRESULT CALLBACK mainWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA
|
|||||||
case WM_COMMAND:
|
case WM_COMMAND:
|
||||||
switch (LOWORD(wParam))
|
switch (LOWORD(wParam))
|
||||||
{
|
{
|
||||||
// simply forward these
|
case ID_FILE_SAVE: /* meh.*/ break;
|
||||||
case WM_UNDO:
|
case ID_EDIT_UNDO: SendMessage(trackViewWin, WM_UNDO, 0, 0); break;
|
||||||
case WM_REDO:
|
case ID_EDIT_REDO: SendMessage(trackViewWin, WM_REDO, 0, 0); break;
|
||||||
case WM_COPY:
|
case ID_EDIT_COPY: SendMessage(trackViewWin, WM_COPY, 0, 0); break;
|
||||||
case WM_PASTE:
|
case ID_EDIT_CUT: SendMessage(trackViewWin, WM_CUT, 0, 0); break;
|
||||||
case WM_CUT:
|
case ID_EDIT_PASTE: SendMessage(trackViewWin, WM_PASTE, 0, 0); break;
|
||||||
SendMessage(trackViewWin, LOWORD(wParam), 0, 0);
|
default:
|
||||||
break;
|
printf("cmd %d %d\n", wParam, lParam);
|
||||||
|
|
||||||
default:
|
|
||||||
printf("cmd %d %d\n", wParam, lParam);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -114,7 +92,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 = NULL;
|
wc.lpszMenuName = (LPCSTR)IDR_MENU;
|
||||||
wc.lpszClassName = mainWindowClassName;
|
wc.lpszClassName = mainWindowClassName;
|
||||||
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
|
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
|
||||||
|
|
||||||
@ -215,6 +193,9 @@ int _tmain(int argc, _TCHAR* argv[])
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HACCEL accel = LoadAccelerators(hInstance, (LPCSTR)IDR_ACCELERATOR);
|
||||||
|
printf("accel: %p\n", accel);
|
||||||
|
|
||||||
ShowWindow(hwnd, TRUE);
|
ShowWindow(hwnd, TRUE);
|
||||||
UpdateWindow(hwnd);
|
UpdateWindow(hwnd);
|
||||||
|
|
||||||
@ -278,9 +259,12 @@ int _tmain(int argc, _TCHAR* argv[])
|
|||||||
|
|
||||||
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
|
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
|
||||||
{
|
{
|
||||||
TranslateMessage(&msg);
|
if (!TranslateAccelerator(hwnd, accel, &msg))
|
||||||
DispatchMessage(&msg);
|
{
|
||||||
if (WM_QUIT == msg.message) done = true;
|
TranslateMessage(&msg);
|
||||||
|
DispatchMessage(&msg);
|
||||||
|
if (WM_QUIT == msg.message) done = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
105
synctracker2.rc
Normal file
105
synctracker2.rc
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
// Microsoft Visual C++ generated resource script.
|
||||||
|
//
|
||||||
|
#include "resource.h"
|
||||||
|
|
||||||
|
#define APSTUDIO_READONLY_SYMBOLS
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Generated from the TEXTINCLUDE 2 resource.
|
||||||
|
//
|
||||||
|
#include "afxres.h"
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
#undef APSTUDIO_READONLY_SYMBOLS
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Norwegian (Bokmal) resources
|
||||||
|
|
||||||
|
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NOR)
|
||||||
|
#ifdef _WIN32
|
||||||
|
LANGUAGE LANG_NORWEGIAN, SUBLANG_NORWEGIAN_BOKMAL
|
||||||
|
#pragma code_page(1252)
|
||||||
|
#endif //_WIN32
|
||||||
|
|
||||||
|
#ifdef APSTUDIO_INVOKED
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// TEXTINCLUDE
|
||||||
|
//
|
||||||
|
|
||||||
|
1 TEXTINCLUDE
|
||||||
|
BEGIN
|
||||||
|
"resource.h\0"
|
||||||
|
END
|
||||||
|
|
||||||
|
2 TEXTINCLUDE
|
||||||
|
BEGIN
|
||||||
|
"#include ""afxres.h""\r\n"
|
||||||
|
"\0"
|
||||||
|
END
|
||||||
|
|
||||||
|
3 TEXTINCLUDE
|
||||||
|
BEGIN
|
||||||
|
"\r\n"
|
||||||
|
"\0"
|
||||||
|
END
|
||||||
|
|
||||||
|
#endif // APSTUDIO_INVOKED
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Accelerator
|
||||||
|
//
|
||||||
|
|
||||||
|
IDR_ACCELERATOR ACCELERATORS
|
||||||
|
BEGIN
|
||||||
|
"C", ID_EDIT_COPY, VIRTKEY, CONTROL, NOINVERT
|
||||||
|
"X", ID_EDIT_CUT, VIRTKEY, CONTROL, NOINVERT
|
||||||
|
"V", ID_EDIT_PASTE, VIRTKEY, CONTROL, NOINVERT
|
||||||
|
"Z", ID_EDIT_UNDO, VIRTKEY, CONTROL, NOINVERT
|
||||||
|
"Z", ID_EDIT_REDO, VIRTKEY, SHIFT, CONTROL, NOINVERT
|
||||||
|
END
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Menu
|
||||||
|
//
|
||||||
|
|
||||||
|
IDR_MENU MENU
|
||||||
|
BEGIN
|
||||||
|
POPUP "&File"
|
||||||
|
BEGIN
|
||||||
|
MENUITEM "&Open\tCtrl+O", ID_FILE_OPEN
|
||||||
|
MENUITEM "&Save\tCtrl+S", ID_FILE_SAVE
|
||||||
|
MENUITEM "Save &As", ID_FILE_SAVE_AS
|
||||||
|
MENUITEM SEPARATOR
|
||||||
|
MENUITEM "E&xit", ID_FILE_EXIT
|
||||||
|
END
|
||||||
|
POPUP "&Edit"
|
||||||
|
BEGIN
|
||||||
|
MENUITEM "Undo\tCtrl+Z", ID_EDIT_UNDO
|
||||||
|
MENUITEM "Redo\tCtrl+Shift+Z", ID_EDIT_REDO
|
||||||
|
MENUITEM SEPARATOR
|
||||||
|
MENUITEM "&Copy\tCtrl+C", ID_EDIT_COPY
|
||||||
|
MENUITEM "Cu&t\tCtrl+X", ID_EDIT_CUT
|
||||||
|
MENUITEM "&Paste\tCtrl+V", ID_EDIT_PASTE
|
||||||
|
END
|
||||||
|
END
|
||||||
|
|
||||||
|
#endif // Norwegian (Bokmal) resources
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef APSTUDIO_INVOKED
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Generated from the TEXTINCLUDE 3 resource.
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
#endif // not APSTUDIO_INVOKED
|
||||||
|
|
||||||
@ -206,6 +206,10 @@
|
|||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
|
RelativePath=".\resource.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
RelativePath=".\stdafx.h"
|
RelativePath=".\stdafx.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
@ -223,6 +227,10 @@
|
|||||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
|
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
|
||||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
||||||
>
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\synctracker2.rc"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
</Files>
|
</Files>
|
||||||
<Globals>
|
<Globals>
|
||||||
|
|||||||
148
trackview.cpp
148
trackview.cpp
@ -42,6 +42,9 @@ TrackView::TrackView()
|
|||||||
selectDarkBrush = CreateSolidBrush(darken(GetSysColor(COLOR_HIGHLIGHT), 0.9f));
|
selectDarkBrush = CreateSolidBrush(darken(GetSysColor(COLOR_HIGHLIGHT), 0.9f));
|
||||||
|
|
||||||
editBrush = CreateSolidBrush(RGB(255, 255, 0));
|
editBrush = CreateSolidBrush(RGB(255, 255, 0));
|
||||||
|
|
||||||
|
clipboardFormat = RegisterClipboardFormat("syncdata");
|
||||||
|
if (0 == clipboardFormat) printf("geh");
|
||||||
}
|
}
|
||||||
|
|
||||||
TrackView::~TrackView()
|
TrackView::~TrackView()
|
||||||
@ -306,6 +309,99 @@ void TrackView::paintTracks(HDC hdc, RECT rcTracks)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TrackView::copy()
|
||||||
|
{
|
||||||
|
if (!selectActive) return;
|
||||||
|
|
||||||
|
int selectLeft = min(selectStartTrack, selectStopTrack);
|
||||||
|
int selectRight = max(selectStartTrack, selectStopTrack);
|
||||||
|
int selectTop = min(selectStartRow, selectStopRow);
|
||||||
|
int selectBottom = max(selectStartRow, selectStopRow);
|
||||||
|
printf("copying:\n");
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
struct CopyEntry
|
||||||
|
{
|
||||||
|
int track, row;
|
||||||
|
float val;
|
||||||
|
bool valExisting;
|
||||||
|
};
|
||||||
|
std::vector<CopyEntry> copyBuffer;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (FAILED(OpenClipboard(getWin())))
|
||||||
|
{
|
||||||
|
MessageBox(NULL, "Failed to open clipboard", NULL, MB_OK);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// gather data
|
||||||
|
int rows = selectBottom - selectTop + 1;
|
||||||
|
int columns = selectRight - selectLeft + 1;
|
||||||
|
size_t cells = columns * rows;
|
||||||
|
HGLOBAL hmem = GlobalAlloc(GMEM_MOVEABLE, sizeof(float) * cells);
|
||||||
|
|
||||||
|
std::string copyString;
|
||||||
|
for (int row = selectTop; row <= selectBottom; ++row)
|
||||||
|
{
|
||||||
|
for (int track = selectLeft; track <= selectRight; ++track)
|
||||||
|
{
|
||||||
|
const SyncTrack &t = syncDataEdit.getSyncData()->getTrack(track);
|
||||||
|
char temp[128];
|
||||||
|
if (t.isKeyFrame(row)) sprintf(temp, "%.2f\t", t.getKeyFrame(row)->value);
|
||||||
|
else sprintf(temp, "--- \t");
|
||||||
|
copyString += temp;
|
||||||
|
printf("(%d %d) = %s", track, row, temp);
|
||||||
|
}
|
||||||
|
puts("");
|
||||||
|
copyString += "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
HGLOBAL hmem_text = GlobalAlloc(GMEM_MOVEABLE, strlen(copyString.c_str()) + 1);
|
||||||
|
char *clipbuf = (char *)GlobalLock(hmem_text);
|
||||||
|
memcpy(clipbuf, copyString.c_str(), strlen(copyString.c_str()) + 1);
|
||||||
|
GlobalUnlock(hmem_text);
|
||||||
|
|
||||||
|
// update clipboard
|
||||||
|
EmptyClipboard();
|
||||||
|
SetClipboardData(clipboardFormat, hmem);
|
||||||
|
SetClipboardData(CF_TEXT, hmem_text);
|
||||||
|
CloseClipboard();
|
||||||
|
|
||||||
|
// should this memory be free'd or not? freeing seems to cause some hick-ups some times...
|
||||||
|
// GlobalFree(hmem);
|
||||||
|
// GlobalFree(hmem_text);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TrackView::cut()
|
||||||
|
{
|
||||||
|
int selectLeft = min(selectStartTrack, selectStopTrack);
|
||||||
|
int selectRight = max(selectStartTrack, selectStopTrack);
|
||||||
|
int selectTop = min(selectStartRow, selectStopRow);
|
||||||
|
int selectBottom = max(selectStartRow, selectStopRow);
|
||||||
|
|
||||||
|
copy();
|
||||||
|
#if 0
|
||||||
|
for (int track = selectLeft; track <= selectRight; ++track)
|
||||||
|
{
|
||||||
|
SyncTrack &t = syncDataEdit.getSyncData()->getTrack(track);
|
||||||
|
for (int row = selectTop; row <= selectBottom; ++row)
|
||||||
|
{
|
||||||
|
if (t.isKeyFrame(row)) t.deleteKeyFrame(row);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
invalidateRange(selectLeft, selectRight, selectTop, selectBottom);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void TrackView::paste()
|
||||||
|
{
|
||||||
|
int selectLeft = min(selectStartTrack, selectStopTrack);
|
||||||
|
int selectRight = max(selectStartTrack, selectStopTrack);
|
||||||
|
int selectTop = min(selectStartRow, selectStopRow);
|
||||||
|
int selectBottom = max(selectStartRow, selectStopRow);
|
||||||
|
}
|
||||||
|
|
||||||
void TrackView::setupScrollBars()
|
void TrackView::setupScrollBars()
|
||||||
{
|
{
|
||||||
SCROLLINFO si = { sizeof(si) };
|
SCROLLINFO si = { sizeof(si) };
|
||||||
@ -518,10 +614,13 @@ LRESULT TrackView::onKeyDown(UINT keyCode, UINT flags)
|
|||||||
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);
|
||||||
selectStartTrack = selectStopTrack = editTrack;
|
if (!selectActive)
|
||||||
selectStartRow = selectStopRow = editRow;
|
{
|
||||||
selectActive = true;
|
selectStartTrack = selectStopTrack = editTrack;
|
||||||
|
selectStartRow = selectStopRow = editRow;
|
||||||
|
selectActive = true;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// simulate keyboard accelerators
|
// simulate keyboard accelerators
|
||||||
@ -529,10 +628,10 @@ LRESULT TrackView::onKeyDown(UINT keyCode, UINT flags)
|
|||||||
if (ctrlDown) SendMessage(GetParent(this->getWin()), WM_COMMAND, MAKEWPARAM(shiftDown ? WM_REDO : WM_UNDO, 1), 0);
|
if (ctrlDown) SendMessage(GetParent(this->getWin()), WM_COMMAND, MAKEWPARAM(shiftDown ? WM_REDO : WM_UNDO, 1), 0);
|
||||||
break;
|
break;
|
||||||
case 'C':
|
case 'C':
|
||||||
if (ctrlDown && !altDown && !shiftDown)
|
/* if (ctrlDown && !altDown && !shiftDown)
|
||||||
{
|
{
|
||||||
SendMessage(GetParent(this->getWin()), WM_COMMAND, MAKEWPARAM(WM_COPY, 1), 0);
|
SendMessage(GetParent(this->getWin()), WM_COMMAND, MAKEWPARAM(WM_COPY, 1), 0);
|
||||||
}
|
} */
|
||||||
// printf("hit '%c', flags: %X\n", keyCode, flags);
|
// printf("hit '%c', flags: %X\n", keyCode, flags);
|
||||||
// if (ctrlDown) SendMessage(GetParent(this->getWin()), WM_COMMAND, MAKEWPARAM(shiftDown ? WM_REDO : WM_UNDO, 1), 0);
|
// if (ctrlDown) SendMessage(GetParent(this->getWin()), WM_COMMAND, MAKEWPARAM(shiftDown ? WM_REDO : WM_UNDO, 1), 0);
|
||||||
break;
|
break;
|
||||||
@ -668,40 +767,9 @@ LRESULT TrackView::windowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|||||||
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:
|
case WM_COPY: copy(); break;
|
||||||
{
|
case WM_CUT: cut(); break;
|
||||||
int selectLeft = min(selectStartTrack, selectStopTrack);
|
case WM_PASTE: paste(); break;
|
||||||
int selectRight = max(selectStartTrack, selectStopTrack);
|
|
||||||
int selectTop = min(selectStartRow, selectStopRow);
|
|
||||||
int selectBottom = max(selectStartRow, selectStopRow);
|
|
||||||
printf("copying:\n");
|
|
||||||
|
|
||||||
struct CopyEntry
|
|
||||||
{
|
|
||||||
int track, row;
|
|
||||||
float val;
|
|
||||||
bool valExisting;
|
|
||||||
};
|
|
||||||
|
|
||||||
// std::vector<CopyEntry> copyBuffer;
|
|
||||||
if (FAILED(OpenClipboard(getWin())))
|
|
||||||
{
|
|
||||||
MessageBox(NULL, "Failed to open clipboard", NULL, MB_OK);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
EmptyClipboard();
|
|
||||||
for (int track = selectLeft; track <= selectRight; ++track)
|
|
||||||
{
|
|
||||||
for (int row = selectTop; row <= selectBottom; ++row)
|
|
||||||
{
|
|
||||||
printf("(%d %d) = ", track, row);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
CloseClipboard();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WM_UNDO:
|
case WM_UNDO:
|
||||||
if (!syncDataEdit.undo()) MessageBeep(0);
|
if (!syncDataEdit.undo()) MessageBeep(0);
|
||||||
|
|||||||
@ -137,6 +137,10 @@ private:
|
|||||||
LRESULT onKeyDown(UINT keyCode, UINT flags);
|
LRESULT onKeyDown(UINT keyCode, UINT flags);
|
||||||
LRESULT onChar(UINT keyCode, UINT flags);
|
LRESULT onChar(UINT keyCode, UINT flags);
|
||||||
|
|
||||||
|
void copy();
|
||||||
|
void cut();
|
||||||
|
void paste();
|
||||||
|
|
||||||
// the window procedure
|
// the window procedure
|
||||||
|
|
||||||
void paintTracks(HDC hdc, RECT rcTracks);
|
void paintTracks(HDC hdc, RECT rcTracks);
|
||||||
@ -228,6 +232,8 @@ private:
|
|||||||
|
|
||||||
HWND hwnd;
|
HWND hwnd;
|
||||||
HBRUSH editBrush;
|
HBRUSH editBrush;
|
||||||
|
|
||||||
|
UINT clipboardFormat;
|
||||||
};
|
};
|
||||||
|
|
||||||
ATOM registerTrackViewWindowClass(HINSTANCE hInstance);
|
ATOM registerTrackViewWindowClass(HINSTANCE hInstance);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user