This repository has been archived by the owner on Jul 8, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathurl_window.cxx
98 lines (79 loc) · 2.44 KB
/
url_window.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*
Copyright (C) 2015, 2019 daltomi <[email protected]>
This file is part of flvlc.
flvlc is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
flvlc is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with flvlc. If not, see <http://www.gnu.org/licenses/>.
*/
#include "url_window.hpp"
URL_Window::URL_Window(int x, int y)
: Fl_Menu_Window(x, y, 390, 70, 0), addr(nullptr)
{
input = new Fl_Input(30, 10, 346, 24, "URL:");
input->labelfont(1);
input->labelsize(9);
input->textfont(4);
input->textsize(9);
input->textcolor(Fl_Color(FL_BLUE));
box_info = new Fl_Box(30, 40, 200, 10);
box_info->labelsize(9);
box_info->align(Fl_Align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE));
box_info->label("Specify the protocol: http, ftp,...");
btn_ok = new Fl_Button(245, 40, 60, 20, "&Accept");
btn_ok->box(FL_SHADOW_BOX);
btn_ok->color(FL_BACKGROUND2_COLOR);
btn_ok->labelsize(9);
btn_ok->callback(URL_Window::callback, (void *)this);
btn_ok->deactivate();
btn_cancel = new Fl_Button(316, 40, 60, 20, "&Cancel");
btn_cancel->box(FL_SHADOW_BOX);
btn_cancel->color(FL_BACKGROUND2_COLOR);
btn_cancel->labelsize(9);
btn_cancel->callback(URL_Window::callback, (void *)this);
box(FL_BORDER_BOX);
color((Fl_Color)215);
set_modal();
clear_border();
position(x - (w() / 2), y - (h() / 2));
end();
show();
Fl::add_timeout(0.100f, check_input_empty, (void *)this);
}
URL_Window::~URL_Window()
{
Fl::remove_timeout(URL_Window::check_input_empty);
delete btn_ok;
delete box_info;
delete btn_cancel;
delete input;
}
const char *URL_Window::value() const
{
return addr;
}
void URL_Window::callback(Fl_Widget *w, void *data)
{
URL_Window *win = (URL_Window *)data;
if (win->btn_ok == w) {
win->addr = win->input->value();
}
win->hide();
}
void URL_Window::check_input_empty(void *data)
{
URL_Window *win = (URL_Window *)data;
if (nullptr == win->input->value() or
strlen(win->input->value()) == 0) {
win->btn_ok->deactivate();
} else {
win->btn_ok->activate();
}
Fl::repeat_timeout(0.100f, URL_Window::check_input_empty, data);
}