#include "mywin_inc.h" #include "mywin_user_menu.h" #include "system_file.h" #include "mywin_user_tool.h" #include "ff.h" #include "elf.h" void MENU_ToolScanFile (WIN_MenuStruct *menu); //进入设置页面 WIN_MenuStruct *MENU_Tool (WIN_WindowStruct *base,WIN_PicStruct *pic) { WIN_MenuStruct *menu=WIN_CreatMenu (base,(void (*)(WIN_WindowStruct *,WIN_MsgStruct *))MENU_ToolMsgLoop, 0,0,base->x_size,base->y_size); ((WIN_WindowStruct *)menu)->intercept=1;//不发送按键消息到父窗口 WIN_SetBackPicPath ((WIN_WindowStruct *)menu,base->pic_path); MENU_SetTitle (menu,0,"工具"); MENU_SetMaxItem(menu,TOOL_APP_MAXNUM); MENU_ToolScanFile(menu); WIN_ShowWindow((WIN_WindowStruct*)menu); return menu; } void MENU_ToolScanFile (WIN_MenuStruct *menu) { FRESULT ret=FR_OK; DIR dir={0}; FILINFO *file_info=0; file_info=mymalloc (sizeof(FILINFO)); ret=f_findfirst(&dir,file_info,TOOL_APP_PATH,"*.axf"); while ((ret==FR_OK)&&(file_info->fname[0]!=0)) { if (AM_DIR&file_info->fattrib) continue; if(MENU_GetAllItemNum(menu)fname); else break; ret=f_findnext(&dir,file_info); } myfree(file_info); } static void MENU_ToolEnter (WIN_MenuStruct *menu) { //选择了一个 char *path=mymalloc(256); sprintf(path,"%s/%s",TOOL_APP_PATH,MENU_GetSelectItem(menu)); app_run_path(path); myfree(path); } static void MENU_ToolDeleteFun(WIN_MenuStruct *menu) { } //消息处理函数 void MENU_ToolMsgLoop (WIN_MenuStruct *menu,WIN_MsgStruct *msg) { WIN_MoveStruct *m=0; WIN_TouchStruct *t=0; WIN_KeyStruct *k=0; switch (msg->msg) { case WIN_MSG_KEY: k=msg->data.p; if (k->shortPress&KEY_VALUE_ENTER) { MENU_ToolEnter(menu); } else { MENU_DefaultMsgLoop (menu,msg); } break;//case WIN_MSG_KEY: case WIN_MSG_MOVE: m=msg->data.p; switch (m->moveType) { case MOVE_DATA_SHORT: // if (m->y_move>((WIN_WindowStruct *)menu)->y_size/2-20&&m->y_move<((WIN_WindowStruct *)menu)->y_size/2+20) // { // MENU_ToolEnter(menu); // } break; default: MENU_DefaultMsgLoop (menu,msg); break; } break; case WIN_MSG_CHID: switch (msg->data.v) { case CHID_DELETE: break; case CHID_USER: { if (msg->srcWin==menu->bar) { if (msg->data2.v==SCROLLBAR_PRESSED) { MENU_ToolEnter(menu); } } else { MENU_DefaultMsgLoop (menu,msg); } } break; default: break; } break; default: MENU_DefaultMsgLoop (menu,msg); break; } }