device_choice.cc
Go to the documentation of this file.
1 /*
2  * Roboception GmbH
3  * Munich, Germany
4  * www.roboception.com
5  *
6  * Copyright (c) 2024 Roboception GmbH
7  * All rights reserved
8  *
9  * Author: Heiko Hirschmueller
10  */
11 
12 #include "device_choice.h"
13 
14 DeviceChoice::DeviceChoice(int x, int y, int w, int h, const char *label) :
15  Fl_Choice(x, y, w, h, label)
16 {
17  down_box(FL_GTK_DOWN_BOX);
18 }
19 
20 std::string DeviceChoice::getMAC()
21 {
22  std::string ret;
23 
24  int i=Fl_Choice::value();
25 
26  if (i >= 0 && i < size())
27  {
28  std::string label=menu()[i].label();
29 
30  size_t i=label.find(" - ");
31 
32  if (i != std::string::npos)
33  {
34  ret=label.substr(i+3);
35  }
36  }
37 
38  return ret;
39 }
40 
41 void DeviceChoice::update(const std::vector<std::pair<std::string, std::string> > &list,
42  const std::string &sel_mac)
43 {
44  clear();
45  add("<CUSTOM>", 0, 0, 0, 0);
46 
47  size_t sel=0;
48  for (size_t i=0; i<list.size(); i++)
49  {
50  add((list[i].first+" - "+list[i].second).c_str(), 0, 0, 0, 0);
51 
52  if (list[i].second == sel_mac)
53  {
54  sel=i+1;
55  }
56  }
57 
58  value(static_cast<int>(sel));
59 }
DeviceChoice::DeviceChoice
DeviceChoice(int x, int y, int w, int h, const char *label)
Definition: device_choice.cc:14
device_choice.h
DeviceChoice::update
void update(const std::vector< std::pair< std::string, std::string > > &list, const std::string &sel_mac)
Definition: device_choice.cc:41
DeviceChoice::getMAC
std::string getMAC()
Definition: device_choice.cc:20


rcdiscover
Author(s): Heiko Hirschmueller , Raphael Schaller
autogenerated on Thu Aug 1 2024 02:55:56