added support for unicode-builds
This commit is contained in:
parent
259fdd957b
commit
18bb1b5566
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
#include "trackview.h"
|
#include "trackview.h"
|
||||||
|
|
||||||
const char *mainWindowClassName = "MainWindow";
|
const TCHAR *mainWindowClassName = _T("MainWindow");
|
||||||
|
|
||||||
HWND trackViewWin;
|
HWND trackViewWin;
|
||||||
LRESULT CALLBACK mainWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
LRESULT CALLBACK mainWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include "trackview.h"
|
#include "trackview.h"
|
||||||
|
|
||||||
const char *trackViewWindowClassName = "TrackView";
|
const TCHAR *trackViewWindowClassName = _T("TrackView");
|
||||||
|
|
||||||
static const int topMarginHeight = 20;
|
static const int topMarginHeight = 20;
|
||||||
static const int leftMarginWidth = 60;
|
static const int leftMarginWidth = 60;
|
||||||
@ -11,7 +11,13 @@ static const int fontHeight = 16;
|
|||||||
static const int fontWidth = 12;
|
static const int fontWidth = 12;
|
||||||
|
|
||||||
static const int lines = 0x80;
|
static const int lines = 0x80;
|
||||||
static const int tracks = 8;
|
static const int tracks = 16;
|
||||||
|
|
||||||
|
int TrackView::getScreenY(int line)
|
||||||
|
{
|
||||||
|
return topMarginHeight + (line - scrollPosY) * fontHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void TrackView::onCreate(HWND hwnd)
|
void TrackView::onCreate(HWND hwnd)
|
||||||
{
|
{
|
||||||
@ -47,11 +53,14 @@ void TrackView::onPaint(HWND hwnd)
|
|||||||
|
|
||||||
void TrackView::paintTracks(HDC hdc, RECT rcTracks)
|
void TrackView::paintTracks(HDC hdc, RECT rcTracks)
|
||||||
{
|
{
|
||||||
char temp[256];
|
TCHAR temp[256];
|
||||||
|
|
||||||
int firstLine = scrollPosY + max((rcTracks.top - topMarginHeight) / fontHeight, 0);
|
int firstLine = scrollPosY + max((rcTracks.top - topMarginHeight) / fontHeight, 0);
|
||||||
int lastLine = scrollPosY + min(((rcTracks.bottom - topMarginHeight) + (fontHeight - 1)) / fontHeight, lines - 1);
|
int lastLine = scrollPosY + min(((rcTracks.bottom - topMarginHeight) + (fontHeight - 1)) / fontHeight, lines - 1);
|
||||||
|
|
||||||
|
int editLine = firstLine + (lastLine - firstLine) / 2;
|
||||||
|
HBRUSH editBrush = CreateSolidBrush(RGB(255, 255, 0));
|
||||||
|
|
||||||
lastLine = min(lastLine, lines);
|
lastLine = min(lastLine, lines);
|
||||||
|
|
||||||
RECT topLeftCorner;
|
RECT topLeftCorner;
|
||||||
@ -64,26 +73,29 @@ void TrackView::paintTracks(HDC hdc, RECT rcTracks)
|
|||||||
|
|
||||||
SetBkMode(hdc, TRANSPARENT);
|
SetBkMode(hdc, TRANSPARENT);
|
||||||
|
|
||||||
for (int y = firstLine; y < lastLine; ++y)
|
for (int line = firstLine; line < lastLine; ++line)
|
||||||
{
|
{
|
||||||
RECT leftMargin;
|
RECT leftMargin;
|
||||||
leftMargin.left = 0;
|
leftMargin.left = 0;
|
||||||
leftMargin.right = leftMarginWidth;
|
leftMargin.right = leftMarginWidth;
|
||||||
leftMargin.top = topMarginHeight + (y - scrollPosY) * fontHeight;
|
leftMargin.top = getScreenY(line);
|
||||||
leftMargin.bottom = leftMargin.top + fontHeight;
|
leftMargin.bottom = leftMargin.top + fontHeight;
|
||||||
|
|
||||||
|
// if (y == editLine) FillRect(hdc, &leftMargin, editBrush);
|
||||||
|
// else
|
||||||
FillRect(hdc, &leftMargin, (HBRUSH)GetStockObject(LTGRAY_BRUSH));
|
FillRect(hdc, &leftMargin, (HBRUSH)GetStockObject(LTGRAY_BRUSH));
|
||||||
|
|
||||||
DrawEdge(hdc, &leftMargin, BDR_RAISEDINNER | BDR_RAISEDOUTER, BF_RIGHT | BF_BOTTOM | BF_TOP);
|
DrawEdge(hdc, &leftMargin, BDR_RAISEDINNER | BDR_RAISEDOUTER, BF_RIGHT | BF_BOTTOM | BF_TOP);
|
||||||
// Rectangle( hdc, leftMargin.left, leftMargin.top, leftMargin.right, leftMargin.bottom + 1);
|
// Rectangle( hdc, leftMargin.left, leftMargin.top, leftMargin.right, leftMargin.bottom + 1);
|
||||||
if ((y % 16) == 0) SetTextColor(hdc, RGB(0, 0, 0));
|
if ((line % 16) == 0) SetTextColor(hdc, RGB(0, 0, 0));
|
||||||
else if ((y % 8) == 0) SetTextColor(hdc, RGB(32, 32, 32));
|
else if ((line % 8) == 0) SetTextColor(hdc, RGB(32, 32, 32));
|
||||||
else if ((y % 4) == 0) SetTextColor(hdc, RGB(64, 64, 64));
|
else if ((line % 4) == 0) SetTextColor(hdc, RGB(64, 64, 64));
|
||||||
else SetTextColor(hdc, RGB(128, 128, 128));
|
else SetTextColor(hdc, RGB(128, 128, 128));
|
||||||
|
|
||||||
_snprintf_s(temp, 256, "%04Xh", y);
|
_sntprintf_s(temp, 256, _T("%04Xh"), line);
|
||||||
TextOut(hdc,
|
TextOut(hdc,
|
||||||
leftMargin.left, leftMargin.top,
|
leftMargin.left, leftMargin.top,
|
||||||
temp, int(strlen(temp))
|
temp, int(_tcslen(temp))
|
||||||
);
|
);
|
||||||
|
|
||||||
ExcludeClipRect(hdc, leftMargin.left, leftMargin.top, leftMargin.right, leftMargin.bottom);
|
ExcludeClipRect(hdc, leftMargin.left, leftMargin.top, leftMargin.right, leftMargin.bottom);
|
||||||
@ -92,7 +104,6 @@ void TrackView::paintTracks(HDC hdc, RECT rcTracks)
|
|||||||
SetTextColor(hdc, RGB(0, 0, 0));
|
SetTextColor(hdc, RGB(0, 0, 0));
|
||||||
|
|
||||||
int trackLeft = leftMarginWidth - scrollPosX;
|
int trackLeft = leftMarginWidth - scrollPosX;
|
||||||
int trackTop = 0;
|
|
||||||
for (int x = 0; x < tracks; ++x)
|
for (int x = 0; x < tracks; ++x)
|
||||||
{
|
{
|
||||||
int trackWidth = fontWidth * 5;
|
int trackWidth = fontWidth * 5;
|
||||||
@ -110,46 +121,45 @@ void TrackView::paintTracks(HDC hdc, RECT rcTracks)
|
|||||||
FillRect(hdc, &fillRect, (HBRUSH)GetStockObject(LTGRAY_BRUSH));
|
FillRect(hdc, &fillRect, (HBRUSH)GetStockObject(LTGRAY_BRUSH));
|
||||||
|
|
||||||
/* format the text */
|
/* format the text */
|
||||||
_snprintf_s(temp, 256, "track %d", x);
|
_sntprintf_s(temp, 256, _T("track %d"), x);
|
||||||
TextOut(hdc,
|
TextOut(hdc,
|
||||||
fillRect.left, 0,
|
fillRect.left, 0,
|
||||||
temp, int(strlen(temp))
|
temp, int(_tcslen(temp))
|
||||||
);
|
);
|
||||||
ExcludeClipRect(hdc, topMargin.left, topMargin.top, topMargin.right, topMargin.bottom);
|
ExcludeClipRect(hdc, topMargin.left, topMargin.top, topMargin.right, topMargin.bottom);
|
||||||
|
|
||||||
// SetBkColor(hdc, RGB(255, 0, 0));
|
// SetBkColor(hdc, RGB(255, 0, 0));
|
||||||
trackTop = topMarginHeight + (firstLine - scrollPosY) * fontHeight;
|
for (int line = firstLine; line < lastLine; ++line)
|
||||||
for (int y = firstLine; y < lastLine; ++y)
|
|
||||||
{
|
{
|
||||||
RECT patternDataRect;
|
RECT patternDataRect;
|
||||||
patternDataRect.left = trackLeft;
|
patternDataRect.left = trackLeft;
|
||||||
patternDataRect.right = trackLeft + trackWidth;
|
patternDataRect.right = trackLeft + trackWidth;
|
||||||
patternDataRect.top = trackTop;
|
patternDataRect.top = getScreenY(line);
|
||||||
patternDataRect.bottom = patternDataRect.top + fontHeight;
|
patternDataRect.bottom = patternDataRect.top + fontHeight;
|
||||||
|
|
||||||
if (y % 8 == 0) FillRect( hdc, &patternDataRect, (HBRUSH)GetStockObject(LTGRAY_BRUSH));
|
if (line % 8 == 0) FillRect( hdc, &patternDataRect, (HBRUSH)GetStockObject(LTGRAY_BRUSH));
|
||||||
else FillRect( hdc, &patternDataRect, (HBRUSH)GetStockObject(WHITE_BRUSH));
|
else FillRect( hdc, &patternDataRect, (HBRUSH)GetStockObject(WHITE_BRUSH));
|
||||||
|
|
||||||
// if (y % 8 == 0) DrawEdge(hdc, &patternDataRect, BDR_RAISEDINNER | BDR_SUNKENOUTER, BF_TOP | BF_BOTTOM | BF_FLAT);
|
// if (y % 8 == 0) DrawEdge(hdc, &patternDataRect, BDR_RAISEDINNER | BDR_SUNKENOUTER, BF_TOP | BF_BOTTOM | BF_FLAT);
|
||||||
|
|
||||||
bool key = (y % 8 == 0);
|
bool key = (line % 8 == 0);
|
||||||
float val = (float(y) / 16);
|
float val = (float(line) / 16);
|
||||||
|
|
||||||
/* format the text */
|
/* format the text */
|
||||||
if (!key) _snprintf_s(temp, 256, " - - -");
|
if (!key) _sntprintf_s(temp, 256, _T(" - - -"));
|
||||||
else _snprintf_s(temp, 256, "%2.2f", val);
|
else _sntprintf_s(temp, 256, _T("%2.2f"), val);
|
||||||
TextOut(hdc,
|
TextOut(hdc,
|
||||||
trackLeft, trackTop,
|
trackLeft, patternDataRect.top,
|
||||||
temp, int(strlen(temp))
|
temp, int(_tcslen(temp))
|
||||||
);
|
);
|
||||||
trackTop += fontHeight;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RECT bottomMargin;
|
RECT bottomMargin;
|
||||||
bottomMargin.top = trackTop;
|
bottomMargin.top = getScreenY(lines);
|
||||||
bottomMargin.bottom = rcTracks.bottom;
|
bottomMargin.bottom = rcTracks.bottom;
|
||||||
bottomMargin.left = trackLeft;
|
bottomMargin.left = trackLeft;
|
||||||
bottomMargin.right = trackLeft + trackWidth;
|
bottomMargin.right = trackLeft + trackWidth;
|
||||||
|
DrawEdge(hdc, &bottomMargin, BDR_SUNKENINNER | BDR_RAISEDOUTER, BF_ADJUST | BF_TOP);
|
||||||
FillRect(hdc, &bottomMargin, (HBRUSH)GetStockObject(WHITE_BRUSH));
|
FillRect(hdc, &bottomMargin, (HBRUSH)GetStockObject(WHITE_BRUSH));
|
||||||
|
|
||||||
trackLeft += trackWidth;
|
trackLeft += trackWidth;
|
||||||
@ -166,7 +176,7 @@ void TrackView::paintTracks(HDC hdc, RECT rcTracks)
|
|||||||
|
|
||||||
/* pad left margin to the left edge */
|
/* pad left margin to the left edge */
|
||||||
RECT leftMargin;
|
RECT leftMargin;
|
||||||
leftMargin.top = trackTop;
|
leftMargin.top = getScreenY(lines);
|
||||||
leftMargin.bottom = rcTracks.bottom;
|
leftMargin.bottom = rcTracks.bottom;
|
||||||
leftMargin.left = 0;
|
leftMargin.left = 0;
|
||||||
leftMargin.right = leftMarginWidth;
|
leftMargin.right = leftMarginWidth;
|
||||||
@ -181,6 +191,8 @@ void TrackView::paintTracks(HDC hdc, RECT rcTracks)
|
|||||||
rightMargin.right = rcTracks.right;
|
rightMargin.right = rcTracks.right;
|
||||||
DrawEdge(hdc, &rightMargin, BDR_SUNKENINNER | BDR_RAISEDOUTER, BF_ADJUST | BF_LEFT);
|
DrawEdge(hdc, &rightMargin, BDR_SUNKENINNER | BDR_RAISEDOUTER, BF_ADJUST | BF_LEFT);
|
||||||
FillRect( hdc, &rightMargin, (HBRUSH)GetStockObject(LTGRAY_BRUSH));
|
FillRect( hdc, &rightMargin, (HBRUSH)GetStockObject(LTGRAY_BRUSH));
|
||||||
|
|
||||||
|
DeleteObject(editBrush);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackView::setupScrollBars(HWND hwnd)
|
void TrackView::setupScrollBars(HWND hwnd)
|
||||||
@ -369,7 +381,7 @@ LRESULT TrackView::windowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_KEYDOWN:
|
case WM_KEYDOWN:
|
||||||
onKeyDown(hwnd, wParam, lParam);
|
onKeyDown(hwnd, (UINT)wParam, (UINT)lParam);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|||||||
@ -19,6 +19,8 @@ public:
|
|||||||
void setupScrollBars(HWND hwnd);
|
void setupScrollBars(HWND hwnd);
|
||||||
void setScrollPos(HWND hwnd, int newScrollPosX, int newScrollPosY);
|
void setScrollPos(HWND hwnd, int newScrollPosX, int newScrollPosY);
|
||||||
|
|
||||||
|
int getScreenY(int line);
|
||||||
|
|
||||||
int scrollPosX, scrollPosY;
|
int scrollPosX, scrollPosY;
|
||||||
int windowWidth, windowHeight;
|
int windowWidth, windowHeight;
|
||||||
int windowLines;
|
int windowLines;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user