editor: get rid of some TCHARism
We dont need unicode everywhere. TCHARism is just noise.
This commit is contained in:
parent
7934871684
commit
06c75438cf
@ -24,9 +24,9 @@
|
|||||||
#include "recentfiles.h"
|
#include "recentfiles.h"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
const TCHAR *mainWindowClassName = _T("MainWindow");
|
const char *mainWindowClassName = "MainWindow";
|
||||||
const TCHAR *mainWindowTitle = _T("GNU Rocket System");
|
const char *mainWindowTitle = "GNU Rocket System";
|
||||||
const TCHAR *keyName = _T("SOFTWARE\\GNU Rocket");
|
const char *keyName = "SOFTWARE\\GNU Rocket";
|
||||||
|
|
||||||
HWND hwnd = NULL;
|
HWND hwnd = NULL;
|
||||||
TrackView *trackView = NULL;
|
TrackView *trackView = NULL;
|
||||||
@ -51,8 +51,8 @@ static LRESULT CALLBACK setRowsDialogProc(HWND hDlg, UINT message, WPARAM wParam
|
|||||||
assert(NULL != rows);
|
assert(NULL != rows);
|
||||||
|
|
||||||
/* create row-string */
|
/* create row-string */
|
||||||
TCHAR temp[256];
|
char temp[256];
|
||||||
_sntprintf_s(temp, 256, _T("%d"), *rows);
|
_snprintf_s(temp, 256, "%d", *rows);
|
||||||
|
|
||||||
/* set initial row count */
|
/* set initial row count */
|
||||||
SetDlgItemText(hDlg, IDC_SETROWS_EDIT, temp);
|
SetDlgItemText(hDlg, IDC_SETROWS_EDIT, temp);
|
||||||
@ -64,9 +64,9 @@ static LRESULT CALLBACK setRowsDialogProc(HWND hDlg, UINT message, WPARAM wParam
|
|||||||
if (LOWORD(wParam) == IDOK)
|
if (LOWORD(wParam) == IDOK)
|
||||||
{
|
{
|
||||||
/* get value */
|
/* get value */
|
||||||
TCHAR temp[256];
|
char temp[256];
|
||||||
GetDlgItemText(hDlg, IDC_SETROWS_EDIT, temp, 256);
|
GetDlgItemText(hDlg, IDC_SETROWS_EDIT, temp, 256);
|
||||||
int result = _tstoi(temp);
|
int result = atoi(temp);
|
||||||
|
|
||||||
/* update editor */
|
/* update editor */
|
||||||
SendMessage(GetParent(hDlg), WM_SETROWS, 0, result);
|
SendMessage(GetParent(hDlg), WM_SETROWS, 0, result);
|
||||||
@ -100,8 +100,8 @@ static LRESULT CALLBACK biasSelectionDialogProc(HWND hDlg, UINT message, WPARAM
|
|||||||
assert(NULL != intialBias);
|
assert(NULL != intialBias);
|
||||||
|
|
||||||
/* create bias-string */
|
/* create bias-string */
|
||||||
TCHAR temp[256];
|
char temp[256];
|
||||||
_sntprintf_s(temp, 256, _T("%d"), *intialBias);
|
_snprintf(temp, 256, "%d", *intialBias);
|
||||||
|
|
||||||
/* set initial bias */
|
/* set initial bias */
|
||||||
SetDlgItemText(hDlg, IDC_SETROWS_EDIT, temp);
|
SetDlgItemText(hDlg, IDC_SETROWS_EDIT, temp);
|
||||||
@ -112,9 +112,9 @@ static LRESULT CALLBACK biasSelectionDialogProc(HWND hDlg, UINT message, WPARAM
|
|||||||
if (LOWORD(wParam) == IDOK)
|
if (LOWORD(wParam) == IDOK)
|
||||||
{
|
{
|
||||||
/* get value */
|
/* get value */
|
||||||
TCHAR temp[256];
|
char temp[256];
|
||||||
GetDlgItemText(hDlg, IDC_BIASSELECTION_EDIT, temp, 256);
|
GetDlgItemText(hDlg, IDC_BIASSELECTION_EDIT, temp, 256);
|
||||||
int bias = _tstoi(temp);
|
int bias = atoi(temp);
|
||||||
|
|
||||||
/* update editor */
|
/* update editor */
|
||||||
SendMessage(GetParent(hDlg), WM_BIASSELECTION, 0, LPARAM(bias));
|
SendMessage(GetParent(hDlg), WM_BIASSELECTION, 0, LPARAM(bias));
|
||||||
@ -139,8 +139,8 @@ static LRESULT CALLBACK biasSelectionDialogProc(HWND hDlg, UINT message, WPARAM
|
|||||||
|
|
||||||
void setWindowFileName(std::string fileName)
|
void setWindowFileName(std::string fileName)
|
||||||
{
|
{
|
||||||
TCHAR drive[_MAX_DRIVE],dir[_MAX_DIR],fname[_MAX_FNAME],ext[_MAX_EXT];
|
char drive[_MAX_DRIVE],dir[_MAX_DIR],fname[_MAX_FNAME],ext[_MAX_EXT];
|
||||||
_tsplitpath(fileName.c_str(), drive, dir, fname, ext);
|
_splitpath(fileName.c_str(), drive, dir, fname, ext);
|
||||||
std::string windowTitle = std::string(fname) + std::string(" - ") + std::string(mainWindowTitle);
|
std::string windowTitle = std::string(fname) + std::string(" - ") + std::string(mainWindowTitle);
|
||||||
SetWindowText(hwnd, windowTitle.c_str());
|
SetWindowText(hwnd, windowTitle.c_str());
|
||||||
}
|
}
|
||||||
@ -201,7 +201,7 @@ void loadDocument(const std::string &_fileName)
|
|||||||
SendMessage(hwnd, WM_CURRVALDIRTY, 0, 0);
|
SendMessage(hwnd, WM_CURRVALDIRTY, 0, 0);
|
||||||
InvalidateRect(trackViewWin, NULL, FALSE);
|
InvalidateRect(trackViewWin, NULL, FALSE);
|
||||||
}
|
}
|
||||||
else MessageBox(hwnd, _T("failed to open file"), mainWindowTitle, MB_OK | MB_ICONERROR | MB_SETFOREGROUND);
|
else MessageBox(hwnd, "failed to open file", mainWindowTitle, MB_OK | MB_ICONERROR | MB_SETFOREGROUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
void fileOpen()
|
void fileOpen()
|
||||||
@ -249,7 +249,7 @@ void fileSaveAs()
|
|||||||
mruFileList.update();
|
mruFileList.update();
|
||||||
DrawMenuBar(hwnd);
|
DrawMenuBar(hwnd);
|
||||||
}
|
}
|
||||||
else MessageBox(hwnd, _T("Failed to save file"), mainWindowTitle, MB_OK | MB_ICONERROR | MB_SETFOREGROUND);
|
else MessageBox(hwnd, "Failed to save file", mainWindowTitle, MB_OK | MB_ICONERROR | MB_SETFOREGROUND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -259,7 +259,7 @@ void fileSave()
|
|||||||
else if (!document.save(fileName.c_str()))
|
else if (!document.save(fileName.c_str()))
|
||||||
{
|
{
|
||||||
document.sendSaveCommand();
|
document.sendSaveCommand();
|
||||||
MessageBox(hwnd, _T("Failed to save file"), mainWindowTitle, MB_OK | MB_ICONERROR | MB_SETFOREGROUND);
|
MessageBox(hwnd, "Failed to save file", mainWindowTitle, MB_OK | MB_ICONERROR | MB_SETFOREGROUND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -267,7 +267,7 @@ void attemptQuit()
|
|||||||
{
|
{
|
||||||
if (document.modified())
|
if (document.modified())
|
||||||
{
|
{
|
||||||
UINT res = MessageBox(hwnd, _T("Save before exit?"), mainWindowTitle, MB_YESNOCANCEL | MB_ICONQUESTION);
|
UINT res = MessageBox(hwnd, "Save before exit?", mainWindowTitle, MB_YESNOCANCEL | MB_ICONQUESTION);
|
||||||
if (IDYES == res) fileSave();
|
if (IDYES == res) fileSave();
|
||||||
if (IDCANCEL != res) DestroyWindow(hwnd);
|
if (IDCANCEL != res) DestroyWindow(hwnd);
|
||||||
}
|
}
|
||||||
@ -298,10 +298,10 @@ static LRESULT CALLBACK mainWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA
|
|||||||
|
|
||||||
int statwidths[] = { 150, 150 + 32, 150 + 32 * 2, 150 + 32 * 4};
|
int statwidths[] = { 150, 150 + 32, 150 + 32 * 2, 150 + 32 * 4};
|
||||||
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)_T("Not connected"));
|
SendMessage(statusBarWin, SB_SETTEXT, 0, (LPARAM)"Not connected");
|
||||||
SendMessage(statusBarWin, SB_SETTEXT, 1, (LPARAM)_T("0"));
|
SendMessage(statusBarWin, SB_SETTEXT, 1, (LPARAM)"0");
|
||||||
SendMessage(statusBarWin, SB_SETTEXT, 2, (LPARAM)_T("0"));
|
SendMessage(statusBarWin, SB_SETTEXT, 2, (LPARAM)"0");
|
||||||
SendMessage(statusBarWin, SB_SETTEXT, 3, (LPARAM)_T("---"));
|
SendMessage(statusBarWin, SB_SETTEXT, 3, (LPARAM)"---");
|
||||||
|
|
||||||
if (ERROR_SUCCESS != RegOpenKey(HKEY_CURRENT_USER, keyName, ®ConfigKey))
|
if (ERROR_SUCCESS != RegOpenKey(HKEY_CURRENT_USER, keyName, ®ConfigKey))
|
||||||
{
|
{
|
||||||
@ -421,7 +421,7 @@ static LRESULT CALLBACK mainWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA
|
|||||||
HINSTANCE hInstance = GetModuleHandle(NULL);
|
HINSTANCE hInstance = GetModuleHandle(NULL);
|
||||||
int rows = int(trackView->getRows());
|
int rows = int(trackView->getRows());
|
||||||
INT_PTR result = DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_SETROWS), hwnd, (DLGPROC)setRowsDialogProc, (LPARAM)&rows);
|
INT_PTR result = DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_SETROWS), hwnd, (DLGPROC)setRowsDialogProc, (LPARAM)&rows);
|
||||||
if (FAILED(result)) MessageBox(hwnd, _T("unable to create dialog box"), mainWindowTitle, MB_OK | MB_ICONERROR | MB_SETFOREGROUND);
|
if (FAILED(result)) MessageBox(hwnd, "unable to create dialog box", mainWindowTitle, MB_OK | MB_ICONERROR | MB_SETFOREGROUND);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -430,7 +430,7 @@ static LRESULT CALLBACK mainWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA
|
|||||||
HINSTANCE hInstance = GetModuleHandle(NULL);
|
HINSTANCE hInstance = GetModuleHandle(NULL);
|
||||||
int initialBias = 0;
|
int initialBias = 0;
|
||||||
INT_PTR result = DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_BIASSELECTION), hwnd, (DLGPROC)biasSelectionDialogProc, (LPARAM)&initialBias);
|
INT_PTR result = DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_BIASSELECTION), hwnd, (DLGPROC)biasSelectionDialogProc, (LPARAM)&initialBias);
|
||||||
if (FAILED(result)) MessageBox(hwnd, _T("unable to create dialog box"), mainWindowTitle, MB_OK | MB_ICONERROR | MB_SETFOREGROUND);
|
if (FAILED(result)) MessageBox(hwnd, "unable to create dialog box", mainWindowTitle, MB_OK | MB_ICONERROR | MB_SETFOREGROUND);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -438,29 +438,29 @@ static LRESULT CALLBACK mainWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA
|
|||||||
|
|
||||||
case WM_ROWCHANGED:
|
case WM_ROWCHANGED:
|
||||||
{
|
{
|
||||||
TCHAR temp[256];
|
char temp[256];
|
||||||
_sntprintf_s(temp, 256, _T("%d"), lParam );
|
_snprintf_s(temp, 256, "%d", lParam );
|
||||||
SendMessage(statusBarWin, SB_SETTEXT, 1, (LPARAM)temp);
|
SendMessage(statusBarWin, SB_SETTEXT, 1, (LPARAM)temp);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_TRACKCHANGED:
|
case WM_TRACKCHANGED:
|
||||||
{
|
{
|
||||||
TCHAR temp[256];
|
char temp[256];
|
||||||
_sntprintf_s(temp, 256, _T("%d"), lParam);
|
_snprintf_s(temp, 256, "%d", lParam);
|
||||||
SendMessage(statusBarWin, SB_SETTEXT, 2, (LPARAM)temp);
|
SendMessage(statusBarWin, SB_SETTEXT, 2, (LPARAM)temp);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_CURRVALDIRTY:
|
case WM_CURRVALDIRTY:
|
||||||
{
|
{
|
||||||
TCHAR temp[256];
|
char temp[256];
|
||||||
if (document.num_tracks > 0) {
|
if (document.num_tracks > 0) {
|
||||||
sync_track *t = document.tracks[document.getTrackIndexFromPos(trackView->getEditTrack())];
|
sync_track *t = document.tracks[document.getTrackIndexFromPos(trackView->getEditTrack())];
|
||||||
float row = float(trackView->getEditRow());
|
float row = float(trackView->getEditRow());
|
||||||
_sntprintf_s(temp, 256, _T("%f"), sync_get_val(t, row));
|
_snprintf_s(temp, 256, "%f", sync_get_val(t, row));
|
||||||
} else
|
} else
|
||||||
_sntprintf_s(temp, 256, _T("---"));
|
_snprintf_s(temp, 256, "---");
|
||||||
SendMessage(statusBarWin, SB_SETTEXT, 3, (LPARAM)temp);
|
SendMessage(statusBarWin, SB_SETTEXT, 3, (LPARAM)temp);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -530,7 +530,7 @@ SOCKET clientConnect(SOCKET serverSocket, sockaddr_in *host)
|
|||||||
return clientSocket;
|
return clientSocket;
|
||||||
}
|
}
|
||||||
|
|
||||||
int _tmain(int argc, _TCHAR* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
|
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
|
||||||
@ -624,13 +624,13 @@ int _tmain(int argc, _TCHAR* argv[])
|
|||||||
// look for new clients
|
// look for new clients
|
||||||
if (select(0, &fds, NULL, NULL, &timeout) > 0)
|
if (select(0, &fds, NULL, NULL, &timeout) > 0)
|
||||||
{
|
{
|
||||||
SendMessage(statusBarWin, SB_SETTEXT, 0, (LPARAM)_T("Accepting..."));
|
SendMessage(statusBarWin, SB_SETTEXT, 0, (LPARAM)"Accepting...");
|
||||||
sockaddr_in client;
|
sockaddr_in client;
|
||||||
clientSocket = clientConnect(serverSocket, &client);
|
clientSocket = clientConnect(serverSocket, &client);
|
||||||
if (INVALID_SOCKET != clientSocket)
|
if (INVALID_SOCKET != clientSocket)
|
||||||
{
|
{
|
||||||
TCHAR temp[256];
|
char temp[256];
|
||||||
_sntprintf_s(temp, 256, _T("Connected to %s"), inet_ntoa(client.sin_addr));
|
_snprintf_s(temp, 256, "Connected to %s", inet_ntoa(client.sin_addr));
|
||||||
SendMessage(statusBarWin, SB_SETTEXT, 0, (LPARAM)temp);
|
SendMessage(statusBarWin, SB_SETTEXT, 0, (LPARAM)temp);
|
||||||
document.clientSocket = NetworkSocket(clientSocket);
|
document.clientSocket = NetworkSocket(clientSocket);
|
||||||
document.clientRemap.clear();
|
document.clientRemap.clear();
|
||||||
@ -638,7 +638,7 @@ int _tmain(int argc, _TCHAR* argv[])
|
|||||||
document.sendSetRowCommand(trackView->getEditRow());
|
document.sendSetRowCommand(trackView->getEditRow());
|
||||||
guiConnected = true;
|
guiConnected = true;
|
||||||
}
|
}
|
||||||
else SendMessage(statusBarWin, SB_SETTEXT, 0, (LPARAM)_T("Not Connected."));
|
else SendMessage(statusBarWin, SB_SETTEXT, 0, (LPARAM)"Not Connected.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -699,7 +699,7 @@ int _tmain(int argc, _TCHAR* argv[])
|
|||||||
{
|
{
|
||||||
document.clientPaused = true;
|
document.clientPaused = true;
|
||||||
InvalidateRect(trackViewWin, NULL, FALSE);
|
InvalidateRect(trackViewWin, NULL, FALSE);
|
||||||
SendMessage(statusBarWin, SB_SETTEXT, 0, (LPARAM)_T("Not Connected."));
|
SendMessage(statusBarWin, SB_SETTEXT, 0, (LPARAM)"Not Connected.");
|
||||||
guiConnected = false;
|
guiConnected = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -70,10 +70,10 @@ void RecentFiles::update()
|
|||||||
menuEntry += char('1' + i);
|
menuEntry += char('1' + i);
|
||||||
menuEntry += " ";
|
menuEntry += " ";
|
||||||
|
|
||||||
TCHAR path[_MAX_PATH], drive[_MAX_DRIVE], dir[_MAX_DIR], fname[_MAX_FNAME], ext[_MAX_EXT];
|
char path[_MAX_PATH], drive[_MAX_DRIVE], dir[_MAX_DIR], fname[_MAX_FNAME], ext[_MAX_EXT];
|
||||||
_tsplitpath(it->c_str(), drive, dir, fname, ext);
|
_splitpath(it->c_str(), drive, dir, fname, ext);
|
||||||
if (_tcslen(dir) > MAX_DIR_LEN) _tcscpy(dir, _T("\\..."));
|
if (strlen(dir) > MAX_DIR_LEN) strcpy(dir, "\\...");
|
||||||
_tmakepath(path, drive, dir, fname, ext);
|
_makepath(path, drive, dir, fname, ext);
|
||||||
menuEntry += std::string(path);
|
menuEntry += std::string(path);
|
||||||
|
|
||||||
AppendMenu(mruFileMenu, MF_STRING, ID_RECENTFILES_FILE1 + i, menuEntry.c_str());
|
AppendMenu(mruFileMenu, MF_STRING, ID_RECENTFILES_FILE1 + i, menuEntry.c_str());
|
||||||
|
|||||||
@ -11,6 +11,5 @@
|
|||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <tchar.h>
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#define ASSERT(x) assert(x)
|
#define ASSERT(x) assert(x)
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
#include "syncdocument.h"
|
#include "syncdocument.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <tchar.h>
|
|
||||||
|
|
||||||
SyncDocument::~SyncDocument()
|
SyncDocument::~SyncDocument()
|
||||||
{
|
{
|
||||||
@ -81,19 +80,19 @@ bool SyncDocument::save(const std::string &fileName)
|
|||||||
{
|
{
|
||||||
char temp[256];
|
char temp[256];
|
||||||
_variant_t varNodeType((short)MSXML2::NODE_ELEMENT);
|
_variant_t varNodeType((short)MSXML2::NODE_ELEMENT);
|
||||||
MSXML2::IXMLDOMElementPtr rootNode = doc->createElement(_T("tracks"));
|
MSXML2::IXMLDOMElementPtr rootNode = doc->createElement("tracks");
|
||||||
doc->appendChild(rootNode);
|
doc->appendChild(rootNode);
|
||||||
|
|
||||||
_snprintf(temp, 256, "%d", getRows());
|
_snprintf(temp, 256, "%d", getRows());
|
||||||
rootNode->setAttribute(_T("rows"), temp);
|
rootNode->setAttribute("rows", temp);
|
||||||
|
|
||||||
for (size_t i = 0; i < num_tracks; ++i) {
|
for (size_t i = 0; i < num_tracks; ++i) {
|
||||||
const sync_track *t = tracks[i];
|
const sync_track *t = tracks[i];
|
||||||
|
|
||||||
MSXML2::IXMLDOMElementPtr trackElem = doc->createElement(_T("track"));
|
MSXML2::IXMLDOMElementPtr trackElem = doc->createElement("track");
|
||||||
trackElem->setAttribute(_T("name"), t->name);
|
trackElem->setAttribute("name", t->name);
|
||||||
|
|
||||||
rootNode->appendChild(doc->createTextNode(_T("\n\t")));
|
rootNode->appendChild(doc->createTextNode("\n\t"));
|
||||||
rootNode->appendChild(trackElem);
|
rootNode->appendChild(trackElem);
|
||||||
|
|
||||||
for (int i = 0; i < (int)t->num_keys; ++i) {
|
for (int i = 0; i < (int)t->num_keys; ++i) {
|
||||||
@ -101,25 +100,25 @@ bool SyncDocument::save(const std::string &fileName)
|
|||||||
float value = t->keys[i].value;
|
float value = t->keys[i].value;
|
||||||
char interpolationType = char(t->keys[i].type);
|
char interpolationType = char(t->keys[i].type);
|
||||||
|
|
||||||
MSXML2::IXMLDOMElementPtr keyElem = doc->createElement(_T("key"));
|
MSXML2::IXMLDOMElementPtr keyElem = doc->createElement("key");
|
||||||
|
|
||||||
_snprintf(temp, 256, _T("%d"), row);
|
_snprintf(temp, 256, "%d", row);
|
||||||
keyElem->setAttribute(_T("row"), temp);
|
keyElem->setAttribute("row", temp);
|
||||||
|
|
||||||
_snprintf(temp, 256, _T("%f"), value);
|
_snprintf(temp, 256, "%f", value);
|
||||||
keyElem->setAttribute(_T("value"), temp);
|
keyElem->setAttribute("value", temp);
|
||||||
|
|
||||||
_snprintf(temp, 256, _T("%d"), interpolationType);
|
_snprintf(temp, 256, "%d", interpolationType);
|
||||||
keyElem->setAttribute(_T("interpolation"), temp);
|
keyElem->setAttribute("interpolation", temp);
|
||||||
|
|
||||||
trackElem->appendChild(doc->createTextNode(_T("\n\t\t")));
|
trackElem->appendChild(doc->createTextNode("\n\t\t"));
|
||||||
trackElem->appendChild(keyElem);
|
trackElem->appendChild(keyElem);
|
||||||
}
|
}
|
||||||
if (t->num_keys)
|
if (t->num_keys)
|
||||||
trackElem->appendChild(doc->createTextNode(_T("\n\t")));
|
trackElem->appendChild(doc->createTextNode("\n\t"));
|
||||||
}
|
}
|
||||||
if (0 != num_tracks)
|
if (0 != num_tracks)
|
||||||
rootNode->appendChild(doc->createTextNode(_T("\n")));
|
rootNode->appendChild(doc->createTextNode("\n"));
|
||||||
|
|
||||||
doc->save(fileName.c_str());
|
doc->save(fileName.c_str());
|
||||||
|
|
||||||
|
|||||||
@ -74,7 +74,7 @@ public:
|
|||||||
|
|
||||||
~SyncDocument();
|
~SyncDocument();
|
||||||
|
|
||||||
size_t createTrack(const std::basic_string<TCHAR> &name)
|
size_t createTrack(const std::string &name)
|
||||||
{
|
{
|
||||||
size_t index = sync_create_track(this, name.c_str());
|
size_t index = sync_create_track(this, name.c_str());
|
||||||
trackOrder.push_back(index);
|
trackOrder.push_back(index);
|
||||||
|
|||||||
@ -4,16 +4,15 @@
|
|||||||
|
|
||||||
#include "trackview.h"
|
#include "trackview.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <tchar.h>
|
|
||||||
|
|
||||||
static const TCHAR *trackViewWindowClassName = _T("TrackView");
|
static const char *trackViewWindowClassName = "TrackView";
|
||||||
|
|
||||||
static DWORD darken(DWORD col, float amt)
|
static DWORD darken(DWORD col, float amt)
|
||||||
{
|
{
|
||||||
return RGB(GetRValue(col) * amt, GetGValue(col) * amt, GetBValue(col) * amt);
|
return RGB(GetRValue(col) * amt, GetGValue(col) * amt, GetBValue(col) * amt);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int getMaxCharacterWidth(HDC hdc, TCHAR *chars, size_t len)
|
static int getMaxCharacterWidth(HDC hdc, char *chars, size_t len)
|
||||||
{
|
{
|
||||||
int maxDigitWidth = 0;
|
int maxDigitWidth = 0;
|
||||||
for (size_t i = 0; i < len; ++i)
|
for (size_t i = 0; i < len; ++i)
|
||||||
@ -25,9 +24,9 @@ static int getMaxCharacterWidth(HDC hdc, TCHAR *chars, size_t len)
|
|||||||
return maxDigitWidth;
|
return maxDigitWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int getMaxCharacterWidthFromString(HDC hdc, TCHAR *chars)
|
static int getMaxCharacterWidthFromString(HDC hdc, char *chars)
|
||||||
{
|
{
|
||||||
return getMaxCharacterWidth(hdc, chars, _tcslen(chars));
|
return getMaxCharacterWidth(hdc, chars, strlen(chars));
|
||||||
}
|
}
|
||||||
|
|
||||||
TrackView::TrackView()
|
TrackView::TrackView()
|
||||||
@ -60,7 +59,7 @@ TrackView::TrackView()
|
|||||||
|
|
||||||
editBrush = CreateSolidBrush(RGB(255, 255, 0)); // yellow
|
editBrush = CreateSolidBrush(RGB(255, 255, 0)); // yellow
|
||||||
|
|
||||||
clipboardFormat = RegisterClipboardFormat(_T("syncdata"));
|
clipboardFormat = RegisterClipboardFormat("syncdata");
|
||||||
assert(0 != clipboardFormat);
|
assert(0 != clipboardFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,10 +90,10 @@ void TrackView::setFont(HFONT font)
|
|||||||
|
|
||||||
rowHeight = tm.tmHeight + tm.tmExternalLeading;
|
rowHeight = tm.tmHeight + tm.tmExternalLeading;
|
||||||
fontWidth = tm.tmAveCharWidth;
|
fontWidth = tm.tmAveCharWidth;
|
||||||
trackWidth = getMaxCharacterWidthFromString(hdc, _T("0123456789.")) * 16;
|
trackWidth = getMaxCharacterWidthFromString(hdc, "0123456789.") * 16;
|
||||||
|
|
||||||
topMarginHeight = rowHeight + 4;
|
topMarginHeight = rowHeight + 4;
|
||||||
leftMarginWidth = getMaxCharacterWidthFromString(hdc, _T("0123456789abcdefh")) * 8;
|
leftMarginWidth = getMaxCharacterWidthFromString(hdc, "0123456789abcdefh") * 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
int TrackView::getScreenY(int row) const
|
int TrackView::getScreenY(int row) const
|
||||||
@ -195,7 +194,7 @@ void TrackView::paintTracks(HDC hdc, RECT rcTracks)
|
|||||||
const SyncDocument *doc = getDocument();
|
const SyncDocument *doc = getDocument();
|
||||||
if (NULL == doc) return;
|
if (NULL == doc) return;
|
||||||
|
|
||||||
TCHAR temp[256];
|
char temp[256];
|
||||||
|
|
||||||
int firstRow = editRow - windowRows / 2 - 1;
|
int firstRow = editRow - windowRows / 2 - 1;
|
||||||
int lastRow = editRow + windowRows / 2 + 1;
|
int lastRow = editRow + windowRows / 2 + 1;
|
||||||
@ -230,10 +229,10 @@ void TrackView::paintTracks(HDC hdc, RECT rcTracks)
|
|||||||
/* if ((row % 4) == 0) SetTextColor(hdc, GetSysColor(COLOR_BTNTEXT));
|
/* if ((row % 4) == 0) SetTextColor(hdc, GetSysColor(COLOR_BTNTEXT));
|
||||||
else SetTextColor(hdc, GetSysColor(COLOR_GRAYTEXT)); */
|
else SetTextColor(hdc, GetSysColor(COLOR_GRAYTEXT)); */
|
||||||
|
|
||||||
_sntprintf_s(temp, 256, _T("%0*Xh"), 5, row);
|
_snprintf_s(temp, 256, "%0*Xh", 5, row);
|
||||||
TextOut(hdc,
|
TextOut(hdc,
|
||||||
leftMargin.left, leftMargin.top,
|
leftMargin.left, leftMargin.top,
|
||||||
temp, int(_tcslen(temp))
|
temp, int(strlen(temp))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -310,19 +309,19 @@ void TrackView::paintTracks(HDC hdc, RECT rcTracks)
|
|||||||
}
|
}
|
||||||
/* format the text */
|
/* format the text */
|
||||||
if (drawEditString)
|
if (drawEditString)
|
||||||
_sntprintf_s(temp, 256, editString.c_str());
|
_snprintf_s(temp, 256, editString.c_str());
|
||||||
else if (idx < 0)
|
else if (idx < 0)
|
||||||
_sntprintf_s(temp, 256, _T(" ---"));
|
_snprintf_s(temp, 256, " ---");
|
||||||
else {
|
else {
|
||||||
float val = t->keys[idx].value;
|
float val = t->keys[idx].value;
|
||||||
_sntprintf_s(temp, 256, _T("% .2f"), val);
|
_snprintf_s(temp, 256, "% .2f", val);
|
||||||
}
|
}
|
||||||
|
|
||||||
COLORREF oldCol;
|
COLORREF oldCol;
|
||||||
if (selected) oldCol = SetTextColor(hdc, GetSysColor(COLOR_HIGHLIGHTTEXT));
|
if (selected) oldCol = SetTextColor(hdc, GetSysColor(COLOR_HIGHLIGHTTEXT));
|
||||||
TextOut(hdc,
|
TextOut(hdc,
|
||||||
patternDataRect.left, patternDataRect.top,
|
patternDataRect.left, patternDataRect.top,
|
||||||
temp, int(_tcslen(temp))
|
temp, int(strlen(temp))
|
||||||
);
|
);
|
||||||
if (selected) SetTextColor(hdc, oldCol);
|
if (selected) SetTextColor(hdc, oldCol);
|
||||||
}
|
}
|
||||||
@ -381,7 +380,7 @@ void TrackView::editCopy()
|
|||||||
|
|
||||||
if (FAILED(OpenClipboard(getWin())))
|
if (FAILED(OpenClipboard(getWin())))
|
||||||
{
|
{
|
||||||
MessageBox(NULL, _T("Failed to open clipboard"), NULL, MB_OK);
|
MessageBox(NULL, "Failed to open clipboard", NULL, MB_OK);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -454,7 +453,7 @@ void TrackView::editPaste()
|
|||||||
|
|
||||||
if (FAILED(OpenClipboard(getWin())))
|
if (FAILED(OpenClipboard(getWin())))
|
||||||
{
|
{
|
||||||
MessageBox(NULL, _T("Failed to open clipboard"), NULL, MB_OK);
|
MessageBox(NULL, "Failed to open clipboard", NULL, MB_OK);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -753,7 +752,7 @@ void TrackView::editEnterValue()
|
|||||||
int idx = sync_find_key(t, editRow);
|
int idx = sync_find_key(t, editRow);
|
||||||
if (idx >= 0)
|
if (idx >= 0)
|
||||||
newKey = t->keys[idx]; // copy old key
|
newKey = t->keys[idx]; // copy old key
|
||||||
newKey.value = float(_tstof(editString.c_str())); // modify value
|
newKey.value = float(atof(editString.c_str())); // modify value
|
||||||
editString.clear();
|
editString.clear();
|
||||||
|
|
||||||
SyncDocument::Command *cmd = doc->getSetKeyFrameCommand(int(trackIndex), newKey);
|
SyncDocument::Command *cmd = doc->getSetKeyFrameCommand(int(trackIndex), newKey);
|
||||||
@ -1197,7 +1196,7 @@ HWND TrackView::create(HINSTANCE hInstance, HWND hwndParent)
|
|||||||
{
|
{
|
||||||
HWND hwnd = CreateWindowEx(
|
HWND hwnd = CreateWindowEx(
|
||||||
WS_EX_CLIENTEDGE,
|
WS_EX_CLIENTEDGE,
|
||||||
trackViewWindowClassName, _T(""),
|
trackViewWindowClassName, "",
|
||||||
WS_VSCROLL | WS_HSCROLL | WS_CHILD | WS_VISIBLE,
|
WS_VSCROLL | WS_HSCROLL | WS_CHILD | WS_VISIBLE,
|
||||||
CW_USEDEFAULT, CW_USEDEFAULT, // x, y
|
CW_USEDEFAULT, CW_USEDEFAULT, // x, y
|
||||||
CW_USEDEFAULT, CW_USEDEFAULT, // width, height
|
CW_USEDEFAULT, CW_USEDEFAULT, // width, height
|
||||||
|
|||||||
@ -189,7 +189,7 @@ private:
|
|||||||
|
|
||||||
SyncDocument *document;
|
SyncDocument *document;
|
||||||
|
|
||||||
std::basic_string<TCHAR> editString;
|
std::string editString;
|
||||||
|
|
||||||
HWND hwnd;
|
HWND hwnd;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user