Same fix as r45172 for classes/iconimage:
[AROS-Contrib.git] / Games / lbreakout2 / gui / gui_theme.c
blobba3d2a6f2bad49691b9d826bb1eafd3bbdc2f510
1 /***************************************************************************
2 gui_theme.c - description
3 -------------------
4 begin : Fri Oct 11 2002
5 copyright : (C) 2002 by Michael Speck
6 email : kulkanie@gmx.net
7 ***************************************************************************/
9 /***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
18 #include <stdlib.h>
19 #include <sys/types.h>
20 #include <sys/stat.h>
21 #include "gui_theme.h"
23 #define ABORT( msg ) { fprintf( stderr, "%s\n", msg ); exit(1); }
25 GuiTheme *gui_theme = 0;
28 ====================================================================
29 Load a theme from a theme directory. The surface path set by
30 stk_surface_set_path() is prepended.
31 ====================================================================
34 GuiTheme* gui_theme_load( char *name )
36 GuiTheme *theme = calloc( 1, sizeof( GuiTheme ) );
37 if ( theme == 0 ) ABORT( "Out Of Memory" )
39 theme->box_wallpaper =
40 stk_surface_load( SDL_SWSURFACE,
41 "%s/box_wallpaper.png", name );
42 theme->widget_wallpaper =
43 stk_surface_load( SDL_SWSURFACE,
44 "%s/widget_wallpaper.png", name );
45 theme->box_frame =
46 stk_surface_load( SDL_SWSURFACE,
47 "%s/box_frame.png", name );
48 theme->widget_frame =
49 stk_surface_load( SDL_SWSURFACE,
50 "%s/widget_frame.png", name );
51 theme->button_frame_normal =
52 stk_surface_load( SDL_SWSURFACE,
53 "%s/button_frame_normal.png", name );
54 theme->button_frame_clicked =
55 stk_surface_load( SDL_SWSURFACE,
56 "%s/button_frame_clicked.png", name );
57 theme->button_wallpaper_normal =
58 stk_surface_load( SDL_SWSURFACE,
59 "%s/button_wallpaper_normal.png", name );
60 theme->button_wallpaper_focused =
61 stk_surface_load( SDL_SWSURFACE,
62 "%s/button_wallpaper_focused.png", name );
63 theme->scrollbar_arrows =
64 stk_surface_load( SDL_SWSURFACE,
65 "%s/scrollbar_arrows.png", name );
66 theme->scrollbar_arrow_size =
67 theme->scrollbar_arrows->h;
68 theme->checkbox =
69 stk_surface_load( SDL_SWSURFACE,
70 "%s/checkbox.png", name );
71 theme->checkbox_size = theme->checkbox->h;
72 theme->progress_high =
73 stk_surface_load( SDL_SWSURFACE,
74 "%s/progress_high.png", name );
75 theme->progress_medium =
76 stk_surface_load( SDL_SWSURFACE,
77 "%s/progress_medium.png", name );
78 theme->progress_low =
79 stk_surface_load( SDL_SWSURFACE,
80 "%s/progress_low.png", name );
81 theme->list_item_color =
82 stk_surface_load( SDL_SWSURFACE,
83 "%s/list_item_color.png", name );
84 theme->spinbutton_arrows =
85 stk_surface_load( SDL_SWSURFACE,
86 "%s/spinbutton_arrows.png", name );
87 theme->spinbutton_arrow_size =
88 theme->spinbutton_arrows->h;
90 theme->font =
91 stk_font_load( SDL_SWSURFACE, "%s/font.png", name );
92 theme->edit_font =
93 stk_font_load( SDL_SWSURFACE, "%s/font.png", name );
94 theme->label_font =
95 stk_font_load( SDL_SWSURFACE, "%s/font.png", name );
96 theme->button_font = theme->font;
97 theme->progressbar_font = theme->font;
99 theme->click_sound =
100 stk_sound_load( -1, "%s/click.wav", name );
101 theme->type_sound =
102 stk_sound_load( -1, "%s/edit.wav", name );
104 return theme;
108 ====================================================================
109 Free the memory of a surface if not NULL and reset the pointer
110 to NULL.
111 ====================================================================
113 void gui_theme_delete( GuiTheme **theme )
115 if ( *theme ) {
116 stk_surface_free( &(*theme)->box_wallpaper );
117 stk_surface_free( &(*theme)->widget_wallpaper );
118 stk_surface_free( &(*theme)->box_frame );
119 stk_surface_free( &(*theme)->widget_frame );
120 stk_surface_free( &(*theme)->button_frame_normal );
121 stk_surface_free( &(*theme)->button_frame_clicked );
122 stk_surface_free( &(*theme)->button_wallpaper_normal );
123 stk_surface_free( &(*theme)->button_wallpaper_focused );
124 stk_surface_free( &(*theme)->scrollbar_arrows );
125 stk_surface_free( &(*theme)->checkbox );
126 stk_surface_free( &(*theme)->progress_high );
127 stk_surface_free( &(*theme)->progress_medium );
128 stk_surface_free( &(*theme)->progress_low );
129 stk_surface_free( &(*theme)->list_item_color );
130 stk_surface_free( &(*theme)->spinbutton_arrows );
131 stk_font_free( &(*theme)->font );
132 stk_font_free( &(*theme)->edit_font );
133 stk_font_free( &(*theme)->label_font );
134 stk_sound_free( &(*theme)->click_sound );
135 stk_sound_free( &(*theme)->type_sound );
136 free( *theme ); *theme = 0;
141 ====================================================================
142 Select the current theme. New widgets will use its graphics.
143 ====================================================================
145 void gui_theme_select( GuiTheme *theme )
147 gui_theme = theme;