Programming and Graphics

(Kiana) #1

8.5 GUI programming withGtk+ 283


Figure 8.4.1 A GUI produced byGlui. Data can be entered in the checkbox.

#include "glui.h"

using namespace std;
int prime;

int main(int argc, char* argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUTRGB | GLUTDOUBLE | GLUTDEPTH);
glutInitWindowPosition(50,50);
glutInitWindowSize(300,300);
GLUI *glui = GLUIMaster.createglui( "GLUI");
new GLUICheckbox(glui,"Next",&prime);
(new GLUISpinner(glui,"Prime number:",&prime))




  • setintlimits(10, 60);
    glutMainLoop();
    return 0;
    }





ThreeGluifunctions are called by this program. Running the code produces
the graphics display shown in Figure 8.4.1.


Gluiprogramming requires familiarization with the library nomenclature
and protocols, which are explained in detail in theGluimanual.


Problem


8.4.1. Adapt to C++ and run aGluicode of your choice from theGluidis-
tribution.

8.5 GUI programming with GTK+


A powerful widget library is implemented in theGtk+toolkit included in
several Linux distributions (seehttp://www.gtk.org). Gtk+was originally
developed for the gnu image manipulation program GIMP; accordingly, it is
known as β€œthe GIMP toolkit.”

Free download pdf