当前位置: 首页>>代码示例>>C++>>正文


C++ SyncDocument类代码示例

本文整理汇总了C++中SyncDocument的典型用法代码示例。如果您正苦于以下问题:C++ SyncDocument类的具体用法?C++ SyncDocument怎么用?C++ SyncDocument使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了SyncDocument类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getDocument

void TrackView::editBiasValue(float amount)
{
	SyncDocument *doc = getDocument();

	if (0 == getTrackCount()) {
		QApplication::beep();
		return;
	}

	QRect selection = getSelection();

	doc->beginMacro("bias");
	for (int track = selection.left(); track <= selection.right(); ++track) {
		Q_ASSERT(track < getTrackCount());
		SyncTrack *t = getTrack(track);

		for (int row = selection.top(); row <= selection.bottom(); ++row) {
			if (t->isKeyFrame(row)) {
				SyncTrack::TrackKey k = t->getKeyFrame(row); // copy old key
				k.value += amount; // modify value

				// add sub-command
				doc->setKeyFrame(t, k);
			}
		}
	}
	doc->endMacro();

	dirtyCurrentValue();
}
开发者ID:kusma,项目名称:rocket,代码行数:30,代码来源:trackview.cpp

示例2: getDocument

void TrackView::editToggleInterpolationType()
{
	SyncDocument *doc = getDocument();
	if (NULL == doc) return;
	
	if (editTrack < int(getTrackCount())) {
		size_t trackIndex = doc->getTrackIndexFromPos(editTrack);
		const sync_track *t = doc->tracks[trackIndex];

		int idx = key_idx_floor(t, editRow);
		if (idx < 0) {
			MessageBeep(~0U);
			return;
		}

		// copy and modify
		track_key newKey = t->keys[idx];
		newKey.type = (enum key_type)
		    ((newKey.type + 1) % KEY_TYPE_COUNT);

		// apply change to data-set
		SyncDocument::Command *cmd = doc->getSetKeyFrameCommand(int(trackIndex), newKey);
		doc->exec(cmd);

		// update user interface
		SendMessage(GetParent(getWin()), WM_CURRVALDIRTY, 0, 0);
		InvalidateRect(getWin(), NULL, FALSE);
	}
	else
		MessageBeep(~0U);
}
开发者ID:henrikno,项目名称:rocket,代码行数:31,代码来源:trackview.cpp

示例3: processCommand

static void processCommand(ClientSocket &sock)
{
	SyncDocument *doc = trackView->getDocument();
	int strLen, serverIndex, newRow;
	std::string trackName;
	const sync_track *t;
	unsigned char cmd = 0;
	if (sock.recv((char*)&cmd, 1)) {
		switch (cmd) {
		case GET_TRACK:
			// read data
			sock.recv((char *)&strLen, sizeof(int));
			strLen = ntohl(strLen);
			if (!sock.connected())
				return;

			if (!strLen) {
				sock.disconnect();
				InvalidateRect(trackViewWin, NULL, FALSE);
				return;
			}

			trackName.resize(strLen);
			if (!sock.recv(&trackName[0], strLen))
				return;

			if (int(strlen(trackName.c_str())) != strLen) {
				sock.disconnect();
				InvalidateRect(trackViewWin, NULL, FALSE);
				return;
			}

			// find track
			serverIndex = sync_find_track(doc,
			    trackName.c_str());
			if (0 > serverIndex)
				serverIndex =
				    int(doc->createTrack(trackName));

			// setup remap
			doc->clientSocket.clientTracks[trackName] = clientIndex++;

			// send key-frames
			t = doc->tracks[serverIndex];
			for (int i = 0; i < (int)t->num_keys; ++i)
				doc->clientSocket.sendSetKeyCommand(trackName,
				    t->keys[i]);

			InvalidateRect(trackViewWin, NULL, FALSE);
			break;

		case SET_ROW:
			sock.recv((char*)&newRow, sizeof(int));
			trackView->setEditRow(ntohl(newRow));
			break;
		}
	}
}
开发者ID:Web5design,项目名称:rocket,代码行数:58,代码来源:editor.cpp

示例4: attemptQuit

