gui-builder form file decoding

Started by ingar, 12 April 2019, 10:11:13

ingar

Hi all,

I am very new in this. But one question:
Do I have to decode the form.txt file created by tgui-builder myself, or are there some functions I can call
for decoding the file and creating the window?

Ingar Steinsland
ingar@labelcraft.net

texus

The Gui class and any container widget have a loadWidgetsFromFile function where you can pass the filename (and a loadWidgetsFromStream function in case you want to load it from memory).

ingar

Hi again,

Thanks a lot. It worked. I used the "loadWidgetsFromStream", since I have automatic the process of embedding
external files in my executable (in this case "form.txt"). TGUI now displays the form created by gui-builder.

Now I think I have one more to figure out: How do I get hold of the control objects created by "loadWidgetsFromStream"?
If I know this, I can start using the controls. After that, I think I will make me a class call CDialog, similar to the one in
Microsoft MFC.

Ingar


Quote from: texus on 12 April 2019, 18:21:18
The Gui class and any container widget have a loadWidgetsFromFile function where you can pass the filename (and a loadWidgetsFromStream function in case you want to load it from memory).

texus

You can use the get function which takes the name of the widget as parameter:
Code (cpp) Select
tgui::Widget::Ptr widget = gui.get("name"); // Without template you get the Widget base class (for when you don't need functions specific to the widget type)
tgui::Button::Ptr button = gui.get<tgui::Button>("name"); // With template you can get an object of the right type