GrNewWindowEx()

Name

GrNewWindowEx() -- Create a new window

Synopsis

GR_WINDOW_ID GrNewWindowEx ( GR_WM_PROPS props , GR_CHAR * title , GR_WINDOW_ID parent , GR_COORD x , GR_COORD y , GR_COORD width , GR_COORD height , GR_COLOR background );

Description

This function will create a new window with the specified parent window and the specified window attributes and properties.

Parameters

TypeNameDescription
GR_WM_PROPSpropsWindow manager properties for this window.
GR_CHARtitleThe text that will appear in the title bar of this window if the window is a top level window.
GR_WINDOW_IDparentThe parent of window of the window that will be created.
GR_COORDxThe X position of the new window with respect to its parent window.
GR_COORDyThe Y position of the new window with respect to its parent window.
GR_COORDwidthThe width (in pixels) of the new window.
GR_COORDheightThe hieght (in pixels) of the new window.
GR_COLORbackgroundThe background color of this window.

Returns

The ID of the newly created window or 0 in case of failure.

Example

Example 2-1. Using GrNewWindowEx()

 
#include <stdio.h>
#define MWINCLUDECOLORS
#include "microwin/nano-X.h"

GR_WINDOW_ID  wid;
GR_GC_ID      gc;

void event_handler (GR_EVENT *event);

int main (void)
{
    if (GrOpen() < 0)
    {
        fprintf (stderr, "GrOpen failed");
        exit (1);
    }

    gc = GrNewGC();
    GrSetGCUseBackground (gc, GR_FALSE);
    GrSetGCForeground (gc, RED);

    wid = GrNewWindowEx (GR_WM_PROPS_APPFRAME |
                         GR_WM_PROPS_CAPTION  |
                         GR_WM_PROPS_CLOSEBOX,
                         "Hello Window",
                         GR_ROOT_WINDOW_ID, 
                         50, 50, 200, 100, WHITE);

    GrSelectEvents (wid, GR_EVENT_MASK_EXPOSURE | 
                         GR_EVENT_MASK_CLOSE_REQ);

    GrMapWindow (wid);
    GrMainLoop (event_handler);
}

void event_handler (GR_EVENT *event)
{
    switch (event->type)
    {
    case GR_EVENT_TYPE_EXPOSURE:
        GrText (wid, gc, 50, 50, 
                "Hello World",  -1, GR_TFASCII);
        break;

    case GR_EVENT_TYPE_CLOSE_REQ:
        GrClose();
        exit (0);
    }
}

See Also

GR_WM_PROPS, GrDestroyWindow(), GrNewWindow(), GrNewInputWindow(), GrSetWMProperties(), GrGetWMProperties(), Window Functions.