18 #include <YWidgetFactory.h> 20 #include <YLayoutBox.h> 21 #include <YAlignment.h> 22 #include <YButtonBox.h> 23 #include <YPushButton.h> 24 #include <YInputField.h> 28 #define YUILogComponent "ui-popup" 31 #include <YPopupInternal.h> 37 auto popup = f->createPopupDialog();
38 auto mb = f->createMarginBox(popup, 1, 0.1);
39 auto vbox = f->createVBox(mb);
40 f->createLabel(vbox, label);
42 auto bbox = f->createButtonBox(vbox);
43 auto okButton = f->createPushButton(bbox,
"OK");
44 okButton->setRole(YOKButton);
45 okButton->setDefaultButton();
49 auto event = popup->waitForEvent();
50 if (event && (event->widget() == okButton ||
event->eventType() == YEvent::CancelEvent))
64 static void addTextField(
YWidget *parent,
const std::string &val)
75 auto popup = f->createPopupDialog();
76 auto mb = f->createMarginBox(popup, 1, 0.1);
77 auto vbox = f->createVBox(mb);
78 f->createHeading(vbox, label);
79 YWidget *arrayBox = f->createVBox(vbox);
82 for(
auto&& str: array) addTextField(arrayBox, str);
84 auto addButton = f->createPushButton(vbox,
"Add Item");
86 auto spacing = f->createVSpacing(vbox, 1);
89 auto bbox = f->createButtonBox(vbox);
90 auto okButton = f->createPushButton(bbox,
"OK");
91 okButton->setRole(YOKButton);
92 okButton->setDefaultButton();
93 auto cancelButton = f->createPushButton(bbox,
"Cancel");
94 cancelButton->setRole(YCancelButton);
100 auto event = popup->waitForEvent();
102 if (!event)
continue;
105 if (event->widget() == cancelButton ||
event->eventType() == YEvent::CancelEvent)
110 else if (event->widget() == okButton)
115 for(
auto&& widget: *arrayBox)
118 if (input) array.push_back(input->value());
124 else if (event->widget() == addButton)
126 addTextField(arrayBox,
"");
127 popup->recalcLayout();
130 yuiWarning() <<
"Unknown event " <<
event << std::endl;
140 YPopupInternal::StringArray ret {
"",
"",
"" };
146 return StringArray();
static YWidgetFactory * widgetFactory()
Return the widget factory that provides all the createXY() methods for standard (mandatory, i.e.
Transport class for the value of simple properties.