CONSTANT 
    class_rec_dialog := "dialogwidgetclassrec",
    class_rec_button := "pushbuttonwidgetclassrec";

CONSTANT
    create_rtn_dialog := "dwt$dialog_box_popup_create",
    create_rtn_button := "dwt$push_button_create";

CONSTANT 
    resource_y := "y",
    resource_x := "x",
    resource_label := "label",
    resource_title := "title",
    resource_activate_callback := "activateCallback",
    resource_conformToText := "conformToText";

PROCEDURE dismiss_window_box

    LOCAL
        callback_args,
        d_box_index,
        status;

    status := GET_INFO (WIDGET, "callback_parameters", callback_args);
    d_box_index := callback_args {"closure"};
    DELETE (d_box_array {d_box_index});
    d_box_array {d_box_index} := TPU$K_UNSPECIFIED;

ENDPROCEDURE;

PROCEDURE create_button_widget (parent, label, closure, program_source, offset)

    LOCAL
        button_widget;

    button_widget :=
        CREATE_WIDGET (pushbutton_class,
                       label,
                       parent,
                       COMPILE (program_source),
                       closure,
                       resource_activate_callback, 0,
                       resource_x, 0,
                       resource_y, offset,
                       resource_conformToText, 1,
                       resource_label, label);
    MANAGE_WIDGET (button_widget);
    offset := offset + 20;

ENDPROCEDURE;

PROCEDURE eve_window_box

    LOCAL
        button_index,
        d_box,
        d_box_index,
        offset;

    CONSTANT
        no_closure := "Closure Not Used";

    !
    ! Define widget classes
    !
    dialog_class := DEFINE_WIDGET_CLASS (
                        class_rec_dialog,
                        create_rtn_dialog);
    pushbutton_class := DEFINE_WIDGET_CLASS (
                        class_rec_button,
                        create_rtn_button);

    ! 
    ! Create the dialog box
    !
    d_box :=
        CREATE_WIDGET (dialog_class,
                       "Window Box",
                       SCREEN,
                       "MESSAGE ('Callback activated')",
                       no_closure,
                       resource_title, "Button Box");

    !
    ! Save the dialog box widget
    !
    IF GET_INFO (d_box_array, "type") <> ARRAY
    THEN
        d_box_array := CREATE_ARRAY;
    ENDIF;

    IF GET_INFO (d_box_array, "last") = TPU$K_UNSPECIFIED
    THEN
        d_box_index := 0;
    ELSE
        d_box_index :=
                GET_INFO (d_box_array, "last") + 1;
    ENDIF;

    d_box_array {d_box_index} := d_box;
    offset := 0;

    create_button_widget (d_box,
                          "Next Window",
                          no_closure,
                          "eve_next_window",
                          offset);
    create_button_widget (d_box,
                          "Previous Window",
                          no_closure,
                          "eve_previous_window",
                          offset);
    create_button_widget (d_box,
                          "Split Window",
                          no_closure,
                          "eve_split_window (2)",
                          offset);
    create_button_widget (d_box,
                          "Delete Window",
                          no_closure,
                          "eve_delete_window",
                          offset);
    create_button_widget (d_box,
                          'Dismiss',
                          d_box_index,
                          'dismiss_window_box',
                          offset);

    !
    ! Manage the buttons, then the dialog box
    !
    manage_widget (d_box);

    RETURN true;

ENDPROCEDURE;

