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> 40 auto popup = f->createPopupDialog();
41 auto mb = f->createMarginBox(popup, 1, 0.1);
42 auto vbox = f->createVBox(mb);
43 f->createLabel(vbox, label);
45 auto bbox = f->createButtonBox(vbox);
46 auto okButton = f->createPushButton(bbox,
"OK");
47 okButton->setRole(YOKButton);
48 okButton->setDefaultButton();
52 auto event = popup->waitForEvent();
53 if (event && (event->widget() == okButton ||
event->eventType() == YEvent::CancelEvent))
67 static void addTextField(
YWidget *parent,
const string &val)
78 auto popup = f->createPopupDialog();
79 auto mb = f->createMarginBox(popup, 1, 0.1);
80 auto vbox = f->createVBox(mb);
81 f->createHeading(vbox, label);
82 YWidget *arrayBox = f->createVBox(vbox);
85 for(
auto&& str: array) addTextField(arrayBox, str);
87 auto addButton = f->createPushButton(vbox,
"Add Item");
89 auto spacing = f->createVSpacing(vbox, 1);
92 auto bbox = f->createButtonBox(vbox);
93 auto okButton = f->createPushButton(bbox,
"OK");
94 okButton->setRole(YOKButton);
95 okButton->setDefaultButton();
96 auto cancelButton = f->createPushButton(bbox,
"Cancel");
97 cancelButton->setRole(YCancelButton);
103 auto event = popup->waitForEvent();
105 if (!event)
continue;
108 if (event->widget() == cancelButton ||
event->eventType() == YEvent::CancelEvent)
113 else if (event->widget() == okButton)
118 for(
auto&& widget: *arrayBox)
121 if (input) array.push_back(input->value());
127 else if (event->widget() == addButton)
129 addTextField(arrayBox,
"");
130 popup->recalcLayout();
133 yuiWarning() <<
"Unknown event " <<
event << endl;
143 YPopupInternal::StringArray ret {
"",
"",
"" };
149 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.