/* Copyright 2015-2017, Stephen Fryatt (info@stevefryatt.org.uk)
 *
 * This file is part of Wimp Programming In C:
 *
 *   http://www.stevefryatt.org.uk/risc-os/wimp-prog
 *
 * Licensed under the EUPL, Version 1.2 only (the "Licence");
 * You may not use this work except in compliance with the
 * Licence.
 *
 * You may obtain a copy of the Licence at:
 *
 *   http://joinup.ec.europa.eu/software/page/eupl
 *
 * Unless required by applicable law or agreed to in
 * writing, software distributed under the Licence is
 * distributed on an "AS IS" basis, WITHOUT WARRANTIES
 * OR CONDITIONS OF ANY KIND, either express or implied.
 *
 * See the Licence for the specific language governing
 * permissions and limitations under the Licence.
 */

/**
 * File: repbox.c
 */

#include "oslib/os.h"
#include "oslib/wimp.h"
#include "oslib/wimpspriteop.h"
#include "sflib/debug.h"

#include <string.h>

#include "repbox.h"

/* Report a message */

void repbox_message(char *message, char *buttons)
{
	os_error			error;
	wimp_error_box_selection	selection = wimp_ERROR_BOX_SELECTED_NOTHING;

	error.errnum = 255;
	strncpy(error.errmess, message, os_ERROR_LIMIT);
	error.errmess[os_ERROR_LIMIT - 1] = '\0';

	selection = wimp_report_error_by_category(&error, wimp_ERROR_BOX_GIVEN_CATEGORY |
		(wimp_ERROR_BOX_CATEGORY_INFO << wimp_ERROR_BOX_CATEGORY_SHIFT) |
		wimp_ERROR_BOX_OK_ICON | wimp_ERROR_BOX_CANCEL_ICON,
		"Example App", "application", wimpspriteop_AREA, buttons);

	switch (selection) {
	case wimp_ERROR_BOX_SELECTED_OK:
		debug_printf("User selected Continue button (code %d)", selection);
		break;
	case wimp_ERROR_BOX_SELECTED_CANCEL:
		debug_printf("User selected Cancel button (code %d)", selection);
		break;
	default:
		debug_printf("User selected custom button %d", selection);
		break;
	}
}

