| 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 |
#include "threads.h" |
| 27 |
|
| 28 |
#include "flmsg_dialog.h" |
| 29 |
#include "flmsg.h" |
| 30 |
|
| 31 |
Fl_Group *tab_custom = (Fl_Group *)0; |
| 32 |
|
| 33 |
FTextView *txt_custom_msg = (FTextView *)0; |
| 34 |
Fl_Button *btn_custom_edit = (Fl_Button *)0; |
| 35 |
Fl_Button *btn_custom_view = (Fl_Button *)0; |
| 36 |
|
| 37 |
static void cb_btn_custom_edit(Fl_Button*, void*) { |
| 38 |
if (custom_select < 0) return; |
| 39 |
handle_type = HANDLE_EDIT; |
| 40 |
std::string url = "http://127.0.0.1:"; |
| 41 |
url.append(sz_srvr_portnbr); |
| 42 |
open_url(url.c_str()); |
| 43 |
} |
| 44 |
|
| 45 |
static void cb_btn_custom_view(Fl_Button*, void*) { |
| 46 |
if (custom_select < 0) return; |
| 47 |
handle_type = HANDLE_VIEW; |
| 48 |
std::string url = "http://127.0.0.1:"; |
| 49 |
url.append(sz_srvr_portnbr); |
| 50 |
open_url(url.c_str()); |
| 51 |
} |
| 52 |
|
| 53 |
static void custom_changed(FTextEdit *, void *) |
| 54 |
{ |
| 55 |
estimate(); |
| 56 |
} |
| 57 |
|
| 58 |
static void do_read_cb(const char *fn) { |
| 59 |
custom_set_fname(fn); |
| 60 |
} |
| 61 |
|
| 62 |
void create_custom_tab() |
| 63 |
{ |
| 64 |
int width = 570; |
| 65 |
tab_custom = new Fl_Group(0, tab_top, 570, 380); |
| 66 |
tab_custom->align(FL_ALIGN_TOP); |
| 67 |
|
| 68 |
btn_custom_edit = new Fl_Button(width/2 - 120, tab_top + 5, 100, 24, _("Edit Form")); |
| 69 |
btn_custom_edit->tooltip(_("")); |
| 70 |
btn_custom_edit->callback((Fl_Callback*)cb_btn_custom_edit); |
| 71 |
|
| 72 |
btn_custom_view = new Fl_Button(width/2 + 20, tab_top + 5, 100, 24, _("View Form")); |
| 73 |
btn_custom_view->tooltip(_("")); |
| 74 |
btn_custom_view->callback((Fl_Callback*)cb_btn_custom_view); |
| 75 |
|
| 76 |
txt_custom_msg = new FTextView(2, tab_top + 24 + 10, 566, 430 - (tab_top + 24 + 10 + 2)); |
| 77 |
txt_custom_msg->box(FL_DOWN_FRAME); |
| 78 |
txt_custom_msg->color((Fl_Color)FL_BACKGROUND2_COLOR); |
| 79 |
txt_custom_msg->selection_color((Fl_Color)FL_SELECTION_COLOR); |
| 80 |
txt_custom_msg->labeltype(FL_NORMAL_LABEL); |
| 81 |
txt_custom_msg->labelfont(0); |
| 82 |
txt_custom_msg->labelsize(14); |
| 83 |
txt_custom_msg->labelcolor((Fl_Color)FL_FOREGROUND_COLOR); |
| 84 |
txt_custom_msg->align(FL_ALIGN_TOP_LEFT); |
| 85 |
txt_custom_msg->set_read_cb(do_read_cb); |
| 86 |
txt_custom_msg->callback((Fl_Callback*)custom_changed); |
| 87 |
txt_custom_msg->when(FL_WHEN_CHANGED); |
| 88 |
|
| 89 |
tab_custom->end(); |
| 90 |
tab_custom->hide(); |
| 91 |
} |