Login:    Password:      Don't have a username? Register!

Home > Projects > Envoy

Hello World

Here's the code for a minimal "Hellow World" app using convey:

#include <convey.h>

int main( int argc, char** argv )
{
  cvyappwindow app =
    convey_app_new(
      &argc,
      argv,
      "Hello World",
      200,
      100
    );
  convey_label_new(
    convey_app_get_layout( app ),
    "Hello World"
  );
  convey_app_display( app );
  return 0;
}
 

First, we create the application window, using convey_app_new, passing in the command-line parameters, and specifying the titlebar text and window dimensions.

Next, we create a label to hold our message. Note the first argument of any widget creation function is a parent layout - this is required, so in a complex hierarchy of widgets, ensure you create containers first. In this case, we can use the application window itself, which always comes with a built in container layout, which we fetch with convey_app_get_layout.

Lastly, we call convey_app_display to show the window (and any child widgets), and begin the message processing loop. Control will not proceed to any code after this point until the main application window is closed, which will usually imply the program should exit, as we do in this example.

Save the above file as "hello_world.c". To build the program, type gcc `pkg-config --cflags --libs convey` hello_world.c -o cvyhw

Then you should be able to run it using ./cvyhw. A small window will display using whichever display library was selected when you installed libconvey. When you're done marvelling at the splendor of it, simply close the window.