static void OpenFileProcess(int sel_num,char* record_file) { result = f_open (&listfile, FILE_LIST_PATH, FA_READ|FA_OPEN_EXISTING); //打开索引文件 if(result != FR_OK) return ; result = f_lseek (&listfile, sel_num*BROWSER_FILE_NAME_LEN); if(result != FR_OK) return ; result = f_read (&listfile, curentopenfile, BROWSER_FILE_NAME_LEN, &bw); if(result != FR_OK) return ; //printf("\nfileItem=:%s",openfile); f_close (&listfile); if(strstr(curentopenfile,".gcode")||strstr(curentopenfile,".GCODE") ||strstr(curentopenfile,".g")||strstr(curentopenfile,".G")) //判断是否是gcode文件,可以执行打印指令 { //对话框显示是否打印该文件 _ChooseFrame = CreatePrintFileWaring(); WM_MakeModal(_ChooseFrame); } #if 0 else if(strstr(openfile,".txt")||strstr(openfile,".TXT") ||strstr(openfile,".c")||strstr(openfile,".c") ||strstr(openfile,".cpp")||strstr(openfile,".CPP") ||strstr(openfile,".h")||strstr(openfile,".h"))//判断是否可以使用txt格式打开 { //printf("\ntxt file"); WM_HideWindow(hDialog); hOpenfile=FRAMEWIN_CreateEx(0,0,320,240,WM_HBKWIN,WM_CF_SHOW,0,0,0,_cbOpenfile); FRAMEWIN_SetTextColor(hOpenfile,GUI_DARKGRAY); FRAMEWIN_SetTitleHeight(hOpenfile, 20); FRAMEWIN_SetText(hOpenfile,framename); FRAMEWIN_SetTextAlign(hOpenfile, GUI_TA_LEFT | GUI_TA_VCENTER); FRAMEWIN_AddCloseButton(hOpenfile,FRAMEWIN_BUTTON_RIGHT,0); hWin=MULTIEDIT_CreateEx(5,22,295,230,hOpenfile, WM_CF_SHOW,MULTIEDIT_CF_AUTOSCROLLBAR_V|MULTIEDIT_CF_READONLY,0,0,0); MULTIEDIT_SetBkColor(hWin,MULTIEDIT_CI_READONLY,GUI_WHITE); MULTIEDIT_SetWrapWord(hWin); MULTIEDIT_AddText(hWin,txtBuffer); } #endif else { GUI_MessageBox("Sorry,do not support open the file!","Sorry",GUI_MESSAGEBOX_CF_MODAL); } }
void run_db(void) { /* printf("Database name : %s\n", db->name); printf("Database nb children : %i\n", (int)db->nb_motifs); for (uint32_t i = 0; i < db->nb_motifs; i++) { motif_t * m = db->motifs; printf(" motif %i:\n", (int)i); printf(" name : %s\n", m->name); printf(" desc : %s\n", m->desc); printf(" img : %s\n", m->image); } */ char error_404[] = "No Motifs Found in Database!"; if (db->motifs == NULL) { strcpy(current_motif_title, error_404); } else { current_motif_index = 1; //sprintf(current_motif_title, "%i/%i -- %s", (int)current_motif_index, (int)db->nb_motifs, db->motifs->name); //current_motif_desc = db->motifs->desc; update_motif(); } WM_HWIN db_nav_win = WINDOW_CreateEx( 0, 0, 800, 480, WM_HBKWIN, WM_CF_SHOW, 0, GUI_ID_USER+0, _cbrundb); WINDOW_SetBkColor(db_nav_win, GUI_WHITE); motif_name_widget = TEXT_CreateEx( 0, 0, 800, 100, db_nav_win, WM_CF_SHOW, TEXT_CF_HCENTER | TEXT_CF_VCENTER, GUI_ID_TEXT0, (const char *)current_motif_title); motif_desc_widget = MULTIEDIT_CreateEx( 100, 100, 600, 380, db_nav_win, WM_CF_SHOW, MULTIEDIT_CF_AUTOSCROLLBAR_V, GUI_ID_MULTIEDIT1, 5000, (const char *) current_motif_desc ); BUTTON_Handle bt_prev_widget = BUTTON_CreateEx( 0, 100, 100, 380, db_nav_win, WM_CF_SHOW, 0, GUI_ID_BUTTON0); BUTTON_Handle bt_next_widget = BUTTON_CreateEx( 700, 100, 100, 380, db_nav_win, WM_CF_SHOW, 0, GUI_ID_BUTTON1); TEXT_SetFont(motif_name_widget, GUI_FONT_24_1); BUTTON_SetFont(bt_prev_widget, GUI_FONT_24_1); BUTTON_SetFont(bt_next_widget, GUI_FONT_24_1); MULTIEDIT_SetFont(motif_desc_widget, GUI_FONT_24_1); MULTIEDIT_SetWrapWord(motif_desc_widget); BUTTON_SetBitmap(bt_prev_widget, BUTTON_BI_UNPRESSED, &bmarrowdefault); BUTTON_SetBitmap(bt_next_widget, BUTTON_BI_UNPRESSED, &bmarrowrdefault); BUTTON_SetBitmap(bt_prev_widget, BUTTON_BI_PRESSED , &bmarrowclicked); BUTTON_SetBitmap(bt_next_widget, BUTTON_BI_PRESSED , &bmarrowrclicked); }
/********************************************************************* * * _DemoMultiedit */ static void _DemoMultiedit(void) { GUI_RECT Rect; int WinFlags; _hFrame = 1; _Overwrite = 0; _ReadOnly = 0; _Password = 0; /* Create framewin */ _ChangeInfoText("Create framewin", SPEED); _hFrame = FRAMEWIN_CreateEx(60, 80, 200, 120, WM_HBKWIN, WM_CF_SHOW, 0, 0, "Notepad", 0); _hClient = WM_GetClientWindow(_hFrame); _pcbFrameWin = WM_SetCallback(_hFrame, _cbFrameWin); _pcbFrameWinClient = WM_SetCallback(_hClient, _cbFrameWinClient); /* Set framewin properties */ FRAMEWIN_SetMoveable(_hFrame, 1); FRAMEWIN_SetActive(_hFrame, 1); FRAMEWIN_SetTextAlign(_hFrame, GUI_TA_HCENTER | GUI_TA_VCENTER); FRAMEWIN_SetFont(_hFrame, &GUI_Font8x12_ASCII); FRAMEWIN_SetTitleHeight(_hFrame, 16); /* Add framewin buttons */ if (_ChangeInfoText("Add framewin buttons", SPEED)) return; FRAMEWIN_AddCloseButton(_hFrame, FRAMEWIN_BUTTON_LEFT, 0); FRAMEWIN_AddMaxButton(_hFrame, FRAMEWIN_BUTTON_RIGHT, 0); FRAMEWIN_AddMinButton(_hFrame, FRAMEWIN_BUTTON_RIGHT, 1); WM_InvalidateWindow(_hFrame); /* Create buttons */ if (_ChangeInfoText("Add option buttons", SPEED)) return; _hWrapButton = _CreateLButton("None", 0, 36, 16, _hClient, ID_NONEWRAP); _CreateLButton("Word", 37, 36, 16, _hClient, ID_WORDWRAP); _CreateLButton("Char", 74, 36, 16, _hClient, ID_CHARWRAP); _CreateRButton("PSW", 52, 25, 16, _hClient, ID_PASSWORD); _CreateRButton("OVR", 26, 25, 16, _hClient, ID_OVERWRITE); _CreateRButton("R/O", 0, 25, 16, _hClient, ID_READONLY); _SetButtonState(_hWrapButton, 1); /* Create multiedit */ if (_ChangeInfoText("using\nMULTIEDIT_CreateEx", SPEED)) return; WinFlags = WM_CF_SHOW | WM_CF_ANCHOR_RIGHT | WM_CF_ANCHOR_LEFT | WM_CF_ANCHOR_TOP | WM_CF_ANCHOR_BOTTOM; WM_GetClientRectEx(_hClient, &Rect); _hMEdit = MULTIEDIT_CreateEx(0, 0, 0, Rect.y1 - 16 + 1, _hClient, WinFlags, MULTIEDIT_CF_INSERT, 0, 0, ""); _pcbMultiEdit = WM_SetCallback(_hMEdit, _cbMultiEdit); MULTIEDIT_SetAutoScrollH(_hMEdit, 1); MULTIEDIT_SetAutoScrollV(_hMEdit, 1); WM_SetFocus(_hMEdit); if (_ChangeInfoText("using\nMULTIEDIT_SetText", SPEED)) return; MULTIEDIT_SetText(_hMEdit, "This sample demonstrates the use of a multiedit widget!"); if (_ChangeInfoText("using\nMULTIEDIT_SetFont", SPEED)) return; MULTIEDIT_SetFont(_hMEdit, &GUI_Font16_1); if (_ChangeInfoText("using\nMULTIEDIT_SetTextColor", SPEED)) return; MULTIEDIT_SetTextColor(_hMEdit, 0, 0xE00000); if (_ChangeInfoText("using\nMULTIEDIT_SetBkColor", SPEED)) return; MULTIEDIT_SetBkColor(_hMEdit, 0, 0xD0FFFF); if (_ChangeInfoText("using\nMULTIEDIT_SetWrapWord", SPEED)) return; MULTIEDIT_SetWrapWord(_hMEdit); _SetButtonState(_hWrapButton, 0); _hWrapButton = WM_GetDialogItem(_hClient, ID_WORDWRAP); _SetButtonState(_hWrapButton, 1); if (_ChangeInfoText("using\nMULTIEDIT_SetHBorder", SPEED)) return; MULTIEDIT_SetHBorder(_hMEdit, 3); if (_ChangeInfoText("using\nMULTIEDIT_SetPrompt", SPEED)) return; MULTIEDIT_SetPrompt(_hMEdit, "Type: "); if (_ChangeInfoText("Play with multiedit...", SPEED)) return; while (_hFrame) { GUI_Delay(100); } }
/********************************************************************* * * MULTIEDIT_Create */ MULTIEDIT_HANDLE MULTIEDIT_Create(int x0, int y0, int xsize, int ysize, WM_HWIN hParent, int Id, int Flags, int ExFlags, const char * pText, int MaxLen) { return MULTIEDIT_CreateEx(x0, y0, xsize, ysize, hParent, Flags, ExFlags, Id, MaxLen, pText); }