| 1 | |
|---|
| 2 | #include "DHL_OSAL.h" |
|---|
| 3 | #include "DHL_DBG.h" |
|---|
| 4 | #include "DHL_Graphic.h" |
|---|
| 5 | |
|---|
| 6 | #include "DMG_Draw.h" |
|---|
| 7 | #include "DMG_Util.h" |
|---|
| 8 | #if SUPPORT_JUNGLE |
|---|
| 9 | #include "grp_jungle.h" |
|---|
| 10 | #endif |
|---|
| 11 | |
|---|
| 12 | #if SUPPORT_BMF |
|---|
| 13 | #include "BMF.h" |
|---|
| 14 | #endif |
|---|
| 15 | |
|---|
| 16 | //#include <string.h> |
|---|
| 17 | //#include <string.h> |
|---|
| 18 | |
|---|
| 19 | DHL_MODULE("DMG_D", 0); |
|---|
| 20 | |
|---|
| 21 | /* config */ |
|---|
| 22 | |
|---|
| 23 | #define USE_KOR_AUTO_CHANGE 1 |
|---|
| 24 | #define USE_GRP_MTX 0 |
|---|
| 25 | |
|---|
| 26 | |
|---|
| 27 | #if USE_KOR_AUTO_CHANGE |
|---|
| 28 | #define DEF_KOR_FONT (eDMG_FONT_DHL+1) /*±âº» ÇÑ±Û ÆùÆ®*/ |
|---|
| 29 | #endif |
|---|
| 30 | |
|---|
| 31 | |
|---|
| 32 | |
|---|
| 33 | static tDHL_GrpRect p_rect={0,0,0,0}; |
|---|
| 34 | |
|---|
| 35 | static tDHL_PlaneID p_plane_id; |
|---|
| 36 | static tDMG_FontAttr p_font_attr; |
|---|
| 37 | |
|---|
| 38 | #if USE_GRP_MTX |
|---|
| 39 | static OS_SEMAPHORE_ID p_mtx; |
|---|
| 40 | #endif |
|---|
| 41 | |
|---|
| 42 | static int p_temp_font_size; |
|---|
| 43 | |
|---|
| 44 | |
|---|
| 45 | #if COMMENT |
|---|
| 46 | __Local_Func__() {} |
|---|
| 47 | #endif |
|---|
| 48 | |
|---|
| 49 | |
|---|
| 50 | #if USE_GRP_MTX |
|---|
| 51 | static void p_lock(BOOL block) |
|---|
| 52 | { |
|---|
| 53 | if(!p_mtx) return; |
|---|
| 54 | |
|---|
| 55 | if(block) OS_TakeSemaphore(p_mtx); |
|---|
| 56 | else OS_GiveSemaphore(p_mtx); |
|---|
| 57 | } |
|---|
| 58 | #else |
|---|
| 59 | #define p_lock(lock) |
|---|
| 60 | #endif |
|---|
| 61 | |
|---|
| 62 | |
|---|
| 63 | static void p_merge_rect(tDHL_GrpRect *r1, int x, int y, int w, int h) |
|---|
| 64 | { |
|---|
| 65 | /* r1¿¡ r2¸¦ mergeÇÔ */ |
|---|
| 66 | if(r1->w==0 && r1->h==0) {r1->x=x; r1->y=y; r1->w=w; r1->h=h; return;} |
|---|
| 67 | |
|---|
| 68 | if(r1->x>x) {r1->w+=r1->x-x; r1->x=x;} |
|---|
| 69 | if(r1->y>y) {r1->h+=r1->y-y; r1->y=y;} |
|---|
| 70 | if(r1->x+r1->w<x+w) r1->w=x+w-r1->x; |
|---|
| 71 | if(r1->y+r1->h<y+h) r1->h=y+h-r1->y; |
|---|
| 72 | |
|---|
| 73 | dprint(2, "--> auto refresh(%d,%d,%d,%d)->(%d,%d,%d,%d)\n", |
|---|
| 74 | x, y, w, h, r1->x, r1->y, r1->w, r1->h); |
|---|
| 75 | |
|---|
| 76 | } |
|---|
| 77 | |
|---|
| 78 | |
|---|
| 79 | const static UINT32 p_color_table[][2]={ |
|---|
| 80 | {eDMG_C_TRANSPARENT, 0x00000000}, |
|---|
| 81 | {eDMG_C_BLACK, 0xff000000}, |
|---|
| 82 | {eDMG_C_RED, 0xffff0000}, |
|---|
| 83 | {eDMG_C_GREEN, 0xff00ff00}, |
|---|
| 84 | {eDMG_C_BLUE, 0xff0000ff}, |
|---|
| 85 | {eDMG_C_YELLOW, 0xffffff00}, |
|---|
| 86 | {eDMG_C_MAGENTA, 0xffff00ff}, |
|---|
| 87 | {eDMG_C_CYAN, 0xff00ffff}, |
|---|
| 88 | {eDMG_C_WHITE, 0xffffffff}, |
|---|
| 89 | {eDMG_C_H_BLACK, 0x8f000000}, |
|---|
| 90 | {eDMG_C_H_RED, 0x8fff0000}, |
|---|
| 91 | {eDMG_C_H_GREEN, 0x8f00ff00}, |
|---|
| 92 | {eDMG_C_H_BLUE, 0x8f0000ff}, |
|---|
| 93 | {eDMG_C_H_YELLOW, 0x8fffff00}, |
|---|
| 94 | {eDMG_C_H_MAGENTA, 0x8fff00ff}, |
|---|
| 95 | {eDMG_C_H_CYAN, 0x8f00ffff}, |
|---|
| 96 | {eDMG_C_H_WHITE, 0x8fffffff} |
|---|
| 97 | }; |
|---|
| 98 | |
|---|
| 99 | |
|---|
| 100 | static UINT32 p_convert_color(UINT32 color) |
|---|
| 101 | { |
|---|
| 102 | UINT32 ret_color; |
|---|
| 103 | unsigned int i; |
|---|
| 104 | tDHL_PixelType pixel_type; |
|---|
| 105 | |
|---|
| 106 | for(i=0; i<(int)sizeof(p_color_table)/sizeof(p_color_table[0]); i++) { |
|---|
| 107 | if(color==p_color_table[i][0]) return p_color_table[i][1]; |
|---|
| 108 | } |
|---|
| 109 | |
|---|
| 110 | return color; |
|---|
| 111 | } |
|---|
| 112 | |
|---|
| 113 | |
|---|
| 114 | #if COMMENT |
|---|
| 115 | __Draw_Func__() {} |
|---|
| 116 | #endif |
|---|
| 117 | |
|---|
| 118 | |
|---|
| 119 | |
|---|
| 120 | |
|---|
| 121 | void DMG_SetPlane(tDHL_PlaneID id) |
|---|
| 122 | { |
|---|
| 123 | p_lock(TRUE); |
|---|
| 124 | p_plane_id=id; |
|---|
| 125 | p_lock(FALSE); |
|---|
| 126 | } |
|---|
| 127 | |
|---|
| 128 | tDHL_PlaneID DMG_GetPlane() |
|---|
| 129 | { |
|---|
| 130 | return p_plane_id; |
|---|
| 131 | } |
|---|
| 132 | |
|---|
| 133 | |
|---|
| 134 | UINT32 DMG_ConvertDefColor(UINT32 color) |
|---|
| 135 | { |
|---|
| 136 | return p_convert_color(color); |
|---|
| 137 | } |
|---|
| 138 | |
|---|
| 139 | |
|---|
| 140 | void DMG_FillRect(int x, int y, int w, int h, UINT32 color) |
|---|
| 141 | { |
|---|
| 142 | p_lock(TRUE); |
|---|
| 143 | DHL_FillRect(p_plane_id, x, y, w, h, p_convert_color(color)); |
|---|
| 144 | p_merge_rect(&p_rect, x, y, w, h); |
|---|
| 145 | p_lock(FALSE); |
|---|
| 146 | } |
|---|
| 147 | |
|---|
| 148 | void DMG_EraseRect(int x, int y, int w, int h, UINT32 color) |
|---|
| 149 | { |
|---|
| 150 | p_lock(TRUE); |
|---|
| 151 | DHL_EraseRect(p_plane_id, x, y, w, h, p_convert_color(color)); |
|---|
| 152 | p_merge_rect(&p_rect, x, y, w, h); |
|---|
| 153 | p_lock(FALSE); |
|---|
| 154 | } |
|---|
| 155 | |
|---|
| 156 | void DMG_DrawHLine(int x, int y, int w, UINT32 color) |
|---|
| 157 | { |
|---|
| 158 | p_lock(TRUE); |
|---|
| 159 | DHL_DrawHLine(p_plane_id, x, y, w, p_convert_color(color)); |
|---|
| 160 | p_merge_rect(&p_rect, x, y, w, 1); |
|---|
| 161 | p_lock(FALSE); |
|---|
| 162 | } |
|---|
| 163 | |
|---|
| 164 | void DMG_DrawVLine(int x, int y, int h, UINT32 color) |
|---|
| 165 | { |
|---|
| 166 | p_lock(TRUE); |
|---|
| 167 | DHL_DrawVLine(p_plane_id, x, y, h, p_convert_color(color)); |
|---|
| 168 | p_merge_rect(&p_rect, x, y, 1, h); |
|---|
| 169 | p_lock(FALSE); |
|---|
| 170 | } |
|---|
| 171 | |
|---|
| 172 | void DMG_BLT(tDHL_PlaneID src_id, tDHL_PlaneID dst_id, tDHL_GrpRect *src_r, tDHL_GrpRect *dst_r) |
|---|
| 173 | { |
|---|
| 174 | if(src_r->w==0 || src_r->h==0 || dst_r->w==0 || dst_r->h==0) return; |
|---|
| 175 | |
|---|
| 176 | p_lock(TRUE); |
|---|
| 177 | |
|---|
| 178 | DHL_PostDraw(dst_id, src_r->x, src_r->y, src_r->w, src_r->h); |
|---|
| 179 | |
|---|
| 180 | DHL_BLT(src_id, dst_id, src_r, dst_r); |
|---|
| 181 | |
|---|
| 182 | p_merge_rect(&p_rect, src_r->x, src_r->y, src_r->w, src_r->h); |
|---|
| 183 | p_merge_rect(&p_rect, dst_r->x, dst_r->y, dst_r->w, dst_r->h); |
|---|
| 184 | |
|---|
| 185 | p_lock(FALSE); |
|---|
| 186 | } |
|---|
| 187 | |
|---|
| 188 | void DMG_DrawLine(int x1, int y1, int x2, int y2) |
|---|
| 189 | { |
|---|
| 190 | /* not implemented yet */ |
|---|
| 191 | dprint(0, "not implemented yet!\n"); |
|---|
| 192 | } |
|---|
| 193 | |
|---|
| 194 | void DMG_DrawBox(int x, int y, int w, int h, UINT32 color) |
|---|
| 195 | { |
|---|
| 196 | p_lock(TRUE); |
|---|
| 197 | |
|---|
| 198 | DHL_DrawHLine(p_plane_id, x, y, w, p_convert_color(color)); |
|---|
| 199 | DHL_DrawVLine(p_plane_id, x, y, h, p_convert_color(color)); |
|---|
| 200 | DHL_DrawHLine(p_plane_id, x, y+h-1, w, p_convert_color(color)); |
|---|
| 201 | DHL_DrawVLine(p_plane_id, x+w-1, y, h, p_convert_color(color)); |
|---|
| 202 | dprint(2, "[%s] (x,y,w,h) -> (%d,%d,%d,%d)\n", __FUNCTION__, x, y, w, h); |
|---|
| 203 | |
|---|
| 204 | p_merge_rect(&p_rect, x, y, w, h); |
|---|
| 205 | |
|---|
| 206 | p_lock(FALSE); |
|---|
| 207 | } |
|---|
| 208 | |
|---|
| 209 | void DMG_DrawEllipse(int ox, int oy, int rw, int rh) |
|---|
| 210 | { |
|---|
| 211 | dprint(0, "not implemented yet!\n"); |
|---|
| 212 | } |
|---|
| 213 | |
|---|
| 214 | |
|---|
| 215 | void DMG_AutoRefresh() |
|---|
| 216 | { |
|---|
| 217 | p_lock(TRUE); |
|---|
| 218 | |
|---|
| 219 | if(p_rect.w>0 && p_rect.h>0) { |
|---|
| 220 | DHL_PostDraw(p_plane_id, p_rect.x, p_rect.y, p_rect.w, p_rect.h); |
|---|
| 221 | DHL_RefreshPlane(p_plane_id, p_rect.x, p_rect.y, p_rect.w, p_rect.h); |
|---|
| 222 | p_rect.x=0; |
|---|
| 223 | p_rect.y=0; |
|---|
| 224 | p_rect.w=0; |
|---|
| 225 | p_rect.h=0; |
|---|
| 226 | } |
|---|
| 227 | |
|---|
| 228 | p_lock(FALSE); |
|---|
| 229 | } |
|---|
| 230 | |
|---|
| 231 | |
|---|
| 232 | #if COMMENT |
|---|
| 233 | __Image_Func__() {} |
|---|
| 234 | #endif |
|---|
| 235 | |
|---|
| 236 | |
|---|
| 237 | void DMG_DrawImage(int x, int y, int w, int h, void *pimg) |
|---|
| 238 | { |
|---|
| 239 | tDHL_Image img; |
|---|
| 240 | |
|---|
| 241 | if (pimg == NULL) |
|---|
| 242 | { |
|---|
| 243 | return; |
|---|
| 244 | } |
|---|
| 245 | |
|---|
| 246 | img.is_file=FALSE; |
|---|
| 247 | |
|---|
| 248 | img.src.image.buf=pimg; |
|---|
| 249 | img.src.image.is_png=FALSE; |
|---|
| 250 | img.src.image.width=w; |
|---|
| 251 | img.src.image.height=h; |
|---|
| 252 | |
|---|
| 253 | p_lock(TRUE); |
|---|
| 254 | |
|---|
| 255 | DHL_DrawImage(p_plane_id, x, y, &img); |
|---|
| 256 | p_merge_rect(&p_rect, x, y, w, h); |
|---|
| 257 | |
|---|
| 258 | p_lock(FALSE); |
|---|
| 259 | } |
|---|
| 260 | |
|---|
| 261 | |
|---|
| 262 | void DMG_DrawImagePng(int x, int y, void *pimg) |
|---|
| 263 | { |
|---|
| 264 | tDHL_Image img; |
|---|
| 265 | int w=0, h=0; |
|---|
| 266 | |
|---|
| 267 | dprint(1, "%s:(%x)\n", __FUNCTION__, pimg); |
|---|
| 268 | |
|---|
| 269 | if (pimg == NULL) |
|---|
| 270 | { |
|---|
| 271 | return; |
|---|
| 272 | } |
|---|
| 273 | |
|---|
| 274 | img.is_file=FALSE; |
|---|
| 275 | |
|---|
| 276 | img.src.image.buf=pimg; |
|---|
| 277 | img.src.image.is_png=TRUE; |
|---|
| 278 | |
|---|
| 279 | p_lock(TRUE); |
|---|
| 280 | |
|---|
| 281 | DHL_DrawImage(p_plane_id, x, y, &img); |
|---|
| 282 | |
|---|
| 283 | DHL_GetImageSize(&img, &w, &h); |
|---|
| 284 | p_merge_rect(&p_rect, x, y, w, h); |
|---|
| 285 | |
|---|
| 286 | p_lock(FALSE); |
|---|
| 287 | } |
|---|
| 288 | |
|---|
| 289 | |
|---|
| 290 | void DMG_DrawImageFile(int x, int y, char *file_name) |
|---|
| 291 | { |
|---|
| 292 | tDHL_Image img; |
|---|
| 293 | int w=0, h=0; |
|---|
| 294 | |
|---|
| 295 | if (file_name == NULL) |
|---|
| 296 | { |
|---|
| 297 | return; |
|---|
| 298 | } |
|---|
| 299 | |
|---|
| 300 | img.is_file=TRUE; |
|---|
| 301 | |
|---|
| 302 | img.src.file_name=file_name; |
|---|
| 303 | |
|---|
| 304 | p_lock(TRUE); |
|---|
| 305 | |
|---|
| 306 | DHL_DrawImage(p_plane_id, x, y, &img); |
|---|
| 307 | |
|---|
| 308 | DHL_GetImageSize(&img, &w, &h); |
|---|
| 309 | p_merge_rect(&p_rect, x, y, w, h); |
|---|
| 310 | |
|---|
| 311 | p_lock(FALSE); |
|---|
| 312 | } |
|---|
| 313 | |
|---|
| 314 | |
|---|
| 315 | |
|---|
| 316 | |
|---|
| 317 | |
|---|
| 318 | #if COMMENT |
|---|
| 319 | __Print_Func__() {} |
|---|
| 320 | #endif |
|---|
| 321 | |
|---|
| 322 | |
|---|
| 323 | typedef struct { |
|---|
| 324 | UINT16 idx; |
|---|
| 325 | UINT16 len; |
|---|
| 326 | UINT16 width; /* line width */ |
|---|
| 327 | } tPRIV_RowInfo; |
|---|
| 328 | |
|---|
| 329 | |
|---|
| 330 | /* local variables */ |
|---|
| 331 | // zooyouny : default¸¦ BMF·Î º¯°æ |
|---|
| 332 | #if 0 // todo cc Å×½ºÆ® ÇÒ¶§´Â 0À¸·Î ¼³Á¤ ÇÒ °Í |
|---|
| 333 | static tDMG_Font p_font=eDMG_FONT_JUNGLE; |
|---|
| 334 | #else |
|---|
| 335 | static tDMG_Font p_font=eDMG_FONT_BMF; |
|---|
| 336 | #endif |
|---|
| 337 | |
|---|
| 338 | static tDMG_Language p_lang=eDMG_LANG_ENG; |
|---|
| 339 | |
|---|
| 340 | static int p_inter_line_gap=4; |
|---|
| 341 | |
|---|
| 342 | /* local functions */ |
|---|
| 343 | |
|---|
| 344 | static BOOL p_is_alphabet(UINT16 ch) |
|---|
| 345 | { |
|---|
| 346 | //return ((ch>='a' && ch<='z') || (ch>='A' && ch<='Z') || (ch>=0xc0 && ch<=0xff)); |
|---|
| 347 | return (ch!=' '); |
|---|
| 348 | |
|---|
| 349 | } |
|---|
| 350 | |
|---|
| 351 | static BOOL p_is_wansung(UINT8 ch1, UINT8 ch2) |
|---|
| 352 | { |
|---|
| 353 | //return (ch1>=0xa1 && ch2>=0xa0); |
|---|
| 354 | return FALSE; //±¹³»ÇâÀÌ ¾Æ´Ï¸é FALSE¸¦ ¸®ÅÏÇÔ. |
|---|
| 355 | } |
|---|
| 356 | |
|---|
| 357 | |
|---|
| 358 | static void p_convert_hex_ch(char *pstr) |
|---|
| 359 | { |
|---|
| 360 | int i; |
|---|
| 361 | int hex_mode=-1; |
|---|
| 362 | char hex_buf[3]={0,0,0}; |
|---|
| 363 | |
|---|
| 364 | for(i=0; pstr[i]; i++) { |
|---|
| 365 | if(pstr[i]=='#') { /* ##À̳ª #x#ÀÇ °æ¿ì #¸¸ ÂïÀ½ */ |
|---|
| 366 | if(hex_mode>=0) { |
|---|
| 367 | hex_mode=-1; |
|---|
| 368 | } |
|---|
| 369 | else { /* #À̸é hex mode·Î ÁøÀÔ */ |
|---|
| 370 | hex_mode=0; |
|---|
| 371 | continue; |
|---|
| 372 | } |
|---|
| 373 | } /* ÀÌ¹Ì hex mode·Î ÁøÀÔÇßÀ¸¸é hexdecimal °ªÀ» ÀúÀå */ |
|---|
| 374 | else if(hex_mode>=0) { |
|---|
| 375 | hex_buf[hex_mode++]=pstr[i]; |
|---|
| 376 | |
|---|
| 377 | if(hex_mode>=2) { /* hex°ª 2°³¸¦ ÀÔ·Â ¹Þ¾ÒÀ¸¸é PrintÇÔ */ |
|---|
| 378 | int temp, j; |
|---|
| 379 | |
|---|
| 380 | sscanf(hex_buf, "%x", &temp); |
|---|
| 381 | i-=2; |
|---|
| 382 | pstr[i]=temp; |
|---|
| 383 | |
|---|
| 384 | //i+3À» i+1·Î ¿Å°Ü¾ß ÇÔ |
|---|
| 385 | for(j=i+3; pstr[j]; j++) { |
|---|
| 386 | pstr[j-2]=pstr[j]; |
|---|
| 387 | } |
|---|
| 388 | pstr[j-2]='\0'; |
|---|
| 389 | |
|---|
| 390 | hex_mode=-1; |
|---|
| 391 | continue; |
|---|
| 392 | } |
|---|
| 393 | } |
|---|
| 394 | } |
|---|
| 395 | } |
|---|
| 396 | |
|---|
| 397 | |
|---|
| 398 | static int p_get_ch_width(UINT16 ch, BOOL bconvert_to_uni) |
|---|
| 399 | { |
|---|
| 400 | int ret_val=0; |
|---|
| 401 | |
|---|
| 402 | |
|---|
| 403 | if(ch>=0xa1a0 && bconvert_to_uni) { |
|---|
| 404 | //¿Ï¼ºÇüÀ» unicode·Î º¯°æÇÔ. |
|---|
| 405 | ch=DMG_Ksx1001toUnicode(ch); |
|---|
| 406 | } |
|---|
| 407 | |
|---|
| 408 | if(p_font==eDMG_FONT_JUNGLE) { |
|---|
| 409 | #if SUPPORT_JUNGLE |
|---|
| 410 | ret_val=Jungle_GetChWidth(ch); |
|---|
| 411 | #else |
|---|
| 412 | dprint(0, "!! %s : jungle is not spported\n"); |
|---|
| 413 | #endif |
|---|
| 414 | } |
|---|
| 415 | else if(p_font==eDMG_FONT_BMF) { |
|---|
| 416 | #if SUPPORT_BMF |
|---|
| 417 | ret_val=BMF_GetChWidth(ch); |
|---|
| 418 | #else |
|---|
| 419 | dprint(0, "!! %s : bmf is not spported\n"); |
|---|
| 420 | #endif |
|---|
| 421 | } |
|---|
| 422 | else if(p_font>=eDMG_FONT_DHL && p_font<=eDMG_FONT_DHL_END) { |
|---|
| 423 | #if USE_DHL_FONT |
|---|
| 424 | |
|---|
| 425 | ret_val=DHL_GetChWidth(ch); |
|---|
| 426 | #else |
|---|
| 427 | dprint(0, "!! %s : DHL font is not supported\n", __FUNCTION__); |
|---|
| 428 | #endif |
|---|
| 429 | } |
|---|
| 430 | |
|---|
| 431 | #if USE_KOR_AUTO_CHANGE && USE_DHL_FONT |
|---|
| 432 | if(ret_val==0) { /* ÆùÆ® º¯°æÀ» ½ÃµµÇÑ´Ù */ |
|---|
| 433 | int temp=p_font; |
|---|
| 434 | |
|---|
| 435 | DMG_SetFont(DEF_KOR_FONT); |
|---|
| 436 | ret_val=DHL_GetChWidth(ch); |
|---|
| 437 | DMG_SetFont(temp); |
|---|
| 438 | } |
|---|
| 439 | #endif |
|---|
| 440 | |
|---|
| 441 | if(ret_val==0) { |
|---|
| 442 | dprint(2, "!! %s fail to get ch(0x%x)\n", __FUNCTION__, ch); |
|---|
| 443 | } |
|---|
| 444 | |
|---|
| 445 | return ret_val; |
|---|
| 446 | |
|---|
| 447 | } |
|---|
| 448 | |
|---|
| 449 | |
|---|
| 450 | static int p_get_str_width(char *pstr, int num) |
|---|
| 451 | { |
|---|
| 452 | int i; |
|---|
| 453 | int width; |
|---|
| 454 | UINT8 *pbuf=(UINT8 *)pstr; |
|---|
| 455 | |
|---|
| 456 | for(i=0, width=0; pstr[i] && ((num<0) || (i<num)); i++) { |
|---|
| 457 | |
|---|
| 458 | if((num<0 || i<num-1) && p_is_wansung(pbuf[i], pbuf[i+1])) { |
|---|
| 459 | width+=p_get_ch_width((pbuf[i]<<8)|pbuf[++i], TRUE); |
|---|
| 460 | } |
|---|
| 461 | else { |
|---|
| 462 | width+=p_get_ch_width(pstr[i], FALSE); |
|---|
| 463 | } |
|---|
| 464 | } |
|---|
| 465 | |
|---|
| 466 | return width; |
|---|
| 467 | } |
|---|
| 468 | |
|---|
| 469 | |
|---|
| 470 | static int p_get_ustr_width(UINT16 *pstr, int num) |
|---|
| 471 | { |
|---|
| 472 | int i; |
|---|
| 473 | int width; |
|---|
| 474 | |
|---|
| 475 | for(i=0, width=0; pstr[i] && ((num<0) || (i<num)); i++) |
|---|
| 476 | width+=p_get_ch_width(pstr[i], !p_font_attr.is_unicode); |
|---|
| 477 | |
|---|
| 478 | return width; |
|---|
| 479 | } |
|---|
| 480 | |
|---|
| 481 | |
|---|
| 482 | static int p_print_ch(int x, int y, UINT16 ch, UINT32 color, BOOL bconvert_to_uni) |
|---|
| 483 | { |
|---|
| 484 | int ret_val=0; |
|---|
| 485 | |
|---|
| 486 | dprint(1, "p_print_ch:x(%d), y(%d), ch(%x), color(%x)\n", |
|---|
| 487 | x, y, ch, color); |
|---|
| 488 | |
|---|
| 489 | color=p_convert_color(color); |
|---|
| 490 | |
|---|
| 491 | if(ch>=0xa1a0 && bconvert_to_uni) { |
|---|
| 492 | //¿Ï¼ºÇüÀ» unicode·Î º¯°æÇÔ. |
|---|
| 493 | ch=DMG_Ksx1001toUnicode(ch); |
|---|
| 494 | } |
|---|
| 495 | |
|---|
| 496 | p_lock(TRUE); |
|---|
| 497 | |
|---|
| 498 | if(p_font==eDMG_FONT_JUNGLE) { |
|---|
| 499 | #if SUPPORT_JUNGLE |
|---|
| 500 | ret_val=Jungle_PrintCh(p_plane_id, x, y, ch, color); |
|---|
| 501 | #else |
|---|
| 502 | dprint(0, "!! %s : jungle is not spported\n"); |
|---|
| 503 | #endif |
|---|
| 504 | } |
|---|
| 505 | else if(p_font==eDMG_FONT_BMF) { |
|---|
| 506 | #if SUPPORT_BMF |
|---|
| 507 | ret_val=BMF_PrintCh(p_plane_id, x, y, ch, color); |
|---|
| 508 | #else |
|---|
| 509 | dprint(0, "!! %s : BMF is not spported\n"); |
|---|
| 510 | #endif |
|---|
| 511 | } |
|---|
| 512 | else if(p_font>=eDMG_FONT_DHL && p_font<=eDMG_FONT_DHL_END) { |
|---|
| 513 | #if USE_DHL_FONT |
|---|
| 514 | ret_val=DHL_PrintCh(p_plane_id, x, y, ch, color); |
|---|
| 515 | #else |
|---|
| 516 | dprint(0, "!! %s : DHL Font is not supported\n", __FUNCTION__); |
|---|
| 517 | #endif |
|---|
| 518 | } |
|---|
| 519 | |
|---|
| 520 | #if USE_KOR_AUTO_CHANGE && USE_DHL_FONT |
|---|
| 521 | if(ret_val==0) { /* ÆùÆ® º¯°æÀ» ½ÃµµÇÑ´Ù */ |
|---|
| 522 | int temp=p_font; |
|---|
| 523 | |
|---|
| 524 | DMG_SetFont(DEF_KOR_FONT); |
|---|
| 525 | ret_val=DHL_PrintCh(p_plane_id, x, y, ch, color); |
|---|
| 526 | DMG_SetFont(temp); |
|---|
| 527 | } |
|---|
| 528 | #endif |
|---|
| 529 | |
|---|
| 530 | p_merge_rect(&p_rect, x, y, ret_val, DMG_GetChHeight(ch)+2); //³Ë³ËÇÏ°Ô rect¸¦ ÀâÀ½. |
|---|
| 531 | |
|---|
| 532 | p_lock(FALSE); |
|---|
| 533 | |
|---|
| 534 | return ret_val; |
|---|
| 535 | } |
|---|
| 536 | |
|---|
| 537 | |
|---|
| 538 | static int p_print_str(int x, int y, char *pstr, int num, UINT32 color) |
|---|
| 539 | { |
|---|
| 540 | int i, posx; |
|---|
| 541 | UINT8 *pbuf=(UINT8 *)pstr; |
|---|
| 542 | |
|---|
| 543 | for(i=0, posx=x; pstr[i] && ((num<0) || (i<num)); i++) { |
|---|
| 544 | |
|---|
| 545 | if((num<0 || i<num-1) && p_is_wansung(pbuf[i], pbuf[i+1])) { |
|---|
| 546 | posx+=p_print_ch(posx, y, (pbuf[i]<<8)|pbuf[++i], color, TRUE); |
|---|
| 547 | } |
|---|
| 548 | else { |
|---|
| 549 | posx+=p_print_ch(posx, y, pbuf[i], color, FALSE); |
|---|
| 550 | } |
|---|
| 551 | |
|---|
| 552 | } |
|---|
| 553 | |
|---|
| 554 | return posx; |
|---|
| 555 | } |
|---|
| 556 | |
|---|
| 557 | |
|---|
| 558 | static int p_print_ustr(int x, int y, UINT16 *pstr, int num, UINT32 color) |
|---|
| 559 | { |
|---|
| 560 | int i, posx; |
|---|
| 561 | |
|---|
| 562 | for(i=0, posx=x; pstr[i] && ((num<0) || (i<num)); i++) |
|---|
| 563 | posx+=p_print_ch(posx, y, pstr[i], color, !p_font_attr.is_unicode); |
|---|
| 564 | |
|---|
| 565 | return posx; |
|---|
| 566 | } |
|---|
| 567 | |
|---|
| 568 | |
|---|
| 569 | static int p_compute_str_rows(char *pstr, int box_w, tPRIV_RowInfo *row_info) |
|---|
| 570 | { |
|---|
| 571 | int i, j; |
|---|
| 572 | int str_w; |
|---|
| 573 | int ch_w; |
|---|
| 574 | int num_line=0; |
|---|
| 575 | UINT8 *pbuf=(UINT8 *)pstr; |
|---|
| 576 | BOOL bcr=FALSE; //carriage return |
|---|
| 577 | |
|---|
| 578 | row_info[num_line].idx=0; |
|---|
| 579 | |
|---|
| 580 | for(i=0, str_w=0; pbuf[i] && num_line<MAX_NUM_DRAW_ROW; i++) { |
|---|
| 581 | BOOL bwansung=FALSE; |
|---|
| 582 | bcr=FALSE; |
|---|
| 583 | |
|---|
| 584 | if(p_is_wansung(pbuf[i], pbuf[i+1])) { |
|---|
| 585 | ch_w=p_get_ch_width((pbuf[i]<<8)|pbuf[++i], TRUE); |
|---|
| 586 | bwansung=TRUE; |
|---|
| 587 | } |
|---|
| 588 | else if(pbuf[i]==0xa || pbuf[i]==0xd) { |
|---|
| 589 | bcr=TRUE; |
|---|
| 590 | } |
|---|
| 591 | else { |
|---|
| 592 | ch_w=p_get_ch_width(pbuf[i], FALSE); |
|---|
| 593 | } |
|---|
| 594 | |
|---|
| 595 | if(bcr) { //carriage returnÀ̱⠶§¹®¿¡ ¹Ù·Î ÁٹٲÞÇÔ. |
|---|
| 596 | row_info[num_line].len=i-row_info[num_line].idx; |
|---|
| 597 | row_info[num_line].width=str_w; |
|---|
| 598 | row_info[num_line+1].idx=row_info[num_line].idx+row_info[num_line].len+1; |
|---|
| 599 | |
|---|
| 600 | str_w=0; |
|---|
| 601 | num_line++; |
|---|
| 602 | } |
|---|
| 603 | else if(str_w+ch_w<=box_w && !bcr) { |
|---|
| 604 | str_w+=ch_w; |
|---|
| 605 | } |
|---|
| 606 | else {/*ÁÙ¹Ù²Þ ÇÊ¿ä*/ |
|---|
| 607 | int twidth=str_w; /* wordwrap¸¦ ÇÒ ¼ö ¾ø´Â °æ¿ì twidth¸¦ »ç¿ëÇÔ */ |
|---|
| 608 | BOOL bfound=FALSE; |
|---|
| 609 | |
|---|
| 610 | /* word wrapÀ» Áö¿øÇÒ·Á¸é..*/ |
|---|
| 611 | /* Ư¼ö ¹®ÀÚ, ¼ýÀÚ, °ø¹éÀ» ãÀ½ */ |
|---|
| 612 | |
|---|
| 613 | if(bwansung) i--; |
|---|
| 614 | |
|---|
| 615 | for(j=i-1; j>=row_info[num_line].idx; j--) { |
|---|
| 616 | if(j>row_info[num_line].idx && p_is_wansung(pbuf[j-1], pbuf[j])) { |
|---|
| 617 | if(j<i) { |
|---|
| 618 | str_w-=p_get_ch_width((pbuf[j-1]<<8)|pbuf[j], FALSE); |
|---|
| 619 | } |
|---|
| 620 | j--; |
|---|
| 621 | continue; |
|---|
| 622 | } |
|---|
| 623 | else if(p_is_alphabet(pbuf[j])) { |
|---|
| 624 | if(j<i) str_w-=p_get_ch_width(pbuf[j], TRUE); |
|---|
| 625 | continue; |
|---|
| 626 | } |
|---|
| 627 | |
|---|
| 628 | j++; |
|---|
| 629 | row_info[num_line].len=j-row_info[num_line].idx; |
|---|
| 630 | row_info[num_line].width=str_w; |
|---|
| 631 | |
|---|
| 632 | row_info[num_line+1].idx=row_info[num_line].idx+row_info[num_line].len; |
|---|
| 633 | |
|---|
| 634 | i=j; |
|---|
| 635 | str_w=0; |
|---|
| 636 | num_line++; |
|---|
| 637 | bfound=TRUE; |
|---|
| 638 | break; |
|---|
| 639 | } |
|---|
| 640 | |
|---|
| 641 | if(!bfound) {/*¾ÕÂÊ ¸ðµÎ°¡ ¾ËÆÄºªÀÓ --> word wrap Àû¿ë ¾ÈÇÔ*/ |
|---|
| 642 | //ÇöÀç °ÍÀº »èÁ¦ÇØ¾ß ÇÔ. |
|---|
| 643 | //row_info[num_line].len=(i-1)-row_info[num_line].idx; |
|---|
| 644 | row_info[num_line].len=i-row_info[num_line].idx; |
|---|
| 645 | row_info[num_line].width=twidth; |
|---|
| 646 | row_info[num_line+1].idx=row_info[num_line].idx+row_info[num_line].len; |
|---|
| 647 | |
|---|
| 648 | str_w=0; |
|---|
| 649 | num_line++; |
|---|
| 650 | } |
|---|
| 651 | } |
|---|
| 652 | } |
|---|
| 653 | |
|---|
| 654 | if(num_line==MAX_NUM_DRAW_ROW) |
|---|
| 655 | return num_line; |
|---|
| 656 | |
|---|
| 657 | row_info[num_line].len=i-row_info[num_line].idx; |
|---|
| 658 | row_info[num_line].width=str_w; |
|---|
| 659 | |
|---|
| 660 | return num_line+1; |
|---|
| 661 | } |
|---|
| 662 | |
|---|
| 663 | |
|---|
| 664 | static int p_compute_ustr_rows(UINT16 *pstr, int box_w, tPRIV_RowInfo *row_info) |
|---|
| 665 | { |
|---|
| 666 | int i, j; |
|---|
| 667 | int str_w; |
|---|
| 668 | int ch_w; |
|---|
| 669 | int num_line=0; |
|---|
| 670 | UINT16 *pbuf=(UINT16 *)pstr; |
|---|
| 671 | BOOL bcr=FALSE; //carriage return |
|---|
| 672 | |
|---|
| 673 | row_info[num_line].idx=0; |
|---|
| 674 | |
|---|
| 675 | for(i=0, str_w=0; pbuf[i] && num_line<MAX_NUM_DRAW_ROW; i++) { |
|---|
| 676 | |
|---|
| 677 | bcr=FALSE; |
|---|
| 678 | |
|---|
| 679 | if(pbuf[i]==0xa || pbuf[i]==0xd) { |
|---|
| 680 | bcr=TRUE; |
|---|
| 681 | } |
|---|
| 682 | else { |
|---|
| 683 | ch_w=p_get_ch_width(pbuf[i], !p_font_attr.is_unicode); |
|---|
| 684 | } |
|---|
| 685 | |
|---|
| 686 | if(bcr) { |
|---|
| 687 | row_info[num_line].len=i-row_info[num_line].idx; |
|---|
| 688 | row_info[num_line].width=str_w; |
|---|
| 689 | row_info[num_line+1].idx=row_info[num_line].idx+row_info[num_line].len+1; |
|---|
| 690 | |
|---|
| 691 | str_w=0; |
|---|
| 692 | num_line++; |
|---|
| 693 | } |
|---|
| 694 | else if(str_w+ch_w<=box_w && !bcr) { |
|---|
| 695 | str_w+=ch_w; |
|---|
| 696 | } |
|---|
| 697 | else {/*ÁÙ¹Ù²Þ ÇÊ¿ä*/ |
|---|
| 698 | int twidth=str_w; /* wordwrap¸¦ ÇÒ ¼ö ¾ø´Â °æ¿ì twidth¸¦ »ç¿ëÇÔ */ |
|---|
| 699 | BOOL bfound=FALSE; |
|---|
| 700 | |
|---|
| 701 | /* word wrapÀ» Áö¿øÇÒ·Á¸é..*/ |
|---|
| 702 | /* Ư¼ö ¹®ÀÚ, ¼ýÀÚ, °ø¹éÀ» ãÀ½ */ |
|---|
| 703 | for(j=i-1; j>=row_info[num_line].idx; j--) { |
|---|
| 704 | |
|---|
| 705 | if(p_is_alphabet(pbuf[j])) { |
|---|
| 706 | if(j<i) str_w-=p_get_ch_width(pbuf[j], TRUE); |
|---|
| 707 | continue; |
|---|
| 708 | } |
|---|
| 709 | |
|---|
| 710 | j++; |
|---|
| 711 | row_info[num_line].len=j-row_info[num_line].idx; |
|---|
| 712 | row_info[num_line].width=str_w; |
|---|
| 713 | |
|---|
| 714 | row_info[num_line+1].idx=row_info[num_line].idx+row_info[num_line].len; |
|---|
| 715 | |
|---|
| 716 | i=j - 1; |
|---|
| 717 | str_w=0; |
|---|
| 718 | num_line++; |
|---|
| 719 | bfound=TRUE; |
|---|
| 720 | break; |
|---|
| 721 | } |
|---|
| 722 | |
|---|
| 723 | if(!bfound) {/*¾ÕÂÊ ¸ðµÎ°¡ ¾ËÆÄºªÀÓ --> word wrap Àû¿ë ¾ÈÇÔ*/ |
|---|
| 724 | //ÇöÀç °ÍÀº »èÁ¦ÇØ¾ß ÇÔ. |
|---|
| 725 | //row_info[num_line].len=(i-1)-row_info[num_line].idx; |
|---|
| 726 | row_info[num_line].len=i-row_info[num_line].idx; |
|---|
| 727 | row_info[num_line].width=twidth; |
|---|
| 728 | row_info[num_line+1].idx=row_info[num_line].idx+row_info[num_line].len; |
|---|
| 729 | i--; |
|---|
| 730 | |
|---|
| 731 | str_w=0; |
|---|
| 732 | num_line++; |
|---|
| 733 | } |
|---|
| 734 | } |
|---|
| 735 | } |
|---|
| 736 | |
|---|
| 737 | if(num_line==MAX_NUM_DRAW_ROW) |
|---|
| 738 | return num_line; |
|---|
| 739 | |
|---|
| 740 | row_info[num_line].len=i-row_info[num_line].idx; |
|---|
| 741 | row_info[num_line].width=str_w; |
|---|
| 742 | |
|---|
| 743 | return num_line+1; |
|---|
| 744 | } |
|---|
| 745 | |
|---|
| 746 | |
|---|
| 747 | static int p_print_row_ex(int x, int y, int w, char *pstr, |
|---|
| 748 | int num, UINT32 color, UINT32 opt, int strw) |
|---|
| 749 | { |
|---|
| 750 | int startx; |
|---|
| 751 | |
|---|
| 752 | if(opt&DMG_OPT_A_CT) |
|---|
| 753 | startx=x+(w-strw)/2; |
|---|
| 754 | else if(opt&DMG_OPT_A_RT) |
|---|
| 755 | startx=x+(w-strw); |
|---|
| 756 | else |
|---|
| 757 | startx=x; |
|---|
| 758 | |
|---|
| 759 | return p_print_str(startx, y, pstr, num, color); |
|---|
| 760 | } |
|---|
| 761 | |
|---|
| 762 | |
|---|
| 763 | static int p_uprint_row_ex(int x, int y, int w, UINT16 *pstr, |
|---|
| 764 | int num, UINT32 color, UINT32 opt, int strw) |
|---|
| 765 | { |
|---|
| 766 | int startx, starty; |
|---|
| 767 | |
|---|
| 768 | if(opt&DMG_OPT_A_CT) |
|---|
| 769 | startx=x+(w-strw)/2; |
|---|
| 770 | else if(opt&DMG_OPT_A_RT) |
|---|
| 771 | startx=x+(w-strw); |
|---|
| 772 | else |
|---|
| 773 | startx=x; |
|---|
| 774 | |
|---|
| 775 | return p_print_ustr(startx, y, pstr, num, color); |
|---|
| 776 | } |
|---|
| 777 | |
|---|
| 778 | |
|---|
| 779 | |
|---|
| 780 | |
|---|
| 781 | /* apis */ |
|---|
| 782 | #if COMMENT |
|---|
| 783 | ______________() {} |
|---|
| 784 | #endif |
|---|
| 785 | |
|---|
| 786 | |
|---|
| 787 | int DMG_PrintCh(int x, int y, UINT16 ch, UINT32 color) |
|---|
| 788 | { |
|---|
| 789 | return p_print_ch(x, y, ch, color, FALSE); |
|---|
| 790 | } |
|---|
| 791 | |
|---|
| 792 | |
|---|
| 793 | int DMG_PrintStr(int x, int y, char *pstr, UINT32 color) |
|---|
| 794 | { |
|---|
| 795 | int width; |
|---|
| 796 | |
|---|
| 797 | if(!pstr) return 0; |
|---|
| 798 | |
|---|
| 799 | p_lock(TRUE); |
|---|
| 800 | |
|---|
| 801 | p_convert_hex_ch(pstr); |
|---|
| 802 | width=p_print_str(x, y, pstr, -1, p_convert_color(color)); |
|---|
| 803 | |
|---|
| 804 | p_lock(FALSE); |
|---|
| 805 | |
|---|
| 806 | return width; |
|---|
| 807 | } |
|---|
| 808 | |
|---|
| 809 | |
|---|
| 810 | void DMG_PrintStrEx(int x, int y, int w, int h, |
|---|
| 811 | char *pstr, UINT32 color, UINT32 opt) |
|---|
| 812 | { |
|---|
| 813 | int i; |
|---|
| 814 | int starty, strh; |
|---|
| 815 | int num_rows; |
|---|
| 816 | tPRIV_RowInfo row_info[MAX_NUM_DRAW_ROW]; |
|---|
| 817 | int dot_width=0; |
|---|
| 818 | UINT8 *pbuf=(UINT8 *)pstr; |
|---|
| 819 | |
|---|
| 820 | if(!pstr) return; |
|---|
| 821 | |
|---|
| 822 | if(w<DMG_GetStrWidth(pstr) && w<DMG_GetStrWidth("...")) return; |
|---|
| 823 | |
|---|
| 824 | if(h<p_font_attr.size+2) { |
|---|
| 825 | h=p_font_attr.size+2; //h°¡ ÃÖ¼ÒÇÑ font size+2 º¸´Ù Å©°Ô ¸¸µç´Ù. |
|---|
| 826 | } |
|---|
| 827 | |
|---|
| 828 | color=p_convert_color(color); |
|---|
| 829 | |
|---|
| 830 | p_convert_hex_ch(pstr); |
|---|
| 831 | |
|---|
| 832 | strh=DMG_GetStrHeight(pstr); |
|---|
| 833 | |
|---|
| 834 | num_rows=p_compute_str_rows(pstr, w, row_info); |
|---|
| 835 | |
|---|
| 836 | if(num_rows*strh+(num_rows-1)*p_inter_line_gap>h) { /*stringÀÌ ÁÖ¾îÁø boxÀÇ ¿µ¿ªÀ» ¹þ¾î³²*/ |
|---|
| 837 | dot_width=DMG_GetStrWidth("..."); |
|---|
| 838 | |
|---|
| 839 | num_rows=(h+p_inter_line_gap)/(strh+p_inter_line_gap); |
|---|
| 840 | |
|---|
| 841 | while(w-row_info[num_rows-1].width<dot_width) { |
|---|
| 842 | int str_idx=row_info[num_rows-1].idx+row_info[num_rows-1].len-1; |
|---|
| 843 | |
|---|
| 844 | if(p_is_wansung(pbuf[str_idx-1], pbuf[str_idx])) { |
|---|
| 845 | row_info[num_rows-1].width-= |
|---|
| 846 | p_get_ch_width((pbuf[str_idx-1]<<8)|pbuf[str_idx], TRUE); |
|---|
| 847 | row_info[num_rows-1].len-=2; |
|---|
| 848 | } |
|---|
| 849 | else { |
|---|
| 850 | row_info[num_rows-1].width-=p_get_ch_width(pbuf[str_idx], FALSE); |
|---|
| 851 | row_info[num_rows-1].len--; |
|---|
| 852 | } |
|---|
| 853 | |
|---|
| 854 | if(row_info[num_rows-1].len==0) break; |
|---|
| 855 | } |
|---|
| 856 | |
|---|
| 857 | row_info[num_rows-1].width+=dot_width; |
|---|
| 858 | } |
|---|
| 859 | |
|---|
| 860 | if(opt&DMG_OPT_A_TP) |
|---|
| 861 | starty=y; |
|---|
| 862 | else if(opt&DMG_OPT_A_BT) |
|---|
| 863 | starty=y+(h-(strh*num_rows+p_inter_line_gap*(num_rows-1))); |
|---|
| 864 | else |
|---|
| 865 | starty=y+(h-(strh*num_rows+p_inter_line_gap*(num_rows-1)))/2; |
|---|
| 866 | |
|---|
| 867 | p_lock(TRUE); |
|---|
| 868 | |
|---|
| 869 | for(i=0; i<num_rows; i++) { |
|---|
| 870 | |
|---|
| 871 | if(dot_width>0 && i==num_rows-1) { |
|---|
| 872 | |
|---|
| 873 | char temp[256]; |
|---|
| 874 | |
|---|
| 875 | if(row_info[i].len>=250) { |
|---|
| 876 | dprint(0, "!! warning : character nums in row is over 250\n"); |
|---|
| 877 | return; |
|---|
| 878 | } |
|---|
| 879 | |
|---|
| 880 | strncpy(temp, &pstr[row_info[i].idx], row_info[i].len); |
|---|
| 881 | temp[row_info[i].len]='\0'; |
|---|
| 882 | |
|---|
| 883 | strcat(temp, "..."); |
|---|
| 884 | |
|---|
| 885 | row_info[i].len+=3; |
|---|
| 886 | |
|---|
| 887 | p_print_row_ex(x, starty+i*(strh+p_inter_line_gap), w, temp, row_info[i].len, |
|---|
| 888 | color, opt, row_info[i].width); |
|---|
| 889 | |
|---|
| 890 | } |
|---|
| 891 | else { |
|---|
| 892 | p_print_row_ex(x, starty+i*(strh+p_inter_line_gap), w, &pstr[row_info[i].idx], row_info[i].len, |
|---|
| 893 | color, opt, row_info[i].width); |
|---|
| 894 | } |
|---|
| 895 | |
|---|
| 896 | } |
|---|
| 897 | |
|---|
| 898 | p_lock(FALSE); |
|---|
| 899 | } |
|---|
| 900 | |
|---|
| 901 | |
|---|
| 902 | |
|---|
| 903 | |
|---|
| 904 | int DMG_PrintStr3Lang(int x, int y, |
|---|
| 905 | char *pstr1, char *pstr2, char *pstr3, UINT32 color) |
|---|
| 906 | { |
|---|
| 907 | char *pprint_str=eDMG_LANG_ENG; |
|---|
| 908 | int width; |
|---|
| 909 | |
|---|
| 910 | p_lock(TRUE); |
|---|
| 911 | |
|---|
| 912 | if(p_lang==eDMG_LANG_ENG) pprint_str=pstr1; |
|---|
| 913 | else if(p_lang==eDMG_LANG_SPA) pprint_str=pstr2; |
|---|
| 914 | else if(p_lang==eDMG_LANG_FRE) pprint_str=pstr3; |
|---|
| 915 | |
|---|
| 916 | if(!pprint_str) pprint_str=pstr1; |
|---|
| 917 | |
|---|
| 918 | if(!pprint_str) return 0; |
|---|
| 919 | |
|---|
| 920 | p_convert_hex_ch(pprint_str); |
|---|
| 921 | |
|---|
| 922 | width=p_print_str(x, y, pprint_str, -1, p_convert_color(color)); |
|---|
| 923 | |
|---|
| 924 | p_lock(FALSE); |
|---|
| 925 | |
|---|
| 926 | return width; |
|---|
| 927 | } |
|---|
| 928 | |
|---|
| 929 | |
|---|
| 930 | void DMG_PrintStrEx3Lang(int x, int y, int w, int h, |
|---|
| 931 | char *pstr1, char *pstr2, char *pstr3, UINT32 color, UINT32 opt) |
|---|
| 932 | { |
|---|
| 933 | char *pprint_str=eDMG_LANG_ENG; |
|---|
| 934 | |
|---|
| 935 | p_lock(TRUE); |
|---|
| 936 | |
|---|
| 937 | if(p_lang==eDMG_LANG_ENG) pprint_str=pstr1; |
|---|
| 938 | else if(p_lang==eDMG_LANG_SPA) pprint_str=pstr2; |
|---|
| 939 | else if(p_lang==eDMG_LANG_FRE) pprint_str=pstr3; |
|---|
| 940 | |
|---|
| 941 | if(!pprint_str) pprint_str=pstr1; |
|---|
| 942 | |
|---|
| 943 | if(!pprint_str) return; |
|---|
| 944 | |
|---|
| 945 | DMG_PrintStrEx(x, y, w, h, pprint_str, p_convert_color(color), opt); |
|---|
| 946 | |
|---|
| 947 | p_lock(FALSE); |
|---|
| 948 | } |
|---|
| 949 | |
|---|
| 950 | |
|---|
| 951 | |
|---|
| 952 | int DMG_PrintUStr(int x, int y, UINT16 *pstr, UINT32 color) |
|---|
| 953 | { |
|---|
| 954 | int i, posx; |
|---|
| 955 | |
|---|
| 956 | if(!pstr) return 0; |
|---|
| 957 | |
|---|
| 958 | color=p_convert_color(color); |
|---|
| 959 | |
|---|
| 960 | p_lock(TRUE); |
|---|
| 961 | |
|---|
| 962 | for(i=0, posx=x; pstr[i]; i++) |
|---|
| 963 | posx+=p_print_ch(posx, y, pstr[i], color, !p_font_attr.is_unicode); |
|---|
| 964 | |
|---|
| 965 | p_lock(FALSE); |
|---|
| 966 | |
|---|
| 967 | return posx; |
|---|
| 968 | } |
|---|
| 969 | |
|---|
| 970 | void DMG_PrintUStrEx(int x, int y, int w, int h, |
|---|
| 971 | UINT16 *pstr, UINT32 color, UINT32 opt) |
|---|
| 972 | { |
|---|
| 973 | int i; |
|---|
| 974 | int starty, strh; |
|---|
| 975 | int num_rows, total_num_rows; |
|---|
| 976 | tPRIV_RowInfo row_info[MAX_NUM_DRAW_ROW]; |
|---|
| 977 | int dot_width=0; |
|---|
| 978 | |
|---|
| 979 | if(!pstr) return; |
|---|
| 980 | |
|---|
| 981 | if(w<DMG_GetUStrWidth(pstr) && w<DMG_GetStrWidth("...")) return; |
|---|
| 982 | |
|---|
| 983 | if(h<p_font_attr.size+2) { |
|---|
| 984 | h=p_font_attr.size+2; //h°¡ ÃÖ¼ÒÇÑ font size+2 º¸´Ù Å©°Ô ¸¸µç´Ù. |
|---|
| 985 | } |
|---|
| 986 | |
|---|
| 987 | color=p_convert_color(color); |
|---|
| 988 | |
|---|
| 989 | strh=DMG_GetUStrHeight(pstr); |
|---|
| 990 | |
|---|
| 991 | num_rows=p_compute_ustr_rows(pstr, w, row_info); |
|---|
| 992 | total_num_rows = num_rows; |
|---|
| 993 | |
|---|
| 994 | if(num_rows*strh+(num_rows-1)*p_inter_line_gap>h) { /*stringÀÌ ÁÖ¾îÁø boxÀÇ ¿µ¿ªÀ» ¹þ¾î³²*/ |
|---|
| 995 | dot_width=DMG_GetStrWidth("..."); |
|---|
| 996 | |
|---|
| 997 | num_rows=(h+p_inter_line_gap)/(strh+p_inter_line_gap); |
|---|
| 998 | |
|---|
| 999 | while(w-row_info[num_rows-1].width<dot_width) { |
|---|
| 1000 | row_info[num_rows-1].width-= |
|---|
| 1001 | p_get_ch_width(pstr[row_info[num_rows-1].idx+row_info[num_rows-1].len-1], |
|---|
| 1002 | !p_font_attr.is_unicode); |
|---|
| 1003 | |
|---|
| 1004 | if(--row_info[num_rows-1].len<=0) break; |
|---|
| 1005 | } |
|---|
| 1006 | |
|---|
| 1007 | row_info[num_rows-1].width+=dot_width; |
|---|
| 1008 | |
|---|
| 1009 | if(total_num_rows > num_rows) |
|---|
| 1010 | { |
|---|
| 1011 | int ch_w, tmp_i; |
|---|
| 1012 | |
|---|
| 1013 | for(tmp_i = 0 ; tmp_i < row_info[num_rows].len ; tmp_i++) |
|---|
| 1014 | { |
|---|
| 1015 | ch_w=p_get_ch_width(pstr[row_info[num_rows].idx + tmp_i], !p_font_attr.is_unicode); |
|---|
| 1016 | if(row_info[num_rows-1].width + ch_w > w) |
|---|
| 1017 | { |
|---|
| 1018 | break; |
|---|
| 1019 | } |
|---|
| 1020 | |
|---|
| 1021 | row_info[num_rows-1].width += ch_w; |
|---|
| 1022 | row_info[num_rows-1].len += 1; |
|---|
| 1023 | } |
|---|
| 1024 | } |
|---|
| 1025 | } |
|---|
| 1026 | |
|---|
| 1027 | if(opt&DMG_OPT_A_TP) |
|---|
| 1028 | starty=y; |
|---|
| 1029 | else if(opt&DMG_OPT_A_BT) |
|---|
| 1030 | starty=y+(h-(strh*num_rows+p_inter_line_gap*(num_rows-1))); |
|---|
| 1031 | else |
|---|
| 1032 | starty=y+(h-(strh*num_rows+p_inter_line_gap*(num_rows-1)))/2; |
|---|
| 1033 | |
|---|
| 1034 | p_lock(TRUE); |
|---|
| 1035 | |
|---|
| 1036 | for(i=0; i<num_rows; i++) { |
|---|
| 1037 | |
|---|
| 1038 | if(dot_width>0 && i==num_rows-1) { |
|---|
| 1039 | |
|---|
| 1040 | UINT16 temp[256]; |
|---|
| 1041 | |
|---|
| 1042 | if(row_info[i].len>=250) { |
|---|
| 1043 | dprint(0, "!! warning : character nums in row is over 250\n"); |
|---|
| 1044 | break; |
|---|
| 1045 | } |
|---|
| 1046 | |
|---|
| 1047 | DMG_UStrNCpy(temp, &pstr[row_info[i].idx], row_info[i].len); |
|---|
| 1048 | temp[row_info[i].len]='\0'; |
|---|
| 1049 | |
|---|
| 1050 | DMG_UStrCat(temp, DMG_MakeUniStr2("...")); |
|---|
| 1051 | |
|---|
| 1052 | row_info[i].len+=3; |
|---|
| 1053 | p_uprint_row_ex(x, starty+i*(strh+p_inter_line_gap), w, temp, row_info[i].len, |
|---|
| 1054 | color, opt, DMG_GetUStrWidth(temp)); |
|---|
| 1055 | |
|---|
| 1056 | } |
|---|
| 1057 | else { |
|---|
| 1058 | p_uprint_row_ex(x, starty+i*(strh+p_inter_line_gap), w, &pstr[row_info[i].idx], |
|---|
| 1059 | row_info[i].len, color, opt, row_info[i].width); |
|---|
| 1060 | } |
|---|
| 1061 | } |
|---|
| 1062 | |
|---|
| 1063 | p_lock(FALSE); |
|---|
| 1064 | |
|---|
| 1065 | } |
|---|
| 1066 | |
|---|
| 1067 | |
|---|
| 1068 | void DMG_PrintNUStrEx(int x, int y, int w, int h, |
|---|
| 1069 | int str_start, int str_len, |
|---|
| 1070 | UINT16* pstr, UINT32 color, UINT32 opt) |
|---|
| 1071 | { |
|---|
| 1072 | UINT16 str[500]; |
|---|
| 1073 | int i; |
|---|
| 1074 | |
|---|
| 1075 | if(!pstr || str_start < 0) return; |
|---|
| 1076 | |
|---|
| 1077 | for(i = 0 ; i < str_len ; i++) |
|---|
| 1078 | { |
|---|
| 1079 | str[i] = pstr[str_start + i]; |
|---|
| 1080 | } |
|---|
| 1081 | |
|---|
| 1082 | str[str_len] = '\0'; |
|---|
| 1083 | |
|---|
| 1084 | DMG_PrintUStrEx(x, y, w, h, str, color, opt); |
|---|
| 1085 | } |
|---|
| 1086 | |
|---|
| 1087 | |
|---|
| 1088 | |
|---|
| 1089 | int DMG_GetChWidth(UINT16 ch) |
|---|
| 1090 | { |
|---|
| 1091 | return p_get_ch_width(ch, !p_font_attr.is_unicode); |
|---|
| 1092 | } |
|---|
| 1093 | |
|---|
| 1094 | |
|---|
| 1095 | |
|---|
| 1096 | int DMG_GetStrWidth(char *pstr) |
|---|
| 1097 | { |
|---|
| 1098 | if(!pstr) return 0; |
|---|
| 1099 | |
|---|
| 1100 | p_convert_hex_ch(pstr); |
|---|
| 1101 | return p_get_str_width(pstr, -1); |
|---|
| 1102 | } |
|---|
| 1103 | |
|---|
| 1104 | |
|---|
| 1105 | |
|---|
| 1106 | int DMG_GetUStrWidth(UINT16 *pstr) |
|---|
| 1107 | { |
|---|
| 1108 | if(!pstr) return 0; |
|---|
| 1109 | |
|---|
| 1110 | return p_get_ustr_width(pstr, -1); |
|---|
| 1111 | } |
|---|
| 1112 | |
|---|
| 1113 | |
|---|
| 1114 | int DMG_GetChHeight(UINT16 ch) |
|---|
| 1115 | { |
|---|
| 1116 | int ret_val=0; |
|---|
| 1117 | |
|---|
| 1118 | if(p_font==eDMG_FONT_JUNGLE) { |
|---|
| 1119 | #if SUPPORT_JUNGLE |
|---|
| 1120 | ret_val=Jungle_GetChHeight(ch); |
|---|
| 1121 | #else |
|---|
| 1122 | dprint(0, "!! %s : jungle is not spported\n"); |
|---|
| 1123 | #endif |
|---|
| 1124 | } |
|---|
| 1125 | else if(p_font==eDMG_FONT_BMF) { |
|---|
| 1126 | #if SUPPORT_BMF |
|---|
| 1127 | ret_val=BMF_GetChHeight(ch); |
|---|
| 1128 | #else |
|---|
| 1129 | dprint(0, "!! %s : jungle is not spported\n"); |
|---|
| 1130 | #endif |
|---|
| 1131 | } |
|---|
| 1132 | else if(p_font>=eDMG_FONT_DHL && p_font<=eDMG_FONT_DHL_END) { |
|---|
| 1133 | #if USE_DHL_FONT |
|---|
| 1134 | ret_val=DHL_GetChHeight(ch); |
|---|
| 1135 | #else |
|---|
| 1136 | dprint(0, "!! %s : DHL Font is not supported\n", __FUNCTION__); |
|---|
| 1137 | #endif |
|---|
| 1138 | } |
|---|
| 1139 | |
|---|
| 1140 | #if USE_KOR_AUTO_CHANGE && USE_DHL_FONT |
|---|
| 1141 | if(ret_val==0) { /* ÆùÆ® º¯°æÀ» ½ÃµµÇÑ´Ù */ |
|---|
| 1142 | int temp=p_font; |
|---|
| 1143 | |
|---|
| 1144 | DMG_SetFont(DEF_KOR_FONT); |
|---|
| 1145 | ret_val=DHL_GetChHeight(ch); |
|---|
| 1146 | DMG_SetFont(temp); |
|---|
| 1147 | } |
|---|
| 1148 | #endif |
|---|
| 1149 | |
|---|
| 1150 | return ret_val; |
|---|
| 1151 | } |
|---|
| 1152 | |
|---|
| 1153 | |
|---|
| 1154 | int DMG_GetStrHeight(char *pstr) |
|---|
| 1155 | { |
|---|
| 1156 | int i; |
|---|
| 1157 | int height=0, temp; |
|---|
| 1158 | |
|---|
| 1159 | if(!pstr) return 0; |
|---|
| 1160 | |
|---|
| 1161 | p_convert_hex_ch(pstr); |
|---|
| 1162 | |
|---|
| 1163 | for(i=0; pstr[i]; i++) { |
|---|
| 1164 | temp=DMG_GetChHeight(pstr[i]); |
|---|
| 1165 | if(temp>height) height=temp; |
|---|
| 1166 | } |
|---|
| 1167 | |
|---|
| 1168 | return height; |
|---|
| 1169 | } |
|---|
| 1170 | |
|---|
| 1171 | |
|---|
| 1172 | int DMG_GetUStrHeight(UINT16 *pstr) |
|---|
| 1173 | { |
|---|
| 1174 | int i; |
|---|
| 1175 | int height=0, temp; |
|---|
| 1176 | |
|---|
| 1177 | if(!pstr) return 0; |
|---|
| 1178 | |
|---|
| 1179 | for(i=0; pstr[i]; i++) { |
|---|
| 1180 | temp=DMG_GetChHeight(pstr[i]); |
|---|
| 1181 | if(temp>height) height=temp; |
|---|
| 1182 | } |
|---|
| 1183 | |
|---|
| 1184 | return height; |
|---|
| 1185 | } |
|---|
| 1186 | |
|---|
| 1187 | |
|---|
| 1188 | void DMG_GetDefaultFontAttr(tDMG_FontAttr *pfont_attr) |
|---|
| 1189 | { |
|---|
| 1190 | if(!pfont_attr) { |
|---|
| 1191 | dprint(0, "!! %s : font_attr is NULL\n", __FUNCTION__); |
|---|
| 1192 | return; |
|---|
| 1193 | } |
|---|
| 1194 | |
|---|
| 1195 | pfont_attr->size=DEFAULT_FONT_SIZE; |
|---|
| 1196 | pfont_attr->is_bold=FALSE; |
|---|
| 1197 | pfont_attr->is_italic=FALSE; |
|---|
| 1198 | pfont_attr->is_underline=FALSE; |
|---|
| 1199 | pfont_attr->is_unicode=TRUE; |
|---|
| 1200 | pfont_attr->font_style=eDMG_FS_SANSERIF; |
|---|
| 1201 | pfont_attr->edge_type=eDMG_ET_NONE; |
|---|
| 1202 | } |
|---|
| 1203 | |
|---|
| 1204 | |
|---|
| 1205 | void DMG_GetFontAttr(tDMG_FontAttr *pfont_attr) |
|---|
| 1206 | { |
|---|
| 1207 | if(p_font==eDMG_FONT_NONE) { |
|---|
| 1208 | DMG_GetDefaultFontAttr(pfont_attr); |
|---|
| 1209 | } |
|---|
| 1210 | else { |
|---|
| 1211 | *pfont_attr=p_font_attr; |
|---|
| 1212 | } |
|---|
| 1213 | } |
|---|
| 1214 | |
|---|
| 1215 | |
|---|
| 1216 | void DMG_SetFontAttr(tDMG_FontAttr *pfont_attr) |
|---|
| 1217 | { |
|---|
| 1218 | p_lock(TRUE); |
|---|
| 1219 | |
|---|
| 1220 | p_font_attr=*pfont_attr; |
|---|
| 1221 | |
|---|
| 1222 | if(p_font==eDMG_FONT_JUNGLE) { |
|---|
| 1223 | #if SUPPORT_JUNGLE |
|---|
| 1224 | Jungle_FontAttr attr; |
|---|
| 1225 | |
|---|
| 1226 | attr.size=pfont_attr->size; |
|---|
| 1227 | attr.is_bold=pfont_attr->is_bold; |
|---|
| 1228 | attr.is_italic=pfont_attr->is_italic; |
|---|
| 1229 | attr.is_underline=pfont_attr->is_underline; |
|---|
| 1230 | attr.is_unicode=pfont_attr->is_unicode; |
|---|
| 1231 | attr.font_style=pfont_attr->font_style; |
|---|
| 1232 | attr.edge_type=pfont_attr->edge_type; |
|---|
| 1233 | attr.c_edge=pfont_attr->c_edge; |
|---|
| 1234 | |
|---|
| 1235 | Jungle_SetFontAttr(&attr); |
|---|
| 1236 | #else |
|---|
| 1237 | dprint(0, "!! %s : jungle is not spported\n"); |
|---|
| 1238 | #endif |
|---|
| 1239 | |
|---|
| 1240 | } |
|---|
| 1241 | else if(p_font==eDMG_FONT_BMF) { |
|---|
| 1242 | #if SUPPORT_BMF |
|---|
| 1243 | BMF_FontAttr attr; |
|---|
| 1244 | |
|---|
| 1245 | attr.size=pfont_attr->size; |
|---|
| 1246 | attr.is_bold=pfont_attr->is_bold; |
|---|
| 1247 | attr.is_italic=pfont_attr->is_italic; |
|---|
| 1248 | attr.is_underline=pfont_attr->is_underline; |
|---|
| 1249 | attr.is_unicode=pfont_attr->is_unicode; |
|---|
| 1250 | |
|---|
| 1251 | attr.font_style=pfont_attr->font_style; |
|---|
| 1252 | attr.edge_type=pfont_attr->edge_type; |
|---|
| 1253 | attr.c_edge=pfont_attr->c_edge; |
|---|
| 1254 | |
|---|
| 1255 | BMF_SetFontAttr(&attr); |
|---|
| 1256 | #else |
|---|
| 1257 | dprint(0, "!! %s : jungle is not spported\n"); |
|---|
| 1258 | #endif |
|---|
| 1259 | |
|---|
| 1260 | } |
|---|
| 1261 | else if(p_font>=eDMG_FONT_DHL && p_font<=eDMG_FONT_DHL_END) { |
|---|
| 1262 | #if USE_DHL_FONT |
|---|
| 1263 | tDHL_FontAttr attr; |
|---|
| 1264 | |
|---|
| 1265 | attr.type=p_font-eDMG_FONT_DHL; |
|---|
| 1266 | attr.size=pfont_attr->size; |
|---|
| 1267 | attr.is_bold=pfont_attr->is_bold; |
|---|
| 1268 | attr.is_italic=pfont_attr->is_italic; |
|---|
| 1269 | attr.is_underline=pfont_attr->is_underline; |
|---|
| 1270 | |
|---|
| 1271 | DHL_SetFontAttr(&attr); |
|---|
| 1272 | #else |
|---|
| 1273 | dprint(0, "!! %s : only Jungle is supported\n", __FUNCTION__); |
|---|
| 1274 | #endif |
|---|
| 1275 | } |
|---|
| 1276 | |
|---|
| 1277 | p_lock(FALSE); |
|---|
| 1278 | } |
|---|
| 1279 | |
|---|
| 1280 | |
|---|
| 1281 | void DMG_SetFontSize(int size) |
|---|
| 1282 | { |
|---|
| 1283 | tDMG_FontAttr attr; |
|---|
| 1284 | |
|---|
| 1285 | DMG_GetFontAttr(&attr); |
|---|
| 1286 | |
|---|
| 1287 | p_lock(TRUE); |
|---|
| 1288 | |
|---|
| 1289 | attr.size=size; |
|---|
| 1290 | |
|---|
| 1291 | DMG_SetFontAttr(&attr); |
|---|
| 1292 | |
|---|
| 1293 | p_lock(FALSE); |
|---|
| 1294 | } |
|---|
| 1295 | |
|---|
| 1296 | int DMG_GetFontSize() |
|---|
| 1297 | { |
|---|
| 1298 | tDMG_FontAttr attr; |
|---|
| 1299 | |
|---|
| 1300 | DMG_GetFontAttr(&attr); |
|---|
| 1301 | |
|---|
| 1302 | return attr.size; |
|---|
| 1303 | } |
|---|
| 1304 | |
|---|
| 1305 | int DMG_GetUStrLineCount(int w, UINT16 *pstr, DMG_STR_RowInfo_t* return_str_info_t) |
|---|
| 1306 | { |
|---|
| 1307 | int i; |
|---|
| 1308 | int num_rows; // , total_num_rows; |
|---|
| 1309 | tPRIV_RowInfo row_info[MAX_NUM_DRAW_ROW]; |
|---|
| 1310 | |
|---|
| 1311 | if(!pstr) return 0; |
|---|
| 1312 | |
|---|
| 1313 | num_rows=p_compute_ustr_rows(pstr, w, row_info); |
|---|
| 1314 | for(i = 0 ; i < num_rows ; i++) |
|---|
| 1315 | { |
|---|
| 1316 | return_str_info_t[i].idx = row_info[i].idx; |
|---|
| 1317 | return_str_info_t[i].len = row_info[i].len; |
|---|
| 1318 | } |
|---|
| 1319 | |
|---|
| 1320 | return num_rows; |
|---|
| 1321 | } |
|---|
| 1322 | |
|---|
| 1323 | |
|---|
| 1324 | |
|---|
| 1325 | void DMG_SetTempFontSize(int size) |
|---|
| 1326 | { |
|---|
| 1327 | //Àӽ÷Πfont¸¦ »ç¿ëÇÒ ¶§ ÀÌ ÇÔ¼ö¸¦ »ç¿ëÇÔ. |
|---|
| 1328 | if(p_temp_font_size==0) |
|---|
| 1329 | p_temp_font_size=DMG_GetFontSize(); |
|---|
| 1330 | |
|---|
| 1331 | DMG_SetFontSize(size); |
|---|
| 1332 | } |
|---|
| 1333 | |
|---|
| 1334 | void DMG_RestoreFontSize() |
|---|
| 1335 | { |
|---|
| 1336 | if(p_temp_font_size>0) { |
|---|
| 1337 | DMG_SetFontSize(p_temp_font_size); |
|---|
| 1338 | p_temp_font_size=0; |
|---|
| 1339 | } |
|---|
| 1340 | } |
|---|
| 1341 | |
|---|
| 1342 | |
|---|
| 1343 | |
|---|
| 1344 | void DMG_SetLanguage(tDMG_Language lang) |
|---|
| 1345 | { |
|---|
| 1346 | p_lock(TRUE); |
|---|
| 1347 | |
|---|
| 1348 | p_lang=lang; |
|---|
| 1349 | |
|---|
| 1350 | p_lock(FALSE); |
|---|
| 1351 | } |
|---|
| 1352 | |
|---|
| 1353 | |
|---|
| 1354 | int DMG_GetLanguage() |
|---|
| 1355 | { |
|---|
| 1356 | return p_lang; |
|---|
| 1357 | } |
|---|
| 1358 | |
|---|
| 1359 | |
|---|
| 1360 | void DMG_SetFont(tDMG_Font font) |
|---|
| 1361 | { |
|---|
| 1362 | p_lock(TRUE); |
|---|
| 1363 | |
|---|
| 1364 | p_font=font; |
|---|
| 1365 | |
|---|
| 1366 | #if SUPPORT_JUNGLE |
|---|
| 1367 | if(p_font==eDMG_FONT_JUNGLE) { |
|---|
| 1368 | |
|---|
| 1369 | } |
|---|
| 1370 | |
|---|
| 1371 | #endif |
|---|
| 1372 | |
|---|
| 1373 | #if SUPPORT_BMF |
|---|
| 1374 | if(p_font==eDMG_FONT_BMF) { |
|---|
| 1375 | |
|---|
| 1376 | } |
|---|
| 1377 | #endif |
|---|
| 1378 | |
|---|
| 1379 | if(p_font>=eDMG_FONT_DHL && p_font<=eDMG_FONT_DHL_END) { |
|---|
| 1380 | #if USE_DHL_FONT |
|---|
| 1381 | tDHL_FontAttr attr; |
|---|
| 1382 | |
|---|
| 1383 | DHL_GetFontAttr(&attr); |
|---|
| 1384 | |
|---|
| 1385 | attr.type=p_font-eDMG_FONT_DHL; |
|---|
| 1386 | |
|---|
| 1387 | DHL_SetFontAttr(&attr); |
|---|
| 1388 | #else |
|---|
| 1389 | dprint(0, "!! %s : only Jungle is supported\n", __FUNCTION__); |
|---|
| 1390 | #endif |
|---|
| 1391 | |
|---|
| 1392 | } |
|---|
| 1393 | p_lock(FALSE); |
|---|
| 1394 | } |
|---|
| 1395 | |
|---|
| 1396 | |
|---|
| 1397 | void DMG_SetInterLineGap(int gap) |
|---|
| 1398 | { |
|---|
| 1399 | p_lock(TRUE); |
|---|
| 1400 | p_inter_line_gap=gap; |
|---|
| 1401 | p_lock(FALSE); |
|---|
| 1402 | } |
|---|
| 1403 | |
|---|
| 1404 | |
|---|
| 1405 | void DMG_DrawInit() |
|---|
| 1406 | { |
|---|
| 1407 | tDMG_FontAttr font_attr; |
|---|
| 1408 | |
|---|
| 1409 | #if USE_GRP_MTX |
|---|
| 1410 | p_mtx=OS_CreateMutexSemaphore("dmg_mtx"); |
|---|
| 1411 | /* mutex init */ |
|---|
| 1412 | #endif |
|---|
| 1413 | |
|---|
| 1414 | DMG_GetDefaultFontAttr(&font_attr); |
|---|
| 1415 | |
|---|
| 1416 | #if SUPPORT_JUNGLE |
|---|
| 1417 | if(1) { |
|---|
| 1418 | Jungle_FontAttr attr; |
|---|
| 1419 | |
|---|
| 1420 | attr.size=font_attr.size; |
|---|
| 1421 | attr.is_bold=font_attr.is_bold; |
|---|
| 1422 | attr.is_italic=font_attr.is_italic; |
|---|
| 1423 | attr.is_underline=font_attr.is_underline; |
|---|
| 1424 | attr.is_unicode=font_attr.is_unicode; |
|---|
| 1425 | attr.font_style=font_attr.font_style; |
|---|
| 1426 | attr.edge_type=font_attr.edge_type; |
|---|
| 1427 | attr.c_edge=font_attr.c_edge; |
|---|
| 1428 | |
|---|
| 1429 | Jungle_FontInit(&attr); |
|---|
| 1430 | } |
|---|
| 1431 | #endif |
|---|
| 1432 | |
|---|
| 1433 | #if SUPPORT_BMF |
|---|
| 1434 | if(1) { |
|---|
| 1435 | BMF_FontAttr attr; |
|---|
| 1436 | |
|---|
| 1437 | attr.size=font_attr.size; |
|---|
| 1438 | attr.is_bold=font_attr.is_bold; |
|---|
| 1439 | attr.is_italic=font_attr.is_italic; |
|---|
| 1440 | attr.is_underline=font_attr.is_underline; |
|---|
| 1441 | attr.is_unicode=font_attr.is_unicode; |
|---|
| 1442 | attr.font_style=font_attr.font_style; |
|---|
| 1443 | attr.edge_type=font_attr.edge_type; |
|---|
| 1444 | attr.c_edge=font_attr.c_edge; |
|---|
| 1445 | |
|---|
| 1446 | BMF_FontInit(&attr); |
|---|
| 1447 | } |
|---|
| 1448 | #endif |
|---|
| 1449 | |
|---|
| 1450 | #if USE_DHL_FONT |
|---|
| 1451 | if(1) { |
|---|
| 1452 | tDHL_FontAttr attr; |
|---|
| 1453 | |
|---|
| 1454 | attr.type=0; |
|---|
| 1455 | attr.size=font_attr.size; |
|---|
| 1456 | attr.is_bold=font_attr.is_bold; |
|---|
| 1457 | attr.is_italic=font_attr.is_italic; |
|---|
| 1458 | attr.is_underline=font_attr.is_underline; |
|---|
| 1459 | |
|---|
| 1460 | DHL_FontInit(&attr); |
|---|
| 1461 | } |
|---|
| 1462 | #endif |
|---|
| 1463 | |
|---|
| 1464 | #if SUPPORT_BMFONT |
|---|
| 1465 | |
|---|
| 1466 | |
|---|
| 1467 | #endif |
|---|
| 1468 | |
|---|
| 1469 | p_font_attr=font_attr; |
|---|
| 1470 | } |
|---|
| 1471 | |
|---|
| 1472 | |
|---|
| 1473 | |
|---|
| 1474 | |
|---|
| 1475 | |
|---|
| 1476 | |
|---|
| 1477 | #if 0 |
|---|
| 1478 | ___Debug___() {} |
|---|
| 1479 | #endif |
|---|
| 1480 | |
|---|
| 1481 | void pixel_info(int x, int y) |
|---|
| 1482 | { |
|---|
| 1483 | UINT32 color; |
|---|
| 1484 | |
|---|
| 1485 | DHL_GetPixel(0, x, y, &color); |
|---|
| 1486 | |
|---|
| 1487 | printf("------------------------------------\n"); |
|---|
| 1488 | printf("pixel(%d,%d) color : 0x%08x\n", x, y, color); |
|---|
| 1489 | printf("------------------------------------\n"); |
|---|
| 1490 | } |
|---|
| 1491 | |
|---|
| 1492 | void change_fstyle(int style) |
|---|
| 1493 | { |
|---|
| 1494 | tDMG_FontAttr attr; |
|---|
| 1495 | |
|---|
| 1496 | DMG_GetFontAttr(&attr); |
|---|
| 1497 | |
|---|
| 1498 | attr.font_style=(tDMG_FontStyle)style; |
|---|
| 1499 | |
|---|
| 1500 | DMG_SetFontAttr(&attr); |
|---|
| 1501 | } |
|---|
| 1502 | |
|---|
| 1503 | |
|---|
| 1504 | void print_ch(int x, int y, UINT16 ch, UINT32 color) |
|---|
| 1505 | { |
|---|
| 1506 | DMG_PrintCh(x, y, ch, color); |
|---|
| 1507 | DMG_AutoRefresh(); |
|---|
| 1508 | } |
|---|
| 1509 | |
|---|
| 1510 | void print_str(int x, int y, int size, char *pstr, UINT32 color) |
|---|
| 1511 | { |
|---|
| 1512 | DMG_SetFontSize(size); |
|---|
| 1513 | DMG_EraseRect(x, y, 200, 100, 0xff000000); |
|---|
| 1514 | DMG_PrintStr(x, y, pstr, color); |
|---|
| 1515 | DMG_AutoRefresh(); |
|---|
| 1516 | } |
|---|
| 1517 | |
|---|
| 1518 | void print_str_ex(int x, int y, int w, int h, int size, char *pstr) |
|---|
| 1519 | { |
|---|
| 1520 | DMG_SetFontSize(size); |
|---|
| 1521 | DMG_EraseRect(x, y, w, h, 0xff000000); |
|---|
| 1522 | DMG_PrintStrEx(x, y, w, h, pstr, 0xffff0000, DMG_OPT_A_TP); |
|---|
| 1523 | DMG_AutoRefresh(); |
|---|
| 1524 | } |
|---|
| 1525 | |
|---|
| 1526 | void test_print(int x, int y, int w, int h, int opt) |
|---|
| 1527 | { |
|---|
| 1528 | char *str="TV guide abc def ghi jkl"; |
|---|
| 1529 | |
|---|
| 1530 | DMG_PrintStrEx(x, y, w, h, str, 0xff000000, opt); |
|---|
| 1531 | DMG_AutoRefresh(); |
|---|
| 1532 | } |
|---|
| 1533 | |
|---|
| 1534 | |
|---|
| 1535 | void print_draw_time() |
|---|
| 1536 | { |
|---|
| 1537 | int i; |
|---|
| 1538 | UINT32 start_ms; |
|---|
| 1539 | int x=0; |
|---|
| 1540 | |
|---|
| 1541 | start_ms=DHL_OS_GetMsCount(); |
|---|
| 1542 | |
|---|
| 1543 | DMG_EraseRect(0, 0, 720, 480, 0xff000000); |
|---|
| 1544 | |
|---|
| 1545 | dprint(0, "BG Draw Time : %d(ms)\n", DHL_OS_GetMsCount()-start_ms); |
|---|
| 1546 | start_ms=DHL_OS_GetMsCount(); |
|---|
| 1547 | |
|---|
| 1548 | for(x=0,i=0; x<680; i++) x+=DMG_PrintCh(x, 50, 0x20+i%0x10, 0xffffffff); |
|---|
| 1549 | for(x=0,i=0; x<680; i++) x+=DMG_PrintCh(x, 80, 0x30+i%0x10, 0xffffffff); |
|---|
| 1550 | for(x=0,i=0; x<680; i++) x+=DMG_PrintCh(x, 110, 0x40+i%0x10, 0xffffffff); |
|---|
| 1551 | for(x=0,i=0; x<680; i++) x+=DMG_PrintCh(x, 140, 0x50+i%0x10, 0xffffffff); |
|---|
| 1552 | for(x=0,i=0; x<680; i++) x+=DMG_PrintCh(x, 170, 0x60+i%0x10, 0xffffffff); |
|---|
| 1553 | for(x=0,i=0; x<680; i++) x+=DMG_PrintCh(x, 200, 0x70+i%0x10, 0xffffffff); |
|---|
| 1554 | |
|---|
| 1555 | for(x=0,i=0; x<680; i++) x+=DMG_PrintCh(x, 230, 0x20+i%0x10, 0xffffffff); |
|---|
| 1556 | for(x=0,i=0; x<680; i++) x+=DMG_PrintCh(x, 260, 0x30+i%0x10, 0xffffffff); |
|---|
| 1557 | for(x=0,i=0; x<680; i++) x+=DMG_PrintCh(x, 290, 0x40+i%0x10, 0xffffffff); |
|---|
| 1558 | for(x=0,i=0; x<680; i++) x+=DMG_PrintCh(x, 320, 0x50+i%0x10, 0xffffffff); |
|---|
| 1559 | for(x=0,i=0; x<680; i++) x+=DMG_PrintCh(x, 350, 0x60+i%0x10, 0xffffffff); |
|---|
| 1560 | for(x=0,i=0; x<680; i++) x+=DMG_PrintCh(x, 380, 0x70+i%0x10, 0xffffffff); |
|---|
| 1561 | |
|---|
| 1562 | dprint(0, "Print Time : %d(ms)\n", DHL_OS_GetMsCount()-start_ms); |
|---|
| 1563 | start_ms=DHL_OS_GetMsCount(); |
|---|
| 1564 | |
|---|
| 1565 | DMG_AutoRefresh(); |
|---|
| 1566 | #if 0 |
|---|
| 1567 | dprint(0, "Refresh Time : %d(ms)\n", DHL_OS_GetMsCount()-start_ms); |
|---|
| 1568 | start_ms=DHL_OS_GetMsCount(); |
|---|
| 1569 | |
|---|
| 1570 | App_OSD_BackupScreen(0, 0, 720, 480); |
|---|
| 1571 | |
|---|
| 1572 | dprint(0, "Backup Time : %d(ms)\n", DHL_OS_GetMsCount()-start_ms); |
|---|
| 1573 | start_ms=DHL_OS_GetMsCount(); |
|---|
| 1574 | |
|---|
| 1575 | App_OSD_RestoreScreen(0, 0, 720, 480); |
|---|
| 1576 | |
|---|
| 1577 | dprint(0, "Restore Time : %d(ms)\n", DHL_OS_GetMsCount()-start_ms); |
|---|
| 1578 | start_ms=DHL_OS_GetMsCount(); |
|---|
| 1579 | |
|---|
| 1580 | //grp_pixel_rect(0, 0, 0, 720, 480, 0xff000000); |
|---|
| 1581 | |
|---|
| 1582 | //dprint(0, "pixel rect Time : %d(ms)\n", DHL_OS_GetMsCount()-start_ms); |
|---|
| 1583 | //start_ms=DHL_OS_GetMsCount(); |
|---|
| 1584 | #endif |
|---|
| 1585 | } |
|---|
| 1586 | |
|---|
| 1587 | |
|---|
| 1588 | |
|---|
| 1589 | /* end of file */ |
|---|