hscroll
This commit is contained in:
parent
f483f6cfc2
commit
d7a45e6c23
@ -116,7 +116,8 @@
|
|||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||||
RuntimeLibrary="2"
|
RuntimeLibrary="0"
|
||||||
|
BufferSecurityCheck="false"
|
||||||
UsePrecompiledHeader="0"
|
UsePrecompiledHeader="0"
|
||||||
WarningLevel="3"
|
WarningLevel="3"
|
||||||
Detect64BitPortabilityProblems="true"
|
Detect64BitPortabilityProblems="true"
|
||||||
@ -134,6 +135,7 @@
|
|||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
LinkIncremental="1"
|
LinkIncremental="1"
|
||||||
|
GenerateManifest="false"
|
||||||
GenerateDebugInformation="true"
|
GenerateDebugInformation="true"
|
||||||
SubSystem="1"
|
SubSystem="1"
|
||||||
OptimizeReferences="2"
|
OptimizeReferences="2"
|
||||||
@ -145,6 +147,7 @@
|
|||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManifestTool"
|
Name="VCManifestTool"
|
||||||
|
EmbedManifest="false"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXDCMakeTool"
|
Name="VCXDCMakeTool"
|
||||||
|
|||||||
@ -12,7 +12,7 @@ static const int fontWidth = 6;
|
|||||||
|
|
||||||
static const int trackWidth = fontWidth * 16;
|
static const int trackWidth = fontWidth * 16;
|
||||||
|
|
||||||
static const int lines = 0x80;
|
static const int lines = 0x20;
|
||||||
static const int tracks = 16;
|
static const int tracks = 16;
|
||||||
|
|
||||||
TrackView::TrackView(HWND hwnd)
|
TrackView::TrackView(HWND hwnd)
|
||||||
@ -55,19 +55,6 @@ void TrackView::onPaint()
|
|||||||
PAINTSTRUCT ps;
|
PAINTSTRUCT ps;
|
||||||
HDC hdc = BeginPaint(hwnd, &ps);
|
HDC hdc = BeginPaint(hwnd, &ps);
|
||||||
|
|
||||||
SetBkMode(hdc, OPAQUE);
|
|
||||||
// SetBkColor(hdc, RGB(255, 0, 0));
|
|
||||||
|
|
||||||
/*
|
|
||||||
RECT margin = rect;
|
|
||||||
|
|
||||||
margin.left = 0;
|
|
||||||
margin.right = LeftMarginWidth();
|
|
||||||
rect.left += LeftMarginWidth();
|
|
||||||
|
|
||||||
PaintMargin(hdc, nLineNo, &margin);
|
|
||||||
*/
|
|
||||||
|
|
||||||
paintTracks(hdc, ps.rcPaint);
|
paintTracks(hdc, ps.rcPaint);
|
||||||
|
|
||||||
EndPaint(hwnd, &ps);
|
EndPaint(hwnd, &ps);
|
||||||
@ -137,8 +124,12 @@ void TrackView::paintTracks(HDC hdc, RECT rcTracks)
|
|||||||
topMargin.right = topMargin.left + trackWidth;
|
topMargin.right = topMargin.left + trackWidth;
|
||||||
|
|
||||||
RECT fillRect = topMargin;
|
RECT fillRect = topMargin;
|
||||||
|
|
||||||
|
HBRUSH bgBrush = (HBRUSH)GetStockObject(LTGRAY_BRUSH);
|
||||||
|
if (track == editTrack) bgBrush = editBrush;
|
||||||
|
|
||||||
DrawEdge(hdc, &fillRect, BDR_RAISEDINNER | BDR_RAISEDOUTER, BF_ADJUST | BF_LEFT | BF_RIGHT | BF_BOTTOM);
|
DrawEdge(hdc, &fillRect, BDR_RAISEDINNER | BDR_RAISEDOUTER, BF_ADJUST | BF_LEFT | BF_RIGHT | BF_BOTTOM);
|
||||||
FillRect(hdc, &fillRect, (HBRUSH)GetStockObject(LTGRAY_BRUSH));
|
FillRect(hdc, &fillRect, bgBrush);
|
||||||
|
|
||||||
/* format the text */
|
/* format the text */
|
||||||
_sntprintf_s(temp, 256, _T("track %d"), track);
|
_sntprintf_s(temp, 256, _T("track %d"), track);
|
||||||
@ -176,19 +167,9 @@ void TrackView::paintTracks(HDC hdc, RECT rcTracks)
|
|||||||
temp, int(_tcslen(temp))
|
temp, int(_tcslen(temp))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
RECT bottomMargin;
|
|
||||||
bottomMargin.top = getScreenY(lines);
|
|
||||||
bottomMargin.bottom = rcTracks.bottom;
|
|
||||||
bottomMargin.left = trackLeft;
|
|
||||||
bottomMargin.right = trackLeft + trackWidth;
|
|
||||||
DrawEdge(hdc, &bottomMargin, BDR_SUNKENINNER | BDR_RAISEDOUTER, BF_ADJUST | BF_TOP);
|
|
||||||
FillRect(hdc, &bottomMargin, (HBRUSH)GetStockObject(WHITE_BRUSH));
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* pad top margin to the left edge */
|
/* pad top margin to the left edge */
|
||||||
|
|
||||||
RECT topMargin;
|
RECT topMargin;
|
||||||
topMargin.top = 0;
|
topMargin.top = 0;
|
||||||
topMargin.bottom = topMarginHeight;
|
topMargin.bottom = topMarginHeight;
|
||||||
@ -231,10 +212,10 @@ void TrackView::setupScrollBars()
|
|||||||
SetScrollInfo(hwnd, SB_VERT, &si, TRUE);
|
SetScrollInfo(hwnd, SB_VERT, &si, TRUE);
|
||||||
|
|
||||||
si.fMask = SIF_POS | SIF_PAGE | SIF_RANGE | SIF_DISABLENOSCROLL;
|
si.fMask = SIF_POS | SIF_PAGE | SIF_RANGE | SIF_DISABLENOSCROLL;
|
||||||
si.nPos = scrollPosX;
|
si.nPos = editTrack;
|
||||||
si.nPage = windowWidth / 2;
|
si.nPage = windowTracks;
|
||||||
si.nMin = 0;
|
si.nMin = 0;
|
||||||
si.nMax = windowWidth * 2; // 0x80;
|
si.nMax = tracks - 1 + windowTracks - 1;
|
||||||
SetScrollInfo(hwnd, SB_HORZ, &si, TRUE);
|
SetScrollInfo(hwnd, SB_HORZ, &si, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -314,6 +295,8 @@ void TrackView::setEditTrack(int newEditTrack)
|
|||||||
editTrack = min(editTrack, tracks - 1);
|
editTrack = min(editTrack, tracks - 1);
|
||||||
|
|
||||||
RECT trackRect;
|
RECT trackRect;
|
||||||
|
|
||||||
|
/* dirty marker */
|
||||||
trackRect.top = getScreenY(editLine);
|
trackRect.top = getScreenY(editLine);
|
||||||
trackRect.bottom = trackRect.top + fontHeight;
|
trackRect.bottom = trackRect.top + fontHeight;
|
||||||
|
|
||||||
@ -325,6 +308,27 @@ void TrackView::setEditTrack(int newEditTrack)
|
|||||||
trackRect.right = trackRect.left + trackWidth;
|
trackRect.right = trackRect.left + trackWidth;
|
||||||
InvalidateRect(hwnd, &trackRect, TRUE);
|
InvalidateRect(hwnd, &trackRect, TRUE);
|
||||||
|
|
||||||
|
/* dirty track-marker */
|
||||||
|
trackRect.top = 0;
|
||||||
|
trackRect.bottom = topMarginHeight;
|
||||||
|
|
||||||
|
trackRect.left = getScreenX(oldEditTrack);
|
||||||
|
trackRect.right = trackRect.left + trackWidth;
|
||||||
|
InvalidateRect(hwnd, &trackRect, TRUE);
|
||||||
|
|
||||||
|
trackRect.left = getScreenX(editTrack);
|
||||||
|
trackRect.right = trackRect.left + trackWidth;
|
||||||
|
InvalidateRect(hwnd, &trackRect, TRUE);
|
||||||
|
|
||||||
|
if (getScreenX(editTrack) < 0)
|
||||||
|
{
|
||||||
|
setScrollPos(scrollPosX - trackWidth, scrollPosY);
|
||||||
|
}
|
||||||
|
else if (getScreenX(editTrack) + trackWidth > windowWidth)
|
||||||
|
{
|
||||||
|
setScrollPos(scrollPosX + trackWidth, scrollPosY);
|
||||||
|
}
|
||||||
|
else setupScrollBars();
|
||||||
}
|
}
|
||||||
|
|
||||||
static int getScrollPos(HWND hwnd, int bar)
|
static int getScrollPos(HWND hwnd, int bar)
|
||||||
@ -370,29 +374,32 @@ void TrackView::onHScroll(UINT sbCode, int newPos)
|
|||||||
switch (sbCode)
|
switch (sbCode)
|
||||||
{
|
{
|
||||||
case SB_LEFT:
|
case SB_LEFT:
|
||||||
setScrollPos(0, scrollPosY);
|
setEditTrack(0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SB_RIGHT:
|
||||||
|
setEditTrack(tracks - 1);
|
||||||
break;
|
break;
|
||||||
// SB_RIGHT currently missing.
|
|
||||||
|
|
||||||
case SB_LINELEFT:
|
case SB_LINELEFT:
|
||||||
setScrollPos(scrollPosX - fontWidth, scrollPosY);
|
setEditTrack(editTrack - 1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SB_LINERIGHT:
|
case SB_LINERIGHT:
|
||||||
setScrollPos(scrollPosX + fontWidth, scrollPosY);
|
setEditTrack(editTrack + 1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SB_PAGELEFT:
|
case SB_PAGELEFT:
|
||||||
setScrollPos(scrollPosX - 20, scrollPosY);
|
setEditTrack(editTrack - windowTracks);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SB_PAGEDOWN:
|
case SB_PAGEDOWN:
|
||||||
setScrollPos(scrollPosX + 20, scrollPosY);
|
setEditTrack(editTrack + windowTracks);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SB_THUMBPOSITION:
|
case SB_THUMBPOSITION:
|
||||||
case SB_THUMBTRACK:
|
case SB_THUMBTRACK:
|
||||||
setScrollPos(getScrollPos(hwnd, SB_HORZ), scrollPosY);
|
setEditTrack(getScrollPos(hwnd, SB_HORZ));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -420,7 +427,8 @@ void TrackView::onSize(int width, int height)
|
|||||||
windowWidth = width;
|
windowWidth = width;
|
||||||
windowHeight = height;
|
windowHeight = height;
|
||||||
|
|
||||||
windowLines = (height - topMarginHeight) / fontHeight;
|
windowLines = (height - topMarginHeight) / fontHeight;
|
||||||
|
windowTracks = (width - leftMarginWidth) / trackWidth;
|
||||||
|
|
||||||
setEditLine(editLine);
|
setEditLine(editLine);
|
||||||
setupScrollBars();
|
setupScrollBars();
|
||||||
|
|||||||
@ -34,7 +34,7 @@ public:
|
|||||||
|
|
||||||
int scrollPosX, scrollPosY;
|
int scrollPosX, scrollPosY;
|
||||||
int windowWidth, windowHeight;
|
int windowWidth, windowHeight;
|
||||||
int windowLines;
|
int windowLines, windowTracks;
|
||||||
|
|
||||||
HWND hwnd;
|
HWND hwnd;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user