StringWidgets.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "Basic.h"
4 
6 {
8  : public ValueMixin<LineEdit, std::string, LineEditBuilder>
9  , public ToolTipMixin<LineEditBuilder>
10  {
11  using ValueMixin::ValueMixin;
12  };
13 
15  : public ValueMixin<ComboBox, std::string, ComboBoxBuilder>
16  , public ToolTipMixin<ComboBoxBuilder>
17  {
18  using ValueMixin::ValueMixin;
19 
20  ComboBoxBuilder& options(std::vector<std::string> const& options)
21  {
22  widget().options = options;
23  return *this;
24  }
25  ComboBoxBuilder& addOptions(std::vector<std::string> const& options)
26  {
27  widget().options.insert(widget().options.end(), options.begin(), options.end());
28  return *this;
29  }
30 
31  operator WidgetPtr() const override
32  {
33  ComboBox& w = *dynamic_cast<ComboBox*>(widget_.get());
34  if (!w.options.empty())
35  {
36  const auto it = std::find(
37  w.options.begin(),
38  w.options.end(),
39  getSingleValue<std::string>(w.defaultValue)
40  );
41  if (it == w.options.end())
42  {
43  w.defaultValue = makeValue(w.options.front());
44  }
45  }
46  return widget_;
47  }
48  };
49 }
50 
51 namespace armarx::RemoteGui
52 {
53  inline detail::LineEditBuilder makeLineEdit(std::string const& name)
54  {
55  return detail::LineEditBuilder(name);
56  }
57 
58  inline detail::ComboBoxBuilder makeComboBox(std::string const& name)
59  {
60  return detail::ComboBoxBuilder(name);
61  }
62 }
Basic.h
armarx::RemoteGui::detail::LineEditBuilder
Definition: StringWidgets.h:7
armarx::RemoteGui
Definition: LightweightRemoteGuiComponentPlugin.h:30
armarx::RemoteGui::detail
Definition: Basic.h:10
armarx::RemoteGui::detail::WidgetBuilder::widget_
WidgetPtr widget_
Definition: Basic.h:35
armarx::RemoteGui::makeLineEdit
detail::LineEditBuilder makeLineEdit(std::string const &name)
Definition: StringWidgets.h:53
armarx::RemoteGui::detail::WidgetMixin< ComboBox, ComboBoxBuilder >::widget
ComboBox & widget()
Definition: Basic.h:50
armarx::RemoteGui::detail::ComboBoxBuilder::addOptions
ComboBoxBuilder & addOptions(std::vector< std::string > const &options)
Definition: StringWidgets.h:25
armarx::RemoteGui::detail::ToolTipMixin
Definition: Basic.h:200
armarx::RemoteGui::Client::ComboBox
Definition: Widgets.h:50
armarx::RemoteGui::makeValue
ValueVariant makeValue(bool value)
Definition: Storage.cpp:133
armarx::RemoteGui::detail::ComboBoxBuilder::options
ComboBoxBuilder & options(std::vector< std::string > const &options)
Definition: StringWidgets.h:20
armarx::WidgetDescription::WidgetPtr
::IceInternal::Handle<::armarx::WidgetDescription::Widget > WidgetPtr
Definition: NJointControllerBase.h:66
armarx::RemoteGui::makeComboBox
detail::ComboBoxBuilder makeComboBox(std::string const &name)
Definition: StringWidgets.h:58
armarx::RemoteGui::detail::ComboBoxBuilder
Definition: StringWidgets.h:14
armarx::RemoteGui::detail::ValueMixin
Definition: Basic.h:68