brewpanel/sdlgui.c

Sun, 08 Nov 2015 17:49:29 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Sun, 08 Nov 2015 17:49:29 +0100
changeset 412
f1a042a59b61
parent 410
e3f8a51b566a
child 415
d9b7e0705f56
permissions
-rw-r--r--

Basic ideas to write to the simulated LCD display are in place.

409
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 /*****************************************************************************
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2 * Copyright (C) 2015
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3 *
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4 * Michiel Broek <mbroek at mbse dot eu>
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5 *
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6 * This file is part of the mbsePi-apps emulator
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7 *
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8 * The gui code is based on the gui from the emulator ARAnyM,
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9 * Copyright (c) 2004 Petr Stehlik of ARAnyM dev team
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10 *
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11 * This progrm is free software; you can redistribute it and/or modify it
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12 * under the terms of the GNU General Public License as published by the
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13 * Free Software Foundation; either version 2, or (at your option) any
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14 * later version.
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
15 *
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
16 * mbsePi-apps is distributed in the hope that it will be useful, but
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
19 * General Public License for more details.
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
20 *
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
21 * You should have received a copy of the GNU General Public License
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
22 * along with mbsePi-apps; see the file COPYING. If not, write to the Free
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
23 * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
24 *****************************************************************************/
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
25
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
26 #include "brewpanel.h"
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
27 #include "sdlgui.h"
410
e3f8a51b566a Fixed compiling on systems without SDL libraries, and they don't need tha brewpanel program.
Michiel Broek <mbroek@mbse.eu>
parents: 409
diff changeset
28
e3f8a51b566a Fixed compiling on systems without SDL libraries, and they don't need tha brewpanel program.
Michiel Broek <mbroek@mbse.eu>
parents: 409
diff changeset
29 #ifdef HAVE_SDL_SDL_H
e3f8a51b566a Fixed compiling on systems without SDL libraries, and they don't need tha brewpanel program.
Michiel Broek <mbroek@mbse.eu>
parents: 409
diff changeset
30
409
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
31 #include "lcdfont10x16.h"
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
32
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
33
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
34 static SDL_Surface *pSdlGuiScrn; /* Pointer to the actual main SDL screen surface */
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
35 static SDL_Surface *pFontGfx = NULL; /* The LCD font graphics */
412
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
36 static SDL_Surface *pBgSurface; /* Pointer to the application SDL screen surface */
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
37 static SDL_Rect dlgrect, bgrect;
409
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
38 static int fontwidth, fontheight; /* Width & height of the actual font */
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
39 TTF_Font *pFont = NULL; /* TTF font for buttons etc. */
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
40
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
41 extern int my_shutdown;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
42
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
43
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
44 /*-----------------------------------------------------------------------*/
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
45 /*
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
46 * Load an 1 plane XBM into a 8 planes SDL_Surface.
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
47 */
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
48 static SDL_Surface *SDLGui_LoadXBM(int w, int h, const char *pXbmBits)
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
49 {
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
50 SDL_Surface *bitmap;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
51 Uint8 *dstbits;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
52 const Uint8 *srcbits;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
53 int x, y, srcpitch, mask;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
54
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
55 srcbits = (Uint8 *)pXbmBits;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
56
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
57 /* Allocate the bitmap */
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
58 if ((bitmap = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 8, 0, 0, 0, 0)) == NULL) {
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
59 syslog(LOG_NOTICE, "Failed to allocate bitmap: %s", SDL_GetError());
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
60 return NULL;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
61 }
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
62
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
63 srcpitch = ((w + 7) / 8);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
64 dstbits = (Uint8 *)bitmap->pixels;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
65 mask = 1;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
66
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
67 /* Copy the pixels */
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
68 for (y = 0 ; y < h ; y++) {
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
69 for (x = 0 ; x < w ; x++) {
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
70 dstbits[x] = (srcbits[x / 8] & mask) ? 1 : 0;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
71 mask <<= 1;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
72 mask |= (mask >> 8);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
73 mask &= 0xFF;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
74 }
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
75 dstbits += bitmap->pitch;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
76 srcbits += srcpitch;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
77 }
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
78
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
79 return bitmap;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
80 }
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
81
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
82
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
83
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
84 /*
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
85 * Initialize the GUI.
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
86 */
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
87 int SDLGui_Init(void)
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
88 {
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
89 char *Pt = NULL;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
90
412
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
91 SDL_Color blackWhiteColors[2] = {{255, 255, 255, 0}, {53, 59, 61, 0}};
409
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
92
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
93 /*
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
94 * Initialize the LCD font graphics:
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
95 */
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
96 pFontGfx = SDLGui_LoadXBM(lcdfont10x16_width, lcdfont10x16_height, lcdfont10x16_bits);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
97 if (pFontGfx == NULL) {
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
98 syslog(LOG_NOTICE, "Error: Can not init font graphics!");
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
99 return -1;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
100 }
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
101
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
102 /* Set color palette of the LCD font graphics: */
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
103 SDL_SetColors(pFontGfx, blackWhiteColors, 0, 2);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
104
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
105 /* Set font color 0 as transparent: */
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
106 SDL_SetColorKey(pFontGfx, (SDL_SRCCOLORKEY|SDL_RLEACCEL), 0);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
107
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
108 if (TTF_Init() == -1) {
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
109 syslog(LOG_NOTICE, "Could not init SDL_ttf");
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
110 return -1;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
111 }
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
112
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
113 /*
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
114 * Load TTF font for the dialogs
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
115 */
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
116 Pt = calloc(1024, sizeof(char));
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
117 sprintf(Pt, "%s", "/usr/share/fonts/TTF/DejaVuSans.ttf");
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
118 if ((pFont = TTF_OpenFont(Pt, 14 )) == NULL) {
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
119 sprintf(Pt, "%s", "/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf");
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
120 if ((pFont = TTF_OpenFont(Pt, 14 )) == NULL) {
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
121 sprintf(Pt, "%s", "/usr/share/fonts/truetype/freefont/DejaVuSans.ttf");
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
122 if ((pFont = TTF_OpenFont(Pt, 14 )) == NULL) {
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
123 syslog(LOG_NOTICE, "Could not load DejaVuSans.ttf");
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
124 return -1;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
125 }
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
126 }
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
127 }
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
128 syslog(LOG_NOTICE, "Using ttf font: %s\n", Pt);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
129 free(Pt);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
130 Pt = NULL;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
131
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
132 return 0;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
133 }
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
134
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
135
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
136
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
137 /*
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
138 * Uninitialize the GUI.
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
139 */
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
140 int SDLGui_UnInit(void)
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
141 {
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
142 if (pFont)
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
143 TTF_CloseFont(pFont);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
144 pFont = NULL;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
145
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
146 if (pFontGfx)
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
147 SDL_FreeSurface(pFontGfx);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
148 pFontGfx = NULL;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
149
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
150 return 0;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
151 }
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
152
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
153
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
154
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
155 /*
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
156 * Inform the SDL-GUI about the actual SDL_Surface screen pointer and
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
157 * prepare the font to suit the actual resolution.
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
158 */
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
159 int SDLGui_SetScreen(SDL_Surface *pScrn)
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
160 {
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
161 pSdlGuiScrn = pScrn;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
162
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
163 if (pFontGfx == NULL) {
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
164 syslog(LOG_NOTICE, "Error: A problem with the font occured!");
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
165 return -1;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
166 }
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
167
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
168 /* Get the font width and height: */
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
169 fontwidth = pFontGfx->w/16;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
170 fontheight = pFontGfx->h/16;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
171
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
172 return 0;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
173 }
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
174
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
175
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
176
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
177 /*
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
178 * Center a dialog so that it appears in the middle of the screen.
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
179 * Note: We only store the coordinates in the root box of the dialog,
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
180 * all other objects in the dialog are positioned relatively to this one.
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
181 */
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
182 void SDLGui_CenterDlg(SGOBJ *dlg)
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
183 {
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
184 dlg[0].x = (pSdlGuiScrn->w/1-dlg[0].w)/2;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
185 dlg[0].y = (pSdlGuiScrn->h/1-dlg[0].h)/2;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
186 }
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
187
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
188
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
189
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
190 /*
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
191 * Draw a text string using TTF
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
192 */
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
193 static void SDLGui_TTF(int x, int y, const char *txt)
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
194 {
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
195 SDL_Rect offset;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
196 SDL_Color textColor = { 0, 0, 0 };
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
197 SDL_Surface* message = NULL;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
198
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
199 message = TTF_RenderText_Solid(pFont, txt, textColor);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
200 offset.x = x;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
201 offset.y = y;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
202 SDL_BlitSurface(message, NULL, pSdlGuiScrn, &offset);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
203 SDL_FreeSurface(message);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
204 message = NULL;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
205 }
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
206
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
207
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
208
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
209 /*
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
210 * Draw a dialog TTF text object.
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
211 */
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
212 static void SDLGui_DrawTTF(const SGOBJ *tdlg, int objnum)
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
213 {
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
214 int x, y;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
215
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
216 x = (tdlg[0].x + tdlg[objnum].x);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
217 y = (tdlg[0].y + tdlg[objnum].y);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
218 SDLGui_TTF(x, y, tdlg[objnum].txt);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
219 }
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
220
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
221
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
222
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
223 /*
412
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
224 * Draw the cursor
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
225 */
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
226 void SDLGui_Cursor(int x, int y)
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
227 {
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
228 SDL_Rect dr;
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
229 Uint32 color = SDL_MapRGB(pSdlGuiScrn->format, 53, 59, 61);
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
230
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
231 dr.x=x;
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
232 dr.y=y;
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
233 dr.w=fontwidth;
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
234 dr.h=fontheight;
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
235
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
236 SDL_FillRect(pSdlGuiScrn, &dr, color);
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
237 SDL_UpdateRect(pSdlGuiScrn, x, y, fontwidth, fontheight);
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
238 }
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
239
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
240
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
241
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
242 /*
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
243 * Draw a text character
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
244 */
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
245 void SDLGui_Char(int x, int y, Uint8 c, int bLight)
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
246 {
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
247 SDL_Rect sr, dr;
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
248 Uint32 bg;
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
249
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
250 if (bLight)
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
251 bg = SDL_MapRGB(pSdlGuiScrn->format,156,235, 4);
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
252 else
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
253 bg = SDL_MapRGB(pSdlGuiScrn->format, 94,147, 69);
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
254
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
255 sr.x=fontwidth*(c%16);
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
256 sr.y=fontheight*(c/16);
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
257 sr.w=fontwidth;
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
258 sr.h=fontheight;
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
259 dr.x=x;
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
260 dr.y=y;
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
261 dr.w=fontwidth;
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
262 dr.h=fontheight;
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
263
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
264 SDL_FillRect(pSdlGuiScrn, &dr, bg);
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
265 SDL_BlitSurface(pFontGfx, &sr, pSdlGuiScrn, &dr);
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
266 SDL_UpdateRect(pSdlGuiScrn, x, y, fontwidth, fontheight);
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
267 }
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
268
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
269
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
270
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
271 /*
409
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
272 * Draw a text string.
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
273 */
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
274 static void SDLGui_Text(int x, int y, const char *txt)
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
275 {
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
276 int i;
412
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
277 Uint8 c;
409
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
278 SDL_Rect sr, dr;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
279
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
280 for (i=0; txt[i]!=0; i++) {
412
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
281 c = txt[i] & 0xff;
409
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
282 sr.x=fontwidth*(c%16);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
283 sr.y=fontheight*(c/16);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
284 sr.w=fontwidth;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
285 sr.h=fontheight;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
286 dr.x=x+i*(fontwidth+2);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
287 dr.y=y;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
288 dr.w=fontwidth;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
289 dr.h=fontheight;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
290 SDL_BlitSurface(pFontGfx, &sr, pSdlGuiScrn, &dr);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
291 }
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
292 }
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
293
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
294
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
295
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
296 /*
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
297 * Draw a dialog text object.
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
298 */
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
299 static void SDLGui_DrawText(const SGOBJ *tdlg, int objnum)
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
300 {
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
301 int x, y;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
302
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
303 x = (tdlg[0].x + tdlg[objnum].x);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
304 y = (tdlg[0].y + tdlg[objnum].y);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
305 SDLGui_Text(x, y, tdlg[objnum].txt);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
306 }
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
307
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
308
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
309
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
310 /*
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
311 * Draw a dialog LCD object.
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
312 */
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
313 static void SDLGui_DrawLCD(const SGOBJ *bdlg, int objnum)
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
314 {
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
315 SDL_Rect rect;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
316 int x, y, w, h, offset, border = 4;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
317 Uint32 bg0 = SDL_MapRGB(pSdlGuiScrn->format, 94,147, 69);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
318 Uint32 bg1 = SDL_MapRGB(pSdlGuiScrn->format,156,235, 4);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
319 Uint32 bc = SDL_MapRGB(pSdlGuiScrn->format, 32, 32, 32);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
320 Uint32 bg;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
321
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
322 /*
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
323 * Width and height are given in character columns and rows,
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
324 * so calculate the display size in pixels.
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
325 */
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
326 w = bdlg[objnum].w * (fontwidth + 2) + 10;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
327 h = bdlg[objnum].h * (fontheight + 2) + 4;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
328
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
329 if (bdlg[objnum].x == -1) {
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
330 /*
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
331 * Auto center
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
332 */
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
333 x = (bdlg[0].w - w) / 2;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
334 } else {
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
335 x = bdlg[objnum].x;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
336 }
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
337 y = bdlg[objnum].y;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
338 if (objnum > 0) { /* Since the root object is a box, too, */
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
339 /* we have to look for it now here and only */
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
340 x += bdlg[0].x; /* add its absolute coordinates if we need to */
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
341 y += bdlg[0].y;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
342 }
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
343
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
344 if (bdlg[objnum].state & SG_SELECTED) {
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
345 bg = bg1;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
346 } else {
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
347 bg = bg0;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
348 }
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
349
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
350 /* The root box should be bigger than the screen, so we disable the offset there: */
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
351 if (objnum != 0)
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
352 offset = border;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
353 else
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
354 offset = 0;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
355
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
356 /* Draw background: */
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
357 rect.x = x;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
358 rect.y = y;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
359 rect.w = w;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
360 rect.h = h;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
361 SDL_FillRect(pSdlGuiScrn, &rect, bg);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
362
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
363 /* Draw upper border: */
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
364 rect.x = x - offset;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
365 rect.y = y - offset;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
366 rect.w = w + offset + offset;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
367 rect.h = border;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
368 SDL_FillRect(pSdlGuiScrn, &rect, bc);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
369
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
370 /* Draw left border: */
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
371 rect.x = x - offset;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
372 rect.y = y;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
373 rect.w = border;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
374 rect.h = h;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
375 SDL_FillRect(pSdlGuiScrn, &rect, bc);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
376
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
377 /* Draw bottom border: */
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
378 rect.x = x - offset;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
379 rect.y = y + h - border + offset;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
380 rect.w = w + offset + offset;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
381 rect.h = border;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
382 SDL_FillRect(pSdlGuiScrn, &rect, bc);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
383
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
384 /* Draw right border: */
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
385 rect.x = x + w - border + offset;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
386 rect.y = y;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
387 rect.w = border;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
388 rect.h = h;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
389 SDL_FillRect(pSdlGuiScrn, &rect, bc);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
390 }
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
391
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
392
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
393
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
394 /*
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
395 * Draw a dialog box object.
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
396 */
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
397 static void SDLGui_DrawBox(const SGOBJ *bdlg, int objnum)
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
398 {
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
399 SDL_Rect rect;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
400 int x, y, w, h, offset, shade = 2;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
401 Uint32 grey = SDL_MapRGB(pSdlGuiScrn->format,192,192,192);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
402 Uint32 upleftc, downrightc;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
403
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
404 x = bdlg[objnum].x;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
405 y = bdlg[objnum].y;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
406 if (objnum > 0) { /* Since the root object is a box, too, */
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
407 /* we have to look for it now here and only */
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
408 x += bdlg[0].x; /* add its absolute coordinates if we need to */
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
409 y += bdlg[0].y;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
410 }
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
411 w = bdlg[objnum].w;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
412 h = bdlg[objnum].h;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
413
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
414 if (bdlg[objnum].state & SG_SELECTED) {
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
415 upleftc = SDL_MapRGB(pSdlGuiScrn->format,128,128,128);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
416 downrightc = SDL_MapRGB(pSdlGuiScrn->format,255,255,255);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
417 } else {
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
418 upleftc = SDL_MapRGB(pSdlGuiScrn->format,255,255,255);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
419 downrightc = SDL_MapRGB(pSdlGuiScrn->format,128,128,128);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
420 }
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
421
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
422 /* The root box should be bigger than the screen, so we disable the offset there: */
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
423 if (objnum != 0)
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
424 offset = shade;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
425 else
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
426 offset = 0;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
427
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
428 /* Draw background: */
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
429 rect.x = x;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
430 rect.y = y;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
431 rect.w = w;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
432 rect.h = h;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
433 SDL_FillRect(pSdlGuiScrn, &rect, grey);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
434
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
435 /* Draw upper border: */
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
436 rect.x = x;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
437 rect.y = y - offset;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
438 rect.w = w;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
439 rect.h = shade;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
440 SDL_FillRect(pSdlGuiScrn, &rect, upleftc);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
441
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
442 /* Draw left border: */
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
443 rect.x = x - offset;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
444 rect.y = y;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
445 rect.w = shade;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
446 rect.h = h;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
447 SDL_FillRect(pSdlGuiScrn, &rect, upleftc);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
448
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
449 /* Draw bottom border: */
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
450 rect.x = x;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
451 rect.y = y + h - shade + offset;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
452 rect.w = w;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
453 rect.h = shade;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
454 SDL_FillRect(pSdlGuiScrn, &rect, downrightc);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
455
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
456 /* Draw right border: */
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
457 rect.x = x + w - shade + offset;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
458 rect.y = y;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
459 rect.w = shade;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
460 rect.h = h;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
461 SDL_FillRect(pSdlGuiScrn, &rect, downrightc);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
462 }
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
463
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
464
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
465
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
466 /*
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
467 * Draw a normal button.
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
468 */
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
469 static void SDLGui_DrawButton(const SGOBJ *bdlg, int objnum)
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
470 {
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
471 int x, y, w, h;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
472
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
473 SDLGui_DrawBox(bdlg, objnum);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
474 /*
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
475 * Use bold text and get outer dimensions of the text
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
476 */
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
477 TTF_SetFontStyle(pFont, TTF_STYLE_BOLD);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
478 TTF_SizeText(pFont, bdlg[objnum].txt, &w, &h);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
479 x = bdlg[0].x + bdlg[objnum].x + (bdlg[objnum].w - w) / 2;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
480 y = bdlg[0].y + bdlg[objnum].y + (bdlg[objnum].h - h) / 2;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
481
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
482 if (bdlg[objnum].state & SG_SELECTED) {
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
483 x += 1;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
484 y += 1;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
485 }
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
486
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
487 if ((bdlg[objnum].flags & SG_HIDE) == 0)
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
488 SDLGui_TTF(x, y, bdlg[objnum].txt);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
489 TTF_SetFontStyle(pFont, TTF_STYLE_NORMAL);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
490 }
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
491
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
492
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
493
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
494 /*
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
495 * Draw a whole dialog.
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
496 */
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
497 void SDLGui_DrawDialog(const SGOBJ *dlg)
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
498 {
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
499 int i;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
500
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
501 for (i = 0; dlg[i].type != -1; i++) {
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
502 switch (dlg[i].type) {
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
503 case SGBOX:
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
504 SDLGui_DrawBox(dlg, i);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
505 break;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
506 case SGLCD:
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
507 SDLGui_DrawLCD(dlg, i);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
508 break;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
509 case SGTEXT:
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
510 SDLGui_DrawText(dlg, i);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
511 break;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
512 case SGTTF:
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
513 SDLGui_DrawTTF(dlg, i);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
514 break;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
515 case SGBUTTON:
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
516 SDLGui_DrawButton(dlg, i);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
517 break;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
518 }
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
519 }
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
520
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
521 SDL_UpdateRect(pSdlGuiScrn, 0,0,0,0);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
522 }
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
523
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
524
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
525
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
526 /*
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
527 * Search an object at a certain position.
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
528 */
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
529 static int SDLGui_FindObj(const SGOBJ *dlg, int fx, int fy)
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
530 {
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
531 int len, i, ob = -1, xpos, ypos;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
532
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
533 len = 0;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
534 while (dlg[len].type != -1)
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
535 len++;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
536
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
537 xpos = fx;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
538 ypos = fy;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
539 /* Now search for the object: */
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
540 for (i = len; i >= 0; i--) {
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
541 if (xpos >= dlg[0].x + dlg[i].x && ypos >= dlg[0].y + dlg[i].y &&
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
542 xpos < dlg[0].x + dlg[i].x + dlg[i].w && ypos < dlg[0].y + dlg[i].y + dlg[i].h) {
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
543 ob = i;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
544 break;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
545 }
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
546 }
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
547
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
548 return ob;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
549 }
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
550
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
551
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
552
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
553 /*
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
554 * Search a button with a special flag (e.g. SG_DEFAULT or SG_CANCEL).
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
555 */
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
556 static int SDLGui_SearchFlaggedButton(const SGOBJ *dlg, int flag)
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
557 {
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
558 int i = 0;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
559
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
560 while (dlg[i].type != -1) {
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
561 if (dlg[i].flags & flag)
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
562 return i;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
563 i++;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
564 }
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
565
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
566 return 0;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
567 }
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
568
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
569
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
570
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
571 /*
412
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
572 * Show dialog.
409
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
573 */
412
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
574 int SDLGui_DoDialogInit(SGOBJ *dlg)
409
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
575 {
412
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
576 if ((pSdlGuiScrn->h < dlg[0].h) && (pSdlGuiScrn->w < dlg[0].w)) {
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
577 syslog(LOG_NOTICE, "Screen size too small for dialog!");
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
578 return SDLGUI_ERROR;
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
579 }
409
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
580
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
581 dlgrect.x = dlg[0].x;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
582 dlgrect.y = dlg[0].y;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
583 dlgrect.w = dlg[0].w;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
584 dlgrect.h = dlg[0].h;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
585
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
586 bgrect.x = bgrect.y = 0;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
587 bgrect.w = dlgrect.w;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
588 bgrect.h = dlgrect.h;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
589
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
590 /*
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
591 * Save background
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
592 */
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
593 pBgSurface = SDL_CreateRGBSurface(SDL_SWSURFACE, dlgrect.w, dlgrect.h, pSdlGuiScrn->format->BitsPerPixel,
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
594 pSdlGuiScrn->format->Rmask, pSdlGuiScrn->format->Gmask, pSdlGuiScrn->format->Bmask, pSdlGuiScrn->format->Amask);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
595 if (pSdlGuiScrn->format->palette != NULL) {
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
596 SDL_SetColors(pBgSurface, pSdlGuiScrn->format->palette->colors, 0, pSdlGuiScrn->format->palette->ncolors-1);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
597 }
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
598
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
599 if (pBgSurface != NULL) {
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
600 SDL_BlitSurface(pSdlGuiScrn, &dlgrect, pBgSurface, &bgrect);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
601 } else {
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
602 syslog(LOG_NOTICE, "SDLGUI_DoDialog: CreateRGBSurface failed: %s", SDL_GetError());
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
603 }
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
604
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
605 /* (Re-)draw the dialog */
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
606 SDLGui_DrawDialog(dlg);
412
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
607 return 0;
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
608 }
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
609
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
610
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
611
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
612 /*
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
613 * Process a dialog. Returns the button number that has been pressed
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
614 */
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
615 int SDLGui_DoDialogLoop(SGOBJ *dlg)
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
616 {
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
617 int obj = 0, oldbutton = 0, retbutton = 0, b, i, j;
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
618 SDL_Event sdlEvent;
409
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
619
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
620 /*
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
621 * Is the left mouse button still pressed? Yes -> Handle TOUCHEXIT objects here
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
622 */
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
623 SDL_PumpEvents();
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
624 b = SDL_GetMouseState(&i, &j);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
625 obj = SDLGui_FindObj(dlg, i, j);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
626 if (obj > 0 && (dlg[obj].flags & SG_TOUCHEXIT) ) {
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
627 oldbutton = obj;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
628 if (b & SDL_BUTTON(1)) {
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
629 dlg[obj].state |= SG_SELECTED;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
630 retbutton = obj;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
631 }
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
632 }
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
633
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
634 /* The main loop */
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
635 while (retbutton == 0 && !my_shutdown) {
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
636 if (SDL_WaitEvent(&sdlEvent) == 1) /* Wait for events */
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
637 switch (sdlEvent.type) {
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
638 case SDL_QUIT:
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
639 retbutton = SDLGUI_QUIT;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
640 break;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
641
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
642 case SDL_MOUSEBUTTONDOWN:
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
643 if (sdlEvent.button.button != SDL_BUTTON_LEFT) {
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
644 /* Not left mouse button -> unsupported event */
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
645 break;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
646 }
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
647 /* It was the left button: Find the object under the mouse cursor */
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
648 obj = SDLGui_FindObj(dlg, sdlEvent.button.x, sdlEvent.button.y);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
649 if (obj > 0) {
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
650 if (dlg[obj].type == SGBUTTON) {
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
651 dlg[obj].state |= SG_SELECTED;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
652 SDLGui_DrawButton(dlg, obj);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
653 SDL_UpdateRect(pSdlGuiScrn, dlg[0].x + dlg[obj].x - 2, dlg[0].y + dlg[obj].y - 2, dlg[obj].w + 4, dlg[obj].h + 4);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
654 oldbutton=obj;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
655 }
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
656 if ( dlg[obj].flags & SG_TOUCHEXIT ) {
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
657 dlg[obj].state |= SG_SELECTED;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
658 retbutton = obj;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
659 }
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
660 }
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
661 break;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
662
412
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
663 case SDL_MOUSEBUTTONUP:
409
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
664 if (sdlEvent.button.button != SDL_BUTTON_LEFT) {
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
665 /* Not left mouse button -> unsupported event */
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
666 break;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
667 }
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
668 /* It was the left button: Find the object under the mouse cursor */
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
669 obj = SDLGui_FindObj(dlg, sdlEvent.button.x, sdlEvent.button.y);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
670 if (obj > 0) {
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
671 switch (dlg[obj].type) {
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
672 case SGBUTTON:
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
673 if (oldbutton==obj)
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
674 retbutton=obj;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
675 break;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
676 }
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
677 }
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
678 if (oldbutton > 0) {
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
679 dlg[oldbutton].state &= ~SG_SELECTED;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
680 SDLGui_DrawButton(dlg, oldbutton);
412
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
681 SDL_UpdateRect(pSdlGuiScrn, dlg[0].x+dlg[oldbutton].x-2, dlg[0].y+dlg[oldbutton].y-2, dlg[oldbutton].w+4, dlg[oldbutton].h+4);
409
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
682 oldbutton = 0;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
683 }
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
684 if (obj >= 0 && (dlg[obj].flags & SG_EXIT)) {
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
685 retbutton = obj;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
686 }
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
687 break;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
688
412
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
689 case SDL_MOUSEMOTION:
409
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
690 break;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
691
412
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
692 case SDL_KEYDOWN: /* Key pressed */
409
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
693 if (sdlEvent.key.keysym.sym == SDLK_RETURN || sdlEvent.key.keysym.sym == SDLK_KP_ENTER) {
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
694 retbutton = SDLGui_SearchFlaggedButton(dlg, SG_DEFAULT);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
695 } else if (sdlEvent.key.keysym.sym == SDLK_ESCAPE) {
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
696 retbutton = SDLGui_SearchFlaggedButton(dlg, SG_CANCEL);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
697 }
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
698 break;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
699 }
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
700 }
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
701
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
702 if (retbutton == SDLGUI_QUIT)
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
703 my_shutdown = TRUE;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
704
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
705 return retbutton;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
706 }
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
707
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
708
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
709
412
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
710 void SDLGui_DoDialogEnd(void)
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
711 {
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
712 /* Restore background */
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
713 if (pBgSurface) {
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
714 SDL_BlitSurface(pBgSurface, &bgrect, pSdlGuiScrn, &dlgrect);
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
715 SDL_FreeSurface(pBgSurface);
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
716 }
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
717 }
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
718
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
719
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
720
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
721 /*
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
722 * Initialize a LCD object. Set the coordinates and dimenstions. Return index.
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
723 */
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
724 int SDLGui_LCDinit(SGOBJ *dlg, int *x, int *y, int *w, int *h, int *cols, int *rows, int lcdindex)
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
725 {
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
726 int i, index;
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
727
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
728 /*
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
729 * Search the LCD display
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
730 */
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
731 *x = *y = *w = *h = *cols = *rows = i = index = 0;
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
732 for (;;) {
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
733 if (dlg[i].type == -1) {
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
734 syslog(LOG_NOTICE, "SDLGui_LCDinit() lcdindex=%d not found", lcdindex);
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
735 return -1;
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
736 }
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
737 if (dlg[i].type == SGLCD) {
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
738 if (index == lcdindex)
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
739 break;
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
740 index++;
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
741 }
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
742 i++;
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
743 }
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
744 fprintf(stdout, "SDLGui_LCDinit=%d LCD=%dx%d %dx%d\n", i, dlg[i].x, dlg[i].y, dlg[i].w, dlg[i].h);
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
745
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
746 *cols = dlg[i].w;
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
747 *rows = dlg[i].h;
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
748 *w = dlg[i].w * (fontwidth + 2) + 10;
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
749 *h = dlg[i].h * (fontheight + 2) + 4;
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
750 if (dlg[i].x == -1) {
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
751 *x = (dlg[0].w - *w) / 2;
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
752 } else {
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
753 *x = dlg[i].x;
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
754 }
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
755 *y = dlg[i].y;
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
756
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
757 return lcdindex;
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
758 }
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
759
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
760
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
761 /*
409
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
762 void SDLGui_LCDwrite(SGOBJ *dlg, int x, int y, Uint8 c, int lcdindex)
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
763 {
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
764 int i, index;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
765
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
766 fprintf(stdout, "SDLGui_LCDwrite( , %d, %d, %c, %d)\n", x, y, c, lcdindex);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
767
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
768 i = index = 0;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
769 for (;;) {
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
770 if (dlg[i].type == -1) {
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
771 syslog(LOG_NOTICE, "SDLGui_LCDwrite() lcdindex=%d not found", lcdindex);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
772 return;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
773 }
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
774 if (dlg[i].type == SGLCD) {
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
775 if (index == lcdindex)
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
776 break;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
777 index++;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
778 }
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
779 i++;
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
780 }
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
781 fprintf(stdout, "SDLGui_LCDwrite i=%d LCD=%dx%d\n", i, dlg[i].w, dlg[i].h);
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
782
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
783 }
412
f1a042a59b61 Basic ideas to write to the simulated LCD display are in place.
Michiel Broek <mbroek@mbse.eu>
parents: 410
diff changeset
784 */
409
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
785
410
e3f8a51b566a Fixed compiling on systems without SDL libraries, and they don't need tha brewpanel program.
Michiel Broek <mbroek@mbse.eu>
parents: 409
diff changeset
786 #endif
409
cdf68044adaf 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
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
787

mercurial