Example #1
0
void TrackView::editPreviousBookmark()
{
	SyncDocument *doc = getDocument();

	int row = doc->prevRowBookmark(getEditRow());
	if (row >= 0)
		setEditRow(row, false);
}
Example #2
0
static LRESULT CALLBACK mainWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	SyncDocument *doc = trackView ? trackView->getDocument() : NULL;
	switch(msg)
	{
	case WM_CREATE:
		{
			trackViewWin = trackView->create(hInst, hwnd);
			InitCommonControls();
			statusBarWin = createStatusBar(hInst, hwnd);

			if (ERROR_SUCCESS != RegOpenKey(HKEY_CURRENT_USER, keyName, &regConfigKey))
			{
				if (ERROR_SUCCESS != RegCreateKey(HKEY_CURRENT_USER, keyName, &regConfigKey))
					die("failed to create registry key");
			}
			
			/* Recent Files menu */
			mruFileList = RecentFiles(findSubMenuContaining(GetMenu(hwnd), ID_RECENTFILES_NORECENTFILES));
			mruFileList.load(regConfigKey);
		}
		break;
	
	case WM_CLOSE:
		attemptQuit();
		break;
	
	case WM_DESTROY:
		mruFileList.save(regConfigKey);
		RegCloseKey(regConfigKey);
		regConfigKey = NULL;
		PostQuitMessage(0);
		break;
	
	case WM_SIZE:
		{
			int width  = LOWORD(lParam);
			int height = HIWORD(lParam);
			
			RECT statusBarRect;
			GetClientRect(statusBarWin, &statusBarRect);
			int statusBarHeight = statusBarRect.bottom - statusBarRect.top;
			
			MoveWindow(trackViewWin, 0, 0, width, height - statusBarHeight, TRUE);
			MoveWindow(statusBarWin, 0, height - statusBarHeight, width, statusBarHeight, TRUE);
		}
		break;
	
	case WM_SETFOCUS:
		SetFocus(trackViewWin); // needed to forward keyboard input
		break;
	
	case WM_SETROWS:
		trackView->setRows(int(lParam));
		break;
	
	case WM_BIASSELECTION:
		trackView->editBiasValue(float(lParam));
		break;
	
	case WM_COMMAND:
		switch (LOWORD(wParam))
		{
		case ID_FILE_NEW:
			fileNew();
			InvalidateRect(trackViewWin, NULL, FALSE);
			break;
			
		case ID_FILE_OPEN:
			fileOpen();
			break;
		
		case ID_FILE_SAVE_AS:
			fileSaveAs();
			break;
		
		case ID_FILE_SAVE:
			fileSave();
			break;
		
		case ID_EDIT_SELECTALL:
			trackView->selectAll();
			break;
		
		case ID_EDIT_SELECTTRACK:
			trackView->selectTrack(trackView->getEditTrack());
			break;
		
		case ID_EDIT_SELECTROW:
			trackView->selectRow(trackView->getEditRow());
			break;
		
		case ID_FILE_REMOTEEXPORT:
			doc->clientSocket.sendSaveCommand();
			break;
		
		case ID_RECENTFILES_FILE1:
		case ID_RECENTFILES_FILE2:
		case ID_RECENTFILES_FILE3:
		case ID_RECENTFILES_FILE4:
		case ID_RECENTFILES_FILE5:
			{
				int index = LOWORD(wParam) - ID_RECENTFILES_FILE1;
				std::wstring fileName;
				if (mruFileList.getEntry(index, fileName))
				{
					loadDocument(fileName);
				}
			}
			break;
		
		case ID_FILE_EXIT:
			attemptQuit();
			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_BOOKMARK_PREV:
			{
				int row = doc->prevRowBookmark(trackView->getEditRow());
				if (row >= 0)
					trackView->setEditRow(row);
			}
			break;

		case ID_EDIT_BOOKMARK_NEXT:
			{
				int row = doc->nextRowBookmark(trackView->getEditRow());
				if (row >= 0)
					trackView->setEditRow(row);
			}
			break;


		case ID_EDIT_SETROWS:
			{
				size_t rows = trackView->getRows();
				INT_PTR result = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_SETROWS), hwnd, (DLGPROC)setRowsDialogProc, (LPARAM)&rows);
				if (FAILED(result))
					error("unable to create dialog box");
			}
			break;
		
		case ID_EDIT_BIAS:
			{
				int initialBias = 0;
				INT_PTR result = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_BIASSELECTION), hwnd, (DLGPROC)biasSelectionDialogProc, (LPARAM)&initialBias);
				if (FAILED(result))
					error("unable to create dialog box");
			}
			break;
		}
		break;
	
	case WM_ROWCHANGED:
		{
			char temp[256];
			snprintf(temp, 256, "%d", lParam );
			SendMessage(statusBarWin, SB_SETTEXT, 1, (LPARAM)temp);
		}
		break;
	
	case WM_TRACKCHANGED:
		{
			char temp[256];
			snprintf(temp, 256, "%d", lParam);
			SendMessage(statusBarWin, SB_SETTEXT, 2, (LPARAM)temp);
		}
		break;
	
	case WM_CURRVALDIRTY:
		{
			char temp[256];
			if (doc->num_tracks > 0) {
				const sync_track *t = doc->tracks[doc->getTrackIndexFromPos(trackView->getEditTrack())];
				int row = trackView->getEditRow();
				int idx = key_idx_floor(t, row);
				snprintf(temp, 256, "%f", sync_get_val(t, row));
				const char *str = "---";
				if (idx >= 0) {
					switch (t->keys[idx].type) {
					case KEY_STEP:   str = "step"; break;
					case KEY_LINEAR: str = "linear"; break;
					case KEY_SMOOTH: str = "smooth"; break;
					case KEY_RAMP:   str = "ramp"; break;
					}
				}
				SendMessage(statusBarWin, SB_SETTEXT, 4, (LPARAM)str);
			} else
				snprintf(temp, 256, "---");
			SendMessage(statusBarWin, SB_SETTEXT, 3, (LPARAM)temp);
		}
		break;
	
	default:
		return DefWindowProcW(hwnd, msg, wParam, lParam);
	}
	return 0;
}