Hello, World! example

Traditionally, user guides start with a "Hello, World!" program, which just prints this text.

It is explained in detail in the Getting started section.

Example 1.1. Hello, World!

#include <ufo/ufo.hpp>
#include <ufo/ux/ux.hpp>

using namespace ufo;

int
main(int argc, char ** argv) {
  // Creates the toolkit object, initializes UFO
  UXToolkit tk;
  // loads the video driver and creates the event queue
  UXDisplay display;

  // Creates a frame
  UXFrame * frame = display.createFrame();
  frame->setTitle("base code");
  frame->setBounds(0, 0, 640, 480);
  frame->setVisible(true);

  frame->getContentPane()->add(new ULabel("Hello, World!"));

  // main event loop
  bool done = false;
  while (!done) {
    // pumps events from the system event queue
    display.pumpEvents();
    // dispatchEvents returns true when a quit event was processed.
    done = display.dispatchEvents();

    if (!done) {
      // repaint the frame
      frame->repaint();
      // give other processes a chance
      tk.sleep(1);
    }
  }

  return 0;
}

On Unix like systems, you can compile this example via:

g++ -o hello hello.cpp `pkg-config --cflags --libs ufo`