Skip to content

Instantly share code, notes, and snippets.

@mvidner
Last active December 25, 2015 16:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mvidner/7004734 to your computer and use it in GitHub Desktop.
Save mvidner/7004734 to your computer and use it in GitHub Desktop.
// https://github.com/libyui/libyui/issues/61
// g++ -std=c++11 $(pkg-config --cflags --libs libyui) -o a.out libyui-61-deletechildren.cc
#include "YUI.h"
#include "YWidgetFactory.h"
#include "YDialog.h"
#include "YLayoutBox.h"
#include "YSpacing.h"
#include "YLabel.h"
#include "YPushButton.h"
#include "YEvent.h"
#include "YDialogSpy.h"
#include "YReplacePoint.h"
int main(int argc, char **argv)
{
/***************************************************************************************/
auto wf = YUI::widgetFactory();
auto mainDialog = wf->createMainDialog();
auto rp = wf->createReplacePoint(mainDialog);
auto mainVBox = wf->createVBox(rp);
auto mainLabel = wf->createLabel(mainVBox, "Hello world!");
wf->createVSpacing(mainVBox);
auto mainButton = wf->createPushButton(mainVBox, "Close");
mainDialog->pollEvent();
YDialogSpy::showDialogSpy();
while (true) {
auto event = mainDialog->waitForEvent();
if (event)
if (event->eventType() == YEvent::CancelEvent || event->widget() == mainButton)
break;
}
rp->deleteChildren();
/*****************************************************************************************/
mainVBox = wf->createVBox(rp);
mainLabel = wf->createLabel(mainVBox, "Hello world #2!");
wf->createVSpacing(mainVBox);
mainButton = wf->createPushButton(mainVBox, "Close #2");
rp->showChild();
mainDialog->recalcLayout();
mainDialog->pollEvent();
YDialogSpy::showDialogSpy();
while (true) {
auto event = mainDialog->waitForEvent();
if (event)
if (event->eventType() == YEvent::CancelEvent || event->widget() == mainButton)
break;
}
mainDialog->destroy();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment