1 /* Copyright (C) 2007-2008 The Android Open Source Project 2 ** 3 ** This software is licensed under the terms of the GNU General Public 4 ** License version 2, as published by the Free Software Foundation, and 5 ** may be copied, distributed, and modified under those terms. 6 ** 7 ** This program is distributed in the hope that it will be useful, 8 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 9 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 ** GNU General Public License for more details. 11 */ 12 #ifndef _ANDROID_SKIN_FILE_H 13 #define _ANDROID_SKIN_FILE_H 14 15 #include "android/skin/image.h" 16 #include "android/config.h" 17 #include "android/framebuffer.h" 18 19 /** Layout 20 **/ 21 22 typedef struct SkinBackground { 23 SkinImage* image; 24 SkinRect rect; 25 char valid; 26 } SkinBackground; 27 28 typedef struct SkinDisplay { 29 SkinRect rect; /* display rectangle */ 30 SkinRotation rotation; /* framebuffer rotation */ 31 int bpp; /* bits per pixel, 32 or 16 */ 32 char valid; 33 QFrameBuffer qfbuff[1]; 34 } SkinDisplay; 35 36 typedef struct SkinButton { 37 struct SkinButton* next; 38 const char* name; 39 SkinImage* image; 40 SkinRect rect; 41 unsigned keycode; 42 } SkinButton; 43 44 typedef struct SkinPart { 45 struct SkinPart* next; 46 const char* name; 47 SkinBackground background[1]; 48 SkinDisplay display[1]; 49 SkinButton* buttons; 50 SkinRect rect; /* bounding box of all parts */ 51 } SkinPart; 52 53 #define SKIN_PART_LOOP_BUTTONS(part,button) \ 54 do { \ 55 SkinButton* __button = (part)->buttons; \ 56 while (__button != NULL) { \ 57 SkinButton* __button_next = __button->next; \ 58 SkinButton* button = __button; 59 60 #define SKIN_PART_LOOP_END \ 61 __button = __button_next; \ 62 } \ 63 } while (0); 64 65 typedef struct SkinLocation { 66 SkinPart* part; 67 SkinPos anchor; 68 SkinRotation rotation; 69 struct SkinLocation* next; 70 } SkinLocation; 71 72 typedef struct SkinLayout { 73 struct SkinLayout* next; 74 const char* name; 75 unsigned color; 76 int event_type; 77 int event_code; 78 int event_value; 79 char has_dpad_rotation; 80 SkinRotation dpad_rotation; 81 SkinSize size; 82 SkinLocation* locations; 83 } SkinLayout; 84 85 #define SKIN_LAYOUT_LOOP_LOCS(layout,loc) \ 86 do { \ 87 SkinLocation* __loc = (layout)->locations; \ 88 while (__loc != NULL) { \ 89 SkinLocation* __loc_next = (__loc)->next; \ 90 SkinLocation* loc = __loc; 91 92 #define SKIN_LAYOUT_LOOP_END \ 93 __loc = __loc_next; \ 94 } \ 95 } while (0); 96 97 extern SkinDisplay* skin_layout_get_display( SkinLayout* layout ); 98 99 extern SkinRotation skin_layout_get_dpad_rotation( SkinLayout* layout ); 100 101 typedef struct SkinFile { 102 int version; /* 1, 2 or 3 */ 103 SkinPart* parts; 104 SkinLayout* layouts; 105 int num_parts; 106 int num_layouts; 107 } SkinFile; 108 109 #define SKIN_FILE_LOOP_LAYOUTS(file,layout) \ 110 do { \ 111 SkinLayout* __layout = (file)->layouts; \ 112 while (__layout != NULL) { \ 113 SkinLayout* __layout_next = __layout->next; \ 114 SkinLayout* layout = __layout; 115 116 #define SKIN_FILE_LOOP_END_LAYOUTS \ 117 __layout = __layout_next; \ 118 } \ 119 } while (0); 120 121 #define SKIN_FILE_LOOP_PARTS(file,part) \ 122 do { \ 123 SkinPart* __part = (file)->parts; \ 124 while (__part != NULL) { \ 125 SkinPart* __part_next = __part->next; \ 126 SkinPart* part = __part; 127 128 #define SKIN_FILE_LOOP_END_PARTS \ 129 __part = __part_next; \ 130 } \ 131 } while (0); 132 133 extern SkinFile* skin_file_create_from_aconfig( AConfig* aconfig, const char* basepath ); 134 extern void skin_file_free( SkinFile* file ); 135 136 #endif /* _ANDROID_SKIN_FILE_H */ 137