file.h revision 97d795c955f8d261a0a5294d49ea06d5a473ed03
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 "framebuffer.h" 18 19/** Layout 20 **/ 21 22typedef struct SkinBackground { 23 SkinImage* image; 24 SkinRect rect; 25 char valid; 26} SkinBackground; 27 28typedef 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 36typedef struct SkinButton { 37 struct SkinButton* next; 38 const char* name; 39 SkinImage* image; 40 SkinRect rect; 41 unsigned keycode; 42} SkinButton; 43 44typedef 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 65typedef struct SkinLocation { 66 SkinPart* part; 67 SkinPos anchor; 68 SkinRotation rotation; 69 struct SkinLocation* next; 70} SkinLocation; 71 72typedef 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 97extern SkinDisplay* skin_layout_get_display( SkinLayout* layout ); 98 99extern SkinRotation skin_layout_get_dpad_rotation( SkinLayout* layout ); 100 101typedef struct SkinFile { 102 SkinPart* parts; 103 SkinLayout* layouts; 104 int num_parts; 105 int num_layouts; 106} SkinFile; 107 108#define SKIN_FILE_LOOP_LAYOUTS(file,layout) \ 109 do { \ 110 SkinLayout* __layout = (file)->layouts; \ 111 while (__layout != NULL) { \ 112 SkinLayout* __layout_next = __layout->next; \ 113 SkinLayout* layout = __layout; 114 115#define SKIN_FILE_LOOP_END_LAYOUTS \ 116 __layout = __layout_next; \ 117 } \ 118 } while (0); 119 120#define SKIN_FILE_LOOP_PARTS(file,part) \ 121 do { \ 122 SkinPart* __part = (file)->parts; \ 123 while (__part != NULL) { \ 124 SkinPart* __part_next = __part->next; \ 125 SkinPart* part = __part; 126 127#define SKIN_FILE_LOOP_END_PARTS \ 128 __part = __part_next; \ 129 } \ 130 } while (0); 131 132extern SkinFile* skin_file_create_from_aconfig( AConfig* aconfig, const char* basepath ); 133extern void skin_file_free( SkinFile* file ); 134 135#endif /* _ANDROID_SKIN_FILE_H */ 136