Thanks for that detailed explanation :)..I had gotten really confused with the
concepts...
What I'm doing now is I'm not creating subwindows, but instead I'm creating
windows outside the begin(); - end(); of the main window. I was almost able to
achieve all the requirements, but I'm facing one problem.
A sample of my code is as below :
#include <stdlib.h>
#include <stdio.h>
#include <fltk/run.h>
#include <fltk/Window.h>
#include <fltk/events.h>
#include <fltk/GlWindow.h>
#include "fltk\\compat\\FL\\Fl_Widget.h"
#include "fltk\\compat\\FL\\Fl_Button.h"
#include "fltk\\compat\\FL\\Fl_Window.h"
using namespace fltk;
#include "fltk\\compat\\FL\\gl.h"
#include "glu.h"
void Init_opengl ()
{
glEnable(GL_POINT_SMOOTH) ;
glEnable(GL_LINE_SMOOTH);
glEnable(GL_POLYGON_SMOOTH);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
glHint(GL_POINT_SMOOTH_HINT, GL_NICEST) ;
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST) ;
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST) ;
}
class Sample_Window : public GlWindow {
private:
int window_x,window_y,window_w,window_h;
bool is_visible;
int handle(int);
int color;
public:
void draw();
void show(void) {
is_visible = true;
GlWindow::show();
}
void hide(void) {
is_visible = false;
GlWindow::hide();
}
void set_state();
Sample_Window(int x, int y, int w, int h,int color);
};
void Sample_Window :: set_state() {
glClearColor(0,0,0,1.0);
glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
Init_opengl ();
glViewport(0, 0, window_w, window_h);
gluOrtho2D(0, window_w, 0, window_h);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
Sample_Window :: Sample_Window(int xx, int yy, int ww, int hh,int c) :
GlWindow(xx,yy,ww,hh) {
window_x = xx;
window_y = yy;
window_w = ww;
window_h = hh;
color = c;
}
void Sample_Window :: draw() {
set_state();
glPushMatrix();
if(color == 1)
glColor4f(0.5,0.5,0.5,1);
else if(color == 2)
glColor4f(1,1,1,1);
glRectf(0,0,window_w,window_h);
}
int Sample_Window :: handle(int e) {
int ret = Window::handle(e);
return ret;
}
int main(int argc, char ** argv) {
fltk::Window* main_data_window = new fltk::Window(15,100,400, 400,
"Sample App");
main_data_window->buttonbox(fltk::BORDER_BOX);
main_data_window->color((fltk::Color)56);
main_data_window->align(fltk::ALIGN_LEFT|fltk::ALIGN_CLIP);
main_data_window->begin();
main_data_window->hide();
main_data_window->end();
Sample_Window* compass_window = new Sample_Window(16,125,250,200,1);
compass_window->border(0);
compass_window->align(fltk::ALIGN_TOP|fltk::ALIGN_LEFT);
compass_window->set_non_modal();
compass_window->hide();
compass_window->end();
Sample_Window* ack_window = new Sample_Window(16,325,250,50,2);
ack_window->border(0);
ack_window->align(fltk::ALIGN_TOP|fltk::ALIGN_LEFT);
ack_window->set_non_modal();
ack_window->hide();
ack_window->end();
main_data_window->show();
compass_window->show();
ack_window->show();
compass_window->hide(); //if these two lines are commented, then both
the windows are visible,
compass_window->show();// but if they are executed, only compass_window
will be visible
return fltk::run();
}
Depending on the user, I need to hide or show compass_window or ack_window..but
when I call show(), other windows whose's child_of_ is the window I'm gonna
show, also disappear..Is there any way I can overcome this??
Thanks,
Lakshmi
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk