Files
player/Project/Src/MyWinApp/mywin_user_filder.c

895 lines
24 KiB
C
Raw Normal View History

2025-06-27 00:32:57 +08:00
#include "mywin_inc.h"
#include "ff.h"
#include "nes_main.h"
2025-06-27 00:32:57 +08:00
#include "gif.h"
#include "system_updata.h"
#include "avi.h"
#include "mywin_user_photo.h"
#include "mywin_user_animation.h"
#include "mywin_music.h"
#include "mywin_user_filder.h"
#include "elf.h"
#include "lcd_rgb.h"
#include "tools.h"
#include "nrf.h"
#include "mywin_user_debug.h"
2025-07-01 00:09:47 +08:00
#include "string.h"
2025-07-05 19:05:35 +08:00
#include "char_encode.h"
2025-06-27 00:32:57 +08:00
2025-07-05 19:47:28 +08:00
// <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2025-06-27 00:32:57 +08:00
#define WIN_FILDER_TYPE "WIN_FilderStruct"
2025-07-01 00:09:47 +08:00
static const char *g_popup_itmes[] =
{
2025-07-05 19:47:28 +08:00
"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>",
"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>",
"<EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD>ϵͳ<EFBFBD>ļ<EFBFBD>",
"<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>Ϣ",
"ɾ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>",
"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>",
2025-06-27 00:32:57 +08:00
};
2025-07-01 00:09:47 +08:00
void FILDER_Delete(WIN_FilderStruct *up);
2025-06-27 00:32:57 +08:00
2025-07-01 00:09:47 +08:00
WIN_FilderStruct *WIN_CreatFilder(WIN_WindowStruct *base,
void (*msgLoop)(struct _WIN_WindowStruct *win, WIN_MsgStruct *msg),
int x, int y, int x_size, int y_size)
2025-06-27 00:32:57 +08:00
{
2025-07-05 19:47:28 +08:00
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣѭ<CFA2><D1AD>
2025-07-01 00:09:47 +08:00
if (msgLoop == 0)
2025-06-27 00:32:57 +08:00
{
2025-07-01 00:09:47 +08:00
msgLoop = (void (*)(struct _WIN_WindowStruct *win, WIN_MsgStruct *msg))FILDER_defaultMsgLoop;
2025-06-27 00:32:57 +08:00
}
2025-07-01 00:09:47 +08:00
WIN_FilderStruct *ret = mymalloc_exm(sizeof(WIN_FilderStruct));
2025-07-05 19:47:28 +08:00
// <20><><EFBFBD>ø<EFBFBD><C3B8><EFBFBD><EFBFBD>Ĺ<EFBFBD><C4B9><EFBFBD><ECBAAF>
2025-06-27 00:32:57 +08:00
if (ret)
{
2025-07-01 00:09:47 +08:00
mymemset(ret, 0, sizeof(WIN_FilderStruct));
// if (0==WIN_CreatWindowExt((WIN_WindowStruct *)ret,base,msgLoop,x,y,x_size,y_size))
if (0 == WIN_CreatTouchEx((WIN_TouchWinStruct *)ret, base, msgLoop, x, y, x_size, y_size))
2025-06-27 00:32:57 +08:00
{
2025-07-05 19:47:28 +08:00
// <20><><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>
2025-07-01 00:09:47 +08:00
myfree(ret);
ret = 0;
2025-06-27 00:32:57 +08:00
}
else
{
2025-07-05 19:47:28 +08:00
// <20><><EFBFBD><EFBFBD>
2025-07-01 00:09:47 +08:00
((WIN_WindowStruct *)ret)->winType = WIN_FILDER_TYPE;
((WIN_WindowStruct *)ret)->deleteWindow = (void (*)(struct _WIN_WindowStruct *win))FILDER_Delete;
((WIN_WindowStruct *)ret)->bkcolor = 0x808080;
((WIN_WindowStruct *)ret)->color = 0xffffff;
2025-07-05 19:47:28 +08:00
((WIN_WindowStruct *)ret)->intercept = 1; // <20><><EFBFBD><EFBFBD><EFBFBD>Ͱ<EFBFBD><CDB0><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2025-07-01 00:09:47 +08:00
ret->titleHight = 30;
ret->itemHight = 30;
ret->itemIndent = 35;
ret->scrollbar_xsize = 10;
ret->itemNumOnePage = (((WIN_WindowStruct *)ret)->y_size - ret->titleHight) / ret->itemHight;
ret->itemHight = (((WIN_WindowStruct *)ret)->y_size - ret->titleHight) / ret->itemNumOnePage;
ret->imgDir = 0;
ret->imgFile = 0;
tools_updata_on();
2025-06-27 00:32:57 +08:00
}
}
2025-07-01 00:09:47 +08:00
2025-06-27 00:32:57 +08:00
return ret;
}
2025-07-01 00:09:47 +08:00
void FILDER_Delete(WIN_FilderStruct *up)
2025-06-27 00:32:57 +08:00
{
2025-07-01 00:09:47 +08:00
tools_updata_off();
2025-06-27 00:32:57 +08:00
2025-07-05 19:47:28 +08:00
// <20><><EFBFBD>ø<EFBFBD><C3B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٺ<EFBFBD><D9BA><EFBFBD>
2025-07-01 00:09:47 +08:00
WIN_DeleteWindow((WIN_WindowStruct *)up);
2025-06-27 00:32:57 +08:00
}
2025-07-05 19:47:28 +08:00
// <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
2025-07-01 00:09:47 +08:00
int FILDER_SetIndex(WIN_FilderStruct *filder, int index);
2025-06-27 00:32:57 +08:00
2025-07-05 19:47:28 +08:00
// <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD>ͬʱɨ<CAB1><C9A8>·<EFBFBD><C2B7><EFBFBD>µ<EFBFBD><C2B5>ļ<EFBFBD>
2025-07-01 00:09:47 +08:00
void FILDER_SetFileDir(WIN_FilderStruct *filder, char *dir)
2025-06-27 00:32:57 +08:00
{
2025-07-01 00:09:47 +08:00
mymemcpy(filder->dirName, dir, strlen(dir));
2025-06-27 00:32:57 +08:00
FILDER_ClearItem(filder);
2025-07-01 00:09:47 +08:00
FILDER_ScanFile(filder);
2025-06-27 00:32:57 +08:00
}
2025-07-05 19:47:28 +08:00
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ
2025-07-01 00:09:47 +08:00
void FILDER_ClearItem(WIN_FilderStruct *filder)
2025-06-27 00:32:57 +08:00
{
2025-07-01 00:09:47 +08:00
filder->fileNum = 0;
filder->firstItemOnPage = 0;
filder->dirNum = 0;
filder->file[0].name[0] = 0;
FILDER_SetIndex(filder, 0);
2025-06-27 00:32:57 +08:00
}
2025-07-05 19:47:28 +08:00
// <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>Ŀ
2025-07-01 00:09:47 +08:00
void FILDER_AddItem(WIN_FilderStruct *filder, Filder_FildInfo *file)
2025-06-27 00:32:57 +08:00
{
2025-07-01 00:09:47 +08:00
if (filder->fileNum < FILDER_FILE_MAXNUM)
2025-06-27 00:32:57 +08:00
{
2025-07-01 00:09:47 +08:00
mymemcpy(&filder->file[filder->fileNum], file, sizeof(Filder_FildInfo));
2025-06-27 00:32:57 +08:00
filder->fileNum++;
2025-07-01 00:09:47 +08:00
2025-07-05 19:47:28 +08:00
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>У<EFBFBD><D0A3>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF>1
2025-07-01 00:09:47 +08:00
if (file->type == FILDER_DIR_TYPE)
{
filder->dirNum++;
}
2025-06-27 00:32:57 +08:00
}
}
2025-07-05 19:47:28 +08:00
// <20><>ָ<EFBFBD><D6B8>λ<EFBFBD>ò<EFBFBD><C3B2><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>Ŀ
2025-07-01 00:09:47 +08:00
void FILDER_InsertItem(WIN_FilderStruct *filder, Filder_FildInfo *file, int index)
2025-06-27 00:32:57 +08:00
{
2025-07-01 00:09:47 +08:00
if (index < 0)
return;
if (filder->fileNum < FILDER_FILE_MAXNUM)
2025-06-27 00:32:57 +08:00
{
2025-07-05 19:47:28 +08:00
// <20><><EFBFBD>б<EFBFBD><D0B1>м<EFBFBD><D0BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ
2025-07-01 00:09:47 +08:00
if (index < filder->fileNum)
2025-06-27 00:32:57 +08:00
{
2025-07-05 19:47:28 +08:00
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
2025-07-01 00:09:47 +08:00
for (int i = filder->fileNum - 1; i >= index; i--)
2025-06-27 00:32:57 +08:00
{
2025-07-01 00:09:47 +08:00
mymemcpy(&filder->file[i + 1], &filder->file[i], sizeof(Filder_FildInfo));
2025-06-27 00:32:57 +08:00
}
2025-07-05 19:47:28 +08:00
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ
2025-07-01 00:09:47 +08:00
mymemcpy(&filder->file[index], file, sizeof(Filder_FildInfo));
2025-06-27 00:32:57 +08:00
filder->fileNum++;
2025-07-01 00:09:47 +08:00
2025-07-05 19:47:28 +08:00
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>У<EFBFBD><D0A3>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF>1
2025-07-01 00:09:47 +08:00
if (file->type == FILDER_DIR_TYPE)
{
filder->dirNum++;
}
2025-06-27 00:32:57 +08:00
}
else
{
2025-07-01 00:09:47 +08:00
FILDER_AddItem(filder, file);
2025-06-27 00:32:57 +08:00
}
2025-07-01 00:09:47 +08:00
}
2025-06-27 00:32:57 +08:00
}
2025-07-05 19:47:28 +08:00
// <20><>ջ
2025-07-01 00:09:47 +08:00
int FILDER_PathPush(WIN_FilderStruct *filder)
2025-06-27 00:32:57 +08:00
{
2025-07-01 00:09:47 +08:00
if (filder->path.fileNum < FILDER_DIR_DEPTH)
2025-06-27 00:32:57 +08:00
{
2025-07-01 00:09:47 +08:00
for (int i = filder->path.fileNum; i > 0; i--)
2025-06-27 00:32:57 +08:00
{
2025-07-01 00:09:47 +08:00
filder->path.first[i] = filder->path.first[i - 1];
filder->path.index[i] = filder->path.index[i - 1];
2025-06-27 00:32:57 +08:00
}
2025-07-01 00:09:47 +08:00
filder->path.first[0] = filder->firstItemOnPage;
filder->path.index[0] = filder->index;
2025-06-27 00:32:57 +08:00
filder->path.fileNum++;
return 0;
}
return -1;
}
2025-07-05 19:47:28 +08:00
// <20><>ջ
2025-07-01 00:09:47 +08:00
int FILDER_PathPull(WIN_FilderStruct *filder)
2025-06-27 00:32:57 +08:00
{
if (filder->path.fileNum)
{
2025-07-01 00:09:47 +08:00
filder->firstItemOnPage = filder->path.first[0];
filder->index = filder->path.index[0];
2025-06-27 00:32:57 +08:00
filder->path.fileNum--;
2025-07-01 00:09:47 +08:00
for (int i = 0; i < filder->path.fileNum; i++)
2025-06-27 00:32:57 +08:00
{
2025-07-01 00:09:47 +08:00
filder->path.first[i] = filder->path.first[i + 1];
filder->path.index[i] = filder->path.index[i + 1];
2025-06-27 00:32:57 +08:00
}
return 0;
}
return -1;
}
2025-07-05 19:47:28 +08:00
// <20><><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>׷<EFBFBD>ӵ<EFBFBD>Ŀ¼<C4BF><C2BC>ͬʱɨ<CAB1><C9A8>·<EFBFBD><C2B7><EFBFBD>µ<EFBFBD><C2B5>ļ<EFBFBD>,Ŀ<><EFBFBD><EAB2BB>Ŀ¼ʱ<C2BC><CAB1><EFBFBD><EFBFBD>-1
2025-07-01 00:09:47 +08:00
int FILDER_DirAppend(WIN_FilderStruct *filder, Filder_FildInfo *file)
2025-06-27 00:32:57 +08:00
{
2025-07-01 00:09:47 +08:00
int dir_len = strlen(filder->dirName);
if (file->type == FILDER_DIR_TYPE)
2025-06-27 00:32:57 +08:00
{
2025-07-01 00:09:47 +08:00
filder->dirName[dir_len] = '/';
2025-06-27 00:32:57 +08:00
dir_len++;
2025-07-01 00:09:47 +08:00
mymemcpy(&filder->dirName[dir_len], file->name, strlen(file->name) + 1);
FILDER_PathPush(filder);
2025-06-27 00:32:57 +08:00
FILDER_ClearItem(filder);
2025-07-01 00:09:47 +08:00
FILDER_ScanFile(filder);
FILDER_SetIndex(filder, 0);
2025-06-27 00:32:57 +08:00
return 0;
}
else
{
return -1;
}
}
2025-07-05 19:47:28 +08:00
// <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>Ŀ¼<C4BF><C2BC>ͬʱɨ<CAB1><C9A8>Ŀ¼<C4BF>µ<EFBFBD><C2B5>ļ<EFBFBD>,<2C><><EFBFBD>ܼ<EFBFBD><DCBC><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>-1
2025-07-01 00:09:47 +08:00
int FILDER_DirCut(WIN_FilderStruct *filder)
2025-06-27 00:32:57 +08:00
{
2025-07-01 00:09:47 +08:00
int dir_len = strlen(filder->dirName);
if (dir_len == 0)
return -1;
char *ptr_name = &filder->dirName[dir_len - 1];
while (*ptr_name && (*ptr_name != '/') && (*ptr_name != ':'))
{
*ptr_name = 0;
ptr_name--;
}
if (*ptr_name == '/')
{
*ptr_name = 0;
2025-06-27 00:32:57 +08:00
FILDER_ClearItem(filder);
FILDER_PathPull(filder);
2025-07-01 00:09:47 +08:00
FILDER_ScanFile(filder);
FILDER_SetIndex(filder, filder->index);
2025-06-27 00:32:57 +08:00
return 0;
}
else
{
return -1;
}
}
2025-07-05 19:47:28 +08:00
// <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>·<EFBFBD><C2B7>
2025-07-01 00:09:47 +08:00
void FILDER_GetFileRoute(WIN_FilderStruct *filder)
2025-06-27 00:32:57 +08:00
{
2025-07-01 00:09:47 +08:00
int dir_len = strlen(filder->dirName);
mymemcpy(filder->fileName, filder->dirName, dir_len + 1);
filder->fileName[dir_len] = '/';
2025-06-27 00:32:57 +08:00
dir_len++;
2025-07-01 00:09:47 +08:00
mymemcpy(&filder->fileName[dir_len], filder->file[filder->index].name, strlen(filder->file[filder->index].name) + 1);
2025-06-27 00:32:57 +08:00
}
2025-07-05 19:47:28 +08:00
// ɨ<><C9A8><EFBFBD>ļ<EFBFBD>
2025-07-01 00:09:47 +08:00
void FILDER_ScanFile(WIN_FilderStruct *filder)
2025-06-27 00:32:57 +08:00
{
2025-07-01 00:09:47 +08:00
FRESULT ret = FR_OK;
DIR dir = {0};
FILINFO *file_info = 0;
Filder_FildInfo *file_info_x = 0;
file_info = mymalloc(sizeof(FILINFO));
file_info_x = mymalloc(sizeof(Filder_FildInfo));
ret = f_findfirst(&dir, file_info, filder->dirName, "*");
while ((ret == FR_OK) && (file_info->fname[0] != 0))
{
mymemcpy(file_info_x->name, file_info->fname, strlen(file_info->fname) + 1);
file_info_x->size = file_info->fsize;
if (AM_DIR & file_info->fattrib)
{
file_info_x->type = FILDER_DIR_TYPE;
}
else
{
file_info_x->type = FILDER_FILE_TYPE;
}
if (filder->fileNum < FILDER_FILE_MAXNUM)
{
if (file_info_x->type == FILDER_DIR_TYPE)
2025-06-27 00:32:57 +08:00
{
2025-07-01 00:09:47 +08:00
FILDER_InsertItem(filder, file_info_x, filder->dirNum);
2025-06-27 00:32:57 +08:00
}
else
{
2025-07-01 00:09:47 +08:00
FILDER_AddItem(filder, file_info_x);
2025-06-27 00:32:57 +08:00
}
}
else
{
break;
}
2025-07-01 00:09:47 +08:00
ret = f_findnext(&dir, file_info);
2025-06-27 00:32:57 +08:00
}
myfree(file_info);
myfree(file_info_x);
}
2025-07-05 19:47:28 +08:00
// <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
2025-07-01 00:09:47 +08:00
void FILDER_OpenFile(WIN_FilderStruct *filder)
2025-06-27 00:32:57 +08:00
{
2025-07-01 00:09:47 +08:00
int str_len = strlen(filder->file[filder->index].name);
char *p_str = &filder->file[filder->index].name[str_len - 4];
if (strcmp(p_str, ".jpg") == 0)
2025-06-27 00:32:57 +08:00
{
FILDER_GetFileRoute(filder);
2025-07-01 00:09:47 +08:00
PHOTO_ShowPhoto((WIN_WindowStruct *)filder, filder->fileName);
2025-06-27 00:32:57 +08:00
}
2025-07-01 00:09:47 +08:00
else if (strcmp(p_str, ".bmp") == 0)
2025-06-27 00:32:57 +08:00
{
FILDER_GetFileRoute(filder);
2025-07-01 00:09:47 +08:00
PHOTO_ShowPhoto((WIN_WindowStruct *)filder, filder->fileName);
2025-06-27 00:32:57 +08:00
}
2025-07-01 00:09:47 +08:00
else if (strcmp(p_str, ".png") == 0)
2025-06-27 00:32:57 +08:00
{
FILDER_GetFileRoute(filder);
2025-07-01 00:09:47 +08:00
PHOTO_ShowPhoto((WIN_WindowStruct *)filder, filder->fileName);
2025-06-27 00:32:57 +08:00
}
2025-07-01 00:09:47 +08:00
else if (strcmp(p_str, ".pic") == 0)
2025-06-27 00:32:57 +08:00
{
FILDER_GetFileRoute(filder);
2025-07-01 00:09:47 +08:00
WIN_PicStruct pic = {0};
u32 file_size = 0;
u8 *data = 0;
FIL *file = mymalloc(sizeof(FIL));
FILINFO *file_info = mymalloc(sizeof(FILINFO));
2025-06-27 00:32:57 +08:00
UINT br;
2025-07-01 00:09:47 +08:00
u8 res = 0;
f_stat((char *)filder->fileName, file_info);
data = mymalloc(file_info->fsize);
f_open(file, (char *)filder->fileName, FA_READ);
f_read(file, data, file_info->fsize, &br);
2025-06-27 00:32:57 +08:00
f_close(file);
2025-07-01 00:09:47 +08:00
res = WIN_GetImageSize((u8 *)data, &pic.xsize, &pic.ysize);
if (res == 0)
{
pic.data = (u16 *)(data + 8);
}
PHOTO_ShowPic((WIN_WindowStruct *)filder, &pic);
2025-06-27 00:32:57 +08:00
myfree(data);
myfree(file);
myfree(file_info);
}
2025-07-01 00:09:47 +08:00
else if (strcmp(p_str, ".gif") == 0)
2025-06-27 00:32:57 +08:00
{
FILDER_GetFileRoute(filder);
2025-07-01 00:09:47 +08:00
ANIMATION_ShowGif((WIN_WindowStruct *)filder, (char *)filder->fileName);
2025-06-27 00:32:57 +08:00
}
2025-07-01 00:09:47 +08:00
else if ((strcmp(p_str, ".nes") == 0) || (strcmp(p_str, ".NES") == 0))
2025-06-27 00:32:57 +08:00
{
FILDER_GetFileRoute(filder);
WIN_KeyShieldOn();
nes_load ((u8*)filder->fileName,LCD_GetShowAddr(),LCD_GetLcdSizeX()/2-128,LCD_GetLcdSizeY()/2-120);
2025-06-27 00:32:57 +08:00
WIN_KeyShieldOff();
}
2025-07-01 00:09:47 +08:00
else if (strcmp(p_str, ".avi") == 0)
2025-06-27 00:32:57 +08:00
{
FILDER_GetFileRoute(filder);
WIN_KeyShieldOn();
2025-07-01 00:09:47 +08:00
int ret = video_play(filder->fileName, 0);
2025-06-27 00:32:57 +08:00
WIN_KeyShieldOff();
}
2025-07-01 00:09:47 +08:00
else if (strcmp(p_str, ".mp3") == 0)
2025-06-27 00:32:57 +08:00
{
FILDER_GetFileRoute(filder);
2025-07-01 00:09:47 +08:00
MUSIC_PlaySong((WIN_WindowStruct *)filder, filder->fileName);
2025-06-27 00:32:57 +08:00
}
2025-07-01 00:09:47 +08:00
else if (strcmp(p_str, ".axf") == 0)
2025-06-27 00:32:57 +08:00
{
2025-07-05 19:47:28 +08:00
// ִ<>г<EFBFBD><D0B3><EFBFBD><EFBFBD>ļ<EFBFBD>
2025-06-27 00:32:57 +08:00
FILDER_GetFileRoute(filder);
app_run_path(filder->fileName);
}
2025-07-01 00:09:47 +08:00
else if (strcmp(p_str, ".lua") == 0)
2025-06-27 00:32:57 +08:00
{
2025-07-05 19:47:28 +08:00
// ִ<><D6B4>lua<75>ű<EFBFBD>
2025-06-27 00:32:57 +08:00
FILDER_GetFileRoute(filder);
2025-07-01 00:09:47 +08:00
DEBUG_EnterPrintCmd(filder->fileName);
}
2025-06-27 00:32:57 +08:00
else
{
2025-07-05 19:47:28 +08:00
MSGBOX_TipsTime((WIN_WindowStruct *)filder, "<EFBFBD><EFBFBD>ʾ", "<EFBFBD><EFBFBD>֧<EFBFBD>ֵ<EFBFBD><EFBFBD>ļ<EFBFBD>", "ȷ<EFBFBD><EFBFBD>", 5000);
2025-06-27 00:32:57 +08:00
}
}
2025-07-01 00:09:47 +08:00
void FILDER_PaintItem(WIN_FilderStruct *filder, int index)
2025-06-27 00:32:57 +08:00
{
2025-07-01 00:09:47 +08:00
if (index < 0 || index >= filder->fileNum)
return;
int x = 0;
int y = filder->titleHight + filder->y_off + (index - filder->firstItemOnPage) * filder->itemHight;
int x_size = ((WIN_WindowStruct *)filder)->x_size;
int y_size = filder->itemHight;
Filder_FildInfo *file = &filder->file[index];
2025-07-05 19:47:28 +08:00
// <20><>ʾͼ<CABE><CDBC>
2025-07-01 00:09:47 +08:00
int img_xsize = 0;
int img_ysize = 0;
char *img = 0;
if (file->type == FILDER_DIR_TYPE)
{
img = filder->imgDir;
}
else
{
img = filder->imgFile;
}
if (img)
{
WIN_PicStruct *pic = WIN_GetPic(img);
if (pic)
{
WIN_DrawPic(pic, x + (filder->itemIndent - pic->xsize) / 2, y + (y_size - img_ysize) / 2,
pic->xsize, pic->ysize);
}
}
2025-07-05 19:47:28 +08:00
// <20><>ʾ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
// RECT_Struct rs={0};//<2F><><EFBFBD>ڲü<DAB2><C3BC><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD>ľ<EFBFBD><C4BE><EFBFBD>
2025-07-01 00:09:47 +08:00
// rs.x=x+filder->itemIndent;rs.y=y;
// rs.x_size=x_size-filder->scrollbar_xsize-filder->itemIndent-1;
// rs.y_size=y_size;
// WIN_SetWinInvalidRect (((WIN_WindowStruct *)filder),&rs);
if (index == filder->index)
WIN_DrawTxtAt(file->name, x + filder->itemIndent + filder->scroll_x, y + y_size / 2 - WIN_GetFontHight() / 2);
else
WIN_DrawTxtAt(file->name, x + filder->itemIndent, y + y_size / 2 - WIN_GetFontHight() / 2);
2025-06-27 00:32:57 +08:00
}
2025-07-05 19:47:28 +08:00
// <20><><EFBFBD>ƺ<EFBFBD><C6BA><EFBFBD>
2025-07-01 00:09:47 +08:00
void FILDER_DefaultPaint(WIN_FilderStruct *filder)
2025-06-27 00:32:57 +08:00
{
2025-07-05 19:47:28 +08:00
// ʹ<><CAB9>˫<EFBFBD><CBAB><EFBFBD><EFBFBD><E5A3AC>ֹ<EFBFBD><D6B9>˸
2025-07-01 00:09:47 +08:00
// LCD_LayerBufferOn();
int x = 0;
int y = 0;
int x_size = ((WIN_WindowStruct *)filder)->x_size;
int y_size = ((WIN_WindowStruct *)filder)->y_size;
char txt_buff[20] = {0};
WIN_PaintBackGround((WIN_WindowStruct *)filder);
2025-07-05 19:47:28 +08:00
// <20><><EFBFBD>ƹ<EFBFBD><C6B9><EFBFBD><EFBFBD><EFBFBD>
2025-07-01 00:09:47 +08:00
int scrollbar_x = x_size - filder->scrollbar_xsize;
int scrollbar_y = y + filder->titleHight;
int scrollbar_xsize = filder->scrollbar_xsize;
int scrollbar_ysize = y_size - scrollbar_y;
int scrollbar_tstart = filder->firstItemOnPage * scrollbar_ysize / filder->fileNum;
int scrollbar_tsize = filder->itemNumOnePage * scrollbar_ysize / filder->fileNum;
WIN_SetLcdColor(((WIN_WindowStruct *)filder)->color);
WIN_DrawHLine(scrollbar_x, scrollbar_y, scrollbar_x + scrollbar_xsize - 1);
WIN_DrawHLine(scrollbar_x, scrollbar_y + scrollbar_ysize - 1, scrollbar_x + scrollbar_xsize - 1);
WIN_DrawVLine(scrollbar_x, scrollbar_y, scrollbar_y + scrollbar_ysize - 1);
WIN_DrawVLine(scrollbar_x + scrollbar_xsize - 1, scrollbar_y, scrollbar_y + scrollbar_ysize - 1);
WIN_FillRectByColor(scrollbar_x, scrollbar_y + scrollbar_tstart, scrollbar_xsize, scrollbar_tsize);
2025-07-05 19:47:28 +08:00
// <20><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
2025-07-01 00:09:47 +08:00
WIN_SetFontMode(WIN_DRAWMODE_ALONE);
2025-07-05 19:47:28 +08:00
WIN_DrawTxtHCenterAt("<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", x_size / 2, filder->titleHight / 2 - WIN_GetFontHight() / 2);
2025-07-01 00:09:47 +08:00
2025-07-05 19:47:28 +08:00
// <20><>ʾ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>Ϣ
2025-07-01 00:09:47 +08:00
sprintf(txt_buff, "%d/%d", filder->index + 1, filder->fileNum);
WIN_DrawTxtAt(txt_buff, x_size - WIN_GetFontWidth() * strlen(txt_buff) / 2 - 1, filder->titleHight / 2 - WIN_GetFontHight() / 2);
2025-07-05 19:47:28 +08:00
// <20><>ʾѡ<CABE>п<EFBFBD>
2025-07-01 00:09:47 +08:00
int selete_x = x;
int selete_y = y + filder->titleHight;
int selete_xsize = x_size - scrollbar_xsize - 1;
int selete_ysize = filder->itemHight;
WIN_SetLcdColor(0x00ffff);
selete_y += filder->itemHight * (filder->index - filder->firstItemOnPage);
WIN_FillRectByColorAlpha(selete_x, selete_y, selete_xsize, selete_ysize, 16);
2025-07-05 19:47:28 +08:00
// <20><>ʾ<EFBFBD>ļ<EFBFBD>
RECT_Struct rs = {0}; // <20><><EFBFBD>ڲü<DAB2><C3BC><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD>ľ<EFBFBD><C4BE><EFBFBD>
2025-07-01 00:09:47 +08:00
rs.x = x;
rs.y = y + filder->titleHight;
rs.x_size = x_size - scrollbar_xsize - 1;
rs.y_size = y_size - rs.y;
WIN_SetLcdColor(((WIN_WindowStruct *)filder)->color);
WIN_SetWinInvalidRect(((WIN_WindowStruct *)filder), &rs);
for (int i = 0; i < filder->itemNumOnePage + 2; i++)
{
FILDER_PaintItem(filder, i + filder->firstItemOnPage - 1);
}
WIN_SetWinInvalidRect(((WIN_WindowStruct *)filder), 0);
2025-06-27 00:32:57 +08:00
}
typedef struct
{
char *name;
char *path;
2025-07-01 00:09:47 +08:00
} sysfile_updata_struct;
2025-06-27 00:32:57 +08:00
2025-07-01 00:09:47 +08:00
static int sysfile_updata(void *ptr)
2025-06-27 00:32:57 +08:00
{
2025-07-01 00:09:47 +08:00
sysfile_updata_struct *t = ptr;
SysFile_Updata(t->name, t->path);
2025-06-27 00:32:57 +08:00
return 0;
}
2025-07-01 00:09:47 +08:00
static void FILDER_Down(WIN_FilderStruct *filder)
2025-06-27 00:32:57 +08:00
{
2025-07-01 00:09:47 +08:00
if (filder->index < filder->fileNum - 1)
2025-06-27 00:32:57 +08:00
{
2025-07-01 00:09:47 +08:00
FILDER_SetIndex(filder, filder->index + 1);
if (filder->index >= filder->firstItemOnPage + filder->itemNumOnePage)
2025-06-27 00:32:57 +08:00
{
filder->firstItemOnPage++;
}
}
else
{
2025-07-01 00:09:47 +08:00
FILDER_SetIndex(filder, 0);
filder->firstItemOnPage = 0;
2025-06-27 00:32:57 +08:00
}
}
2025-07-01 00:09:47 +08:00
static void FILDER_Up(WIN_FilderStruct *filder)
2025-06-27 00:32:57 +08:00
{
2025-07-01 00:09:47 +08:00
if (filder->index > 0)
2025-06-27 00:32:57 +08:00
{
2025-07-01 00:09:47 +08:00
FILDER_SetIndex(filder, filder->index - 1);
if (filder->index < filder->firstItemOnPage)
2025-06-27 00:32:57 +08:00
{
filder->firstItemOnPage--;
}
}
else
{
2025-07-01 00:09:47 +08:00
FILDER_SetIndex(filder, filder->fileNum - 1);
if (filder->fileNum > filder->itemNumOnePage)
filder->firstItemOnPage = filder->fileNum - filder->itemNumOnePage;
else
filder->firstItemOnPage = 0;
2025-06-27 00:32:57 +08:00
}
}
static int g_send_file(void *t);
2025-07-01 00:09:47 +08:00
static int set_progress(int now, int all);
static void get_progress(int *now, int *all);
static int g_send(void *data, int size);
2025-06-27 00:32:57 +08:00
2025-07-01 00:09:47 +08:00
static void FILDER_Enter(WIN_FilderStruct *filder, int x, int y)
2025-06-27 00:32:57 +08:00
{
2025-07-05 19:47:28 +08:00
// <20><><EFBFBD><EFBFBD>
2025-07-01 00:09:47 +08:00
if (FILDER_DirAppend(filder, &filder->file[filder->index]) == -1)
2025-06-27 00:32:57 +08:00
{
2025-07-05 19:47:28 +08:00
// <20><><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>Ĵ<EFBFBD><C4B4><EFBFBD>
2025-07-01 00:09:47 +08:00
int index = POPUP_SelectItem((WIN_WindowStruct *)filder, (char **)g_popup_itmes, 6, x, y);
if (index == 0)
2025-06-27 00:32:57 +08:00
{
FILDER_OpenFile(filder);
}
2025-07-01 00:09:47 +08:00
else if (index == 1)
2025-06-27 00:32:57 +08:00
{
2025-07-05 19:47:28 +08:00
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2025-07-01 00:09:47 +08:00
char *txt_buff = mymalloc(256);
mymemcpy(txt_buff, filder->file[filder->index].name, strlen(filder->file[filder->index].name) + 1);
if (INPUT_KeyBoard((WIN_WindowStruct *)filder, txt_buff, 256) == 1)
2025-06-27 00:32:57 +08:00
{
2025-07-01 00:09:47 +08:00
char *txt_path_old = mymalloc(256);
FILDER_GetFileRoute(filder);
2025-07-05 19:47:28 +08:00
mymemcpy(txt_path_old, filder->fileName, strlen(filder->fileName) + 1); // ԭʼ·<CABC><C2B7>
mymemcpy(filder->file[filder->index].name, txt_buff, strlen(txt_buff) + 1); // <20><><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
FILDER_GetFileRoute(filder); // <20><>·<EFBFBD><C2B7>
2025-07-01 00:09:47 +08:00
if (f_rename(txt_path_old, filder->fileName) == FR_OK)
2025-06-27 00:32:57 +08:00
{
2025-07-05 19:47:28 +08:00
MSGBOX_TipsTime((WIN_WindowStruct *)filder, "<EFBFBD><EFBFBD>ʾ", "<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸ijɹ<EFBFBD>", "ȷ<EFBFBD><EFBFBD>", 5000);
2025-07-01 00:09:47 +08:00
}
else
2025-06-27 00:32:57 +08:00
{
2025-07-05 19:47:28 +08:00
MSGBOX_TipsTime((WIN_WindowStruct *)filder, "<EFBFBD><EFBFBD>ʾ", "<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸<EFBFBD>ʧ<EFBFBD><EFBFBD>", "ȷ<EFBFBD><EFBFBD>", 5000);
2025-06-27 00:32:57 +08:00
}
2025-07-01 00:09:47 +08:00
myfree(txt_path_old);
2025-06-27 00:32:57 +08:00
}
myfree(txt_buff);
}
2025-07-01 00:09:47 +08:00
else if (index == 2)
2025-06-27 00:32:57 +08:00
{
2025-07-05 19:47:28 +08:00
// <20><><EFBFBD>Ƶ<EFBFBD>ϵͳ<CFB5>ļ<EFBFBD>
2025-06-27 00:32:57 +08:00
FILDER_GetFileRoute(filder);
2025-07-01 00:09:47 +08:00
// SysFile_Updata (filder->file[filder->index].name,filder->fileName);
sysfile_updata_struct upd = {0};
upd.name = filder->file[filder->index].name;
upd.path = filder->fileName;
2025-07-05 19:47:28 +08:00
WORKING_DoWork((WIN_WindowStruct *)filder, "<EFBFBD><EFBFBD><EFBFBD>ڸ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>ϵͳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", sysfile_updata, &upd);
2025-07-01 00:09:47 +08:00
2025-07-05 19:47:28 +08:00
MSGBOX_TipsTime((WIN_WindowStruct *)filder, "<EFBFBD><EFBFBD>ʾ", "<EFBFBD>Ѹ<EFBFBD><EFBFBD>Ƶ<EFBFBD>ϵͳ<EFBFBD>ļ<EFBFBD>", "ȷ<EFBFBD><EFBFBD>", 5000);
2025-06-27 00:32:57 +08:00
}
2025-07-01 00:09:47 +08:00
else if (index == 3)
2025-06-27 00:32:57 +08:00
{
2025-07-05 19:47:28 +08:00
// <20>ļ<EFBFBD><C4BC><EFBFBD>Ϣ
2025-07-01 00:09:47 +08:00
char *txt_buff = mymalloc(512);
2025-06-27 00:32:57 +08:00
FILDER_GetFileRoute(filder);
2025-07-10 00:08:56 +08:00
sprintf(txt_buff, "·<EFBFBD><EFBFBD><EFBFBD><EFBFBD>%s\n<EFBFBD><EFBFBD>С<EFBFBD><EFBFBD>%u Byte", filder->fileName, (uint32_t)filder->file[filder->index].size);
2025-07-05 19:47:28 +08:00
MSGBOX_Tips((WIN_WindowStruct *)filder, "<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>Ϣ", txt_buff, "ȷ<EFBFBD><EFBFBD>");
2025-06-27 00:32:57 +08:00
myfree(txt_buff);
}
2025-07-01 00:09:47 +08:00
else if (index == 4)
2025-06-27 00:32:57 +08:00
{
2025-07-05 19:47:28 +08:00
// ɾ<><C9BE>
if (MSGBOX_Inquiry((WIN_WindowStruct *)filder, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>", "ȷ<EFBFBD><EFBFBD>ɾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", "ȷ<EFBFBD><EFBFBD>", "ȡ<EFBFBD><EFBFBD>") == 0)
2025-06-27 00:32:57 +08:00
{
FILDER_GetFileRoute(filder);
2025-07-01 00:09:47 +08:00
if (f_unlink(filder->fileName) == FR_OK)
2025-06-27 00:32:57 +08:00
{
2025-07-05 19:47:28 +08:00
MSGBOX_TipsTime((WIN_WindowStruct *)filder, "<EFBFBD><EFBFBD>ʾ", "<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><EFBFBD>", "ȷ<EFBFBD><EFBFBD>", 5000);
2025-06-27 00:32:57 +08:00
FILDER_ClearItem(filder);
2025-07-01 00:09:47 +08:00
FILDER_ScanFile(filder);
2025-06-27 00:32:57 +08:00
}
else
{
2025-07-05 19:47:28 +08:00
MSGBOX_TipsTime((WIN_WindowStruct *)filder, "<EFBFBD><EFBFBD>ʾ", "ɾ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>ʧ<EFBFBD><EFBFBD>", "ȷ<EFBFBD><EFBFBD>", 5000);
2025-06-27 00:32:57 +08:00
}
}
}
2025-07-01 00:09:47 +08:00
else if (index == 5)
{
2025-07-05 19:47:28 +08:00
// <20><><EFBFBD><EFBFBD>
2025-07-01 00:09:47 +08:00
FILDER_GetFileRoute(filder);
SysFile_SendStruct send;
SysFile_SendFileInit(&send, filder->file[filder->index].name, filder->fileName,
g_send, set_progress);
2025-07-05 19:47:28 +08:00
int ret = WORKING_DoWorkPro((WIN_WindowStruct *)filder, "<EFBFBD><EFBFBD><EFBFBD>ڷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>", g_send_file, &send,
2025-07-01 00:09:47 +08:00
0, 0, get_progress, 25);
if (ret == 0)
2025-07-05 19:47:28 +08:00
MSGBOX_TipsTime((WIN_WindowStruct *)filder, "<EFBFBD><EFBFBD>ʾ", "<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͳɹ<EFBFBD>", "ȷ<EFBFBD><EFBFBD>", 5000);
2025-07-01 00:09:47 +08:00
else
2025-07-05 19:47:28 +08:00
MSGBOX_TipsTime((WIN_WindowStruct *)filder, "<EFBFBD><EFBFBD>ʾ", "<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>", "ȷ<EFBFBD><EFBFBD>", 5000);
2025-07-01 00:09:47 +08:00
}
} // if (FILDER_DirAppend (filder,&filder->file[filder->index])==-1)
2025-06-27 00:32:57 +08:00
}
static int g_send_now;
static int g_send_all;
2025-07-01 00:09:47 +08:00
static int set_progress(int now, int all)
2025-06-27 00:32:57 +08:00
{
2025-07-01 00:09:47 +08:00
g_send_now = now;
g_send_all = all;
return 0;
}
static void get_progress(int *now, int *all)
2025-06-27 00:32:57 +08:00
{
2025-07-01 00:09:47 +08:00
*now = g_send_now;
*all = g_send_all;
2025-06-27 00:32:57 +08:00
}
2025-07-01 00:09:47 +08:00
static int g_send(void *data, int size)
2025-06-27 00:32:57 +08:00
{
2025-07-01 00:09:47 +08:00
if (nrf_send(data, size, 0) == NRF_OK)
return 0;
else
return -1;
2025-06-27 00:32:57 +08:00
}
static int g_send_file(void *t)
{
2025-07-01 00:09:47 +08:00
g_send_now = 0;
g_send_all = 0;
SysFile_SendStruct *send = t;
int ret = 0;
ret = SysFile_SendFileName(send);
if (ret != 0)
return ret;
ret = SysFile_SendFileInfo(send);
if (ret != 0)
return ret;
ret = SysFile_SendFileData(send);
return ret;
2025-06-27 00:32:57 +08:00
}
2025-07-01 00:09:47 +08:00
static void FILDER_Home(WIN_FilderStruct *filder)
2025-06-27 00:32:57 +08:00
{
2025-07-05 19:47:28 +08:00
// <20><><EFBFBD><EFBFBD>
2025-07-01 00:09:47 +08:00
if (FILDER_DirCut(filder) == -1)
2025-06-27 00:32:57 +08:00
{
2025-07-05 19:47:28 +08:00
// <20>Ǹ<EFBFBD>Ŀ¼<C4BF>ˣ<EFBFBD><CBA3>˳<EFBFBD><CBB3>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2025-06-27 00:32:57 +08:00
((WIN_WindowStruct *)filder)->deleteWindow((WIN_WindowStruct *)filder);
}
}
2025-07-01 00:09:47 +08:00
int FILDER_GetTouchIndex(WIN_FilderStruct *filder, int x, int y)
2025-06-27 00:32:57 +08:00
{
2025-07-01 00:09:47 +08:00
if (y < filder->titleHight)
return -1;
return (y - filder->titleHight) / filder->itemHight + filder->firstItemOnPage;
2025-06-27 00:32:57 +08:00
}
2025-07-01 00:09:47 +08:00
int FILDER_SetIndex(WIN_FilderStruct *filder, int index)
2025-06-27 00:32:57 +08:00
{
2025-07-01 00:09:47 +08:00
int x_size = ((WIN_WindowStruct *)filder)->x_size - filder->itemIndent;
Filder_FildInfo *file = &filder->file[index];
filder->scroll_xsize = (strlen(file->name) + 4) * WIN_GetFontWidth() / 2;
if (filder->scroll_xsize > x_size)
{
if (filder->scroll_timer == 0)
filder->scroll_timer = WIN_CreatTimer((WIN_WindowStruct *)filder, 50);
}
else
{
if (filder->scroll_timer)
WIN_DeleteTimer(filder->scroll_timer);
filder->scroll_timer = 0;
}
filder->index = index;
filder->scroll_x = 0;
return 0;
2025-06-27 00:32:57 +08:00
}
void FILDER_ScrollTimer(WIN_FilderStruct *filder)
{
2025-07-01 00:09:47 +08:00
int x_size = ((WIN_WindowStruct *)filder)->x_size - filder->itemIndent;
int y = (filder->index - filder->firstItemOnPage) * filder->itemHight + filder->titleHight;
if (filder->scroll_x + filder->scroll_xsize > x_size)
{
filder->scroll_x -= 3;
}
else
{
filder->scroll_x = 4 * WIN_GetFontWidth() / 2;
}
WIN_SetInvalidRectWhenTop((WIN_WindowStruct *)filder, filder->itemIndent, y, x_size, filder->itemHight);
2025-06-27 00:32:57 +08:00
}
2025-07-01 00:09:47 +08:00
#define FIRST_ADD() \
{ \
if (filder->firstItemOnPage < filder->fileNum - filder->itemNumOnePage) \
{ \
filder->firstItemOnPage++; \
if (filder->index < filder->firstItemOnPage) \
FILDER_SetIndex(filder, filder->firstItemOnPage); \
filder->y_off += filder->itemHight; \
} \
else \
filder->y_off = 0; \
}
#define FIRST_SUB() \
{ \
if (filder->firstItemOnPage > 0) \
{ \
filder->firstItemOnPage--; \
if (filder->index > filder->firstItemOnPage + filder->itemNumOnePage - 1) \
FILDER_SetIndex(filder, filder->firstItemOnPage + filder->itemNumOnePage - 1); \
filder->y_off -= filder->itemHight; \
} \
else \
filder->y_off = 0; \
}
2025-06-27 00:32:57 +08:00
2025-07-01 00:09:47 +08:00
#define IS_MIDDLE() (filder->firstItemOnPage > 0 || m->y_move < 0) && (filder->firstItemOnPage < filder->fileNum - filder->itemNumOnePage || m->y_move > 0)
2025-06-27 00:32:57 +08:00
2025-07-05 19:47:28 +08:00
// <20><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2025-07-01 00:09:47 +08:00
void FILDER_defaultMsgLoop(WIN_FilderStruct *filder, WIN_MsgStruct *msg)
2025-06-27 00:32:57 +08:00
{
2025-07-01 00:09:47 +08:00
WIN_MoveStruct *m = 0;
WIN_KeyStruct *k = 0;
2025-06-27 00:32:57 +08:00
switch (msg->msg)
2025-07-01 00:09:47 +08:00
{
case WIN_MSG_PAINT:
FILDER_DefaultPaint(filder);
2025-06-27 00:32:57 +08:00
break;
2025-07-01 00:09:47 +08:00
case WIN_MSG_TIMER:
if (msg->data.v == filder->scroll_timer)
{
FILDER_ScrollTimer(filder);
}
break;
case WIN_MSG_KEY:
k = msg->data.p;
2025-07-05 19:47:28 +08:00
// <20>յ<EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD>򷵻ؼ<F2B7B5BB>
2025-07-01 00:09:47 +08:00
if (k->shortPress & KEY_VALUE_DOWN)
{
FILDER_Down(filder);
} // if (k->shortPress&KEY_VALUE_DOWN)
else if (k->shortPress & KEY_VALUE_UP)
{
FILDER_Up(filder);
} // else if (k->shortPress&KEY_VALUE_UP)
else if (k->shortPress & KEY_VALUE_ENTER)
{
FILDER_Enter(filder, 100, 100);
}
else if (k->shortPress & KEY_VALUE_HOME)
{
FILDER_Home(filder);
}
if (k->shortPress)
{
WIN_SetInvalid((WIN_WindowStruct *)filder);
}
break; // case WIN_MSG_KEY:
case WIN_MSG_MOVE:
m = msg->data.p;
switch (m->moveType)
{
case MOVE_DATA_SHORT:
{
int index = FILDER_GetTouchIndex(filder, m->x_move, m->y_move);
if (index == filder->index)
2025-06-27 00:32:57 +08:00
{
2025-07-01 00:09:47 +08:00
FILDER_Enter(filder, m->x_move, m->y_move);
}
else if (index != -1)
2025-06-27 00:32:57 +08:00
{
2025-07-01 00:09:47 +08:00
FILDER_SetIndex(filder, index);
2025-06-27 00:32:57 +08:00
}
2025-07-01 00:09:47 +08:00
else
2025-06-27 00:32:57 +08:00
{
FILDER_Home(filder);
}
2025-07-01 00:09:47 +08:00
WIN_SetInvalid((WIN_WindowStruct *)filder);
}
break;
case MOVE_DATA_MOVED:
if (IS_MIDDLE())
2025-06-27 00:32:57 +08:00
{
2025-07-01 00:09:47 +08:00
filder->y_off += m->y_move;
if (filder->y_off >= filder->itemHight)
{
FIRST_SUB();
}
else if (filder->y_off <= -filder->itemHight)
{
FIRST_ADD();
}
if (m->y_move == 0 && m->x_move == 0)
{
filder->y_off = 0;
}
2025-06-27 00:32:57 +08:00
}
2025-07-01 00:09:47 +08:00
else
2025-06-27 00:32:57 +08:00
{
2025-07-01 00:09:47 +08:00
filder->y_off = 0;
2025-06-27 00:32:57 +08:00
}
2025-07-01 00:09:47 +08:00
WIN_SetInvalidWhenTop((WIN_WindowStruct *)filder);
2025-06-27 00:32:57 +08:00
break;
2025-07-01 00:09:47 +08:00
default:
WIN_DefaultMsgLoop((WIN_WindowStruct *)filder, msg);
break;
}
break;
case WIN_MSG_CHID:
switch (msg->data.v)
{
case CHID_DELETE:
break;
case CHID_USER:
{
if (msg->data2.v == BUTTON_PRESSED)
2025-06-27 00:32:57 +08:00
{
2025-07-01 00:09:47 +08:00
// if (msg->srcWin==filder->key_back)
// {
2025-07-05 19:47:28 +08:00
// //<2F><><EFBFBD><EFBFBD>
2025-07-01 00:09:47 +08:00
// FILDER_Home(filder);
// }
// else if (msg->srcWin==filder->key_up)
// {
// FILDER_Up(filder);
// }
// else if (msg->srcWin==filder->key_down)
// {
// FILDER_Down(filder);
// }
// else if (msg->srcWin==filder->key_enter)
// {
// FILDER_Enter(filder);
// }
// WIN_SetInvalid((WIN_WindowStruct *)filder);
2025-06-27 00:32:57 +08:00
}
2025-07-01 00:09:47 +08:00
}
break;
2025-06-27 00:32:57 +08:00
default:
2025-07-01 00:09:47 +08:00
break;
}
break;
default:
WIN_DefaultMsgLoop((WIN_WindowStruct *)filder, msg);
2025-06-27 00:32:57 +08:00
break;
}
}
2025-07-05 19:47:28 +08:00
// ѡ<><D1A1><EFBFBD>ļ<EFBFBD>
2025-07-01 00:09:47 +08:00
int FILDER_ChooseFile(WIN_WindowStruct *win, char *dir)
2025-06-27 00:32:57 +08:00
{
2025-07-01 00:09:47 +08:00
WIN_FilderStruct *filder = 0;
if (win)
2025-06-27 00:32:57 +08:00
{
2025-07-01 00:09:47 +08:00
filder = WIN_CreatFilder(win, 0, 0, 0, win->x_size, win->y_size);
2025-06-27 00:32:57 +08:00
}
2025-07-01 00:09:47 +08:00
else
filder = WIN_CreatFilder(0, 0, 0, 0, WIN_GetWinStruct()->lcd->getLcdSizeX(), WIN_GetWinStruct()->lcd->getLcdSizeY());
WIN_SetBackPicPath((WIN_WindowStruct *)filder, win->pic_path);
FILDER_SetFileDir(filder, dir);
2025-06-27 00:32:57 +08:00
WIN_ShowWindow((WIN_WindowStruct *)filder);
2025-07-01 00:09:47 +08:00
// return WIN_RunBlock ((WIN_WindowStruct *)filder);
2025-06-27 00:32:57 +08:00
return 0;
}