16 InputIP::InputIP(
int x,
int y,
int w,
int h,
const char *label) : Fl_Input(x, y, w, h, label)
21 tooltip(
"Format example: 10.123.4.5");
26 std::istringstream in(value());
30 uint32_t v[4]={256, 256, 256, 256};
31 char s[3]={
' ',
' ',
' '};
32 in >> v[0] >> s[0] >> v[1] >> s[1] >> v[2] >> s[2] >> v[3];
36 for (
int i=0; i<3; i++)
38 if (s[i] !=
'.')
return 0;
50 for (
int i=0; i<4; i++)
52 if (v[i] > 255)
return 0;
57 return ((v[0]<<24) | (v[1]<<16) | (v[2]<<8) | v[3]);
62 std::ostringstream out;
64 out << ((v>>24)&0xff) <<
'.' << ((v>>16)&0xff) <<
'.' << ((v>>8)&0xff) <<
'.' << (v&0xff);
66 value(out.str().c_str());
71 if (event == FL_KEYBOARD && !(Fl::event_key() == FL_Tab))
73 char ascii=Fl::event_text()[0];
75 if (std::isprint(ascii) && !isdigit(ascii) && ascii !=
'.')
81 std::string v=value();
85 int ret=Fl_Input::handle(event);
89 if (
cb && v != value())