summaryrefslogtreecommitdiff
path: root/libs/gtkmm2ext/gtkmm2ext/hexentry.h
blob: 410f54274ebaa9be6049df0e5f8bdb2c6cc57c2f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
    Copyright (C) 1999 Paul Barton-Davis 

    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., 675 Mass Ave, Cambridge, MA 02139, USA.

*/

#ifndef __gtkmm2ext_hexentry_h__
#define __gtkmm2ext_hexentry_h__

#include <gtkmm.h>

namespace Gtkmm2ext {

class HexEntry : public Gtk::Entry

{
  public:
	/* Take a byte-level representation of a series of hexadecimal
	   values and use them to set the displayed text of the entry.
	   Eg. if hexbuf[0] = 0xff and hexbuf[1] = 0xa1 and buflen = 2,
	   then the text will be set to "ff a1".
	*/

	void set_hex (unsigned char *hexbuf, unsigned int buflen);

	/* puts byte-level representation of current entry text
	   into hexbuf, and returns number of bytes written there.

	   NOTE: this will release the existing memory pointed to
	   by hexbuf if buflen indicates that it is not long enough
	   to hold the new representation, and hexbuf is not zero.

	   If the returned length is zero, the contents of hexbuf 
	   are undefined.
	*/

	unsigned int get_hex (unsigned char *hexbuf, size_t buflen);

  private:
	bool on_key_press_event (GdkEventKey *);
};

} /* namespace */

#endif /* __gtkmm2ext_hexentry_h__ */