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 extern int debug; |
45 extern int debug; |
46 |
46 |
|
47 extern SDL_Window *S_window; |
47 |
48 |
48 /*-----------------------------------------------------------------------*/ |
49 /*-----------------------------------------------------------------------*/ |
49 /* |
50 /* |
50 * Load an 1 plane XBM into a 8 planes SDL_Surface. |
51 * Load an 1 plane XBM into a 8 planes SDL_Surface. |
51 */ |
52 */ |
102 syslog(LOG_NOTICE, "Error: Can not init font graphics!"); |
103 syslog(LOG_NOTICE, "Error: Can not init font graphics!"); |
103 return -1; |
104 return -1; |
104 } |
105 } |
105 |
106 |
106 /* Set color palette of the LCD font graphics: */ |
107 /* Set color palette of the LCD font graphics: */ |
107 SDL_SetColors(pFontGfx, blackWhiteColors, 0, 2); |
108 SDL_SetPaletteColors(pFontGfx->format->palette, blackWhiteColors, 0, 2); |
108 |
109 |
109 /* Set font color 0 as transparent: */ |
110 /* Set font color 0 as transparent: */ |
110 SDL_SetColorKey(pFontGfx, (SDL_SRCCOLORKEY|SDL_RLEACCEL), 0); |
111 SDL_SetColorKey(pFontGfx, SDL_RLEACCEL, 0); |
111 |
112 |
112 if (TTF_Init() == -1) { |
113 if (TTF_Init() == -1) { |
113 syslog(LOG_NOTICE, "Could not init SDL_ttf"); |
114 syslog(LOG_NOTICE, "Could not init SDL_ttf"); |
114 return -1; |
115 return -1; |
115 } |
116 } |
240 dr.y = y + fontheight - 2; |
241 dr.y = y + fontheight - 2; |
241 dr.w = fontwidth; |
242 dr.w = fontwidth; |
242 dr.h = 2; |
243 dr.h = 2; |
243 |
244 |
244 SDL_FillRect(pSdlGuiScrn, &dr, color); |
245 SDL_FillRect(pSdlGuiScrn, &dr, color); |
245 SDL_UpdateRect(pSdlGuiScrn, x, y, fontwidth, fontheight); |
246 // SDL_UpdateRect(pSdlGuiScrn, x, y, fontwidth, fontheight); |
246 } |
247 } |
247 } |
248 } |
248 |
249 |
249 |
250 |
250 |
251 |
285 dstbits += dstpitch; |
286 dstbits += dstpitch; |
286 } |
287 } |
287 i++; |
288 i++; |
288 } |
289 } |
289 |
290 |
290 SDL_SetColors(CGchar, blackWhiteColors, 0, 2); |
291 // SDL_SetColors(CGchar, blackWhiteColors, 0, 2); |
291 SDL_SetColorKey(CGchar, (SDL_SRCCOLORKEY|SDL_RLEACCEL), 0); |
292 SDL_SetColorKey(CGchar, SDL_RLEACCEL, 0); |
292 bg = LCDbg0; |
293 bg = LCDbg0; |
293 |
294 |
294 sr.x = sr.y = 0; |
295 sr.x = sr.y = 0; |
295 dr.x = x; |
296 dr.x = x; |
296 dr.y = y; |
297 dr.y = y; |
297 sr.w = dr.w = fontwidth; |
298 sr.w = dr.w = fontwidth; |
298 sr.h = dr.h = fontheight; |
299 sr.h = dr.h = fontheight; |
299 |
300 |
300 SDL_FillRect(pSdlGuiScrn, &dr, bg); |
301 SDL_FillRect(pSdlGuiScrn, &dr, bg); |
301 SDL_BlitSurface(CGchar, &sr, pSdlGuiScrn, &dr); |
302 SDL_BlitSurface(CGchar, &sr, pSdlGuiScrn, &dr); |
302 SDL_UpdateRect(pSdlGuiScrn, x, y, fontwidth, fontheight); |
303 //SDL_UpdateRect(pSdlGuiScrn, x, y, fontwidth, fontheight); |
|
304 SDL_UpdateWindowSurface(S_window); |
303 SDL_FreeSurface(CGchar); |
305 SDL_FreeSurface(CGchar); |
304 } |
306 } |
305 |
307 |
306 |
308 |
307 |
309 |
328 dr.w=fontwidth; |
330 dr.w=fontwidth; |
329 dr.h=fontheight; |
331 dr.h=fontheight; |
330 |
332 |
331 SDL_FillRect(pSdlGuiScrn, &dr, bg); |
333 SDL_FillRect(pSdlGuiScrn, &dr, bg); |
332 SDL_BlitSurface(pFontGfx, &sr, pSdlGuiScrn, &dr); |
334 SDL_BlitSurface(pFontGfx, &sr, pSdlGuiScrn, &dr); |
333 SDL_UpdateRect(pSdlGuiScrn, x, y, fontwidth, fontheight); |
335 // SDL_UpdateRect(pSdlGuiScrn, x, y, fontwidth, fontheight); |
|
336 SDL_UpdateWindowSurface(S_window); |
334 } |
337 } |
335 |
338 |
336 |
339 |
337 |
340 |
338 /* |
341 /* |
796 * Save background |
801 * Save background |
797 */ |
802 */ |
798 pBgSurface = SDL_CreateRGBSurface(SDL_SWSURFACE, dlgrect.w, dlgrect.h, pSdlGuiScrn->format->BitsPerPixel, |
803 pBgSurface = SDL_CreateRGBSurface(SDL_SWSURFACE, dlgrect.w, dlgrect.h, pSdlGuiScrn->format->BitsPerPixel, |
799 pSdlGuiScrn->format->Rmask, pSdlGuiScrn->format->Gmask, pSdlGuiScrn->format->Bmask, pSdlGuiScrn->format->Amask); |
804 pSdlGuiScrn->format->Rmask, pSdlGuiScrn->format->Gmask, pSdlGuiScrn->format->Bmask, pSdlGuiScrn->format->Amask); |
800 if (pSdlGuiScrn->format->palette != NULL) { |
805 if (pSdlGuiScrn->format->palette != NULL) { |
801 SDL_SetColors(pBgSurface, pSdlGuiScrn->format->palette->colors, 0, pSdlGuiScrn->format->palette->ncolors-1); |
806 SDL_SetPaletteColors(pBgSurface->format->palette, pSdlGuiScrn->format->palette->colors, 0, pSdlGuiScrn->format->palette->ncolors-1); |
802 } |
807 } |
803 |
808 |
804 if (pBgSurface != NULL) { |
809 if (pBgSurface != NULL) { |
805 SDL_BlitSurface(pSdlGuiScrn, &dlgrect, pBgSurface, &bgrect); |
810 SDL_BlitSurface(pSdlGuiScrn, &dlgrect, pBgSurface, &bgrect); |
806 } else { |
811 } else { |
845 obj = SDLGui_FindObj(dlg, sdlEvent.button.x, sdlEvent.button.y); |
850 obj = SDLGui_FindObj(dlg, sdlEvent.button.x, sdlEvent.button.y); |
846 if (obj > 0) { |
851 if (obj > 0) { |
847 if (dlg[obj].type == SGBUTTON) { |
852 if (dlg[obj].type == SGBUTTON) { |
848 dlg[obj].state |= SG_SELECTED; |
853 dlg[obj].state |= SG_SELECTED; |
849 SDLGui_DrawButton(dlg, obj); |
854 SDLGui_DrawButton(dlg, obj); |
850 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); |
855 SDL_UpdateWindowSurface(S_window); |
|
856 //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); |
851 retbutton = obj + 1000; |
857 retbutton = obj + 1000; |
852 } |
858 } |
853 } |
859 } |
854 break; |
860 break; |
855 |
861 |
862 obj = SDLGui_FindObj(dlg, sdlEvent.button.x, sdlEvent.button.y); |
868 obj = SDLGui_FindObj(dlg, sdlEvent.button.x, sdlEvent.button.y); |
863 if (obj > 0) { |
869 if (obj > 0) { |
864 if (dlg[obj].type == SGBUTTON) { |
870 if (dlg[obj].type == SGBUTTON) { |
865 dlg[obj].state &= ~SG_SELECTED; |
871 dlg[obj].state &= ~SG_SELECTED; |
866 SDLGui_DrawButton(dlg, obj); |
872 SDLGui_DrawButton(dlg, obj); |
867 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); |
873 SDL_UpdateWindowSurface(S_window); |
|
874 //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); |
868 retbutton = obj; |
875 retbutton = obj; |
869 } |
876 } |
870 } |
877 } |
871 break; |
878 break; |
872 |
879 |