new source files from tim m.
[ardour.git] / libs / gtkmm2ext / gtkmm2ext / hexentry.h
1 /*
2     Copyright (C) 1999 Paul Barton-Davis 
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #ifndef __gtkmm2ext_hexentry_h__
21 #define __gtkmm2ext_hexentry_h__
22
23 #include <gtkmm.h>
24
25 namespace Gtkmm2ext {
26
27 class HexEntry : public Gtk::Entry
28
29 {
30   public:
31         /* Take a byte-level representation of a series of hexadecimal
32            values and use them to set the displayed text of the entry.
33            Eg. if hexbuf[0] = 0xff and hexbuf[1] = 0xa1 and buflen = 2,
34            then the text will be set to "ff a1".
35         */
36
37         void set_hex (unsigned char *hexbuf, unsigned int buflen);
38
39         /* puts byte-level representation of current entry text
40            into hexbuf, and returns number of bytes written there.
41
42            NOTE: this will release the existing memory pointed to
43            by hexbuf if buflen indicates that it is not long enough
44            to hold the new representation, and hexbuf is not zero.
45
46            If the returned length is zero, the contents of hexbuf 
47            are undefined.
48         */
49
50         unsigned int get_hex (unsigned char *hexbuf, size_t buflen);
51
52   private:
53         bool on_key_press_event (GdkEventKey *);
54 };
55
56 } /* namespace */
57
58 #endif /* __gtkmm2ext_hexentry_h__ */