Using NAS GUI



See readme.txt for a general introduction and information about how to install NAS GUI and link your program with it.

int init_nas(void);
Called after allegro_init and set_gfx_mode to initialize NAS GUI. It will return NAS_OK if everything went OK, NAS_ERROR otherwise. This function automatically loads the default skin set so there is no need to call nas_load_skin unless you change themes.

void nas_exit(void);
Shuts down the NAS GUI system, important to call before exiting your program.

int nas_load_skin(char *path);
Loads a theme to be used by NAS GUI, path must be a valid .skn file. It will return 1 if everything loaded OK, 0 otherwise. If 0 is returned you can call allegro_message("An error occurred in %s skin\n%s", path, nas_error[nas_errno]); to find the specific cause of the error.

void nas_destroy_skin(void);
Destroys all fonts, cursors, and the datafile used by the theme in nas_load_skin.

NAS_PLAYER *nas_init_dialog(NAS_WIDGET *dialog, NAS_WIDGET *focus_obj);
This function provides lower level access to the same functionality as nas_do_dialog(), but allows you to combine a dialog box with your own program control structures. It initializes a dialog, returning a pointer to a player object that can be used with nas_update_dialog() and nas_shutdown_dialog(). With these functions, you could implement your own version of nas_do_dialog() with the lines:

        NAS_PLAYER *player = nas_init_dialog(dialog, focus_obj);
        while (nas_update_dialog(player))
            nas_update_screen();
        nas_shutdown_dialog(player);

void nas_do_dialog(NAS_WIDGET *dialog, BITMAP *buffer, NAS_WIDGET *focus_obj);
The basic dialog manager function. This displays a dialog (an array of dialog objects, terminated by one with a NULL dialog procedure), and sets the input focus to the focus_obj (NULL if you don't want anything to have the focus). It interprets user input and dispatches messages as they are required, until one of the dialog procedures tells it to close the dialog. Buffer is set to whatever bitmap you want the GUI to be drawn to (this can be a video bitmap, in which you can set nas_screen to a visible video bitmap).

int nas_update_dialog(NAS_PLAYER *player);
Updates the status of a dialog object returned by nas_init_dialog(). Returns TRUE if the dialog is still active, or FALSE if it has terminated. Upon a return value of FALSE, it is up to you whether to call nas_shutdown_dialog() or to continue execution. The object that requested the exit can be determined from the player->obj field.

void nas_shutdown_dialog(NAS_PLAYER *player);
Destroys a dialog player object returned by nas_init_dialog().

void nas_update_screen(void);
Updates all dialog objects to the screen if any parts have changed using a DRS (Dirty Rectangles) system. This must be called if you are to implement your own custom nas_do_dialog(); procedure, however, nas_do_dialog() calls this for you.

void nas_update_gui(void);
Updates all the dialog objects in the dialog queue, this function unlike nas_do_dialog is non-blocking meaning that it returns immediately. This can be called inside your main loop to update limitless dialogs at once.


Back to Contents