brewpanel/sdlgui.c

changeset 428
d64c4c1edd78
parent 427
e8e548922e31
child 430
36ecc8bbb75d
equal deleted inserted replaced
427:e8e548922e31 428:d64c4c1edd78
42 static Uint32 LCDbg1 = 0; /* LCD background light */ 42 static Uint32 LCDbg1 = 0; /* LCD background light */
43 43
44 extern int my_shutdown; 44 extern int my_shutdown;
45 45
46 46
47
47 /*-----------------------------------------------------------------------*/ 48 /*-----------------------------------------------------------------------*/
48 /* 49 /*
49 * Load an 1 plane XBM into a 8 planes SDL_Surface. 50 * Load an 1 plane XBM into a 8 planes SDL_Surface.
50 */ 51 */
51 static SDL_Surface *SDLGui_LoadXBM(int w, int h, const char *pXbmBits) 52 static SDL_Surface *SDLGui_LoadXBM(int w, int h, const char *pXbmBits)
224 225
225 226
226 /* 227 /*
227 * Draw the cursor 228 * Draw the cursor
228 */ 229 */
229 void SDLGui_Cursor(int x, int y, int on, int blink) 230 void SDLGui_Cursor(SGOBJ *dlg, int fd, int x, int y, int on, int blink)
230 { 231 {
231 SDL_Rect dr; 232 SDL_Rect dr;
232 Uint32 color = SDL_MapRGB(pSdlGuiScrn->format, 53, 59, 61); 233 Uint32 color = SDL_MapRGB(pSdlGuiScrn->format, 53, 59, 61);
233 234
234 if (on) { 235 if (on) {
245 246
246 247
247 /* 248 /*
248 * Draw a text character 249 * Draw a text character
249 */ 250 */
250 void SDLGui_Char(int x, int y, Uint8 c, int bLight) 251 void SDLGui_Char(SGOBJ *dlg, int fd, int x, int y, Uint8 c)
251 { 252 {
252 SDL_Rect sr, dr; 253 SDL_Rect sr, dr;
253 Uint32 bg; 254 Uint32 bg;
254 255
255 if (bLight) 256 if (dlg[1].state & SG_SELECTED) {
256 bg = LCDbg1; 257 bg = LCDbg1;
257 else 258 } else {
258 bg = LCDbg0; 259 bg = LCDbg0;
260 }
259 261
260 sr.x=fontwidth*(c%16); 262 sr.x=fontwidth*(c%16);
261 sr.y=fontheight*(c/16); 263 sr.y=fontheight*(c/16);
262 sr.w=fontwidth; 264 sr.w=fontwidth;
263 sr.h=fontheight; 265 sr.h=fontheight;
313 315
314 316
315 /* 317 /*
316 * Draw a dialog LCD object. 318 * Draw a dialog LCD object.
317 */ 319 */
318 static void SDLGui_DrawLCD(const SGOBJ *bdlg, int objnum) 320 void SDLGui_DrawLCD(SGOBJ *bdlg, int objnum)
319 { 321 {
320 SDL_Rect rect; 322 SDL_Rect rect;
321 int x, y, w, h, offset, border = 4; 323 int x, y, w, h, offset, border = 4;
322 Uint32 bc = SDL_MapRGB(pSdlGuiScrn->format, 32, 32, 32); 324 Uint32 bc = SDL_MapRGB(pSdlGuiScrn->format, 32, 32, 32);
323 Uint32 bg; 325 Uint32 bg;
604 SDLGui_fill_circle(pSdlGuiScrn, bdlg[objnum].x, bdlg[objnum].y, bdlg[objnum].w, color); 606 SDLGui_fill_circle(pSdlGuiScrn, bdlg[objnum].x, bdlg[objnum].y, bdlg[objnum].w, color);
605 } 607 }
606 608
607 609
608 610
611 void SDLGui_LED(SGOBJ *dlg, int fd, int LED, int on)
612 {
613 int i;
614
615 for (i = 0; dlg[i].type != -1; i++) {
616 if (dlg[i].type == LED) {
617 fprintf(stdout, "SDLGui_LED LED=%d on=%d\n", LED, on);
618 if (on) {
619 dlg[i].state |= SG_SELECTED;
620 } else {
621 dlg[i].state &= ~SG_SELECTED;
622 }
623 switch (dlg[i].type) {
624 case SGLEDRED:
625 SDLGUI_DrawLEDRed(dlg, i);
626 break;
627 case SGLEDBLUE:
628 SDLGUI_DrawLEDBlue(dlg, i);
629 break;
630 case SGLEDGREEN:
631 SDLGUI_DrawLEDGreen(dlg, i);
632 break;
633 case SGLEDYELLOW:
634 SDLGUI_DrawLEDYellow(dlg, i);
635 break;
636 }
637 SDL_UpdateRect(pSdlGuiScrn, dlg[i].x - dlg[i].w, dlg[i].y - dlg[i].w, dlg[i].w * 2, dlg[i].w * 2);
638 }
639 }
640 }
641
642
643
609 /* 644 /*
610 * Draw a whole dialog. 645 * Draw a whole dialog.
611 */ 646 */
612 void SDLGui_DrawDialog(const SGOBJ *dlg) 647 void SDLGui_DrawDialog(SGOBJ *dlg)
613 { 648 {
614 int i; 649 int i;
615 650
616 for (i = 0; dlg[i].type != -1; i++) { 651 for (i = 0; dlg[i].type != -1; i++) {
617 switch (dlg[i].type) { 652 switch (dlg[i].type) {
730 while (retbutton == 0 && !my_shutdown) { 765 while (retbutton == 0 && !my_shutdown) {
731 766
732 /* 767 /*
733 * Poll network for data 768 * Poll network for data
734 */ 769 */
735 socket_recv(); 770 socket_recv(dlg);
736 771
737 if (SDL_PollEvent(&sdlEvent) == 1) { /* Wait for events */ 772 if (SDL_PollEvent(&sdlEvent) == 1) { /* Wait for events */
738 switch (sdlEvent.type) { 773 switch (sdlEvent.type) {
739 case SDL_QUIT: 774 case SDL_QUIT:
740 retbutton = SDLGUI_QUIT; 775 retbutton = SDLGUI_QUIT;
842 877
843 return lcdindex; 878 return lcdindex;
844 } 879 }
845 880
846 881
847 /*
848 void SDLGui_LCDwrite(SGOBJ *dlg, int x, int y, Uint8 c, int lcdindex)
849 {
850 int i, index;
851
852 fprintf(stdout, "SDLGui_LCDwrite( , %d, %d, %c, %d)\n", x, y, c, lcdindex);
853
854 i = index = 0;
855 for (;;) {
856 if (dlg[i].type == -1) {
857 syslog(LOG_NOTICE, "SDLGui_LCDwrite() lcdindex=%d not found", lcdindex);
858 return;
859 }
860 if (dlg[i].type == SGLCD) {
861 if (index == lcdindex)
862 break;
863 index++;
864 }
865 i++;
866 }
867 fprintf(stdout, "SDLGui_LCDwrite i=%d LCD=%dx%d\n", i, dlg[i].w, dlg[i].h);
868
869 }
870 */
871
872 #endif 882 #endif
873

mercurial