Fixed bug in DragBar.
[epichord.git] / src / keyboard.h
blob9982203771509b53058a16cbb6349740eef39920
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 int highlight;
40 public:
41 int cur_port;
42 int cur_chan;
43 int scroll;
45 Keyboard(int x, int y, int w, int h, const char* label);
47 void play_note(int note, int rec);
48 void release_note(int note, int rec);
49 void cut_notes(int rec);
50 void set_sustain(int state);
52 void kb_play_note(int note);
53 void kb_release_note(int note);
54 void octave_up();
55 void octave_down();
57 int handle(int event);
58 void draw();
60 void highlight_note(int note);
61 void highlight_clear();
65 int keyboard_handler(int e, fltk::Window* w);
68 struct combo {
69 unsigned int key;
70 unsigned int mod;
71 combo(unsigned zkey, unsigned zmod){key=zkey; mod=zmod;}
72 combo(){key=' '; mod=0;}
73 int operator==(combo c){
74 return (c.key==key && c.mod==mod) ? 1 : 0;
78 class KeyGrabber : public fltk::Widget {
80 char str[32];
81 int in_flag;
83 public:
85 unsigned key;
86 unsigned mod;
87 KeyGrabber(int x, int y, int w, int h, const char* label);
89 int handle(int event);
90 void draw();
92 int set_key(int key, int mod);
93 int set_key(combo c);
94 int cmp(combo c);
96 void save(std::fstream& f);
97 void load(std::fstream& f);
100 void set_keymap(int which, int index, int key, int mod);
101 char* get_keystring(int key, int mod);
103 void load_keymap(std::fstream& f);
104 void save_keymap(std::fstream& f);
105 void load_default_keymap();
107 int zoom_out_key(unsigned,unsigned);
108 int zoom_in_key(unsigned,unsigned);
110 #endif