1 // ----------------------------------------------------------------------------
2 //      FTextView.h
3 //
4 // Copyright (C) 2007-2009
5 //              Stelios Bounanos, M0GLD
6 //
7 // This file is part of fldigi.
8 //
9 // fldigi is free software; you can redistribute it and/or modify
10 // it under the terms of the GNU General Public License as published by
11 // the Free Software Foundation; either version 3 of the License, or
12 // (at your option) any later version.
13 //
14 // fldigi is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 // GNU General Public License for more details.
18 //
19 // You should have received a copy of the GNU General Public License
20 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
21 // ----------------------------------------------------------------------------
22 
23 #ifndef F_EDIT_H_
24 #define F_EDIT_H_
25 
26 #include <stddef.h>
27 #include <string>
28 
29 #include <FL/Fl.H>
30 #include <FL/Enumerations.H>
31 #include <FL/Fl_Menu_Item.H>
32 #include <FL/Fl_Tile.H>
33 
34 #include "FTextView.h"
35 
36 /// A FTextBase subclass to display and edit text
37 
38 class F_Edit : public FTextEdit
39 {
40 public:
41 	F_Edit(int x, int y, int w, int h, const char *l = 0);
42 
43 	virtual int	handle(int event);
44 
45 	void		clear(void);
46 	void		add_text(std::string s);
47 
48 	void		setFont(Fl_Font f, int attr = NATTR);
49 
50 protected:
51 	enum {
52 		EDIT_MENU_CUT, EDIT_MENU_COPY, EDIT_MENU_PASTE,
53 		EDIT_MENU_CLEAR, EDIT_MENU_READ, EDIT_MENU_WRAP
54 	};
55 	int			handle_key(int key);
56 	int			handle_dnd_drag(int pos);
57 	void		handle_context_menu(void);
58 	void		menu_cb(size_t item);
59 	void		change_keybindings(void);
60 	static int	kf_default(int c, Fl_Text_Editor_mod* e);
61 	static int	kf_enter(int c, Fl_Text_Editor_mod* e);
62 	static int	kf_delete(int c, Fl_Text_Editor_mod* e);
63 	static int	kf_cut(int c, Fl_Text_Editor_mod* e);
64 	static int	kf_paste(int c, Fl_Text_Editor_mod* e);
65 
66 private:
67 	F_Edit();
68 	F_Edit(const F_Edit &t);
69 
70 protected:
71 	static		Fl_Menu_Item	menu[];
72 	int			editpos;
73 	int			bkspaces;
74 	static int	*p_editpos;
75 };
76 
77 #endif // F_EDIT_H_
78 
79 // Local Variables:
80 // mode: c++
81 // c-file-style: "linux"
82 // End:
83