i've two sifferent questions, so for the second one i open another thread. Here is the first: Im globally a bit confused concerning the process of updating and painting.
I work on an application using OpenGL to render on wxGLCanvas-controls. Also i use various other controls, like wxTextCtrl, wxStaticBitmap and wxFrame. The application is modular. So predefined groups of controls can be added and removed at runtime.
In order to have a interface that does not care about, which kind a control has, i use a container-control-class (clsControl) derived from wxPanel. So, each wxTextCtrl, wxStaticBitmap etc. is placed in an own clsControl::wxPanel. Like this, for most operations it's not needed, to know, what's inside the wxPanel.
In order to save CPU-time, for most controls i want to use m own paunt-calls - especially, because if the program is running, it renders frames @ 30 or 60Hz (or other framrates if it's configurated for). Therefore, various controls are painted by this. So extra-refreshes, by the system are not needed.
Unfortunately i've several problems in understanding how all the flags and fuctions concerning this, work together. Just for example:
- wxWS_EX_PROCESS_UI_UPDATES
- SetBackgroundStyle, and its flags
- wxEVT_UPDATE_UI
- wxUpdateUIEvent::SetUpdateInterval
- etc.
However, currenty i don't get my main-output to work.
I've two kinds of outputs, with each of them may be instanced several times. One is a preview (so a small wxGLCanvas in the main-window) the other type (the output) is placed in a wxFrame and should fill it completly. As explained, both are using clsControl::wxPanel as containers and differ only in the creation-process, which has the following code (the first one doen't work):
Code: Select all
if (Type == "SCREEN") { Type = "DISPLAY";
SetName ("CONTROL:SCREEN");
CTRLframe = new clsFrame (this, -1, GetTitle(), wxDefaultPosition, wxSize(1024, 630), wxCAPTION | wxRESIZE_BORDER | wxSYSTEM_MENU | wxMINIMIZE_BOX | wxMAXIMIZE_BOX, "OUTPUT");
CTRLcanvas = new wxGLCanvas (CTRLframe, Kontext, -1, wxPoint(0,0), wxSize(1024, 630), 0);
CTRLframe ->Parser = Parser; Parser ->Frame = CTRLframe;
CTRLcanvas ->Connect (wxEVT_PAINT, wxEventHandler(clsControl::OnPaint), NULL, this);
CTRLcanvas ->SetBackgroundStyle(wxBG_STYLE_PAINT );
CTRLframe ->Show();
CTRLcanvas->Show();
this ->Hide();
}
if (Type == "DISPLAY") {
SetName ("CONTROL:DISPLAY");
CTRL ->Hide();
CTRLcanvas = new wxGLCanvas (this, Kontext, -1, wxPoint(0,0), GetSize(), 0);
CTRLcanvas ->Connect (wxEVT_LEFT_UP, wxEventHandler(clsParser ::ParseOnEvent), NULL, Parser);
CTRLcanvas ->Connect (wxEVT_RIGHT_UP, wxEventHandler(clsParser ::ParseOnEvent), NULL, Parser);
CTRLcanvas ->Connect (wxEVT_PAINT, wxEventHandler(clsControl::OnPaint), NULL, this);
CTRLcanvas ->SetBackgroundStyle(wxBG_STYLE_PAINT );
}
The event-function is currently chaotic. But it's structure is this:
Code: Select all
void clsControl:: OnPaint (wxEvent& event) { Print(Mode); // for debugging
if (CTRLcanvas && CTRLcanvas->IsShownOnScreen()) { event.Skip();
[...]
}
else if (CTRLcanvas ) Print(Mode+" - (offscreen)"); // for debugging
else if (CTRLbitmap && CTRLbitmap->IsShownOnScreen()) {
[...]
Code: Select all
if (Control->CTRLcanvas) { Control->CTRLcanvas->Refresh(); Control->CTRLcanvas->Update(); }
By the way: It's the onl paint-function i have. So there is nothing else catching paint-events. So missing Skip() is not he problem.
Would be nice if someone had an idea, what the problem migt be...
Best,
Frank