ciup

iup, IupParamBox problems


First of all sorry for my bad English. I have a problem with IupParamBox, I want to make a settings list with the IupParamBox in a program where settings can be changed. I tried to use the IupGetParam functions but i can not put IupGetParam in a Vbox because it has his own window. There are no examples online with IupParamBox only with IupGetParam. This is the code I made:

    int main(int argc, char **argv){

      int pboolean = 1;

      Ihandle *dlg, *box, *hbox2;

      IupOpen(&argc, &argv);

      hbox2 = IupHbox(IupLabel("Settings"), IupButton("Button D", ""), NULL);

      box = IupVbox(
            IupParamBox(param,
                 "Boolean: %b[No,Yes]\n" ,
                 &pboolean,
                 NULL),
            hbox2,
            NULL);

      dlg = IupDialog(box);

      IupShowXY (dlg, IUP_CENTER, IUP_CENTER);
      IupMainLoop ();
      IupClose ();

    }

I get a window but it is blank, the button is also invisible.

What am I doing wrong and how should I fix it?


Solution

  • Here is a sample code for the IupParamBox:

    int main(int argc, char **argv)
    {
      int pboolean = 1;
      int pinteger = 3456;
      float preal = 3.543f;
      int pinteger2 = 192;
      float preal2 = 0.5f;
      float pangle = 90;
      char pstring[100] = "string text";
      char pcolor[100] = "255 0 128";
      int plist = 2;
      char pfile_name[500] = "test.jpg";
      Ihandle *dlg, *box, *hbox2, *param1, *param2, *param3, *param4, *param5, *param6, *param7, *param8, *param9, *param10, *param11, *param12, *parambox;
    
      IupOpen(&argc, &argv);
      IupSetLanguage("ENGLISH");
    
      param1 = IupParam("Boolean: %b[No,Yes]{Boolean Tip}\n");
      param2 = IupParam("Integer: %i{Integer Tip}\n");
      param3 = IupParam("Real 1: %r{Real Tip}\n");
      param4 = IupParam("Sep1 %t\n");
      param5 = IupParam("Integer: %i[0,255]{Integer Tip 2}\n");
      param6 = IupParam("Real 2: %r[-1.5,1.5]{Real Tip 2}\n");
      param7 = IupParam("Sep2 %t\n");
      param8 = IupParam("Angle: %a[0,360]{Angle Tip}\n");
      param9 = IupParam("String: %s{String Tip}\n");
      param10 = IupParam("List: %l|item1|item2|item3|{List Tip}\n");
      param11 = IupParam("File: %f[OPEN|*.bmp;*.jpg|CURRENT|NO|NO]{File Tip}\n");
      param12 = IupParam("Color: %c{Color Tip}\n");
    
      IupSetInt(param1, "VALUE", pboolean);
      IupSetInt(param2, "VALUE", pinteger);
      IupSetFloat(param3, "VALUE", preal);
      IupSetInt(param5, "VALUE", pinteger2);
      IupSetFloat(param6, "VALUE", preal2);
      IupSetFloat(param8, "VALUE", pangle);
      IupSetAttribute(param9, "VALUE", pstring);
      IupSetInt(param10, "VALUE", plist);
      IupSetAttribute(param11, "VALUE", pfile_name);
      IupSetAttribute(param12, "VALUE", pcolor);
    
      hbox2 = IupHbox(IupLabel("Settings"), IupButton("Extra Button", NULL), NULL);
    
      box = IupVbox(
        parambox = IupParamBox(param1, param2, param3, param4, param5, param6, param7, param8, param9, param10, param11, param12, NULL),
        hbox2,
        NULL);
    
    //  IupSetCallback(parambox, "PARAM_CB", (Icallback)param_action);
    
      dlg = IupDialog(box);
      IupSetAttribute(dlg, "TITLE", "IupParamBox Example");
    
      IupPopup(dlg, IUP_CENTER, IUP_CENTER);
    
      if (IupGetInt(parambox, "STATUS") == 1)
      {
        pboolean = IupGetInt(param1, "VALUE");
        pinteger = IupGetInt(param2, "VALUE");
        preal = IupGetFloat(param3, "VALUE");
        pinteger2 = IupGetInt(param5, "VALUE");
        preal2 = IupGetFloat(param6, "VALUE");
        pangle = IupGetFloat(param8, "VALUE");
        strcpy(pstring, IupGetAttribute(param9, "VALUE"));
        plist = IupGetInt(param10, "VALUE");
        strcpy(pfile_name, IupGetAttribute(param11, "VALUE"));
        strcpy(pcolor, IupGetAttribute(param12, "VALUE"));
    
        IupMessagef("IupGetParam",
                    "Boolean Value: %d\n"
                    "Integer: %d\n"
                    "Real 1: %g\n"
                    "Integer: %d\n"
                    "Real 2: %g\n"
                    "Angle: %g\n"
                    "String: %s\n"
                    "List Index: %d\n"
                    "FileName: %s\n"
                    "Color: %s\n",
                    pboolean, pinteger, (double)preal, pinteger2, (double)preal2, (double)pangle, pstring, plist, pfile_name, pcolor);
      }
    
      IupMainLoop();
      IupClose();
    
      return EXIT_SUCCESS;
    }