Gary Hui Zhang wrote:
>> The Fl_Tabs widget does exactly that when
>> you select a tab: it show()s its group and hides any other contained groups.
>
> This was my understanding but it doesn't appear to work, at least on MacOSX.
I think I can replicate with 1.3.x + OSX.
The following program makes two tabs with an openGL window in each,
drawing an 'x' in one, and a '+' in the other.
A problem crops up when you switch to '+' then /back/ to 'x',
the '+' image and window remains.
Also, when you then resize the window in this mode, you see /both/
gl windows are being shown, with one oddly floating and stuck, eclipsing
the other.
Problem seems to happen only on osx, not on linux.
1.3.x in both cases.
Note sure if my code is doing something wrong here too,
but my guess is it might be something wrong in fltk's handling
of hide()/show() for openGL windows.. not sure.
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Tabs.H>
#include <FL/Fl_Group.H>
#include <FL/Fl_Gl_Window.H>
#include <FL/gl.h>
//
// Simple tabs example with openGL widgets in each tab. -erco 9/12/09
//
class MyGlWindow : public Fl_Gl_Window {
char graphic; // 'x' or '+'
void draw() {
// First time? init viewport, etc.
if (!valid()) {
valid(1);
glLoadIdentity();
glViewport(0,0,w(),h());
glOrtho(-w(),w(),-h(),h(),-1,1);
}
// Clear screen
glClear(GL_COLOR_BUFFER_BIT);
switch(graphic) {
case 'x': // Draw white 'x'
glColor3f(1.0, 1.0, 1.0);
glBegin(GL_LINE_STRIP); glVertex2f(w(), h());
glVertex2f(-w(),-h()); glEnd();
glBegin(GL_LINE_STRIP); glVertex2f(w(),-h()); glVertex2f(-w(),
h()); glEnd();
break;
case '+': // Draw white '+'
glColor3f(1.0, 1.0, 1.0);
glBegin(GL_LINE_STRIP); glVertex2f(w()/2, h());
glVertex2f(w()/2,-h()); glEnd();
glBegin(GL_LINE_STRIP); glVertex2f(w(),h()/2); glVertex2f(-w(),
h()/2); glEnd();
break;
}
}
// HANDLE WINDOW RESIZING
// If window reshaped, need to readjust viewport/ortho
//
void resize(int X,int Y,int W,int H) {
Fl_Gl_Window::resize(X,Y,W,H);
glLoadIdentity();
glViewport(0,0,W,H);
glOrtho(-W,W,-H,H,-1,1);
redraw();
}
public:
// CONSTRUCTOR
MyGlWindow(int X,int Y,int W,int H,const char*L=0) :
Fl_Gl_Window(X,Y,W,H,L) {
graphic = 'x';
end();
}
void Graphic(char val) {
graphic = val;
}
};
int main(int argc, char *argv[]) {
Fl_Window *win = new Fl_Window(500,200,"Tabs/openGL Example");
{
Fl_Tabs *tabs = new Fl_Tabs(10,10,500-20,200-20);
{
// Aaa tab
Fl_Group *x_tab = new Fl_Group(10,35,500-20,200-45,"'x'");
{
MyGlWindow *gl = new MyGlWindow(x_tab->x()+10, x_tab->y()+10,
x_tab->w()-20, x_tab->h()-20);
gl->Graphic('x');
}
x_tab->end();
// Bbb tab
Fl_Group *plus_tab = new Fl_Group(10,35,500-10,200-35,"'+'");
{
MyGlWindow *gl = new MyGlWindow(plus_tab->x()+10,
plus_tab->y()+10, plus_tab->w()-20, plus_tab->h()-20);
gl->Graphic('+');
}
plus_tab->end();
}
tabs->end();
}
win->end();
win->resizable(win);
win->show();
return(Fl::run());
}
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk