From: <pst...@us...> - 2008-03-31 04:12:47
|
Revision: 379 http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=379&view=rev Author: pstieber Date: 2008-03-30 21:12:45 -0700 (Sun, 30 Mar 2008) Log Message: ----------- Moved more data members and code from the track and piano window into the event window. This allowed the removal of the event frame class from other code. Modified Paths: -------------- trunk/jazz/src/ControlEdit.cpp trunk/jazz/src/EventWindow.cpp trunk/jazz/src/EventWindow.h trunk/jazz/src/MouseAction.cpp trunk/jazz/src/MouseAction.h trunk/jazz/src/PianoWindow.cpp trunk/jazz/src/PianoWindow.h trunk/jazz/src/Rhythm.cpp trunk/jazz/src/Rhythm.h trunk/jazz/src/TrackWindow.cpp trunk/jazz/src/TrackWindow.h Modified: trunk/jazz/src/ControlEdit.cpp =================================================================== --- trunk/jazz/src/ControlEdit.cpp 2008-03-31 04:10:22 UTC (rev 378) +++ trunk/jazz/src/ControlEdit.cpp 2008-03-31 04:12:45 UTC (rev 379) @@ -240,7 +240,7 @@ void tCtrlEditBase::OnApply() { wxBeginBusyCursor(); - mpPianoWindow->mpSong->NewUndoBuffer(); + mpPianoWindow->GetSong()->NewUndoBuffer(); // delete old events, but skip clock 0 to preserve track defaults: // (dirty but might work...) tEventIterator iter(track); @@ -360,7 +360,7 @@ // av: called by tArrayEdit::OnPaint void tCtrlEditBase::DrawBars(wxDC* dc) { - JZBarInfo BarInfo(mpPianoWindow->mpSong); + JZBarInfo BarInfo(mpPianoWindow->GetSong()); BarInfo.SetClock(from_clock); long gclk,x; int ii; @@ -515,7 +515,7 @@ static long from_clk, to_clk; wxBeginBusyCursor(); - mpPianoWindow->mpSong->NewUndoBuffer(); + mpPianoWindow->GetSong()->NewUndoBuffer(); tEventIterator iter(track); @@ -618,7 +618,7 @@ } wxBeginBusyCursor(); - mpPianoWindow->mpSong->NewUndoBuffer(); + mpPianoWindow->GetSong()->NewUndoBuffer(); tEventIterator iter(track); @@ -768,7 +768,7 @@ void tChannelAfterEdit::OnApply() { wxBeginBusyCursor(); - mpPianoWindow->mpSong->NewUndoBuffer(); + mpPianoWindow->GetSong()->NewUndoBuffer(); // delete old events, but skip clock 0 to preserve track defaults: // (dirty but might work...) Modified: trunk/jazz/src/EventWindow.cpp =================================================================== --- trunk/jazz/src/EventWindow.cpp 2008-03-31 04:10:22 UTC (rev 378) +++ trunk/jazz/src/EventWindow.cpp 2008-03-31 04:12:45 UTC (rev 379) @@ -34,113 +34,247 @@ using namespace std; -// ************************************************************************ -// tCanvas -// ************************************************************************ +//***************************************************************************** +// Description: +// This is the event window class definition. +//***************************************************************************** +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//BEGIN_EVENT_TABLE(JZEventWindow, wxScrolledWindow) +//END_EVENT_TABLE() -#define ScLine 50L +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +const int JZEventWindow::mScrollSize = 50; +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +JZEventWindow::JZEventWindow( + wxFrame* pParent, + JZSong* pSong, + const wxPoint& Position, + const wxSize& Size) + : wxScrolledWindow( + pParent, + wxID_ANY, + Position, + Size, + wxHSCROLL | wxVSCROLL | wxNO_FULL_REPAINT_ON_RESIZE), + mpSnapSel(0), + mpFilter(0), + mpSong(pSong), + mpGreyColor(0), + mpGreyBrush(0), + mTopInfoHeight(40), + mTrackHeight(10), + mLittleBit(2) +{ + mpSnapSel = new tSnapSelection(this); -//notice, there is a conflict between this and the subclass event tables that i dont know how to resolv -BEGIN_EVENT_TABLE(JZEventFrame, wxFrame) - EVT_SIZE(JZEventFrame::OnSize) -END_EVENT_TABLE() + mpFilter = new JZFilter(mpSong); +#ifdef __WXMSW__ + mpGreyColor = new wxColor(192, 192, 192); +#else + mpGreyColor = new wxColor(220, 220, 220); +#endif -//tCanvas::tCanvas(JZEventFrame *frame, int x, int y, int w, int h, int style) -// : wxScrolledWindow(frame, -1, wxPoint(x, y), wxSize(w, h), style) + mpGreyBrush = new wxBrush(*mpGreyColor, wxSOLID); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +JZEventWindow::~JZEventWindow() +{ + delete mpSnapSel; + delete mpFilter; + delete mpGreyColor; + delete mpGreyBrush; +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +int JZEventWindow::EventsSelected(const wxString& Message) const +{ + if (!mpSnapSel->Selected) + { + wxMessageBox(Message, "Error", wxOK); + return 0; + } + return 1; +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//void JZEventWindow::SetScrollRanges() //{ -// EventWin = frame; +// int Width, Height; +// GetVirtualEventSize(Width, Height); +// SetScrollbars( +// mScrollSize, +// mScrollSize, +// Width / mScrollSize, +// Height / mScrollSize); +// EnableScrolling(false, false); //} -/** -JAVE seems to want to clip the paint area -calls the subclass paint routine +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void JZEventWindow::SetScrollPosition(int x, int y) +{ + x /= mScrollSize; + y /= mScrollSize; + Scroll(x, y); +} -onpaint seems never to get called -*/ +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +int JZEventWindow::y2yLine(int y, int Up) +{ + if (Up) + { + y += mTrackHeight; + } + y -= mTopInfoHeight; + y -= y % mTrackHeight; + y += mTopInfoHeight; + return y; +} -//void tCanvas::OnDraw(wxDC& dc) +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void JZEventWindow::LineText( + wxDC& Dc, + int x, + int y, + int Width, + const char* pString, + int Height, + bool Down) +{ + if (Height <= 0) + { + Height = mTrackHeight; + y = y2yLine(y); + } + if (Width && Height) + { + Dc.SetBrush(*mpGreyBrush); + Dc.SetPen(*wxGREY_PEN); +#ifdef __WXMSW__ + Dc.DrawRectangle(x, y, Width + 1, Height + 1); +#else + Dc.DrawRectangle(x, y, Width, Height); +#endif + x += 1; + y += 1; + Width -= 2; + Height -= 2; + if (Down) + { + Dc.SetPen(*wxBLACK_PEN); + Dc.DrawLine(x, y, x + Width, y); + Dc.DrawLine(x, y, x, y + Height); + Dc.SetPen(*wxWHITE_PEN); + Dc.DrawLine(x + Width, y, x + Width, y + Height); + Dc.DrawLine(x, y + Height, x + Width, y + Height); + } + else + { + Dc.SetPen(*wxWHITE_PEN); + Dc.DrawLine(x, y, x + Width, y); + Dc.DrawLine(x, y, x, y + Height); + Dc.SetPen(*wxBLACK_PEN); + Dc.DrawLine(x + Width, y, x + Width, y + Height); + Dc.DrawLine(x, y + Height, x + Width, y + Height); + } + Dc.SetPen(*wxBLACK_PEN); + x -= 2; + y -= 2; + } + + if (pString && strlen(pString) > 0) + { + wxColor TextBackgroundColor = Dc.GetTextBackground(); + Dc.SetTextBackground(*mpGreyColor); + int TextWidth, TextHeight; + Dc.GetTextExtent(pString, &TextWidth, &TextHeight); + int Margin = (Width - TextWidth) / 2; + if (Margin < mLittleBit) + { + Margin = mLittleBit; + } + Dc.DrawText(pString, x + Margin, y + mLittleBit); + Dc.SetTextBackground(TextBackgroundColor); + } +} + +//----------------------------------------------------------------------------- +// 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 * ScLine, y * ScLine); -// cout << "tCanvas::OnDraw\n"; +// EventWin->OnPaintSub(Dc, x * mScrollSize, y * mScrollSize); +// cout << "JZEventWindow::OnDraw << endl; //} -//the canvas sends events to the subclassed window, i (might)filter the events a bit so as not get all mouse move events -//BEGIN_EVENT_TABLE(tCanvas, wxScrolledWindow) -// EVT_MOUSE_EVENTS(tCanvas::OnMouseEvent) -//// EVT_LEFT_DOWN(tCanvas::OnMouseEvent) -//// EVT_LEFT_UP(tCanvas::OnMouseEvent) -//// EVT_RIGHT_DOWN(tCanvas::OnMouseEvent) -//// EVT_RIGHT_UP(tCanvas::OnMouseEvent) -//END_EVENT_TABLE() - - /** - this mouse handler delegates to the subclased eventwin - */ -//void tCanvas::OnMouseEvent(wxMouseEvent &e) +//----------------------------------------------------------------------------- +// This mouse handler delegates to the subclased event window. +//----------------------------------------------------------------------------- +//void JZEventWindow::OnMouseEvent(wxMouseEvent& MouseEvent) //{ -// EventWin->OnMouseEvent(e); +// EventWin->OnMouseEvent(MouseEvent); //} -/** -probably never called in wx2 -*/ -// void tCanvas::OnEvent(wxMouseEvent &e) -// { -// EventWin->OnMouseEvent(e); -// } +// JAVE the OnChar method seems to be gone in wxwin232, but its documented, so +// I don't know what happened. The OnCharHook should do the same thing +// basically. It was there from the start. OnChar seemd redundant. -//JAVE the OnChar method seems to be gone in wxwin232, but its documented, so i dont know whats happened -//the OnCharHook should do the same thing basically(it was there from the start. OnChar seemd redundant) - -// void tCanvas::OnChar(wxKeyEvent &e) +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +// void JZEventWindow::OnChar(wxKeyEvent& KeyEvent) // { -// if (!EventWin->OnKeyEvent(e)) -// wxWindow::OnChar(e); +// if (!EventWin->OnKeyEvent(KeyEvent)) +// { +// wxWindow::OnChar(KeyEvent); +// } // } -// void JZEventFrame::OnChar(wxKeyEvent& e) +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +// void JZEventFrame::OnChar(wxKeyEvent& KeyEvent) // { -// if (!OnKeyEvent(e)) -// wxFrame::OnChar(e); +// if (!OnKeyEvent(KeyEvent)) +// { +// wxFrame::OnChar(KeyEvent); +// } // } -//bool tCanvas::OnCharHook(wxKeyEvent& e) +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//bool JZEventWindow::OnCharHook(wxKeyEvent& KeyEvent) //{ -// return EventWin->OnKeyEvent(e); +// return EventWin->OnKeyEvent(KeyEvent); //} -bool JZEventFrame::OnCharHook(wxKeyEvent& e) -{ - return OnKeyEvent(e); -} +//***************************************************************************** +// Description: +// This is the event frame class definition. +//***************************************************************************** +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +BEGIN_EVENT_TABLE(JZEventFrame, wxFrame) + EVT_SIZE(JZEventFrame::OnSize) +END_EVENT_TABLE() - -//void tCanvas::SetScrollRanges() -//{ -// int Width, Height; -// EventWin->GetVirtualEventSize(Width, Height); -// SetScrollbars(ScLine, ScLine, Width / ScLine, Height / ScLine); -// EnableScrolling(false, false); -//} - -//void tCanvas::SetScrollPosition(int x, int y) -//{ -// x /= ScLine; -// y /= ScLine; -// Scroll(x, y); -//} - - -// ************************************************************************ -// JZEventFrame -// ************************************************************************ - -// default is 640x442 +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- JZEventFrame::JZEventFrame( wxWindow* pParent, const wxString& Title, @@ -151,7 +285,7 @@ Song(pSong), mpFilter(0), NextWin(0), -// Canvas(0), +// mpEventWindow(0), mpFont(0), mpFixedFont(0), hFixedFont(0), @@ -196,7 +330,6 @@ JZEventFrame::~JZEventFrame() { -// delete Canvas; delete SnapSel; delete mpGreyColor; @@ -219,13 +352,6 @@ void JZEventFrame::CreateMenu() { -#if 0 - wxMenu *menu = new wxMenu; - menu->Append(999, "&MenuItem"); - wxMenuBar *menu_bar = new wxMenuBar; - menu_bar->Append(menu, "&Debug"); - SetMenuBar(menu_bar); -#endif } @@ -236,10 +362,10 @@ */ //void JZEventFrame::CreateCanvas() //{ -// cout << "createcanvas\n"; -// int w, h; -// GetClientSize(&w, &h); -// Canvas = new tCanvas(this, 0, 0, w, h); +// cout << "CreateCanvas" << endl; +// int Width, Height; +// GetClientSize(&Width, &Height); +// mpEventWindow = new JZEventWindow(this, 0, 0, Width, Height); //} /** @@ -251,40 +377,38 @@ CreateMenu(); // CreateCanvas(); -// SnapSel = new tSnapSelection(Canvas); +// SnapSel = new tSnapSelection(mpEventWindow); Setup(); -// Canvas->SetScrollRanges(); -// Canvas->SetScrollPosition(0,0);//this wasnt here before wx2, why? +// mpEventWindow->SetScrollRanges(); +// mpEventWindow->SetScrollPosition(0, 0); //this wasnt here before wx2, why? } -/**initialize the constants used in drawing*/ +// Initialize the constants used in drawing. void JZEventFrame::Setup() { /* int x, y; - wxDC* dc = new wxClientDC(Canvas); - //dc is from Canvas - dc->SetFont(wxNullFont); + wxClientDC Dc(mpEventWindow); + Dc.SetFont(wxNullFont); delete mpFixedFont; mpFixedFont = new wxFont(12, wxSWISS, wxNORMAL, wxNORMAL); - dc->SetFont(*mpFixedFont); - dc->GetTextExtent("M", &x, &y); + Dc.SetFont(*mpFixedFont); + Dc.GetTextExtent("M", &x, &y); hFixedFont = (int)y; delete mpFont; mpFont = new wxFont(FontSize, wxSWISS, wxNORMAL, wxNORMAL); - dc->SetFont(*mpFont); + Dc.SetFont(*mpFont); - dc->GetTextExtent("M", &x, &y); + Dc.GetTextExtent("M", &x, &y); LittleBit = (int)(x/2); - dc->GetTextExtent("HXWjgi", &x, &y); + Dc.GetTextExtent("HXWjgi", &x, &y); mTrackHeight = (int)y + LittleBit; - delete dc; */ } @@ -295,50 +419,56 @@ */ void JZEventFrame::OnSize(wxSizeEvent& Event) { - // wxFrame::OnSize(Event); +// wxFrame::OnSize(Event); - //the below code is from the toolbar sample, the layoutchidlren function - wxSize size = GetClientSize(); + // The code below is from the toolbar sample, the layoutchidlren function + wxSize size = GetClientSize(); - int offset; -// if ( mpToolBar ) -// { -// mpToolBar->SetSize(-1, size.y); -// mpToolBar->Move(0, 0); + int offset; +// if (mpToolBar) +// { +// mpToolBar->SetSize(-1, size.y); +// mpToolBar->Move(0, 0); +// +// offset = mpToolBar->GetSize().x; +// } +// else +// { +// offset = 0; +// } -// offset = mpToolBar->GetSize().x; -// } -// else -// { -// offset = 0; -// } + // The step below should set the offset of the mpEventWindow + // m_textWindow->SetSize(offset, 0, size.x - offset, size.y); - //the step below should set the offset of the Canvas - //m_textWindow->SetSize(offset, 0, size.x - offset, size.y); +// float maxToolBarWidth = 0.0; +// float maxToolBarHeight = 0.0; +// if (mpToolBar) +// { +// mpToolBar->GetMaxSize(&maxToolBarWidth, &maxToolBarHeight); +// } - + offset = mpToolBar->GetSize().y; //get the height of the toolbar -// float maxToolBarWidth = 0.0; -// float maxToolBarHeight = 0.0; -// if (mpToolBar) -// mpToolBar->GetMaxSize(&maxToolBarWidth, &maxToolBarHeight); - - offset = mpToolBar->GetSize().y; //get the height of the toolbar - - int frameWidth, frameHeight; - GetClientSize(&frameWidth, &frameHeight); + int frameWidth, frameHeight; + GetClientSize(&frameWidth, &frameHeight); -// if (Canvas) -// // Canvas->SetSize(0, (int)offset, (int)frameWidth, (int)(frameHeight - offset)); -// Canvas->SetSize(0, (int)0, (int)frameWidth, (int)(frameHeight)); +// if (mpEventWindow) +// // mpEventWindow->SetSize(0, (int)offset, (int)frameWidth, (int)(frameHeight - offset)); +// mpEventWindow->SetSize(0, (int)0, (int)frameWidth, (int)(frameHeight)); // // if (mpToolBar) // // mpToolBar->SetSize(0, 0, (int)frameWidth, (int)maxToolBarHeight); - cout<<"JZEventFrame::OnSize "<<frameWidth<<" "<<frameHeight<<"\n"; + cout + << "JZEventFrame::OnSize " << frameWidth<< 'x' << frameHeight << endl; +} +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +bool JZEventFrame::OnCharHook(wxKeyEvent& e) +{ + return OnKeyEvent(e); +} - } - // ******************************************************************* // Coord-Functions // ******************************************************************* @@ -396,6 +526,7 @@ return Line * mTrackHeight + mTopInfoHeight; } +/* void JZEventFrame::LineText(wxDC *dc, int x, int y, int w, const char *str, int h, bool down) { if (h <= 0) @@ -417,7 +548,8 @@ y += 1; w -= 2; h -= 2; - if (down) { + if (down) + { dc->SetPen(*wxBLACK_PEN); dc->DrawLine(x, y, x+w, y); dc->DrawLine(x, y, x, y+h); @@ -425,7 +557,8 @@ dc->DrawLine(x+w, y, x+w, y+h); dc->DrawLine(x, y+h, x+w, y+h); } - else { + else + { dc->SetPen(*wxWHITE_PEN); dc->DrawLine(x, y, x+w, y); dc->DrawLine(x, y, x, y+h); @@ -441,8 +574,8 @@ dc->DrawText((char *)str, x + LittleBit, y + LittleBit); dc->SetTextBackground(*wxWHITE); } +*/ - // ******************************************************************* // Painting behavior // ******************************************************************* @@ -452,13 +585,13 @@ // wxDC* dc=new wxClientDC(this); // wxPaintEvent e; // cout<<"FIXME JZEventFrame::Redraw"<<endl; -// Canvas->OnDraw(*dc); //this will in turn call the eventwin onpaintsub +// mpEventWindow->OnDraw(*dc); //this will in turn call the eventwin onpaintsub // //the problem is that onpaint no longer tkes no argument, and is supposed to be called from the framework only, so it should be split // delete dc; -// Canvas->Refresh(); +// mpEventWindow->Refresh(); } @@ -468,7 +601,7 @@ 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 Canvas class,and also overridden in the subclass. + 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 @@ -603,7 +736,7 @@ if (Clock > FromClock && ToClock >= Song->MaxQuarters * Song->TicksPerQuarter) return; // int x = Clock2x(Clock); -// Canvas->SetScrollPosition(x - mLeftInfoWidth, CanvasY); +// mpEventWindow->SetScrollPosition(x - mLeftInfoWidth, CanvasY); } if (!SnapSel->Active) // sets clipping @@ -618,13 +751,13 @@ // invalidateRect.width=3; // invalidateRect.height= 100000000; // //DrawPlayPosition(); -// Canvas->Refresh(TRUE,&invalidateRect); +// mpEventWindow->Refresh(TRUE,&invalidateRect); // invalidateRect.x=Clock2x(PlayClock)-1; -// Canvas->Refresh(TRUE,&invalidateRect); +// mpEventWindow->Refresh(TRUE,&invalidateRect); //DrawPlayPosition(); -// Canvas->Refresh(); +// mpEventWindow->Refresh(); } } if (NextWin) @@ -945,10 +1078,10 @@ // int x = CanvasX * 2; // int y = CanvasY; -// wxDC* dc=new wxClientDC(Canvas); +// wxDC* dc=new wxClientDC(mpEventWindow); // JZEventFrame::OnPaintSub(dc, x, y); -// Canvas->SetScrollRanges(); -// Canvas->SetScrollPosition(x, y); +// mpEventWindow->SetScrollRanges(); +// mpEventWindow->SetScrollPosition(x, y); // if (x == 0) // Redraw(); @@ -965,10 +1098,10 @@ // int x = CanvasX / 2; // int y = CanvasY; - //wxDC* dc=new wxClientDC(Canvas); - //JZEventFrame::OnPaintSub(dc, x, y); -// Canvas->SetScrollRanges(); -// Canvas->SetScrollPosition(x, y); + //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-03-31 04:10:22 UTC (rev 378) +++ trunk/jazz/src/EventWindow.h 2008-03-31 04:12:45 UTC (rev 379) @@ -31,45 +31,99 @@ class JZToolBar; class JZPianoFrame; -/** -JAVE i dont get the meaning of this class -it seems to just fork out the method calls to its delegate, EventWin -*/ -/* -class tCanvas: public wxScrolledWindow +//***************************************************************************** +// Description: +// This class is derived from a wxWidgets scrolled window, and acts as the +// common base class for JZTrackWindow and JSPianoWindow. +//***************************************************************************** +class JZEventWindow : public wxScrolledWindow { public: - JZEventFrame *EventWin; - tCanvas(JZEventFrame *frame, int x, int y, int w, int h, int style = 0); - void OnPaint(wxPaintEvent& event); - // void OnEvent(wxMouseEvent& event); - void OnMouseEvent(wxMouseEvent& event); - void OnChar(wxKeyEvent& event); - bool OnCharHook(wxKeyEvent& event); - void SetScrollRanges(); + + tSnapSelection* mpSnapSel; + + JZFilter* mpFilter; + + JZEventWindow( + wxFrame* pParent, + JZSong* pSong, + const wxPoint& Position = wxDefaultPosition, + const wxSize& Size = wxDefaultSize); + + virtual ~JZEventWindow(); + + // WARNING: non-constant access. + JZSong* GetSong() const; + + int EventsSelected(const wxString& Message) const; + + void LineText( + wxDC& Dc, + int x, + int y, + int Width, + const char* pString, + int Height = -1, + bool Down = false); + +// void SetScrollRanges(); + void SetScrollPosition(int x, int y); - void OnDraw(wxDC& dc); - DECLARE_EVENT_TABLE() -}; -*/ + protected: -/** - * JZEventFrame - * - * A window with Panel, Canvas, Scrollbars, Menus, - * common baseclass for TrackWin and PianoWin. - * - *Panel, menu is administered by derived class - * Funktionen - * - Settings dialog - * - Selection via Snapsel - */ +// void OnPaint(wxPaintEvent& Event); +// void OnMouseEvent(wxMouseEvent& Event); +// void OnChar(wxKeyEvent& Event); +// bool OnCharHook(wxKeyEvent& Event); +// void OnDraw(wxDC& Dc); + int y2yLine(int y, int Up = 0); + protected: + + static const int mScrollSize; + + JZSong* mpSong; + +// JZEventFrame* mpEventFrame; + + wxColor* mpGreyColor; + wxBrush* mpGreyBrush; + + int mTopInfoHeight; + int mTrackHeight; + int mLittleBit; + + +// DECLARE_EVENT_TABLE() +}; + +//***************************************************************************** +// Description: +// These are the event window inline member functions. +//***************************************************************************** +//----------------------------------------------------------------------------- +// WARNING: non-constant access. +//----------------------------------------------------------------------------- +inline +JZSong* JZEventWindow::GetSong() const +{ + return mpSong; +} + +//***************************************************************************** +// Description: +// A frame window that containes a scrolled event window. Acts as the +// common base class for JZTrackFrame and JSPianoFrame. +// +// The panel and menu are administered by derived classes. +// Functionality: +// - Settings dialog +// - Selection via Snapsel +//***************************************************************************** class JZEventFrame : public wxFrame { - public: bool OnCharHook(wxKeyEvent& event); @@ -96,7 +150,7 @@ virtual void Create(); virtual void CreateMenu(); void CreateCanvas(); -// tCanvas* Canvas; +// JZEventWindow* mpEventWindow; // Setup() wxFont* mpFont; @@ -132,7 +186,7 @@ int y2Line(int y, int up = 0); 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); +// 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); Modified: trunk/jazz/src/MouseAction.cpp =================================================================== --- trunk/jazz/src/MouseAction.cpp 2008-03-31 04:10:22 UTC (rev 378) +++ trunk/jazz/src/MouseAction.cpp 2008-03-31 04:12:45 UTC (rev 379) @@ -22,10 +22,8 @@ #include "WxWidgets.h" -//#include "config.h" #include "MouseAction.h" #include "EventWindow.h" -#include "DeprecatedStringUtils.h" using namespace std; @@ -520,42 +518,75 @@ return 1; } -// ------------------------------------------------------------------------- +//***************************************************************************** // tMouseButton - simulate a 3D button -// ------------------------------------------------------------------------- - +//***************************************************************************** +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- tMouseButton::tMouseButton( - JZEventFrame *win, - JZRectangle* r, - const char *down, - const char *up) + JZEventWindow* pEventWindow, + JZRectangle* pRectangle, + const char* pDownString, + const char* pUpString) + : mpEventWindow(pEventWindow), + mRectangle(*pRectangle), + mDownString(), + mUpString() { - this->win = win; - this->r = *r; - if (up == 0) - up = down; - this->down = copystring(down); - this->up = copystring(up); - wxDC* dc=new wxClientDC(win); - win->LineText(dc, r->x, r->y, r->width, (char *)down, r->height, TRUE); + if (pDownString) + { + mDownString = pDownString; + } + + if (pUpString) + { + mUpString = pUpString; + } + else + { + mUpString = mDownString; + } + + wxClientDC Dc(mpEventWindow); + + mpEventWindow->LineText( + Dc, + mRectangle.x, + mRectangle.y, + mRectangle.GetWidth(), + mDownString.c_str(), + mRectangle.GetHeight(), + true); } +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- tMouseButton::~tMouseButton() { - delete [] (char *)up; // msvc is buggy! - delete [] (char *)down; } -int tMouseButton::Event(wxMouseEvent &e) +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +int tMouseButton::Event(wxMouseEvent& MouseEvent) { - if (e.ButtonUp()) + if (MouseEvent.ButtonUp()) { Action(); - wxDC* dc=new wxClientDC(win); - win->LineText(dc, r.x, r.y, r.width, (char *)up, r.height, false); + + wxClientDC Dc(mpEventWindow); + + mpEventWindow->LineText( + Dc, + mRectangle.x, + mRectangle.y, + mRectangle.GetWidth(), + mUpString.c_str(), + mRectangle.GetHeight(), + false); + delete this; + return 1; } return 0; } - Modified: trunk/jazz/src/MouseAction.h =================================================================== --- trunk/jazz/src/MouseAction.h 2008-03-31 04:10:22 UTC (rev 378) +++ trunk/jazz/src/MouseAction.h 2008-03-31 04:12:45 UTC (rev 379) @@ -29,6 +29,8 @@ #include "Rectangle.h" +class JZEventWindow; + enum TEMousePlayMode { eMouse, @@ -38,9 +40,12 @@ eRecordButton }; +//***************************************************************************** +//***************************************************************************** class tMouseMapper { public: + // actions // 0..2 = left/middle/right down // 3..5 = left/middle/right down + shift @@ -50,57 +55,96 @@ tMouseMapper(const int actions[12]); tMouseMapper(); - enum Button { Left, Middle, Right }; - void SetAction(int code, Button but = Left, bool shift = FALSE, bool ctrl = FALSE); - int Action(wxMouseEvent &); - void SetLeftAction(int id = 0) { left_action = id; } + enum Button + { + Left, + Middle, + Right + }; + void SetAction( + int code, + Button but = Left, + bool shift = false, + bool ctrl = false); + + int Action(wxMouseEvent&); + + void SetLeftAction(int id = 0) + { + left_action = id; + } + private: + int actions[12]; + int left_action; }; -/** -base class for mouse actions. the classes are instantiated in the mousehandler of eventwin, for example, to keep state during mouse operations, like drag and drop and so on. - -the event() finction is used to determine what to do with an incoming event(normally, if the event is a drag event call the drag function of the class, and so on) -*/ +//***************************************************************************** +// Description: +// This is a base class for mouse actions. The classes are instantiated in +// the mouse handler of the event window, for example, to keep state during +// mouse operations, like drag and drop and so on. +// The Event() function is used to determine what to do with an incoming +// event. Normally, if the event is a drag event, call the drag function of +// the class, and so on. +//***************************************************************************** class tMouseAction { public: + virtual ~tMouseAction() {} - virtual int Dragging(wxMouseEvent &) { return 0; }; - virtual int LeftDown(wxMouseEvent &) { return 0; }; - virtual int LeftUp(wxMouseEvent &) { return 0; }; - virtual int RightDown(wxMouseEvent &) { return 0; }; - virtual int RightUp(wxMouseEvent &) { return 0; }; - virtual int MiddleDown(wxMouseEvent &) { return 0; }; - virtual int MiddleUp(wxMouseEvent &) { return 0; }; - virtual int Event(wxMouseEvent &e) + virtual int Dragging(wxMouseEvent &) { return 0; } + virtual int LeftDown(wxMouseEvent &) { return 0; } + virtual int LeftUp(wxMouseEvent &) { return 0; } + virtual int RightDown(wxMouseEvent &) { return 0; } + virtual int RightUp(wxMouseEvent &) { return 0; } + virtual int MiddleDown(wxMouseEvent &) { return 0; } + virtual int MiddleUp(wxMouseEvent &) { return 0; } + virtual int Event(wxMouseEvent& MouseEvent) { - if (e.Dragging()) return Dragging(e); - else if (e.LeftDown()) return LeftDown(e); - else if (e.LeftUp()) return LeftUp(e); - else if (e.MiddleDown()) return MiddleDown(e); - else if (e.MiddleUp()) return MiddleUp(e); - else if (e.RightDown()) return RightDown(e); - else if (e.RightUp()) return RightUp(e); + if (MouseEvent.Dragging()) + { + return Dragging(MouseEvent); + } + else if (MouseEvent.LeftDown()) + { + return LeftDown(MouseEvent); + } + else if (MouseEvent.LeftUp()) + { + return LeftUp(MouseEvent); + } + else if (MouseEvent.MiddleDown()) + { + return MiddleDown(MouseEvent); + } + else if (MouseEvent.MiddleUp()) + { + return MiddleUp(MouseEvent); + } + else if (MouseEvent.RightDown()) + { + return RightDown(MouseEvent); + } + else if (MouseEvent.RightUp()) + { + return RightUp(MouseEvent); + } return 0; } }; -/** - Selection - draw a rectangle with the mouse, selecting events - - this class needs to draw in the window, thus it needs acess to the device context of the -window. This was by storing a wxCanvas pointer in wxwin168, but wxCanvas is gone in wxwin2. -on the other hand we can now draw in all windows. - - -*/ - - +//***************************************************************************** +// Description: +// Selection - draw a rectangle with the mouse, selecting events +// This class needs to draw in the window, thus it needs access to the +// device context of the window. This was by storing a wxCanvas pointer +// in wxwin168, but wxCanvas is gone in wxwin2. +//***************************************************************************** class tSelection : public tMouseAction { public: @@ -125,30 +169,31 @@ private: wxScrolledWindow* win; + // wxCanvas *Canvas; wxBrush* mpBackgroundBrush; }; +//***************************************************************************** +//***************************************************************************** class tSnapSelection : public tSelection { -protected: - int *xCoords, nxCoords; - int *yCoords, nyCoords; - int xMin, xMax, xStep, yMin, yMax, yStep; + public: + tSnapSelection(wxScrolledWindow *c); + virtual void Snap(float &x, float &y, int up); + void SetXSnap(int ny, int *cx); + void SetYSnap(int ny, int *cy); + void SetXSnap(int xMin, int xMax, int xStep); + void SetYSnap(int yMin, int yMax, int yStep); -public: - tSnapSelection(wxScrolledWindow *c); - virtual void Snap(float &x, float &y, int up); - void SetXSnap(int ny, int *cx); - void SetYSnap(int ny, int *cy); - void SetXSnap(int xMin, int xMax, int xStep); - void SetYSnap(int yMin, int yMax, int yStep); + protected: + int *xCoords, nxCoords; + int *yCoords, nyCoords; + int xMin, xMax, xStep, yMin, yMax, yStep; }; -class JZEventFrame; - - +//***************************************************************************** /** tButtonLabelInterface @@ -158,6 +203,7 @@ indicates if the text should be displayed in a depressed button or a normal button. */ +//***************************************************************************** class tButtonLabelInterface { public: @@ -172,10 +218,12 @@ }; +//***************************************************************************** /** MouseCounter - let you enter numbers with left/right mouse button */ +//***************************************************************************** class tMouseCounter : public wxTimer, public tMouseAction { int Min, Max, Delta; @@ -196,10 +244,9 @@ }; -// ------------------------------------------------------------------------- +//***************************************************************************** // tMarkDestin - mark destination of some operation -// ------------------------------------------------------------------------- - +//***************************************************************************** class tMarkDestin : public tMouseAction { wxScrolledWindow *Canvas; @@ -215,23 +262,38 @@ tMarkDestin(wxScrolledWindow *canvas, wxFrame *frame, int left); }; -// ------------------------------------------------------------------------- +//***************************************************************************** // tMouseButton - simulate a 3D button -// ------------------------------------------------------------------------- - +//***************************************************************************** class tMouseButton : public tMouseAction { public: - tMouseButton(JZEventFrame *win, JZRectangle *r, const char *down, const char *up = 0); + + tMouseButton( + JZEventWindow* pEventWindow, + JZRectangle* pRectangle, + const char* pDownString, + const char* upUpString = 0); + virtual ~tMouseButton(); - virtual int Event(wxMouseEvent &e); + + virtual int Event(wxMouseEvent& MouseEvent); + protected: - virtual void Action() {} + + virtual void Action() + { + } + private: - JZEventFrame *win; - JZRectangle r; - const char *down; - const char *up; + + JZEventWindow* mpEventWindow; + + JZRectangle mRectangle; + + wxString mDownString; + + wxString mUpString; }; #endif // !defined(JZ_MOUSEACTION_H) Modified: trunk/jazz/src/PianoWindow.cpp =================================================================== --- trunk/jazz/src/PianoWindow.cpp 2008-03-31 04:10:22 UTC (rev 378) +++ trunk/jazz/src/PianoWindow.cpp 2008-03-31 04:12:45 UTC (rev 379) @@ -223,7 +223,7 @@ Win = w; // SN++ BUG FIX: undo/redo - Win->mpSong->NewUndoBuffer(); + Win->GetSong()->NewUndoBuffer(); wxClientDC Dc(Win); @@ -336,7 +336,7 @@ Win = w; // SN++ BUG FIX: undo/redo - Win->mpSong->NewUndoBuffer(); + Win->GetSong()->NewUndoBuffer(); // wxClientDC Dc(Win); Win->PrepareDC(Dc); @@ -412,7 +412,7 @@ mpKeyOn = pEvent; // SN++ BUG FIX: undo/redo - Win->mpSong->NewUndoBuffer(); + Win->GetSong()->NewUndoBuffer(); // wxClientDC Dc(Win); Dc.SetFont(*(Win->GetFixedFont())); @@ -528,7 +528,7 @@ //***************************************************************************** //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -BEGIN_EVENT_TABLE(JZPianoWindow, wxScrolledWindow) +BEGIN_EVENT_TABLE(JZPianoWindow, JZEventWindow) EVT_SIZE(JZPianoWindow::OnSize) @@ -538,10 +538,6 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -const int JZPianoWindow::mScrollSize = 50; - -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- JZListen JZPianoWindow::mListen; //----------------------------------------------------------------------------- @@ -550,18 +546,14 @@ JZPianoFrame* pPianoFrame, JZSong* pSong, const wxPoint& Position, - const wxSize& Size, - long WindowStyle) - : wxScrolledWindow(pPianoFrame, wxID_ANY, Position, Size, WindowStyle), + const wxSize& Size) + : JZEventWindow(pPianoFrame, pSong, Position, Size), mpPianoFrame(pPianoFrame), - mpSong(pSong), mPlayClock(-1), mSnapCount(0), mpMouseAction(0), - mpSnapSel(0), mpTrack(0), mTrackIndex(0), - mpFilter(0), mpCtrlEdit(0), mMousePlay(play_actions), mMouseEvent(evnt_actions), @@ -601,14 +593,10 @@ { InitColors(); - mpFilter = new JZFilter(mpSong); - mpTrack = mpSong->GetTrack(mTrackIndex); mFontSize = mPianoFontSizes[1]; // Must be an entry in the array. - mpSnapSel = new tSnapSelection(this); - for (int i = 0; i < eMaxTrackCount; i++) { mFromLines[i] = 64; @@ -627,7 +615,6 @@ delete mpFont; delete mpFixedFont; delete mpDrumFont; - delete mpSnapSel; delete mpGuitarFrame; } @@ -651,22 +638,17 @@ //----------------------------------------------------------------------------- void JZPianoWindow::Setup() { - // This section is from JZEventFrame::Setup() - - int Width, Height; - wxClientDC Dc(this); Dc.SetFont(wxNullFont); delete mpFixedFont; mpFixedFont = new wxFont(12, wxSWISS, wxNORMAL, wxNORMAL); - Dc.SetFont(*mpFixedFont); - Dc.GetTextExtent("M", &Width, &Height); - mFixedFontHeight = Height; - mTopInfoHeight = mFixedFontHeight + 2 * mLittleBit; + int Width, Height; + Dc.GetTextExtent("M", &Width, &mFixedFontHeight); + delete mpFont; mpFont = new wxFont(mFontSize, wxSWISS, wxNORMAL, wxNORMAL); Dc.SetFont(*mpFont); @@ -674,8 +656,10 @@ Dc.GetTextExtent("M", &Width, &Height); mLittleBit = Width / 2; + mTopInfoHeight = mFixedFontHeight + 2 * mLittleBit; + Dc.GetTextExtent("HXWjgi", &Width, &Height); - mTrackHeight = Height + mLittleBit; + mTrackHeight = Height + 2 * mLittleBit; delete mpDrumFont; mpDrumFont = new wxFont(mFontSize + 3, wxSWISS, wxNORMAL, wxNORMAL); @@ -1118,15 +1102,6 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -void JZPianoWindow::SetScrollPosition(int x, int y) -{ - x /= mScrollSize; - y /= mScrollSize; - Scroll(x, y); -} - -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- int JZPianoWindow::Line2y(int Line) { return Line * mTrackHeight + mTopInfoHeight; @@ -1587,7 +1562,6 @@ // ------------------------------------------------------------------------ // Snapper // ------------------------------------------------------------------------ - void JZPianoWindow::SnapSelStop(wxMouseEvent& Event) { if (mpSnapSel->Selected) Modified: trunk/jazz/src/PianoWindow.h =================================================================== --- trunk/jazz/src/PianoWindow.h 2008-03-31 04:10:22 UTC (rev 378) +++ trunk/jazz/src/PianoWindow.h 2008-03-31 04:12:45 UTC (rev 379) @@ -23,6 +23,7 @@ #ifndef JZ_PIANOWINDOW_H #define JZ_PIANOWINDOW_H +#include "EventWindow.h" #include "MouseAction.h" #include "Track.h" #include "Globals.h" @@ -36,10 +37,8 @@ class tSnapSelection; class JZGuitarFrame; -// ------------------------------------------------------------------------- -// MousePiano -// ------------------------------------------------------------------------- - +//***************************************************************************** +//***************************************************************************** class JZListen : public wxTimer { public: @@ -63,7 +62,9 @@ JZTrack* mpTrack; }; -class JZPianoWindow : public wxScrolledWindow, public tButtonLabelInterface +//***************************************************************************** +//***************************************************************************** +class JZPianoWindow : public JZEventWindow, public tButtonLabelInterface { public: @@ -71,8 +72,7 @@ JZPianoFrame* pFrame, JZSong* pSong, const wxPoint& Position = wxDefaultPosition, - const wxSize& Size = wxDefaultSize, - long WindowStyle = 0); + const wxSize& Size = wxDefaultSize); virtual ~JZPianoWindow(); @@ -201,8 +201,6 @@ public: - JZSong* mpSong; - int mFromLines[eMaxTrackCount]; int mPlayClock; @@ -220,12 +218,8 @@ tEventArray mPasteBuffer; - tSnapSelection* mpSnapSel; - public: - void SetScrollPosition(int x, int y); - void SetScrollRanges(const int& x, const int& y); void DrawEvent( @@ -313,16 +307,12 @@ private: - static const int mScrollSize; - static JZListen mListen; JZTrack* mpTrack; int mTrackIndex; - JZFilter* mpFilter; - tCtrlEditBase* mpCtrlEdit; tMouseMapper mMousePlay; Modified: trunk/jazz/src/Rhythm.cpp =================================================================== --- trunk/jazz/src/Rhythm.cpp 2008-03-31 04:10:22 UTC (rev 378) +++ trunk/jazz/src/Rhythm.cpp 2008-03-31 04:12:45 UTC (rev 379) @@ -492,7 +492,7 @@ //#include "Bitmaps/rrggen.xpm" //#include "Bitmaps/help.xpm" -tRhythmWin::tRhythmWin(JZEventFrame *e, JZSong *s) +tRhythmWin::tRhythmWin(JZEventWindow* pEventWindow, JZSong* pSong) : wxFrame( 0, wxID_ANY, @@ -501,11 +501,11 @@ gpConfig->GetValue(C_RhythmXpos), gpConfig->GetValue(C_RhythmYpos)), wxSize(640, 580)), - edit(0) + edit(0), + mpEventWindow(pEventWindow), + mpSong(pSong) { #ifdef OBSOLETE - event_win = e; - song = s; in_create = 1; n_instruments = 0; act_instrument = -1; @@ -1022,10 +1022,14 @@ void tRhythmWin::GenRhythm() { - if (!event_win->EventsSelected("please mark destination track in trackwin")) + if ( + !mpEventWindow->EventsSelected( + "Please mark the destination track in the track window")) + { return; + } - JZFilter* pFilter = event_win->mpFilter; + JZFilter* pFilter = mpEventWindow->mpFilter; if (pFilter->FromTrack != pFilter->ToTrack) { @@ -1035,8 +1039,8 @@ long fr_clock = pFilter->FromClock; long to_clock = pFilter->ToClock; - JZTrack *track = song->GetTrack(pFilter->FromTrack); - song->NewUndoBuffer(); + JZTrack *track = mpSong->GetTrack(pFilter->FromTrack); + mpSong->NewUndoBuffer(); // remove selection //if (wxMessageBox("Erase destination before generating?", "Replace", wxYES_NO) == wxYES) @@ -1048,7 +1052,7 @@ for (int i = 0; i < n_instruments; i++) instruments[i]->GenInit(fr_clock); - JZBarInfo bar_info(song); + JZBarInfo bar_info(mpSong); bar_info.SetClock(fr_clock); // for (int i = 0; i < n_instruments; i++) @@ -1063,7 +1067,7 @@ track->Cleanup(); - event_win->Redraw(); + mpEventWindow->Refresh(); } Modified: trunk/jazz/src/Rhythm.h =================================================================== --- trunk/jazz/src/Rhythm.h 2008-03-31 04:10:22 UTC (rev 378) +++ trunk/jazz/src/Rhythm.h 2008-03-31 04:12:45 UTC (rev 379) @@ -30,7 +30,7 @@ #include <iostream> class JZTrack; -class JZEventFrame; +class JZEventWindow; class JZSong; class JZBarInfo; @@ -113,6 +113,24 @@ class tRhythmWin : public wxFrame { + public: + + tRhythmWin(JZEventWindow* pEventWindow, JZSong* pSong); + + virtual ~tRhythmWin(); + + virtual void OnMenuCommand(int id); + + virtual void OnSize(int w, int h); + + void OnPaint(); + + void GenRhythm(); + + bool OnClose(); + + private: + friend std::ostream& operator << (std::ostream& os, tRhythmWin const &a); friend std::istream& operator >> (std::istream& is, tRhythmWin &a); @@ -164,8 +182,8 @@ void AddInstrument(tRhythm *r); void DelInstrument(); - JZEventFrame *event_win; - JZSong *song; + JZEventWindow* mpEventWindow; + JZSong* mpSong; void RndEnable(); @@ -178,15 +196,6 @@ void DownInstrument(); void InitInstrumentList(); - public: - - virtual void OnMenuCommand(int id); - virtual void OnSize(int w, int h); - tRhythmWin(JZEventFrame *parent, JZSong *song); - virtual ~tRhythmWin(); - void OnPaint(); - void GenRhythm(); - bool OnClose(); }; extern tRhythmWin *rhythm_win; Modified: trunk/jazz/src/TrackWindow.cpp =================================================================== --- trunk/jazz/src/TrackWindow.cpp 2008-03-31 04:10:22 UTC (rev 378) +++ trunk/jazz/src/TrackWindow.cpp 2008-03-31 04:12:45 UTC (rev 379) @@ -40,42 +40,32 @@ //***************************************************************************** //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -BEGIN_EVENT_TABLE(JZTrackWindow, wxScrolledWindow) +BEGIN_EVENT_TABLE(JZTrackWindow, JZEventWindow) + EVT_SIZE(JZTrackWindow::OnSize) + EVT_ERASE_BACKGROUND(JZTrackWindow::OnEraseBackground) + + EVT_LEFT_DOWN(JZTrackWindow::OnLeftButtonDown) + EVT_LEFT_UP(JZTrackWindow::OnLeftButtonUp) + EVT_RIGHT_UP(JZTrackWindow::OnRightButtonUp) + END_EVENT_TABLE() //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -const int JZTrackWindow::mScrollSize = 50; - -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- JZTrackWindow::JZTrackWindow( wxFrame* pParent, JZSong* pSong, const wxPoint& Position, const wxSize& Size) - : wxScrolledWindow( - pParent, - wxID_ANY, - Position, - Size, - wxHSCROLL | wxVSCROLL | wxNO_FULL_REPAINT_ON_RESIZE), - mpFilter(0), - mpSnapSel(0), - mpSong(pSong), - mpGreyColor(0), - mpGreyBrush(0), - mTrackHeight(10), - mTopInfoHeight(40), + : JZEventWindow(pParent, pSong, Position, Size), mLeftInfoWidth(100), mClocksPerPixel(36), mPlayClock(-1), mUseColors(true), - mLittleBit(2), mEventsX(), mEventsY(), mEventsWidth(), @@ -107,18 +97,6 @@ mDrawing(false), mpFrameBuffer(0) { -#ifdef __WXMSW__ - mpGreyColor = new wxColor(192, 192, 192); -#else - mpGreyColor = new wxColor(220, 220, 220); -#endif - - mpGreyBrush = new wxBrush(*mpGreyColor, wxSOLID); - - mpSnapSel = new tSnapSelection(this); - - mpFilter = new JZFilter(mpSong); - SetBackgroundColour(*wxWHITE); mpFrameBuffer = new wxBitmap; @@ -128,12 +106,8 @@ //----------------------------------------------------------------------------- JZTrackWindow::~JZTrackWindow() { - delete mpGreyColor; - delete mpGreyBrush; delete mpFixedFont; delete mpFont; - delete mpSnapSel; - delete mpFilter; delete mpFrameBuffer; } @@ -159,11 +133,11 @@ Dc.GetTextExtent("M", &Width, &Height); mLittleBit = Width / 2; + mTopInfoHeight = mFixedFontHeight + 2 * mLittleBit; + Dc.GetTextExtent("HXWjgi", &Width, &Height); mTrackHeight = Height + 2 * mLittleBit; - mTopInfoHeight = mFixedFontHeight + 2 * mLittleBit; - Dc.GetTextExtent("999", &Width, &Height); mNumberWidth = Width + 2 * mLittleBit; @@ -284,6 +258,20 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- +void JZTrackWindow::OnLeftButtonDown(wxMouseEvent& Event) +{ + wxPoint Point = Event.GetPosition(); + + if ( + Point.x >= mEventsX && Point.x < mEventsX + mEventsWidth && + Point.y >= mEventsY && Point.y < mEventsY + mEventsHeight) + { + SnapSelectionStart(Event); + } +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void JZTrackWindow::OnLeftButtonUp(wxMouseEvent& Event) { wxPoint Point = Event.GetPosition(); @@ -353,6 +341,12 @@ { ToggleTrackState(Point); } + else if ( + Point.x >= mEventsX && Point.x < mEventsX + mEventsWidth && + Point.y >= mEventsY && Point.y < mEventsY + mEventsHeight) + { + SnapSelectionStop(Event); + } } //----------------------------------------------------------------------------- @@ -1098,20 +1092,6 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -int JZTrackWindow::y2yLine(int y, int Up) -{ - if (Up) - { - y += mTrackHeight; - } - y -= mTopInfoHeight; - y -= y % mTrackHeight; - y += mTopInfoHeight; - return y; -} - -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- int JZTrackWindow::x2Clock(int x) { return (x - mEventsX) * mClocksPerPixel + mFromClock; @@ -1191,15 +1171,6 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -void JZTrackWindow::SetScrollPosition(int x, int y) -{ - x /= mScrollSize; - y /= mScrollSize; - Scroll(x, y); -} - -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- void JZTrackWindow::MousePlay(wxMouseEvent& Event, TEMousePlayMode Mode) { if (Mode == eMouse && !Event.ButtonDown()) @@ -1367,3 +1338,30 @@ } } } + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void JZTrackWindow::SnapSelectionStart(wxMouseEvent& Event) +{ + mpSnapSel->SetXSnap(mBarCount, mBarX); + mpSnapSel->SetYSnap( + TrackIndex2y(mFromLine), + mEventsY + mEventsHeight, + mTrackHeight); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void JZTrackWindow::SnapSelectionStop(wxMouseEvent& Event) +{ + if (mpSnapSel->Selected) + { + mpFilter->FromTrack = y2TrackIndex(mpSnapSel->r.y); + mpFilter->ToTrack = y2TrackIndex( + mpSnapSel->r.y + mpSnapSel->r.GetHeight() - 1); + mpFilter->FromClock = x2BarClock(mpSnapSel->r.x + 1); + mpFilter->ToClock = x2BarClock( + mpSnapSel->r.x + mpSnapSel->r.GetWidth() + 1); +// NextWin->NewPosition(mpFilter->FromTrack, mpFilter->FromClock); + } +} Modified: trunk/jazz/src/TrackWindow.h =================================================================== --- trunk/jazz/src/TrackWindow.h 2008-03-31 04:10:22 UTC (rev 378) +++ trunk/jazz/src/TrackWindow.h 2008-03-31 04:12:45 UTC (rev 379) @@ -23,6 +23,7 @@ #ifndef JZ_TRACKWINDOW_H #define JZ_TRACKWINDOW_H +#include "EventWindow.h" #include "MouseAction.h" #include "Rectangle.h" @@ -50,14 +51,12 @@ eNmModes }; -class JZTrackWindow : public wxScrolledWindow +//***************************************************************************** +//***************************************************************************** +class JZTrackWindow : public JZEventWindow { public: - JZFilter* mpFilter; - - tSnapSelection* mpSnapSel; - enum TELimits { eMaxBars = 200 @@ -85,8 +84,6 @@ void SetScrollRanges(const int& x, const int& y); - void SetScrollPosition(int x, int y); - private: void GetVirtualEventSize(int& Width, int& Height) const; @@ -95,6 +92,8 @@ void OnEraseBackground(wxEraseEvent& Event); + void OnLeftButtonDown(wxMouseEvent& Event); + void OnLeftButtonUp(wxMouseEvent& Event); void OnRightButtonUp(wxMouseEvent& Event); @@ -132,6 +131,10 @@ const char* GetNumberString() const; + void SnapSelectionStart(wxMouseEvent& Event); + + void SnapSelectionStop(wxMouseEvent& Event); + // Was the VLine macro void DrawVerticalLine(wxDC& Dc, int XPosition) const; @@ -154,24 +157,12 @@ int x2BarClock(int x, int Next = 0); - int y2yLine(int y, int Up = 0); - private: - static const int mScrollSize; - - JZSong* mpSong; - - wxColor* mpGreyColor; - wxBrush* mpGreyBrush; - - int mTrackHeight; - int mTopInfoHeight; int mLeftInfoWidth; int mClocksPerPixel; int mPlayClock; bool mUseColors; - int mLittleBit; int mEventsX, mEventsY, mEventsWidth, mEventsHeight; int mScrolledX, mScrolledY; int mCanvasWidth, mCanvasHeight; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |