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;
}
Example #2
0
static void loadDocument(const std::wstring &_fileName)
{
	SyncDocument *newDoc = SyncDocument::load(_fileName);
	if (newDoc) {
		// update MRU list
		mruFileList.insert(_fileName);
		mruFileList.update();
		DrawMenuBar(hwnd);

		// set new document
		setDocument(newDoc);
		setWindowFileName(_fileName.c_str());
	}
	else
		error("failed to open file");
}
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();
}
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");
}
Example #5
0
static void fileNew()
{
	setDocument(new SyncDocument);
	setWindowFileName(L"Untitled");
}