I would like to add several buttons to my project, but i don't know how many! so i don't want to define them in introjucer.
i tried in my window component constructor to add this, but the i can't see anything on the screen. Am i missing something? can you gimme some hints on the best way to do this? any example i could look for? what is the juce way of doing this? is it with vectors?
should i pre make the components vs run time making them makes a huge deal on cpu?
I came from scripting languages, so any help to understand this and subjacent concepts would be really appreciated.
I would say it's always best to generate objects dynamically if you don't know on startup how many you will need. Creating 1000s of object and only using as many of them as the user wants is not such a great approach. OwnedArray works like a standard vector more or less. It may even have some extra functionality :)
Now leads me to this question: is the OwnedArray the equivelent injuce for std::Vector?
JUCE has two array classes. Array and OwnedArray. Array is closer in behaviour to std::vector<>.
Read: http://www.parashift.com/c++-faq-lite/container-of-smart-ptr.html which gives a good overview of the risks involved in using a vector to store object pointers, and touches on why creating a vector of class type is not always possible or desirable.
tl;dr: std::vector<Component> will not behave well for a multitude of reasons, and std::vector<Component*> risks leaking component instances. OwnedArray<Component*> side-steps those issues.