Fixed bug that crashed on saving after importing.
[epichord.git] / src / keyboard.h
blobcc672977801aeeb002b0b3c4e73cdeaa5d66f254
1 /*
2 Epichord - a midi sequencer
3 Copyright (C) 2008 Evan Rinehart
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to
18 The Free Software Foundation, Inc.
19 51 Franklin Street, Fifth Floor
20 Boston, MA 02110-1301, USA
23 #ifndef keyboard_h
24 #define keyboard_h
26 #include <fstream>
28 class Keyboard : public fltk::Widget {
30 int cur_note;
31 int sustain;
33 char ons[128];
34 char helds[128];
36 int octave;
38 public:
39 int cur_port;
40 int cur_chan;
41 int scroll;
43 Keyboard(int x, int y, int w, int h, const char* label);
45 void play_note(int note, int rec);
46 void release_note(int note, int rec);
47 void cut_notes(int rec);
48 void set_sustain(int state);
50 void kb_play_note(int note);
51 void kb_release_note(int note);
52 void octave_up();
53 void octave_down();
55 int handle(int event);
56 void draw();
61 int keyboard_handler(int e, fltk::Window* w);
64 struct combo {
65 unsigned int key;
66 unsigned int mod;
67 combo(unsigned zkey, unsigned zmod){key=zkey; mod=zmod;}
68 combo(){key=' '; mod=0;}
69 int operator==(combo c){
70 return (c.key==key && c.mod==mod) ? 1 : 0;
74 class KeyGrabber : public fltk::Widget {
76 char str[32];
77 int in_flag;
79 public:
81 unsigned key;
82 unsigned mod;
83 KeyGrabber(int x, int y, int w, int h, const char* label);
85 int handle(int event);
86 void draw();
88 int set_key(int key, int mod);
89 int set_key(combo c);
90 int cmp(combo c);
92 void save(std::fstream& f);
93 void load(std::fstream& f);
96 void set_keymap(int which, int index, int key, int mod);
97 char* get_keystring(int key, int mod);
99 void load_keymap(std::fstream& f);
100 void save_keymap(std::fstream& f);
101 void load_default_keymap();
103 int zoom_out_key(unsigned,unsigned);
104 int zoom_in_key(unsigned,unsigned);
106 #endif