14 #include <FL/fl_draw.H>
15 #include <FL/fl_ask.H>
16 #include <FL/filename.H>
25 tooltip(
"Double-click row to open WebGUI in browser.");
37 col_header_height(24);
65 for (
size_t i=0; i<
device.size(); i++)
79 void DeviceList::add(
const char *name,
const char *manufacturer,
const char *model,
const char *sn,
80 const char *ip,
const char *mac,
const char *interface,
bool reachable)
85 for (
size_t i=0; i<
device.size(); i++)
87 if (
device[i].item[5].compare(mac) == 0)
89 k=
static_cast<int>(i);
98 if (
device[k].interface_list.insert(interface).second)
102 std::ostringstream out;
105 for (
const auto &it:
device[k].interface_list)
107 if (!first) out <<
", ";
112 device[k].item[6]=out.str();
113 device[k].reachable|=reachable;
117 device[k].item[7]=
"\u2713";
121 device[k].item[7]=
"\u2717";
133 data.
item[1]=manufacturer;
138 data.
item[6]=interface;
144 data.
item[7]=u8
"\u2713";
148 data.
item[7]=u8
"\u2717";
159 rows(
static_cast<int>(
index.size()));
167 for (
size_t i=0; i<
index.size(); i++)
169 if (row_selected(
static_cast<int>(i)))
171 sel=
static_cast<int>(i);
181 return (sel >= 0 &&
device[
index[sel]].reachable &&
182 device[
index[sel]].item[2].compare(0, 3,
"rc_") == 0);
188 return (sel >= 0 &&
device[
index[sel]].item[2].compare(0, 9,
"rc_visard") == 0);
200 return std::string();
205 std::vector<std::pair<std::string, std::string> > ret;
207 for (
size_t i=0; i<
index.size(); i++)
209 if (!only_rc_visard ||
device[
index[i]].item[2].compare(0, 9,
"rc_visard") == 0)
220 if (r >= 0 && r <
static_cast<int>(
index.size()) && c >= 0 && c < 7)
225 return std::string();
236 std::ostringstream out;
238 out <<
"http://" <<
device[
index[r]].item[4].c_str();
241 if (fl_open_uri(out.str().c_str(), msg, 160) == 0)
253 rows(
static_cast<int>(
index.size()));
263 rows(
static_cast<int>(
index.size()));
271 if (_sort_col >= 0 && _sort_col < 8)
292 int ret=Fl_Table_Row::handle(event);
294 if (Fl::event() == FL_PUSH)
301 for (
size_t i=0; i<
device.size(); i++)
303 device[i].new_discovery=
false;
309 if (Fl::event_button() == FL_LEFT_MOUSE)
311 if (callback_context() == CONTEXT_COL_HEADER)
319 if (Fl::event_clicks() == 1 && callback_context() == CONTEXT_CELL)
327 else if (Fl::event_button() == FL_MIDDLE_MOUSE)
329 if (callback_context() == CONTEXT_CELL)
333 std::string value=
getCell(callback_row(), callback_col());
334 select_row(callback_row());
336 Fl::copy(value.c_str(),
static_cast<int>(value.size()), 0);
348 else if (Fl::event() == FL_RELEASE && Fl::event_button() == FL_LEFT_MOUSE)
360 case CONTEXT_STARTPAGE:
361 fl_font(FL_HELVETICA, 14);
364 case CONTEXT_RC_RESIZE:
368 for (
int i=0; i<cols()-1; i++)
373 int last_col=cols()-1;
376 if (cw+col_width(last_col) != tiw)
378 col_width(last_col, tiw-cw);
384 case CONTEXT_COL_HEADER:
386 static const char *header[]={
"Name",
"Manufacturer",
"Model",
"Serial",
387 "IP Address",
"MAC Address",
"Interface(s)",
"Reachable"};
389 fl_push_clip(X, Y, W, H);
390 fl_draw_box(FL_THIN_UP_BOX, X, Y, W, H, row_header_color());
391 fl_color(FL_INACTIVE_COLOR);
397 std::ostringstream out;
398 out << header[COL] <<
' ';
409 fl_draw(out.str().c_str(), X, Y, W, H, FL_ALIGN_LEFT);
413 fl_draw(header[COL], X, Y, W, H, FL_ALIGN_LEFT);
422 fl_push_clip(X, Y, W, H);
424 if (row_selected(ROW))
427 fl_color(0x0c84a200);
438 fl_rectf(X, Y, W, H);
440 if (row_selected(ROW))
446 fl_color(0x20202000);
451 fl_draw(
device[
index[ROW]].item[COL].c_str(), X+3, Y, W, H, FL_ALIGN_LEFT);
455 fl_draw(
device[
index[ROW]].item[COL].c_str(), X+3, Y, W, H, FL_ALIGN_CENTER);
508 for (
int k=0; k<7 && !found; k++)
528 while (k <
index.size())
539 if (k >=
index.size())
553 for (
size_t i=0; i<
device.size(); i++)