I'm creating a menu system for an openGL application I'm working on in C++. I'm shooting for a structure to something I've learned before (TObjects in Delphi). The structure I am shooting for is something along the lines of
Object->Component->Control(if visual/interacts)->Specific Item
One thing I am thinking about is how I control the users 'focus'. Focus would be a member of control, and would be useful for instance what buttons would do, where typing occurs, etc... It would seem that focus should be a pointer to a specific GUI item, and thus a derived class of control. The object type that I would need to point to would not always be the same. How can I declare a pointer in the control base class to point to any of derived classes? I've tried searching google but I don't think I'm using the correct terms because I just get a lot of explanations of inheritance.. I don't think the answer is there.
One work around I thought about using was a protected value in the Component Base class, let's call it ID
. ID
would be unique each time any new object is created and I could declare the focus pointer as int* focus
and then try to back track from the IDs what needs to happen. It seems like it would be a bit more of a hassle.
Thanks in advance for any advice