Writing Programs Using `newt`
Prev |  | Next

# 3. Windows

While most `newt` applications do use windows, `newt`'s window support is actually extremely limited. Windows must be destroyed in the opposite of the order they were created, and only the topmost window may be active. Corollaries to this are:

- The user may not switch between windows.

- Only the top window may be destroyed.

While this is quite a severe limitation, adopting it greatly simplifies both writing `newt` applications and developing `newt` itself, as it separates `newt` from the world of event-driven programming. However, this tradeoff between function and simplicity may make `newt` unsuitable for some tasks.

## 3.1. Creating Windows

There are two main ways of opening `newt` windows: with or without explicit sizings. When grids (which will be introduced later in this tutorial) are used, a window may be made to just fit the grid. When grids are not used, explicit sizing must be given.

    int newtCenteredWindow(int width, int height, const char * title);
    int newtOpenWindow(int left, int top, int width, int height,
    		   const char * title);

The first of these functions open a centered window of the specified size. The `title` is optional -- if it is `NULL`, then no title is used. `newtOpenWindow*(` is similar, but it requires a specific location for the upper left-hand corner of the window.

## 3.2. Destroying Windows

All windows are destroyed in the same manner, no matter how the windows were originally created.

    void newtPopWindow(void);

This function removes the top window from the display, and redraws the display areas which the window overwrote.

Prev | Home | Next
Basic `Newt` Functions |  | Components