| 1 | #ifndef __DST_WINDOW_H__ |
|---|
| 2 | #define __DST_WINDOW_H__ |
|---|
| 3 | |
|---|
| 4 | #include "DST_WinManagerTask.h" |
|---|
| 5 | #include "DST_HostInterface.h" |
|---|
| 6 | #include "DST_WindowEvent.h" |
|---|
| 7 | #include "DST_FontEngine.h" |
|---|
| 8 | |
|---|
| 9 | struct DST_RECT |
|---|
| 10 | { |
|---|
| 11 | int x; |
|---|
| 12 | int y; |
|---|
| 13 | int w; |
|---|
| 14 | int h; |
|---|
| 15 | }; |
|---|
| 16 | |
|---|
| 17 | #define ALIGN_LEFT 0 |
|---|
| 18 | #define ALIGN_CENTER 1 |
|---|
| 19 | #define ALIGN_RIGHT 2 |
|---|
| 20 | #define ALIGN_TOP 0 |
|---|
| 21 | #define ALIGN_MIDDLE 1 |
|---|
| 22 | #define ALIGN_BOTTOM 2 |
|---|
| 23 | |
|---|
| 24 | #define DST_COLOR_BLACK CONV32_16(0xFF000000) |
|---|
| 25 | |
|---|
| 26 | class CFont |
|---|
| 27 | { |
|---|
| 28 | private: |
|---|
| 29 | DS_U8 nSize; |
|---|
| 30 | OSD_PIXEL_T Color; |
|---|
| 31 | DS_U8 hor_align; // (0: Left, 1: Center, 2: Right) |
|---|
| 32 | DS_U8 ver_align; // (0: Top, 1: Middle, 2: Bottom) |
|---|
| 33 | |
|---|
| 34 | int dot1_width; |
|---|
| 35 | int dot2_width; |
|---|
| 36 | int dot3_width; |
|---|
| 37 | public: |
|---|
| 38 | CFont(DS_U8 nSize=15, OSD_PIXEL_T Color=DST_COLOR_BLACK, DS_U8 hor_align = ALIGN_CENTER, DS_U8 ver_align = ALIGN_MIDDLE) |
|---|
| 39 | { |
|---|
| 40 | SetSize(nSize); |
|---|
| 41 | SetColor(Color); //256ÀÌ»óÀÏ °æ¿ì default : white |
|---|
| 42 | SetHorAlign(hor_align); //(0: Left, 1: Center, 2: Right) |
|---|
| 43 | SetVerAlign(ver_align); //(0: Top, 1: Middle, 2: Bottom) |
|---|
| 44 | } |
|---|
| 45 | void SetSize(DS_U8 Size) |
|---|
| 46 | { |
|---|
| 47 | if (Size == nSize) |
|---|
| 48 | return; |
|---|
| 49 | |
|---|
| 50 | nSize = Size; |
|---|
| 51 | dot1_width = DST_GetTextWidth((char*)".", Size); |
|---|
| 52 | dot2_width = DST_GetTextWidth((char*)"..", Size); |
|---|
| 53 | dot3_width = DST_GetTextWidth((char*)"...", Size); |
|---|
| 54 | } |
|---|
| 55 | int GetDot1Width(void) |
|---|
| 56 | { |
|---|
| 57 | return dot1_width; |
|---|
| 58 | } |
|---|
| 59 | |
|---|
| 60 | int GetDot2Width(void) |
|---|
| 61 | { |
|---|
| 62 | return dot2_width; |
|---|
| 63 | } |
|---|
| 64 | |
|---|
| 65 | int GetDot3Width(void) |
|---|
| 66 | { |
|---|
| 67 | return dot3_width; |
|---|
| 68 | } |
|---|
| 69 | |
|---|
| 70 | DS_U8 GetSize() |
|---|
| 71 | { |
|---|
| 72 | if (nSize < 5) return 5; |
|---|
| 73 | return nSize; |
|---|
| 74 | } |
|---|
| 75 | void SetColor(OSD_PIXEL_T nColor) |
|---|
| 76 | { |
|---|
| 77 | Color = nColor; |
|---|
| 78 | } |
|---|
| 79 | OSD_PIXEL_T GetColor() |
|---|
| 80 | { |
|---|
| 81 | return Color; |
|---|
| 82 | } |
|---|
| 83 | void SetHorAlign(DS_U8 hor) |
|---|
| 84 | { |
|---|
| 85 | hor_align = hor; |
|---|
| 86 | } |
|---|
| 87 | DS_U8 GetHorAlign() |
|---|
| 88 | { |
|---|
| 89 | switch (hor_align) |
|---|
| 90 | { |
|---|
| 91 | case ALIGN_LEFT: return ALIGN_LEFT; |
|---|
| 92 | case ALIGN_RIGHT: return ALIGN_RIGHT; |
|---|
| 93 | } |
|---|
| 94 | return ALIGN_CENTER; |
|---|
| 95 | } |
|---|
| 96 | void SetVerAlign(DS_U8 ver) |
|---|
| 97 | { |
|---|
| 98 | ver_align = ver; |
|---|
| 99 | } |
|---|
| 100 | DS_U8 GetVerAlign() |
|---|
| 101 | { |
|---|
| 102 | switch (ver_align) |
|---|
| 103 | { |
|---|
| 104 | case ALIGN_TOP: return ALIGN_TOP; |
|---|
| 105 | case ALIGN_BOTTOM: return ALIGN_BOTTOM; |
|---|
| 106 | } |
|---|
| 107 | return ALIGN_MIDDLE; |
|---|
| 108 | } |
|---|
| 109 | }; |
|---|
| 110 | |
|---|
| 111 | #define TIMER_ID_MAX 6 // ÃÖ´ë ŸÀÌ¸Ó °¹¼ö ¼³Á¤ |
|---|
| 112 | |
|---|
| 113 | class CWindow |
|---|
| 114 | { |
|---|
| 115 | protected: |
|---|
| 116 | // À©µµ ¸Å´ÏÀú °ü·Ã |
|---|
| 117 | char strWinName[32]; // À©µµ¿ìÀÇ À̸§À¸·Î µð¹ö±ë ¿ëµµ |
|---|
| 118 | SWinEventMsg eventInit; // À©µµ¿ì »ý¼º½Ã Àü´ÞµÇ´Â ¸Þ½ÃÁö |
|---|
| 119 | int nWinState; // ÀÌ À©µµ¿ìÀÇ »óÅ·ΠWindow Manager¿¡¼ Á¦¾îÇÔ |
|---|
| 120 | WinID m_WinIDParent; // ºÎ¸ð À©µµ¿ìÀÇ ¾ÆÀ̵ð |
|---|
| 121 | bool bVisible; // Visible ¼Ó¼º |
|---|
| 122 | bool bTransparentWindow; // Åõ¸í À©µÎ¿ì ¿©ºÎ. Åõ¸í»ö ºÎºÐÀº ±×¸®Áö ¾Ê´Â´Ù. |
|---|
| 123 | bool bFocus; // ÇöÀç Focus »óÅÂÀÎÁö ³ªÅ¸³¿. ºÎ¸ð ÀÚ½Ä À©µµ¿ì°£ Åë½Å ¿ëµµ |
|---|
| 124 | // ±×¸®±â °ü·Ã |
|---|
| 125 | DST_RECT rect; // À©µµ¿ìÀÇ Å©±â |
|---|
| 126 | OSD_PIXEL_T *imgBuff; // À©µµ¿ìÀÇ À̹ÌÁö ¹öÆÛ |
|---|
| 127 | // ۰ü·Ã |
|---|
| 128 | bool bRegisterKey[KEY_ID_MAX + 1]; // ƯÁ¤ ۰¡ µî·ÏµÇ¾ú´ÂÁö À¯¹«¸¦ ³ªÅ¸³»´Â ¹è¿ |
|---|
| 129 | DS_U32 nKeyDelay[KEY_ID_MAX + 1]; // ƯÁ¤ ŰÀÇ µô·¹ÀÌ °ª ¹è¿ |
|---|
| 130 | DS_U32 nKeyRepeat[KEY_ID_MAX + 1]; // ƯÁ¤ ŰÀÇ ¸®ÇÍ °ª ¹è¿ |
|---|
| 131 | // ŸÀÌ¸Ó |
|---|
| 132 | DS_U32 TimerTickCount[TIMER_ID_MAX]; // ŸÀ̸Ӱ¡ ½ÃÀÛµÈ ½Ã°£ |
|---|
| 133 | DS_U32 TimerInterval[TIMER_ID_MAX]; // ŸÀÌ¸Ó °£°Ý |
|---|
| 134 | // OSD_PIXEL_T Pallette[256]; |
|---|
| 135 | DS_U8 Brightness; |
|---|
| 136 | CFont font; |
|---|
| 137 | public: |
|---|
| 138 | // »ý¼ºÀÚ ¼Ò¸êÀÚ |
|---|
| 139 | CWindow(SWinEventMsg event); |
|---|
| 140 | virtual ~CWindow() |
|---|
| 141 | { |
|---|
| 142 | if (imgBuff) DST_OS_Free(&imgBuff); |
|---|
| 143 | imgBuff = 0; |
|---|
| 144 | UpdateScreen(); |
|---|
| 145 | } |
|---|
| 146 | // À©µµ ¼Ó¼º |
|---|
| 147 | void SetParentWinID(WinID nID); |
|---|
| 148 | WinID GetParentWinID(); |
|---|
| 149 | WinID GetWinID(); |
|---|
| 150 | |
|---|
| 151 | void SetSize(int x, int y, int w, int h); |
|---|
| 152 | int GetState(); |
|---|
| 153 | void SetState(int n); |
|---|
| 154 | |
|---|
| 155 | void SetWinName(const char* strName); |
|---|
| 156 | void SetTransparent(bool bValue) |
|---|
| 157 | { |
|---|
| 158 | bTransparentWindow = bValue; |
|---|
| 159 | } |
|---|
| 160 | bool GetTransparent() |
|---|
| 161 | { |
|---|
| 162 | return bTransparentWindow; |
|---|
| 163 | } |
|---|
| 164 | // Message |
|---|
| 165 | void DoOnMessage(SWinEventMsg event); |
|---|
| 166 | virtual void OnMessage(SWinEventMsg /*event*/){} |
|---|
| 167 | // Show |
|---|
| 168 | void DoShow(); |
|---|
| 169 | virtual void Show() {} |
|---|
| 170 | virtual void Show(WinID) {} |
|---|
| 171 | // Hide |
|---|
| 172 | virtual void Hide(WinID) {} |
|---|
| 173 | // Remove |
|---|
| 174 | void Close(); // ÀÌ À©µµ¿ì¸¦ ´Ý°íÀÚ ÇÒ ¶§ È£Ãâ |
|---|
| 175 | void CloseParents(CWindow* pWin); // ÀÚ±â ÀÚ½ÅÀ» Æ÷ÇÔÇÑ ¸ðµç Á¶»ó À©µµ¿ì¸¦ ´Ý´Â´Ù. |
|---|
| 176 | |
|---|
| 177 | // À©µµ¿ì À§Ä¡ ¹× º¸ÀÌ´Â ¼Ó¼º Á¦¾î |
|---|
| 178 | void SetVisible(bool bValue); |
|---|
| 179 | bool GetVisible(); |
|---|
| 180 | void Move(int x, int y); |
|---|
| 181 | |
|---|
| 182 | // Æ÷Ä¿½º °ü·Ã |
|---|
| 183 | void FocusToParent(); |
|---|
| 184 | void FocusToChild(WinID nID); |
|---|
| 185 | void DoFocus(bool bFocus); |
|---|
| 186 | virtual void Focus(bool /*bFocus*/){} |
|---|
| 187 | |
|---|
| 188 | // ±×¸®±â |
|---|
| 189 | DST_RECT GetSize() { return rect; } |
|---|
| 190 | OSD_PIXEL_T *GetImgBuff(); |
|---|
| 191 | void UpdateScreen(); |
|---|
| 192 | void UpdateScreen(int x, int y, int w, int h); |
|---|
| 193 | void DrawPixel(int x, int y, OSD_PIXEL_T color); |
|---|
| 194 | void DrawBox32(int x, int y, int w, int h, OSD_PIXEL_T color); |
|---|
| 195 | void DrawImage(int x, int y, DS_U8 *image, bool bProcessTransparent = false); |
|---|
| 196 | void DrawImage1(int x, int y, DS_U8 *image, bool bProcessTransparent); |
|---|
| 197 | void DrawImage4(int x, int y, DS_U8 *image, bool bProcessTransparent); |
|---|
| 198 | void DrawImage5(int x, int y, DS_U8 *image, bool bProcessTransparent); |
|---|
| 199 | void DrawImage6(int x, int y, DS_U8 *image, bool bProcessTransparent); |
|---|
| 200 | void setFontStyle(DS_U8 size, DS_U32 color, DS_U8 ver_align, DS_U8 hor_align); |
|---|
| 201 | |
|---|
| 202 | // ¹®ÀÚÃâ·Â |
|---|
| 203 | void DrawText(int x, int y, int w, int h, char *strText, CFont* font); |
|---|
| 204 | void DrawTextUTF8(int start_x, int start_y, int width, int height, DS_U8* strText, CFont* font); |
|---|
| 205 | void DrawTextUni(int x, int y, int w, int h, DS_U16* strText, CFont* font); |
|---|
| 206 | void DrawText32(int start_x, int start_y, int width, int height, DS_U32* strText, CFont* font); |
|---|
| 207 | |
|---|
| 208 | // Ű |
|---|
| 209 | void RegisterAllKey(); |
|---|
| 210 | void UnRegisterAllKey(); |
|---|
| 211 | void RegisterAllNumKey(); |
|---|
| 212 | void UnRegisterAllNumKey(); |
|---|
| 213 | void RegisterKey(DS_U8 nKeyCode, bool bState, int nDelay = 0, int nRepeat = 0); |
|---|
| 214 | bool IsRegisterKey(DS_U8 nKeyCode); |
|---|
| 215 | DS_U32 GetKeyDelay(DS_U8 KeyCode) |
|---|
| 216 | { |
|---|
| 217 | return nKeyDelay[KeyCode]; |
|---|
| 218 | } |
|---|
| 219 | DS_U32 GetKeyRepeat(DS_U8 KeyCode) |
|---|
| 220 | { |
|---|
| 221 | return nKeyRepeat[KeyCode]; |
|---|
| 222 | } |
|---|
| 223 | virtual void KeyInput(DS_U8 /*key*/, bool /*bRepeat*/){} |
|---|
| 224 | |
|---|
| 225 | // ŸÀӾƿô ŸÀÌ¸Ó |
|---|
| 226 | void SetTimeOut(int nSecond); |
|---|
| 227 | DS_U32 GetTimeOut(); |
|---|
| 228 | void SetTimer(char nID, int ms); |
|---|
| 229 | void ResetTimer(char nID); |
|---|
| 230 | void KillTimer(char nID); |
|---|
| 231 | bool ProcessTimer(); |
|---|
| 232 | void DoOnTimer(char nID); |
|---|
| 233 | virtual void OnTimer(char /*nID*/) {} |
|---|
| 234 | DS_U8 GetBrightness() |
|---|
| 235 | { |
|---|
| 236 | return Brightness; |
|---|
| 237 | } |
|---|
| 238 | void SetBrightness(DS_U8 nVal) |
|---|
| 239 | { |
|---|
| 240 | Brightness = (nVal < 100) ? nVal : 100; |
|---|
| 241 | } |
|---|
| 242 | }; |
|---|
| 243 | |
|---|
| 244 | #endif |
|---|