#include #include "theme.h" #include "structures.h" #include "widgets.h" void SetColorKey(SDL_Surface *s) { SDL_SetColorKey(s, SDL_SRCCOLORKEY, SDL_MapRGB(s->format, 255, 0, 0)); } wTHEME *wDefaultTheme() { wTHEME *t = malloc(sizeof(wTHEME)); if (!t) return NULL; SDL_PixelFormat *fmt = SDL_GetVideoSurface()->format; t->color1 = SDL_MapRGB(fmt, 239,251,247); t->color2 = SDL_MapRGB(fmt, 24,48,90); t->color3 = SDL_MapRGB(fmt, 66,113,206); t->color4 = SDL_MapRGB(fmt, 33,16,33); t->defbg = wBackgroundColor(SDL_MapRGB(fmt,99,162,181), SDL_MapRGB(fmt,214,235,235), BACKG_TRICOLOR); t->font_index = NSDL_FONT_THIN; t->font = nSDL_LoadFont(t->font_index, 33, 16, 33); t->button_bg = wBackgroundColor(SDL_MapRGB(fmt, 222,222,222), SDL_MapRGB(fmt, 16,52,132), BACKG_HGRAD); t->button_bg_selected = wBackgroundColor(SDL_MapRGB(fmt, 0,24,33), SDL_MapRGB(fmt, 74,77,74), BACKG_HGRAD); t->button_font = nSDL_LoadFont(NSDL_FONT_VGA, 0, 0, 0); t->button_font_selected = nSDL_LoadFont(NSDL_FONT_VGA, 255, 255, 255); Uint16 img_check_0[125] = { // 11x11 0x2a01,0x000B,0x000B,0x0000,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff, 0xffff,0xffff,0xffff,0xffff,0xf79f,0xffff,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0xf79f,0xffff,0x0000,0xffff,0xffff, 0xffff,0xffff,0xffff,0xffff,0xffff,0x0000,0xf79f,0xffff,0x0000,0xf7bf, 0xf7bf,0xf7bf,0xf7bf,0xf7bf,0xf7bf,0xf7bf,0x0000,0xf79f,0xffff,0x0000, 0xf79f,0xf79f,0xf79f,0xf79f,0xf79f,0xf79f,0xf79f,0x0000,0xf79f,0xffff, 0x0000,0xef5e,0xef5e,0xef5e,0xef5e,0xef5e,0xef5e,0xef5e,0x0000,0xf79f, 0xffff,0x0000,0xe71e,0xe71e,0xe71e,0xe71e,0xe71e,0xe71e,0xe71e,0x0000, 0xf79f,0xffff,0x0000,0xde9d,0xde9d,0xde9d,0xde9d,0xde9d,0xde9d,0xde9d, 0x0000,0xf79f,0xffff,0x0000,0xcdfc,0xcdfc,0xcdfc,0xcdfc,0xcdfc,0xcdfc, 0xcdfc,0x0000,0xf79f,0xffff,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0xf79f,0xf79f,0xf79f,0xf79f,0xf79f,0xf79f,0xf79f, 0xf79f,0xf79f,0xf79f,0xf79f,0xf79 }; Uint16 img_check_1[125] = { // 11x11 0x2a01,0x000B,0x000B,0x0000,0xf7bf,0xf7bf,0xf7bf,0xf7bf,0xf7bf,0xf7bf, 0xf7bf,0xf7bf,0xf7bf,0xf7bf,0xe71e,0xf7bf,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0xe71e,0xf7bf,0x0000,0xffff,0xffff, 0xffff,0xffff,0xffff,0xffff,0x24d6,0x0000,0xe71e,0xf7bf,0x0000,0xf7bf, 0xf7bf,0xf7bf,0xf7bf,0xf7bf,0x24d6,0x1b4f,0x0000,0xe71e,0xf7bf,0x0000, 0x24d6,0xf79f,0xf79f,0xf79f,0x24d6,0x1b4f,0x24d6,0x0000,0xe71e,0xf7bf, 0x0000,0x1b4f,0x24d6,0xef5e,0x24d6,0x1b4f,0x24d6,0xef5e,0x0000,0xe71e, 0xf7bf,0x0000,0x24d6,0x1b4f,0x24d6,0x1b4f,0x24d6,0xe71e,0xe71e,0x0000, 0xe71e,0xf7bf,0x0000,0xde9d,0x24d6,0x1b4f,0x24d6,0xde9d,0xde9d,0xde9d, 0x0000,0xe71e,0xf7bf,0x0000,0xcdfc,0xcdfc,0x24d6,0xcdfc,0xcdfc,0xcdfc, 0xcdfc,0x0000,0xe71e,0xf7bf,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0xe71e,0xe71e,0xe71e,0xe71e,0xe71e,0xe71e,0xe71e, 0xe71e,0xe71e,0xe71e,0xe71e,0xe71 }; t->img_check_0 = nSDL_LoadImage(img_check_0); SetColorKey(t->img_check_0); t->img_check_1 = nSDL_LoadImage(img_check_1); SetColorKey(t->img_check_1); Uint16 image_up[53] = { // 7x7 0x2a01,0x0007,0x0007,0x0000,0xf800,0xf800,0xf800,0x29eb,0xf800,0xf800, 0xf800,0xf800,0xf800,0x29eb,0x9edd,0x29eb,0xf800,0xf800,0xf800,0x29eb, 0x051d,0x29eb,0x9edd,0x29eb,0xf800,0x29eb,0x051d,0x29eb,0xffff,0x29eb, 0x9edd,0x29eb,0x29eb,0x051d,0x051d,0x9edd,0x9edd,0x9edd,0x29eb,0x29eb, 0x29eb,0x29eb,0x29eb,0x29eb,0x29eb,0x29eb,0xf800,0xf800,0xf800,0xf800, 0xf800,0xf800,0xf800 }; Uint16 image_down[53] = { // 7x7 0x2a01,0x0007,0x0007,0x0000,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800, 0xf800,0x29eb,0x29eb,0x29eb,0x29eb,0x29eb,0x29eb,0x29eb,0x29eb,0x051d, 0x051d,0x9edd,0x9edd,0x9edd,0x29eb,0x29eb,0x051d,0x29eb,0xffff,0x29eb, 0x9edd,0x29eb,0xf800,0x29eb,0x051d,0x29eb,0x9edd,0x29eb,0xf800,0xf800, 0xf800,0x29eb,0x9edd,0x29eb,0xf800,0xf800,0xf800,0xf800,0xf800,0x29eb, 0xf800,0xf800,0xf800 }; Uint16 image_left[53] = { // 7x7 0x2a01,0x0007,0x0007,0x0000,0xf800,0xf800,0xf800,0x29cb,0x29cb,0x29cb, 0xf800,0xf800,0xf800,0x29cb,0x053d,0x053d,0x29cb,0xf800,0xf800,0x29cb, 0x053d,0x29cb,0x053d,0x29cb,0xf800,0x29cb,0x9efd,0x29cb,0xffff,0x9efd, 0x29cb,0xf800,0xf800,0x29cb,0x9efd,0x29cb,0x9efd,0x29cb,0xf800,0xf800, 0xf800,0x29cb,0x9efd,0x9efd,0x29cb,0xf800,0xf800,0xf800,0xf800,0x29cb, 0x29cb,0x29cb,0xf800 }; Uint16 image_right[53] = { // 7x7 0x2a01,0x0007,0x0007,0x0000,0xf800,0x29cb,0x29cb,0x29cb,0xf800,0xf800, 0xf800,0xf800,0x29cb,0x9efd,0x9efd,0x29cb,0xf800,0xf800,0xf800,0x29cb, 0x9efd,0x29cb,0x9efd,0x29cb,0xf800,0xf800,0x29cb,0x9efd,0xffff,0x29cb, 0x9efd,0x29cb,0xf800,0x29cb,0x053d,0x29cb,0x053d,0x29cb,0xf800,0xf800, 0x29cb,0x053d,0x053d,0x29cb,0xf800,0xf800,0xf800,0x29cb,0x29cb,0x29cb, 0xf800,0xf800,0xf800 }; t->img_scrollb_up = nSDL_LoadImage(image_up); SetColorKey(t->img_scrollb_up); t->img_scrollb_down = nSDL_LoadImage(image_down); SetColorKey(t->img_scrollb_down); t->img_scrollb_left = nSDL_LoadImage(image_left); SetColorKey(t->img_scrollb_left); t->img_scrollb_right = nSDL_LoadImage(image_right); SetColorKey(t->img_scrollb_right); t->tab_color2 = SDL_MapRGB(fmt, 210, 230, 247); t->tab_color3 = SDL_MapRGB(fmt, 49, 88, 100); t->tab_color4 = SDL_MapRGB(fmt, 86, 41, 41); t->tab_f1 = nSDL_LoadFont(NSDL_FONT_TINYTYPE, 0, 0, 0); t->tab_f2 = nSDL_LoadFont(NSDL_FONT_TINYTYPE, 210, 230, 247); Uint16 image_tab_delete[] = { // 5x6 0x2a01,0x0005,0x0006,0x0000,0x8802,0xb8c1,0xf800,0xb8c1,0x8802,0xb8c1, 0x8802,0xb8c1,0x8802,0xb8c1,0xf800,0xb8c1,0x7002,0xb8c1,0xf800,0xf800, 0xb8c1,0x7002,0xb8c1,0xf800,0xb8c1,0x8802,0xb8c1,0x8802,0xb8c1,0x8802, 0xb8c1,0xf800,0xb8c1,0x8802 }; t->tab_delete = nSDL_LoadImage(image_tab_delete); SetColorKey(t->tab_delete); t->request_c1 = SDL_MapRGB(fmt, 231,227,255); t->request_c2 = SDL_MapRGB(fmt, 239,239,239); t->request_c3 = SDL_MapRGB(fmt, 49,65,115); t->request_f1 = nSDL_LoadFont(NSDL_FONT_THIN, 0, 8, 41); t->request_f2 = nSDL_LoadFont(NSDL_FONT_TINYTYPE, 107, 146, 189); Uint16 image_request_left[] = { // 5x7 0x2a01,0x0005,0x0007,0x0000,0xf800,0xf800,0xf800,0x2270,0xf800,0xf800, 0xf800,0x2270,0x9579,0xf800,0xf800,0x2270,0x9579,0x2b8f,0xf800,0x2270, 0x9579,0x2b8f,0x9db9,0xf800,0xf800,0x2270,0x9579,0x2b8f,0xf800,0xf800, 0xf800,0x2270,0x9579,0xf800,0xf800,0xf800,0xf800,0x2270,0xf800 }; Uint16 image_request_right[] = { // 5x7 0x2a01,0x0005,0x0007,0x0000,0xf800,0x2270,0xf800,0xf800,0xf800,0xf800, 0x9579,0x2270,0xf800,0xf800,0xf800,0x2b8f,0x9579,0x2270,0xf800,0xf800, 0x9db9,0x2b8f,0x9579,0x2270,0xf800,0x2b8f,0x9579,0x2270,0xf800,0xf800, 0x9579,0x2270,0xf800,0xf800,0xf800,0x2270,0xf800,0xf800,0xf800 }; t->request_right = nSDL_LoadImage(image_request_right); t->request_left = nSDL_LoadImage(image_request_left); SetColorKey(t->request_right); SetColorKey(t->request_left); Uint16 image_menus_right[] = { // 5x7 0x2a01,0x0005,0x0007,0x0000,0xf800,0x2270,0xf800,0xf800,0xf800,0xf800, 0x9579,0x2270,0xf800,0xf800,0xf800,0x2b8f,0x9579,0x2270,0xf800,0xf800, 0x9db9,0x2b8f,0x9579,0x2270,0xf800,0x2b8f,0x9579,0x2270,0xf800,0xf800, 0x9579,0x2270,0xf800,0xf800,0xf800,0x2270,0xf800,0xf800,0xf800 }; t->menus_right = nSDL_LoadImage(image_menus_right); SetColorKey(t->menus_right); t->text_c1 = SDL_MapRGB(fmt, 198,211,222); t->menus_title_c1 = SDL_MapRGB(fmt, 0,0,0); t->menus_title_c2 = SDL_MapRGB(fmt, 33,142,140); t->menus_title_font = nSDL_LoadFont(NSDL_FONT_TINYTYPE, 231, 255, 239); t->menus_font1 = nSDL_LoadFont(NSDL_FONT_VGA, 82, 56, 90); t->menus_c1 = SDL_MapRGB(fmt, 222,223,247); t->menus_font2 = nSDL_LoadFont(NSDL_FONT_VGA, 156, 32, 33); t->map_c1 = SDL_MapRGB(fmt, 255,255,206); Uint16 image_pbar_cursor[] = { // 9x9 0x2a01,0x0009,0x0009,0x0000,0xf800,0xf800,0xf800,0xf800,0x0000,0xf800, 0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0x0000,0x4a49,0x0000,0xf800, 0xf800,0xf800,0xf800,0xf800,0x0000,0x7bcf,0x4a49,0x7bcf,0x0000,0xf800, 0xf800,0xf800,0x0000,0xa514,0x7bcf,0x4a49,0x7bcf,0xa514,0x0000,0xf800, 0x0000,0xbdf7,0xa514,0x7bcf,0xef5d,0x7bcf,0xa514,0xbdf7,0x0000,0xf800, 0x0000,0xa514,0x7bcf,0x4a49,0x7bcf,0xa514,0x0000,0xf800,0xf800,0xf800, 0x0000,0x7bcf,0x4a49,0x7bcf,0x0000,0xf800,0xf800,0xf800,0xf800,0xf800, 0x0000,0x4a49,0x0000,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800, 0x0000,0xf800,0xf800,0xf800,0xf800 }; Uint16 image_pbar_cursor_v[] = { 0x2a01,0x0009,0x0009,0x0000,0xf800,0xf800,0xf800,0xf800,0x0000,0xf800, 0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0x0000,0xbdf7,0x0000,0xf800, 0xf800,0xf800,0xf800,0xf800,0x0000,0xa514,0xa514,0xa514,0x0000,0xf800, 0xf800,0xf800,0x0000,0x7bcf,0x7bcf,0x7bcf,0x7bcf,0x7bcf,0x0000,0xf800, 0x0000,0x4a49,0x4a49,0x4a49,0xef5d,0x4a49,0x4a49,0x4a49,0x0000,0xf800, 0x0000,0x7bcf,0x7bcf,0x7bcf,0x7bcf,0x7bcf,0x0000,0xf800,0xf800,0xf800, 0x0000,0xa514,0xa514,0xa514,0x0000,0xf800,0xf800,0xf800,0xf800,0xf800, 0x0000,0xbdf7,0x0000,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800, 0x0000,0xf800,0xf800,0xf800,0xf800 }; t->pbar_cursor = nSDL_LoadImage(image_pbar_cursor); t->pbar_cursor_v = nSDL_LoadImage(image_pbar_cursor_v); SetColorKey(t->pbar_cursor); SetColorKey(t->pbar_cursor_v); Uint16 image_window_icon[] = { 0x2a01,0x000B,0x000B,0x0000,0x9edd,0x9edd,0x9edd,0x9edd,0x9edd,0x9edd, 0x9edd,0x9edd,0x9edd,0x9edd,0x9edd,0x9edd,0xf800,0xf800,0xf800,0xf800, 0xf800,0xf800,0xf800,0xf800,0xf800,0x9edd,0x9edd,0xf800,0x6e5b,0x6e5b, 0x6e5b,0x6e5b,0x6e5b,0x6e5b,0x6e5b,0xf800,0x9edd,0x9edd,0xf800,0x6e5b, 0xf800,0xf800,0xf800,0xf800,0xf800,0x6e5b,0xf800,0x9edd,0x9edd,0xf800, 0x6e5b,0xf800,0x4dfb,0x4dfb,0x4dfb,0xf800,0x6e5b,0xf800,0x9edd,0x9edd, 0xf800,0x6e5b,0xf800,0x4dfb,0xf800,0x4dfb,0xf800,0x6e5b,0xf800,0x9edd, 0x9edd,0xf800,0x6e5b,0xf800,0x4dfb,0x4dfb,0x4dfb,0xf800,0x6e5b,0xf800, 0x9edd,0x9edd,0xf800,0x6e5b,0xf800,0xf800,0xf800,0xf800,0xf800,0x6e5b, 0xf800,0x9edd,0x9edd,0xf800,0x6e5b,0x6e5b,0x6e5b,0x6e5b,0x6e5b,0x6e5b, 0x6e5b,0xf800,0x9edd,0x9edd,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800, 0xf800,0xf800,0xf800,0x9edd,0x9edd,0x9edd,0x9edd,0x9edd,0x9edd,0x9edd, 0x9edd,0x9edd,0x9edd,0x9edd,0x9edd }; t->window_icon = nSDL_LoadImage(image_window_icon); SetColorKey(t->window_icon); t->window_c1 = SDL_MapRGB(fmt, 0,0,0); t->window_title_bg = wBackgroundColor(SDL_MapRGB(fmt, 0,0,0), SDL_MapRGB(fmt, 214,231,225), BACKG_HGRAD); t->window_title_font = nSDL_LoadFont(NSDL_FONT_TINYTYPE, 255, 255, 255); t->dialog_bg1 = wBackgroundColor(SDL_MapRGB(fmt, 222,222,222), SDL_MapRGB(fmt, 57,162,132), BACKG_HGRAD); t->dialog_bg2 = wBackgroundColor(SDL_MapRGB(fmt, 222,222,222), SDL_MapRGB(fmt, 148,73,82), BACKG_HGRAD); return t; } void wCloseTheme(wTHEME *t) { if (!t) return; free(t->defbg); if (t->font) nSDL_FreeFont(t->font); free(t->button_bg); free(t->button_bg_selected); nSDL_FreeFont(t->button_font); nSDL_FreeFont(t->button_font_selected); SDL_FreeSurface(t->img_check_0); SDL_FreeSurface(t->img_check_1); SDL_FreeSurface(t->img_scrollb_up); SDL_FreeSurface(t->img_scrollb_down); SDL_FreeSurface(t->img_scrollb_right); SDL_FreeSurface(t->img_scrollb_left); SDL_FreeSurface(t->tab_delete); nSDL_FreeFont(t->tab_f1); nSDL_FreeFont(t->tab_f2); nSDL_FreeFont(t->request_f1); nSDL_FreeFont(t->request_f2); SDL_FreeSurface(t->request_right); SDL_FreeSurface(t->request_left); SDL_FreeSurface(t->menus_right); nSDL_FreeFont(t->menus_title_font); nSDL_FreeFont(t->menus_font1); nSDL_FreeFont(t->menus_font2); SDL_FreeSurface(t->pbar_cursor); SDL_FreeSurface(t->pbar_cursor_v); SDL_FreeSurface(t->window_icon); free(t->window_title_bg); nSDL_FreeFont(t->window_title_font); }