static void attemptQuit()
{
	SyncDocument *doc = trackView->getDocument();
	if (doc->modified()) {
		UINT res = MessageBox(hwnd, "Save before exit?", mainWindowTitle, MB_YESNOCANCEL | MB_ICONQUESTION);
		if ((IDYES == res && fileSave()) || (IDNO == res))
			DestroyWindow(hwnd);
	}
	else DestroyWindow(hwnd);
}
开发者ID:Web5design,项目名称:rocket,代码行数:10,代码来源:editor.cpp

示例5: fileSave

static bool fileSave()
{
	SyncDocument *doc = trackView->getDocument();
	if (doc->fileName.empty())
		return fileSaveAs();

	if (!doc->save(doc->fileName)) {
		doc->clientSocket.sendSaveCommand();
		error("Failed to save file");
		return false;
	}
	return true;
}
开发者ID:Web5design,项目名称:rocket,代码行数:13,代码来源:editor.cpp

示例6: fileNew

void fileNew()
{
	// document.purgeUnusedTracks();
	SyncDocument::MultiCommand *multiCmd = new SyncDocument::MultiCommand();
	for (size_t i = 0; i < document.num_tracks; ++i) {
		sync_track *t = document.tracks[i];
		for (size_t j = 0; j < t->num_keys; ++j)
			multiCmd->addCommand(new SyncDocument::DeleteCommand(i, t->keys[j].row));
	}
	document.exec(multiCmd);

	setWindowFileName(L"Untitled");
	fileName.clear();

	document.clearUndoStack();
	document.clearRedoStack();
}
开发者ID:visualizersdotnl,项目名称:hot-stuff-src,代码行数:17,代码来源:editor.cpp

示例7: file

SyncDocument *SyncDocument::load(const QString &fileName)
{
	SyncDocument *ret = new SyncDocument;
	ret->fileName = fileName;

	QFile file(fileName);
	if (!file.open(QIODevice::ReadOnly)) {
		QMessageBox::critical(NULL, "Error", file.errorString());
		return NULL;
	}

	QDomDocument doc;
	QString err;
	if (!doc.setContent(&file, &err)) {
		file.close();
		QMessageBox::critical(NULL, "Error", err);
		return NULL;
	}
	file.close();

	QDomNamedNodeMap attribs = doc.documentElement().attributes();
	QDomNode rowsParam = attribs.namedItem("rows");
	if (!rowsParam.isNull()) {
		QString rowsString = rowsParam.nodeValue();
		ret->setRows(rowsString.toInt());
	}

	QDomNodeList trackNodes =
	    doc.documentElement().elementsByTagName("track");
	for (int i = 0; i < int(trackNodes.length()); ++i) {
		QDomNode trackNode = trackNodes.item(i);
		QDomNamedNodeMap attribs = trackNode.attributes();

		QString name = attribs.namedItem("name").nodeValue();

		// look up track-name, create it if it doesn't exist
		SyncTrack *t = ret->findTrack(name.toUtf8());
		if (!t)
			t = ret->createTrack(name.toUtf8().constData());

		QDomNodeList rowNodes = trackNode.childNodes();
		for (int i = 0; i < int(rowNodes.length()); ++i) {
			QDomNode keyNode = rowNodes.item(i);
			QString baseName = keyNode.nodeName();
			if (baseName == "key") {
				QDomNamedNodeMap rowAttribs = keyNode.attributes();
				QString rowString = rowAttribs.namedItem("row").nodeValue();
				QString valueString = rowAttribs.namedItem("value").nodeValue();
				QString interpolationString = rowAttribs.namedItem("interpolation").nodeValue();

				SyncTrack::TrackKey k;
				k.row = rowString.toInt();
				k.value = valueString.toFloat();
				k.type = SyncTrack::TrackKey::KeyType(interpolationString.toInt());

				Q_ASSERT(!t->isKeyFrame(k.row));
				t->setKey(k);
			}
		}
	}

	// YUCK: gathers from entire document
	QDomNodeList bookmarkNodes =
	    doc.documentElement().elementsByTagName("bookmark");
	for (int i = 0; i < int(bookmarkNodes.length()); ++i) {
		QDomNode bookmarkNode =
		    bookmarkNodes.item(i);
		QDomNamedNodeMap bookmarkAttribs =
		    bookmarkNode.attributes();
		QString str =
		    bookmarkAttribs.namedItem("row").nodeValue();
		int row = str.toInt();
		ret->toggleRowBookmark(row);
	}

	return ret;
}
开发者ID:yonglehou,项目名称:rocket-1,代码行数:77,代码来源:syncdocument.cpp

