-rw-r--r-- | noncore/multimedia/powerchord/fretboard.cpp | 16 | ||||
-rw-r--r-- | noncore/multimedia/powerchord/powerchordbase.cpp | 17 |
2 files changed, 16 insertions, 17 deletions
diff --git a/noncore/multimedia/powerchord/fretboard.cpp b/noncore/multimedia/powerchord/fretboard.cpp index bf78e4c..2e48f26 100644 --- a/noncore/multimedia/powerchord/fretboard.cpp +++ b/noncore/multimedia/powerchord/fretboard.cpp @@ -1,233 +1,231 @@ // // FretBoard class to display interface for chord finder application // // Copyright (c) 2001 Camilo Mesias // camilo@mesias.co.uk // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -//#include <FL/Fl.H> -//#include <FL/Fl_Widget.H> -//#include <FL/fl_draw.H> -#include <stdio.h> -#include <qpe/resource.h> #include "fretboard.h" + +#include <opie2/oresource.h> + #include <qpainter.h> void FretBoard::refresh(){ ce.calculate(); emit nameChanged(QString(ce.label())); for (int i=0;i<6;i++){ Finger(i, ce.finger(i)); // yuk switch (i) { case 0: emit s1nameChanged(QString(ce.name(i))); break; case 1: emit s2nameChanged(QString(ce.name(i))); break; case 2: emit s3nameChanged(QString(ce.name(i))); break; case 3: emit s4nameChanged(QString(ce.name(i))); break; case 4: emit s5nameChanged(QString(ce.name(i))); break; case 5: emit s6nameChanged(QString(ce.name(i))); break; } } update(); } FretBoard::FretBoard(QWidget *parent, const char *name ) : QWidget( parent, name ), ce() { ce.base(9); ce.chord(0); ce.fret(0); ce.span(1); ce.vary(7); ce.tune(0); refresh(); // setPalette( QPalette( QColor( 250, 250, 200) ) ); - stringtop_pix = Resource::loadPixmap( "powerchord/stringtop_s"); - string_pix = Resource::loadPixmap( "powerchord/string_s"); - finger_pix = Resource::loadPixmap( "powerchord/justfing_s"); - mute_pix = Resource::loadPixmap( "powerchord/muted_s"); + stringtop_pix = Opie::Core::OResource::loadPixmap( "powerchord/stringtop_s"); + string_pix = Opie::Core::OResource::loadPixmap( "powerchord/string_s"); + finger_pix = Opie::Core::OResource::loadPixmap( "powerchord/justfing_s"); + mute_pix = Opie::Core::OResource::loadPixmap( "powerchord/muted_s"); // box(FL_NO_BOX); // finger[0] = OPEN; // finger[1] = OPEN; // finger[2] = OPEN; // finger[3] = OPEN; // finger[4] = OPEN; // finger[5] = OPEN; initial_fret = 0; // label(FL_NORMAL_LABEL, "Chord"); } // int FretBoard::Finger(int f){ // if (f < 0 || f > 5){ // fprintf(stderr, "Error - finger value was %d\n", f); // return 0; // } // return finger[f]; // } void FretBoard::Finger(int f, int position){ if (f < 0 || f > 5){ fprintf(stderr, "Error - finger2 value was %d\n", f); return; } finger[f] = position; } // void FretBoard::draw(void) { // draw_box(); // draw_label(); // } // void FretBoard::draw_label(void) { // align(FL_ALIGN_CENTER | FL_ALIGN_TOP | FL_ALIGN_WRAP); // this->Fl_Widget::draw_label(); // } //void FretBoard::draw_box(void) { void FretBoard::paintEvent(QPaintEvent *){ // fl_color(FL_WHITE); // Fl_Widget::draw_box(); // fl_color(FL_BLACK); QPainter p( this ); p.setBrush(black); p.translate(0, 0); // draw each string for (int f=0; f<=5; f++){ // draw a string starting from the highest visible fret for (int pp=0; pp<=6; pp++){ int this_fret = initial_fret + pp; int cx = /* x() + */ 28*f; int cy = /* y() + */ pp*30; // fl_color(FL_WHITE); // fl_rectf(cx, cy, 24, 24); // p.setBrush(white); // p.setPen(NoPen); // p.drawRect( QRect(cx, cy, 24, 24) ); // fl_color(FL_BLACK); // p.setBrush(black); // p.setPen(black); // draw the string unless at top if (this_fret!=0){ // fl_line(cx+12, cy, cx+12, cy+23); // p.drawLine(cx+12, cy, cx+12, cy+23); } // draw mutes if at top if (pp == 0 && finger[f] == MUTED){ p.drawPixmap(cx,cy,mute_pix); // fl_line(cx+4, cy+19, cx+19, cy+4); // p.drawLine(cx+4, cy+19, cx+19, cy+4); // fl_line(cx+5, cy+19, cx+20, cy+4); // p.drawLine(cx+5, cy+19, cx+20, cy+4); // fl_line(cx+4, cy+4, cx+19, cy+19); // p.drawLine(cx+4, cy+4, cx+19, cy+19); // fl_line(cx+5, cy+4, cx+20, cy+19); // p.drawLine(cx+5, cy+4, cx+20, cy+19); } if (this_fret==0){ // above, blank }else if(this_fret==1){ // top p.drawPixmap(cx,cy,stringtop_pix); }else{ // normal p.drawPixmap(cx,cy,string_pix); } // frets at bottom // thick line if at top // int x0 = (f==0)?(cx+12):cx; // int x1 = (f==5)?(cx+12):(cx+23); // for (int offset=23; offset>((this_fret==0)?20:22); offset--){ // fl_line(x0, cy+offset, x1, cy+offset); // p.drawLine(x0, cy+offset, x1, cy+offset); // } // finger if at that position if ((initial_fret==0 && pp == finger[f]) || (initial_fret!=0 && pp == finger[f]-8)){ p.drawPixmap(cx,cy,finger_pix); // fl_color(FL_WHITE); // p.setBrush(white); // p.setPen(NoPen); // fl_rectf(cx+4, cy+4, 16, 16); // p.drawRect( QRect(cx+4, cy+4, 16, 16)); // fl_color(FL_BLACK); //p.setPen(black); // fl_line(cx+4, cy+11, cx+7, cy+16); //p.drawLine(cx+4, cy+11, cx+7, cy+16); // fl_line(cx+7, cy+16, cx+12, cy+19); //p.drawLine(cx+7, cy+16, cx+12, cy+19); // fl_line(cx+12, cy+19, cx+16, cy+16); //p.drawLine(cx+12, cy+19, cx+16, cy+16); // fl_line(cx+16, cy+16, cx+19, cy+12); //p.drawLine(cx+16, cy+16, cx+19, cy+12); // fl_line(cx+19, cy+12, cx+16, cy+7); //p.drawLine(cx+19, cy+12, cx+16, cy+7); // fl_line(cx+16, cy+7, cx+12, cy+4); //p.drawLine(cx+16, cy+7, cx+12, cy+4); // fl_line(cx+11, cy+4, cx+7, cy+7); //p.drawLine(cx+11, cy+4, cx+7, cy+7); // fl_line(cx+7, cy+7, cx+4, cy+11); //p.drawLine(cx+7, cy+7, cx+4, cy+11); } } } p.end(); } diff --git a/noncore/multimedia/powerchord/powerchordbase.cpp b/noncore/multimedia/powerchord/powerchordbase.cpp index f0d1487..0efc4bd 100644 --- a/noncore/multimedia/powerchord/powerchordbase.cpp +++ b/noncore/multimedia/powerchord/powerchordbase.cpp @@ -1,239 +1,240 @@ /**************************************************************************** ** Form implementation generated from reading ui file 'powerchordbase.ui' ** ** Created: Sun Jan 13 23:05:11 2002 ** by: The User Interface Compiler (uic) ** ** WARNING! All changes made in this file will be lost! ****************************************************************************/ #include "powerchordbase.h" #include "fretboard.h" #include "vumeter.h" /* OPIE */ #include <opie2/odebug.h> -#include <qpe/resource.h> +#include <opie2/oresource.h> using namespace Opie::Core; /* QT */ +#include <qbitmap.h> #include <qcombobox.h> #include <qlabel.h> #include <qlistbox.h> #include <qpushbutton.h> #include <qspinbox.h> #include <qtabwidget.h> #include <qlayout.h> #include <qtooltip.h> /* * Constructs a PowerchordBase which is a child of 'parent', with the * name 'name' and widget flags set to 'f' */ PowerchordBase::PowerchordBase( QWidget* parent, const char* name, WFlags fl ) : QWidget( parent, name, fl ) { simulation_timer = 0; audio_timer = 0; // setPalette( QPalette( QColor( 232, 227, 215) ) ); // QPixmap image0(QString("/opt/Qtopia/pics/powerchord/image0")); - QPixmap image1 = Resource::loadPixmap( "powerchord/image1"); - QPixmap image2 = Resource::loadPixmap( "powerchord/image2"); - QPixmap image3 = Resource::loadPixmap( "powerchord/image3"); - QPixmap image4 = Resource::loadPixmap( "powerchord/image4"); - QPixmap image5 = Resource::loadPixmap( "powerchord/image5"); - image6 = Resource::loadPixmap( "powerchord/image6"); - image_open = Resource::loadPixmap( "powerchord/image_open"); + QPixmap image1 = Opie::Core::OResource::loadPixmap( "powerchord/image1"); + QPixmap image2 = Opie::Core::OResource::loadPixmap( "powerchord/image2"); + QPixmap image3 = Opie::Core::OResource::loadPixmap( "powerchord/image3"); + QPixmap image4 = Opie::Core::OResource::loadPixmap( "powerchord/image4"); + QPixmap image5 = Opie::Core::OResource::loadPixmap( "powerchord/image5"); + image6 = Opie::Core::OResource::loadPixmap( "powerchord/image6"); + image_open = Opie::Core::OResource::loadPixmap( "powerchord/image_open"); // image0.setMask(image0.createHeuristicMask()); image1.setMask(image1.createHeuristicMask()); // image2.setMask(image2.createHeuristicMask()); // image3.setMask(image3.createHeuristicMask()); // image4.setMask(image4.createHeuristicMask()); // image5.setMask(image5.createHeuristicMask()); // image6->setMask(image6->createHeuristicMask()); // image_open->setMask(image_open->createHeuristicMask()); if ( !name ) setName( "PowerchordBase" ); resize( 240, 284 ); setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, sizePolicy().hasHeightForWidth() ) ); setMinimumSize( QSize( 240, 284 ) ); setMaximumSize( QSize( 240, 284 ) ); setCaption( tr( "Powerchord" ) ); tabs = new QTabWidget( this, "tabs" ); tabs->setEnabled( TRUE ); tabs->setGeometry( QRect( 0, 0, 240, 286 ) ); tabs->setTabPosition( QTabWidget::Bottom ); tab = new QWidget( tabs, "tab" ); chordkey = new QComboBox( FALSE, tab, "chordkey" ); chordkey->insertItem( tr( "maj" ) ); chordkey->insertItem( tr( "min" ) ); chordkey->insertItem( tr( "7th" ) ); chordkey->insertItem( tr( "m7" ) ); chordkey->insertItem( tr( "maj7" ) ); chordkey->insertItem( tr( "6th" ) ); chordkey->insertItem( tr( "m6th" ) ); chordkey->insertItem( tr( "aug" ) ); chordkey->insertItem( tr( "dim" ) ); chordkey->insertItem( tr( "sus4" ) ); chordkey->insertItem( tr( "7sus4" ) ); chordkey->insertItem( tr( "9th" ) ); chordkey->insertItem( tr( "add9" ) ); chordkey->insertItem( tr( "m9th" ) ); chordkey->insertItem( tr( "maj9" ) ); chordkey->insertItem( tr( "sus2" ) ); chordkey->insertItem( tr( "7sus2" ) ); chordkey->insertItem( tr( "11th" ) ); chordkey->insertItem( tr( "m11th" ) ); chordkey->insertItem( tr( "13th" ) ); chordkey->insertItem( tr( "m13th" ) ); chordkey->insertItem( tr( "maj13" ) ); chordkey->insertItem( tr( "6/9" ) ); chordkey->insertItem( tr( "flat5" ) ); chordkey->insertItem( tr( "7#9" ) ); chordkey->insertItem( tr( QString::fromUtf8( "ø7" ) ) ); chordkey->insertItem( tr( "5" ) ); chordkey->setGeometry( QRect( 40, 0, 51, 21 ) ); chordfret = new QComboBox( FALSE, tab, "chordfret" ); chordfret->insertItem( tr( "open" ) ); chordfret->insertItem( tr( "1st" ) ); chordfret->insertItem( tr( "2nd" ) ); chordfret->insertItem( tr( "3rd" ) ); chordfret->insertItem( tr( "4th" ) ); chordfret->insertItem( tr( "5th" ) ); chordfret->insertItem( tr( "6th" ) ); chordfret->insertItem( tr( "7th" ) ); chordfret->insertItem( tr( "8th" ) ); chordfret->insertItem( tr( "9th" ) ); chordfret->insertItem( tr( "10th" ) ); chordfret->insertItem( tr( "11th" ) ); chordfret->insertItem( tr( "12th" ) ); chordfret->insertItem( tr( "13th" ) ); chordfret->insertItem( tr( "14th" ) ); chordfret->insertItem( tr( "15th" ) ); chordfret->insertItem( tr( "16th" ) ); chordfret->setGeometry( QRect( 90, 0, 55, 21 ) ); //cxm less 5 width chordnote = new QComboBox( FALSE, tab, "chordnote" ); chordnote->insertItem( tr( "C" ) ); chordnote->insertItem( tr( "C#" ) ); chordnote->insertItem( tr( "D" ) ); chordnote->insertItem( tr( "Eb" ) ); chordnote->insertItem( tr( "E" ) ); chordnote->insertItem( tr( "F" ) ); chordnote->insertItem( tr( "F#" ) ); chordnote->insertItem( tr( "G" ) ); chordnote->insertItem( tr( "G#" ) ); chordnote->insertItem( tr( "A" ) ); chordnote->insertItem( tr( "Bb" ) ); chordnote->insertItem( tr( "B" ) ); chordnote->setGeometry( QRect( 0, 0, 40, 21 ) ); chordnote->setCurrentItem( 9 ); QWidget* privateLayoutWidget = new QWidget( tab, "Layout1" ); privateLayoutWidget->setGeometry( QRect( 5, 232, 160, 20 ) ); Layout1 = new QHBoxLayout( privateLayoutWidget ); Layout1->setSpacing( 6 ); Layout1->setMargin( 0 ); s1_1 = new QLabel( privateLayoutWidget, "s1_1" ); s1_1->setText( tr( "E" ) ); s1_1->setAlignment( int( QLabel::AlignCenter ) ); Layout1->addWidget( s1_1 ); s1_2 = new QLabel( privateLayoutWidget, "s1_2" ); s1_2->setText( tr( "A" ) ); s1_2->setAlignment( int( QLabel::AlignCenter ) ); Layout1->addWidget( s1_2 ); s1_3 = new QLabel( privateLayoutWidget, "s1_3" ); s1_3->setText( tr( "E" ) ); s1_3->setAlignment( int( QLabel::AlignCenter ) ); Layout1->addWidget( s1_3 ); s1_4 = new QLabel( privateLayoutWidget, "s1_4" ); s1_4->setText( tr( "A" ) ); s1_4->setAlignment( int( QLabel::AlignCenter ) ); Layout1->addWidget( s1_4 ); s1_5 = new QLabel( privateLayoutWidget, "s1_5" ); s1_5->setText( tr( "C#" ) ); s1_5->setAlignment( int( QLabel::AlignCenter ) ); Layout1->addWidget( s1_5 ); s1_6 = new QLabel( privateLayoutWidget, "s1_6" ); s1_6->setText( tr( "E" ) ); s1_6->setAlignment( int( QLabel::AlignCenter ) ); Layout1->addWidget( s1_6 ); // sound_label = new QLabel( tab, "sound_label" ); // sound_label->setGeometry( QRect( 185, 160, 32, 17 ) ); // sound_label->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, sound_label->sizePolicy().hasHeightForWidth() ) ); // sound_label->setPixmap( image0 ); // sound_label->pixmap()->setMask(*image0.mask()); // sound_label->setScaledContents( TRUE ); // sound_label->setBackgroundMode( QWidget::PaletteButton ); // sound_label->setBackgroundColor(this->backgroundColor()); // sound_label->setPalette( QPalette( QColor( 232, 227, 215) ) ); Frame6 = new QFrame( tab, "Frame6" ); Frame6->setGeometry( QRect( 170, 145, 66, 10 ) ); Frame6->setFrameShape( QFrame::HLine ); Frame6->setFrameShadow( QFrame::Raised ); chordshow_label = new QLabel( tab, "chordshow_label" ); chordshow_label->setGeometry( QRect( 185, 60, 32, 17 ) ); // chordshow_label->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, chordshow_label->sizePolicy().hasHeightForWidth() ) ); chordshow_label->setFrameShape( QLabel::NoFrame ); chordshow_label->setPixmap( image1 ); chordshow_label->setScaledContents( TRUE ); // chordshow_label->setBackgroundMode( QWidget::PaletteButton ); transport_rec = new QPushButton( tab, "transport_rec" ); transport_rec->setGeometry( QRect( 170, 80, 30, 30 ) ); transport_rec->setText( "" ); transport_rec->setPixmap( image2 ); play_sound = new QPushButton( tab, "play_sound" ); play_sound->setGeometry( QRect( 170, 180, 60, 55 ) ); play_sound->setText( "" ); play_sound->setPixmap( image3 ); Frame6_2 = new QFrame( tab, "Frame6_2" ); Frame6_2->setGeometry( QRect( 170, 45, 66, 10 ) ); Frame6_2->setFrameShape( QFrame::HLine ); Frame6_2->setFrameShadow( QFrame::Raised ); transport_play = new QPushButton( tab, "transport_play" ); transport_play->setEnabled( FALSE ); transport_play->setGeometry( QRect( 200, 80, 30, 30 ) ); transport_play->setText( "" ); transport_play->setPixmap( image3 ); transport_rew = new QPushButton( tab, "transport_rew" ); transport_rew->setEnabled( FALSE ); transport_rew->setGeometry( QRect( 170, 110, 30, 30 ) ); transport_rew->setText( "" ); transport_rew->setPixmap( image4 ); transport_fwd = new QPushButton( tab, "transport_fwd" ); transport_fwd->setEnabled( FALSE ); transport_fwd->setGeometry( QRect( 200, 110, 30, 30 ) ); transport_fwd->setText( "" ); transport_fwd->setPixmap( image5 ); chordname = new QLabel( tab, "chordname" ); chordname->setGeometry( QRect( 146, 0, 90, 20 ) ); //cxm moved l 5 chordname->setText( tr( "A" ) ); chordname->setAlignment( int( QLabel::AlignCenter ) ); QToolTip::add( chordname, "" ); synth = new gs(); tuner = new gt(); |