-
Help with classes
I'm definitely getting lost in al the wxWidget classes. I want to have a frame/window that acts like a cout - there's a textbox on it, and it can be accessed from any other frame.
I'm not sure how I can do this, though. Someone on the wxForum recommended me wxLog, but that seems to be only local to a class. Is it possible to make the log global to all classes ? If yes, how?
-
Hmm, i think i got it, but I don't know how to implement this.
I've got class A and class B, both implemented in main. Class A contains a pointer to a class B. Somehow, I have to set this pointer externally, in main, after B is implemented.
Is this possible?
-
std::cout is a global instance of std::ostream if I'm not mistaken, so you might also declare a global wxLog or whatever instance.
-
There's a wx class that is a textbox, but I can't remember the name offhand. What you should do is provide a function for your frame that the textbox is on, to accept a wxString and then have that frame put the wxString in the textbox.
-
yes, but how can I call the frame with the textbox from a bunch of other frames?
I'm thinking of something with pointers, but I ain't entirely sure.
-
Do you have no idea how any of this works?
Create a parent frame that represents your program. Have that frame start other frames or dialogs, depending on what is needed. Pass a pointer (or a reference) of the parent frame into the constructor of your child frames. Heck, you probably could even pass it into the constructor of wxFrame as the parent window (although that may not be what you want).
There. Now the child frame can call a function in your parent frame. addText() or something that you define. Go for it.
TBH, I think you're rushing your way learning a bunch of libraries and fancy things before even getting a real firm grasp of the language itself. Consider slowing down and building a better foundation.
-
If the other frames are children of the window where you want to print to, you should be able to get a pointer to the parent from the child (some method). To call a custom method on it, you'd need to dynamic_cast it to your frame class.
If they are not children, you'll probably need to store a pointer/reference to the log window/control in each of them.