|
From: <pst...@us...> - 2008-04-14 14:39:37
|
Revision: 459
http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=459&view=rev
Author: pstieber
Date: 2008-04-14 07:39:29 -0700 (Mon, 14 Apr 2008)
Log Message:
-----------
1. Started putting window management in the hands of a new project manager class.
This include creation and updating. The code uses the observer pattern to some extent,
but is a partial implementation at this point. This should prevent windows from holding
pointers to other windows.
2. Fixed scrolling for the track and piano windows.
3. Fixed some leaks in the windows device code.
Modified Paths:
--------------
trunk/jazz/src/AlsaPlayer.cpp
trunk/jazz/src/Audio.h
trunk/jazz/src/Dialogs.cpp
trunk/jazz/src/Dialogs.h
trunk/jazz/src/EventWindow.cpp
trunk/jazz/src/EventWindow.h
trunk/jazz/src/GuitarFrame.cpp
trunk/jazz/src/GuitarFrame.h
trunk/jazz/src/Harmony.cpp
trunk/jazz/src/JazzPlusPlusApplication.cpp
trunk/jazz/src/Makefile.am
trunk/jazz/src/MouseAction.cpp
trunk/jazz/src/MouseAction.h
trunk/jazz/src/PianoFrame.cpp
trunk/jazz/src/PianoFrame.h
trunk/jazz/src/PianoWindow.cpp
trunk/jazz/src/PianoWindow.h
trunk/jazz/src/Player.cpp
trunk/jazz/src/Project.cpp
trunk/jazz/src/TrackFrame.cpp
trunk/jazz/src/TrackFrame.h
trunk/jazz/src/TrackWindow.cpp
trunk/jazz/src/TrackWindow.h
trunk/jazz/src/mswin/WindowsPlayer.cpp
trunk/jazz/vc8/JazzPlusPlus-VC8.vcproj
trunk/jazz/vc9/JazzPlusPlus-VC9.vcproj
Added Paths:
-----------
trunk/jazz/src/ProjectManager.cpp
trunk/jazz/src/ProjectManager.h
Modified: trunk/jazz/src/AlsaPlayer.cpp
===================================================================
--- trunk/jazz/src/AlsaPlayer.cpp 2008-04-13 00:18:54 UTC (rev 458)
+++ trunk/jazz/src/AlsaPlayer.cpp 2008-04-14 14:39:29 UTC (rev 459)
@@ -32,6 +32,7 @@
#include "WxWidgets.h"
#include "AlsaPlayer.h"
+#include "ProjectManager.h"
#include "TrackFrame.h"
#include "TrackWindow.h"
#include "Dialogs.h"
@@ -715,7 +716,7 @@
flush_output();
stop_queue_timer();
clear_input_queue();
- gpTrackWindow->NewPlayPosition(-1L);
+ JZProjectManager::Instance()->NewPlayPosition(-1);
RecdBuffer.Keyoff2Length();
}
@@ -849,7 +850,8 @@
}
if (recd_clock != old_recd_clock)
{
- gpTrackWindow->NewPlayPosition(PlayLoop->Ext2IntClock(recd_clock/48 * 48));
+ JZProjectManager::Instance()->NewPlayPosition(
+ PlayLoop->Ext2IntClock(recd_clock / 48 * 48));
}
return recd_clock;
}
Modified: trunk/jazz/src/Audio.h
===================================================================
--- trunk/jazz/src/Audio.h 2008-04-13 00:18:54 UTC (rev 458)
+++ trunk/jazz/src/Audio.h 2008-04-14 14:39:29 UTC (rev 459)
@@ -96,6 +96,7 @@
~tAudioBuffer()
{
+ delete hdr;
delete [] data;
}
Modified: trunk/jazz/src/Dialogs.cpp
===================================================================
--- trunk/jazz/src/Dialogs.cpp 2008-04-13 00:18:54 UTC (rev 458)
+++ trunk/jazz/src/Dialogs.cpp 2008-04-14 14:39:29 UTC (rev 459)
@@ -27,6 +27,7 @@
#include "Synth.h"
#include "Command.h"
#include "EventWindow.h"
+#include "ProjectManager.h"
#include "Track.h"
#include "Events.h"
#include "Player.h"
@@ -54,7 +55,6 @@
: tPropertyListDlg("Shift events left/right"),
mSteps(0),
mUnit(unit),
- mpEventWindow(pEventWindow),
mpFilter(pFilter),
mpSong(pFilter->mpSong)
{
@@ -67,12 +67,9 @@
cout << "tShiftDlg::OnClose " << mSteps << endl;
tCmdShift cmd(mpFilter, mSteps * mUnit);
cmd.Execute();
- mpEventWindow->Refresh();
- if (mpEventWindow->NextWin)
- {
- mpEventWindow->NextWin->Refresh();
- }
+ JZProjectManager::Instance()->UpdateAllViews();
+
// wxForm::OnOk();
return false;
}
@@ -110,7 +107,6 @@
{
Filter = f;
Song = f->mpSong;
- mpEventWindow = w;
}
@@ -123,12 +119,9 @@
<< endl;
tCmdCleanup cln(Filter, limit, shortenOverlaps);
cln.Execute();
- mpEventWindow->Refresh();
- if (mpEventWindow->NextWin)
- {
- mpEventWindow->NextWin->Refresh();
- }
+ JZProjectManager::Instance()->UpdateAllViews();
+
//wxForm::OnOk();
return false;
}
@@ -194,19 +187,15 @@
{
Filter = f;
Song = f->mpSong;
- mpEventWindow = w;
}
bool tSearchReplaceDlg::OnClose()
{
tCmdSearchReplace sr(Filter, frCtrl - 1, toCtrl-1);
sr.Execute();
- mpEventWindow->Refresh();
- if (mpEventWindow->NextWin)
- {
- mpEventWindow->NextWin->Refresh();
- }
+ JZProjectManager::Instance()->UpdateAllViews();
+
return false;
}
@@ -244,7 +233,6 @@
tTransposeDlg::tTransposeDlg(JZEventFrame *w, JZFilter *f)
: tPropertyListDlg("Transpose")
{
- mpEventWindow = w;
Filter = f;
Song = f->mpSong;
}
@@ -254,15 +242,9 @@
{
tCmdTranspose trn(Filter, Notes, Scale, FitIntoScale);
trn.Execute();
- if (mpEventWindow->NextWin)
- {
- mpEventWindow->NextWin->Refresh();
- }
- else
- {
- mpEventWindow->Refresh();
- }
+ JZProjectManager::Instance()->UpdateAllViews();
+
return false;
}
@@ -404,7 +386,6 @@
{
Filter = f;
Song = f->mpSong;
- mpEventWindow = w;
}
@@ -413,11 +394,7 @@
tCmdLength cmd(Filter, FromValue, ToValue, Mode);
cmd.Execute();
- mpEventWindow->Refresh();
- if (mpEventWindow->NextWin)
- {
- mpEventWindow->NextWin->Refresh();
- }
+ JZProjectManager::Instance()->UpdateAllViews();
//tPropertyListDlg::OnClose();
return false;
@@ -469,7 +446,6 @@
{
Filter = f;
Song = f->mpSong;
- mpEventWindow = w;
}
@@ -477,12 +453,9 @@
{
tCmdSeqLength cmd(Filter, scale);
cmd.Execute();
- mpEventWindow->Refresh();
- if (mpEventWindow->NextWin)
- {
- mpEventWindow->NextWin->Refresh();
- }
+ JZProjectManager::Instance()->UpdateAllViews();
+
//tPropertyListDlg::OnClose();
return false;
}
@@ -516,7 +489,6 @@
{
Filter = f;
Song = f->mpSong;
- mpEventWindow = w;
}
@@ -525,12 +497,9 @@
tCmdMidiDelay cmd(Filter, scale,clockDelay,repeat);
cmd.Execute();
- mpEventWindow->Refresh();
- if (mpEventWindow->NextWin)
- {
- mpEventWindow->NextWin->Refresh();
- }
+ JZProjectManager::Instance()->UpdateAllViews();
+
//tPropertyListDlg::OnClose();
return false;
}
@@ -579,7 +548,6 @@
: tPropertyListDlg("Delete" )
{
Filter = f;
- mpEventWindow = w;
}
@@ -587,12 +555,9 @@
{
tCmdErase cmd(Filter, LeaveSpace);
cmd.Execute();
- mpEventWindow->Refresh();
- if (mpEventWindow->NextWin)
- {
- mpEventWindow->NextWin->Refresh();
- }
+ JZProjectManager::Instance()->UpdateAllViews();
+
// tPropertyListDlg::OnClose();
return false;
}
@@ -674,7 +639,6 @@
{
Filter = f;
Song = f->mpSong;
- mpEventWindow = w;
}
@@ -687,26 +651,23 @@
qnt.NoteStart = NoteStart;
qnt.NoteLength = NoteLength;
qnt.Execute();
- mpEventWindow->Refresh();
- if (mpEventWindow->NextWin)
- {
- mpEventWindow->NextWin->Refresh();
- }
+ JZProjectManager::Instance()->UpdateAllViews();
+
//tPropertyListDlg::OnClose();
return false;
}
void tQuantizeDlg::OnHelp()
{
- if (mpEventWindow->NextWin)
- {
- gpHelpInstance->ShowTopic("Quantize");
- }
- else
- {
- gpHelpInstance->ShowTopic("Pianowin Quantize");
- }
+// if (mpEventWindow->NextWin)
+// {
+// gpHelpInstance->ShowTopic("Quantize");
+// }
+// else
+// {
+// gpHelpInstance->ShowTopic("Pianowin Quantize");
+// }
}
void tQuantizeDlg::AddProperties()
Modified: trunk/jazz/src/Dialogs.h
===================================================================
--- trunk/jazz/src/Dialogs.h 2008-04-13 00:18:54 UTC (rev 458)
+++ trunk/jazz/src/Dialogs.h 2008-04-14 14:39:29 UTC (rev 459)
@@ -40,7 +40,6 @@
long mSteps; // 0 was static
long mUnit;
- JZEventFrame* mpEventWindow;
JZFilter* mpFilter;
JZSong* mpSong;
@@ -59,7 +58,6 @@
JZFilter *Filter;
JZSong *Song;
- JZEventFrame* mpEventWindow;
tCleanupDlg(JZEventFrame *w, JZFilter *f);
void AddProperties();
@@ -79,7 +77,6 @@
JZFilter *Filter;
JZSong *Song;
- JZEventFrame* mpEventWindow;
tSearchReplaceDlg(JZEventFrame *w, JZFilter *f);
void AddProperties();
@@ -96,7 +93,6 @@
static bool FitIntoScale;
static int Scale;
- JZEventFrame* mpEventWindow;
JZFilter *Filter;
JZSong *Song;
@@ -150,7 +146,6 @@
JZFilter *Filter;
JZSong *Song;
- JZEventFrame* mpEventWindow;
tLengthDlg(JZEventFrame *win, JZFilter *f);
void AddProperties();
@@ -168,7 +163,6 @@
JZFilter *Filter;
JZSong *Song;
- JZEventFrame* mpEventWindow;
tSeqLengthDlg(JZEventFrame *win, JZFilter *f);
void AddProperties();
@@ -187,7 +181,6 @@
JZFilter *Filter;
JZSong *Song;
- JZEventFrame* mpEventWindow;
tMidiDelayDlg(JZEventFrame *win, JZFilter *f);
void AddProperties();
@@ -198,7 +191,6 @@
class tDeleteDlg : public tPropertyListDlg
{
JZFilter *Filter;
- JZEventFrame* mpEventWindow;
public:
static bool LeaveSpace; // 1
@@ -243,7 +235,6 @@
JZFilter *Filter;
JZSong *Song;
- JZEventFrame* mpEventWindow;
long Quantize(long);
Modified: trunk/jazz/src/EventWindow.cpp
===================================================================
--- trunk/jazz/src/EventWindow.cpp 2008-04-13 00:18:54 UTC (rev 458)
+++ trunk/jazz/src/EventWindow.cpp 2008-04-14 14:39:29 UTC (rev 459)
@@ -45,16 +45,12 @@
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
-const int JZEventWindow::mScrollSize = 50;
-
-//-----------------------------------------------------------------------------
-//-----------------------------------------------------------------------------
JZEventWindow::JZEventWindow(
wxFrame* pParent,
JZSong* pSong,
const wxPoint& Position,
const wxSize& Size)
- : wxScrolledWindow(
+ : wxWindow(
pParent,
wxID_ANY,
Position,
@@ -65,9 +61,23 @@
mpSong(pSong),
mpGreyColor(0),
mpGreyBrush(0),
+ mClockTicsPerPixel(36),
mTopInfoHeight(40),
+ mLeftInfoWidth(100),
mTrackHeight(10),
- mLittleBit(2)
+ mLittleBit(2),
+ mEventsX(0),
+ mEventsY(mTopInfoHeight),
+ mEventsWidth(),
+ mEventsHeight(),
+ mCanvasWidth(0),
+ mCanvasHeight(0),
+ mFromClock(0),
+ mToClock(0),
+ mFromLine(0),
+ mToLine(0),
+ mScrolledX(0),
+ mScrolledY(0)
{
mpSnapSel = new tSnapSelection(this);
@@ -105,30 +115,98 @@
}
//-----------------------------------------------------------------------------
+// Description:
+// Only consider the event portion of the window when computing the virtual
+// size. Do not consider the static information of the left or top portion of
+// the screen.
//-----------------------------------------------------------------------------
-//void JZEventWindow::SetScrollRanges()
-//{
-// int Width, Height;
-// GetVirtualEventSize(Width, Height);
-// SetScrollbars(
-// mScrollSize,
-// mScrollSize,
-// Width / mScrollSize,
-// Height / mScrollSize);
-// EnableScrolling(false, false);
-//}
+void JZEventWindow::GetVirtualEventSize(
+ int& EventWidth,
+ int& EventHeight) const
+{
+ int TotalClockTics = mpSong->MaxQuarters * mpSong->TicksPerQuarter;
+ EventWidth = TotalClockTics / mClockTicsPerPixel;
+ EventHeight = 127 * mTrackHeight;
+}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
-void JZEventWindow::SetScrollPosition(int x, int y)
+void JZEventWindow::SetXScrollPosition(int x)
{
- x /= mScrollSize;
- y /= mScrollSize;
- Scroll(x, y);
+ // The following line converts an x position in window coordinates to an
+ // x position in scrolled coordinates.
+ int ScrolledX = x - mEventsX + mScrolledX;
+
+ if (mScrolledX != ScrolledX)
+ {
+ mScrolledX = ScrolledX;
+
+ // Set the new from clock and to clock positions based on the new scroll
+ // position.
+ mFromClock = mScrolledX * mClockTicsPerPixel;
+ mToClock = x2Clock(mCanvasWidth);
+
+ SetScrollPos(wxHORIZONTAL, mScrolledX);
+ }
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
+void JZEventWindow::SetYScrollPosition(int y)
+{
+ // The following line converts a y position in window coordinates to a
+ // y position in scrolled coordinates.
+ int ScrolledY = y - mEventsY + mScrolledY;
+
+ if (mScrolledY != y)
+ {
+ mScrolledY = ScrolledY;
+
+ // Set the new from line and to line positions based on the new scroll
+ // position.
+ mFromLine = mScrolledY / mTrackHeight;
+ mToLine = 1 + (mScrolledY + mCanvasHeight - mTopInfoHeight) / mTrackHeight;
+
+ SetScrollPos(wxVERTICAL, mScrolledY);
+ }
+}
+
+//-----------------------------------------------------------------------------
+// Description:
+// This function takes an x-pixel value in window coordinates and converts
+// it to clock tics.
+//-----------------------------------------------------------------------------
+int JZEventWindow::x2Clock(int x)
+{
+ return (x - mEventsX) * mClockTicsPerPixel + mFromClock;
+}
+
+//-----------------------------------------------------------------------------
+// Description:
+// This function takes clock tics and converts the value into an x-pixel
+// location on the screen in window coordinates.
+//-----------------------------------------------------------------------------
+int JZEventWindow::Clock2x(int Clock)
+{
+ return mEventsX + (Clock - mFromClock) / mClockTicsPerPixel;
+}
+
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+int JZEventWindow::x2BarClock(int x, int Next)
+{
+ int Clock = x2Clock(x);
+ JZBarInfo BarInfo(mpSong);
+ BarInfo.SetClock(Clock);
+ while (Next--)
+ {
+ BarInfo.Next();
+ }
+ return BarInfo.Clock;
+}
+
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
int JZEventWindow::y2yLine(int y, int Up)
{
if (Up)
@@ -142,7 +220,23 @@
}
//-----------------------------------------------------------------------------
+// Was the VLine macro
//-----------------------------------------------------------------------------
+void JZEventWindow::DrawVerticalLine(wxDC& Dc, int XPosition) const
+{
+ Dc.DrawLine(XPosition, 0, XPosition, mEventsY + mEventsHeight);
+}
+
+//-----------------------------------------------------------------------------
+// Was the HLine macro
+//-----------------------------------------------------------------------------
+void JZEventWindow::DrawHorizontalLine(wxDC& Dc, int YPosition) const
+{
+ Dc.DrawLine(0, YPosition, mCanvasWidth, YPosition);
+}
+
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
void JZEventWindow::LineText(
wxDC& Dc,
int x,
@@ -210,21 +304,6 @@
}
//-----------------------------------------------------------------------------
-// JAVE seems to want to clip the paint area
-// calls the subclass paint routine
-//
-// OnPaint seems never to get called
-//-----------------------------------------------------------------------------
-//void JZEventWindow::OnDraw(wxDC& Dc)
-//{
-// //onpaint never seems to get called, but ondraw does get called
-// int x = 0, y = 0;
-// GetViewStart(&x, &y);
-// EventWin->OnPaintSub(Dc, x * mScrollSize, y * mScrollSize);
-// cout << "JZEventWindow::OnDraw << endl;
-//}
-
-//-----------------------------------------------------------------------------
// This mouse handler delegates to the subclased event window.
//-----------------------------------------------------------------------------
//void JZEventWindow::OnMouseEvent(wxMouseEvent& MouseEvent)
@@ -284,19 +363,13 @@
: wxFrame(pParent, wxID_ANY, Title, Position, Size),
Song(pSong),
mpFilter(0),
- NextWin(0),
-// mpEventWindow(0),
- mpFont(0),
mpFixedFont(0),
hFixedFont(0),
- LittleBit(1),
mTrackHeight(0),
mTopInfoHeight(40),
- mLeftInfoWidth(100),
FontSize(12),
ClocksPerPixel(36),
- UseColors(true),
- mEventsX(mLeftInfoWidth),
+ mEventsX(),
mEventsY(mTopInfoHeight),
mEventsWidth(0),
mEventsHeight(0),
@@ -337,7 +410,6 @@
delete mpFilter;
- delete mpFont;
delete mpFixedFont;
delete mpToolBar;
@@ -373,16 +445,9 @@
*/
void JZEventFrame::Create()
{
- cout <<"JZEventFrame::Create\n";
CreateMenu();
-// CreateCanvas();
-// SnapSel = new tSnapSelection(mpEventWindow);
-
-
Setup();
-// mpEventWindow->SetScrollRanges();
-// mpEventWindow->SetScrollPosition(0, 0); //this wasnt here before wx2, why?
}
@@ -405,10 +470,10 @@
Dc.SetFont(*mpFont);
Dc.GetTextExtent("M", &x, &y);
- LittleBit = (int)(x/2);
+ mLittleBit = (int)(x/2);
Dc.GetTextExtent("HXWjgi", &x, &y);
- mTrackHeight = (int)y + LittleBit;
+ mTrackHeight = (int)y + mLittleBit;
*/
}
@@ -474,30 +539,6 @@
// *******************************************************************
-int JZEventFrame::x2Clock(int x)
-{
- return (x - mEventsX) * ClocksPerPixel + FromClock;
-}
-
-
-int JZEventFrame::Clock2x(int clk)
-{
- return mEventsX + (clk - FromClock) / ClocksPerPixel;
-}
-
-int JZEventFrame::x2BarClock(int x, int next)
-{
- int clk = x2Clock(x);
- JZBarInfo b(Song);
- b.SetClock(clk);
- while (next--)
- {
- b.Next();
- }
- return b.Clock;
-}
-
-
int JZEventFrame::y2yLine(int y, int up)
{
if (up)
@@ -571,7 +612,7 @@
y -= 2;
}
dc->SetTextBackground(*mpGreyColor);
- dc->DrawText((char *)str, x + LittleBit, y + LittleBit);
+ dc->DrawText((char *)str, x + mLittleBit, y + mLittleBit);
dc->SetTextBackground(*wxWHITE);
}
*/
@@ -595,42 +636,6 @@
}
-/**
- JAVE this was originally called OnPaint(x,y), but i renamed it because i confused it with the OnPaint() framework routine
- the call graph feels odd: the canvas is a member of the eventwin, with a pointer to the parent. the child calss the parent to redraw itself
-
- it doesnt do any real drawing, instead it sets up some member vars, to be used by other parts of the class
-
- it is now normally called from OnDraw in the mpEventWindow class,and also overridden in the subclass.
- so this one here just sets up constants
-
-
- dc is the device context to draw in, normally generated from the framework from ondraw
- x and y is the coordinates of the start of the view
-
-*/
-void JZEventFrame::OnPaintSub(wxDC *dc, int x, int y)
-{
- //printf("EventWin::OnPaintSub: x %ld, y %ld, w %ld, h %ld\n", x, y, w, h);
- CanvasX = x;
- CanvasY = y;
-// wxCanvas::GetClientSize returns huge values, at least in wx_xt
- int xc, yc;
- GetClientSize(&xc, &yc);
- CanvasW = xc;
- CanvasH = yc;
-
- mEventsX = CanvasX + mLeftInfoWidth;
- mEventsY = CanvasY + mTopInfoHeight;
- mEventsWidth = CanvasW - mLeftInfoWidth;
- mEventsHeight = CanvasH - mTopInfoHeight;
-
- FromLine = CanvasY / mTrackHeight;
- ToLine = (CanvasY + CanvasH - mTopInfoHeight) / mTrackHeight;
- FromClock = CanvasX * ClocksPerPixel;
- ToClock = x2Clock(CanvasX + CanvasW);
-}
-
// ******************************************************************
// Mouse
// ******************************************************************
@@ -712,83 +717,9 @@
}
//-----------------------------------------------------------------------------
-//-----------------------------------------------------------------------------
-void JZEventFrame::GetVirtualEventSize(int& Width, int& Height)
-{
- int TotalClockTics = Song->MaxQuarters * Song->TicksPerQuarter;
- Width = TotalClockTics / ClocksPerPixel + mLeftInfoWidth;
- Height = 127 * mTrackHeight + mTopInfoHeight;
-}
-
-//-----------------------------------------------------------------------------
// PlayPosition
//-----------------------------------------------------------------------------
-// Update the play position to the clock argument, and trigger a redraw so
-// the play bar will be drawn.
-void JZEventFrame::NewPlayPosition(int Clock)
-{
- int scroll_clock = (FromClock + 5 * ToClock) / 6;
-
- if (!SnapSel->Active && ((Clock > scroll_clock) || (Clock < FromClock)) && (Clock >= 0))
- {
- // avoid permenent redraws when end of scroll range is reached
- if (Clock > FromClock && ToClock >= Song->MaxQuarters * Song->TicksPerQuarter)
- return;
-// int x = Clock2x(Clock);
-// mpEventWindow->SetScrollPosition(x - mLeftInfoWidth, CanvasY);
- }
-
- if (!SnapSel->Active) // sets clipping
- {
- if (PlayClock != Clock)
- {
-// int oldplayclock=PlayClock;
-// PlayClock = Clock;
-// wxRect invalidateRect;
-// invalidateRect.x=Clock2x(oldplayclock)-1;
-// invalidateRect.y=CanvasY;
-// invalidateRect.width=3;
-// invalidateRect.height= 100000000;
-// //DrawPlayPosition();
-// mpEventWindow->Refresh(TRUE,&invalidateRect);
-
-// invalidateRect.x=Clock2x(PlayClock)-1;
-// mpEventWindow->Refresh(TRUE,&invalidateRect);
- //DrawPlayPosition();
-
-// mpEventWindow->Refresh();
- }
- }
- if (NextWin)
- {
- NextWin->NewPlayPosition(Clock);
- }
-}
-
-/** draw the "play position", by placing a vertical line where the "play clock" is */
-void JZEventFrame::DrawPlayPosition(wxDC* dc)
-{
- if (!SnapSel->Active && PlayClock >= FromClock && PlayClock < ToClock)
- {
-// wxDC* dc = new wxClientDC(this);
-// dc->SetLogicalFunction(wxXOR);
- dc->SetBrush(*wxBLACK_BRUSH);
- dc->SetPen(*wxBLACK_PEN);
- int x = Clock2x(PlayClock);
-
- //cout<<"JZEventFrame::DrawPlayPosition play pos x "<<x<<" "<<FromClock<<" "<<ToClock<<endl;
- //dc->DrawRectangle(x, CanvasY, 2*LittleBit, mTopInfoHeight);
- dc->DrawLine(x, CanvasY, x, mEventsY + mEventsHeight); //draw a line, 2 pixwels wide
- dc->DrawLine(x + 1, CanvasY, x + 1, mEventsY + mEventsHeight);
- dc->SetLogicalFunction(wxCOPY);
- }
-//OLD if (NextWin)
-//OLD {
-//OLD NextWin->DrawPlayPosition(dc);
-//OLD }
-}
-
// **************************************************************************
// EventsSelected
// **************************************************************************
@@ -964,10 +895,6 @@
tCmdConvertToModulation cmd(mpFilter);
cmd.Execute();
Redraw();
- if (NextWin)
- NextWin->Redraw();
-
-
}
@@ -1065,44 +992,4 @@
// mpSettingsDialog = new wxDialogBox(this, "MeterChange", FALSE );
dlg = new tMeterChangeDlg(this);
dlg->Create();
-
}
-
-
-void JZEventFrame::ZoomIn()
-{
-
-// if (ClocksPerPixel >= 2)
-// {
-// ClocksPerPixel /= 2;
-// int x = CanvasX * 2;
-// int y = CanvasY;
-
-// wxDC* dc=new wxClientDC(mpEventWindow);
-// JZEventFrame::OnPaintSub(dc, x, y);
-// mpEventWindow->SetScrollRanges();
-// mpEventWindow->SetScrollPosition(x, y);
-// if (x == 0)
-// Redraw();
-
-// }
-}
-
-//-----------------------------------------------------------------------------
-//-----------------------------------------------------------------------------
-void JZEventFrame::ZoomOut()
-{
-// if (ClocksPerPixel <= 120)
-// {
-// ClocksPerPixel *= 2;
-// int x = CanvasX / 2;
-// int y = CanvasY;
-
- //wxClientDC Dc(mpEventWindow);
- //JZEventFrame::OnPaintSub(Dc, x, y);
-// mpEventWindow->SetScrollRanges();
-// mpEventWindow->SetScrollPosition(x, y);
- //if (x == 0)
- // Redraw();
-// }
-}
Modified: trunk/jazz/src/EventWindow.h
===================================================================
--- trunk/jazz/src/EventWindow.h 2008-04-13 00:18:54 UTC (rev 458)
+++ trunk/jazz/src/EventWindow.h 2008-04-14 14:39:29 UTC (rev 459)
@@ -36,7 +36,7 @@
// This class is derived from a wxWidgets scrolled window, and acts as the
// common base class for JZTrackWindow and JSPianoWindow.
//*****************************************************************************
-class JZEventWindow : public wxScrolledWindow
+class JZEventWindow : public wxWindow
{
public:
@@ -66,36 +66,50 @@
int Height = -1,
bool Down = false);
-// void SetScrollRanges();
+ //========================================
+ // Coordinate conversion member functions.
+ //========================================
- void SetScrollPosition(int x, int y);
+ int x2Clock(int x);
+ int Clock2x(int Clock);
+
+ int x2BarClock(int x, int Next = 0);
+
protected:
-// void OnPaint(wxPaintEvent& Event);
-// void OnMouseEvent(wxMouseEvent& Event);
-// void OnChar(wxKeyEvent& Event);
-// bool OnCharHook(wxKeyEvent& Event);
-// void OnDraw(wxDC& Dc);
+ void DrawVerticalLine(wxDC& Dc, int XPosition) const;
+ void DrawHorizontalLine(wxDC& Dc, int YPosition) const;
+
+ virtual void GetVirtualEventSize(int& EventWidth, int& EventHeight) const;
+
+ virtual void SetXScrollPosition(int x);
+
+ virtual void SetYScrollPosition(int y);
+
int y2yLine(int y, int Up = 0);
protected:
- static const int mScrollSize;
-
JZSong* mpSong;
-// JZEventFrame* mpEventFrame;
-
wxColor* mpGreyColor;
wxBrush* mpGreyBrush;
+ int mClockTicsPerPixel;
int mTopInfoHeight;
+ int mLeftInfoWidth;
int mTrackHeight;
int mLittleBit;
+ int mEventsX, mEventsY, mEventsWidth, mEventsHeight;
+ int mCanvasWidth, mCanvasHeight;
+ int mFromClock, mToClock;
+ int mFromLine, mToLine;
+ int mScrolledX, mScrolledY;
+
// DECLARE_EVENT_TABLE()
};
@@ -143,9 +157,6 @@
JZFilter* mpFilter;
- JZPianoFrame* NextWin;
-
-
// 2) Create():
virtual void Create();
virtual void CreateMenu();
@@ -153,24 +164,18 @@
// JZEventWindow* mpEventWindow;
// Setup()
- wxFont* mpFont;
wxFont* mpFixedFont; // remains with 12pt
int hFixedFont; // Height of letters
- int LittleBit;
int mTrackHeight;
int mTopInfoHeight;
- int mLeftInfoWidth;
int FontSize;
int ClocksPerPixel;
- bool UseColors;
// Parameters changed, e.g. Song loaded
virtual void Setup();
- // filled by OnPaint()
- //wxDC *dc;
int mEventsX, mEventsY, mEventsWidth, mEventsHeight;
int CanvasX, CanvasY, CanvasW, CanvasH; // canvas coords
int FromClock, ToClock;
@@ -187,21 +192,10 @@
int y2yLine(int y, int up = 0);
int Line2y(int line);
// void LineText(wxDC *dc, int x, int y, int w, const char *str, int h = -1, bool down = false);
- int x2Clock(int x);
- int Clock2x(int clk);
- int x2BarClock(int x, int Next = 0);
int PlayClock;
- virtual void NewPlayPosition(int Clock);
- virtual void DrawPlayPosition(wxDC* dc);
- // sent by trackwin: scroll to Position
- virtual void NewPosition(int TrackNr, int Clock)
- {
- }
-
// Events
- virtual void OnPaintSub(wxDC *dc, int x, int y);
virtual int OnMouseEvent(wxMouseEvent& Event);
virtual bool OnKeyEvent(wxKeyEvent& Event); // true = processed by eventwin
virtual void OnSize(wxSizeEvent& Event);
@@ -218,8 +212,6 @@
// Mixer-Dialog
wxDialog* MixerForm;
- virtual void GetVirtualEventSize(int& Width, int& Height);
-
// Edit-Menu
// if selection active: TRUE, else: Errormessage + FALSE
@@ -239,9 +231,6 @@
void MenSearchReplace();
void MenMeterChange();
- void ZoomIn();
- void ZoomOut();
-
protected:
JZToolBar* mpToolBar;
Modified: trunk/jazz/src/GuitarFrame.cpp
===================================================================
--- trunk/jazz/src/GuitarFrame.cpp 2008-04-13 00:18:54 UTC (rev 458)
+++ trunk/jazz/src/GuitarFrame.cpp 2008-04-14 14:39:29 UTC (rev 459)
@@ -27,6 +27,7 @@
#include "GuitarFrame.h"
#include "GuitarWindow.h"
#include "GuitarSettingsDialog.h"
+#include "ProjectManager.h"
//*****************************************************************************
// Description:
@@ -84,6 +85,13 @@
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
+JZGuitarFrame::~JZGuitarFrame()
+{
+ JZProjectManager::Instance()->Detach(this);
+}
+
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
void JZGuitarFrame::PrepareDC(wxDC& Dc)
{
}
Modified: trunk/jazz/src/GuitarFrame.h
===================================================================
--- trunk/jazz/src/GuitarFrame.h 2008-04-13 00:18:54 UTC (rev 458)
+++ trunk/jazz/src/GuitarFrame.h 2008-04-14 14:39:29 UTC (rev 459)
@@ -25,13 +25,18 @@
class JZGuitarWindow;
-// Define a new frame type: this is going to be our main frame
+//*****************************************************************************
+// Description:
+// This is the guitar frame class declaration.
+//*****************************************************************************
class JZGuitarFrame : public wxFrame
{
public:
JZGuitarFrame(wxWindow* pParent = 0);
+ ~JZGuitarFrame();
+
void PrepareDC(wxDC& Dc);
void ShowPitch(int Pitch);
Modified: trunk/jazz/src/Harmony.cpp
===================================================================
--- trunk/jazz/src/Harmony.cpp 2008-04-13 00:18:54 UTC (rev 458)
+++ trunk/jazz/src/Harmony.cpp 2008-04-14 14:39:29 UTC (rev 459)
@@ -24,6 +24,7 @@
#include "Harmony.h"
#include "HarmonyP.h"
+#include "ProjectManager.h"
#include "Player.h"
#include "TrackFrame.h"
#include "TrackWindow.h"
@@ -1356,16 +1357,8 @@
if (gpTrackFrame->GetPianoWindow())
{
- // Show in GuitarWin
- JZGuitarFrame* pGuitarFrame =
- gpTrackFrame->GetPianoWindow()->GetGuitarFrame();
- if (pGuitarFrame)
- {
- // Remove actual pianowin/mouse position
- pGuitarFrame->ShowPitch(0);
-// pGuitarFrame->Redraw();
- pGuitarFrame->Update();
- }
+ // Show in the guitar view.
+ JZProjectManager::Instance()->ShowPitch(0);
}
}
}
Modified: trunk/jazz/src/JazzPlusPlusApplication.cpp
===================================================================
--- trunk/jazz/src/JazzPlusPlusApplication.cpp 2008-04-13 00:18:54 UTC (rev 458)
+++ trunk/jazz/src/JazzPlusPlusApplication.cpp 2008-04-14 14:39:29 UTC (rev 459)
@@ -25,6 +25,7 @@
#include "JazzPlusPlusApplication.h"
#include "TrackFrame.h"
#include "Project.h"
+#include "ProjectManager.h"
#include "Globals.h"
#ifdef _MSC_VER
@@ -135,17 +136,18 @@
wxApp::OnInit();
// Create the main application window.
- mpTrackFrame = new JZTrackFrame(
- 0,
- "Jazz++",
- gpSong,
- wxPoint(10, 10),
- wxSize(600, 400));
+ mpTrackFrame = JZProjectManager::Instance()->CreateTrackView();
+// new JZTrackFrame(
+// 0,
+// "Jazz++",
+// gpSong,
+// wxPoint(10, 10),
+// wxSize(600, 400));
gpTrackFrame = mpTrackFrame;
// Show it and tell the application that it's our main window
- mpTrackFrame->Show(true);
+// mpTrackFrame->Show(true);
SetTopWindow(mpTrackFrame);
return true;
@@ -167,6 +169,8 @@
// Prevent reported leaks from the configuration class.
delete wxConfigBase::Set(0);
+ JZProjectManager::Destroy();
+
return 0;
}
Modified: trunk/jazz/src/Makefile.am
===================================================================
--- trunk/jazz/src/Makefile.am 2008-04-13 00:18:54 UTC (rev 458)
+++ trunk/jazz/src/Makefile.am 2008-04-14 14:39:29 UTC (rev 459)
@@ -55,6 +55,7 @@
PianoWindow.cpp \
Player.cpp \
Project.cpp \
+ProjectManager.cpp \
PropertyListDialog.cpp \
Random.cpp \
RecordingInfo.cpp \
@@ -130,6 +131,7 @@
PianoWindow.h \
Player.h \
Project.h \
+ProjectManager.h \
PropertyListDialog.h \
Random.h \
RecordingInfo.h \
Modified: trunk/jazz/src/MouseAction.cpp
===================================================================
--- trunk/jazz/src/MouseAction.cpp 2008-04-13 00:18:54 UTC (rev 458)
+++ trunk/jazz/src/MouseAction.cpp 2008-04-14 14:39:29 UTC (rev 459)
@@ -92,7 +92,7 @@
//////////////////////////////////////////////////////////
//tSelection implementation
-tSelection::tSelection(wxScrolledWindow* pWindow)
+tSelection::tSelection(wxWindow* pWindow)
: win(pWindow),
mpBackgroundBrush(0)
{
@@ -343,7 +343,7 @@
}
-tSnapSelection::tSnapSelection(wxScrolledWindow *c)
+tSnapSelection::tSnapSelection(wxWindow *c)
: tSelection(c)
{
xCoords = 0;
@@ -471,7 +471,7 @@
// -------------------------------------------------------------------------
-tMarkDestin::tMarkDestin(wxScrolledWindow* canvas, wxFrame *frame, int left)
+tMarkDestin::tMarkDestin(wxWindow* canvas, wxFrame *frame, int left)
{
wxCursor c;
Canvas = canvas;
Modified: trunk/jazz/src/MouseAction.h
===================================================================
--- trunk/jazz/src/MouseAction.h 2008-04-13 00:18:54 UTC (rev 458)
+++ trunk/jazz/src/MouseAction.h 2008-04-14 14:39:29 UTC (rev 459)
@@ -149,7 +149,7 @@
{
public:
- tSelection(wxScrolledWindow* w);//wxCanvas *canvas);
+ tSelection(wxWindow* w);//wxCanvas *canvas);
virtual ~tSelection();
int Active;
@@ -168,7 +168,7 @@
private:
- wxScrolledWindow* win;
+ wxWindow* win;
// wxCanvas *Canvas;
wxBrush* mpBackgroundBrush;
@@ -179,7 +179,7 @@
class tSnapSelection : public tSelection
{
public:
- tSnapSelection(wxScrolledWindow *c);
+ tSnapSelection(wxWindow *c);
virtual void Snap(float &x, float &y, int up);
void SetXSnap(int ny, int *cx);
void SetYSnap(int ny, int *cy);
@@ -194,15 +194,13 @@
//*****************************************************************************
-/**
- tButtonLabelInterface
-
- Specifies an interface for displaying a text string within another widget.
- The other widget would inherit from this interface and implement the Display
- method to print the string somewhere appropriate. The down argument
- indicates if the text should be displayed in a depressed button or a normal
- button.
-*/
+// tButtonLabelInterface
+//
+// Specifies an interface for displaying a text string within another widget.
+// The other widget would inherit from this interface and implement the Display
+// method to print the string somewhere appropriate. The down argument
+// indicates if the text should be displayed in a depressed button or a normal
+// button.
//*****************************************************************************
class tButtonLabelInterface
{
@@ -219,13 +217,26 @@
//*****************************************************************************
-/**
- MouseCounter - let you enter numbers with left/right mouse button
-
-*/
+// MouseCounter - let you enter numbers with left/right mouse button
//*****************************************************************************
class tMouseCounter : public wxTimer, public tMouseAction
{
+ public:
+
+ JZRectangle r;
+
+ int Value;
+
+ tMouseCounter(
+ tButtonLabelInterface *win,
+ JZRectangle *rec,
+ int val,
+ int min,
+ int max,
+ int wait = 0);
+
+ private:
+
int Min, Max, Delta;
int Timeout;
int Wait; // don't inc/dec at Init
@@ -237,10 +248,6 @@
virtual int RightUp(wxMouseEvent &);
virtual void Notify();
virtual void ShowValue(bool down);
- public:
- JZRectangle r;
- int Value;
- tMouseCounter(tButtonLabelInterface *win, JZRectangle *rec, int val, int min, int max, int wait = 0);
};
@@ -249,7 +256,7 @@
//*****************************************************************************
class tMarkDestin : public tMouseAction
{
- wxScrolledWindow *Canvas;
+ wxWindow *Canvas;
wxFrame *Frame;
int ButtonDown(wxMouseEvent &);
@@ -259,7 +266,7 @@
virtual int LeftDown(wxMouseEvent &);
virtual int RightDown(wxMouseEvent &);
- tMarkDestin(wxScrolledWindow *canvas, wxFrame *frame, int left);
+ tMarkDestin(wxWindow *canvas, wxFrame *frame, int left);
};
//*****************************************************************************
Modified: trunk/jazz/src/PianoFrame.cpp
===================================================================
--- trunk/jazz/src/PianoFrame.cpp 2008-04-13 00:18:54 UTC (rev 458)
+++ trunk/jazz/src/PianoFrame.cpp 2008-04-14 14:39:29 UTC (rev 459)
@@ -26,6 +26,7 @@
#include "PianoFrame.h"
#include "PianoWindow.h"
+#include "ProjectManager.h"
#include "Song.h"
#include "Track.h"
#include "Synth.h"
@@ -87,8 +88,6 @@
#define MEN_CTRL_TEMPO 42
#define MEN_REDO 47
-#define MEN_ZOOMIN 48
-#define MEN_ZOOMOUT 49
#define MEN_CTRL_POLY_AFTER 50
#define MEN_CTRL_CHANNEL_AFTER 51
@@ -117,8 +116,8 @@
{ MEN_SHIFTR, FALSE, shiftr_xpm, "shift selection right"},
{ MEN_VIS_ALL_TRK, TRUE, evnts_xpm, "show events from all tracks"},
{ JZToolBar::eToolBarSeparator },
- { MEN_ZOOMIN, FALSE, zoomin_xpm, "zoom in"},
- { MEN_ZOOMOUT, FALSE, zoomout_xpm, "zoom out"},
+ { wxID_ZOOM_IN, FALSE, zoomin_xpm, "zoom in"},
+ { wxID_ZOOM_OUT, FALSE, zoomout_xpm, "zoom out"},
{ wxID_UNDO, FALSE, undo_xpm, "undo"},
{ MEN_REDO, FALSE, redo_xpm, "redo"},
{ MEN_RESET, FALSE, panic_xpm, "all notes off"},
@@ -156,8 +155,8 @@
//*****************************************************************************
BEGIN_EVENT_TABLE(JZPianoFrame, wxFrame)
- EVT_MENU(MEN_ZOOMIN, JZPianoFrame::OnZoomIn)
- EVT_MENU(MEN_ZOOMOUT, JZPianoFrame::OnZoomOut)
+ EVT_MENU(wxID_ZOOM_IN, JZPianoFrame::OnZoomIn)
+ EVT_MENU(wxID_ZOOM_OUT, JZPianoFrame::OnZoomOut)
EVT_MENU(ID_SNAP_8, JZPianoFrame::OnSnap8)
EVT_MENU(ID_SNAP_8D, JZPianoFrame::OnSnap8D)
EVT_MENU(ID_SNAP_16, JZPianoFrame::OnSnap16)
@@ -268,6 +267,8 @@
delete MixerForm;
delete mpToolBar;
+
+ JZProjectManager::Instance()->Detach(this);
}
//-----------------------------------------------------------------------------
@@ -308,7 +309,7 @@
// show the guitar edit window.
void JZPianoFrame::OnGuitar(wxCommandEvent& Event)
{
- mpPianoWindow->CreateGuitarWindow();
+ JZProjectManager::Instance()->CreateGuitarView();
}
@@ -376,13 +377,6 @@
SetMenuBar(menu_bar);
}
-
-
-JZGuitarFrame* JZPianoFrame::GetGuitarFrame()
-{
- return mpPianoWindow->GetGuitarFrame();
-}
-
void JZPianoFrame::OnFilter(wxCommandEvent& Event)
{
mpPianoWindow->EditFilter();
@@ -747,6 +741,11 @@
mpPianoWindow->NewPlayPosition(Clock);
}
+void JZPianoFrame::ShowPitch(int Pitch)
+{
+ mpPianoWindow->ShowPitch(Pitch);
+}
+
void JZPianoFrame::Redraw()
{
mpPianoWindow->Refresh();
Modified: trunk/jazz/src/PianoFrame.h
===================================================================
--- trunk/jazz/src/PianoFrame.h 2008-04-13 00:18:54 UTC (rev 458)
+++ trunk/jazz/src/PianoFrame.h 2008-04-14 14:39:29 UTC (rev 459)
@@ -59,8 +59,6 @@
void OnMDialog(wxCommandEvent& Event);
void OnMCutPaste(wxCommandEvent& Event);
- void OnZoomIn(wxCommandEvent& Event);
- void OnZoomOut(wxCommandEvent& Event);
void OnSnap8(wxCommandEvent& Event);
void OnSnap8D(wxCommandEvent& Event);
void OnSnap16(wxCommandEvent& Event);
@@ -68,11 +66,8 @@
void VisibleDialog();
-
void CreateMenu();
- void OnPaintSub(wxDC* dc, int x, int y);
-
void OnSnapDlg(wxCommandEvent& Event);
// Current track.
@@ -81,8 +76,6 @@
void MouseCutPaste(wxMouseEvent &e, bool cut);
- JZGuitarFrame* GetGuitarFrame();
-
bool OnClose();
void PressRadio(int id = 0);
@@ -121,14 +114,20 @@
void OnCut(wxCommandEvent& Event);
void OnCopy(wxCommandEvent& Event);
void OnErase(wxCommandEvent& Event);
- void OnVisibleAllTracks(wxCommandEvent& Event);
void OnReset(wxCommandEvent& Event);
- public:
+ //==============================================
+ // These are facades for piano window functions.
+ //==============================================
void NewPlayPosition(int Clock);
+
+ void ShowPitch(int Pitch);
+
void Redraw();
+ public:
+
JZPianoWindow* mpPianoWindow;
int mClockTicsPerPixel;
@@ -138,6 +137,11 @@
private:
+ void OnZoomIn(wxCommandEvent& Event);
+ void OnZoomOut(wxCommandEvent& Event);
+
+ void OnVisibleAllTracks(wxCommandEvent& Event);
+
void OnGuitar(wxCommandEvent& Event);
private:
Modified: trunk/jazz/src/PianoWindow.cpp
===================================================================
--- trunk/jazz/src/PianoWindow.cpp 2008-04-13 00:18:54 UTC (rev 458)
+++ trunk/jazz/src/PianoWindow.cpp 2008-04-14 14:39:29 UTC (rev 459)
@@ -26,6 +26,7 @@
#include "PianoWindow.h"
#include "PianoFrame.h"
+#include "ProjectManager.h"
#include "ControlEdit.h"
#include "Song.h"
#include "Filter.h"
@@ -124,9 +125,9 @@
int tMousePlay::ProcessEvent(wxMouseEvent& Event)
{
int x, y;
+ Event.GetPosition(&x, &y);
int OldPitch = mPitch;
- mpPianoWindow->LogicalMousePosition(Event, x, y);
if (Event.LeftDown())
{
@@ -227,7 +228,7 @@
wxClientDC Dc(Win);
// to translate scrolled coordinates
- Win->DoPrepareDC(Dc);
+ Win->PrepareDC(Dc);
Win->DrawEvent(Dc, Copy, wxWHITE_BRUSH, 0);
Win->DrawEvent(Dc, Copy, Copy->GetBrush(), 1, 1);
@@ -253,10 +254,10 @@
int tKeyLengthDragger::Dragging(wxMouseEvent& Event)
{
wxClientDC Dc(Win);
- Win->DoPrepareDC(Dc); //to translate scrolled coordinates
+ Win->PrepareDC(Dc); //to translate scrolled coordinates
Win->DrawEvent(Dc, Copy, Copy->GetBrush(), 1, 1);
int fx, fy;
- Win->LogicalMousePosition(Event, fx, fy);
+ Event.GetPosition(&fx, &fy);
int Clock = Win->x2Clock(fx);
int Length = Clock - Copy->GetClock();
if (Length <= 0)
@@ -346,7 +347,7 @@
Win->GetSong()->NewUndoBuffer();
//
wxClientDC Dc(Win);
- Win->DoPrepareDC(Dc);
+ Win->PrepareDC(Dc);
Win->DrawEvent(Dc, Copy, wxWHITE_BRUSH, 0);
Win->DrawEvent(Dc, Copy, Copy->GetBrush(), 1, 1);
}
@@ -371,10 +372,10 @@
int tPlayTrackLengthDragger::Dragging(wxMouseEvent& Event)
{
wxClientDC Dc(Win);
- Win->DoPrepareDC(Dc);
+ Win->PrepareDC(Dc);
Win->DrawEvent(Dc, Copy, Copy->GetBrush(), 1, 1);
int fx, fy;
- Win->LogicalMousePosition(Event, fx, fy);
+ Event.GetPosition(&fx, &fy);
int Clock = Win->x2Clock(fx);
int Length = Clock - Copy->GetClock();
if (Length <= 0)
@@ -390,7 +391,7 @@
int tPlayTrackLengthDragger::ButtonUp(wxMouseEvent& Event)
{
wxClientDC Dc(Win);
- Win->DoPrepareDC(Dc);
+ Win->PrepareDC(Dc);
Win->DrawEvent(Dc, Copy, Copy->GetBrush(), 1, 1);
Win->DrawEvent(Dc, Copy, Copy->GetBrush(), 0, 1);
@@ -449,7 +450,7 @@
Win->ApplyToTrack(mpKeyOn, Copy);
wxClientDC Dc(Win);
- Win->DoPrepareDC(Dc);
+ Win->PrepareDC(Dc);
Win->DrawEvent(Dc, Copy, Copy->GetBrush(), 0, 1);
Win->UpdateControl();
@@ -504,7 +505,7 @@
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
-#define IsBlack(Key) isBlack[(Key) % 12]
+#define IsBlack(Key) isBlack[(Key) % 12]
//-----------------------------------------------------------------------------
// Mouse Actions Mapping
@@ -556,8 +557,14 @@
EVT_SIZE(JZPianoWindow::OnSize)
+ EVT_ERASE_BACKGROUND(JZPianoWindow::OnEraseBackground)
+
+ EVT_PAINT(JZPianoWindow::OnPaint)
+
EVT_MOUSE_EVENTS(JZPianoWindow::OnMouseEvent)
+ EVT_SCROLLWIN(JZPianoWindow::OnScroll)
+
END_EVENT_TABLE()
//-----------------------------------------------------------------------------
@@ -581,19 +588,6 @@
mpCtrlEdit(0),
mMousePlay(play_actions),
mMouseEvent(evnt_actions),
- mLittleBit(1),
- mClockTicsPerPixel(4),
- mTopInfoHeight(40),
- mLeftInfoWidth(100),
- mFromClock(0),
- mToClock(0),
- mFromLine(0),
- mToLine(0),
- mCanvasX(0),
- mCanvasY(0),
- mCanvasWidth(0),
- mCanvasHeight(0),
- mTrackHeight(0),
mUseColors(true),
mMouseLine(-1),
mFontSize(12),
@@ -603,18 +597,22 @@
mpDrumFont(0),
mSnapDenomiator(16),
mVisibleKeyOn(true),
- mVisiblePitch(false),
- mVisibleController(false),
- mVisibleProgram(false),
- mVisibleTempo(false),
- mVisibleSysex(false),
- mVisiblePlayTrack(false),
+ mVisiblePitch(true),
+ mVisibleController(true),
+ mVisibleProgram(true),
+ mVisibleTempo(true),
+ mVisibleSysex(true),
+ mVisiblePlayTrack(true),
mVisibleDrumNames(true),
- mVisibleAllTracks(false),
+ mVisibleAllTracks(true),
mVisibleHBChord(true),
- mVisibleMono(false),
- mpGuitarFrame(0)
+ mVisibleMono(true),
+ mDrawing(false),
+ mpFrameBuffer(0)
{
+ // This is more appropriate than the value in the event window constructor.
+ mClockTicsPerPixel = 4;
+
InitColors();
mpTrack = mpSong->GetTrack(mTrackIndex);
@@ -628,6 +626,8 @@
mMouseEvent.SetLeftAction(MA_SELECT);
+ mpFrameBuffer = new wxBitmap;
+
Setup();
}
@@ -639,7 +639,7 @@
delete mpFont;
delete mpFixedFont;
delete mpDrumFont;
- delete mpGuitarFrame;
+ delete mpFrameBuffer;
}
//-----------------------------------------------------------------------------
@@ -694,30 +694,61 @@
mPianoWidth = Width + mLittleBit;
mLeftInfoWidth = mPianoWidth;
+
+ SetScrollRanges();
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
void JZPianoWindow::OnDraw(wxDC& Dc)
{
- // OnPaint never seems to get called, but OnDraw does get called.
- int x = 0, y = 0;
- GetViewStart(&x, &y);
- OnPaintSub(Dc, x * mScrollSize, y * mScrollSize);
+ Draw(Dc);
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
-void JZPianoWindow::OnPaintSub(wxDC& Dc, int x, int y)
+void JZPianoWindow::Draw(wxDC& Dc)
{
+ if (!mpFrameBuffer->Ok() || mDrawing)
+ {
+ return;
+ }
+
+ mDrawing = true;
+
+ // Create a memory device context and select the frame bitmap into it.
+ wxMemoryDC LocalDc;
+ LocalDc.SelectObject(*mpFrameBuffer);
+
+ LocalDc.SetFont(*mpFont);
+
+ // Setup the brush that is used to clear the background.
+ LocalDc.SetBackground(*wxWHITE_BRUSH);
+
+ // Clear the background using the brush that was just setup,
+ // in case the following drawing calls fail.
+ LocalDc.Clear();
+
// int OldFromClock = mFromClock;
- OnEventWinPaintSub(x, y);
+ GetClientSize(&mCanvasWidth, &mCanvasHeight);
-// SN++ Da Jazz nun eine ReDo Funktion hat. Behebt gleichzeitig ein kleines
-// Update Problem beim mehrfachen ZoomOut.
-// Aktives Ctrl-Fenster neu zeichnen bzw. reinitialisieren.
+ mEventsX = mLeftInfoWidth;
+ mEventsY = mTopInfoHeight;
+ mEventsWidth = mCanvasWidth - mLeftInfoWidth;
+ mEventsHeight = mCanvasHeight - mTopInfoHeight;
+
+ mFromLine = mScrolledY / mTrackHeight;
+ mToLine = 1 + (mScrolledY + mCanvasHeight - mTopInfoHeight) / mTrackHeight;
+
+ mFromClock = mScrolledX * mClockTicsPerPixel;
+ mToClock = x2Clock(mCanvasWidth);
+
+ // SN++ Because jazz has a ReDo function. Fixes simultaneously update a
+ // small problem when multiple ZoomOut. Active Ctrl draw new windows or
+ // reinitialize.
+
// if (mpCtrlEdit && OldFromClock != mFromClock)
// mpCtrlEdit->ReInit(mpTrack, mFromClock, mClockTicsPerPixel);
@@ -726,46 +757,50 @@
mpCtrlEdit->ReInit(mpTrack, mFromClock, mClockTicsPerPixel);
}
- mPianoX = mCanvasX;
+ mPianoX = 0;
- int StopClk;
JZBarInfo BarInfo(mpSong);
- char buf[20];
- Dc.DestroyClippingRegion();
- Dc.SetBackground(*wxWHITE_BRUSH);
- DrawPlayPosition(Dc);
- mpSnapSel->Draw(Dc, mEventsX, mEventsY, mEventsWidth, mEventsHeight);
- Dc.Clear();
+//DEBUG cout
+//DEBUG << "mLeftInfoWidth: " << mLeftInfoWidth << '\n'
+//DEBUG << "mCanvasWidth - mLeftInfoWidth: " << mCanvasWidth - mLeftInfoWidth << '\n'
+//DEBUG << "BarInfo.TicksPerBar " << BarInfo.TicksPerBar << '\n'
+//DEBUG << "From Clock: " << mFromClock << '\n'
+//DEBUG << "To Clock: " << mToClock << '\n'
+//DEBUG << "Clocks/Pixel: " << mClockTicsPerPixel << '\n'
+//DEBUG << "From Measure: " << mFromClock / BarInfo.TicksPerBar << '\n'
+//DEBUG << "To Measure: " << mToClock / BarInfo.TicksPerBar << '\n'
+//DEBUG << "From X: " << Clock2x(mFromClock) << '\n'
+//DEBUG << "To X: " << Clock2x(mToClock) << '\n'
+//DEBUG << endl;
-
///////////////////////////////////////////////////////////////
// horizontal lines(ripped from drawpianoroll code)
-// for (y = Line2y(mFromLine); y < mEventsY + mEventsHeight; y += mTrackHeight)
+// for (y = TrackIndex2y(mFromLine); y < mEventsY + mEventsHeight; y += mTrackHeight)
// if (y > mEventsY) // cheaper than clipping
-// Dc.DrawLine(mEventsX+1, y, mEventsX + mEventsWidth, y);
+// LocalDc.DrawLine(mEventsX+1, y, mEventsX + mEventsWidth, y);
- Dc.SetPen(*wxGREY_PEN);
- wxBrush blackKeysBrush=wxBrush(wxColor(250,240,240),wxSOLID);
+ LocalDc.SetPen(*wxGREY_PEN);
+ wxBrush blackKeysBrush = wxBrush(wxColor(250, 240, 240), wxSOLID);
int Pitch = 127 - mFromLine;
- y = Line2y(mFromLine);
+ int y = TrackIndex2y(mFromLine);
while (Pitch >= 0 && y < mEventsY + mEventsHeight)
{
if (IsBlack(Pitch))
{
- Dc.SetBrush(blackKeysBrush);//*wxLIGHT_GREY_PEN
- Dc.DrawRectangle(mCanvasX, y, 2000, mTrackHeight);
+ LocalDc.SetBrush(blackKeysBrush);
+ LocalDc.DrawRectangle(0, y, 2000, mTrackHeight);
}
else if ((Pitch % 12) == 0)
{
- Dc.SetPen(*wxCYAN_PEN);
- Dc.DrawLine(mCanvasX, y + mTrackHeight, 2000, y + mTrackHeight);
+ LocalDc.SetPen(*wxCYAN_PEN);
+ LocalDc.DrawLine(0, y + mTrackHeight, 2000, y + mTrackHeight);
}
else if (!IsBlack(Pitch - 1))
{
- Dc.SetPen(*wxGREEN_PEN);
- Dc.DrawLine(mCanvasX, y + mTrackHeight, 2000, y + mTrackHeight);
+ LocalDc.SetPen(*wxGREEN_PEN);
+ LocalDc.DrawLine(0, y + mTrackHeight, 2000, y + mTrackHeight);
}
y += mTrackHeight;
@@ -775,62 +810,58 @@
///////////////////////////////////////////////////////////////
-
mMouseLine = -1;
- #define VLine(x) DrawLine(x, mCanvasY, x, mEventsY + mEventsHeight)
- #define HLine(y) DrawLine(mCanvasX, y, mCanvasX + mCanvasWidth, y)
+ LocalDc.SetPen(*wxBLACK_PEN);
- Dc.SetPen(*wxBLACK_PEN);
+ DrawVerticalLine(LocalDc, 0);
+ DrawVerticalLine(LocalDc, mEventsX);
+ DrawVerticalLine(LocalDc, mEventsX - 1);
- // vertical lines
+ DrawHorizontalLine(LocalDc, mEventsY);
+ DrawHorizontalLine(LocalDc, mEventsY - 1);
+ DrawHorizontalLine(LocalDc, mEventsY + mEventsHeight);
- Dc.VLine(mPianoX);
- Dc.VLine(mEventsX);
- Dc.VLine(mEventsX - 1);
- Dc.HLine(mEventsY);
- Dc.HLine(mEventsY - 1);
- Dc.HLine(mEventsY + mEventsHeight);
-
// draw vlines and bar numbers
- Dc.SetFont(*mpFixedFont);
+ LocalDc.SetFont(*mpFixedFont);
BarInfo.SetClock(mFromClock);
- StopClk = x2Clock(mCanvasX + mCanvasWidth);
+ int StopClk = x2Clock(mCanvasWidth);
int clk = BarInfo.Clock;
int intro = mpSong->GetIntroLength();
while (clk < StopClk)
{
clk = BarInfo.Clock;
- x = Clock2x(clk);
+ int x = Clock2x(clk);
// vertical lines and bar numbers
int i;
- Dc.SetPen(*wxBLACK_PEN);
- sprintf(buf, "%d", BarInfo.BarNr + 1 - intro);
+ LocalDc.SetPen(*wxBLACK_PEN);
+ ostringstream Oss;
+ Oss << BarInfo.BarNr + 1 - intro;
if (x > mEventsX)
{
- Dc.DrawText(buf, x + mLittleBit, mEventsY - mFixedFontHeight - 2);
- Dc.SetPen(*wxGREY_PEN);
- Dc.DrawLine(x, mEventsY - mFixedFontHeight, x, mEventsY + mEventsHeight);
+ LocalDc.DrawText(Oss.str().c_str(), x + mLittleBit, mEventsY - mFixedFontHeight - 2);
+ LocalDc.SetPen(*wxGREY_PEN);
+ LocalDc.DrawLine(x, mEventsY - mFixedFontHeight, x, mEventsY + mEventsHeight);
}
- Dc.SetPen(*wxLIGHT_GREY_PEN);
+ LocalDc.SetPen(*wxLIGHT_GREY_PEN);
for (i = 0; i < BarInfo.CountsPerBar; i++)
{
clk += BarInfo.TicksPerBar / BarInfo.CountsPerBar;
x = Clock2x(clk);
if (x > mEventsX)
{
- Dc.DrawLine(x, mEventsY + 1, x, mEventsY + mEventsHeight);
+ LocalDc.DrawLine(x, mEventsY + 1, x, mEventsY + mEventsHeight);
}
}
BarInfo.Next();
}
- LineText(Dc, mCanvasX, mCanvasY, mPianoWidth, mTopInfoHeight);
+ LineText(LocalDc, 0, 0, mPianoWidth, mTopInfoHeight);
- Dc.SetPen(*wxBLACK_PEN);
- DrawPianoRoll(Dc);
+ LocalDc.SetPen(*wxBLACK_PEN);
+ DrawPianoRoll(LocalDc);
// Draw chords from harmony-browser.
if (mVisibleHBChord && gpHarmonyBrowser && !mpTrack->IsDrumTrack())
@@ -848,9 +879,9 @@
sbrush.SetColour(230,255,230);
#endif
- //Dc.SetClippingRegion(mEventsX, mEventsY, mEventsWidth, mEventsHeight);
- Dc.SetLogicalFunction(wxXOR);
- Dc.SetPen(*wxTRANSPARENT_PEN);
+// LocalDc.SetClippingRegion(mEventsX, mEventsY, mEventsWidth, mEventsHeight);
+ LocalDc.SetLogicalFunction(wxXOR);
+ LocalDc.SetPen(*wxTRANSPARENT_PEN);
int steps = pAnalyzer->Steps();
for (int step = 0; step < steps; step ++)
@@ -890,13 +921,13 @@
}
if (brush)
{
- Dc.SetBrush(*brush);
+ LocalDc.SetBrush(*brush);
while (pitch < 127)
{
int y = Pitch2y(pitch);
if (y >= mEventsY && y <= mEventsY + mEventsHeight - h) // y-clipping
{
- Dc.DrawRectangle(x, y, w, h);
+ LocalDc.DrawRectangle(x, y, w, h);
}
pitch += 12;
}
@@ -905,52 +936,81 @@
}
}
- //Dc.DestroyClippingRegion();
- Dc.SetLogicalFunction(wxCOPY);
- Dc.SetPen(*wxBLACK_PEN);
- Dc.SetBrush(*wxBLACK_BRUSH);
+// LocalDc.DestroyClippingRegion();
+ LocalDc.SetLogicalFunction(wxCOPY);
+ LocalDc.SetPen(*wxBLACK_PEN);
+ LocalDc.SetBrush(*wxBLACK_BRUSH);
}
}
/////////end draw choords
if (mVisibleAllTracks)
{
- int i;
- for (i = 0; i < mpSong->nTracks; i++)
+ for (int i = 0; i < mpSong->nTracks; ++i)
{
- JZTrack *t = mpSong->GetTrack(i);
- if (t != mpTrack && IsVisible(t))
+ JZTrack* pTrack = mpSong->GetTrack(i);
+ if (pTrack != mpTrack && IsVisible(pTrack))
{
- DrawEvents(Dc, t, StatKeyOn, wxLIGHT_GREY_BRUSH, TRUE);
+ DrawEvents(LocalDc, pTrack, StatKeyOn, wxLIGHT_GREY_BRUSH, TRUE);
}
}
}
if (mVisibleKeyOn)
- DrawEvents(Dc, mpTrack, StatKeyOn, wxRED_BRUSH, FALSE);
+ {
+ DrawEvents(LocalDc, mpTrack, StatKeyOn, wxRED_BRUSH, FALSE);
+ }
if (mVisiblePitch)
- DrawEvents(Dc, mpTrack, StatPitch, wxBLUE_BRUSH, FALSE);
+ {
+ DrawEvents(LocalDc, mpTrack, StatPitch, wxBLUE_BRUSH, FALSE);
+ }
if (mVisibleController)
- DrawEvents(Dc, mpTrack, StatControl, wxCYAN_BRUSH, FALSE);
+ {
+ DrawEvents(LocalDc, mpTrack, StatControl, wxCYAN_BRUSH, FALSE);
+ }
if (mVisibleProgram)
- DrawEvents(Dc, mpTrack, StatProgram, wxGREEN_BRUSH, FALSE);
+ {
+ DrawEvents(LocalDc, mpTrack, StatProgram, wxGREEN_BRUSH, FALSE);
+ }
if (mVisibleTempo)
- DrawEvents(Dc, mpTrack, StatSetTempo, wxGREEN_BRUSH, FALSE);
+ {
+ DrawEvents(LocalDc, mpTrack, StatSetTempo, wxGREEN_BRUSH, FALSE);
+ }
if (mVisibleSysex)
- DrawEvents(Dc, mpTrack, StatSysEx, wxGREEN_BRUSH, FALSE);
+ {
+ DrawEvents(LocalDc, mpTrack, StatSysEx, wxGREEN_BRUSH, FALSE);
+ }
if (mVisiblePlayTrack)
- DrawEvents(Dc, mpTrack, StatPlayTrack, wxLIGHT_GREY_BRUSH, FALSE);
+ {
+ DrawEvents(LocalDc, mpTrack, StatPlayTrack, wxLIGHT_GREY_BRUSH, FALSE);
+ }
- DrawEvents(Dc, mpTrack, StatEndOfTrack, wxRED_BRUSH, FALSE);
- DrawEvents(Dc, mpTrack, StatText, wxBLACK_BRUSH, FALSE);
+ DrawEvents(LocalDc, mpTrack, StatEndOfTrack, wxRED_BRUSH, FALSE);
+ DrawEvents(LocalDc, mpTrack, StatText, wxBLACK_BRUSH, FALSE);
- Dc.SetPen(*wxBLACK_PEN);
- Dc.SetBrush(*wxBLACK_BRUSH);
- Dc.SetBackground(*wxWHITE_BRUSH); // xor-bug
+// LocalDc.SetPen(*wxBLACK_PEN);
+// LocalDc.SetBrush(*wxBLACK_BRUSH);
+// LocalDc.SetBackground(*wxWHITE_BRUSH); // xor-bug
- mpSnapSel->Draw(Dc, mEventsX, mEventsY, mEventsWidth, mEventsHeight);
+ DrawPlayPosition(LocalDc);
- DrawPlayPosition(Dc);
+ // Draw the selection box.
+ mpSnapSel->Draw(LocalDc, mEventsX, mEventsY, mEventsWidth, mEventsHeight);
+
+ Dc.Blit(
+ 0,
+ 0,
+ mCanvasWidth,
+ mCanvasHeight,
+ &LocalDc,
+ 0,
+ 0,
+ wxCOPY);
+
+ LocalDc.SetFont(wxNullFont);
+ LocalDc.SelectObject(wxNullBitmap);
+
+ mDrawing = false;
}
//-----------------------------------------------------------------------------
@@ -964,49 +1024,24 @@
{
Dc.SetBrush(*wxBLACK_BRUSH);
Dc.SetPen(*wxBLACK_PEN);
+
int x = Clock2x(mPlayClock);
-// Dc.SetLogicalFunction(wxXOR);
-
// Draw a line, 2 pixels wide.
- Dc.DrawLine(x, mCanvasY,x, mEventsY + mEventsHeight);
- Dc.DrawLine(x+1,mCanvasY,x+1,mEventsY + mEventsHeight);
-
-// Dc.SetLogicalFunction(wxCOPY);
+ Dc.DrawLine(x, 0, x, mEventsY + mEventsHeight);
+ Dc.DrawLine(x + 1, 0, x + 1, mEventsY + mEventsHeight);
}
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
-void JZPianoWindow::OnEventWinPaintSub(int x, int y)
-{
- mCanvasX = x;
- mCanvasY = y;
- int xc, yc;
- GetClientSize(&xc, &yc);
- mCanvasWidth = xc;
- mCanvasHeight = yc;
-
- mEventsX = mCanvasX + mLeftInfoWidth;
- mEventsY = mCanvasY + mTopInfoHeight;
- mEventsWidth = mCanvasWidth - mLeftInfoWidth;
- mEventsHeight = mCanvasHeight - mTopInfoHeight;
-
- mFromLine = mCanvasY / mTrackHeight;
- mToLine = (mCanvasY + mCanvasHeight - mTopInfoHeight) / mTrackHeight;
- mFromClock = mCanvasX * mClockTicsPerPixel;
- mToClock = x2Clock(mCanvasX + mCanvasWidth);
-}
-
-//-----------------------------------------------------------------------------
-//-----------------------------------------------------------------------------
void JZPianoWindow::OnSize(wxSizeEvent& Event)
{
GetClientSize(&mCanvasWidth, &mCanvasHeight);
if (mCanvasWidth > 0 && mCanvasHeight > 0)
{
- SetScrollRanges(mCanvasX, mCanvasY);
- Refresh(false);
+ mpFrameBuffer->Create(mCanvasWidth, mCanvasHeight);
+ SetScrollRanges();
}
}
@@ -1097,16 +1132,19 @@
mTrackIndex = TrackIndex;
mpTrack = mpSong->GetTrack(mTrackIndex);
mpPianoFrame->SetTitle(mpTrack->GetName());
+
+ SetYScrollPosition(TrackIndex2y(mFromLines[mTrackIndex]));
}
// change position
if (Clock >= 0)
{
int x = Clock2x(Clock);
- SetScrollPosition(x - mLeftInfoWidth, Line2y(mFromLines[mTrackIndex]));
+//OLD SetScrollPosition(x, TrackIndex2y(mFromLines[mTrackIndex]));
+ SetXScrollPosition(x);
}
-// SN++ Ist geaendert. OnPaint zeichnet immer neu -> Bug Fix bei ZoomOut!
+// SN++ Is changed. OnPaint always draws new -> Bug Fix for ZoomOut!
/*
// OnPaint() redraws only if clock has changed
if (mpCtrlEdit && TrackIndex >= 0)
@@ -1117,27 +1155,36 @@
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
-void JZPianoWindow::SetScrollRanges(const int& x, const int& y)
+void JZPianoWindow::SetScrollRanges()
{
- int Width, Height;
- GetVirtualEventSize(Width, Height);
- SetScrollbars(
- mScrollSize,
- mScrollSize,
- Width / mScrollSize,
- Height / mScrollSize,
- x,
- y);
- EnableScrolling(false, false);
+ int EventWidth, EventHeight;
+ GetVirtualEventSize(EventWidth, EventHeight);
+
+ // Must add the thumb size to the passed range to reach the maximum
+ // desired value.
+ int ThumbSize;
+
+ ...
[truncated message content] |