brewpanel/dlgBrew.c

Sat, 07 Nov 2015 22:04:17 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Sat, 07 Nov 2015 22:04:17 +0100
changeset 409
cdf68044adaf
child 410
e3f8a51b566a
permissions
-rw-r--r--

Added a new brewpanel program that runs on an SDL/X screen. It will be an emulator for the hardware panels. Development version 0.5.0

/*****************************************************************************
 * Copyright (C) 2015
 *   
 * Michiel Broek <mbroek at mbse dot eu>
 *
 * This file is part of the mbsePi-apps
 *
 * The gui code is based on the gui from the emulator ARAnyM,
 * Copyright (c) 2004 Petr Stehlik of ARAnyM dev team
 *
 * mbsePi-apps is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation; either version 2, or (at your option) any
 * later version.
 *
 * mbsePi-apps is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with mbsePi-apps; see the file COPYING.  If not, write to the Free
 * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
 *****************************************************************************/

#include "brewpanel.h"
#include "dlgBrew.h"
#include "sdlgui.h"

extern SDL_Surface	*PAN_surface;
extern int		my_shutdown;


#define	MAINDLG_B1	 2
#define MAINDLG_B2	 3
#define MAINDLG_B3	 4
#define MAINDLG_B4	 5
#define MAINDLG_QUIT     6


/* The main dialog: */
static SGOBJ maindlg[] =
{
/*        type      flags     state   x    y    w    h  txt  */
	{ SGBOX,    0,           0,   0,   0, 374, 470, NULL },
	{ SGLCD,    0,           0,  -1,  44,  20,   4, NULL },
	{ SGBUTTON, 0,           0,  85, 130,  20,  20, (char *)"1" },
	{ SGBUTTON, 0,           0, 145, 130,  20,  20, (char *)"2" },
	{ SGBUTTON, 0,           0, 205, 130,  20,  20, (char *)"3" },
	{ SGBUTTON, 0,           0, 265, 130,  20,  20, (char *)"4" },
	{ SGBUTTON, 0,           0, 147, 430,  80,  20, (char *)"Quit" },
	{ SGTTF,    0,           0,   5, 280,   0,   0, (char *)"The quick brown fox jumps over the lazy dog" },
	{ -1,       0,           0,   0,   0,   0,   0, NULL }
};




/*
 * This functions sets up the actual font and then displays the brew panel dialog.
 */
int Dialog_BrewDlg(void)
{
    int retbut;
    int bOldMouseVisibility;
    int nOldMouseX, nOldMouseY;

    if (SDLGui_SetScreen(PAN_surface)) {
	syslog(LOG_NOTICE, "SDLGui_SetScreen(PAN_surface) failed: %s", SDL_GetError());
	return FALSE;
    }

    SDL_GetMouseState(&nOldMouseX, &nOldMouseY);
    bOldMouseVisibility = SDL_ShowCursor(SDL_QUERY);
    SDL_ShowCursor(SDL_ENABLE);

    SDLGui_CenterDlg(maindlg);

    do {
	retbut = SDLGui_DoDialog(maindlg, NULL);
 SDLGui_LCDwrite(maindlg, 0, 0, 'A', 0);

	fprintf(stdout, "SDLGui_DoDialog retbut=%d\n", retbut);

	switch (retbut) {
	    case MAINDLG_B1:	fprintf(stdout, "Button 1\n");
		    		break;
	    case MAINDLG_B2:	fprintf(stdout, "Button 2\n");
				break;
	    case MAINDLG_B3:	fprintf(stdout, "Button 3\n");
				break;
	    case MAINDLG_B4:	fprintf(stdout, "Button 4\n");
				break;
	    case MAINDLG_QUIT:	my_shutdown = TRUE;
				break;
	}

    } while (retbut != SDLGUI_QUIT && retbut != SDLGUI_ERROR && !my_shutdown);

    SDL_ShowCursor(bOldMouseVisibility);

    return TRUE;
}

mercurial