示例8: fileSaveAs

bool fileSaveAs()
{
	wchar_t temp[_MAX_FNAME + 1];
	temp[0] = '\0';
	
	OPENFILENAMEW ofn;
	ZeroMemory(&ofn, sizeof(ofn));
	ofn.lStructSize = sizeof(ofn);
	ofn.lpstrFile = temp;
	ofn.nMaxFile = _MAX_FNAME;
	ofn.lpstrDefExt = L"rocket";
	ofn.lpstrFilter = L"ROCKET File (*.rocket)\0*.rocket\0All Files (*.*)\0*.*\0\0";
	ofn.Flags = OFN_SHOWHELP | OFN_OVERWRITEPROMPT;
	
	if (GetSaveFileNameW(&ofn)) {
		if (document.save(temp)) {
			document.sendSaveCommand();
			setWindowFileName(temp);
			fileName = temp;
			
			mruFileList.insert(temp);
			mruFileList.update();
			DrawMenuBar(hwnd);
			return true;
		} else
			error("Failed to save file");
	}
	return false;
}
开发者ID:visualizersdotnl,项目名称:hot-stuff-src,代码行数:29,代码来源:editor.cpp

示例9: fileSave

bool fileSave()
{
	if (fileName.empty())
		return fileSaveAs();

	if (!document.save(fileName.c_str())) {
		document.sendSaveCommand();
		error("Failed to save file");
		return false;
	}
	return true;
}
开发者ID:visualizersdotnl,项目名称:hot-stuff-src,代码行数:12,代码来源:editor.cpp

示例10: processCommand

void processCommand(NetworkSocket &sock)
{
	size_t clientIndex = 0;
	int strLen, serverIndex, newRow;
	std::string trackName;
	const sync_track *t;
	unsigned char cmd = 0;
	if (sock.recv((char*)&cmd, 1, 0)) {
		switch (cmd) {
		case GET_TRACK:
			// read data
			sock.recv((char *)&clientIndex, sizeof(int), 0);
			sock.recv((char *)&strLen, sizeof(int), 0);
			clientIndex = ntohl(clientIndex);
			strLen = ntohl(strLen);
			if (!sock.connected())
				return;

			trackName.resize(strLen);
			if (!sock.recv(&trackName[0], strLen, 0))
				return;

			// find track
			serverIndex = sync_find_track(&document,
			    trackName.c_str());
			if (0 > serverIndex)
				serverIndex =
				    int(document.createTrack(trackName));

			// setup remap
			document.clientRemap[serverIndex] = clientIndex;

			// send key-frames
			t = document.tracks[serverIndex];
			for (int i = 0; i < (int)t->num_keys; ++i)
				document.sendSetKeyCommand(int(serverIndex),
				    t->keys[i]);

			InvalidateRect(trackViewWin, NULL, FALSE);
			break;

		case SET_ROW:
			sock.recv((char*)&newRow, sizeof(int), 0);
			trackView->setEditRow(ntohl(newRow));
			break;
		}
	}
}
开发者ID:visualizersdotnl,项目名称:hot-stuff-src,代码行数:48,代码来源:editor.cpp

示例11: attemptQuit

void attemptQuit()
{
	if (document.modified())
	{
		UINT res = MessageBox(hwnd, "Save before exit?", mainWindowTitle, MB_YESNOCANCEL | MB_ICONQUESTION);
		if ((IDYES == res && fileSave()) || (IDNO == res))
			DestroyWindow(hwnd);
	}
	else DestroyWindow(hwnd);
}
开发者ID:visualizersdotnl,项目名称:hot-stuff-src,代码行数:10,代码来源:editor.cpp

示例12: loadDocument

void loadDocument(const std::wstring &_fileName)
{
	fileNew();
	if (document.load(_fileName))
	{
		setWindowFileName(_fileName.c_str());
		fileName = _fileName;
		
		mruFileList.insert(_fileName);
		mruFileList.update();
		DrawMenuBar(hwnd);
		
		document.clearUndoStack();
		document.clearRedoStack();
		trackView->setDocument(&document);

		SendMessage(hwnd, WM_CURRVALDIRTY, 0, 0);
		InvalidateRect(trackViewWin, NULL, FALSE);
	}
	else
		error("failed to open file");
}
开发者ID:visualizersdotnl,项目名称:hot-stuff-src,代码行数:22,代码来源:editor.cpp

