source: svn/trunk/zasc/app_c/DST_Window.h @ 27

Last change on this file since 27 was 2, checked in by jglee, 11 years ago

first commit

File size: 14.4 KB
Line 
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
9typedef struct 
10{
11        int       x;
12        int       y;
13        int       w;
14        int       h;
15} DST_RECT;
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#if 1
27typedef struct
28{
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        int dot1_width;
34        int dot2_width;
35        int dot3_width;
36} CFont;
37#else
38class CFont
39{
40private:
41        DS_U8 nSize;
42        OSD_PIXEL_T Color;
43        DS_U8 hor_align; // (0: Left, 1: Center, 2: Right)
44        DS_U8 ver_align; // (0: Top, 1: Middle, 2: Bottom)
45
46        int dot1_width;
47        int dot2_width;
48        int dot3_width;
49public:
50        CFont(DS_U8 nSize=15, OSD_PIXEL_T Color=DST_COLOR_BLACK, DS_U8 hor_align = ALIGN_CENTER, DS_U8 ver_align = ALIGN_MIDDLE)
51        {
52                SetSize(nSize);
53                SetColor(Color);                //256ÀÌ»óÀÏ °æ¿ì default : white
54                SetHorAlign(hor_align);         //(0: Left, 1: Center, 2: Right)
55                SetVerAlign(ver_align);         //(0: Top, 1: Middle, 2: Bottom)
56        }
57        void SetSize(DS_U8 Size)
58        {
59            if (Size == nSize)
60                return;
61
62                nSize = Size;
63            dot1_width = DST_GetTextWidth((char*)".", Size);
64            dot2_width = DST_GetTextWidth((char*)"..", Size);
65            dot3_width = DST_GetTextWidth((char*)"...", Size);
66        }
67        int GetDot1Width(void)
68        {
69            return dot1_width;
70        }
71
72        int GetDot2Width(void)
73        {
74            return dot2_width;
75        }
76
77        int GetDot3Width(void)
78        {
79            return dot3_width;
80        }
81
82        DS_U8 GetSize()
83        {
84                if (nSize < 5) return 5;
85                return nSize;
86        }
87        void SetColor(OSD_PIXEL_T nColor)
88        {
89                Color = nColor;
90        }
91        OSD_PIXEL_T GetColor()
92        {
93                return Color;
94        }
95        void SetHorAlign(DS_U8 hor)
96        {
97                hor_align = hor;
98        }
99        DS_U8 GetHorAlign()
100        {
101                switch (hor_align)
102                {
103                        case ALIGN_LEFT: return ALIGN_LEFT;
104                        case ALIGN_RIGHT: return ALIGN_RIGHT;
105                }
106                return ALIGN_CENTER;
107        }
108        void SetVerAlign(DS_U8 ver)
109        {
110                ver_align = ver;
111        }
112        DS_U8 GetVerAlign()
113        {
114                switch (ver_align)
115                {
116                        case ALIGN_TOP: return ALIGN_TOP;
117                        case ALIGN_BOTTOM: return ALIGN_BOTTOM;
118                }
119                return ALIGN_MIDDLE;
120        }
121};
122#endif
123
124#define TIMER_ID_MAX    6 // ÃÖ´ë ŸÀÌ¸Ó °¹¼ö ¼³Á¤
125
126#if 1
127
128typedef struct _CWINDOW CWindow;
129
130typedef void (*CFONT_CFont)(CWindow* this, DS_U8 nSize, OSD_PIXEL_T Color, DS_U8 hor_align, DS_U8 ver_align);
131typedef void (*CFONT_SetSize)(CWindow* this, DS_U8 Size);
132typedef int (*CFONT_GetDot1Width)(CWindow* this);
133typedef int (*CFONT_GetDot2Width)(CWindow* this);
134typedef int (*CFONT_GetDot3Width)(CWindow* this);
135typedef DS_U8 (*CFONT_GetSize)(CWindow* this);
136typedef void (*CFONT_SetColor)(CWindow* this, OSD_PIXEL_T nColor);
137typedef OSD_PIXEL_T (*CFONT_GetColor)(CWindow* this);
138typedef void (*CFONT_SetHorAlign)(CWindow* this, DS_U8 hor);
139typedef DS_U8 (*CFONT_GetHorAlign)(CWindow* this);
140typedef void (*CFONT_SetVerAlign)(CWindow* this, DS_U8 ver);
141typedef DS_U8 (*CFONT_GetVerAlign)(CWindow* this);
142
143typedef void (*Window_Constructor) (CWindow* this, SWinEventMsg event);
144typedef void (*Window_Destructor) (CWindow* this);             
145typedef void (*Window_SetParentWinID) (CWindow* this, WinID nID);
146typedef WinID (*Window_GetParentWinID) (CWindow* this);         
147typedef WinID (*Window_GetWinID) (CWindow* this);       
148typedef void (*Window_SetSize) (CWindow* this, int x, int y, int w, int h);             
149typedef int (*Window_GetState)(CWindow* this);
150typedef void (*Window_SetState)(CWindow* this, int n);
151
152typedef void (*Window_SetWinName)(CWindow* this, const char* strName);
153typedef void (*Window_SetTransparent)(CWindow* this, bool bValue);
154typedef bool (*Window_GetTransparent)(CWindow* this);
155        // Message
156typedef void (*Window_DoOnMessage)(CWindow* this, SWinEventMsg event);
157typedef void (*Window_OnMessage)(CWindow* this, SWinEventMsg event);
158        // Show
159typedef void (*Window_DoShow)(CWindow* this);
160typedef void (*Window_Show)(CWindow* this);
161typedef void (*Window_ShowWindow)(CWindow* this, WinID);
162        // Hide
163typedef void (*Window_Hide)(CWindow* this, WinID);
164        // Remove
165typedef void (*Window_Close)(CWindow* this); // ÀÌ À©µµ¿ì¸¦ ´Ý°íÀÚ ÇÒ ¶§ È£Ãâ
166typedef void (*Window_CloseParents)(CWindow* this, CWindow* pWin); // ÀÚ±â ÀÚ½ÅÀ» Æ÷ÇÔÇÑ ¸ðµç Á¶»ó À©µµ¿ì¸¦ ´Ý´Â´Ù.
167
168        // À©µµ¿ì À§Ä¡ ¹× º¸ÀÌ´Â ¼Ó¼º Á¦¾î
169typedef void (*Window_SetVisible)(CWindow* this, bool bValue);
170typedef bool (*Window_GetVisible)(CWindow* this);
171typedef void (*Window_Move)(CWindow* this, int x, int y);
172
173        // Æ÷Ä¿½º °ü·Ã
174typedef void (*Window_FocusToParent)(CWindow* this);
175typedef void (*Window_FocusToChild)(CWindow* this, WinID nID);
176typedef void (*Window_DoFocus)(CWindow* this, bool bFocus);
177typedef void (*Window_Focus)(CWindow* this, bool bFocus);
178
179        // ±×¸®±â
180typedef DST_RECT (*Window_GetSize)(CWindow* this);
181typedef OSD_PIXEL_T *(*Window_GetImgBuff)(CWindow* this);
182typedef void (*Window_UpdateScreen)(CWindow* this);
183typedef void (*Window_UpdateScreenEx)(CWindow* this, int x, int y, int w, int h);
184typedef void (*Window_DrawPixel)(CWindow* this, int x, int y, OSD_PIXEL_T color);
185typedef void (*Window_DrawBox32)(CWindow* this, int x, int y, int w, int h, OSD_PIXEL_T color);
186typedef void (*Window_DrawImage)(CWindow* this, int x, int y, DS_U8 *image, bool bProcessTransparent);
187//typedef void (*Window_DrawImage1)(CWindow* this, int x, int y, DS_U8 *image, bool bProcessTransparent);
188//typedef void (*Window_DrawImage4)(CWindow* this, int x, int y, DS_U8 *image, bool bProcessTransparent);
189//typedef void (*Window_DrawImage5)(CWindow* this, int x, int y, DS_U8 *image, bool bProcessTransparent);
190//typedef void (*Window_DrawImage6)(CWindow* this, int x, int y, DS_U8 *image, bool bProcessTransparent);
191typedef void (*Window_setFontStyle)(CWindow* this, DS_U8 size, DS_U32 color, DS_U8 ver_align, DS_U8 hor_align);
192       
193        // ¹®ÀÚÃâ·Â
194typedef void (*Window_DrawText)(CWindow* this, int x, int y, int w, int h, char *strText, CFont* font);
195typedef void (*Window_DrawTextUTF8)(CWindow* this, int start_x, int start_y, int width, int height, DS_U8* strText, CFont* font);
196typedef void (*Window_DrawTextUni)(CWindow* this, int x, int y, int w, int h, DS_U16* strText, CFont* font);
197typedef void (*Window_DrawText32)(CWindow* this, int start_x, int start_y, int width, int height, DS_U32* strText, CFont* font);
198
199        // Ű
200typedef void (*Window_RegisterAllKey)(CWindow* this);
201typedef void (*Window_UnRegisterAllKey)(CWindow* this);
202typedef void (*Window_RegisterAllNumKey)(CWindow* this);
203typedef void (*Window_UnRegisterAllNumKey)(CWindow* this);
204typedef void (*Window_RegisterKey)(CWindow* this, DS_U8 nKeyCode, bool bState, int nDelay, int nRepeat);
205typedef bool (*Window_IsRegisterKey)(CWindow* this, DS_U8 nKeyCode);
206typedef DS_U32 (*Window_GetKeyDelay)(CWindow* this, DS_U8 KeyCode);
207typedef DS_U32 (*Window_GetKeyRepeat)(CWindow* this, DS_U8 KeyCode);
208typedef void (*Window_KeyInput)(CWindow* this, DS_U8 /*key*/, bool /*bRepeat*/);
209
210        // ŸÀӾƿô ŸÀ̸Ó
211typedef void (*Window_SetTimeOut)(CWindow* this, int nSecond);
212typedef DS_U32 (*Window_GetTimeOut)(CWindow* this);
213typedef void (*Window_SetTimer)(CWindow* this, char nID, int ms);
214typedef void (*Window_ResetTimer)(CWindow* this, char nID);
215typedef void (*Window_KillTimer)(CWindow* this, char nID);
216typedef bool (*Window_ProcessTimer)(CWindow* this);
217typedef void (*Window_DoOnTimer)(CWindow* this, char nID);
218typedef void (*Window_OnTimer)(CWindow* this, char /*nID*/);
219
220
221struct _CWINDOW
222{
223        // À©µµ ¸Å´ÏÀú °ü·Ã
224        char strWinName[32]; // À©µµ¿ìÀÇ À̸§À¸·Î µð¹ö±ë ¿ëµµ
225        SWinEventMsg eventInit; // À©µµ¿ì »ý¼º½Ã Àü´ÞµÇ´Â ¸Þ½ÃÁö
226        int nWinState; // ÀÌ À©µµ¿ìÀÇ »óÅ·ΠWindow Manager¿¡¼­ Á¦¾îÇÔ
227        WinID   m_WinIDParent; // ºÎ¸ð À©µµ¿ìÀÇ ¾ÆÀ̵ð
228        bool bVisible; // Visible ¼Ó¼º
229        bool bTransparentWindow; // Åõ¸í À©µÎ¿ì ¿©ºÎ. Åõ¸í»ö ºÎºÐÀº ±×¸®Áö ¾Ê´Â´Ù.
230        bool bFocus; // ÇöÀç Focus »óÅÂÀÎÁö ³ªÅ¸³¿. ºÎ¸ð ÀÚ½Ä À©µµ¿ì°£ Åë½Å ¿ëµµ
231        // ±×¸®±â °ü·Ã
232        DST_RECT rect; // À©µµ¿ìÀÇ Å©±â
233        OSD_PIXEL_T *imgBuff; // À©µµ¿ìÀÇ À̹ÌÁö ¹öÆÛ
234        // ۰ü·Ã
235        bool bRegisterKey[KEY_ID_MAX + 1]; // ƯÁ¤ ۰¡ µî·ÏµÇ¾ú´ÂÁö À¯¹«¸¦ ³ªÅ¸³»´Â ¹è¿­
236        DS_U32 nKeyDelay[KEY_ID_MAX + 1]; // ƯÁ¤ ŰÀÇ µô·¹ÀÌ °ª ¹è¿­
237        DS_U32 nKeyRepeat[KEY_ID_MAX + 1]; // ƯÁ¤ ŰÀÇ ¸®ÇÍ °ª ¹è¿­
238        // ŸÀ̸Ó
239        DS_U32 TimerTickCount[TIMER_ID_MAX]; // ŸÀ̸Ӱ¡ ½ÃÀÛµÈ ½Ã°£
240        DS_U32 TimerInterval[TIMER_ID_MAX]; // ŸÀÌ¸Ó °£°Ý
241//      OSD_PIXEL_T Pallette[256];
242        CFont font;
243       
244        //struct Class_Window *pParent;
245       
246        CFONT_CFont FontFont; // ÃʱâÈ­
247        CFONT_SetSize FontSetSize;
248        CFONT_GetDot1Width FontGetDot1Width;
249        CFONT_GetDot2Width FontGetDot2Width;
250        CFONT_GetDot3Width FontGetDot3Width;
251        CFONT_GetSize FontGetSize;
252        CFONT_SetColor FontSetColor;
253        CFONT_GetColor FontGetColor;
254        CFONT_SetHorAlign FontSetHorAlign;
255        CFONT_GetHorAlign FontGetHorAlign;
256        CFONT_SetVerAlign FontSetVerAlign;
257        CFONT_GetVerAlign FontGetVerAlign;
258       
259        Window_Constructor Constructor;
260        Window_Destructor Destructor; // CWindow ÆÄ»ý Ŭ·¡½ºÀÇ ¼Ò¸êÀÚ
261        Window_Destructor DestructorMother; // CwindowÀÇ ¼Ò¸êÀÚ
262        Window_SetParentWinID SetParentWinID;
263        Window_GetParentWinID GetParentWinID;
264        Window_GetWinID GetWinID;
265        Window_SetSize SetSize;
266        Window_GetState GetState;
267        Window_SetState SetState;
268        Window_SetWinName SetWinName;
269        Window_SetTransparent SetTransparent;
270        Window_GetTransparent GetTransparent;
271        Window_DoOnMessage DoOnMessage;
272        Window_OnMessage OnMessage;
273        Window_DoShow DoShow;
274        Window_Show Show;
275        Window_ShowWindow ShowWindow;
276        Window_Hide Hide;
277        Window_Close Close;
278        Window_CloseParents CloseParents;
279        Window_SetVisible SetVisible;
280        Window_GetVisible GetVisible;
281        Window_Move Move;
282        Window_FocusToParent FocusToParent;
283        Window_FocusToChild FocusToChild;
284        Window_DoFocus DoFocus;
285        Window_Focus Focus;
286        Window_GetSize GetSize;
287        Window_GetImgBuff GetImgBuff;
288        Window_UpdateScreen UpdateScreen;
289        Window_UpdateScreenEx UpdateScreenEx;
290        Window_DrawPixel DrawPixel;
291        Window_DrawBox32 DrawBox32;
292        Window_DrawImage DrawImage;
293//      Window_DrawImage1 DrawImage1;
294//      Window_DrawImage4 DrawImage4;
295//      Window_DrawImage5 DrawImage5;
296//      Window_DrawImage6 DrawImage6;
297        Window_setFontStyle setFontStyle;
298        Window_DrawText DrawText;
299        Window_DrawTextUTF8 DrawTextUTF8;
300        Window_DrawTextUni DrawTextUni;
301        Window_DrawText32 DrawText32;
302        Window_RegisterAllKey RegisterAllKey;
303        Window_UnRegisterAllKey UnRegisterAllKey;
304//      Window_RegisterAllNumKey RegisterAllNumKey;
305//      Window_UnRegisterAllNumKey UnRegisterAllNumKey;
306        Window_RegisterKey RegisterKey;
307        Window_IsRegisterKey IsRegisterKey;
308        Window_GetKeyDelay GetKeyDelay;
309        Window_GetKeyRepeat GetKeyRepeat;
310        Window_KeyInput KeyInput;
311        Window_SetTimeOut SetTimeOut;
312        Window_GetTimeOut GetTimeOut;
313        Window_SetTimer SetTimer;
314        Window_ResetTimer ResetTimer;
315        Window_KillTimer KillTimer;
316        Window_ProcessTimer ProcessTimer;
317        Window_DoOnTimer DoOnTimer;
318        Window_OnTimer OnTimer;
319       
320}; 
321
322// ±âº» À©µµ¿ì¸¦ »ý¼ºÇÑ´Ù.
323CWindow* NewCWindow(SWinEventMsg event);
324// À©µµ¿ì¸¦ Á¦°ÅÇÑ´Ù.
325void DeleteCWindow(CWindow*pWin);
326
327#else
328class CWindow
329{
330protected:
331        // À©µµ ¸Å´ÏÀú °ü·Ã
332        char strWinName[32]; // À©µµ¿ìÀÇ À̸§À¸·Î µð¹ö±ë ¿ëµµ
333        SWinEventMsg eventInit; // À©µµ¿ì »ý¼º½Ã Àü´ÞµÇ´Â ¸Þ½ÃÁö
334        int nWinState; // ÀÌ À©µµ¿ìÀÇ »óÅ·ΠWindow Manager¿¡¼­ Á¦¾îÇÔ
335        WinID   m_WinIDParent; // ºÎ¸ð À©µµ¿ìÀÇ ¾ÆÀ̵ð
336        bool bVisible; // Visible ¼Ó¼º
337        bool bTransparentWindow; // Åõ¸í À©µÎ¿ì ¿©ºÎ. Åõ¸í»ö ºÎºÐÀº ±×¸®Áö ¾Ê´Â´Ù.
338        bool bFocus; // ÇöÀç Focus »óÅÂÀÎÁö ³ªÅ¸³¿. ºÎ¸ð ÀÚ½Ä À©µµ¿ì°£ Åë½Å ¿ëµµ
339        // ±×¸®±â °ü·Ã
340        DST_RECT rect; // À©µµ¿ìÀÇ Å©±â
341        OSD_PIXEL_T *imgBuff; // À©µµ¿ìÀÇ À̹ÌÁö ¹öÆÛ
342        // ۰ü·Ã
343        bool bRegisterKey[KEY_ID_MAX + 1]; // ƯÁ¤ ۰¡ µî·ÏµÇ¾ú´ÂÁö À¯¹«¸¦ ³ªÅ¸³»´Â ¹è¿­
344        DS_U32 nKeyDelay[KEY_ID_MAX + 1]; // ƯÁ¤ ŰÀÇ µô·¹ÀÌ °ª ¹è¿­
345        DS_U32 nKeyRepeat[KEY_ID_MAX + 1]; // ƯÁ¤ ŰÀÇ ¸®ÇÍ °ª ¹è¿­
346        // ŸÀ̸Ó
347        DS_U32 TimerTickCount[TIMER_ID_MAX]; // ŸÀ̸Ӱ¡ ½ÃÀÛµÈ ½Ã°£
348        DS_U32 TimerInterval[TIMER_ID_MAX]; // ŸÀÌ¸Ó °£°Ý
349//      OSD_PIXEL_T Pallette[256];
350        CFont font;
351public:
352        // »ý¼ºÀÚ ¼Ò¸êÀÚ
353        CWindow(SWinEventMsg event);
354        virtual ~CWindow()
355        {
356                if (imgBuff) DST_OS_Free(&imgBuff);
357                imgBuff = 0;
358                UpdateScreen();
359        }
360        // À©µµ ¼Ó¼º
361        void SetParentWinID(WinID nID);
362        WinID GetParentWinID();
363        WinID GetWinID();
364
365        void SetSize(int x, int y, int w, int h);
366        int GetState();
367        void SetState(int n);
368
369        void SetWinName(const char* strName);
370        void SetTransparent(bool bValue)
371        {
372                bTransparentWindow = bValue;
373        }
374        bool GetTransparent()
375        {
376                return bTransparentWindow;
377        }
378        // Message
379        void DoOnMessage(SWinEventMsg event);
380        virtual void OnMessage(SWinEventMsg /*event*/){}
381        // Show
382        void DoShow();
383        virtual void Show() {}
384        virtual void Show(WinID) {}
385        // Hide
386        virtual void Hide(WinID) {}
387        // Remove
388        void Close(); // ÀÌ À©µµ¿ì¸¦ ´Ý°íÀÚ ÇÒ ¶§ È£Ãâ
389        void CloseParents(CWindow* pWin); // ÀÚ±â ÀÚ½ÅÀ» Æ÷ÇÔÇÑ ¸ðµç Á¶»ó À©µµ¿ì¸¦ ´Ý´Â´Ù.
390
391        // À©µµ¿ì À§Ä¡ ¹× º¸ÀÌ´Â ¼Ó¼º Á¦¾î
392        void SetVisible(bool bValue);
393        bool GetVisible();
394        void Move(int x, int y);
395
396        // Æ÷Ä¿½º °ü·Ã
397        void FocusToParent();
398        void FocusToChild(WinID nID);
399        void DoFocus(bool bFocus);
400        virtual void Focus(bool /*bFocus*/){}
401
402        // ±×¸®±â
403        DST_RECT GetSize() { return rect; }
404        OSD_PIXEL_T *GetImgBuff();
405        void UpdateScreen();
406        void UpdateScreen(int x, int y, int w, int h);
407        void DrawPixel(int x, int y, OSD_PIXEL_T color);
408        void DrawBox32(int x, int y, int w, int h, OSD_PIXEL_T color);
409        void DrawImage(int x, int y, DS_U8 *image, bool bProcessTransparent = false);
410        void DrawImage1(int x, int y, DS_U8 *image, bool bProcessTransparent);
411        void DrawImage4(int x, int y, DS_U8 *image, bool bProcessTransparent);
412        void DrawImage5(int x, int y, DS_U8 *image, bool bProcessTransparent);
413        void DrawImage6(int x, int y, DS_U8 *image, bool bProcessTransparent);
414        void setFontStyle(DS_U8 size, DS_U32 color, DS_U8 ver_align, DS_U8 hor_align);
415       
416        // ¹®ÀÚÃâ·Â
417        void DrawText(int x, int y, int w, int h, char *strText, CFont* font);
418        void DrawTextUTF8(int start_x, int start_y, int width, int height, DS_U8* strText, CFont* font);
419        void DrawTextUni(int x, int y, int w, int h, DS_U16* strText, CFont* font);
420        void DrawText32(int start_x, int start_y, int width, int height, DS_U32* strText, CFont* font);
421
422        // Ű
423        void RegisterAllKey();
424        void UnRegisterAllKey();
425        void RegisterAllNumKey();
426  void UnRegisterAllNumKey();
427        void RegisterKey(DS_U8 nKeyCode, bool bState, int nDelay = 0, int nRepeat = 0);
428        bool IsRegisterKey(DS_U8 nKeyCode);
429        DS_U32 GetKeyDelay(DS_U8 KeyCode)
430        {
431                return nKeyDelay[KeyCode];
432        }
433        DS_U32 GetKeyRepeat(DS_U8 KeyCode)
434        {
435                return nKeyRepeat[KeyCode];
436        }
437        virtual void KeyInput(DS_U8 /*key*/, bool /*bRepeat*/){}
438
439        // ŸÀӾƿô ŸÀ̸Ó
440        void SetTimeOut(int nSecond);
441        DS_U32 GetTimeOut();
442        void SetTimer(char nID, int ms);
443        void ResetTimer(char nID);
444        void KillTimer(char nID);
445        bool ProcessTimer();
446        void DoOnTimer(char nID);
447        virtual void OnTimer(char /*nID*/) {}
448};
449#endif
450
451#endif
Note: See TracBrowser for help on using the repository browser.