1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
37
38
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
90
91
92
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
140
141
142
147
148
149
150
151
152
153
154
155
159
163
164
165
170
171
172
173
174
175
176
177
178
182
186
187
188
193
194
195
196
197
198
199
200
201
212
223
224
225
230
231
232
233
234
235
236
237
238
242
246
247
248
253
254
255
256
257
258
259
260
261
265
269
270
271
276
277
278
279
280
281
282
283
284
288
292
293
294
295
300
301
302
303
304
305
306
307
308
312
316
317
318
323
334
335
340
351
352
357
368
369
374
385
386
391
402
403
408
419
420
421
426
437
438
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
466
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
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
532
533
534
535
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
572
573
574
575
576
577
578
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
646
650
651
656
661
666
667
672
673
674
675
680
685
689
693
694
695
696
697
702
703
704
705
706
707
708
709
710
711
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
776
780
781
785
789
790
791
792
793
794
795
796
797
798
799
803
804
805
813
815
816
817
818
819
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
895
900
901
902
903
904
905
906
917
918
919
920
921
922
923
924
925
930
931
932
933
934
935
936
937
938
939
940
944
948
949
950
951
952
953
954
955
956
957
958
959
973
974
975
977
978
979
980
981
982
983
984
985
986
987
988
989
990
994
998
999
1000
1001
1002
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1042
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1060
1061
1062
1063
1064
1065
1066
1070
1074
1075
1076
1080
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1097
1098
1099
1100
1101
1106
1111
1112
1116
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1137
1138
1139
1140
1141
1146
1151
1152
1156
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1189
1190
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1215
1219
1220
1221
1222
1223
1226
1227
/* ... */
#include "DIALOG.h"
#include "k_module.h"
#include "k_rtc.h"
#include "imagebrowser_res.c"
#include "k_modules_res.h"
#include "k_storage.h"
#include "k_mem.h"
#include "../Modules/filebrowser/filebrowser_app.h"
8 includes
/* ... */
/* ... */
Includes
typedef union
{
uint32_t d32;
struct
{
uint32_t ss_timer : 4;
uint32_t reserved : 28;
...}b;
...}
ImageSettingsTypeDef;
Private typedef
#define OFF 0x00
#define ON 0x01
#define ID_WINDOW_0 (GUI_ID_USER + 0x00)
#define ID_SETTINGS_BUTTON (GUI_ID_USER + 0x01)
#define ID_CLOSE_BUTTON (GUI_ID_USER + 0x02)
#define ID_SLIDE_BUTTON (GUI_ID_USER + 0x03)
#define ID_NEXT_BUTTON (GUI_ID_USER + 0x04)
#define ID_PREVIOUS_BUTTON (GUI_ID_USER + 0x05)
#define ID_IMAGE_LIST (GUI_ID_USER + 0x06)
#define ID_OPEN_BUTTON (GUI_ID_USER + 0x07)
#define ID_ADD_BUTTON (GUI_ID_USER + 0x08)
#define ID_FRAMEWIN_0 (GUI_ID_USER + 0x10)
#define ID_MULTIPAGE (GUI_ID_USER + 0x13)
#define ID_BUTTON_OK (GUI_ID_USER + 0x19)
#define ID_BUTTON_CANCEL (GUI_ID_USER + 0x1A)
#define ID_TEXT_0 (GUI_ID_USER + 0x23)
#define ID_SPINBOX_0 (GUI_ID_USER + 0x24)
#define ID_TEXT_1 (GUI_ID_USER + 0x25)
#define ID_TEXT_2 (GUI_ID_USER + 0x26)
#define ID_SLIDER_TIMER 1
#define ID_PLAYLIST_TIMER 2
#define IMAGE_TYPE_UNKNOWN 0
#define IMAGE_TYPE_BMP 1
#define IMAGE_TYPE_JPG 2
24 defines
Private defines
static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] =
{
{ WINDOW_CreateIndirect, "Window", ID_WINDOW_0, 0, 0, 320, 215, 0, 0x0, 0 },
{ LISTBOX_CreateIndirect, "List", ID_IMAGE_LIST, 230, 6, 85, 134, 0, 0x0, 0 }
...};
static const GUI_WIDGET_CREATE_INFO _aSettingsDialogCreate[] =
{
{ FRAMEWIN_CreateIndirect, "Settings", ID_FRAMEWIN_0, 50, 50, 220, 100, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "OK", ID_BUTTON_OK, 130, 5, 70, 30, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "Cancel", ID_BUTTON_CANCEL, 130, 45, 70, 30, 0, 0x0, 0 },
{ TEXT_CreateIndirect, "Slide show timer : ", ID_TEXT_1, 10, 20, 100, 20, 0, 0x0, 0 },
{ TEXT_CreateIndirect, "(seconds)", ID_TEXT_2, 70, 45, 50, 20, 0, 0x0, 0 },
{ SPINBOX_CreateIndirect, "Spinbox", ID_SPINBOX_0, 10, 43, 60, 20, 0, 0x0, 0 }
...};
static uint8_t _acBuffer[1536];
FIL Image_File;
static WM_HWIN IMAGE_hWin, imFrame;
static WM_HTIMER hTimerTime;
__IO uint32_t slideshow_state;
__IO uint32_t IMAGE_Enlarge;
char const *apDrives[2] = {"0:", "1:"};
const char acMask_img[] = ".img";
const char acMask_dir[] = ".dir";
uint32_t effects;
ImageSettingsTypeDef ImSettings;
static uint16_t file_pos = 0;
static uint8_t IMAGE_Type = IMAGE_TYPE_UNKNOWN;
static uint8_t playlist_select = 0;
static WM_HTIMER hPlaylistTimer;
static FILELIST_FileTypeDef *pImageList;
static CHOOSEFILE_INFO *pFileInfo;
Private variables
static void Startup(WM_HWIN hWin, uint16_t xpos, uint16_t ypos);
static void ImageDirectOpen(char *filename);
K_ModuleItem_Typedef image_browser =
{
3,
"Image Viewer",
&bmimage,
Startup,
ImageDirectOpen,
...};
Private function prototypes
/* ... */
static void _OnPaint_open(BUTTON_Handle hObj) {
int Index;
GUI_SetBkColor(FRAMEWIN_GetDefaultClientColor());
GUI_Clear();
Index = (WIDGET_GetState(hObj) & BUTTON_STATE_PRESSED) ? 1 : 0;
if(Index)
{
GUI_DrawBitmap(&bmopen_pressed, 0, 0);
}if (Index) { ... }
else
{
GUI_DrawBitmap(&bmopen_not_pressed, 0, 0);
}else { ... }
}{ ... }
/* ... */
static void _OnPaint_previous(BUTTON_Handle hObj) {
int Index;
GUI_SetBkColor(FRAMEWIN_GetDefaultClientColor());
GUI_Clear();
Index = (WIDGET_GetState(hObj) & BUTTON_STATE_PRESSED) ? 1 : 0;
if(Index)
{
GUI_DrawBitmap(&bmprevious_pressed, 0, 0);
}if (Index) { ... }
else
{
GUI_DrawBitmap(&bmprevious_not_pressed, 0, 0);
}else { ... }
}{ ... }
/* ... */
static void _OnPaint_play(BUTTON_Handle hObj) {
int Index;
GUI_SetBkColor(FRAMEWIN_GetDefaultClientColor());
GUI_Clear();
Index = (WIDGET_GetState(hObj) & BUTTON_STATE_PRESSED) ? 1 : 0;
if(Index)
{
if(slideshow_state == ON)
{
GUI_DrawBitmap(&bmpause_pressed, 0, 0);
}if (slideshow_state == ON) { ... }
else if(slideshow_state == OFF)
{
GUI_DrawBitmap(&bmplay_pressed, 0, 0);
}else if (slideshow_state == OFF) { ... }
}if (Index) { ... }
else
{
if(slideshow_state == ON)
{
GUI_DrawBitmap(&bmpause_not_pressed, 0, 0);
}if (slideshow_state == ON) { ... }
else if(slideshow_state == OFF)
{
GUI_DrawBitmap(&bmplay_not_pressed, 0, 0);
}else if (slideshow_state == OFF) { ... }
}else { ... }
}{ ... }
/* ... */
static void _OnPaint_next(BUTTON_Handle hObj) {
int Index;
GUI_SetBkColor(FRAMEWIN_GetDefaultClientColor());
GUI_Clear();
Index = (WIDGET_GetState(hObj) & BUTTON_STATE_PRESSED) ? 1 : 0;
if(Index)
{
GUI_DrawBitmap(&bmnext_pressed, 0, 0);
}if (Index) { ... }
else
{
GUI_DrawBitmap(&bmnext_not_pressed, 0, 0);
}else { ... }
}{ ... }
/* ... */
static void _OnPaint_settings(BUTTON_Handle hObj) {
int Index;
GUI_SetBkColor(FRAMEWIN_GetDefaultClientColor());
GUI_Clear();
Index = (WIDGET_GetState(hObj) & BUTTON_STATE_PRESSED) ? 1 : 0;
if(Index)
{
GUI_DrawBitmap(&bmsettings_button_pressed, 0, 0);
}if (Index) { ... }
else
{
GUI_DrawBitmap(&bmsettings_button_not_pressed, 0, 0);
}else { ... }
}{ ... }
/* ... */
static void _OnPaint_close(BUTTON_Handle hObj) {
int Index;
GUI_SetBkColor(FRAMEWIN_GetDefaultClientColor());
GUI_Clear();
Index = (WIDGET_GetState(hObj) & BUTTON_STATE_PRESSED) ? 1 : 0;
if(Index)
{
GUI_DrawBitmap(&bmclose_pressed, 0, 0);
}if (Index) { ... }
else
{
GUI_DrawBitmap(&bmclose_not_pressed, 0, 0);
}else { ... }
}{ ... }
/* ... */
static void _OnPaint_add(BUTTON_Handle hObj) {
int Index;
GUI_SetBkColor(FRAMEWIN_GetDefaultClientColor());
GUI_Clear();
Index = (WIDGET_GetState(hObj) & BUTTON_STATE_PRESSED) ? 1 : 0;
if(Index)
{
GUI_DrawBitmap(&bmadd_pressed, 0, 0);
}if (Index) { ... }
else
{
GUI_DrawBitmap(&bmadd_not_pressed, 0, 0);
}else { ... }
}{ ... }
/* ... */
static void _cbButton_open(WM_MESSAGE * pMsg) {
switch (pMsg->MsgId) {
case WM_PAINT:
_OnPaint_open(pMsg->hWin);
break;case WM_PAINT:
default:
BUTTON_Callback(pMsg);
break;default
}switch (pMsg->MsgId) { ... }
}{ ... }
/* ... */
static void _cbButton_previous(WM_MESSAGE * pMsg) {
switch (pMsg->MsgId) {
case WM_PAINT:
_OnPaint_previous(pMsg->hWin);
break;case WM_PAINT:
default:
BUTTON_Callback(pMsg);
break;default
}switch (pMsg->MsgId) { ... }
}{ ... }
/* ... */
static void _cbButton_play(WM_MESSAGE * pMsg) {
switch (pMsg->MsgId) {
case WM_PAINT:
_OnPaint_play(pMsg->hWin);
break;case WM_PAINT:
default:
BUTTON_Callback(pMsg);
break;default
}switch (pMsg->MsgId) { ... }
}{ ... }
/* ... */
static void _cbButton_next(WM_MESSAGE * pMsg) {
switch (pMsg->MsgId) {
case WM_PAINT:
_OnPaint_next(pMsg->hWin);
break;case WM_PAINT:
default:
BUTTON_Callback(pMsg);
break;default
}switch (pMsg->MsgId) { ... }
}{ ... }
/* ... */
static void _cbButton_settings(WM_MESSAGE * pMsg) {
switch (pMsg->MsgId) {
case WM_PAINT:
_OnPaint_settings(pMsg->hWin);
break;case WM_PAINT:
default:
BUTTON_Callback(pMsg);
break;default
}switch (pMsg->MsgId) { ... }
}{ ... }
/* ... */
static void _cbButton_close(WM_MESSAGE * pMsg) {
switch (pMsg->MsgId) {
case WM_PAINT:
_OnPaint_close(pMsg->hWin);
break;case WM_PAINT:
default:
BUTTON_Callback(pMsg);
break;default
}switch (pMsg->MsgId) { ... }
}{ ... }
/* ... */
static void _cbButton_add(WM_MESSAGE * pMsg) {
switch (pMsg->MsgId) {
case WM_PAINT:
_OnPaint_add(pMsg->hWin);
break;case WM_PAINT:
default:
BUTTON_Callback(pMsg);
break;default
}switch (pMsg->MsgId) { ... }
}{ ... }
/* ... */
static void _AddEntireFolder(char *Foldername)
{
FRESULT res = FR_OK;
FILINFO fno;
DIR dir;
char *fn;
char tmp[FILEMGR_FULL_PATH_SIZE];
WM_HWIN hItem;
res = f_opendir(&dir, Foldername);
if (res == FR_OK)
{
while (1)
{
res = f_readdir(&dir, &fno);
if (res != FR_OK || fno.fname[0] == 0)
{
break;
}if (res != FR_OK || fno.fname[0] == 0) { ... }
if (fno.fname[0] == '.')
{
continue;
}if (fno.fname[0] == '.') { ... }
fn = fno.fname;
if (pImageList->ptr < FILEMGR_LIST_DEPDTH)
{
if ((fno.fattrib & AM_DIR) == 0)
{
if((strstr(fn, ".jpg")) || (strstr(fn, ".bmp")) || (strstr(fn, ".JPG")) || (strstr(fn, ".BMP")))
{
strcpy(tmp, Foldername);
strcat(tmp, "/");
strcat(tmp, fn);
strncpy((char *)pImageList->file[pImageList->ptr].name, (char *)tmp, FILEMGR_FILE_NAME_SIZE);
hItem = WM_GetDialogItem(IMAGE_hWin, ID_IMAGE_LIST);
FILEMGR_GetFileOnly (tmp, fn);
LISTBOX_AddString(hItem, fn);
pImageList->ptr++;
}if ((strstr(fn, ".jpg")) || (strstr(fn, ".bmp")) || (strstr(fn, ".JPG")) || (strstr(fn, ".BMP"))) { ... }
}if ((fno.fattrib & AM_DIR) == 0) { ... }
}if (pImageList->ptr < FILEMGR_LIST_DEPDTH) { ... }
}while (1) { ... }
}if (res == FR_OK) { ... }
f_closedir(&dir);
}{ ... }
/* ... */
static void _cbSettingsDialog(WM_MESSAGE * pMsg)
{
int Id, NCode;
WM_HWIN hItem;
uint32_t tmp_param = 0;
switch (pMsg->MsgId)
{
case WM_INIT_DIALOG:
WM_MakeModal(pMsg->hWin);
hItem = pMsg->hWin;
FRAMEWIN_AddCloseButton(hItem, FRAMEWIN_BUTTON_RIGHT, 0);
hItem = WM_GetDialogItem(pMsg->hWin, ID_MULTIPAGE);
hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_OK);
BUTTON_SetFont(hItem, GUI_FONT_13B_1);
hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_CANCEL);
BUTTON_SetFont(hItem, GUI_FONT_13B_1);
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_1);
TEXT_SetFont(hItem, GUI_FONT_13B_1);
hItem = WM_GetDialogItem(pMsg->hWin, ID_SPINBOX_0);
SPINBOX_SetRange(hItem, 1, 10);
if(ImSettings.b.ss_timer > 0)
{
SPINBOX_SetValue(hItem, ImSettings.b.ss_timer);
}if (ImSettings.b.ss_timer > 0) { ... }
else
{
ImSettings.b.ss_timer = 1;
SPINBOX_SetValue(hItem, 1);
}else { ... }
break;
case WM_INIT_DIALOG:
case WM_NOTIFY_PARENT:
Id = WM_GetId(pMsg->hWinSrc);
NCode = pMsg->Data.v;
switch (Id)
{
case ID_BUTTON_OK:
switch (NCode) {
case WM_NOTIFICATION_RELEASED:
hItem = WM_GetDialogItem(pMsg->hWin, ID_SPINBOX_0);
ImSettings.b.ss_timer = SPINBOX_GetValue(hItem);
WM_RestartTimer(hTimerTime, (ImSettings.b.ss_timer * 1000));
tmp_param = k_BkupRestoreParameter(CALIBRATION_IMAGE_SETTINGS_BKP);
if(ImSettings.d32 != tmp_param)
{
k_BkupSaveParameter(CALIBRATION_IMAGE_SETTINGS_BKP, ImSettings.d32);
}if (ImSettings.d32 != tmp_param) { ... }
GUI_EndDialog(pMsg->hWin, 0);
break;case WM_NOTIFICATION_RELEASED:
}switch (NCode) { ... }
break;
case ID_BUTTON_OK:
case ID_BUTTON_CANCEL:
switch (NCode) {
case WM_NOTIFICATION_RELEASED:
GUI_EndDialog(pMsg->hWin, 0);
break;case WM_NOTIFICATION_RELEASED:
}switch (NCode) { ... }
break;case ID_BUTTON_CANCEL:
}switch (Id) { ... }
break;
case WM_NOTIFY_PARENT:
}switch (pMsg->MsgId) { ... }
}{ ... }
/* ... */
static int _GetData(void * p, const U8 ** ppData, unsigned NumBytesReq, U32 Off)
{
unsigned int NumBytesRead;
FIL * phFile;
phFile = (FIL *)p;
if (NumBytesReq > sizeof(_acBuffer)) {
NumBytesReq = sizeof(_acBuffer);
}if (NumBytesReq > sizeof(_acBuffer)) { ... }
f_lseek(phFile, Off);
f_read(phFile, _acBuffer, NumBytesReq, &NumBytesRead);
*ppData =(unsigned char *) _acBuffer;
return NumBytesRead;
}{ ... }
/* ... */
static int _DrawImage(FIL *hFile, uint8_t Enlarge, uint8_t type)
{
int XPos, YPos, XSize, YSize, nx, ny, n;
GUI_JPEG_INFO Info;
if(type == IMAGE_TYPE_BMP)
{
Info.XSize = GUI_BMP_GetXSizeEx(_GetData, hFile);
Info.YSize = GUI_BMP_GetYSizeEx(_GetData, hFile);
}if (type == IMAGE_TYPE_BMP) { ... }
else if (type == IMAGE_TYPE_JPG)
{
GUI_JPEG_GetInfoEx(_GetData, hFile, &Info);
}else if (type == IMAGE_TYPE_JPG) { ... }
if((Info.XSize == 0) || (Info.YSize == 0) ||
(Info.XSize > 1024) || (Info.YSize > 768))
{
return 1;
}if ((Info.XSize == 0) || (Info.YSize == 0) || (Info.XSize > 1024) || (Info.YSize > 768)) { ... }
if(Enlarge == 0)
{
nx = 220000 / Info.XSize;
ny = 134000 / Info.YSize;
}if (Enlarge == 0) { ... }
else
{
nx = 320000 / Info.XSize;
ny = 240000 / Info.YSize;
}else { ... }
if (nx < ny) {
n = nx;
}if (nx < ny) { ... } else {
n = ny;
}else { ... }
XSize = Info.XSize * n / 1000;
YSize = Info.YSize * n / 1000;
if(Enlarge == 0)
{
XPos = (220 - XSize) / 2;
YPos = (134 - YSize) / 2;
}if (Enlarge == 0) { ... }
else
{
XPos = (320 - XSize) / 2;
YPos = (240 - YSize) / 2;
}else { ... }
if(type == IMAGE_TYPE_BMP)
{
return GUI_BMP_DrawScaledEx(_GetData, hFile, XPos, YPos, n, 1000);
}if (type == IMAGE_TYPE_BMP) { ... }
else if (type == IMAGE_TYPE_JPG)
{
return GUI_JPEG_DrawScaledEx(_GetData, hFile, XPos, YPos, n, 1000);
}else if (type == IMAGE_TYPE_JPG) { ... }
return 0;
}{ ... }
/* ... */
static void _cbImageWindow(WM_MESSAGE * pMsg)
{
WM_HWIN hItem;
GUI_RECT r;
int Id;
const GUI_PID_STATE * pState;
switch (pMsg->MsgId)
{
case WM_TOUCH:
pState = (const GUI_PID_STATE *)pMsg->Data.p;
if(pImageList->ptr > 0)
{
if (pState) {
if (pState->Pressed == 1)
{
IMAGE_Enlarge ^= 1;
if (IMAGE_Enlarge)
{
WM_AttachWindowAt(pMsg->hWin, WM_HBKWIN, 0, 0);
WM_SetSize(pMsg->hWin, LCD_GetXSize(), LCD_GetYSize());
}if (IMAGE_Enlarge) { ... }
else
{
WM_AttachWindowAt(pMsg->hWin, IMAGE_hWin, 6, 6);
WM_SetSize(pMsg->hWin, 220, 134);
}else { ... }
WM_InvalidateWindow(pMsg->hWin);
}if (pState->Pressed == 1) { ... }
}if (pState) { ... }
}if (pImageList->ptr > 0) { ... }
break;
case WM_TOUCH:
case WM_PAINT:
WM_GetInsideRect(&r);
GUI_ClearRectEx(&r);
if (pImageList->ptr > 0)
{
if(_DrawImage(&Image_File, IMAGE_Enlarge, IMAGE_Type) > 0)
{
f_close(&Image_File);
GUI_ClearRectEx(&r);
GUI_DispStringAt("Error : Image cannot be displayed", 20, 80);
if(hTimerTime != 0)
{
slideshow_state = OFF;
hItem = WM_GetDialogItem(IMAGE_hWin, ID_SLIDE_BUTTON);
WM_InvalidateWindow(hItem);
WM_Update(hItem);
WM_DeleteTimer(hTimerTime);
hTimerTime = 0;
}if (hTimerTime != 0) { ... }
}if (_DrawImage(&Image_File, IMAGE_Enlarge, IMAGE_Type) > 0) { ... }
}if (pImageList->ptr > 0) { ... }
break;
case WM_PAINT:
case WM_TIMER:
Id = WM_GetTimerId(pMsg->Data.v);
if(Id == ID_SLIDER_TIMER)
{
if(pImageList->ptr > 1)
{
if (file_pos < (pImageList->ptr - 1))
{
file_pos++;
}if (file_pos < (pImageList->ptr - 1)) { ... }
else if (file_pos == (pImageList->ptr - 1))
{
file_pos=0;
}else if (file_pos == (pImageList->ptr - 1)) { ... }
if((strstr((char *)pImageList->file[file_pos].name, ".bmp")) || (strstr((char *)pImageList->file[file_pos].name, ".BMP")))
{
IMAGE_Type = IMAGE_TYPE_BMP;
}if ((strstr((char *)pImageList->file[file_pos].name, ".bmp")) || (strstr((char *)pImageList->file[file_pos].name, ".BMP"))) { ... }
else if((strstr((char *)pImageList->file[file_pos].name, ".jpg")) || (strstr((char *)pImageList->file[file_pos].name, ".JPG")))
{
IMAGE_Type = IMAGE_TYPE_JPG;
}else if ((strstr((char *)pImageList->file[file_pos].name, ".jpg")) || (strstr((char *)pImageList->file[file_pos].name, ".JPG"))) { ... }
f_close(&Image_File);
f_open(&Image_File, (char const *)pImageList->file[file_pos].name, FA_OPEN_EXISTING | FA_READ);
WM_InvalidateWindow(imFrame);
hItem = WM_GetDialogItem(IMAGE_hWin, ID_IMAGE_LIST);
LISTBOX_SetSel(hItem, file_pos);
}if (pImageList->ptr > 1) { ... }
WM_RestartTimer(pMsg->Data.v, (ImSettings.b.ss_timer * 1000));
}if (Id == ID_SLIDER_TIMER) { ... }
else if (Id == ID_PLAYLIST_TIMER)
{
playlist_select = 0;
}else if (Id == ID_PLAYLIST_TIMER) { ... }
break;
case WM_TIMER:
case WM_DELETE:
if(hTimerTime != 0)
{
WM_DeleteTimer(hTimerTime);
hTimerTime = 0;
}if (hTimerTime != 0) { ... }
break;
case WM_DELETE:
default:
WM_DefaultProc(pMsg);default
}switch (pMsg->MsgId) { ... }
}{ ... }
/* ... */
static void _cbDialog(WM_MESSAGE * pMsg)
{
WM_HWIN hItem;
GUI_RECT r;
int result;
int Id, NCode, Index;
char tmp[FILEMGR_FILE_NAME_SIZE];
switch (pMsg->MsgId)
{
case WM_INIT_DIALOG:
pImageList = (FILELIST_FileTypeDef *)k_malloc(sizeof(FILELIST_FileTypeDef));
pFileInfo = (CHOOSEFILE_INFO *)k_malloc(sizeof(CHOOSEFILE_INFO));
pImageList->ptr = 0;
file_pos = 0;
effects = 0;
ImSettings.d32 = k_BkupRestoreParameter(CALIBRATION_IMAGE_SETTINGS_BKP);
if(ImSettings.b.ss_timer == 0)
{
ImSettings.b.ss_timer = 1;
}if (ImSettings.b.ss_timer == 0) { ... }
IMAGE_Enlarge = 0;
hItem = WM_GetClientWindow(pMsg->hWin);
WM_GetClientRectEx(hItem, &r);
imFrame = WM_CreateWindowAsChild(r.x0 + 6, r.y0 + 6, r.x1 - 98, r.y1 - 78, hItem, WM_CF_SHOW, _cbImageWindow, 0);
hItem = BUTTON_CreateEx(47, 155, 35, 35, pMsg->hWin, WM_CF_SHOW, 0, ID_PREVIOUS_BUTTON);
WM_SetCallback(hItem, _cbButton_previous);
hItem = BUTTON_CreateEx(94, 148, 50, 50, pMsg->hWin, WM_CF_SHOW, 0, ID_SLIDE_BUTTON);
WM_SetCallback(hItem, _cbButton_play);
slideshow_state = OFF;
hItem = BUTTON_CreateEx(154, 155, 35, 35, pMsg->hWin, WM_CF_SHOW, 0, ID_NEXT_BUTTON);
WM_SetCallback(hItem, _cbButton_next);
hItem = BUTTON_CreateEx(242, 145, 70, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_ADD_BUTTON);
WM_SetCallback(hItem, _cbButton_add);
hItem = BUTTON_CreateEx(242, 175, 70, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_OPEN_BUTTON);
WM_SetCallback(hItem, _cbButton_open);
hItem = BUTTON_CreateEx(196, 174, 30, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_SETTINGS_BUTTON);
WM_SetCallback(hItem, _cbButton_settings);
hItem = BUTTON_CreateEx(10, 174, 30, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_CLOSE_BUTTON);
WM_SetCallback(hItem, _cbButton_close);
hItem = WM_GetDialogItem(pMsg->hWin, ID_IMAGE_LIST);
LISTBOX_SetBkColor(hItem, LISTBOX_CI_SEL, GUI_BLUE);
LISTBOX_SetTextColor(hItem, LISTBOX_CI_SEL, GUI_WHITE);
LISTBOX_SetBkColor(hItem, LISTBOX_CI_UNSEL, GUI_BLACK);
LISTBOX_SetTextColor(hItem, LISTBOX_CI_UNSEL, GUI_CYAN);
LISTBOX_SetAutoScrollV(hItem, 1);
break;
case WM_INIT_DIALOG:
case WM_TIMER:
playlist_select = 0;
break;
case WM_TIMER:
case WM_PAINT:
DrawRect3D(5, 140, 222, 67);
DrawRect3D(230, 140, 83, 67);
break;case WM_PAINT:
case WM_NOTIFY_PARENT:
Id = WM_GetId(pMsg->hWinSrc);
NCode = pMsg->Data.v;
switch (Id) {
case ID_SETTINGS_BUTTON:
switch (NCode) {
case WM_NOTIFICATION_CLICKED:
break;case WM_NOTIFICATION_CLICKED:
case WM_NOTIFICATION_RELEASED:
GUI_CreateDialogBox(_aSettingsDialogCreate, GUI_COUNTOF(_aSettingsDialogCreate), _cbSettingsDialog, IMAGE_hWin, 0, 0);
break;case WM_NOTIFICATION_RELEASED:
}switch (NCode) { ... }
break;
case ID_SETTINGS_BUTTON:
case ID_IMAGE_LIST:
if(NCode == WM_NOTIFICATION_CLICKED)
{
hItem = WM_GetDialogItem(pMsg->hWin, ID_IMAGE_LIST);
Index = LISTBOX_GetSel(hItem);
if(Index < pImageList->ptr)
{
if(playlist_select == 0)
{
hPlaylistTimer = WM_CreateTimer(pMsg->hWin, ID_PLAYLIST_TIMER, 500, 0);
playlist_select = (Index + 1);
}if (playlist_select == 0) { ... }
else if(playlist_select == (Index + 1))
{
WM_DeleteTimer(hPlaylistTimer);
hPlaylistTimer = 0;
playlist_select = 0;
if(Index < pImageList->ptr)
{
file_pos = Index;
if((strstr((char *)pImageList->file[file_pos].name, ".bmp")) || (strstr((char *)pImageList->file[file_pos].name, ".BMP")))
{
IMAGE_Type = IMAGE_TYPE_BMP;
}if ((strstr((char *)pImageList->file[file_pos].name, ".bmp")) || (strstr((char *)pImageList->file[file_pos].name, ".BMP"))) { ... }
else if((strstr((char *)pImageList->file[file_pos].name, ".jpg")) || (strstr((char *)pImageList->file[file_pos].name, ".JPG")))
{
IMAGE_Type = IMAGE_TYPE_JPG;
}else if ((strstr((char *)pImageList->file[file_pos].name, ".jpg")) || (strstr((char *)pImageList->file[file_pos].name, ".JPG"))) { ... }
f_close(&Image_File);
f_open(&Image_File, (char const *)pImageList->file[file_pos].name, FA_OPEN_EXISTING | FA_READ);
WM_InvalidateWindow(imFrame);
}if (Index < pImageList->ptr) { ... }
}else if (playlist_select == (Index + 1)) { ... }
}if (Index < pImageList->ptr) { ... }
}if (NCode == WM_NOTIFICATION_CLICKED) { ... }
break;
case ID_IMAGE_LIST:
case ID_CLOSE_BUTTON:
switch (NCode) {
case WM_NOTIFICATION_CLICKED:
break;case WM_NOTIFICATION_CLICKED:
case WM_NOTIFICATION_RELEASED:
f_close(&Image_File);
k_free(pImageList);
k_free(pFileInfo);
GUI_EndDialog(pMsg->hWin, 0);
break;case WM_NOTIFICATION_RELEASED:
}switch (NCode) { ... }
break;
case ID_CLOSE_BUTTON:
case ID_OPEN_BUTTON:
switch (NCode) {
case WM_NOTIFICATION_CLICKED:
break;case WM_NOTIFICATION_CLICKED:
case WM_NOTIFICATION_RELEASED:
pFileInfo->pfGetData = k_GetData;
pFileInfo->pMask = acMask_dir;
hItem = CHOOSEFILE_Create(pMsg->hWin, 20, 20, 200, 150, apDrives, GUI_COUNTOF(apDrives), 0, "add a folder", 0, pFileInfo);
WM_MakeModal(hItem);
result = GUI_ExecCreatedDialog(hItem);
if (result == 0)
{
if(pImageList->ptr == 0)
{
_AddEntireFolder(pFileInfo->pRoot);
file_pos = 0;
if((strstr((char *)pImageList->file[file_pos].name, ".bmp")) || (strstr((char *)pImageList->file[file_pos].name, ".BMP")))
{
IMAGE_Type = IMAGE_TYPE_BMP;
}if ((strstr((char *)pImageList->file[file_pos].name, ".bmp")) || (strstr((char *)pImageList->file[file_pos].name, ".BMP"))) { ... }
else if((strstr((char *)pImageList->file[file_pos].name, ".jpg")) || (strstr((char *)pImageList->file[file_pos].name, ".JPG")))
{
IMAGE_Type = IMAGE_TYPE_JPG;
}else if ((strstr((char *)pImageList->file[file_pos].name, ".jpg")) || (strstr((char *)pImageList->file[file_pos].name, ".JPG"))) { ... }
f_open(&Image_File, (char *)pImageList->file[file_pos].name, FA_OPEN_EXISTING | FA_READ);
WM_InvalidateWindow(imFrame);
}if (pImageList->ptr == 0) { ... }
else
{
_AddEntireFolder(pFileInfo->pRoot);
}else { ... }
}if (result == 0) { ... }
break;case WM_NOTIFICATION_RELEASED:
}switch (NCode) { ... }
break;
case ID_OPEN_BUTTON:
case ID_ADD_BUTTON:
switch (NCode) {
case WM_NOTIFICATION_CLICKED:
break;case WM_NOTIFICATION_CLICKED:
case WM_NOTIFICATION_RELEASED:
pFileInfo->pfGetData = k_GetData;
pFileInfo->pMask = acMask_img;
hItem = CHOOSEFILE_Create(pMsg->hWin, 20, 20, 200, 150, apDrives, GUI_COUNTOF(apDrives), 0, "Add an image to playlist", 0, pFileInfo);
WM_MakeModal(hItem);
result = GUI_ExecCreatedDialog(hItem);
if (result == 0)
{
if((strstr(pFileInfo->pRoot, ".jpg")) || (strstr(pFileInfo->pRoot, ".bmp")) || (strstr(pFileInfo->pRoot, ".JPG")) || (strstr(pFileInfo->pRoot, ".BMP")))
{
strcpy((char *)pImageList->file[pImageList->ptr].name, pFileInfo->pRoot);
FILEMGR_GetFileOnly(tmp, (char *)pFileInfo->pRoot);
hItem = WM_GetDialogItem(IMAGE_hWin, ID_IMAGE_LIST);
LISTBOX_AddString(hItem, tmp);
LISTBOX_SetSel(hItem, pImageList->ptr);
pImageList->ptr++;
file_pos = pImageList->ptr - 1;
f_close(&Image_File);
if((strstr((char *)pImageList->file[file_pos].name, ".bmp")) || (strstr((char *)pImageList->file[file_pos].name, ".BMP")))
{
IMAGE_Type = IMAGE_TYPE_BMP;
}if ((strstr((char *)pImageList->file[file_pos].name, ".bmp")) || (strstr((char *)pImageList->file[file_pos].name, ".BMP"))) { ... }
else if((strstr((char *)pImageList->file[file_pos].name, ".jpg")) || (strstr((char *)pImageList->file[file_pos].name, ".JPG")))
{
IMAGE_Type = IMAGE_TYPE_JPG;
}else if ((strstr((char *)pImageList->file[file_pos].name, ".jpg")) || (strstr((char *)pImageList->file[file_pos].name, ".JPG"))) { ... }
f_open(&Image_File, (char *)pImageList->file[file_pos].name, FA_OPEN_EXISTING | FA_READ);
WM_InvalidateWindow(imFrame);
}if ((strstr(pFileInfo->pRoot, ".jpg")) || (strstr(pFileInfo->pRoot, ".bmp")) || (strstr(pFileInfo->pRoot, ".JPG")) || (strstr(pFileInfo->pRoot, ".BMP"))) { ... }
}if (result == 0) { ... }
break;case WM_NOTIFICATION_RELEASED:
}switch (NCode) { ... }
break;
case ID_ADD_BUTTON:
case ID_SLIDE_BUTTON:
switch (NCode) {
case WM_NOTIFICATION_CLICKED:
break;case WM_NOTIFICATION_CLICKED:
case WM_NOTIFICATION_RELEASED:
if(pImageList->ptr > 1)
{
f_close(&Image_File);
f_open(&Image_File, (char const *)pImageList->file[file_pos].name, FA_OPEN_EXISTING | FA_READ);
if((strstr((char *)pImageList->file[file_pos].name, ".bmp")) || (strstr((char *)pImageList->file[file_pos].name, ".BMP")))
{
IMAGE_Type = IMAGE_TYPE_BMP;
}if ((strstr((char *)pImageList->file[file_pos].name, ".bmp")) || (strstr((char *)pImageList->file[file_pos].name, ".BMP"))) { ... }
else if((strstr((char *)pImageList->file[file_pos].name, ".jpg")) || (strstr((char *)pImageList->file[file_pos].name, ".JPG")))
{
IMAGE_Type = IMAGE_TYPE_JPG;
}else if ((strstr((char *)pImageList->file[file_pos].name, ".jpg")) || (strstr((char *)pImageList->file[file_pos].name, ".JPG"))) { ... }
WM_InvalidateWindow(imFrame);
if (slideshow_state == OFF)
{
hTimerTime = WM_CreateTimer(imFrame, ID_SLIDER_TIMER, (ImSettings.b.ss_timer * 1000) , 0);
}if (slideshow_state == OFF) { ... }
else if(hTimerTime != 0)
{
WM_DeleteTimer(hTimerTime);
hTimerTime = 0;
}else if (hTimerTime != 0) { ... }
slideshow_state = (slideshow_state == OFF ? ON : OFF);
}if (pImageList->ptr > 1) { ... }
break;case WM_NOTIFICATION_RELEASED:
}switch (NCode) { ... }
break;
case ID_SLIDE_BUTTON:
case ID_NEXT_BUTTON:
switch (NCode) {
case WM_NOTIFICATION_CLICKED:
break;case WM_NOTIFICATION_CLICKED:
case WM_NOTIFICATION_RELEASED:
if(pImageList->ptr > 0)
{
if (file_pos < (pImageList->ptr - 1))
{
file_pos++;
f_close(&Image_File);
}if (file_pos < (pImageList->ptr - 1)) { ... }
else
{
file_pos = 0;
f_close(&Image_File);
}else { ... }
if((strstr((char *)pImageList->file[file_pos].name, ".bmp")) || (strstr((char *)pImageList->file[file_pos].name, ".BMP")))
{
IMAGE_Type = IMAGE_TYPE_BMP;
}if ((strstr((char *)pImageList->file[file_pos].name, ".bmp")) || (strstr((char *)pImageList->file[file_pos].name, ".BMP"))) { ... }
else if((strstr((char *)pImageList->file[file_pos].name, ".jpg")) || (strstr((char *)pImageList->file[file_pos].name, ".JPG")))
{
IMAGE_Type = IMAGE_TYPE_JPG;
}else if ((strstr((char *)pImageList->file[file_pos].name, ".jpg")) || (strstr((char *)pImageList->file[file_pos].name, ".JPG"))) { ... }
f_open(&Image_File, (char const *)pImageList->file[file_pos].name, FA_OPEN_EXISTING | FA_READ);
WM_InvalidateWindow(imFrame);
hItem = WM_GetDialogItem(IMAGE_hWin, ID_IMAGE_LIST);
LISTBOX_SetSel(hItem, file_pos);
}if (pImageList->ptr > 0) { ... }
break;case WM_NOTIFICATION_RELEASED:
}switch (NCode) { ... }
break;
case ID_NEXT_BUTTON:
case ID_PREVIOUS_BUTTON:
switch (NCode) {
case WM_NOTIFICATION_CLICKED:
break;case WM_NOTIFICATION_CLICKED:
case WM_NOTIFICATION_RELEASED:
if(pImageList->ptr > 0)
{
if (file_pos > 0 )
{
file_pos--;
f_close(&Image_File);
}if (file_pos > 0) { ... }
else
{
file_pos = (pImageList->ptr - 1);
f_close(&Image_File);
}else { ... }
if((strstr((char *)pImageList->file[file_pos].name, ".bmp")) || (strstr((char *)pImageList->file[file_pos].name, ".BMP")))
{
IMAGE_Type = IMAGE_TYPE_BMP;
}if ((strstr((char *)pImageList->file[file_pos].name, ".bmp")) || (strstr((char *)pImageList->file[file_pos].name, ".BMP"))) { ... }
else if((strstr((char *)pImageList->file[file_pos].name, ".jpg")) || (strstr((char *)pImageList->file[file_pos].name, ".JPG")))
{
IMAGE_Type = IMAGE_TYPE_JPG;
}else if ((strstr((char *)pImageList->file[file_pos].name, ".jpg")) || (strstr((char *)pImageList->file[file_pos].name, ".JPG"))) { ... }
f_open(&Image_File, (char const *)pImageList->file[file_pos].name, FA_OPEN_EXISTING | FA_READ);
WM_InvalidateWindow(imFrame);
hItem = WM_GetDialogItem(IMAGE_hWin, ID_IMAGE_LIST);
LISTBOX_SetSel(hItem, file_pos);
}if (pImageList->ptr > 0) { ... }
break;case WM_NOTIFICATION_RELEASED:
}switch (NCode) { ... }
break;case ID_PREVIOUS_BUTTON:
}switch (Id) { ... }
break;case WM_NOTIFY_PARENT:
default:
WM_DefaultProc(pMsg);
break;default
}switch (pMsg->MsgId) { ... }
}{ ... }
/* ... */
static void Startup(WM_HWIN hWin, uint16_t xpos, uint16_t ypos)
{
IMAGE_hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, hWin, xpos, ypos);
}{ ... }
/* ... */
static void ImageDirectOpen(char *filename)
{
WM_HWIN hItem;
static char tmp[FILEMGR_FILE_NAME_SIZE];
IMAGE_hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_GetDesktopWindowEx(1), 0, 26);
strcpy((char *)pImageList->file[pImageList->ptr].name, filename);
FILEMGR_GetFileOnly(tmp, (char *)filename);
hItem = WM_GetDialogItem(IMAGE_hWin, ID_IMAGE_LIST);
LISTBOX_AddString(hItem, tmp);
LISTBOX_SetSel(hItem, pImageList->ptr);
pImageList->ptr++;
file_pos = pImageList->ptr - 1;
f_close(&Image_File);
if((strstr((char *)pImageList->file[file_pos].name, ".bmp")) || (strstr((char *)pImageList->file[file_pos].name, ".BMP")))
{
IMAGE_Type = IMAGE_TYPE_BMP;
}if ((strstr((char *)pImageList->file[file_pos].name, ".bmp")) || (strstr((char *)pImageList->file[file_pos].name, ".BMP"))) { ... }
else if((strstr((char *)pImageList->file[file_pos].name, ".jpg")) || (strstr((char *)pImageList->file[file_pos].name, ".JPG")))
{
IMAGE_Type = IMAGE_TYPE_JPG;
}else if ((strstr((char *)pImageList->file[file_pos].name, ".jpg")) || (strstr((char *)pImageList->file[file_pos].name, ".JPG"))) { ... }
f_open(&Image_File, (char *)pImageList->file[file_pos].name, FA_OPEN_EXISTING | FA_READ);
WM_InvalidateWindow(imFrame);
}{ ... }
/* ... */
/* ... */