1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
36
37
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
106
107
108
109
112
113
114
119
120
125
126
131
132
137
161
162
167
191
192
193
198
209
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
258
261
262
263
264
269
270
271
272
273
274
275
276
277
281
282
283
284
285
286
287
288
289
290
294
298
302
306
310
313
314
315
316
317
318
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
352
353
354
355
356
357
358
363
387
390
391
392
393
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
445
448
449
450
451
456
457
458
459
462
463
464
467
470
471
472
475
478
479
480
481
482
487
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
534
535
536
537
538
539
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
578
579
580
581
582
583
584
585
586
587
588
589
590
595
596
597
598
599
600
601
602
603
604
605
606
607
612
613
614
616
617
618
619
620
628
629
630
631
632
633
634
635
640
641
642
643
644
645
646
650
651
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
683
684
685
687
688
689
691
692
693
694
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
722
730
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
786
790
791
792
793
794
798
799
800
801
806
807
808
809
811
812
813
814
819
820
821
822
823
824
825
826
827
828
829
830
831
835
839
840
841
842
843
844
845
846
847
848
849
854
865
866
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
987
988
992
993
994
995
996
997
1000
1001
/* ... */
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "DIALOG.h"
#include "MESSAGEBOX.h"
#include "k_rtc.h"
#include "k_log.h"
#include "k_storage.h"
#include "k_module.h"
#include "k_res.c"
#include "cpu_utils.h"
12 includes
/* ... */
/* ... */
Includes
#define ID_TIMER_TIME (GUI_ID_USER + 0x00)
#define ID_SPRITE_TIME (GUI_ID_USER + 0xA0)
#define ID_BUTTON_BKGND (GUI_ID_USER + 0x01)
#define ID_ICONVIEW_MENU (GUI_ID_USER + 0x02)
#define ID_MENU_LOG (GUI_ID_USER + 0x03)
#define ID_MENU_PMGR (GUI_ID_USER + 0x04)
#define ID_MENU_EXIT (GUI_ID_USER + 0x05)
#define ID_MENU_PERF (GUI_ID_USER + 0x06)
#define ID_FRAMEWIN_PERFORMANCE (GUI_ID_USER + 0x10)
#define ID_GRAPH_CPU (GUI_ID_USER + 0x11)
#define ID_BUTTON_HIDE (GUI_ID_USER + 0x12)
#define ID_FRAMEWIN_KERNELLOG (GUI_ID_USER + 0x20)
#define ID_BUTTON_CANCEL_KERNELLOG (GUI_ID_USER + 0x21)
#define ID_MULTIEDIT_KERNELLOG (GUI_ID_USER + 0x22)
#define ID_FRAMEWIN_PROCESSMANAGER (GUI_ID_USER + 0x30)
#define ID_BUTTON_CANCEL_PROCESSMANAGER (GUI_ID_USER + 0x31)
#define ID_LISTVIEW_PROCESSMANAGER (GUI_ID_USER + 0x32)
17 defines
ICONVIEW_Handle hIcon = 0;
int module_active = (-1);
static GRAPH_DATA_Handle hData = 0;
static GRAPH_SCALE_Handle hScale = 0;
static WM_HWIN hPerformance = 0;
static WM_HWIN hProcess = 0;
static WM_HWIN hLog = 0;
uint8_t SpriteDisabled = 0;
xTaskStatusType ProcessStatus[16] ={{0}};
static SystemSettingsTypeDef settings;
uint8_t strMonth[][12] = {"01",
"02",
"03",
"04",
"05",
"06",
"07",
"08",
"09",
"10",
"11",
"12"...};
static MENU_ITEM _aMenuItems[] =
{
{"Kernel Log" , ID_MENU_LOG, 0},
{"Process Viewer" , ID_MENU_PMGR, 0},
{"CPU Usage", ID_MENU_PERF, 0},
{0 , 0 , MENU_IF_SEPARATOR},
{"Cancel" , ID_MENU_EXIT, 0},
...};
static SPRITE _aSprite[] =
{
{ 480, 150, -8, -2, GUI_COUNTOF(apbmbutterfly), apbmbutterfly},
...};
static const GUI_WIDGET_CREATE_INFO _aPerformanceDialogCreate[] = {
{ FRAMEWIN_CreateIndirect, "CPU Usage", ID_FRAMEWIN_PERFORMANCE, 10, 30, 220, 180, 0, 0x0, 0 },
{ GRAPH_CreateIndirect, "", ID_GRAPH_CPU, 5, 9, 200, 130, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "Hide", ID_BUTTON_HIDE, 70, 142, 80, 30, 0, 0x0, 0 },
...};
static const GUI_WIDGET_CREATE_INFO _aKernelLogDialogCreate[] = {
{ FRAMEWIN_CreateIndirect, "Kernel Log", ID_FRAMEWIN_KERNELLOG, 10, 30, 220, 180, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "Cancel", ID_BUTTON_CANCEL_KERNELLOG, 70, 142, 80, 30, 0, 0x0, 0 },
{ MULTIEDIT_CreateIndirect, "Multiedit", ID_MULTIEDIT_KERNELLOG, 5, 9, 200, 130, 0, 0x0, 0 },
...};
static const GUI_WIDGET_CREATE_INFO _aProcessManagerDialogCreate[] = {
{ FRAMEWIN_CreateIndirect, "Process viewer", ID_FRAMEWIN_PROCESSMANAGER, 10, 30, 220, 180, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "Cancel", ID_BUTTON_CANCEL_PROCESSMANAGER, 70, 142, 80, 30, 0, 0x0, 0 },
{ LISTVIEW_CreateIndirect, "Listview", ID_LISTVIEW_PROCESSMANAGER, 5, 5, 200, 130, 0, 0x0, 0 },
...};
/* ... */
static void _cbCpuWindow(WM_MESSAGE * pMsg) {
static WM_HTIMER hTimerTime;
switch (pMsg->MsgId)
{
case WM_CREATE:
hTimerTime = WM_CreateTimer(pMsg->hWin, 0, 400, 0);
break;
case WM_CREATE:
case WM_TIMER:
GRAPH_DATA_YT_AddValue(hData , osGetCPUUsage());
WM_InvalidateWindow(pMsg->hWin);
WM_RestartTimer(pMsg->Data.v, 400);
break;
case WM_TIMER:
case WM_DELETE:
WM_DeleteTimer(hTimerTime);
break;
case WM_DELETE:
default:
WM_DefaultProc(pMsg);default
}switch (pMsg->MsgId) { ... }
}{ ... }
/* ... */
static void _cbTaskWindow(WM_MESSAGE * pMsg) {
static WM_HTIMER hTimerTime;
switch (pMsg->MsgId)
{
case WM_CREATE:
hTimerTime = WM_CreateTimer(pMsg->hWin, 0, 1000, 0);
break;
case WM_CREATE:
case WM_TIMER:
WM_InvalidateWindow(WM_GetParent(pMsg->hWin));
WM_RestartTimer(pMsg->Data.v, 1000);
break;
case WM_TIMER:
case WM_DELETE:
WM_DeleteTimer(hTimerTime);
break;
case WM_DELETE:
default:
WM_DefaultProc(pMsg);default
}switch (pMsg->MsgId) { ... }
}{ ... }
/* ... */
void k_UpdateLog(char *Msg)
{
WM_HWIN hItem;
if(hLog != 0)
{
hItem = WM_GetDialogItem(hLog, ID_MULTIEDIT_KERNELLOG);
MULTIEDIT_SetText(hItem, Msg);
MULTIEDIT_SetCursorOffset(hItem, LOG_IN_ptr);
}if (hLog != 0) { ... }
}{ ... }
/* ... */
static void _cbKernelLogDialog(WM_MESSAGE * pMsg) {
WM_HWIN hItem;
int NCode;
int Id;
switch (pMsg->MsgId) {
case WM_INIT_DIALOG:
hItem = pMsg->hWin;
FRAMEWIN_SetTitleVis(hItem, 0);
hItem = WM_GetDialogItem(pMsg->hWin, ID_MULTIEDIT_KERNELLOG);
MULTIEDIT_SetFont(hItem, GUI_FONT_8_1);
MULTIEDIT_SetTextColor(hItem, MULTIEDIT_CI_READONLY, GUI_GREEN);
MULTIEDIT_SetBkColor(hItem, MULTIEDIT_CI_READONLY, GUI_BLACK);
MULTIEDIT_SetReadOnly(hItem, 1);
MULTIEDIT_SetText(hItem, (char *)pLOG_CacheBuffer);
MULTIEDIT_SetCursorOffset(hItem, LOG_IN_ptr);
MULTIEDIT_SetAutoScrollV(hItem, 1);
break;case WM_INIT_DIALOG:
case WM_NOTIFY_PARENT:
Id = WM_GetId(pMsg->hWinSrc);
NCode = pMsg->Data.v;
switch(Id) {
case ID_BUTTON_CANCEL_KERNELLOG:
switch(NCode) {
case WM_NOTIFICATION_RELEASED:
GUI_EndDialog(pMsg->hWin, 0);
hLog = 0;
break;case WM_NOTIFICATION_RELEASED:
}switch (NCode) { ... }
break;case ID_BUTTON_CANCEL_KERNELLOG:
case ID_MULTIEDIT_KERNELLOG:
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
break;case WM_NOTIFICATION_CLICKED:
case WM_NOTIFICATION_RELEASED:
break;case WM_NOTIFICATION_RELEASED:
case WM_NOTIFICATION_VALUE_CHANGED:
break;case WM_NOTIFICATION_VALUE_CHANGED:
}switch (NCode) { ... }
break;case ID_MULTIEDIT_KERNELLOG:
}switch (Id) { ... }
break;case WM_NOTIFY_PARENT:
default:
WM_DefaultProc(pMsg);
break;default
}switch (pMsg->MsgId) { ... }
}{ ... }
/* ... */
static void _UpdateProcessManagerView(WM_HWIN hItem) {
int Idx;
char str[3];
int16_t tasks_nbr;
tasks_nbr = uxTaskGetSystemState( ProcessStatus, 16, NULL );
if(tasks_nbr > 16)
{
tasks_nbr = 16;
}if (tasks_nbr > 16) { ... }
for (Idx = 0; Idx < tasks_nbr; Idx ++)
{
LISTVIEW_SetItemText(hItem, 0, Idx, (char *)(ProcessStatus[Idx].pcTaskName));
sprintf(str, "%lu", ProcessStatus[Idx].uxCurrentPriority);
LISTVIEW_SetItemText(hItem, 1, Idx, str);
switch (ProcessStatus[Idx].eCurrentState)
{
case eReady:
LISTVIEW_SetItemText(hItem, 2, Idx, "Ready");
break;
case eReady:
case eBlocked:
LISTVIEW_SetItemText(hItem, 2, Idx, "Blocked");
break;
case eBlocked:
case eDeleted:
LISTVIEW_SetItemText(hItem, 2, Idx, "Deleted");
break;
case eDeleted:
case eSuspended:
LISTVIEW_SetItemText(hItem, 2, Idx, "Suspended");
break;
case eSuspended:
case eRunning:
LISTVIEW_SetItemText(hItem, 2, Idx, "Running");
break;
case eRunning:
default:
LISTVIEW_SetItemText(hItem, 2, Idx, "Unknown");
break; default
}switch (ProcessStatus[Idx].eCurrentState) { ... }
}for (Idx = 0; Idx < tasks_nbr; Idx ++) { ... }
LISTVIEW_SetSort(hItem, 1, 0);
}{ ... }
/* ... */
static void _cbProcessManagerDialog(WM_MESSAGE * pMsg) {
WM_HWIN hItem;
int NCode;
int Id, Idx;
switch (pMsg->MsgId) {
case WM_INIT_DIALOG:
hItem = pMsg->hWin;
FRAMEWIN_SetTitleVis(hItem, 0);
hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTVIEW_PROCESSMANAGER);
LISTVIEW_AddColumn(hItem, 90, "Tasks", GUI_TA_HCENTER | GUI_TA_VCENTER);
LISTVIEW_AddColumn(hItem, 50, "Priority", GUI_TA_HCENTER | GUI_TA_VCENTER);
LISTVIEW_AddColumn(hItem, 60, "State", GUI_TA_HCENTER | GUI_TA_VCENTER);
LISTVIEW_SetGridVis(hItem, 1);
LISTVIEW_SetTextAlign(hItem, 0, GUI_TA_LEFT);
LISTVIEW_SetTextAlign(hItem, 1, GUI_TA_HCENTER);
LISTVIEW_SetTextAlign(hItem, 2, GUI_TA_HCENTER);
HEADER_SetDragLimit(LISTVIEW_GetHeader(hItem), 1);
LISTVIEW_SetCompareFunc(hItem, 1, LISTVIEW_CompareDec);
LISTVIEW_SetTextColor(hItem, LISTVIEW_CI_SELFOCUS, GUI_LIGHTBLUE);
for (Idx = 0; Idx < 16; Idx ++)
{
LISTVIEW_AddRow(hItem, NULL);
}for (Idx = 0; Idx < 16; Idx ++) { ... }
_UpdateProcessManagerView(hItem);
WM_CreateWindowAsChild(230, 0, 10, 10, pMsg->hWin, WM_CF_SHOW | WM_CF_HASTRANS, _cbTaskWindow , 0);
break;
case WM_INIT_DIALOG:
case WM_PAINT:
hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTVIEW_PROCESSMANAGER);
_UpdateProcessManagerView(hItem);
break;
case WM_PAINT:
case WM_NOTIFY_PARENT:
Id = WM_GetId(pMsg->hWinSrc);
NCode = pMsg->Data.v;
switch(Id) {
case ID_BUTTON_CANCEL_PROCESSMANAGER:
switch(NCode) {
case WM_NOTIFICATION_RELEASED:
GUI_EndDialog(pMsg->hWin, 0);
hProcess = 0;
break;case WM_NOTIFICATION_RELEASED:
}switch (NCode) { ... }
break;case ID_BUTTON_CANCEL_PROCESSMANAGER:
case ID_LISTVIEW_PROCESSMANAGER:
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
break;case WM_NOTIFICATION_CLICKED:
case WM_NOTIFICATION_RELEASED:
break;case WM_NOTIFICATION_RELEASED:
case WM_NOTIFICATION_SEL_CHANGED:
break;case WM_NOTIFICATION_SEL_CHANGED:
}switch (NCode) { ... }
break;case ID_LISTVIEW_PROCESSMANAGER:
}switch (Id) { ... }
break;case WM_NOTIFY_PARENT:
default:
WM_DefaultProc(pMsg);
break;default
}switch (pMsg->MsgId) { ... }
}{ ... }
/* ... */
static void _cbPerformanceDialog(WM_MESSAGE * pMsg) {
int NCode;
int Id;
WM_HWIN hGraph;
GUI_RECT Rect;
switch (pMsg->MsgId)
{
case WM_INIT_DIALOG:
FRAMEWIN_SetTitleVis(pMsg->hWin, 0);
hGraph = WM_GetDialogItem(pMsg->hWin, ID_GRAPH_CPU);
hData = GRAPH_DATA_YT_Create(GUI_LIGHTGREEN, 500, 0, 20);
GRAPH_SetGridVis(hGraph, 1);
GRAPH_SetBorder(hGraph, 30, 2, 2, 2);
GRAPH_AttachData(hGraph, hData);
hScale = GRAPH_SCALE_Create(20, GUI_TA_RIGHT, GRAPH_SCALE_CF_VERTICAL, 25);
GRAPH_AttachScale(hGraph, hScale);
GRAPH_SCALE_SetTextColor(hScale, GUI_YELLOW);
GRAPH_SetGridDistX(hGraph, 25);
GRAPH_SetGridDistY(hGraph, 25);
WM_GetClientRect(&Rect);
WM_CreateWindowAsChild(230, 0, 10, 10, pMsg->hWin, WM_CF_SHOW | WM_CF_HASTRANS, _cbCpuWindow , 0);
break;
case WM_INIT_DIALOG:
case WM_NOTIFY_PARENT:
Id = WM_GetId(pMsg->hWinSrc);
NCode = pMsg->Data.v;
switch(Id) {
case ID_BUTTON_HIDE:
switch(NCode)
{
case WM_NOTIFICATION_RELEASED:
if(hPerformance != 0)
{
WM_HideWindow(hPerformance);
}if (hPerformance != 0) { ... }
break;case WM_NOTIFICATION_RELEASED:
}switch (NCode) { ... }
break;case ID_BUTTON_HIDE:
}switch (Id) { ... }
break;case WM_NOTIFY_PARENT:
default:
WM_DefaultProc(pMsg);
break;default
}switch (pMsg->MsgId) { ... }
}{ ... }
/* ... */
static void _MoveSprite(SPRITE * pSprite) {
pSprite->Index += 1;
if (pSprite->Index >= pSprite->NumImages) {
pSprite->Index = 0;
}if (pSprite->Index >= pSprite->NumImages) { ... }
pSprite->xPos += pSprite->dx;
if (pSprite->xPos > 240) {
pSprite->xPos = -pSprite->apImages[pSprite->Index]->XSize;
}if (pSprite->xPos > 240) { ... }
if (pSprite->xPos < -pSprite->apImages[pSprite->Index]->XSize) {
pSprite->xPos = 240;
}if (pSprite->xPos < -pSprite->apImages[pSprite->Index]->XSize) { ... }
pSprite->yPos += pSprite->dy;
if (pSprite->yPos < 0) {
pSprite->dy = -pSprite->dy;
}if (pSprite->yPos < 0) { ... }
if (pSprite->yPos > (320 - pSprite->apImages[pSprite->Index]->YSize)) {
pSprite->dy = -pSprite->dy;
}if (pSprite->yPos > (320 - pSprite->apImages[pSprite->Index]->YSize)) { ... }
GUI_SPRITE_SetBitmapAndPosition(pSprite->hSprite, pSprite->apImages[pSprite->Index], pSprite->xPos, pSprite->yPos);
}{ ... }
/* ... */
void _ShowSprites(void) {
_aSprite[0].hSprite = GUI_SPRITE_CreateEx(_aSprite[0].apImages[0], _aSprite[0].xPos, _aSprite[0].yPos, 0);
}{ ... }
/* ... */
static void _AddMenuItem(MENU_Handle hMenu, MENU_Handle hSubmenu, const char* pText, U16 Id, U16 Flags)
{
MENU_ITEM_DATA Item;
Item.pText = pText;
Item.hSubmenu = hSubmenu;
Item.Flags = Flags;
Item.Id = Id;
MENU_AddItem(hMenu, &Item);
}{ ... }
/* ... */
static void _OpenPopup(WM_HWIN hParent, MENU_ITEM * pMenuItems, int NumItems, int x, int y)
{
static MENU_Handle hMenu;
if (!hMenu) {
int i;
hMenu = MENU_CreateEx(0, 0, 0, 0, WM_UNATTACHED, 0, MENU_CF_VERTICAL, 0);
MENU_SetBkColor(hMenu, MENU_CI_SELECTED, GUI_LIGHTBLUE);
for (i = 0; i < NumItems; i++) {
_AddMenuItem(hMenu, 0, pMenuItems[i].sText, pMenuItems[i].Id, pMenuItems[i].Flags);
}for (i = 0; i < NumItems; i++) { ... }
}if (!hMenu) { ... }
MENU_Popup(hMenu, hParent, x, y, 0, 0, 0);
}{ ... }
/* ... */
static void _cbBk(WM_MESSAGE * pMsg) {
MENU_MSG_DATA* pData;
uint32_t NCode, Id;
static uint8_t sel = 0;
switch (pMsg->MsgId)
{
case WM_MENU:
pData = (MENU_MSG_DATA*)pMsg->Data.p;
switch (pData->MsgType)
{
case MENU_ON_ITEMSELECT:
switch (pData->ItemId)
{
case ID_MENU_LOG:
if (hLog == 0)
{
hLog = GUI_CreateDialogBox(_aKernelLogDialogCreate,
GUI_COUNTOF(_aProcessManagerDialogCreate),
_cbKernelLogDialog,
pMsg->hWin,
0,
0);
}if (hLog == 0) { ... }
else
{
WM_ShowWindow(hLog);
WM_BringToTop(hLog);
}else { ... }
break;
case ID_MENU_LOG:
case ID_MENU_PMGR:
if(hProcess == 0)
{
hProcess = GUI_CreateDialogBox(_aProcessManagerDialogCreate,
GUI_COUNTOF(_aProcessManagerDialogCreate),
_cbProcessManagerDialog,
pMsg->hWin,
0,
0);
}if (hProcess == 0) { ... }
else
{
WM_ShowWindow(hProcess);
WM_BringToTop(hProcess);
}else { ... }
break;
case ID_MENU_PMGR:
case ID_MENU_PERF:
if(hPerformance == 0)
{
hPerformance = GUI_CreateDialogBox(_aPerformanceDialogCreate,
GUI_COUNTOF(_aPerformanceDialogCreate),
_cbPerformanceDialog,
pMsg->hWin,
0,
0);
}if (hPerformance == 0) { ... }
else
{
WM_ShowWindow(hPerformance);
WM_BringToTop(hPerformance);
}else { ... }
break;
case ID_MENU_PERF:
case ID_MENU_EXIT:
break;case ID_MENU_EXIT:
}switch (pData->ItemId) { ... }
case MENU_ON_ITEMSELECT: }switch (pData->MsgType) { ... }
break;
case WM_MENU:
case WM_PAINT:
GUI_DrawBitmap(&bmbackground, 0,0);
if(hIcon)
{
WM_BringToBottom(hIcon);
}if (hIcon) { ... }
break;
case WM_PAINT:
case WM_NOTIFY_PARENT:
Id = WM_GetId(pMsg->hWinSrc);
NCode = pMsg->Data.v;
switch (NCode)
{
case WM_NOTIFICATION_CHILD_DELETED:
SpriteDisabled = 0;
GUI_SPRITE_Show(_aSprite[0].hSprite);
break;
case WM_NOTIFICATION_CHILD_DELETED:
case WM_NOTIFICATION_CLICKED:
if (Id == ID_ICONVIEW_MENU)
{
sel = ICONVIEW_GetSel(pMsg->hWinSrc);
if(hPerformance != 0)
{
WM_HideWindow(hPerformance);
}if (hPerformance != 0) { ... }
if(sel < k_ModuleGetNumber())
{
if(sel < 8)
{
ICONVIEW_SetSel(pMsg->hWinSrc, -1);
}if (sel < 8) { ... }
else
{
ICONVIEW_SetSel(pMsg->hWinSrc, k_ModuleGetNumber() + 1);
}else { ... }
}if (sel < k_ModuleGetNumber()) { ... }
}if (Id == ID_ICONVIEW_MENU) { ... }
break;
case WM_NOTIFICATION_CLICKED:
case WM_NOTIFICATION_RELEASED:
if (Id == ID_ICONVIEW_MENU)
{
if(sel < k_ModuleGetNumber())
{
SpriteDisabled = 1;
GUI_SPRITE_Hide(_aSprite[0].hSprite);
module_prop[sel].module->startup(pMsg->hWin, 0, 26);
module_active = sel;
sel = 0;
}if (sel < k_ModuleGetNumber()) { ... }
}if (Id == ID_ICONVIEW_MENU) { ... }
else if ((Id == ID_BUTTON_BKGND) && module_active != 0)
{
_OpenPopup(WM_HBKWIN, _aMenuItems, GUI_COUNTOF(_aMenuItems),0 , 25);
}else if ((Id == ID_BUTTON_BKGND) && module_active != 0) { ... }
break;
case WM_NOTIFICATION_RELEASED:
default:
break;default
}switch (NCode) { ... }
break;case WM_NOTIFY_PARENT:
default:
WM_DefaultProc(pMsg);default
}switch (pMsg->MsgId) { ... }
}{ ... }
/* ... */
static void _cbStatus(WM_MESSAGE * pMsg) {
int xSize, ySize;
static uint8_t TempStr[50];
static WM_HTIMER hTimerTime;
static WM_HTIMER hSpriteTime;
RTC_TimeTypeDef RTC_Time;
RTC_DateTypeDef RTC_DateStructure;
uint8_t sec, min, hour, day, month;
uint16_t year;
WM_HWIN hWin;
hWin = pMsg->hWin;
switch (pMsg->MsgId)
{
case WM_CREATE:
hTimerTime = WM_CreateTimer(hWin, ID_TIMER_TIME, 1000, 0);
if(settings.b.enable_sprite)
{
hSpriteTime = WM_CreateTimer(hWin, ID_SPRITE_TIME, 50, 0);
}if (settings.b.enable_sprite) { ... }
break;
case WM_CREATE:
case WM_DELETE:
WM_DeleteTimer(hTimerTime);
if(settings.b.enable_sprite)
{
WM_DeleteTimer(hSpriteTime);
}if (settings.b.enable_sprite) { ... }
break;
case WM_DELETE:
case WM_TIMER:
if( WM_GetTimerId(pMsg->Data.v) == ID_TIMER_TIME)
{
WM_InvalidateWindow(hWin);
WM_RestartTimer(pMsg->Data.v, 1000);
}if (WM_GetTimerId(pMsg->Data.v) == ID_TIMER_TIME) { ... }
else if( WM_GetTimerId(pMsg->Data.v) == ID_SPRITE_TIME)
{
if(settings.b.enable_sprite)
{
if(SpriteDisabled == 0)
{
_MoveSprite(&_aSprite[0]);
}if (SpriteDisabled == 0) { ... }
}if (settings.b.enable_sprite) { ... }
WM_RestartTimer(pMsg->Data.v, 100);
}else if (WM_GetTimerId(pMsg->Data.v) == ID_SPRITE_TIME) { ... }
break;
case WM_TIMER:
case WM_PAINT:
xSize = WM_GetWindowSizeX(hWin);
ySize = WM_GetWindowSizeY(hWin);
GUI_SetColor(0x40303030);
GUI_FillRect(0, 0, xSize , ySize - 3);
GUI_SetColor(0x808080);
GUI_DrawHLine(ySize - 2, 0, xSize );
GUI_SetColor(0x404040);
GUI_DrawHLine(ySize - 1, 0, xSize );
GUI_SetTextMode(GUI_TM_TRANS);
GUI_SetColor(GUI_WHITE);
GUI_SetFont(GUI_FONT_13B_ASCII);
k_GetTime(&RTC_Time);
sec = RTC_Time.Seconds;
min = RTC_Time.Minutes;
hour = RTC_Time.Hours;
k_GetDate(&RTC_DateStructure);
sprintf((char *)TempStr, "%02d:%02d:%02d", hour , min, sec);
GUI_DispStringAt((char *)TempStr, xSize - 50, 4);
year = RTC_DateStructure.Year + 2015;
month = RTC_DateStructure.Month;
day = RTC_DateStructure.Date;
if((day > 0) && (day <= 31) &&
(month > 0)&& (month <= 12) &&
(year >= 1900))
{
sprintf((char *)TempStr, "%02d/%s/%04d", day , strMonth[month-1], year);
}if ((day > 0) && (day <= 31) && (month > 0)&& (month <= 12) && (year >= 1900)) { ... }
else
{
sprintf((char *)TempStr, "01/01/2015");
}else { ... }
GUI_DispStringHCenterAt((char *)TempStr, xSize / 2, 4);
if(k_StorageGetStatus(USB_DISK_UNIT))
{
GUI_DrawBitmap(&bmusbdisk, xSize - 80, 0);
}if (k_StorageGetStatus(USB_DISK_UNIT)) { ... }
sprintf((char *)TempStr, "%d %%", osGetCPUUsage());
if(osGetCPUUsage() > 95 )
{
sprintf((char *)TempStr, "95 %%");
}if (osGetCPUUsage() > 95) { ... }
GUI_DispStringAt( (char *)TempStr, 42, 4);
break;
case WM_PAINT:
default:
WM_DefaultProc(pMsg);default
}switch (pMsg->MsgId) { ... }
}{ ... }
/* ... */
static void _OnPaint(BUTTON_Handle hObj) {
int Index;
GUI_RECT Rect;
Index = (WIDGET_GetState(hObj) & BUTTON_STATE_PRESSED) ? 1 : 0;
GUI_SetBkColor(FRAMEWIN_GetDefaultClientColor());
GUI_Clear();
WM_GetClientRect(&Rect);
if(Index)
{
GUI_SetColor(0x40000000 | GUI_GRAY);
}if (Index) { ... }
else
{
GUI_SetColor(0x40000000 | GUI_DARKGRAY);
}else { ... }
GUI_FillRectEx(&Rect);
GUI_SetColor(GUI_DARKGRAY);
GUI_DrawRectEx(&Rect);
GUI_DrawBitmap(&bmSTLogo40x20, 0, 0);
}{ ... }
/* ... */
static void _cbButton(WM_MESSAGE * pMsg) {
switch (pMsg->MsgId) {
case WM_PAINT:
_OnPaint(pMsg->hWin);
break;case WM_PAINT:
default:
BUTTON_Callback(pMsg);
break;default
}switch (pMsg->MsgId) { ... }
}{ ... }
/* ... */
void k_SetGuiProfile(void)
{
settings.d32 = k_BkupRestoreParameter(CALIBRATION_GENERAL_SETTINGS_BKP);
if(settings.b.disable_flex_skin == 0)
{
FRAMEWIN_SetDefaultSkin(FRAMEWIN_SKIN_FLEX);
PROGBAR_SetDefaultSkin(PROGBAR_SKIN_FLEX);
RADIO_SetDefaultSkin(RADIO_SKIN_FLEX);
SCROLLBAR_SetDefaultSkin(SCROLLBAR_SKIN_FLEX);
SLIDER_SetDefaultSkin(SLIDER_SKIN_FLEX);
SPINBOX_SetDefaultSkin(SPINBOX_SKIN_FLEX);
BUTTON_SetDefaultSkin(BUTTON_SKIN_FLEX);
DROPDOWN_SetDefaultSkin(DROPDOWN_SKIN_FLEX);
FRAMEWIN_SetDefaultTextColor(0, GUI_DARKGRAY);
FRAMEWIN_SetDefaultTextColor(1, GUI_DARKGRAY);
}if (settings.b.disable_flex_skin == 0) { ... }
else
{
FRAMEWIN_SetDefaultSkinClassic();
PROGBAR_SetDefaultSkinClassic();
RADIO_SetDefaultSkinClassic();
SCROLLBAR_SetDefaultSkinClassic();
SLIDER_SetDefaultSkinClassic();
SPINBOX_SetDefaultSkinClassic();
BUTTON_SetDefaultSkinClassic();
DROPDOWN_SetDefaultSkinClassic();
MULTIPAGE_SetDefaultSkinClassic();
CHECKBOX_SetDefaultSkinClassic();
FRAMEWIN_SetDefaultTextColor(0, GUI_WHITE);
FRAMEWIN_SetDefaultTextColor(1, GUI_WHITE);
}else { ... }
FRAMEWIN_SetDefaultFont(GUI_FONT_10_ASCII);
FRAMEWIN_SetDefaultClientColor(GUI_LIGHTGRAY | 0x20F50000);
FRAMEWIN_SetDefaultTitleHeight(15);
TREEVIEW_SetDefaultBkColor(TREEVIEW_CI_SEL, GUI_LIGHTGRAY | 0x20E50000);
TREEVIEW_SetDefaultBkColor(TREEVIEW_CI_UNSEL, GUI_LIGHTGRAY | 0x20E50000);
TREEVIEW_SetDefaultTextColor(TREEVIEW_CI_SEL, GUI_BLUE);
WINDOW_SetDefaultBkColor(GUI_LIGHTGRAY | 0x20E50000);
MULTIPAGE_SetDefaultBkColor(GUI_LIGHTGRAY | 0x20E50000, 0);
MULTIPAGE_SetDefaultBkColor(GUI_LIGHTGRAY | 0x20E50000, 1);
MULTIPAGE_SetDefaultFont(GUI_FONT_10_ASCII);
CHECKBOX_SetDefaultBkColor(GUI_LIGHTGRAY | 0x20E50000);
CALENDAR_SetDefaultSize(CALENDAR_SI_HEADER, 20 );
CALENDAR_SetDefaultSize(CALENDAR_SI_CELL_X, 25 );
CALENDAR_SetDefaultSize(CALENDAR_SI_CELL_Y, 21 );
MULTIPAGE_SetDefaultBkColor (GUI_WHITE, 1);
SPINBOX_SetDefaultButtonSize(15);
LISTVIEW_SetDefaultGridColor(GUI_WHITE);
SCROLLBAR_SetDefaultWidth(16);
HEADER_SetDefaultBkColor(0x00C5903E);
HEADER_SetDefaultTextColor(GUI_WHITE);
SCROLLBAR_SetDefaultColor(GUI_LIGHTGRAY | 0x20F50000, SCROLLBAR_CI_THUMB);
SCROLLBAR_SetDefaultColor(GUI_LIGHTGRAY | 0x20F50000, SCROLLBAR_CI_SHAFT);
SCROLLBAR_SetDefaultColor(GUI_LIGHTGRAY | 0x20F50000, SCROLLBAR_CI_ARROW);
CHOOSEFILE_SetDelim('/');
}{ ... }
/* ... */
void k_InitMenu(void)
{
WM_HWIN hItem;
uint8_t i = 0;
settings.d32 = k_BkupRestoreParameter(CALIBRATION_GENERAL_SETTINGS_BKP);
WM_SetCallback(WM_HBKWIN, _cbBk);
WM_CreateWindowAsChild(0,
0,
LCD_GetXSize(),
25,
WM_HBKWIN,
WM_CF_SHOW | WM_CF_HASTRANS ,
_cbStatus,
0);
hIcon = ICONVIEW_CreateEx(0,
15,
LCD_GetXSize(),
LCD_GetYSize()- 26,
WM_HBKWIN,
WM_CF_SHOW | WM_CF_HASTRANS | WM_CF_BGND ,
ICONVIEW_CF_AUTOSCROLLBAR_V,
ID_ICONVIEW_MENU,
115,
85);
ICONVIEW_SetFont(hIcon, &GUI_Font13B_ASCII);
ICONVIEW_SetBkColor(hIcon, ICONVIEW_CI_SEL, GUI_LIGHTBLUE |GUI_TRANSPARENT);
ICONVIEW_SetSpace(hIcon, GUI_COORD_Y, 10);
ICONVIEW_SetFrame(hIcon, GUI_COORD_Y, 10);
for (i = 0; i < k_ModuleGetNumber(); i++)
{
ICONVIEW_AddBitmapItem(hIcon,module_prop[i].module->icon, (char *)module_prop[i].module->name);
}for (i = 0; i < k_ModuleGetNumber(); i++) { ... }
if(settings.b.enable_sprite)
{
_ShowSprites();
}if (settings.b.enable_sprite) { ... }
hItem = BUTTON_CreateEx(0, 0, 40, 23, WM_HBKWIN, WM_CF_SHOW, 0, ID_BUTTON_BKGND);
WM_SetCallback(hItem, _cbButton);
}{ ... }
/* ... */
/* ... */