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 FTextRXTX_H_
24 #define FTextRXTX_H_
25 
26 #include <string>
27 
28 #include "FTextView.h"
29 
30 ///
31 /// A TextBase subclass to display received & transmitted text
32 ///
33 class FTextRX : public FTextView
34 {
35 public:
36 	FTextRX(int x, int y, int w, int h, const char *l = 0);
37         ~FTextRX();
38 
39 	virtual int	handle(int event);
40 
41 #if FLDIGI_FLTK_API_MAJOR == 1 && FLDIGI_FLTK_API_MINOR >= 3
42 	virtual void	add(unsigned int  c, int attr = RECV);
43 	virtual	void	add(const char *s, int attr = RECV)
44         {
45                 while (*s)
46                         add(*s++, attr);
47         }
48 #else
49 	virtual void	add(unsigned char c, int attr = RECV);
50 	virtual	void	add(const char *s, int attr = RECV)
51         {
52                 while (*s)
53                         add(*s++, attr);
54         }
55 #endif
56 
57 	void		set_all_entry(bool b);
get_quick_entry(void)58 	bool		get_quick_entry(void) { return menu[RX_MENU_ALL_ENTRY].value(); }
59 	void		set_scroll_hints(bool b);
get_scroll_hints(void)60 	bool		get_scroll_hints(void) { return menu[RX_MENU_SCROLL_HINTS].value(); }
61 	void		mark(FTextBase::TEXT_ATTR attr = CLICK_START);
62 	void		clear(void);
63 
64 	void		setFont(Fl_Font f, int attr = NATTR);
65 
66 protected:
67 	enum {
68 		RX_MENU_QRZ_THIS, RX_MENU_CALL, RX_MENU_NAME, RX_MENU_QTH,
69 		RX_MENU_STATE, RX_MENU_COUNTY, RX_MENU_PROVINCE,
70 		RX_MENU_COUNTRY, RX_MENU_LOC,
71 		RX_MENU_RST_IN, RX_MENU_RST_OUT,
72 		RX_MENU_XCHG, RX_MENU_SERIAL,
73 		RX_MENU_CLASS, RX_MENU_SECTION,
74 
75 		RX_MENU_SS_SER, RX_MENU_SS_PRE, RX_MENU_SS_CHK, RX_MENU_SS_SEC,
76 
77 		RX_MENU_CQZONE, RX_MENU_CQSTATE,
78 		RX_MENU_1010_NR,
79 		RX_MENU_AGE,
80 
81 		RX_MENU_CHECK,
82 		RX_MENU_NAQP,
83 		RX_MENU_SCOUT,
84 		RX_MENU_TROOP,
85 		RX_MENU_POWER,
86 
87 		RX_MENU_QSOP_STATE,
88 		RX_MENU_QSOP_COUNTY,
89 		RX_MENU_QSOP_SERNO,
90 		RX_MENU_QSOP_NAME,
91 		RX_MENU_QSOP_XCHG,
92 		RX_MENU_QSOP_CAT,
93 
94 		RX_MENU_DIV,
95 
96 		RX_MENU_COPY,
97 		RX_MENU_CLEAR,
98 		RX_MENU_SELECT_ALL,
99 		RX_MENU_SAVE,
100 		RX_MENU_WRAP,
101 
102 		RX_MENU_ALL_ENTRY,
103 
104 		RX_MENU_SCROLL_HINTS,
105 
106 		RX_MENU_NUM_ITEMS
107 	};
108 
109 	int			num_words;
110 	int			handle_clickable(int x, int y);
111 	int			handle_qso_data(int start, int end);
112 	void		handle_qsy(int start, int end);
113 	void		handle_context_menu(void);
114 	void		menu_cb(size_t item);
115 
116 	const char*	dxcc_lookup_call(int x, int y);
117 	static void	dxcc_tooltip(void* obj);
118 
119 private:
120 	FTextRX();
121 	FTextRX(const FTextRX &t);
122 
123 protected:
124 	static Fl_Menu_Item menu[];
125 	struct {
126 		bool enabled;
127 		float delay;
128 	} tooltips;
129 };
130 
131 
132 ///
133 /// A FTextBase subclass to display and edit text to be transmitted
134 ///
135 class FTextTX : public FTextEdit
136 {
137 public:
138 	FTextTX(int x, int y, int w, int h, const char *l = 0);
139 
140 	virtual int	handle(int event);
141 
142 	void		clear(void);
143 	void		clear_sent(void);
144 	int			nextChar(void);
145 	bool		eot(void);
146 	void		add_text(std::string s);
pause()147 	void		pause() { PauseBreak = true; }
148 
149 	void		setFont(Fl_Font f, int attr = NATTR);
150 
151 protected:
152 	enum { TX_MENU_TX, TX_MENU_RX, TX_MENU_ABORT,
153 			TX_MENU_MFSK16_IMG,
154 			TX_MENU_CUT, TX_MENU_COPY, TX_MENU_PASTE, TX_MENU_CLEAR,
155 			TX_MENU_READ, TX_MENU_WRAP
156 	};
157 	int		handle_key_shortcuts(int key);
158 	int		handle_key(int key);
159 	int		handle_key_macro(int key);
160 	int		handle_dnd_drag(int pos);
161 	void		handle_context_menu(void);
162 	void		menu_cb(size_t item);
163 	void		change_keybindings(void);
164 	static int	kf_default(int c, Fl_Text_Editor_mod* e);
165 	static int	kf_enter(int c, Fl_Text_Editor_mod* e);
166 	static int	kf_delete(int c, Fl_Text_Editor_mod* e);
167 	static int	kf_cut(int c, Fl_Text_Editor_mod* e);
168 	static int	kf_paste(int c, Fl_Text_Editor_mod* e);
169 
170 private:
171 	FTextTX();
172 	FTextTX(const FTextTX &t);
173 
174 protected:
175 	static Fl_Menu_Item	menu[];
176 	bool		PauseBreak;
177 	int			txpos;
178 	int			utf8_txpos;
179 	static int	*ptxpos;
180 	int			bkspaces;
181 };
182 
183 #endif // FTextRXTX_H_
184 
185 // Local Variables:
186 // mode: c++
187 // c-file-style: "linux"
188 // End:
189