root/core/gui_draw.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


   1 #ifndef GUI_DRAW_H
   2 #define GUI_DRAW_H
   3 
   4 #include "conf.h"       // load OSD_pos & OSD_scale
   5 #include "palette.h"
   6 
   7 //-------------------------------------------------------------------
   8 
   9 extern  unsigned char   *chdk_colors;
  10 
  11 #define IDX_COLOR_TRANSPARENT       0
  12 #define IDX_COLOR_BLACK             1
  13 #define IDX_COLOR_WHITE             2
  14 #define IDX_COLOR_RED               3
  15 #define IDX_COLOR_RED_DK            4
  16 #define IDX_COLOR_RED_LT            5
  17 #define IDX_COLOR_GREEN             6
  18 #define IDX_COLOR_GREEN_DK          7
  19 #define IDX_COLOR_GREEN_LT          8
  20 #define IDX_COLOR_BLUE              9
  21 #define IDX_COLOR_BLUE_DK           10
  22 #define IDX_COLOR_BLUE_LT           11
  23 #define IDX_COLOR_GREY              12
  24 #define IDX_COLOR_GREY_DK           13
  25 #define IDX_COLOR_GREY_LT           14
  26 #define IDX_COLOR_YELLOW            15
  27 #define IDX_COLOR_YELLOW_DK         16
  28 #define IDX_COLOR_YELLOW_LT         17
  29 #define IDX_COLOR_GREY_DK_TRANS     18
  30 #define IDX_COLOR_MAGENTA           19
  31 #define IDX_COLOR_CYAN              IDX_COLOR_BLUE_LT
  32 
  33 #define IDX_COLOR_MAX               19
  34 
  35 #define COLOR_WHITE             (chdk_colors[IDX_COLOR_WHITE])
  36 #define COLOR_RED               (chdk_colors[IDX_COLOR_RED])
  37 #define COLOR_RED_DK            (chdk_colors[IDX_COLOR_RED_DK])
  38 #define COLOR_RED_LT            (chdk_colors[IDX_COLOR_RED_LT])
  39 #define COLOR_GREEN             (chdk_colors[IDX_COLOR_GREEN])
  40 #define COLOR_GREEN_DK          (chdk_colors[IDX_COLOR_GREEN_DK])
  41 #define COLOR_GREEN_LT          (chdk_colors[IDX_COLOR_GREEN_LT])
  42 #define COLOR_BLUE              (chdk_colors[IDX_COLOR_BLUE])
  43 #define COLOR_BLUE_DK           (chdk_colors[IDX_COLOR_BLUE_DK])
  44 #define COLOR_BLUE_LT           (chdk_colors[IDX_COLOR_BLUE_LT])
  45 #define COLOR_GREY              (chdk_colors[IDX_COLOR_GREY])
  46 #define COLOR_GREY_DK           (chdk_colors[IDX_COLOR_GREY_DK])
  47 #define COLOR_GREY_LT           (chdk_colors[IDX_COLOR_GREY_LT])
  48 #define COLOR_YELLOW            (chdk_colors[IDX_COLOR_YELLOW])
  49 #define COLOR_YELLOW_DK         (chdk_colors[IDX_COLOR_YELLOW_DK])
  50 #define COLOR_YELLOW_LT         (chdk_colors[IDX_COLOR_YELLOW_LT])
  51 #define COLOR_GREY_DK_TRANS     (chdk_colors[IDX_COLOR_GREY_DK_TRANS])
  52 #define COLOR_MAGENTA           (chdk_colors[IDX_COLOR_MAGENTA])
  53 #define COLOR_CYAN              (chdk_colors[IDX_COLOR_CYAN])
  54 
  55 //-------------------------------------------------------------------
  56 #define FONT_REAL_WIDTH         8
  57 #define FONT_REAL_HEIGHT        16
  58 
  59 #ifndef THUMB_FW
  60 
  61 #define FONT_WIDTH              8
  62 #define FONT_HEIGHT             16
  63 // Name of default symbol file (for reset)
  64 #define DEFAULT_SYMBOL_FILE "A/CHDK/SYMBOLS/icon_10.rbf"
  65 
  66 #else // THUMB_FW
  67 
  68 #define FONT_WIDTH              14
  69 #define FONT_HEIGHT             32
  70 // Name of default symbol file (for reset)
  71 #define DEFAULT_SYMBOL_FILE "A/CHDK/SYMBOLS/icon_16.rbf"
  72 
  73 #endif // THUMB_FW
  74 
  75 // Text justification & options
  76 #define TEXT_LEFT               0
  77 #define TEXT_CENTER             1
  78 #define TEXT_RIGHT              2
  79 #define TEXT_FILL               16
  80 
  81 // Drawing flag options for rectangle and ellipse
  82 #define RECT_BORDER0            0       // Border widths
  83 #define RECT_BORDER1            1
  84 #define RECT_BORDER2            2
  85 #define RECT_BORDER3            3
  86 #define RECT_BORDER4            4
  87 #define RECT_BORDER5            5
  88 #define RECT_BORDER6            6
  89 #define RECT_BORDER7            7
  90 #define RECT_BORDER_MASK        7
  91 #define DRAW_FILLED             8       // Filled rectangle or ellipse
  92 #define RECT_SHADOW0            0       // Drop shadow widths
  93 #define RECT_SHADOW1            0x10
  94 #define RECT_SHADOW2            0x20
  95 #define RECT_SHADOW3            0x30
  96 #define RECT_SHADOW_MASK        0x30
  97 #define RECT_ROUND_CORNERS      0x40    // Round corners on rectangle
  98 
  99 //-------------------------------------------------------------------
 100 extern void draw_init();
 101 extern void draw_set_draw_proc(void (*pixel_proc)(unsigned int offset, color cl));
 102 extern void update_draw_proc();
 103 
 104 extern void draw_set_guard();
 105 extern int draw_test_guard();
 106 
 107 extern color draw_get_pixel(coord x, coord y);
 108 extern color draw_get_pixel_unrotated(coord x, coord y);
 109 
 110 extern void draw_pixel(coord x, coord y, color cl);
 111 extern void draw_pixel_unrotated(coord x, coord y, color cl);
 112 
 113 extern void draw_dblpixel_raw(unsigned int offset, unsigned int px, unsigned int op);
 114 extern void set_transparent(unsigned int offset, int n_pixel);
 115 extern unsigned int color_to_rawpx(color cl, unsigned int *op);
 116 
 117 extern void draw_line(coord x1, coord y1, coord x2, coord y2, color cl);
 118 extern void draw_hline(coord x, coord y, int len, color cl);
 119 extern void draw_vline(coord x, coord y, int len, color cl);
 120 
 121 // draw shapes
 122 extern void draw_rectangle(coord x1, coord y1, coord x2, coord y2, twoColors cl, int flags);
 123 extern void draw_ellipse(coord xc, coord yc, unsigned int a, unsigned int b, color cl, int flags);
 124 
 125 // draw text
 126 extern int  text_dimensions(const char *s, int width, int max_chars, int *max_lines);
 127 extern void draw_char(coord x, coord y, const char ch, twoColors cl);
 128 extern int  draw_string_clipped(coord x, coord y, const char *s, twoColors cl, int max_width);
 129 extern int  draw_string(coord x, coord y, const char *s, twoColors cl);
 130 extern int  draw_string_justified(coord x, coord y, const char *s, twoColors cl, int xo, int max_width, int justification);
 131 extern int  draw_text_justified(coord x, coord y, const char *s, twoColors cl, int max_chars, int max_lines, int justification);
 132 extern void draw_string_scaled(coord x, coord y, const char *s, twoColors cl, int xsize, int ysize);
 133 extern void draw_osd_string(OSD_pos pos, int xo, int yo, char *s, twoColors c, OSD_scale scale);
 134 extern void draw_button(int x, int y, int w, int str_id, int active);
 135 
 136 extern void draw_txt_string(coord col, coord row, const char *str, twoColors cl);
 137 
 138 extern void draw_restore();
 139 
 140 extern color get_script_color(int cl);
 141 
 142 extern color chdkColorToCanonColor(chdkColor c);
 143 extern twoColors user_color(confColor c);
 144 
 145 //-------------------------------------------------------------------
 146 // Icon rendering using an array of drawing actions
 147 
 148 // Allowed drawing actions for icons
 149 enum icon_actions
 150 {
 151     IA_END,
 152     IA_HLINE,
 153     IA_VLINE,
 154     IA_LINE,
 155     IA_RECT,
 156     IA_FILLED_RECT,
 157     IA_ROUND_RECT,
 158     IA_FILLED_ROUND_RECT
 159 };
 160 
 161 // Structure for a drawing action
 162 typedef struct
 163 {
 164     unsigned char   action;
 165     unsigned char   x1, y1;
 166     unsigned char   x2, y2;
 167     color           cb, cf;     // Note these should be IDX_COLOR_xxx values, converted to actual colors at runtime
 168 } icon_cmd;
 169 
 170 // Draw an icon from a list of actions
 171 extern void draw_icon_cmds(coord x, coord y, icon_cmd *cmds);
 172 
 173 //-------------------------------------------------------------------
 174 #endif

/* [<][>][^][v][top][bottom][index][help] */