xforms-development
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [XForms] some success and some problems with old code using version


From: jos
Subject: Re: [XForms] some success and some problems with old code using version 1.3.7
Date: Sat, 03 May 2014 15:02:43 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0

Hi Jens,

thanks for your reply!
I can, of course, also add an fl_set_xyplot_mouse_buttons() func-
tion to allow the user to re-enable other mouse buttons.
Well, I almost don't dare to ask, but would you please?
It's already done, it was rather trivial in this case.

Great ! Can I download a new version of the library from savanna?

2:  I used fl_get_menu to load and save content to and from my program.
Now all the code returns is a -1. It does not seem to recognize the
menu tree at all.
This happens when using 1.3.7.
When using 1.0.9[01] all is well.
Has the library changed / should I recode this or have there
been no changes to this bit of code over the years (and might this
be a bug) ?
I can't draw any conclusions from your descriptions since I don't
know the circumstances. It would definitely help if I knew how you
set up your menu. A compilable example program would be even better;-)
I'll try to isolate some of the code and get back to you.
Again, if you have some code I can run (perhaps with a few
instructions on how to reproduce the problem) I'll also take
a look!
                           Best regards, Jens

Oke, this is an abstract of the code concerning the menu. I've included all the parts that seem relevant to me:
I'm using the return code - switch approach.

This is the definition of the menu object:

fd_formant->File_Menu = (FL_OBJECT *) safe_alloc(sizeof(FL_OBJECT), "init_file_menu"); fd_formant->File_Menu = obj = fl_add_menu(FL_PULLDOWN_MENU,15,4,42,18,"File");
    fl_set_object_lsize(obj, FL_LARGE_SIZE);
    fl_set_object_color(obj, FL_INACTIVE_COL,FL_RED);
    fl_set_object_callback(obj, do_menu, (long) arg);

This is the definition of the menu structure:

void init_file_menu(long arg)
{
  FD_formant *form = (FD_formant *) arg;
  FL_OBJECT *fdpup;
  int mm, smm1, smm2, smm3,
      smm22, smm31;

  fdpup = form->File_Menu;

  mm = fl_newpup(fl_default_win());
  fl_setpup_bw(mm, -2);
  fl_setpup_shadow(mm, 0);
  smm1 = fl_newpup(0);
  fl_setpup_shadow(smm1, 0);
  smm2 = fl_newpup(0);
  fl_setpup_shadow(smm2, 0);
  smm22 = fl_newpup(0);
  fl_setpup_shadow(smm22, 0);
  smm3 = fl_newpup(0);
  fl_setpup_shadow(smm3, 0);
  smm31 = fl_newpup(0);
  fl_setpup_shadow(smm31, 0);

  fl_addtopup(mm,"Load%m",smm1);
fl_addtopup(smm1,"Project%x11|Excitation%x121|Response%x13|Params%x14|Config%x15");
  fl_addtopup(mm,"Save%m",smm2);
fl_addtopup(smm2,"Project%x21|Excitation%x22%m|Response%x23|Params%x24|Config%x25", smm22);
  fl_addtopup(smm22,"Voice%x221|Noise%x222");
  fl_addtopup(mm,"Generate%m",smm3);
  fl_addtopup(smm3,"Excitation%x31%m|Parameters%x32", smm31);
  fl_addtopup(smm31,"Sine%x311|Square%x312");
  fl_addtopup(mm,"Quit%x3");

  /* attach pup to menu */
  fl_set_menu_popup(fdpup, mm);
}


This is the callback:

void do_menu(FL_OBJECT *obj, long arg)
{
  char buf[255];
  FD_formant *fdfoo = (FD_formant *) arg;

  if (fl_get_menu(obj) >= 0)
     sprintf(buf,"%d (%s)", fl_get_menu(obj), fl_get_menu_text(obj));
  else
     sprintf(buf,"%d", fl_get_menu(obj));
  fprintf(stderr, "%s\n", buf);
  fl_set_object_label(fdfoo->Item_Sel, buf);
  do_file_menu((long) arg);
}


This is the switch function that deals with the selection made in the menu ( abbreviated here ):

void do_file_menu(long arg)
{
   FD_formant *fdfoo = (FD_formant *) arg;
   char  *config_file = (char *) NULL;
   char  *project_file = (char *) NULL;
   char  *params_file = (char *) NULL;
   char  *output_file = (char *) NULL;
   char  *response_file = (char *) NULL;
   char  *voicing_excitation_file = (char *) NULL;
   char  tmp[255];
   int   choice;
   FD_FSELECTOR *fs;

   fl_invalidate_fselector_cache();
   fs = fl_get_fselector_fdstruct();
   fl_set_object_label(fs->ready, "Load");
   choice=fl_get_menu(fdfoo->File_Menu);
#ifdef DEBUG
   printf("Choice: %d\n", choice);
#endif
   switch(choice)
   {
     case 3: // Quit pressed
     {
       done_CB(fdfoo->File_Menu, (long) arg);
       break;
     }
     case 11:
     { // Load project
fl_show_alert("sorry","This function has not been implemented yet.","", 0);
       break;
       fl_set_fselector_title("Load project");
       project_file = get_file_name("*.prj");
     }
// etc. etc.
 }
}



reply via email to

[Prev in Thread] Current Thread [Next in Thread]