gui-builder form file decoding

  • 3 Replies
  • 385 Views
*

ingar

  • *
  • 26
    • View Profile
    • Label Printing Software & Solutions
gui-builder form file decoding
« on: 12 April 2019, 10:11:13 »
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

  • *****
  • 1480
    • View Profile
    • Texus's Blog
Re: gui-builder form file decoding
« Reply #1 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).

*

ingar

  • *
  • 26
    • View Profile
    • Label Printing Software & Solutions
Re: gui-builder form file decoding
« Reply #2 on: 14 April 2019, 11:35:06 »
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


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

  • *****
  • 1480
    • View Profile
    • Texus's Blog
Re: gui-builder form file decoding
« Reply #3 on: 14 April 2019, 11:39:37 »
You can use the get function which takes the name of the widget as parameter:
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