Home | History | Annotate | Download | only in skin
      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-file.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     SkinImage*          onion_image;
     84     int                 onion_alpha;
     85     SkinRotation        onion_rotation;
     86 } SkinLayout;
     87 
     88 #define  SKIN_LAYOUT_LOOP_LOCS(layout,loc)               \
     89     do {                                                 \
     90         SkinLocation*  __loc = (layout)->locations;      \
     91         while (__loc != NULL) {                          \
     92             SkinLocation*  __loc_next = (__loc)->next;   \
     93             SkinLocation*  loc        = __loc;
     94 
     95 #define  SKIN_LAYOUT_LOOP_END   \
     96             __loc = __loc_next; \
     97         }                       \
     98     } while (0);
     99 
    100 extern SkinDisplay*   skin_layout_get_display( SkinLayout*  layout );
    101 
    102 extern SkinRotation   skin_layout_get_dpad_rotation( SkinLayout*  layout );
    103 
    104 typedef struct SkinFile {
    105     int             version;  /* 1, 2 or 3 */
    106     SkinPart*       parts;
    107     SkinLayout*     layouts;
    108     int             num_parts;
    109     int             num_layouts;
    110 } SkinFile;
    111 
    112 #define  SKIN_FILE_LOOP_LAYOUTS(file,layout)             \
    113     do {                                                 \
    114         SkinLayout*  __layout = (file)->layouts;         \
    115         while (__layout != NULL) {                       \
    116             SkinLayout*  __layout_next = __layout->next; \
    117             SkinLayout*  layout        = __layout;
    118 
    119 #define  SKIN_FILE_LOOP_END_LAYOUTS       \
    120             __layout = __layout_next;     \
    121         }                                 \
    122     } while (0);
    123 
    124 #define  SKIN_FILE_LOOP_PARTS(file,part)                 \
    125     do {                                                 \
    126         SkinPart*   __part = (file)->parts;              \
    127         while (__part != NULL) {                         \
    128             SkinPart*  __part_next = __part->next;       \
    129             SkinPart*  part        = __part;
    130 
    131 #define  SKIN_FILE_LOOP_END_PARTS  \
    132             __part = __part_next;  \
    133         }                          \
    134     } while (0);
    135 
    136 extern SkinFile*  skin_file_create_from_aconfig( AConfig*   aconfig, const char*  basepath );
    137 extern void       skin_file_free( SkinFile*  file );
    138 
    139 #endif /* _ANDROID_SKIN_FILE_H */
    140