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.h"
     17 #include "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     char          valid;
     32     QFrameBuffer  qfbuff[1];
     33 } SkinDisplay;
     34 
     35 typedef struct SkinButton {
     36     struct SkinButton*  next;
     37     const char*         name;
     38     SkinImage*          image;
     39     SkinRect            rect;
     40     unsigned            keycode;
     41 } SkinButton;
     42 
     43 typedef struct SkinPart {
     44     struct SkinPart*   next;
     45     const char*        name;
     46     SkinBackground     background[1];
     47     SkinDisplay        display[1];
     48     SkinButton*        buttons;
     49     SkinRect           rect;    /* bounding box of all parts */
     50 } SkinPart;
     51 
     52 #define  SKIN_PART_LOOP_BUTTONS(part,button)              \
     53     do {                                                  \
     54         SkinButton*  __button = (part)->buttons;          \
     55         while (__button != NULL) {                        \
     56             SkinButton*  __button_next = __button->next;  \
     57             SkinButton*  button        = __button;
     58 
     59 #define   SKIN_PART_LOOP_END             \
     60             __button = __button_next;    \
     61         }                                \
     62     } while (0);
     63 
     64 typedef struct SkinLocation {
     65     SkinPart*             part;
     66     SkinPos               anchor;
     67     SkinRotation          rotation;
     68     struct SkinLocation*  next;
     69 } SkinLocation;
     70 
     71 typedef struct SkinLayout {
     72     struct SkinLayout*  next;
     73     const char*         name;
     74     unsigned            color;
     75     int                 event_type;
     76     int                 event_code;
     77     int                 event_value;
     78     char                has_dpad_rotation;
     79     SkinRotation        dpad_rotation;
     80     SkinSize            size;
     81     SkinLocation*       locations;
     82 } SkinLayout;
     83 
     84 #define  SKIN_LAYOUT_LOOP_LOCS(layout,loc)               \
     85     do {                                                 \
     86         SkinLocation*  __loc = (layout)->locations;      \
     87         while (__loc != NULL) {                          \
     88             SkinLocation*  __loc_next = (__loc)->next;   \
     89             SkinLocation*  loc        = __loc;
     90 
     91 #define  SKIN_LAYOUT_LOOP_END   \
     92             __loc = __loc_next; \
     93         }                       \
     94     } while (0);
     95 
     96 extern SkinDisplay*   skin_layout_get_display( SkinLayout*  layout );
     97 
     98 extern SkinRotation   skin_layout_get_dpad_rotation( SkinLayout*  layout );
     99 
    100 typedef struct SkinFile {
    101     SkinPart*       parts;
    102     SkinLayout*     layouts;
    103     int             num_parts;
    104     int             num_layouts;
    105 } SkinFile;
    106 
    107 #define  SKIN_FILE_LOOP_LAYOUTS(file,layout)             \
    108     do {                                                 \
    109         SkinLayout*  __layout = (file)->layouts;         \
    110         while (__layout != NULL) {                       \
    111             SkinLayout*  __layout_next = __layout->next; \
    112             SkinLayout*  layout        = __layout;
    113 
    114 #define  SKIN_FILE_LOOP_END_LAYOUTS       \
    115             __layout = __layout_next;     \
    116         }                                 \
    117     } while (0);
    118 
    119 #define  SKIN_FILE_LOOP_PARTS(file,part)                 \
    120     do {                                                 \
    121         SkinPart*   __part = (file)->parts;              \
    122         while (__part != NULL) {                         \
    123             SkinPart*  __part_next = __part->next;       \
    124             SkinPart*  part        = __part;
    125 
    126 #define  SKIN_FILE_LOOP_END_PARTS  \
    127             __part = __part_next;  \
    128         }                          \
    129     } while (0);
    130 
    131 extern SkinFile*  skin_file_create_from_aconfig( AConfig*   aconfig, const char*  basepath );
    132 extern void       skin_file_free( SkinFile*  file );
    133 
    134 #endif /* _ANDROID_SKIN_FILE_H */
    135