1 /*
2 * Tlf - contest logging program for amateur radio operators
3 * Copyright (C) 2001-2002-2003 Rein Couperus <pa0rct@amsat.org>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19 /* ------------------------------------------------------------
20 *
21 * Make info string for lower status line
22 * x - countrynumber
23 *--------------------------------------------------------------*/
24
25 /** Show infos for selected country on bottom of screen
26 *
27 * Prepares info string for the selected country and shows it on the
28 * bottom line of the screen.
29 *
30 * /param x Country number
31 */
32
33
34 #include <assert.h>
35 #include <math.h>
36 #include <stdio.h>
37 #include <string.h>
38 #include <time.h>
39
40 #include "dxcc.h"
41 #include "getwwv.h"
42 #include "qrb.h"
43 #include "showinfo.h"
44 #include "tlf.h"
45 #include "tlf_curses.h"
46 #include "ui_utils.h"
47
48 #define LINELENGTH 80
49
showinfo(int x)50 void showinfo(int x) {
51
52 extern char cqzone[];
53 extern char ituzone[];
54 extern double DEST_Lat;
55 extern double DEST_Long;
56 extern int timeoffset;
57 extern long timecorr;
58 extern char itustr[];
59 extern int mycountrynr;
60
61 int cury, curx;
62 char pxstr[16];
63 char countrystr[26];
64 char zonestr[3];
65 char contstr[3];
66 double bearing;
67 double range;
68
69 char timebuff[80];
70
71 dxcc_data *dx;
72 prefix_data *pfx;
73 double d;
74 time_t now;
75 struct tm *ptr1;
76
77 if (x == SHOWINFO_DUMMY)
78 pfx = prefix_by_index(prefix_count());
79 else
80 pfx = prefix_by_index(x);
81 dx = dxcc_by_index(pfx -> dxcc_index);
82
83 strcpy(pxstr, dx->pfx);
84 strcpy(countrystr, dx->countryname); /* country */
85
86 if (strlen(cqzone) < 2) {
87 if (dx->cq > MAX_ZONES) dx->cq = MAX_ZONES;
88 snprintf(zonestr, sizeof(zonestr), "%02d", dx->cq); /* cqzone */
89 strcpy(cqzone, zonestr);
90 } else {
91 strncpy(zonestr, cqzone, 2);
92 zonestr[2] = '\0';
93 }
94
95 if (strlen(ituzone) < 2) {
96 sprintf(itustr, "%02d", dx->itu); /* itu zone */
97 } else {
98 strncpy(itustr, ituzone, 2);
99 itustr[2] = '\0';
100 }
101
102 if (pfx->timezone != INFINITY)
103 d = pfx->timezone;
104 else
105 d = dx->timezone; /* GMT difference */
106
107 now = (time(0) + (long)((timeoffset - d) * 3600) + timecorr);
108 ptr1 = gmtime(&now);
109 strftime(timebuff, 80, "%H:%M", ptr1);
110
111 if (pfx->lat != INFINITY)
112 DEST_Lat = pfx->lat;
113 else
114 DEST_Lat = dx->lat; /* where is he? */
115 if (pfx->lon != INFINITY)
116 DEST_Long = pfx->lon;
117 else
118 DEST_Long = dx->lon;
119
120 if (pfx->continent != NULL)
121 strncpy(contstr, pfx->continent, 2); /* continent */
122 else
123 strncpy(contstr, dx->continent, 2); /* continent */
124 contstr[2] = '\0';
125
126 getyx(stdscr, cury, curx);
127 attron(COLOR_PAIR(C_HEADER) | A_STANDOUT);
128
129 mvaddstr(LINES - 1, 0, backgrnd_str);
130
131 if (contstr[0] != '-') {
132 mvprintw(LINES - 1, 0, " %s %s", pxstr, countrystr);
133
134 mvprintw(LINES - 1, 26, " %s %s", contstr, zonestr);
135
136 if (x != 0 && x != mycountrynr && 0 == get_qrb(&range, &bearing)) {
137 mvprintw(LINES - 1, 35, "%.0f km/%.0f deg ", range, bearing);
138 }
139
140 mvprintw(LINES - 1, LINELENGTH - 17, " DX time: %s", timebuff);
141 } else {
142 wwv_show_footer();
143 }
144
145 attron(modify_attr(COLOR_PAIR(NORMCOLOR)));
146 move(cury, curx);
147 }
148