How do I get access to GUI elements in a IUP dialog loaded from a LED file?

雨燕双飞 提交于 2019-12-31 05:11:28

问题


I’m in love with IUP! However I cannot figure out how to get programmatic access (in C) to GUI elements in a dialog loaded by IupLoad() from a LED file.

One extremely laborious way would be to edit the LED file so as to manually give handle names to each single GUI element, then manually define corresponding variables for each element in C, then manually load handles into each variable by using IupGetHandle().

One comfortable way to do it would be to convert the LED file to a C header file using the built-in Layout Dialog tool. The resulting code makes each element available to the application in a simple array called Ihandle* containers[]. But this way deprives us of the benefits of LED files, such as the ability to edit GUI of a binary application by the user and keeping the C code small.

Is there no good way to do it?

Do I overrate the benefits of a third way, if it existed?

I cannot find any IupLoad() example in the directory with C examples.

My own example below explicitly defines one handle name for the top element (dialog) only. It features a very simple dialog where defining each element manually wouldn’t be a hard work at all. But this is only a test example for Stack Overflow and my question is relevant to complex dialogs.

C file:

#include <stdlib.h>
#include <iup.h>

int main(int argc, char **argv)
{
  IupSetGlobal("UTF8MODE", "YES");
  // IupSetGlobal("UTF8MODE_FILE", "YES");
  IupOpen(&argc, &argv);
  if(IupLoad("dropdown.led")) IupMessage("Error", "Failed to load LED.");
  else {
    Ihandle *dropdown = IupGetHandle("dropdown");
    IupShow(dropdown);
    IupMainLoop();
  }
  IupClose();
  return EXIT_SUCCESS;
}

Corresponding dropdown.led file:

dropdown = DIALOG[TITLE=dropdown.led](
  HBOX[CMARGIN=10x10,CGAP=10](
    LIST[VALUE=3, 1=я, 2=ты, 3=оно, 4=мы, 5=вы, 6=они, DROPDOWN=YES](do_nothing),
    LIST[VALUE=3, 1=ik, 2=je, 3=hij, 4=we, DROPDOWN=YES](do_nothing)
  )
)

Which brings us to another question: how can I make Russian characters visible? But this issue is owed a separate thread which I will accordingly create.

All questions that pertain to this particular example:

  1. How do I get access to GUI elements in a IUP dialog loaded from a LED file? (current)
  2. How can I make Russian letters visible in a IUP dialog loaded from a LED file?
  3. A gap in IUP dropdown lists

回答1:


The way os to use IupGetHandle to get access to some element then use IupGetChild*, GetBrother, GetParent functions to get the element you want.

Another option is to use the NAME attribute. You set it on the element you want then use IupGetDialogChild to retrieve the element given the NAME value.



来源:https://stackoverflow.com/questions/43449619/how-do-i-get-access-to-gui-elements-in-a-iup-dialog-loaded-from-a-led-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!