| 1 |
// ---------------------------------------------------------------------------- |
| 2 |
// Copyright (C) 2014 |
| 3 |
// David Freese, W1HKJ |
| 4 |
// |
| 5 |
// This file is part of flmsg |
| 6 |
// |
| 7 |
// flrig is free software; you can redistribute it and/or modify |
| 8 |
// it under the terms of the GNU General Public License as published by |
| 9 |
// the Free Software Foundation; either version 3 of the License, or |
| 10 |
// (at your option) any later version. |
| 11 |
// |
| 12 |
// flrig is distributed in the hope that it will be useful, |
| 13 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
// GNU General Public License for more details. |
| 16 |
// |
| 17 |
// You should have received a copy of the GNU General Public License |
| 18 |
// along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 19 |
// ---------------------------------------------------------------------------- |
| 20 |
|
| 21 |
#include <string> |
| 22 |
|
| 23 |
#include "gettext.h" |
| 24 |
#include "status.h" |
| 25 |
#include "util.h" |
| 26 |
|
| 27 |
#include "flmsg_dialog.h" |
| 28 |
#include "flmsg.h" |
| 29 |
|
| 30 |
extern void csv_editor(std::string); |
| 31 |
|
| 32 |
Fl_Group *tab_csv = (Fl_Group *)0; |
| 33 |
|
| 34 |
FTextEdit *txt_csv_msg = (FTextEdit *)0; |
| 35 |
Fl_Button *btn_csv_import = (Fl_Button *)0; |
| 36 |
Fl_Button *btn_csv_export = (Fl_Button *)0; |
| 37 |
Fl_Button *btn_csv_edit = (Fl_Button *)0; |
| 38 |
Fl_Button *btn_csv_view = (Fl_Button *)0; |
| 39 |
|
| 40 |
static void cb_btn_csv_import(Fl_Button*, void*) { |
| 41 |
cb_csv_import_data(); |
| 42 |
} |
| 43 |
|
| 44 |
static void cb_btn_csv_export(Fl_Button*, void*) { |
| 45 |
cb_csv_export_data(false); |
| 46 |
} |
| 47 |
|
| 48 |
static void cb_btn_csv_edit(Fl_Button*, void*) { |
| 49 |
cb_csv_export_data(true); |
| 50 |
} |
| 51 |
|
| 52 |
static void cb_btn_csv_view(Fl_Button*, void*) { |
| 53 |
csv_editor(txt_csv_msg->buffer()->text()); |
| 54 |
} |
| 55 |
|
| 56 |
static void do_read_cb(const char *fn) { |
| 57 |
csv_set_fname(fn); |
| 58 |
} |
| 59 |
|
| 60 |
static void csv_changed(FTextEdit *, void *) |
| 61 |
{ |
| 62 |
estimate(); |
| 63 |
} |
| 64 |
|
| 65 |
void create_csv_tab() |
| 66 |
{ |
| 67 |
tab_csv = new Fl_Group(0, tab_top, 570, 380); |
| 68 |
tab_csv->align(FL_ALIGN_TOP); |
| 69 |
|
| 70 |
btn_csv_import = new Fl_Button(570/2 - 220, tab_top + 5, 100, 24, _("Import CSV")); |
| 71 |
btn_csv_import->tooltip(_("Import data from spreadsheet CSV file")); |
| 72 |
btn_csv_import->callback((Fl_Callback*)cb_btn_csv_import); |
| 73 |
|
| 74 |
btn_csv_export = new Fl_Button(570/2 - 105, tab_top + 5, 100, 24, _("Export CSV")); |
| 75 |
btn_csv_export->tooltip(_("Export data to spreadsheet CSV file")); |
| 76 |
btn_csv_export->callback((Fl_Callback*)cb_btn_csv_export); |
| 77 |
|
| 78 |
btn_csv_view = new Fl_Button(570/2 + 10, tab_top + 5, 100, 24, _("View CSV")); |
| 79 |
btn_csv_view->tooltip(_("")); |
| 80 |
btn_csv_view->callback((Fl_Callback*)cb_btn_csv_view); |
| 81 |
|
| 82 |
btn_csv_edit = new Fl_Button(570/2 + 120, tab_top + 5, 100, 24, _("Edit CSV")); |
| 83 |
btn_csv_edit->tooltip(_("")); |
| 84 |
btn_csv_edit->callback((Fl_Callback*)cb_btn_csv_edit); |
| 85 |
|
| 86 |
txt_csv_msg = new FTextEdit(2, tab_top + 24 + 10, 566, 430 - (tab_top + 24 + 10 + 2)); |
| 87 |
txt_csv_msg->box(FL_DOWN_FRAME); |
| 88 |
txt_csv_msg->color((Fl_Color)FL_BACKGROUND2_COLOR); |
| 89 |
txt_csv_msg->selection_color((Fl_Color)FL_SELECTION_COLOR); |
| 90 |
txt_csv_msg->labeltype(FL_NORMAL_LABEL); |
| 91 |
txt_csv_msg->labelfont(0); |
| 92 |
txt_csv_msg->labelsize(14); |
| 93 |
txt_csv_msg->labelcolor((Fl_Color)FL_FOREGROUND_COLOR); |
| 94 |
txt_csv_msg->align(FL_ALIGN_TOP_LEFT); |
| 95 |
txt_csv_msg->set_read_cb(do_read_cb); |
| 96 |
txt_csv_msg->callback((Fl_Callback*)csv_changed); |
| 97 |
txt_csv_msg->when(FL_WHEN_CHANGED); |
| 98 |
|
| 99 |
tab_csv->end(); |
| 100 |
tab_csv->hide(); |
| 101 |
} |