source: svn/trunk/zasc/app/DST_WinDebugSQL.cpp @ 22

Last change on this file since 22 was 2, checked in by phkim, 11 years ago

1.phkim

  1. revision copy newcon3sk r27
  • Property svn:executable set to *
File size: 17.6 KB
Line 
1#include "DST_WinManager.h"
2#include "DST_OSDImage.h"
3#include "DST_UserInterface.h"
4#include "DST_DataStrings.h"
5#include "DST_DB_Engine.h"
6
7#if 0
8____CPowerDownCautionWin___()
9#endif
10
11struct DBNAMES
12{
13        char* name;
14};
15
16struct ATTRIBUTES
17{
18        DS_U8 type;
19        char* name;
20};
21
22char * g_name;
23
24class CDebugSQLWin : public CWindow
25{
26private:
27        DS_U16 Pos;
28        DS_U16 Top;
29        DS_U16 Select;
30        DS_U16 ListNum;
31        DS_U16 ItemNum;
32
33        DS_U16 pre_Pos;
34        DS_U16 pre_Top;
35        DS_U16 pre_Select;
36        DS_U16 pre_ListNum;
37        DS_U16 pre_ItemNum;
38
39        DBNAMES* names;
40public:
41        CDebugSQLWin(SWinEventMsg event):CWindow(event)
42        {
43                InitValues();
44                rect.w = 576;
45                rect.h = 384;
46                rect.x = (DST_GetScreenWidth() - rect.w) / 2;
47                rect.y = (DST_GetScreenHeight() - rect.h) / 2;
48
49                SetTimeOut(0);
50
51                RegisterKey(VK_CANCEL, true);
52                RegisterKey(VK_PREV, true);
53                RegisterKey(VK_PREV_MENU, true);
54                RegisterKey(VK_OK, true);
55                RegisterKey(VK_RIGHT, true);
56                RegisterKey(VK_LEFT, true);
57                RegisterKey(VK_UP, true);
58                RegisterKey(VK_DN, true);
59        }
60
61        virtual ~CDebugSQLWin()
62        {
63                if (names) 
64                {
65                        for (int i = 0; i < ItemNum; i++) if (names[i].name) DST_OS_Free(&names[i].name);
66                        DST_OS_Free(&names);
67                }
68
69        }
70       
71        void InitValues(void)
72        {               
73                names = 0;
74                Pos = 0;
75                Top = 0;
76                Select = 0;
77                ListNum = 30;
78                ItemNum = 0;
79
80                pre_Pos = Pos;
81                pre_Top = Top;
82                pre_Select = Select;
83                pre_ListNum = ListNum;
84                pre_ItemNum = ItemNum;
85               
86                UpdateList();
87                if (ItemNum < ListNum) ListNum = ItemNum;
88        }
89        void UpdateList(void)
90        {
91                if (names) 
92                {
93                        for (int i = 0; i < ItemNum; i++) if (names[i].name) DST_OS_Free(&names[i].name);
94                        DST_OS_Free(&names);
95                }
96                names = GetDBTableName(&ItemNum);       
97        }
98       
99
100        DBNAMES* GetDBTableName(DS_U16 *size)
101        {
102
103                CDB db;
104                db.GetTable("SELECT name FROM sqlite_master where type='table' order by name");
105                *size = db.GetRow();
106                if (*size < 1) return 0;
107                DBNAMES* n = (DBNAMES *)DST_OS_Calloc(sizeof(DBNAMES), *size);
108//              DST_Printf("size = %d\n\n\n",*size);
109                for (int i = 0; i < *size; i++)
110                {
111                        int nLen = strlen(db.GetResult((i+1)*db.GetCol()+0));
112                        n[i].name = 0;
113                        n[i].name = (char*)DST_OS_Calloc((nLen+1)*sizeof(char),1);
114                        memcpy(n[i].name,db.GetResult((i+1)*db.GetCol()+0),nLen);
115                       
116//                      DST_Printf("nLen=%d  ",nLen);
117//                      DST_Printf("n[%d].name=%s\n",i,n[i].name);
118                }
119                return n;
120        }
121
122        virtual void Show(WinID id)
123        {
124//              DST_Printf("id=%d\n",id);
125//              switch(id)
126//              {
127//                      case WIN_ERROR:
128//                      case WIN_POWER_DOWN_CAUTION:
129//                              break;
130//                      default:
131//                              KillTimer(1);
132//                              Close();
133//                              break;
134//              }
135        }
136
137        virtual void Show()
138        {
139                DrawAll();
140
141        }       
142
143        void DrawAll()
144        {
145                setFontStyle(15, 0xAAC8C8C8, ALIGN_MIDDLE,ALIGN_CENTER);
146
147                DrawBox32(0, 0, rect.w, rect.h, CONV32_16(0xAA262626));
148
149                for(int x=0;x<3;x++)
150                {
151                        for(int y=0;y<10;y++)
152                        {
153                                if(ItemNum > y+x*10)
154                                {
155                                        if(Select+Top == y+x*10)
156                                                DrawBox32(2+x*192, 84+2+y*30, 192-4, 30-4, CONV32_16(0xAA1C3923));
157                                        else
158                                                DrawBox32(2+x*192, 84+2+y*30, 192-4, 30-4, CONV32_16(0xAAFFA52C));
159                                        DrawText(2+x*192, 84+2+y*30, 192-4, 30-4,names[y+x*10].name,&font);
160//                                      DST_Printf("n[%d].name=%s\n",y+x*10,names[y+x*10].name);
161                                       
162                                }
163                        }
164                }
165               
166        }
167
168        void Draw()
169        {
170                setFontStyle(15, 0xAAC8C8C8, ALIGN_MIDDLE,ALIGN_CENTER);
171
172
173                for(int x=0;x<3;x++)
174                {
175                        for(int y=0;y<10;y++)
176                        {
177                                if(ItemNum > y+x*10)
178                                {
179                                        if(Select+Top == y+x*10)
180                                                DrawBox32(2+x*192, 84+2+y*30, 192-4, 30-4, CONV32_16(0xAA1C3923));
181                                        else
182                                                DrawBox32(2+x*192, 84+2+y*30, 192-4, 30-4, CONV32_16(0xAAFFA52C));
183                                        DrawText(2+x*192, 84+2+y*30, 192-4, 30-4,names[y+x*10].name,&font);
184                                }
185                        }
186                }
187               
188        }
189               
190        virtual void OnTimer(char nID)
191        {
192                switch(nID)
193                {
194                        case 1:
195                                break;
196                }
197        }       
198
199        virtual void KeyInput(DS_U8 key,bool)
200        {
201                switch(key)
202                {
203                        case VK_PREV:
204                        case VK_PREV_MENU:
205                        case VK_CANCEL: 
206                                if (DST_GetWin(WIN_ENGINEER_MODE)==0) DST_CreateWin(WIN_ENGINEER_MODE);
207                                Close();
208                                break;
209                        case VK_OK: 
210//                              if(g_name) DST_OS_Free(&g_name);
211                                g_name = names[Select+Top].name;
212                                DST_CreateWin(WIN_DEBUG_SQL_SUB);
213                                SetVisible(false);
214                                break;
215                        case VK_RIGHT: break;
216                        case VK_LEFT: break;
217                        case VK_UP:
218                        case VK_DN:
219                                if(key == VK_DN)
220                                        ItemIncrease(ItemNum, ListNum, &Top, &Select, &Pos);
221                                else
222                                        ItemDecrease(ItemNum, ListNum, &Top, &Select, &Pos);
223                                Draw();
224                                break;
225
226                }
227        }
228};
229
230
231void DST_CreateDebugSQLWin(SWinEventMsg event)
232{
233        DST_AddWin((WinID)(event.data[0]), new CDebugSQLWin(event));
234}
235
236class CDebugSQLSubWin : public CWindow
237{
238private:
239        DS_U16 RowPos;
240        DS_U16 RowTop;
241        DS_U16 RowSelect;
242        DS_U16 RowListNum;
243        DS_U16 RowItemNum;
244
245        DS_U16 ColPos;
246        DS_U16 ColTop;
247        DS_U16 ColSelect;
248        DS_U16 ColListNum;
249        DS_U16 ColItemNum;
250
251        DS_U16 pre_RowPos;
252        DS_U16 pre_RowTop;
253        DS_U16 pre_RowSelect;
254        DS_U16 pre_RowListNum;
255        int pre_RowItemNum;
256
257        DS_U16 pre_ColPos;
258        DS_U16 pre_ColTop;
259        DS_U16 pre_ColSelect;
260        DS_U16 pre_ColListNum;
261        DS_U16 pre_ColItemNum;
262
263        DBNAMES * results;
264        ATTRIBUTES * attributes;
265public:
266        CDebugSQLSubWin(SWinEventMsg event):CWindow(event)
267        {
268                InitValues();
269                rect.w = 576;
270                rect.h = 384;
271                rect.x = (DST_GetScreenWidth() - rect.w) / 2;
272                rect.y = (DST_GetScreenHeight() - rect.h) / 2;
273
274                SetTimeOut(0);
275
276                RegisterKey(VK_CANCEL, true);
277                RegisterKey(VK_PREV, true);
278                RegisterKey(VK_PREV_MENU, true);
279                RegisterKey(VK_OK, true);
280                RegisterKey(VK_RIGHT, true);
281                RegisterKey(VK_LEFT, true);
282                RegisterKey(VK_UP, true);
283                RegisterKey(VK_DN, true);
284
285        }
286
287        virtual ~CDebugSQLSubWin()
288        {
289                if (results)
290                {
291                        for(int i=0;i<RowItemNum;i++)
292                        {
293                                for(int j=0;j<ColItemNum;j++)
294                                {
295                                        if(results[i*ColItemNum+j].name)
296                                        DST_OS_Free(&results[i*ColItemNum+j].name);
297                                }
298                        }
299                        T();
300                        DST_OS_Free(&results);                 
301                }
302                if(attributes)
303                {
304                        for(int j=0;j<ColItemNum;j++)
305                        {
306                                if(attributes[j].name)  DST_OS_Free(&attributes[j].name);
307                        }
308                        DST_OS_Free(&attributes);
309                }
310        }
311       
312        void InitValues(void)
313        {                                       
314                results = 0;
315                attributes = 0;
316
317                RowPos = 0;
318                RowTop = 0;
319                RowSelect = 0;
320                RowListNum = 10;
321                RowItemNum = 0;
322               
323                ColPos = 0;
324                ColTop = 0;
325                ColSelect = 0;
326                ColListNum = 5;
327                ColItemNum = 0;
328
329                pre_ColItemNum = ColItemNum;
330                pre_ColListNum = ColListNum;
331                pre_ColTop = ColTop;
332                pre_ColSelect = ColSelect;
333                pre_ColPos = ColPos;                           
334       
335                pre_RowItemNum = RowItemNum;
336                pre_RowListNum = RowListNum;
337                pre_RowTop = RowTop;
338                pre_RowSelect = RowSelect;
339                pre_RowPos = RowPos;
340
341                GetDBResult();
342
343                if (RowItemNum < RowListNum) RowListNum = RowItemNum;
344                if (ColItemNum < ColListNum) ColListNum = ColItemNum;
345
346        }
347
348        void GetDBResult()
349        {
350                if(g_name == 0) return;
351               
352                CDB db;
353                if(db.GetTable("SELECT * FROM %s ", g_name)) return;
354               
355                RowItemNum = db.GetRow();
356                ColItemNum = db.GetCol();
357
358                if(RowItemNum == 0) return;
359                if(ColItemNum == 0) return;
360               
361//                      DST_Printf("RowItemNum = %d, ColItemNum = %d\n",RowItemNum,ColItemNum);
362               
363                results = (DBNAMES *)DST_OS_Calloc(sizeof(DBNAMES), RowItemNum*ColItemNum);
364                attributes = (ATTRIBUTES *)DST_OS_Calloc(sizeof(ATTRIBUTES), ColItemNum);
365
366                for(int i=0;i<ColItemNum;i++)
367                {
368                        int nLen = strlen(db.GetResult(i));
369                        attributes[i].type = 0;
370                        attributes[i].name = 0;
371                        attributes[i].name = (char*)DST_OS_Calloc((nLen+1)*sizeof(char),1);
372                        memcpy(attributes[i].name,db.GetResult(i),nLen);                       
373                }
374               
375                for(int i=0;i<RowItemNum;i++)
376                {
377                        for(int j=0;j<ColItemNum;j++)
378                        {
379                                int nLen = strlen(db.GetResult((i+1)*ColItemNum+j));
380                                results[i*ColItemNum+j].name = 0;
381                                results[i*ColItemNum+j].name = (char*)DST_OS_Calloc((nLen+1)*sizeof(char),1);
382                                memcpy(results[i*ColItemNum+j].name,db.GetResult((i+1)*ColItemNum+j),nLen);
383//                                      DST_Printf("results[%d]=%s\n",i*ColItemNum+j,results[i*ColItemNum+j].name);
384                        }
385                }
386
387                // ÀúÀåµÈ ¹è¿­ °ª Ãâ·ÂÇØ¼­ È®ÀÎ
388//                      for(int i=0;i<RowItemNum;i++)
389//                      {
390//                              for(int j=0;j<ColItemNum;j++)
391//                              {
392//                                      DST_Printf("%s ",results[i*ColItemNum+j].name);
393//                              }
394//                              DST_Printf("\n");
395//                      }
396
397               
398                db.GetTable("pragma table_info(%Q)",g_name);
399                if(db.GetRow() < 1 || db.GetRow() != ColItemNum) return;
400                for(int i=0;i<db.GetRow();i++)
401                {
402                        int rc = strcmp((char *)"int",db.GetResult((i+1)*db.GetCol()+2));
403                        attributes[i].type = (rc == 0)?1:0;
404                }
405
406
407
408        }
409
410        virtual void Show(WinID id)
411        {
412//              DST_Printf("id=%d\n",id);
413//              switch(id)
414//              {
415//                      case WIN_ERROR:
416//                      case WIN_POWER_DOWN_CAUTION:
417//                              break;
418//                      default:
419//                              KillTimer(1);
420//                              Close();
421//                              break;
422//              }
423        }
424
425        virtual void Show()
426        {
427                DrawAll();
428        }       
429
430        void DrawVerScrollBar(int x, int y, int h, int total_count, int page_count, int page_start)
431        {
432                if (total_count <= page_count) return;
433                // ¼±Åà ±×¸®±â
434                int nTop = 1;
435                int nBot = 1;
436                int nMinHeight = nTop + nBot + 1; // ÃÖ¼Ò ³ôÀÌ
437                int nHeight = (h * page_count) / total_count; // ³ôÀÌ
438                if (nHeight < nMinHeight) nHeight = nMinHeight; 
439                int nStart = (h * page_start) / total_count;
440                if (nStart + nHeight > h) nStart = h - nHeight; // ¾Æ·¡·Î »ßÁ®³ª¿À´Â°Í ¹æÁö
441                if (total_count == page_start + page_count) nStart = h - nHeight; // ¾Æ·¡ ÇÑÇȼ¿ »ù ¹æÁö
442                int nMid = nHeight - nTop - nBot;       
443                DrawBox32(x,y+nStart,10,1,CONV32_16(0xFFFFFFFF));
444                for (int yy = 0; yy < nMid; yy++)
445                {
446                        DrawBox32(x,y+yy+nStart+nTop,10,1,CONV32_16(0xFFFFFFFF));
447                }
448                DrawBox32(x,y+nStart+nTop+nMid,10,1,CONV32_16(0xFFFFFFFF));
449        }
450
451        void DrawHorScrollBar(int x, int y, int w, int total_count, int page_count, int page_start)
452        {
453                if (total_count <= page_count) return;
454                // ¼±Åà ±×¸®±â
455                int nLeft = 1;
456                int nRight = 1;
457                int nMinWidth = nLeft + nRight + 1; // ÃÖ¼Ò ³ôÀÌ
458                int nWidth = (w * page_count) / total_count; // ³ôÀÌ
459                if (nWidth < nMinWidth) nWidth = nMinWidth; 
460                int nStart = (w * page_start) / total_count;
461                if (nStart + nWidth > w) nStart = w - nWidth; // ¾Æ·¡·Î »ßÁ®³ª¿À´Â°Í ¹æÁö
462                if (total_count == page_start + page_count) nStart = w - nWidth; // ¾Æ·¡ ÇÑÇȼ¿ »ù ¹æÁö
463                int nMid = nWidth - nLeft - nRight;     
464                DrawBox32(x+nStart,y,1,6,CONV32_16(0xFFFFFFFF));
465                for (int xx = 0; xx < nMid; xx++)
466                {
467                        DrawBox32(x+xx+nStart+nLeft,y,1,6,CONV32_16(0xFFFFFFFF));
468                }
469                DrawBox32(x+nStart+nLeft+nMid,y,1,6,CONV32_16(0xFFFFFFFF));
470        }       
471
472        void DrawAll()
473        {
474                setFontStyle(15, 0xFFC8C8C8, ALIGN_MIDDLE,ALIGN_CENTER);
475
476                DrawBox32(0, 0, rect.w, rect.h, CONV32_16(0xAA262626));
477
478               
479                DrawBox32(2, 2, rect.w-4, 54-4, CONV32_16(0xFFFFFFFF));
480                for(int i=0;i<ColListNum;i++)
481                        DrawText(2+i*108, 84+2-28, 108-4, 28-4, attributes[i+ColTop].name,&font);
482
483               
484                setFontStyle(15, 0xFF363636, ALIGN_MIDDLE,ALIGN_CENTER);
485                for(int i=0;i<RowListNum;i++)
486                {
487                        for(int j=0;j<ColListNum;j++)
488                        {
489                                if(RowSelect == i+RowTop && ColSelect == j+ColTop)
490                                        DrawBox32(2+j*108, 84+2+i*28, 108-4, 28-4, CONV32_16(0xAA2C86FF));
491                                else
492                                        DrawBox32(2+j*108, 84+2+i*28, 108-4, 28-4, CONV32_16(0xAAFFA52C));
493
494                               
495                                DrawText32(2+j*108, 84+2+i*28, 108-4, 28-4,DST_UTF82Uni((DS_U8*)results[(i+RowTop)*ColItemNum+(j+ColTop)].name),&font);
496                        }
497                }
498                DrawDetail();
499               
500                DrawVerScrollBar(550, 86, 28*RowListNum-4, RowItemNum, RowListNum, RowTop);
501                DrawHorScrollBar(2, 370, 108*ColListNum-4, ColItemNum, ColListNum, ColTop);
502        }       
503        void Draw()
504        {
505                setFontStyle(15, 0xFFC8C8C8, ALIGN_MIDDLE,ALIGN_CENTER);
506
507                DrawDetailPre();
508                DrawDetail();
509
510               
511                if(ColTop != pre_ColTop)
512                {
513                        for(int i=0;i<ColListNum;i++)
514                                DrawText(2+i*108, 84+2-28, 108-4, 28-4,attributes[i+ColTop].name,&font);
515                }
516               
517                setFontStyle(15, 0xFF363636, ALIGN_MIDDLE,ALIGN_CENTER);
518                bool bDone = false;
519                for(int i=0;i<RowListNum;i++)
520                {
521                        for(int j=0;j<ColListNum;j++)
522                        {
523                                if(RowSelect == i+RowTop && ColSelect == j+ColTop)
524                                {
525                                        DrawBox32(2+j*108, 84+2+i*28, 108-4, 28-4, CONV32_16(0xAA2C86FF));
526                                        DrawText32(2+j*108, 84+2+i*28, 108-4, 28-4,DST_UTF82Uni((DS_U8*)results[(i+RowTop)*ColItemNum+(j+ColTop)].name),&font);
527                                        bDone = true;
528                                        break;
529                                }
530                        }
531                        if(bDone) break;
532                }
533
534                bDone = false;
535                for(int i=0;i<RowListNum;i++)
536                {
537                        for(int j=0;j<ColListNum;j++)
538                        {
539                                if(pre_RowSelect == i+pre_RowTop && pre_ColSelect == j+pre_ColTop)
540                                {
541                                        DrawBox32(2+j*108, 84+2+i*28, 108-4, 28-4, CONV32_16(0xAAFFA52C));
542                                        DrawText32(2+j*108, 84+2+i*28, 108-4, 28-4,DST_UTF82Uni((DS_U8*)results[(i+pre_RowTop)*ColItemNum+(j+pre_ColTop)].name),&font);
543                                        bDone = true;
544                                        break;
545                                }
546                        }
547                        if(bDone) break;
548                }       
549                if(RowTop != pre_RowTop) DrawVerScrollBar(550, 86, 28*RowListNum-4, RowItemNum, RowListNum, RowTop);
550                if(ColTop != pre_ColTop) DrawHorScrollBar(2, 370, 108*ColListNum-4, ColItemNum, ColListNum, ColTop);
551        }
552
553        void DrawDetail()
554        {
555                setFontStyle(15, 0xFF262626, ALIGN_MIDDLE,ALIGN_LEFT);
556                if(results == 0) return;
557                 //column attribute data typeÀÌ intÀÏ °æ¿ì,  hex°ªµµ °°ÀÌ º¸¿©ÁØ´Ù
558                if(attributes[ColPos+ColTop].type == 1)
559                {
560                        int nLen1 = strlen(results[(RowPos+RowTop)*ColItemNum+(ColPos+ColTop)].name);
561                        int number = atoi(results[(RowPos+RowTop)*ColItemNum+(ColPos+ColTop)].name);
562                        char tmpStr[100] = {0,};
563                        sprintf(tmpStr," (0x%08X)",number);
564                        int count = 0;
565                        for(int i=0;i<100;i++)
566                        {
567                                if(tmpStr[i] == 0) break;
568                                count++;
569                        }
570                        int nLen = nLen1 + count + 1;
571                        char * finalStr = (char*)DST_OS_Calloc((nLen)*sizeof(char),1);
572
573                        memcpy(finalStr,results[(RowPos+RowTop)*ColItemNum+(ColPos+ColTop)].name,nLen1);
574                        memcpy(&finalStr[nLen1],tmpStr,count);
575                        DrawText(2, 2, rect.w-4, 54-4,finalStr,&font);
576                        DST_OS_Free(&finalStr);
577                }
578                else
579                {
580                        DrawText32(2, 2, rect.w-4, 54-4, DST_UTF82Uni((DS_U8*)results[(RowPos+RowTop)*ColItemNum+(ColPos+ColTop)].name),&font);
581                }
582        }
583
584        void DrawDetailPre()
585        {
586                setFontStyle(15, 0xFF262626, ALIGN_MIDDLE,ALIGN_LEFT);
587                if(results == 0)
588                {
589                        DrawBox32(2, 2, rect.w-4, 54-4, CONV32_16(0xFFFFFFFF));
590                        return;
591                }
592                 //column attribute data typeÀÌ intÀÏ °æ¿ì,  hex°ªµµ °°ÀÌ º¸¿©ÁØ´Ù
593                if(attributes[pre_ColPos+pre_ColTop].type == 1)
594                {
595                        int nLen1 = strlen(results[(pre_RowPos+pre_RowTop)*ColItemNum+(pre_ColPos+pre_ColTop)].name);
596                        int number = atoi(results[(pre_RowPos+pre_RowTop)*ColItemNum+(pre_ColPos+pre_ColTop)].name);
597                        char tmpStr[100] = {0,};
598                        sprintf(tmpStr," (0x%08X)",number);
599                        int count = 0;
600                        for(int i=0;i<100;i++)
601                        {
602                                if(tmpStr[i] == 0) break;
603                                count++;
604                        }
605                        int nLen = nLen1 + count + 1;
606                        char * finalStr = (char*)DST_OS_Calloc((nLen)*sizeof(char),1);
607
608                        memcpy(finalStr,results[(pre_RowPos+pre_RowTop)*ColItemNum+(pre_ColPos+pre_ColTop)].name,nLen1);
609                        memcpy(&finalStr[nLen1],tmpStr,count);
610                        DrawBox32(2, 2, DST_GetTextWidth(finalStr, font.GetSize()), 54-4, CONV32_16(0xFFFFFFFF));
611                        DST_OS_Free(&finalStr);
612                }
613                else
614                {
615                        DrawBox32(2, 2, DST_GetTextWidth32(DST_UTF82Uni((DS_U8*)results[(pre_RowPos+pre_RowTop)*ColItemNum+(pre_ColPos+pre_ColTop)].name), strlen32(DST_UTF82Uni((DS_U8*)results[(pre_RowPos+pre_RowTop)*ColItemNum+(pre_ColPos+pre_ColTop)].name)), font.GetSize()), 54-4, CONV32_16(0xFFFFFFFF));
616                }
617        }       
618        virtual void OnTimer(char nID)
619        {
620                switch(nID)
621                {
622                        case 1:
623                                break;
624                }
625        }       
626
627        virtual void KeyInput(DS_U8 key,bool)
628        {
629                switch(key)
630                {
631                        case VK_PREV:
632                        case VK_PREV_MENU:
633                        case VK_CANCEL: 
634                                {
635                                        CWindow * sqlWin = DST_GetWin(WIN_DEBUG_SQL);
636                                        if(sqlWin)
637                                                sqlWin->SetVisible(true);
638                                        else
639                                                DST_CreateWin(WIN_DEBUG_SQL);
640                                }
641                                Close();
642                                break;
643                        case VK_OK:
644                               
645                                break;
646                        case VK_LEFT:
647                        case VK_RIGHT:
648                                if(key == VK_RIGHT)
649                                {
650                                        if(pre_ColPos == ColListNum-1 && pre_ColTop+ColListNum < ColItemNum - (ColItemNum%ColListNum))
651                                        {
652                                                ItemIncrease(ColItemNum, ColListNum, &ColTop, &ColSelect, &ColPos,ColListNum);
653                                                ColSelect = 1 + ColSelect - ColListNum;
654                                                ColPos = 0;
655                                        }
656                                        else
657                                        {
658                                                ItemIncrease(ColItemNum, ColListNum, &ColTop, &ColSelect, &ColPos);
659                                        }
660                                }
661                                else
662                                {
663                                        if(pre_ColPos == 0 && pre_ColTop > ColListNum)
664                                        {
665                                       
666                                                ItemDecrease(ColItemNum, ColListNum, &ColTop, &ColSelect, &ColPos,ColListNum);
667                                                ColSelect = ColSelect + ColListNum - 1;
668                                                ColPos = ColListNum -1;
669                                        }
670                                        else
671                                        {
672                                                ItemDecrease(ColItemNum, ColListNum, &ColTop, &ColSelect, &ColPos);
673                                        }
674                                }
675                               
676                                if(ColTop != pre_ColTop) DrawAll();
677                                else Draw();
678                               
679                                pre_ColItemNum = ColItemNum;
680                                pre_ColListNum = ColListNum;
681                                pre_ColTop = ColTop;
682                                pre_ColSelect = ColSelect;
683                                pre_ColPos = ColPos;                           
684                                break;
685                        case VK_UP:
686                        case VK_DN:
687                                if(key == VK_DN)
688                                {
689                                        if(pre_RowPos == RowListNum-1 && pre_RowTop+RowListNum < RowItemNum - (RowItemNum%RowListNum))
690                                        {
691                                                ItemIncrease(RowItemNum, RowListNum, &RowTop, &RowSelect, &RowPos,RowListNum);
692                                                RowSelect = 1 + RowSelect - RowListNum ;
693                                                RowPos = 0;
694                                        }
695                                        else
696                                        {
697                                                ItemIncrease(RowItemNum, RowListNum, &RowTop, &RowSelect, &RowPos);
698                                        }
699                                }
700                                else
701                                {
702                                        if(pre_RowPos == 0 && pre_RowTop > RowListNum)
703                                        {
704                                       
705                                                ItemDecrease(RowItemNum, RowListNum, &RowTop, &RowSelect, &RowPos,RowListNum);
706                                                RowSelect = RowSelect + RowListNum - 1;
707                                                RowPos = RowListNum -1;
708                                        }
709                                        else
710                                        {
711                                                ItemDecrease(RowItemNum, RowListNum, &RowTop, &RowSelect, &RowPos);
712                                        }
713                                }
714
715                                if(RowTop != pre_RowTop) DrawAll();
716                                else Draw();
717                       
718                       
719                                pre_RowItemNum = RowItemNum;
720                                pre_RowListNum = RowListNum;
721                                pre_RowTop = RowTop;
722                                pre_RowSelect = RowSelect;
723                                pre_RowPos = RowPos;                           
724                                break;
725
726                }
727        }
728};
729
730
731void DST_CreateDebugSQLSubWin(SWinEventMsg event)
732{
733        DST_AddWin((WinID)(event.data[0]), new CDebugSQLSubWin(event));
734}
735
Note: See TracBrowser for help on using the repository browser.