1 // ----------------------------------------------------------------------------
2 //
3 // Viewer.cxx -- PSK browser
4 //
5 // Copyright (C) 2015
6 //		David Freese, W1HKJ
7 //
8 // This file is part of fldigi.
9 //
10 // Fldigi is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Fldigi is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with fldigi.  If not, see <http://www.gnu.org/licenses/>.
22 // ----------------------------------------------------------------------------
23 
24 #include <FL/Enumerations.H>
25 
26 #include "config.h"
27 
28 #include "Viewer.h"
29 #include "trx.h"
30 #include "main.h"
31 #include "configuration.h"
32 #include "confdialog.h"
33 #include "status.h"
34 #include "waterfall.h"
35 #include "fl_digi.h"
36 #include "re.h"
37 #include "gettext.h"
38 #include "flmisc.h"
39 #include "spot.h"
40 #include "icons.h"
41 #include "qrunner.h"
42 
43 using namespace std;
44 
45 //
46 // External fsq monitor dialog
47 //
48 
49 Fl_Double_Window  *fsqMonitor = 0;
50 static Fl_Button *btnCloseMonitor;
51 FTextRX           *fsq_monitor = 0;
52 FTextRX           *fsq_que = 0;
53 
cb_btnCloseMonitor(Fl_Button *,void *)54 static void cb_btnCloseMonitor(Fl_Button*, void*) {
55 	progStatus.fsqMONITORxpos = fsqMonitor->x();
56 	progStatus.fsqMONITORypos = fsqMonitor->y();
57 	progStatus.fsqMONITORwidth = fsqMonitor->w();
58 	progStatus.fsqMONITORheight = fsqMonitor->h();
59 	btn_MONITOR->value(0);
60 	btn_MONITOR->redraw();
61 	fsqMonitor->hide();
62 }
63 
create_fsqMonitor(void)64 Fl_Double_Window* create_fsqMonitor(void)
65 {
66 	Fl_Double_Window* w = new Fl_Double_Window(
67 							progStatus.fsqMONITORxpos, progStatus.fsqMONITORypos,
68 							progStatus.fsqMONITORwidth, progStatus.fsqMONITORheight,
69 							_("FSQ monitor"));
70 
71 	Panel *monitor_panel = new Panel(
72 			2, 2,
73 			w->w() - 4, w->h() - 28);
74 
75 		fsq_monitor = new FTextRX(
76 				monitor_panel->x(), monitor_panel->y(),
77 				monitor_panel->w(), 7*monitor_panel->h()/8);
78 			fsq_monitor->color(
79 			fl_rgb_color(
80 				0.98*progdefaults.RxColor.R,
81 				0.98*progdefaults.RxColor.G,
82 				0.98*progdefaults.RxColor.B),
83 				progdefaults.RxTxSelectcolor);
84 			fsq_monitor->setFont(progdefaults.RxFontnbr);
85 			fsq_monitor->setFontSize(progdefaults.RxFontsize);
86 			fsq_monitor->setFontColor(progdefaults.RxFontcolor, FTextBase::RECV);
87 
88 		fsq_que = new FTextRX(
89 				fsq_monitor->x(), fsq_monitor->y() + fsq_monitor->h(),
90 				fsq_monitor->w(), monitor_panel->h() - fsq_monitor->h());
91 			fsq_que->color(
92 			fl_rgb_color(
93 				0.98*progdefaults.RxColor.R,
94 				0.98*progdefaults.RxColor.G,
95 				0.98*progdefaults.RxColor.B),
96 				progdefaults.RxTxSelectcolor);
97 			fsq_que->setFont(progdefaults.RxFontnbr);
98 			fsq_que->setFontSize(progdefaults.RxFontsize);
99 			fsq_que->setFontColor(progdefaults.RxFontcolor, FTextBase::RECV);
100 
101 		Fl_Box *minbox = new Fl_Box(
102 			monitor_panel->x(), monitor_panel->y() + 66,
103 			monitor_panel->w(), monitor_panel->h() - 132);
104 		minbox->hide();
105 
106 		monitor_panel->resizable(minbox);
107 	monitor_panel->end();
108 
109 	Fl_Group *g = new Fl_Group(
110 		fsq_monitor->x(), monitor_panel->y() + monitor_panel->h() + 2,
111 		fsq_monitor->w(), 22);
112 		Fl_Group *g1 = new Fl_Group(
113 					g->x(), g->y() + 2, g->w() - 80, g->h());
114 			g1->box(FL_FLAT_BOX);
115 			g1->end();
116 	// close button
117 		btnCloseMonitor = new Fl_Button(
118 					g->x() + g->w() - 82, g->y(), 80, g->h(),
119 					icons::make_icon_label(_("Close"), close_icon));
120 		btnCloseMonitor->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE);
121 		icons::set_icon_label(btnCloseMonitor);
122 		btnCloseMonitor->callback((Fl_Callback*)cb_btnCloseMonitor);
123 		g->resizable(g1);
124 	g->end();
125 
126 	w->end();
127 	w->callback((Fl_Callback*)cb_btnCloseMonitor);
128 	w->resizable(monitor_panel);
129 	w->size_range( 300, 200 );
130 	w->xclass(PACKAGE_NAME);
131 
132 	w->hide();
133 	return w;
134 }
135 
open_fsqMonitor()136 void open_fsqMonitor()
137 {
138 	if (!fsqMonitor)
139 		fsqMonitor = create_fsqMonitor();
140 	fsqMonitor->show();
141 	fsqMonitor->redraw();
142 }
143 
144 #if (FSQDEBUG == 1)
145 Fl_Double_Window  *fsqDebug = 0;
146 FTextRX           *fsq_debug = 0;
147 
close_fsqDebug()148 void close_fsqDebug()
149 {
150 	if (fsqDebug) fsqDebug->hide();
151 }
152 
cb_CloseDebug(Fl_Button *,void *)153 static void cb_CloseDebug(Fl_Button*, void*) {
154 	fsqDebug->hide();
155 }
156 
create_fsqDebug(void)157 Fl_Double_Window* create_fsqDebug(void)
158 {
159 	Fl_Double_Window* w = new Fl_Double_Window( 50, 50, 500, 300, "FSQ debug");
160 
161 	fsq_debug = new FTextRX(
162 			2, 2,
163 			w->w() - 4, w->h() - 4);
164 		fsq_debug->color( FL_WHITE);
165 		fsq_debug->setFont(progdefaults.RxFontnbr);
166 		fsq_debug->setFontSize(progdefaults.RxFontsize);
167 		fsq_debug->setFontColor(progdefaults.RxFontcolor, FTextBase::RECV);
168 		fsq_debug->setFontColor(progdefaults.XMITcolor, FTextBase::XMIT);
169 		fsq_debug->setFontColor(progdefaults.CTRLcolor, FTextBase::CTRL);
170 		fsq_debug->setFontColor(progdefaults.SKIPcolor, FTextBase::SKIP);
171 		fsq_debug->setFontColor(progdefaults.ALTRcolor, FTextBase::ALTR);
172 
173 	w->end();
174 	w->callback((Fl_Callback*)cb_CloseDebug);
175 	w->resizable(fsq_debug);
176 	w->size_range( 200, 200 );
177 	w->xclass(PACKAGE_NAME);
178 	w->hide();
179 	return w;
180 }
181 
open_fsqDebug()182 void open_fsqDebug()
183 {
184 	if (!fsqDebug)
185 		fsqDebug = create_fsqDebug();
186 	fsqDebug->show();
187 	fsqDebug->redraw();
188 }
189 
write_fsqDebug(string s,int style)190 void write_fsqDebug(string s, int style)
191 {
192 	if (!fsq_debug) return;
193 	REQ(&FTextRX::addstr, fsq_debug, s, style);
194 }
195 #endif
196 
fsq_que_clear()197 void fsq_que_clear()
198 {
199 	REQ(&FTextRX::clear, fsq_que);
200 }
201 
write_fsq_que(std::string s)202 void write_fsq_que(std::string s)
203 {
204 	if (!fsq_que) return;
205 //	REQ(&FTextRX::clear, fsq_que);
206 	REQ(&FTextRX::addstr, fsq_que, s, FTextBase::ALTR);
207 }
208