Planeshift

pawsmusicwindow.h

Go to the documentation of this file.
00001 /*
00002  * pawsmusicwindow.h, Author: Andrea Rizzi <[email protected]>
00003  *
00004  * Copyright (C) 2001-2011 Atomic Blue ([email protected], http://www.atomicblue.org) 
00005  *
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation (version 2 of the License)
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017  *
00018  */
00019 
00020 #ifndef PAWS_MUSIC_WINDOW_H
00021 #define PAWS_MUSIC_WINDOW_H
00022 
00023 
00024 //====================================================================================
00025 // Project Includes
00026 //====================================================================================
00027 #include <clientsongmngr.h>
00028 #include <net/cmdbase.h>
00029 #include <paws/pawsmeterpromptwindow.h>
00030 #include <paws/pawsstringpromptwindow.h>
00031 
00032 //------------------------------------------------------------------------------------
00033 // Forward Declarations
00034 //------------------------------------------------------------------------------------
00035 class Chord;
00036 class Measure;
00037 class SheetLine;
00038 class pawsSheetLine;
00039 
00043 class pawsMusicWindow: public pawsWidget, public psClientNetSubscriber,
00044     public iOnStringEnteredAction, public iOnMeterEnteredListener, iSongManagerListener
00045 {
00046 public:
00047     enum
00048     {
00049         UNALTERED,
00050         FLAT,
00051         NATURAL,
00052         SHARP
00053     };
00054 
00055     enum
00056     {
00057         NO_SELECTED,
00058 
00059         // duration buttons
00060         SIXTEENTH_BUTTON = 200,
00061         EIGHTH_BUTTON,
00062         QUARTER_BUTTON,
00063         HALF_BUTTON,
00064         WHOLE_BUTTON,
00065 
00066         // alteration buttons
00067         FLAT_BUTTON = 300,
00068         NATURAL_BUTTON,
00069         SHARP_BUTTON,
00070     };
00071 
00075     pawsMusicWindow();
00076 
00082     pawsMusicWindow(const pawsMusicWindow* origin);
00083 
00087     virtual ~pawsMusicWindow();
00088 
00098     void OnChordSelection(SheetLine* sheetLine, Measure* measure, Chord* chord, int notePosition, bool before);
00099 
00106     void GetMeter(int &beats, int &beatType);
00107 
00113     uint GetDivisions();
00114 
00115     // From iSongManagerListener
00116     virtual void OnMainPlayerSongStop();
00117 
00118     // From iOnMeterEnteredListener
00119     virtual void OnMeterEntered(const char* name, csString beats, csString beatType);
00120 
00121     // From iOnStringEnteredAction
00122     //-----------------------------
00123     virtual void OnStringEntered(const char* name, int param, const char* value);
00124 
00125     // From psClientNetSubscriber
00126     //----------------------------
00127     virtual void HandleMessage(MsgEntry* message);
00128 
00129     // From pawsWidget
00130     //-----------------
00131     virtual double CalcFunction(MathEnvironment* env, const char* functionName, const double* params);
00132     virtual void Hide();
00133     virtual bool PostSetup();
00134     virtual bool OnButtonPressed(int mouseButton, int keyModifier, pawsWidget* widget);
00135     virtual bool OnScroll(int scrollDirection, pawsScrollBar* widget);
00136 
00137 private:
00138     friend class pawsSheetLine;
00139 
00140     int fifths;                        
00141     csString beats;                    
00142     csString beatType;                 
00143     uint tempo;                        
00144     uint playedTempo;                  
00145 
00146     SheetLine* linesHead;              
00147     Measure* measuresHead;             
00148 
00149     Chord* selectedChord;              
00150     Measure* selectedMeasure;          
00151 
00157     SheetLine* selectedSheetLine;
00158 
00159     int  selectedDurButton;            
00160     int  selectedAlterButton;          
00161 
00162     uint32_t currentItemID;            
00163     bool readOnly;                     
00164     bool edited;                       
00165     bool pendingString;                
00166     bool editMode;                     
00167     bool insertMode;                   
00168 
00169     pawsButton* editButton;
00170     pawsButton* playButton;
00171     pawsWidget* loadButton;
00172     pawsWidget* saveButton;
00173     pawsWidget* titleButton;
00174 
00175     pawsButton* doubleStaffButton;
00176     pawsWidget* tonalityButton;
00177     pawsWidget* meterButton;
00178     pawsWidget* bpmButton;
00179     pawsButton* restButton;
00180 
00181     pawsButton* sixteenthButton;
00182     pawsButton* eighthButton;
00183     pawsButton* quarterButton;
00184     pawsButton* halfButton;
00185     pawsButton* wholeButton;
00186     pawsButton* dotButton;
00187 
00188     pawsButton* flatButton;
00189     // pawsButton* naturalButton; TODO support natural notes in song stream before use this
00190     pawsButton* sharpButton;
00191 
00192     pawsWidget* deleteChordButton;
00193     pawsWidget* deleteMeasureButton;
00194     pawsButton* insertNoteButton;
00195     pawsWidget* insertMeasureButton;
00196 
00197     pawsButton* startRepeatButton;
00198     pawsButton* endRepeatButton;
00199     pawsButton* endingButton;
00200 
00201     pawsSheetLine* pawsLine1;
00202     pawsSheetLine* pawsLine2;
00203 
00204     pawsScrollBar* scrollBar;
00205 
00210     static void OnSheetLineCallback(void* object, SheetLine* sheetLine);
00211 
00215     void Unload();
00216 
00225     bool LoadXML(csRef<iDocument> sheet);
00226 
00234     csString ToXML(bool usePlayedTempo);
00235 
00242     SheetLine* GetSheetLine(int index);
00243 
00249     SheetLine* GetSelectedSheetLine();
00250 
00254     void UpdateScrollBar();
00255 
00262     void UpdateLines(SheetLine* line, bool forceAll);
00263 
00267     void DisplaySelectedMeasure();
00268 
00276     pawsButton* GetButton(int buttonID);
00277 
00281     void DeleteSelectedChord();
00282 
00286     void DeleteSelectedMeasure();
00287 
00291     void InsertMeasure();
00292 
00298     void SetInsertMode(bool toggle);
00299 
00305     void ToggleEditMode(bool toggle);
00306 
00310     void PlayStop();
00311 
00315     void Save();
00316 
00320     void Load();
00321 
00325     void ChangeSongTitle();
00326 
00330     void SwitchDoubleStaff();
00331 
00335     void ChangeTonality();
00336 
00340     void ChangeMeter();
00341 
00345     void ChangeBPM();
00346 
00350     void SetPlayedBPM();
00351 
00355     void ChangeChordDuration();
00356 
00361     void SetEndRepeat();
00362 
00366     void SetEnding();
00367 
00373     int GetSelectedDuration();
00374 
00381     void SetDurationButton(int duration);
00382 
00388     void SelectDuration(int buttonID);
00389 
00396     void SelectAlteration(int buttonID);
00397 
00402     void SetToolbarButtons();
00403 
00408     void ResetState();
00409 
00413     void DeleteAll();
00414 };
00415 
00416 CREATE_PAWS_FACTORY(pawsMusicWindow);
00417 
00418 #endif // PAWS_MUSIC_WINDOW_H