| 1 | #include "DST_WinManager.h" |
|---|
| 2 | #include "DST_OSDImage.h" |
|---|
| 3 | |
|---|
| 4 | DS_U32* DST_UTF82Uni(DS_U8 *utf); |
|---|
| 5 | // ÀÚ±â ÀÚ½ÅÀ» Æ÷ÇÔÇÑ ÇÏÀ§ À©µµ¿ì¸¦ ¸ðµÎ ´Ý´Â´Ù. |
|---|
| 6 | void CWindow::Close() |
|---|
| 7 | { |
|---|
| 8 | for (int i = 0; i < WIN_ID_MAX; i++) |
|---|
| 9 | { |
|---|
| 10 | CWindow *pWin = DST_GetWin((WinID)i); |
|---|
| 11 | if (pWin == 0) continue; |
|---|
| 12 | if (pWin->GetParentWinID() == GetWinID()) { |
|---|
| 13 | pWin->Close(); |
|---|
| 14 | } |
|---|
| 15 | } |
|---|
| 16 | |
|---|
| 17 | nWinState = 2; |
|---|
| 18 | UpdateScreen(); |
|---|
| 19 | } |
|---|
| 20 | |
|---|
| 21 | void CWindow::RegisterAllKey() |
|---|
| 22 | { |
|---|
| 23 | for (int i = 0; i <= KEY_ID_MAX; i++) |
|---|
| 24 | { |
|---|
| 25 | bRegisterKey[i] = true; |
|---|
| 26 | nKeyDelay[i] = 0; |
|---|
| 27 | nKeyRepeat[i] = 0; |
|---|
| 28 | } |
|---|
| 29 | } |
|---|
| 30 | |
|---|
| 31 | void CWindow::UnRegisterAllKey() |
|---|
| 32 | { |
|---|
| 33 | for (int i = 0; i <= KEY_ID_MAX; i++) |
|---|
| 34 | { |
|---|
| 35 | bRegisterKey[i] = false; |
|---|
| 36 | nKeyDelay[i] = 0; |
|---|
| 37 | nKeyRepeat[i] = 0; |
|---|
| 38 | } |
|---|
| 39 | } |
|---|
| 40 | |
|---|
| 41 | void CWindow::RegisterKey(DS_U8 nKeyCode, bool bState, int nDelay, int nRepeat) |
|---|
| 42 | { |
|---|
| 43 | bRegisterKey[nKeyCode] = bState; |
|---|
| 44 | if (nDelay < 10 || nRepeat < 10) |
|---|
| 45 | { |
|---|
| 46 | nKeyDelay[nKeyCode] = 0; |
|---|
| 47 | nKeyRepeat[nKeyCode] = 0; |
|---|
| 48 | } |
|---|
| 49 | nKeyDelay[nKeyCode] = nDelay/10; |
|---|
| 50 | nKeyRepeat[nKeyCode] = nRepeat/10; |
|---|
| 51 | } |
|---|
| 52 | |
|---|
| 53 | bool CWindow::IsRegisterKey(DS_U8 nKeyCode) |
|---|
| 54 | { |
|---|
| 55 | return bRegisterKey[nKeyCode]; |
|---|
| 56 | } |
|---|
| 57 | |
|---|
| 58 | void CWindow::SetWinName(const char* strName) |
|---|
| 59 | { |
|---|
| 60 | strcpy(strWinName, strName); |
|---|
| 61 | } |
|---|
| 62 | |
|---|
| 63 | OSD_PIXEL_T *CWindow::GetImgBuff() |
|---|
| 64 | { |
|---|
| 65 | return imgBuff; |
|---|
| 66 | } |
|---|
| 67 | |
|---|
| 68 | void CWindow::SetVisible(bool bValue) |
|---|
| 69 | { |
|---|
| 70 | bVisible = bValue; |
|---|
| 71 | UpdateScreen(); |
|---|
| 72 | } |
|---|
| 73 | |
|---|
| 74 | void CWindow::Move(int x, int y) |
|---|
| 75 | { |
|---|
| 76 | if (rect.x == x && rect.y == y) return; |
|---|
| 77 | UpdateScreen(); |
|---|
| 78 | rect.x = x; |
|---|
| 79 | rect.y = y; |
|---|
| 80 | UpdateScreen(); |
|---|
| 81 | } |
|---|
| 82 | |
|---|
| 83 | void CWindow::UpdateScreen() |
|---|
| 84 | { |
|---|
| 85 | UpdateScreen(0, 0, rect.w, rect.h); |
|---|
| 86 | } |
|---|
| 87 | |
|---|
| 88 | void CWindow::UpdateScreen(int x, int y, int w, int h) |
|---|
| 89 | { |
|---|
| 90 | DST_RECT rectTemp; |
|---|
| 91 | rectTemp.x = rect.x + x; |
|---|
| 92 | rectTemp.y = rect.y + y; |
|---|
| 93 | rectTemp.w = w; |
|---|
| 94 | rectTemp.h = h; |
|---|
| 95 | DST_AddUpdateRegion(rectTemp); |
|---|
| 96 | } |
|---|
| 97 | |
|---|
| 98 | void CWindow::DrawPixel(int x, int y, OSD_PIXEL_T color) |
|---|
| 99 | { |
|---|
| 100 | if (imgBuff == 0) return; |
|---|
| 101 | if (x < 0) return; |
|---|
| 102 | if (y < 0) return; |
|---|
| 103 | if (x > rect.w) return; |
|---|
| 104 | if (y > rect.h) return; |
|---|
| 105 | *(imgBuff + y * rect.w + x) = color; |
|---|
| 106 | } |
|---|
| 107 | |
|---|
| 108 | void CWindow::DrawBox32(int x, int y, int w, int h, OSD_PIXEL_T color) |
|---|
| 109 | { |
|---|
| 110 | if (imgBuff == 0) return; |
|---|
| 111 | if (w == 0 || h == 0) return; |
|---|
| 112 | OSD_PIXEL_T* des = imgBuff + (rect.w*y+x); |
|---|
| 113 | int hh = h; |
|---|
| 114 | while (hh--) |
|---|
| 115 | { |
|---|
| 116 | int ww = w; |
|---|
| 117 | while (ww--) *des++ = color; |
|---|
| 118 | des += (rect.w - w); |
|---|
| 119 | } |
|---|
| 120 | UpdateScreen(x,y,w,h); |
|---|
| 121 | } |
|---|
| 122 | |
|---|
| 123 | // ¾ÐÃà¾È µÈ 16ºñÆ® 32 ºñÆ® À̹ÌÁö |
|---|
| 124 | void CWindow::DrawImage4(int x, int y, DS_U8 *image, bool bProcessTransparent) |
|---|
| 125 | { |
|---|
| 126 | DS_U16 nWidth = image[1] * 256 + image[2]; |
|---|
| 127 | DS_U16 nHeight = image[3] * 256 + image[4]; |
|---|
| 128 | |
|---|
| 129 | if (x+nWidth > rect.w) return; |
|---|
| 130 | if (y+nHeight > rect.h) return; |
|---|
| 131 | |
|---|
| 132 | UpdateScreen(x, y, nWidth, nHeight); |
|---|
| 133 | |
|---|
| 134 | if (bProcessTransparent == true) |
|---|
| 135 | { |
|---|
| 136 | int yy = nHeight; |
|---|
| 137 | OSD_PIXEL_T *tmpSrc = (OSD_PIXEL_T *)& image[8]; |
|---|
| 138 | OSD_PIXEL_T *tmpDes = imgBuff + y * rect.w + x; |
|---|
| 139 | int nStep = rect.w-nWidth; |
|---|
| 140 | while (yy--) |
|---|
| 141 | { |
|---|
| 142 | int xx = nWidth; |
|---|
| 143 | while (xx--) |
|---|
| 144 | { |
|---|
| 145 | OSD_PIXEL_T max = (sizeof(OSD_PIXEL_T) == 2) ? 0x0F : 0xFF; |
|---|
| 146 | OSD_PIXEL_T sa,sr,sg,sb; |
|---|
| 147 | DST_GetColor(*tmpSrc, &sa, &sr, &sg, &sb); |
|---|
| 148 | OSD_PIXEL_T da,dr,dg,db; |
|---|
| 149 | DST_GetColor(*tmpDes, &da, &dr, &dg, &db); |
|---|
| 150 | |
|---|
| 151 | if (sa != 0) // Åõ¸íÀÌ ¾Æ´Ñ °æ¿ì¸¸ ±×¸°´Ù. |
|---|
| 152 | { |
|---|
| 153 | if (sa == max || da == 0) // ¼Ò½º°¡ ¿ÏÀüºÒÅõ¸íÀ̰ųª ¹è°æÀÌ Åõ¸íÀΰæ¿ì |
|---|
| 154 | { |
|---|
| 155 | *tmpDes = *tmpSrc; |
|---|
| 156 | } |
|---|
| 157 | else // ¹ÝÅõ¸í |
|---|
| 158 | { |
|---|
| 159 | // http://en.wikipedia.org/wiki/Alpha_compositing#Alpha_blending |
|---|
| 160 | OSD_PIXEL_T t = (da * (max-sa) + (max/2)) / max; |
|---|
| 161 | OSD_PIXEL_T a = sa + t; |
|---|
| 162 | if (a > max) a = max; |
|---|
| 163 | OSD_PIXEL_T r = ((sr * sa + dr * t) + (a/2)) / a; |
|---|
| 164 | OSD_PIXEL_T g = ((sg * sa + dg * t) + (a/2)) / a; |
|---|
| 165 | OSD_PIXEL_T b = ((sb * sa + db * t) + (a/2)) / a; |
|---|
| 166 | *tmpDes = DST_SetColor(a, r, g, b); |
|---|
| 167 | } |
|---|
| 168 | } |
|---|
| 169 | tmpSrc++; |
|---|
| 170 | tmpDes++; |
|---|
| 171 | } |
|---|
| 172 | tmpDes += nStep; |
|---|
| 173 | } |
|---|
| 174 | } |
|---|
| 175 | else |
|---|
| 176 | { |
|---|
| 177 | int yy = nHeight; |
|---|
| 178 | OSD_PIXEL_T *tmpSrc = (OSD_PIXEL_T *)& image[image[0]==2? 6:8]; |
|---|
| 179 | OSD_PIXEL_T *tmpDes = imgBuff + y * rect.w + x; |
|---|
| 180 | while (yy--) |
|---|
| 181 | { |
|---|
| 182 | memcpy(tmpDes, tmpSrc, sizeof(OSD_PIXEL_T) * nWidth); |
|---|
| 183 | tmpSrc += nWidth; |
|---|
| 184 | tmpDes += rect.w; |
|---|
| 185 | } |
|---|
| 186 | } |
|---|
| 187 | } |
|---|
| 188 | |
|---|
| 189 | void CWindow::DrawImage5(int x, int y, DS_U8 *image, bool bProcessTransparent) |
|---|
| 190 | { |
|---|
| 191 | DS_U16 nWidth = image[1] * 256 + image[2]; |
|---|
| 192 | DS_U16 nHeight = image[3] * 256 + image[4]; |
|---|
| 193 | |
|---|
| 194 | if (x+nWidth > rect.w) return; |
|---|
| 195 | if (y+nHeight > rect.h) return; |
|---|
| 196 | |
|---|
| 197 | UpdateScreen(x, y, nWidth, nHeight); |
|---|
| 198 | |
|---|
| 199 | DS_U16 nPallette = image[6] * 256 + image[7]; |
|---|
| 200 | DS_U32 *pPallette = (DS_U32*)&image[8]; |
|---|
| 201 | //DST_Printf("nPallette = %d\n", nPallette); |
|---|
| 202 | DS_U32* pDes = (DS_U32*)imgBuff + y * rect.w + x; |
|---|
| 203 | if (bProcessTransparent == true) |
|---|
| 204 | { |
|---|
| 205 | OSD_PIXEL_T max = (sizeof(OSD_PIXEL_T) == 2) ? 0x0F : 0xFF; |
|---|
| 206 | if (nPallette > 256) |
|---|
| 207 | { |
|---|
| 208 | DS_U16* pSrc = (DS_U16*)&image[8 + nPallette*4]; |
|---|
| 209 | for (int yy = 0; yy < nHeight; yy++) |
|---|
| 210 | { |
|---|
| 211 | DS_U32* pDes1 = pDes; |
|---|
| 212 | for (int xx =0; xx < nWidth; xx++) |
|---|
| 213 | { |
|---|
| 214 | OSD_PIXEL_T c = pPallette[*pSrc]; |
|---|
| 215 | OSD_PIXEL_T sa,sr,sg,sb; |
|---|
| 216 | DST_GetColor(c, &sa, &sr, &sg, &sb); |
|---|
| 217 | OSD_PIXEL_T da,dr,dg,db; |
|---|
| 218 | DST_GetColor(*pDes1, &da, &dr, &dg, &db); |
|---|
| 219 | |
|---|
| 220 | if (sa != 0) // Åõ¸íÀÌ ¾Æ´Ñ °æ¿ì¸¸ ±×¸°´Ù. |
|---|
| 221 | { |
|---|
| 222 | if (sa == max || da == 0) // ¼Ò½º°¡ ¿ÏÀüºÒÅõ¸íÀ̰ųª ¹è°æÀÌ Åõ¸íÀΰæ¿ì |
|---|
| 223 | { |
|---|
| 224 | *pDes1 = c; |
|---|
| 225 | } |
|---|
| 226 | else // ¹ÝÅõ¸í |
|---|
| 227 | { |
|---|
| 228 | // http://en.wikipedia.org/wiki/Alpha_compositing#Alpha_blending |
|---|
| 229 | OSD_PIXEL_T t = (da * (max-sa) + (max/2)) / max; |
|---|
| 230 | OSD_PIXEL_T a = sa + t; |
|---|
| 231 | if (a > max) a = max; |
|---|
| 232 | OSD_PIXEL_T r = ((sr * sa + dr * t) + (a/2)) / a; |
|---|
| 233 | OSD_PIXEL_T g = ((sg * sa + dg * t) + (a/2)) / a; |
|---|
| 234 | OSD_PIXEL_T b = ((sb * sa + db * t) + (a/2)) / a; |
|---|
| 235 | *pDes1 = DST_SetColor(a, r, g, b); |
|---|
| 236 | } |
|---|
| 237 | } |
|---|
| 238 | pSrc++; |
|---|
| 239 | pDes1++; |
|---|
| 240 | } |
|---|
| 241 | pDes += rect.w; |
|---|
| 242 | } |
|---|
| 243 | } |
|---|
| 244 | else if (nPallette > 1) |
|---|
| 245 | { |
|---|
| 246 | DS_U8* pSrc = (DS_U8*)&image[8 + nPallette*4]; |
|---|
| 247 | for (int yy = 0; yy < nHeight; yy++) |
|---|
| 248 | { |
|---|
| 249 | DS_U32* pDes1 = pDes; |
|---|
| 250 | for (int xx =0; xx < nWidth; xx++) |
|---|
| 251 | { |
|---|
| 252 | OSD_PIXEL_T c = pPallette[*pSrc]; |
|---|
| 253 | OSD_PIXEL_T sa,sr,sg,sb; |
|---|
| 254 | DST_GetColor(c, &sa, &sr, &sg, &sb); |
|---|
| 255 | OSD_PIXEL_T da,dr,dg,db; |
|---|
| 256 | DST_GetColor(*pDes1, &da, &dr, &dg, &db); |
|---|
| 257 | |
|---|
| 258 | if (sa != 0) // Åõ¸íÀÌ ¾Æ´Ñ °æ¿ì¸¸ ±×¸°´Ù. |
|---|
| 259 | { |
|---|
| 260 | if (sa == max || da == 0) // ¼Ò½º°¡ ¿ÏÀüºÒÅõ¸íÀ̰ųª ¹è°æÀÌ Åõ¸íÀΰæ¿ì |
|---|
| 261 | { |
|---|
| 262 | *pDes1 = c; |
|---|
| 263 | } |
|---|
| 264 | else // ¹ÝÅõ¸í |
|---|
| 265 | { |
|---|
| 266 | // http://en.wikipedia.org/wiki/Alpha_compositing#Alpha_blending |
|---|
| 267 | OSD_PIXEL_T t = (da * (max-sa) + (max/2)) / max; |
|---|
| 268 | OSD_PIXEL_T a = sa + t; |
|---|
| 269 | if (a > max) a = max; |
|---|
| 270 | OSD_PIXEL_T r = ((sr * sa + dr * t) + (a/2)) / a; |
|---|
| 271 | OSD_PIXEL_T g = ((sg * sa + dg * t) + (a/2)) / a; |
|---|
| 272 | OSD_PIXEL_T b = ((sb * sa + db * t) + (a/2)) / a; |
|---|
| 273 | *pDes1 = DST_SetColor(a, r, g, b); |
|---|
| 274 | } |
|---|
| 275 | } |
|---|
| 276 | pSrc++; |
|---|
| 277 | pDes1++; |
|---|
| 278 | } |
|---|
| 279 | pDes += rect.w; |
|---|
| 280 | } |
|---|
| 281 | } |
|---|
| 282 | else // ´Ü »ö |
|---|
| 283 | { |
|---|
| 284 | OSD_PIXEL_T c = pPallette[0]; |
|---|
| 285 | OSD_PIXEL_T sa,sr,sg,sb; |
|---|
| 286 | DST_GetColor(c, &sa, &sr, &sg, &sb); |
|---|
| 287 | for (int yy = 0; yy < nHeight; yy++) |
|---|
| 288 | { |
|---|
| 289 | DS_U32* pDes1 = pDes; |
|---|
| 290 | for (int xx =0; xx < nWidth; xx++) |
|---|
| 291 | { |
|---|
| 292 | OSD_PIXEL_T da,dr,dg,db; |
|---|
| 293 | DST_GetColor(*pDes1, &da, &dr, &dg, &db); |
|---|
| 294 | if (sa != 0) // Åõ¸íÀÌ ¾Æ´Ñ °æ¿ì¸¸ ±×¸°´Ù. |
|---|
| 295 | { |
|---|
| 296 | if (sa == max || da == 0) // ¼Ò½º°¡ ¿ÏÀüºÒÅõ¸íÀ̰ųª ¹è°æÀÌ Åõ¸íÀΰæ¿ì |
|---|
| 297 | { |
|---|
| 298 | *pDes1 = c; |
|---|
| 299 | } |
|---|
| 300 | else // ¹ÝÅõ¸í |
|---|
| 301 | { |
|---|
| 302 | // http://en.wikipedia.org/wiki/Alpha_compositing#Alpha_blending |
|---|
| 303 | OSD_PIXEL_T t = (da * (max-sa) + (max/2)) / max; |
|---|
| 304 | OSD_PIXEL_T a = sa + t; |
|---|
| 305 | if (a > max) a = max; |
|---|
| 306 | OSD_PIXEL_T r = ((sr * sa + dr * t) + (a/2)) / a; |
|---|
| 307 | OSD_PIXEL_T g = ((sg * sa + dg * t) + (a/2)) / a; |
|---|
| 308 | OSD_PIXEL_T b = ((sb * sa + db * t) + (a/2)) / a; |
|---|
| 309 | *pDes1 = DST_SetColor(a, r, g, b); |
|---|
| 310 | } |
|---|
| 311 | } |
|---|
| 312 | pDes1++; |
|---|
| 313 | } |
|---|
| 314 | pDes += rect.w; |
|---|
| 315 | } |
|---|
| 316 | } |
|---|
| 317 | } |
|---|
| 318 | else |
|---|
| 319 | { |
|---|
| 320 | if (nPallette > 256) |
|---|
| 321 | { |
|---|
| 322 | DS_U16* pSrc = (DS_U16*)&image[8 + nPallette*4]; |
|---|
| 323 | for (int yy = 0; yy < nHeight; yy++) |
|---|
| 324 | { |
|---|
| 325 | DS_U32* pDes1 = pDes; |
|---|
| 326 | for (int xx =0; xx < nWidth; xx++) |
|---|
| 327 | { |
|---|
| 328 | *pDes1 = pPallette[*pSrc]; |
|---|
| 329 | pSrc++; |
|---|
| 330 | pDes1++; |
|---|
| 331 | } |
|---|
| 332 | pDes += rect.w; |
|---|
| 333 | } |
|---|
| 334 | } |
|---|
| 335 | else if (nPallette > 1) |
|---|
| 336 | { |
|---|
| 337 | DS_U8* pSrc = (DS_U8*)&image[8 + nPallette*4]; |
|---|
| 338 | for (int yy = 0; yy < nHeight; yy++) |
|---|
| 339 | { |
|---|
| 340 | DS_U32* pDes1 = pDes; |
|---|
| 341 | for (int xx =0; xx < nWidth; xx++) |
|---|
| 342 | { |
|---|
| 343 | *pDes1 = pPallette[*pSrc]; |
|---|
| 344 | pSrc++; |
|---|
| 345 | pDes1++; |
|---|
| 346 | } |
|---|
| 347 | pDes += rect.w; |
|---|
| 348 | } |
|---|
| 349 | } |
|---|
| 350 | else // ÆÈ·¹Æ® °¹¼ö°¡ 1°³ÀÎ °æ¿ì |
|---|
| 351 | { |
|---|
| 352 | T(); |
|---|
| 353 | DrawBox32(x, y, nWidth, nHeight, pPallette[0]); |
|---|
| 354 | } |
|---|
| 355 | } |
|---|
| 356 | } |
|---|
| 357 | |
|---|
| 358 | // 256°³ ÀÌÇÏÀÇ ÆÈ·¹Æ®¸¦ °¡Áø 16ºñÆ® À̹ÌÁö |
|---|
| 359 | void CWindow::DrawImage6(int x, int y, DS_U8 *image, bool bProcessTransparent) |
|---|
| 360 | { |
|---|
| 361 | DS_U16 nWidth = image[1] * 256 + image[2]; |
|---|
| 362 | DS_U16 nHeight = image[3] * 256 + image[4]; |
|---|
| 363 | |
|---|
| 364 | if (x+nWidth > rect.w) return; |
|---|
| 365 | if (y+nHeight > rect.h) return; |
|---|
| 366 | |
|---|
| 367 | UpdateScreen(x, y, nWidth, nHeight); |
|---|
| 368 | |
|---|
| 369 | DS_U16 nPallette = image[5]+1; |
|---|
| 370 | OSD_PIXEL_T *pPallette = (DS_U16*)&image[6]; |
|---|
| 371 | //DST_Printf("nPallette = %d\n", nPallette); |
|---|
| 372 | DS_U8* pSrc = (DS_U8*)&image[6 + nPallette*2]; |
|---|
| 373 | OSD_PIXEL_T* pDes = imgBuff + y * rect.w + x; |
|---|
| 374 | if (bProcessTransparent == true) |
|---|
| 375 | { |
|---|
| 376 | OSD_PIXEL_T max = (sizeof(OSD_PIXEL_T) == 2) ? 0x0F : 0xFF; |
|---|
| 377 | if (nPallette <= 16) |
|---|
| 378 | { |
|---|
| 379 | bool bUpper = true; |
|---|
| 380 | for (int yy = 0; yy < nHeight; yy++) |
|---|
| 381 | { |
|---|
| 382 | OSD_PIXEL_T* pDes1 = pDes; |
|---|
| 383 | for (int xx =0; xx < nWidth; xx++) |
|---|
| 384 | { |
|---|
| 385 | OSD_PIXEL_T c = 0; |
|---|
| 386 | if (bUpper) |
|---|
| 387 | { |
|---|
| 388 | c = pPallette[(*pSrc>>4)&0x0F]; |
|---|
| 389 | bUpper = false; |
|---|
| 390 | } |
|---|
| 391 | else |
|---|
| 392 | { |
|---|
| 393 | c = pPallette[(*pSrc)&0x0F]; |
|---|
| 394 | pSrc++; |
|---|
| 395 | bUpper = true; |
|---|
| 396 | } |
|---|
| 397 | OSD_PIXEL_T sa,sr,sg,sb; |
|---|
| 398 | DST_GetColor(c, &sa, &sr, &sg, &sb); |
|---|
| 399 | OSD_PIXEL_T da,dr,dg,db; |
|---|
| 400 | DST_GetColor(*pDes1, &da, &dr, &dg, &db); |
|---|
| 401 | |
|---|
| 402 | if (sa != 0) // Åõ¸íÀÌ ¾Æ´Ñ °æ¿ì¸¸ ±×¸°´Ù. |
|---|
| 403 | { |
|---|
| 404 | if (sa == max || da == 0) // ¼Ò½º°¡ ¿ÏÀüºÒÅõ¸íÀ̰ųª ¹è°æÀÌ Åõ¸íÀΰæ¿ì |
|---|
| 405 | { |
|---|
| 406 | *pDes1 = c; |
|---|
| 407 | } |
|---|
| 408 | else // ¹ÝÅõ¸í |
|---|
| 409 | { |
|---|
| 410 | // http://en.wikipedia.org/wiki/Alpha_compositing#Alpha_blending |
|---|
| 411 | OSD_PIXEL_T t = (da * (max-sa) + (max/2)) / max; |
|---|
| 412 | OSD_PIXEL_T a = sa + t; |
|---|
| 413 | if (a > max) a = max; |
|---|
| 414 | OSD_PIXEL_T r = ((sr * sa + dr * t) + (a/2)) / a; |
|---|
| 415 | OSD_PIXEL_T g = ((sg * sa + dg * t) + (a/2)) / a; |
|---|
| 416 | OSD_PIXEL_T b = ((sb * sa + db * t) + (a/2)) / a; |
|---|
| 417 | *pDes1 = DST_SetColor(a, r, g, b); |
|---|
| 418 | } |
|---|
| 419 | } |
|---|
| 420 | //pSrc++; |
|---|
| 421 | pDes1++; |
|---|
| 422 | } |
|---|
| 423 | pDes += rect.w; |
|---|
| 424 | } |
|---|
| 425 | } |
|---|
| 426 | else |
|---|
| 427 | { |
|---|
| 428 | for (int yy = 0; yy < nHeight; yy++) |
|---|
| 429 | { |
|---|
| 430 | OSD_PIXEL_T* pDes1 = pDes; |
|---|
| 431 | for (int xx =0; xx < nWidth; xx++) |
|---|
| 432 | { |
|---|
| 433 | OSD_PIXEL_T c = pPallette[*pSrc]; |
|---|
| 434 | OSD_PIXEL_T sa,sr,sg,sb; |
|---|
| 435 | DST_GetColor(c, &sa, &sr, &sg, &sb); |
|---|
| 436 | OSD_PIXEL_T da,dr,dg,db; |
|---|
| 437 | DST_GetColor(*pDes1, &da, &dr, &dg, &db); |
|---|
| 438 | |
|---|
| 439 | if (sa != 0) // Åõ¸íÀÌ ¾Æ´Ñ °æ¿ì¸¸ ±×¸°´Ù. |
|---|
| 440 | { |
|---|
| 441 | if (sa == max || da == 0) // ¼Ò½º°¡ ¿ÏÀüºÒÅõ¸íÀ̰ųª ¹è°æÀÌ Åõ¸íÀΰæ¿ì |
|---|
| 442 | { |
|---|
| 443 | *pDes1 = c; |
|---|
| 444 | } |
|---|
| 445 | else // ¹ÝÅõ¸í |
|---|
| 446 | { |
|---|
| 447 | // http://en.wikipedia.org/wiki/Alpha_compositing#Alpha_blending |
|---|
| 448 | OSD_PIXEL_T t = (da * (max-sa) + (max/2)) / max; |
|---|
| 449 | OSD_PIXEL_T a = sa + t; |
|---|
| 450 | if (a > max) a = max; |
|---|
| 451 | OSD_PIXEL_T r = ((sr * sa + dr * t) + (a/2)) / a; |
|---|
| 452 | OSD_PIXEL_T g = ((sg * sa + dg * t) + (a/2)) / a; |
|---|
| 453 | OSD_PIXEL_T b = ((sb * sa + db * t) + (a/2)) / a; |
|---|
| 454 | *pDes1 = DST_SetColor(a, r, g, b); |
|---|
| 455 | } |
|---|
| 456 | } |
|---|
| 457 | pSrc++; |
|---|
| 458 | pDes1++; |
|---|
| 459 | } |
|---|
| 460 | pDes += rect.w; |
|---|
| 461 | } |
|---|
| 462 | } |
|---|
| 463 | } |
|---|
| 464 | else |
|---|
| 465 | { |
|---|
| 466 | if (nPallette <= 16) |
|---|
| 467 | { |
|---|
| 468 | bool bUpper = true; |
|---|
| 469 | for (int yy = 0; yy < nHeight; yy++) |
|---|
| 470 | { |
|---|
| 471 | OSD_PIXEL_T* pDes1 = pDes; |
|---|
| 472 | for (int xx =0; xx < nWidth; xx++) |
|---|
| 473 | { |
|---|
| 474 | if (bUpper) |
|---|
| 475 | { |
|---|
| 476 | *pDes1 = pPallette[(*pSrc>>4)&0x0F]; |
|---|
| 477 | bUpper = false; |
|---|
| 478 | } |
|---|
| 479 | else |
|---|
| 480 | { |
|---|
| 481 | *pDes1 = pPallette[(*pSrc)&0x0F]; |
|---|
| 482 | pSrc++; |
|---|
| 483 | bUpper = true; |
|---|
| 484 | } |
|---|
| 485 | pDes1++; |
|---|
| 486 | } |
|---|
| 487 | pDes += rect.w; |
|---|
| 488 | } |
|---|
| 489 | } |
|---|
| 490 | else |
|---|
| 491 | { |
|---|
| 492 | for (int yy = 0; yy < nHeight; yy++) |
|---|
| 493 | { |
|---|
| 494 | OSD_PIXEL_T* pDes1 = pDes; |
|---|
| 495 | for (int xx =0; xx < nWidth; xx++) |
|---|
| 496 | { |
|---|
| 497 | *pDes1 = pPallette[*pSrc]; |
|---|
| 498 | pSrc++; |
|---|
| 499 | pDes1++; |
|---|
| 500 | } |
|---|
| 501 | pDes += rect.w; |
|---|
| 502 | } |
|---|
| 503 | } |
|---|
| 504 | } |
|---|
| 505 | } |
|---|
| 506 | |
|---|
| 507 | void CWindow::DrawImage(int x, int y, DS_U8 *image, bool bProcessTransparent) |
|---|
| 508 | { |
|---|
| 509 | if (image == 0) return; |
|---|
| 510 | if (imgBuff == 0) return; |
|---|
| 511 | |
|---|
| 512 | switch (image[0]) |
|---|
| 513 | { |
|---|
| 514 | case 2: |
|---|
| 515 | case 4: |
|---|
| 516 | DrawImage4(x,y,image, bProcessTransparent); |
|---|
| 517 | break; |
|---|
| 518 | case 5: |
|---|
| 519 | DrawImage5(x,y,image, bProcessTransparent); |
|---|
| 520 | break; |
|---|
| 521 | case 6: // ¾ÐÃàµÈ 16ºñÆ® À̹ÌÁö |
|---|
| 522 | DrawImage6(x,y,image, bProcessTransparent); |
|---|
| 523 | break; |
|---|
| 524 | default: |
|---|
| 525 | break; |
|---|
| 526 | } |
|---|
| 527 | } |
|---|
| 528 | |
|---|
| 529 | |
|---|
| 530 | void CWindow::DrawText(int start_x, int start_y, int width, int height, char *strText, CFont* font) |
|---|
| 531 | { |
|---|
| 532 | if (strText == 0) return; |
|---|
| 533 | if (strlen(strText) == 0) return; |
|---|
| 534 | DS_U16* strText16 = (DS_U16*)DST_OS_Malloc((strlen(strText)+1) * sizeof(DS_U16)); |
|---|
| 535 | memset(strText16, 0,(strlen(strText)+1) * sizeof(DS_U16)); |
|---|
| 536 | for (unsigned i= 0; i < strlen(strText); i++) strText16[i] = (DS_U16)(DS_U8)strText[i]; |
|---|
| 537 | DrawTextUni(start_x, start_y, width, height, strText16, font); |
|---|
| 538 | DST_OS_Free(&strText16); |
|---|
| 539 | } |
|---|
| 540 | |
|---|
| 541 | void CWindow::DrawTextUTF8(int start_x, int start_y, int width, int height, DS_U8* strText, CFont* font) |
|---|
| 542 | { |
|---|
| 543 | if (strText == 0) return; |
|---|
| 544 | int nLen = 0; |
|---|
| 545 | for (int i = 0; i < 4096; i++) // 4096ÀÌÇÏ·Î Á¦ÇÑµÊ |
|---|
| 546 | { |
|---|
| 547 | if (strText[i] == 0) break; |
|---|
| 548 | nLen++; |
|---|
| 549 | } |
|---|
| 550 | DST_Printf("nLen = %d\n", nLen); |
|---|
| 551 | if (nLen == 0) return; |
|---|
| 552 | DS_U32 *strText32 = DST_UTF82Uni(strText); // È£ÃâÇÑ ÂÊ¿¡¼ ¸Þ¸ð¸® ÇØÁ¦ |
|---|
| 553 | if (strText32 == 0) return; |
|---|
| 554 | DrawText32(start_x, start_y,width, height, strText32, font); |
|---|
| 555 | //DST_OS_Free(&strText32); |
|---|
| 556 | T(); |
|---|
| 557 | } |
|---|
| 558 | |
|---|
| 559 | void CWindow::DrawTextUni(int start_x, int start_y, int width, int height, DS_U16* strText, CFont* font) |
|---|
| 560 | { |
|---|
| 561 | // ¹®ÀÚ¿ÀÇ ±æÀ̸¦ ±¸ÇÑ´Ù. |
|---|
| 562 | int nStrLen = 0; |
|---|
| 563 | for (int i = 0; i < 4096; i++) // 4096ÀÌÇÏ·Î Á¦ÇÑµÊ |
|---|
| 564 | { |
|---|
| 565 | if (strText[i] == 0) break; |
|---|
| 566 | nStrLen++; |
|---|
| 567 | } |
|---|
| 568 | if (nStrLen == 0) return; |
|---|
| 569 | DS_U32* strText32 = (DS_U32*)DST_OS_Malloc((nStrLen+1) * sizeof(DS_U32)); |
|---|
| 570 | memset(strText32, 0, (nStrLen+1) * sizeof(DS_U32)); |
|---|
| 571 | for (int i = 0; i < nStrLen; i++) strText32[i] = (DS_U32)strText[i]; |
|---|
| 572 | DrawText32(start_x, start_y,width, height, strText32, font); |
|---|
| 573 | DST_OS_Free(&strText32); |
|---|
| 574 | } |
|---|
| 575 | |
|---|
| 576 | void CWindow::DrawText32(int start_x, int start_y, int width, int height, DS_U32* strText, CFont* font) |
|---|
| 577 | { |
|---|
| 578 | if (strText == 0) return; |
|---|
| 579 | // ¹®ÀÚ¿ÀÇ ±æÀ̸¦ ±¸ÇÑ´Ù. |
|---|
| 580 | int nStrLen = 0; |
|---|
| 581 | for (int i = 0; i < 4096; i++) // 4096ÀÌÇÏ·Î Á¦ÇÑµÊ |
|---|
| 582 | { |
|---|
| 583 | if (strText[i] == 0) break; |
|---|
| 584 | nStrLen++; |
|---|
| 585 | } |
|---|
| 586 | if (nStrLen == 0) return; |
|---|
| 587 | |
|---|
| 588 | if (GetImgBuff() == 0) return; |
|---|
| 589 | if (width < 1) return; |
|---|
| 590 | if (height < 1) return; |
|---|
| 591 | if (start_x < 0) start_x = 0; |
|---|
| 592 | if (start_y < 0) start_y = 0; |
|---|
| 593 | if (width > rect.w) width = rect.w; |
|---|
| 594 | if (height > rect.h) height = rect.h; |
|---|
| 595 | if (start_x + width > rect.w) start_x = rect.w-width; |
|---|
| 596 | if (start_y + height > rect.h) start_y = rect.h-height; |
|---|
| 597 | |
|---|
| 598 | // ¹®ÀÚ¿ÀÌ ÅØ½ºÆ® ¹Ú½ºº¸´Ù Å©´Ù¸é ...À» Ãß°¡ÇÑ´Ù. |
|---|
| 599 | if (width < font->GetDot1Width()) return; // ÆøÀÌ Á¼À¸¸é ±Û¾¾¸¦ ¾²Áö ¾Ê´Â´Ù. |
|---|
| 600 | |
|---|
| 601 | static DS_U32 strBuff[4096]; |
|---|
| 602 | DS_U16 nBuffLen = 0; |
|---|
| 603 | int iActualStringWidth = DST_GetTextWidth32(strText, nStrLen, font->GetSize()); |
|---|
| 604 | |
|---|
| 605 | if (width >= iActualStringWidth) |
|---|
| 606 | { |
|---|
| 607 | memcpy(strBuff, strText, nStrLen * sizeof(DS_U32)); |
|---|
| 608 | nBuffLen = nStrLen; |
|---|
| 609 | } |
|---|
| 610 | else if (width >= font->GetDot3Width()) |
|---|
| 611 | { |
|---|
| 612 | for (int i = 1; i < nStrLen; i++) |
|---|
| 613 | { |
|---|
| 614 | memcpy(strBuff, strText, i * sizeof(DS_U32)); |
|---|
| 615 | strBuff[i] = (DS_U32)'.'; |
|---|
| 616 | strBuff[i + 1] = (DS_U32)'.'; |
|---|
| 617 | strBuff[i + 2] = (DS_U32)'.'; |
|---|
| 618 | nBuffLen = i + 3; |
|---|
| 619 | if (width < DST_GetTextWidth32(strBuff, nBuffLen, font->GetSize())) |
|---|
| 620 | { |
|---|
| 621 | strBuff[i - 1] = (DS_U32)'.'; |
|---|
| 622 | nBuffLen--; |
|---|
| 623 | break; |
|---|
| 624 | } |
|---|
| 625 | } |
|---|
| 626 | } |
|---|
| 627 | else if (rect.w >= font->GetDot2Width()) |
|---|
| 628 | { |
|---|
| 629 | strBuff[0] = (DS_U32)'.'; |
|---|
| 630 | strBuff[1] = (DS_U32)'.'; |
|---|
| 631 | nBuffLen = 2; |
|---|
| 632 | } |
|---|
| 633 | else |
|---|
| 634 | { |
|---|
| 635 | strBuff[0] = (DS_U32)'.'; |
|---|
| 636 | nBuffLen = 1; |
|---|
| 637 | } |
|---|
| 638 | |
|---|
| 639 | int nWidth; |
|---|
| 640 | |
|---|
| 641 | // Align 󸮸¦ ÇÑ´Ù. |
|---|
| 642 | if (nBuffLen == nStrLen) |
|---|
| 643 | nWidth = iActualStringWidth; |
|---|
| 644 | else |
|---|
| 645 | nWidth = DST_GetTextWidth32(strBuff, nBuffLen, font->GetSize()); |
|---|
| 646 | |
|---|
| 647 | int nHeight = DST_GetTextHeight(font->GetSize()); |
|---|
| 648 | |
|---|
| 649 | if (nWidth > width) width = nWidth; |
|---|
| 650 | if (nHeight > height) |
|---|
| 651 | { |
|---|
| 652 | start_y = start_y - (nHeight - height) / 2; |
|---|
| 653 | if (start_y < 0) start_y =0; |
|---|
| 654 | height = nHeight; |
|---|
| 655 | } |
|---|
| 656 | if (width > rect.w) return; |
|---|
| 657 | if (height > rect.h) return; |
|---|
| 658 | int x_pos = start_x; |
|---|
| 659 | int y_pos = start_y; |
|---|
| 660 | switch (font->GetHorAlign()) |
|---|
| 661 | { |
|---|
| 662 | case ALIGN_CENTER: x_pos = start_x + (width - nWidth) / 2; break; |
|---|
| 663 | case ALIGN_RIGHT: x_pos = start_x + width - nWidth; break; |
|---|
| 664 | } |
|---|
| 665 | switch (font->GetVerAlign()) |
|---|
| 666 | { |
|---|
| 667 | case ALIGN_MIDDLE: y_pos = start_y + (height - nHeight) / 2; break; |
|---|
| 668 | case ALIGN_BOTTOM: y_pos = start_y + height - nHeight; break; |
|---|
| 669 | } |
|---|
| 670 | // ±Û¾¾´Â Ç×»ó ºÒÅõ¸í »öÀ¸·Î |
|---|
| 671 | OSD_PIXEL_T Color = font->GetColor(); |
|---|
| 672 | switch(sizeof(OSD_PIXEL_T)) |
|---|
| 673 | { |
|---|
| 674 | case 2: |
|---|
| 675 | Color |= 0xF000; |
|---|
| 676 | break; |
|---|
| 677 | case 4: |
|---|
| 678 | Color |= 0xFF000000; // ±Û¾¾´Â Ç×»ó ºÒÅõ¸í »öÀ¸·Î |
|---|
| 679 | break; |
|---|
| 680 | } |
|---|
| 681 | DST_PrintText(GetImgBuff(), rect.w, rect.h, x_pos, y_pos, |
|---|
| 682 | strBuff, nBuffLen, font->GetSize(), Color); |
|---|
| 683 | } |
|---|
| 684 | |
|---|
| 685 | CWindow::CWindow(SWinEventMsg event) |
|---|
| 686 | { |
|---|
| 687 | eventInit = event; |
|---|
| 688 | rect.x = 0; |
|---|
| 689 | rect.y = 0; |
|---|
| 690 | rect.w = 0; |
|---|
| 691 | rect.h = 0; |
|---|
| 692 | sprintf(strWinName, "No name"); |
|---|
| 693 | UnRegisterAllKey(); |
|---|
| 694 | imgBuff = 0; |
|---|
| 695 | bVisible = true; |
|---|
| 696 | nWinState = 0; |
|---|
| 697 | m_WinIDParent = (WinID)event.data[1]; |
|---|
| 698 | for (int i =0; i < TIMER_ID_MAX; i++) |
|---|
| 699 | { |
|---|
| 700 | TimerTickCount[i] = 0; |
|---|
| 701 | TimerInterval[i] = 0; |
|---|
| 702 | } |
|---|
| 703 | SetTimeOut(30); // À©µµ¿ì ±âº» ŸÀӾƿô 30ÃÊ |
|---|
| 704 | bTransparentWindow = true; |
|---|
| 705 | bFocus = false; |
|---|
| 706 | // SetPallette(DST_GetPallette(1)); |
|---|
| 707 | Brightness = 100; |
|---|
| 708 | } |
|---|
| 709 | |
|---|
| 710 | void CWindow::SetTimeOut(int nSecond) |
|---|
| 711 | { |
|---|
| 712 | SetTimer(0, nSecond * 1000); |
|---|
| 713 | } |
|---|
| 714 | |
|---|
| 715 | DS_U32 CWindow::GetTimeOut() |
|---|
| 716 | { |
|---|
| 717 | if (TimerInterval[0] == 0) return 0; |
|---|
| 718 | return TimerInterval[0] / 1000; |
|---|
| 719 | } |
|---|
| 720 | |
|---|
| 721 | void CWindow::SetTimer(char nID, int ms) |
|---|
| 722 | { |
|---|
| 723 | ResetTimer(nID); |
|---|
| 724 | TimerInterval[(int)nID] = ms; |
|---|
| 725 | } |
|---|
| 726 | |
|---|
| 727 | void CWindow::ResetTimer(char nID) |
|---|
| 728 | { |
|---|
| 729 | // if (nID == 0) // ??? ºÐ¼® ÇÊ¿ä ÄÚµå |
|---|
| 730 | // { |
|---|
| 731 | // // ÀÚ±â ÀÚ½ÅÀÇ ÇÏÀ§ À©µµ¿ì°¡ ÀÖ´Ù¸é ŸÀÓ ¾Æ¿ôÀ» ¿¬ÀåÇØÁØ´Ù. |
|---|
| 732 | // for (int i = 0; i < WIN_ID_MAX; i++) |
|---|
| 733 | // { |
|---|
| 734 | // CWindow *pWin = DST_GetWin((WinID)i); |
|---|
| 735 | // if (pWin == 0) continue; |
|---|
| 736 | // if (pWin->GetParentWinID() == GetWinID()) pWin->ResetTimer(0); |
|---|
| 737 | // } |
|---|
| 738 | // } |
|---|
| 739 | TimerTickCount[(int)nID] = (DST_OS_GetTickCount() * 1000) / DST_OS_GetTicksPerSecond(); |
|---|
| 740 | } |
|---|
| 741 | |
|---|
| 742 | void CWindow::KillTimer(char nID) |
|---|
| 743 | { |
|---|
| 744 | TimerTickCount[(int)nID] = 0; |
|---|
| 745 | } |
|---|
| 746 | |
|---|
| 747 | bool CWindow::ProcessTimer() |
|---|
| 748 | { |
|---|
| 749 | for (char i =0; i < TIMER_ID_MAX; i++) |
|---|
| 750 | { |
|---|
| 751 | if (i == 0) // ÀÚ½Ä À©µµ¿ì°¡ ÀÖ´Ù¸é ÀÚ±â ÀÚ½ÅÀÇ Å¸ÀӾƿôÀÌ °è¼Ó ¿¬ÀåµÈ´Ù. |
|---|
| 752 | { |
|---|
| 753 | for (int j = 0; j < WIN_ID_MAX; j++) |
|---|
| 754 | { |
|---|
| 755 | CWindow *pWin = DST_GetWin((WinID)j); |
|---|
| 756 | if (pWin == 0) continue; |
|---|
| 757 | if (pWin->GetParentWinID() != GetWinID()) continue; |
|---|
| 758 | TimerTickCount[0] = (DST_OS_GetTickCount() * 1000) / DST_OS_GetTicksPerSecond(); |
|---|
| 759 | break; |
|---|
| 760 | } |
|---|
| 761 | } |
|---|
| 762 | if (TimerTickCount[(int)i]== 0) continue; |
|---|
| 763 | if (TimerInterval[(int)i]== 0) continue; |
|---|
| 764 | if (TimerTickCount[(int)i] + TimerInterval[(int)i] > ((DST_OS_GetTickCount()*1000)/DST_OS_GetTicksPerSecond())) continue; |
|---|
| 765 | DoOnTimer(i); |
|---|
| 766 | return true; |
|---|
| 767 | } |
|---|
| 768 | return false; |
|---|
| 769 | } |
|---|
| 770 | |
|---|
| 771 | void CWindow::CloseParents(CWindow* pWin) |
|---|
| 772 | { |
|---|
| 773 | CWindow *pWinParent = DST_GetWin(pWin->GetParentWinID()); |
|---|
| 774 | if (pWinParent) |
|---|
| 775 | { |
|---|
| 776 | CloseParents(pWinParent); |
|---|
| 777 | } |
|---|
| 778 | pWin->Close(); |
|---|
| 779 | } |
|---|
| 780 | |
|---|
| 781 | void CWindow::DoOnTimer(char nID) |
|---|
| 782 | { |
|---|
| 783 | if (nID == 0) //0¹ø ŸÀ̸Ӵ À©µµ¿ì ŸÀÓ ¾Æ¿ô ¿ëµµ·Î »ç¿ëÇÑ´Ù. |
|---|
| 784 | { |
|---|
| 785 | CloseParents(this); |
|---|
| 786 | } |
|---|
| 787 | else |
|---|
| 788 | { |
|---|
| 789 | OnTimer(nID); |
|---|
| 790 | if (TimerTickCount[(int)nID] != 0) // KillTimer·Î ÀÌ Å¸À̸Ӹ¦ ²ôÁö ¾Ê¾Ò´Ù¸é ¸®¼Â½ÃŲ´Ù. |
|---|
| 791 | { |
|---|
| 792 | ResetTimer(nID); |
|---|
| 793 | } |
|---|
| 794 | } |
|---|
| 795 | } |
|---|
| 796 | |
|---|
| 797 | void CWindow::SetParentWinID(WinID nID) |
|---|
| 798 | { |
|---|
| 799 | m_WinIDParent = nID; |
|---|
| 800 | } |
|---|
| 801 | |
|---|
| 802 | WinID CWindow::GetParentWinID() |
|---|
| 803 | { |
|---|
| 804 | return m_WinIDParent; |
|---|
| 805 | } |
|---|
| 806 | |
|---|
| 807 | WinID CWindow::GetWinID() |
|---|
| 808 | { |
|---|
| 809 | return (WinID)(eventInit.data[0]); |
|---|
| 810 | } |
|---|
| 811 | |
|---|
| 812 | void CWindow::DoFocus(bool bVal) |
|---|
| 813 | { |
|---|
| 814 | bFocus = bVal; |
|---|
| 815 | Focus(bVal); |
|---|
| 816 | } |
|---|
| 817 | |
|---|
| 818 | void CWindow::SetSize(int x, int y, int w, int h) |
|---|
| 819 | { |
|---|
| 820 | rect.x = x; |
|---|
| 821 | rect.y = y; |
|---|
| 822 | rect.w = w; |
|---|
| 823 | rect.h = h; |
|---|
| 824 | } |
|---|
| 825 | |
|---|
| 826 | int CWindow::GetState() |
|---|
| 827 | { |
|---|
| 828 | return nWinState; |
|---|
| 829 | } |
|---|
| 830 | |
|---|
| 831 | void CWindow::SetState(int n) |
|---|
| 832 | { |
|---|
| 833 | nWinState = n; |
|---|
| 834 | } |
|---|
| 835 | |
|---|
| 836 | void CWindow::DoOnMessage(SWinEventMsg event) |
|---|
| 837 | { |
|---|
| 838 | return OnMessage(event); |
|---|
| 839 | } |
|---|
| 840 | |
|---|
| 841 | void CWindow::DoShow() |
|---|
| 842 | { |
|---|
| 843 | if (rect.w == 0) return; |
|---|
| 844 | if (rect.h == 0) return; |
|---|
| 845 | if (imgBuff != 0) DST_OS_Free(&imgBuff); |
|---|
| 846 | imgBuff = (OSD_PIXEL_T*)DST_OS_Malloc(sizeof(OSD_PIXEL_T) * (rect.w * rect.h)); |
|---|
| 847 | memset(imgBuff, 0, rect.w * rect.h*sizeof(OSD_PIXEL_T)); |
|---|
| 848 | bVisible = true; |
|---|
| 849 | Show(); |
|---|
| 850 | UpdateScreen(); |
|---|
| 851 | } |
|---|
| 852 | |
|---|
| 853 | bool CWindow::GetVisible() |
|---|
| 854 | { |
|---|
| 855 | return bVisible; |
|---|
| 856 | } |
|---|
| 857 | |
|---|
| 858 | void CWindow::FocusToParent() |
|---|
| 859 | { |
|---|
| 860 | FocusToChild(GetParentWinID()); |
|---|
| 861 | } |
|---|
| 862 | |
|---|
| 863 | void CWindow::FocusToChild(WinID nID) |
|---|
| 864 | { |
|---|
| 865 | CWindow *pWin = DST_GetWin(nID); |
|---|
| 866 | if (pWin == 0) return; |
|---|
| 867 | DoFocus(false); |
|---|
| 868 | pWin->DoFocus(true); |
|---|
| 869 | } |
|---|
| 870 | |
|---|
| 871 | void CWindow::setFontStyle(DS_U8 size, DS_U32 color, DS_U8 ver_align, DS_U8 hor_align) |
|---|
| 872 | { |
|---|
| 873 | font.SetHorAlign(hor_align); |
|---|
| 874 | font.SetVerAlign(ver_align); |
|---|
| 875 | font.SetSize(size); |
|---|
| 876 | font.SetColor(CONV32_16(color)); |
|---|
| 877 | } |
|---|
| 878 | |
|---|