|
From: <pst...@us...> - 2008-04-07 01:06:00
|
Revision: 434
http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=434&view=rev
Author: pstieber
Date: 2008-04-06 18:05:58 -0700 (Sun, 06 Apr 2008)
Log Message:
-----------
1. Fixed scrolled drawing.
2. Made cosmetic changes.
Modified Paths:
--------------
trunk/jazz/src/Harmony.cpp
trunk/jazz/src/HarmonyP.cpp
trunk/jazz/src/HarmonyP.h
Modified: trunk/jazz/src/Harmony.cpp
===================================================================
--- trunk/jazz/src/Harmony.cpp 2008-04-07 00:26:38 UTC (rev 433)
+++ trunk/jazz/src/Harmony.cpp 2008-04-07 01:05:58 UTC (rev 434)
@@ -383,7 +383,7 @@
void HBPlayer::SettingsDialog(wxFrame *parent)
{
#ifdef OBSOLETE
- wxDialogBox *panel = new wxDialogBox(parent, "MIDI settings", FALSE );
+ wxDialogBox *panel = new wxDialogBox(pParent, "MIDI settings", FALSE );
tHBPlayerForm *form = new tHBPlayerForm;
form->Add(wxMakeFormMessage("Note Length for paste into piano window"));
@@ -432,10 +432,9 @@
}
//*****************************************************************************
-// HBCanvas
+// Description:
+// This is the harmony browser window.
//*****************************************************************************
-
-/** painting component for the harmony browser*/
class HBCanvas : public wxScrolledWindow
{
friend class HBSettingsDlg;
@@ -446,21 +445,33 @@
public:
- HBCanvas(wxFrame *parent, int x, int y, int w, int h);
+ HBCanvas(wxFrame* pParent, int x, int y, int w, int h);
+
virtual ~HBCanvas();
- virtual void OnDraw(wxDC& dc);
- void DrawMarkers(const HBContext &c, wxDC* dc);
+ virtual void OnDraw(wxDC& Dc);
+
+ void DrawMarkers(wxDC& Dc, const HBContext &c);
+
void ClearSeq();
- int SeqDefined() { return n_seq > 0; }
+ int SeqDefined()
+ {
+ return n_seq > 0;
+ }
+
int GetChordKeys(int *out, int step, int n_steps);
+
int GetSelectedChord(int *out);
+
int GetSelectedScale(int *out);
+
int GetBassKeys(int *out, int step, int n_steps);
- void SettingsDialog(wxFrame *parent);
+ void SettingsDialog();
+
void OnMenuCommand(int id, wxToolBar *mpToolBar);
+
void TransposeSelection();
HBPlayer player;
@@ -470,54 +481,76 @@
SEQMAX = 256
};
- HBAnalyzer * getAnalyzer();
+ HBAnalyzer* getAnalyzer();
protected:
static const int ScFa;
- void ChordRect(JZRectangle &r, const HBContext &ct);
- void DrawChord(const HBContext &ct);
- void UnDrawChord(const HBContext &ct);
+
+ void ChordRect(JZRectangle& Rectangle, const HBContext &ct);
+
+ void DrawChord(wxDC& Dc, const HBContext &ct);
+
+ void UnDrawChord(wxDC& Dc, const HBContext &ct);
+
bool Find(float x, float y, HBContext &out);
private:
virtual void OnMouseEvent(wxMouseEvent& MouseEvent);
+ void SetMarker(int id, wxToolBar *mpToolBar);
+
+ void SetScaleType(int menu_id, tScaleType st, wxToolBar *tb);
+
private:
+ static tScaleType scale_type;
+
+ static int transpose_res;
+
+ static int analyze_res;
+
float xchord, ychord, wchord, hchord;
+
float ofs;
- wxFrame *parent;
- HBContext *seq[SEQMAX];
+// wxFrame* parent;
+
+ HBContext* seq[SEQMAX];
+
int n_seq;
- char *default_filename;
+ char* default_filename;
+
bool has_changed;
HBContext mouse_context;
bool haunschild_layout;
+
bool mark_4_common;
+
bool mark_3_common;
+
bool mark_2_common;
+
bool mark_1_common;
+
bool mark_b_common;
+
bool mark_0_common;
+
bool mark_1_semi;
+
bool mark_251;
+
bool mark_tritone;
+
bool mark_piano;
- void SetMarker(int id, wxToolBar *mpToolBar);
+
int active_marker;
- static int transpose_res;
- static int analyze_res;
-
- static tScaleType scale_type;
- void SetScaleType(int menu_id, tScaleType st, wxToolBar *tb);
-
DECLARE_EVENT_TABLE()
};
@@ -534,10 +567,12 @@
END_EVENT_TABLE()
-HBCanvas::HBCanvas(wxFrame *p, int x, int y, int w, int h)
- : wxScrolledWindow(p, -1, wxPoint(x, y), wxSize(w, h))
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+HBCanvas::HBCanvas(wxFrame* pParent, int x, int y, int w, int h)
+ : wxScrolledWindow(pParent, wxID_ANY, wxPoint(x, y), wxSize(w, h))
{
- parent = p;
+// parent = pParent;
n_seq = 0;
active_marker = 0;
@@ -688,66 +723,70 @@
}
-void HBCanvas::ChordRect(JZRectangle &r, const HBContext &ct)
+void HBCanvas::ChordRect(JZRectangle& Rectangle, const HBContext &ct)
{
if (ct.SeqNr())
{
- r.x = (int)(xchord + (ct.SeqNr() - 1) % 8 * wchord);
- r.y = (int)(hchord * ((ct.SeqNr() -1) / 8 + 0.5));
+ Rectangle.x = (int)(xchord + (ct.SeqNr() - 1) % 8 * wchord);
+ Rectangle.y = (int)(hchord * ((ct.SeqNr() -1) / 8 + 0.5));
}
else if (!haunschild_layout)
{
- r.x = (int)(xchord + ct.ChordNr() * wchord);
- r.y = (int)(ychord + ct.ScaleNr() * hchord);
+ Rectangle.x = (int)(xchord + ct.ChordNr() * wchord);
+ Rectangle.y = (int)(ychord + ct.ScaleNr() * hchord);
}
else
{
- r.x = (int)(xchord + (5 * ct.ChordNr() % 7 + 5 * ct.ScaleNr() % 12) % 7 * wchord);
- r.y = (int)(ychord + (5 * ct.ScaleNr() % 12) * hchord);
+ Rectangle.x = (int)(xchord + (5 * ct.ChordNr() % 7 + 5 * ct.ScaleNr() % 12) % 7 * wchord);
+ Rectangle.y = (int)(ychord + (5 * ct.ScaleNr() % 12) * hchord);
}
- r.x += (int)ofs;
- r.y -= (int)ofs;
- r.width = (int)(wchord - 2 * ofs);
- r.height = (int)(hchord - 2 * ofs);
+ Rectangle.x += (int)ofs;
+ Rectangle.y -= (int)ofs;
+ Rectangle.width = (int)(wchord - 2 * ofs);
+ Rectangle.height = (int)(hchord - 2 * ofs);
}
-void HBCanvas::DrawChord(const HBContext &ct)
+void HBCanvas::DrawChord(wxDC& Dc, const HBContext &ct)
{
- // draw surrounding box
- JZRectangle r;
- ChordRect(r, ct);
- wxDC *dc = new wxClientDC(this);//GetDC();
- dc->DrawRectangle(r.x, r.y, r.width, r.height);
+ // Draw the surrounding box.
+ JZRectangle Rectangle;
+ ChordRect(Rectangle, ct);
+ Dc.DrawRectangle(
+ Rectangle.x,
+ Rectangle.y,
+ Rectangle.width,
+ Rectangle.height);
+
int w, h;
- const char *name = ct.ChordName();
- dc->GetTextExtent(name, &w, &h);
- dc->DrawText((char *)name, r.x + (r.width - w)/2, r.y + (r.height - h)/2);
- delete dc;
+ const char* pName = ct.ChordName();
+ Dc.GetTextExtent(pName, &w, &h);
+ Dc.DrawText(pName, Rectangle.x + (Rectangle.width - w)/2, Rectangle.y + (Rectangle.height - h)/2);
}
-void HBCanvas::UnDrawChord(const HBContext &ct)
+void HBCanvas::UnDrawChord(wxDC& Dc, const HBContext& ct)
{
// draw surrounding box
- JZRectangle r;
- ChordRect(r, ct);
+ JZRectangle Rectangle;
+ ChordRect(Rectangle, ct);
- wxDC *dc = new wxClientDC(this);//GetDC();
- dc->SetPen(*wxWHITE_PEN);
- dc->DrawRectangle(r.x, r.y, r.width, r.height);
- dc->SetPen(*wxBLACK_PEN);
- delete dc;
+ Dc.SetPen(*wxWHITE_PEN);
+ Dc.DrawRectangle(
+ Rectangle.x,
+ Rectangle.y,
+ Rectangle.width,
+ Rectangle.height);
+ Dc.SetPen(*wxBLACK_PEN);
}
-void HBCanvas::OnDraw(wxDC& dcref)
+void HBCanvas::OnDraw(wxDC& Dc)
{
- wxDC *dc = &dcref; //im just lazy, didnt want to change old code
- dc->Clear();
- dc->DrawText("Seq", 5, 5);
+ Dc.Clear();
+ Dc.DrawText("Seq", 5, 5);
ychord = (n_seq/8 + 1) * hchord + (n_seq % 8 ? hchord : 0) + hchord;
@@ -757,33 +796,33 @@
while (iter())
{
const HBContext &ct = iter.Context();
- DrawChord(ct);
+ DrawChord(Dc, ct);
if (ct.ChordNr() == 0 && ct.SeqNr() == 0)
{
- JZRectangle r;
- ChordRect(r, ct);
- dc->DrawText((char *)ct.ScaleName(), 5, r.y);
+ JZRectangle Rectangle;
+ ChordRect(Rectangle, ct);
+ Dc.DrawText(ct.ScaleName(), 5, Rectangle.y);
}
}
- DrawMarkers(mouse_context, dc);
+ DrawMarkers(Dc, mouse_context);
if (!haunschild_layout)
{
for (int j = 0; j < 7; j++)
{
HBContext ct(0, j, scale_type);
- JZRectangle r;
- ChordRect(r, ct);
- r.y -= (int)hchord;
+ JZRectangle Rectangle;
+ ChordRect(Rectangle, ct);
+ Rectangle.y -= (int)hchord;
int w, h;
const char *name = ct.ChordNrName();
- dc->GetTextExtent(name, &w, &h);
- dc->DrawText((char *)name, r.x + (r.width - w)/2, r.y + (r.height - h)/2);
+ Dc.GetTextExtent(name, &w, &h);
+ Dc.DrawText((char *)name, Rectangle.x + (Rectangle.width - w)/2, Rectangle.y + (Rectangle.height - h)/2);
const char *type = ct.ContextName();
- dc->GetTextExtent(type, &w, &h);
- dc->DrawText((char *)type, r.x + (r.width - w)/2, r.y + (r.height - h)/2 - h);
+ Dc.GetTextExtent(type, &w, &h);
+ Dc.DrawText((char *)type, Rectangle.x + (Rectangle.width - w)/2, Rectangle.y + (Rectangle.height - h)/2 - h);
}
}
@@ -814,10 +853,10 @@
#endif
-void HBCanvas::SettingsDialog(wxFrame *parent)
+void HBCanvas::SettingsDialog()
{
#ifdef OBSOLETE
- wxDialogBox *panel = new wxDialogBox(parent, "settings", FALSE );
+ wxDialogBox *panel = new wxDialogBox(this, "settings", FALSE );
wxForm *form = new HBSettingsForm(this);
panel->SetLabelPosition(wxHORIZONTAL);
@@ -947,42 +986,41 @@
return msg[2] ? 1 : 0;
}
-void HBCanvas::DrawMarkers(const HBContext &ct, wxDC* dc)
+void HBCanvas::DrawMarkers(wxDC& Dc, const HBContext &ct)
{
- JZRectangle r;
- //wxDC *dc = GetDC();
- dc->SetLogicalFunction(wxXOR);
- dc->SetBrush(*wxTRANSPARENT_BRUSH);
+ JZRectangle Rectangle;
+ Dc.SetLogicalFunction(wxXOR);
+ Dc.SetBrush(*wxTRANSPARENT_BRUSH);
HBMatchMarkers match(ct, this);
HBContextIterator iter(match);
iter.SetSequence(seq, n_seq);
iter.SetScaleType(scale_type);
while (iter())
{
- ChordRect(r, iter.Context());
- r.x += 3;
- r.y += 3;
- r.width -= 6;
- r.height -= 6;
- dc->DrawRectangle(r.x, r.y, r.width, r.height);
+ ChordRect(Rectangle, iter.Context());
+ Rectangle.x += 3;
+ Rectangle.y += 3;
+ Rectangle.width -= 6;
+ Rectangle.height -= 6;
+ Dc.DrawRectangle(Rectangle.x, Rectangle.y, Rectangle.width, Rectangle.height);
}
// invert actual chord
if (ct.ScaleType() == scale_type)
{
- dc->SetBrush(*wxBLACK_BRUSH);
- ChordRect(r, ct);
- dc->DrawRectangle(r.x, r.y, r.width, r.height);
+ Dc.SetBrush(*wxBLACK_BRUSH);
+ ChordRect(Rectangle, ct);
+ Dc.DrawRectangle(Rectangle.x, Rectangle.y, Rectangle.width, Rectangle.height);
if (ct.SeqNr() > 0)
{
HBContext c(ct);
c.SetSeqNr(0);
- ChordRect(r, c);
- dc->DrawRectangle(r.x, r.y, r.width, r.height);
+ ChordRect(Rectangle, c);
+ Dc.DrawRectangle(Rectangle.x, Rectangle.y, Rectangle.width, Rectangle.height);
}
}
- dc->SetLogicalFunction(wxCOPY);
- dc->SetBrush(*wxWHITE_BRUSH);
+ Dc.SetLogicalFunction(wxCOPY);
+ Dc.SetBrush(*wxWHITE_BRUSH);
}
bool HBCanvas::Find(float x, float y, HBContext &out)
@@ -992,9 +1030,9 @@
iter.SetScaleType(scale_type);
while (iter())
{
- JZRectangle r;
- ChordRect(r, iter.Context());
- if (r.IsInside((int)x, (int)y))
+ JZRectangle Rectangle;
+ ChordRect(Rectangle, iter.Context());
+ if (Rectangle.IsInside((int)x, (int)y))
{
out = iter.Context();
return TRUE;
@@ -1014,7 +1052,9 @@
void HBCanvas::OnMouseEvent(wxMouseEvent& MouseEvent)
{
- wxDC* dc= new wxClientDC(this);
+ wxClientDC Dc(this);
+ DoPrepareDC(Dc);
+
HBContext context;
int x, y;
MouseEvent.GetPosition(&x, &y);
@@ -1036,12 +1076,12 @@
// remove markers first
if (mouse_context.SeqNr() == n_seq)
{
- DrawMarkers(mouse_context, dc);
+ DrawMarkers(Dc, mouse_context);
mouse_context.SetSeqNr(0);
- DrawMarkers(mouse_context, dc);
+ DrawMarkers(Dc, mouse_context);
}
-- n_seq;
- UnDrawChord(context);
+ UnDrawChord(Dc, context);
context.SetSeqNr(0);
Refresh();
}
@@ -1051,9 +1091,9 @@
// add a chord
context.SetSeqNr(n_seq + 1);
*seq[n_seq ++] = context;
- DrawMarkers(mouse_context, dc);
- DrawChord(context);
- DrawMarkers(mouse_context, dc);
+ DrawMarkers(Dc, mouse_context);
+ DrawChord(Dc, context);
+ DrawMarkers(Dc, mouse_context);
Refresh();
}
}
@@ -1067,10 +1107,10 @@
if (MouseEvent.LeftDown() || MouseEvent.MiddleDown()) // && context != mouse_context)
{
- DrawMarkers(mouse_context, dc);
+ DrawMarkers(Dc, mouse_context);
mouse_context = context;
//mouse_context.SetSeqNr(0);
- DrawMarkers(mouse_context, dc);
+ DrawMarkers(Dc, mouse_context);
// paste to PianoWin buffer
if (!mark_piano && gpTrackFrame->GetPianoWindow())
@@ -1099,7 +1139,6 @@
{
player.StopPlay();
}
- delete dc;
}
@@ -1204,7 +1243,7 @@
break;
case MEN_SETTINGS:
- SettingsDialog(parent);
+ SettingsDialog();
break;
default:
Modified: trunk/jazz/src/HarmonyP.cpp
===================================================================
--- trunk/jazz/src/HarmonyP.cpp 2008-04-07 00:26:38 UTC (rev 433)
+++ trunk/jazz/src/HarmonyP.cpp 2008-04-07 01:05:58 UTC (rev 434)
@@ -265,14 +265,51 @@
const char *const HBContext::context_names[nScaleTypes][7] =
{
- { "ion", "dor", "phry", "lyd", "mixo", "aeol", "locr"},
- { "harm", "locr 13", "ion #5", "dor #11", "HM5", "lyd #9", "har dim"},
- { "melod", "dor b9", "lyd #5", "mixo #11", "mixo b13", "locr 9", "superlocr"},
- { "ion b13", "dor b5", "harm alt", "melod #11", "mixo b9", "lyd #9#5", "locr dim"},
+ {
+ "ion",
+ "dor",
+ "phry",
+ "lyd",
+ "mixo",
+ "aeol",
+ "locr"
+ },
+ {
+ "harm",
+ "locr 13",
+ "ion #5",
+ "dor #11",
+ "HM5",
+ "lyd #9",
+ "har dim"
+ },
+ {
+ "melod",
+ "dor b9",
+ "lyd #5",
+ "mixo #11",
+ "mixo b13",
+ "locr 9",
+ "superlocr"
+ },
+ {
+ "ion b13",
+ "dor b5",
+ "harm alt",
+ "melod #11",
+ "mixo b9",
+ "lyd #9#5",
+ "locr dim"
+ },
};
-const char *const HBContext::scale_type_names[nScaleTypes] =
- { "J", "HM", "MM", "HJ" };
+const char* const HBContext::scale_type_names[nScaleTypes] =
+{
+ "J",
+ "HM",
+ "MM",
+ "HJ"
+};
HBContext::HBContext(int sn, int cn, tScaleType st)
@@ -367,12 +404,16 @@
HBChord chord;
int key = scale_nr;
for (i = 0; i < chord_nr; i++)
+ {
key = scale.Iter(key);
+ }
chord += key;
for (i = 1; i < 4; i++)
{
for (j = 0; j < 2; j++)
+ {
key = scale.Iter(key);
+ }
chord += key;
}
return chord;
@@ -383,7 +424,9 @@
{
int key = scale_nr;
for (int i = 0; i < chord_nr; i++)
+ {
key = scale.Iter(key);
+ }
return key % 12;
}
Modified: trunk/jazz/src/HarmonyP.h
===================================================================
--- trunk/jazz/src/HarmonyP.h 2008-04-07 00:26:38 UTC (rev 433)
+++ trunk/jazz/src/HarmonyP.h 2008-04-07 01:05:58 UTC (rev 434)
@@ -258,60 +258,122 @@
public:
HBContext(int sn, int cn = 0, tScaleType st = Major);
+
HBContext();
- HBChord *PScale() { return &scale; }
- HBChord Scale() const { return scale; }
- HBChord *PChord() { return &chord; }
- HBChord Chord() const { return chord; }
- int ScaleKey() const { return scale_nr; }
- int ChordKey() const { return chord_key; }
- int ChordNr() const { return chord_nr; }
- int ScaleNr() const { return scale_nr; }
- tScaleType ScaleType() const { return scale_type; }
- int SeqNr() const { return seq_nr; }
- void SetSeqNr(int n = 0) { seq_nr = n; }
+ HBChord *PScale()
+ {
+ return &scale;
+ }
- const char * ChordName() const; // "Dm75-"
- const char * ChordNrName() const; // "IV"
- const char * ContextName() const // "mixo#11"
+ HBChord Scale() const
{
+ return scale;
+ }
+
+ HBChord *PChord()
+ {
+ return &chord;
+ }
+
+ HBChord Chord() const
+ {
+ return chord;
+ }
+
+ int ScaleKey() const
+ {
+ return scale_nr;
+ }
+
+ int ChordKey() const
+ {
+ return chord_key;
+ }
+
+ int ChordNr() const
+ {
+ return chord_nr;
+ }
+
+ int ScaleNr() const
+ {
+ return scale_nr;
+ }
+
+ tScaleType ScaleType() const
+ {
+ return scale_type;
+ }
+
+ int SeqNr() const
+ {
+ return seq_nr;
+ }
+
+ void SetSeqNr(int n = 0)
+ {
+ seq_nr = n;
+ }
+
+ const char* ChordName() const; // "Dm75-"
+
+ const char* ChordNrName() const; // "IV"
+
+ const char* ContextName() const // "mixo#11"
+ {
return context_names[scale_type][chord_nr];
}
- const char * ScaleName() const; // "C#"
- const char * ScaleTypeName() const; // "major"
- int operator == (const HBContext &o) const
+ const char* ScaleName() const; // "C#"
+
+ const char* ScaleTypeName() const; // "major"
+
+ int operator == (const HBContext& Rhs) const
{
- return scale_type == o.scale_type &&
- scale_nr == o.scale_nr &&
- chord_nr == o.chord_nr;
+ return
+ scale_type == Rhs.scale_type &&
+ scale_nr == Rhs.scale_nr &&
+ chord_nr == Rhs.chord_nr;
}
- int operator != (const HBContext &o) const { return !operator==(o); }
+ int operator != (const HBContext& Rhs) const
+ {
+ return !operator == (Rhs);
+ }
+
private:
+
void Initialize();
+
HBChord MakeScale() const;
+
HBChord MakeChord() const;
+
int MakeChordKey() const;
tScaleType scale_type;
+
int scale_nr;
+
int chord_nr;
+
int seq_nr;
HBChord chord;
+
HBChord scale;
+
int chord_key;
#if NAME_TABLE
static const char *const chord_names[nScaleTypes][7];
#endif
- static const char *const chord_nr_names[7];
- static const char *const scale_type_names[nScaleTypes];
+ static const char* const chord_nr_names[7];
+ static const char* const scale_type_names[nScaleTypes];
static const int flat_keys[12];
- static const char *const context_names[nScaleTypes][7];
+ static const char* const context_names[nScaleTypes][7];
};
@@ -353,21 +415,46 @@
class HBContextIterator
{
public:
+
HBContextIterator();
+
HBContextIterator(HBMatch &);
- void SetSequence(HBContext *s[], int n) { seq = s; n_seq = n; }
- void SetScaleType(tScaleType st) { scale_type = st; }
+
+ void SetSequence(HBContext *s[], int n)
+ {
+ seq = s;
+ n_seq = n;
+ }
+
+ void SetScaleType(tScaleType st)
+ {
+ scale_type = st;
+ }
+
bool operator()();
- const HBContext *operator->() const { return &context; }
- const HBContext &Context() const { return context; }
+ const HBContext *operator->() const
+ {
+ return &context;
+ }
+
+ const HBContext& Context() const
+ {
+ return context;
+ }
+
private:
+
HBContext context;
- HBMatch &match;
+
+ HBMatch& match;
+
HBMatch def_match;
- HBContext **seq;
+ HBContext** seq;
+
int i_seq, n_seq;
+
tScaleType scale_type;
};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|