示例13: WinMain

int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/,
    LPSTR /*lpCmdLine*/, int /*nShowCmd*/)
{
#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(254);
#endif
	
	hInst = hInstance;
	CoInitialize(NULL);

	WSADATA wsa;
	if (0 != WSAStartup(MAKEWORD(2, 0), &wsa))
		die("Failed to init network");

	SOCKET serverSocket = socket(AF_INET, SOCK_STREAM, 0);

	struct sockaddr_in sin;
	memset(&sin, 0, sizeof sin);

	sin.sin_family = AF_INET;
	sin.sin_addr.s_addr = INADDR_ANY;
	sin.sin_port = htons(1338);

	if (SOCKET_ERROR == bind(serverSocket, (struct sockaddr *)&sin,
	    sizeof(sin)))
		die("Could not start server");

	while (listen(serverSocket, SOMAXCONN) == SOCKET_ERROR)
		; /* nothing */

	ATOM mainClass      = registerMainWindowClass(hInstance);
	ATOM trackViewClass = registerTrackViewWindowClass(hInstance);
	if (!mainClass || !trackViewClass)
		die("Window Registration Failed!");

	trackView = new TrackView();
	trackView->setDocument(&document);
	
	hwnd = CreateWindowExW(
		0,
		mainWindowClassName,
		mainWindowTitleW,
		WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
		CW_USEDEFAULT, CW_USEDEFAULT, // x, y
		CW_USEDEFAULT, CW_USEDEFAULT, // width, height
		NULL, NULL, hInstance, NULL
	);

	if (NULL == hwnd)
		die("Window Creation Failed!");

	fileNew();
	
	HACCEL accel = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDR_ACCELERATOR));
	
	ShowWindow(hwnd, TRUE);
	UpdateWindow(hwnd);
	
	bool done = false;
	MSG msg;
	bool guiConnected = false;
	while (!done)
	{
		if (!document.clientSocket.connected())
		{
			SOCKET clientSocket = INVALID_SOCKET;
			fd_set fds;
			FD_ZERO(&fds);
#pragma warning(suppress: 4127)
			FD_SET(serverSocket, &fds);
			struct timeval timeout;
			timeout.tv_sec = 0;
			timeout.tv_usec = 0;
			
			// look for new clients
			if (select(0, &fds, NULL, NULL, &timeout) > 0)
			{
				SendMessage(statusBarWin, SB_SETTEXT, 0, (LPARAM)"Accepting...");
				sockaddr_in client;
				clientSocket = clientConnect(serverSocket, &client);
				if (INVALID_SOCKET != clientSocket)
				{
					char temp[256];
					snprintf(temp, 256, "Connected to %s", inet_ntoa(client.sin_addr));
					SendMessage(statusBarWin, SB_SETTEXT, 0, (LPARAM)temp);
					document.clientSocket = NetworkSocket(clientSocket);
					document.clientRemap.clear();
					document.sendPauseCommand(true);
					document.sendSetRowCommand(trackView->getEditRow());
					guiConnected = true;
				}
				else SendMessage(statusBarWin, SB_SETTEXT, 0, (LPARAM)"Not Connected.");
			}
		}
		
		if (document.clientSocket.connected())
//.........这里部分代码省略.........
开发者ID:visualizersdotnl,项目名称:hot-stuff-src,代码行数:101,代码来源:editor.cpp

示例14: DefWindowProcW

static LRESULT CALLBACK mainWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	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:
			document.sendSaveCommand();
			break;
		
		case ID_RECENTFILES_FILE1:
		case ID_RECENTFILES_FILE2:
		case ID_RECENTFILES_FILE3:
		case ID_RECENTFILES_FILE4:
		case ID_RECENTFILES_FILE5:
//.........这里部分代码省略.........
开发者ID:visualizersdotnl,项目名称:hot-stuff-src,代码行数:101,代码来源:editor.cpp


注:本文中的SyncDocument类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。