Integrating Views with an X Application Using libxviews

The Xlib version has the capability of integrating any Xlib-based application as soon as it is provided a pointer to a Display object, a Window to draw to, and a way to receive events from it.

In the following sections, you will find information on:

Integration Steps

To use Views with any Xlib-based toolkit, you have to:

Create an IlvDisplay instance using an existing X Display.

Use the IlvDisplay constructor:

IlvDisplay::IlvDisplay(IlAny exitingXDisplay, const char* name);

For example:

Display* xdisplay;

// ... initialize this Display*: xdisplay = XOpenDisplay(...);

IlvDisplay* ilvdisplay = new IlvDisplay((IlAny)xdisplay, "Views");

Create some IlvView or IlvContainer instances using an existing X Window:

Use the IlvView constructor:

IlvView::IlvView(IlvDisplay* display,

IlvSystemView existingXWindow)

For example:

IlvDisplay* display;

// initialize this 'display'

Window xWindow;

// initialize this X window

IlvView* view = new IlvView(display, (IlvSystemView)xWindow);

or

IlvContainer* container = new IlvContainer(display,

(IlvSystemView)xWindow);

Manage the events in these IlvView views:

Once you receive an X event, you must call

IlvEventLoop::getEventLoop()->dispatchEvent(&xevent);

Complete Template

The main procedure looks like this:

main()

{

// Initialize your toolkit

Display* xdisplay;

xdisplay = // XOpenDisplay...;

// Initialize an IlvDisplay

IlvDisplay* ilvdisplay = new IlvDisplay((IlAny)xdisplay, "Views");

// Create an X window:

Window xwindow;

xwindow = // ...;

// Create an IlvContainer

IlvContainer* container = new IlvContainer(display,(IlvSystemView)xwindow);

container->addObject(new IlvLabel(...));

// Now call the toolkit main event loop

}