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

102 lines
2.5 KiB
C
Raw Normal View History

2025-06-27 00:32:57 +08:00
#ifndef MYWIN_USER_FILDER_H__
#define MYWIN_USER_FILDER_H__
2025-07-05 19:05:35 +08:00
// 定义列表中最大显示文件数
#define FILDER_FILE_MAXNUM 1000
2025-06-27 00:32:57 +08:00
2025-07-05 19:05:35 +08:00
// 定义最大路径深度
#define FILDER_DIR_DEPTH 10
2025-06-27 00:32:57 +08:00
2025-07-05 19:05:35 +08:00
// 定义文件类型
#define FILDER_FILE_TYPE 1
#define FILDER_DIR_TYPE 0
2025-06-27 00:32:57 +08:00
2025-07-05 19:05:35 +08:00
// 路径栈
2025-06-27 00:32:57 +08:00
typedef struct
{
int index[FILDER_DIR_DEPTH];
int first[FILDER_DIR_DEPTH];
int fileNum;
} Filder_Path;
typedef struct
{
char name[256];
2025-07-05 19:05:35 +08:00
int type; // 1,文件0文件夹
2025-06-27 00:32:57 +08:00
uint64_t size;
2025-07-05 19:05:35 +08:00
} Filder_FildInfo;
2025-06-27 00:32:57 +08:00
typedef struct
{
WIN_TouchWinStruct win;
Filder_FildInfo file[FILDER_FILE_MAXNUM];
char *imgFile;
char *imgDir;
char dirName[256];
2025-07-05 19:05:35 +08:00
char fileName[256]; // 文件路径
2025-06-27 00:32:57 +08:00
Filder_Path path;
int index;
2025-07-05 19:05:35 +08:00
int fileNum; // 条目数
int dirNum; // 文件夹数目
2025-06-27 00:32:57 +08:00
int titleHight;
int itemHight;
int itemIndent;
2025-07-05 19:05:35 +08:00
int scrollbar_xsize; // 滚动条宽度
int itemNumOnePage; // 每页显示条目数
int firstItemOnPage; // 显示在页首的条目编号
2025-06-27 00:32:57 +08:00
2025-07-05 19:05:35 +08:00
int scroll_x; // 滚动显示的x坐标
int scroll_xsize; // 混动显示的x长度
int scroll_timer; // 滚动显示使用的定时器
2025-06-27 00:32:57 +08:00
2025-07-05 19:05:35 +08:00
int y_off; // 支持触屏
} WIN_FilderStruct;
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);
// 设置文件路径,同时扫描路径下的文件
void FILDER_SetFileDir(WIN_FilderStruct *filder, char *dir);
2025-06-27 00:32:57 +08:00
2025-07-05 19:05:35 +08:00
// 入栈
int FILDER_PathPush(WIN_FilderStruct *filder);
// 出栈
int FILDER_PathPull(WIN_FilderStruct *filder);
// 把文件名追加到目录,同时扫描路径下的文件
int FILDER_DirAppend(WIN_FilderStruct *filder, Filder_FildInfo *file);
// 剪短一层目录,同时扫描目录下的文件
int FILDER_DirCut(WIN_FilderStruct *filder);
// 生成文件路径
void FILDER_GetFileRoute(WIN_FilderStruct *filder);
// 清空条目
void FILDER_ClearItem(WIN_FilderStruct *filder);
// 添加一个文件条目
void FILDER_AddItem(WIN_FilderStruct *filder, Filder_FildInfo *file);
// 在指定位置插入一个条目
void FILDER_InsertItem(WIN_FilderStruct *filder, Filder_FildInfo *file, int index);
// 扫描文件
void FILDER_ScanFile(WIN_FilderStruct *filder);
// 打开文件
void FILDER_OpenFile(WIN_FilderStruct *filder);
// 消息框的绘制函数
void FILDER_DefaultPaint(WIN_FilderStruct *filder);
// 消息框的消息处理函数
void FILDER_defaultMsgLoop(WIN_FilderStruct *filder, WIN_MsgStruct *msg);
// 选则文件
int FILDER_ChooseFile(WIN_WindowStruct *win, char *dir);
#endif