Hiii,
I need to add "N" number of items in d4d_menu screen for k60 egui .I can added limited number of item in user menu screen like D4D_DECLARE_MENU_ITEM_FULL( "file1.mp3",&bmp_music_notes,&screen_musicplayer)
D4D_DECLARE_MENU_ITEM_FULL( "file2.mp3",&bmp_music_notes,&screen_musicplayer)
D4D_DECLARE_MENU_ITEM_FULL( "file3.mp3",&bmp_music_notes,&screen_musicplayer)
D4D_DECLARE_MENU_ITEM_FULL( "file4.mp3",&bmp_music_notes,&screen_musicplayer) it in globaly decleared ,So i can't use for and while loop here what i do for this.I attached one example in this mail.
Solved! Go to Solution.
Hi,
the solution is simple.
Declare the MENU object in RAM, and then dynamically alloc memory N*sizeof(D4D_MENU_ITEM). And fill up this structures.
Finally put pointer on this array to MENU object structure (pItems) and update posCnt also in same menu structure.
Hi,
the solution is simple.
Declare the MENU object in RAM, and then dynamically alloc memory N*sizeof(D4D_MENU_ITEM). And fill up this structures.
Finally put pointer on this array to MENU object structure (pItems) and update posCnt also in same menu structure.
Hi,
I am beginner in eGui. I don't know where i should call the menu object structure.I declared like this
D4D_DECLARE_STD_RMENU_AUTOSIZE_BEGIN_INRAM(scrfilemanger_menu, "List Of Files" , FONT_ARIAL12B, 0,30 , 200, 150, 4, FONT_ARIAL12, FONT_ARIAL12, NULL,ScrMenu_OnClick)
D4D_DECLARE_RMENU_END_INRAM(scrfilemanger_menu) ,i don't know in where call the "pItems" structure(OnInit(),OnMain()) .Please explain with any example.
Hi,
anywhere, out of the D4D_MENU code is running.
So all you mentioned functions are OK.
just create the new arrays of the MENU_ITEM structures and update pointer on this array to the MENU object as I describe in previous message.
Gargy
Hi,
I Don't know how to do this ,I did like this
D4D_DECLARE_STD_RMENU_AUTOSIZE_BEGIN_INRAM(scrfilemanger_menu, "List Of Files" , FONT_ARIAL12B, 0,30 , 200, 150, 4, FONT_ARIAL12, FONT_ARIAL12, NULL,ScrMenu_OnClick)
D4D_DECLARE_RMENU_END_INRAM(scrfilemanger_menu)
char str[10][10]={"f1","f2","f3","f4","f5"};
//Screen "Main" function called periodically in each D4D_poll runs
static void ScreenFilemanager_OnMain()
{
D4D_MENU_ITEM* Menu[10];
D4D_MENU* pMenu=D4D_GET_MENU(&scrfilemanger_menu);
int i;
D4D_MENU_INDEX j=0;
// pMenu->posCnt=0;
for(i=0;i<5;i++)
{
//D4D_MenuSetIndex((D4D_OBJECT*)&scrfilemanger_menu,j);
strcpy(Menu[i]->text.pText,str[i]);
Menu[i]->pIcon=NULL;
Menu[i]->pUser=NULL;
pMenu->pItems=Menu[i];
pMenu->posCnt++;
//j++
}
}
When i running the code the filemanager screen stuck and debugger come out of kernal.I don't know how to do this,What change i should make this code.
Hi,
you are close, but not in finish line :smileyhappy:
Look at this:
static void ScreenFilemanager_OnMain()
{
static D4D_MENU_ITEM* Menu[10];
D4D_MENU* pMenu=D4D_GET_MENU(&scrfilemanger_menu);
int i;
D4D_MENU_INDEX j=0;
// pMenu->posCnt=0;
for(i=0;i<5;i++)
{
//D4D_MenuSetIndex((D4D_OBJECT*)&scrfilemanger_me
nu,j);
//strcpy(Menu[i]->text.pText,str[i]);
Menu[i]->text.pText = str[i];
Menu[i]->text.buffSize = 10;
Menu[i]->text.str_properties= NULL; // In menu is used common text properties settings
Menu[i]->text.printLen = 10;
Menu[i]->text.printOff = 0;
Menu[i]->pIcon=NULL;
Menu[i]->pUser=NULL;
//j++
}
pMenu->posCnt = 5;
pMenu->pItems=&Menu[0];
}
I hope this helps, you have to keep in mind that the menu item storage that you will create has to be keep in memory (static).
Gargy
I have a similar need to create dynamic menu items. I thought I understood this chain of posts, but when I run the code and switch to the menu screen, my debugger halts on a hardware error.
Hello,
And, I will add :
static void ScreenFilemanager_OnMain(){static D4D_MENU_ITEM* Menu[10];D4D_MENU* pMenu=D4D_GET_MENU(&scrfilemanger_menu);int i;D4D_MENU_INDEX j=0; for(i=0;i<5;i++) { Menu[i]->text.pText = str[i]; Menu[i]->text.buffSize = 10; Menu[i]->text.str_properties= NULL; // In menu is used common text properties settings Menu[i]->text.printLen = 10; Menu[i]->text.printOff = 0; Menu[i]->pIcon=NULL; Menu[i]->pUser=NULL; } Menu[i]->text.pText = NULL; Menu[i]->pIcon = NULL; pMenu->posCnt = 5; pMenu->pItems=&Menu[0]; }
to end D4D_MENU_ITEM list
Hi,
you right, Good point.
Gargy