On 03/05/13 12:53, Greg Ercolano wrote:
> One sure way would be to derive your own class from Fl_Window
> and make your own draw() method that sets a flag that you can
> then poll for in the above loop. I'm pretty sure that would work,
> but it seems like the kind of thing FLTK would have built in.
Oh, and by that I mean changing your program as follows:
-----------------------------------------------------------------------
#include <FL/Fl_Window.H>
#include <FL/Fl_Tree.H>
// ADD A CUSTOM CLASS TO DETECT IF WINDOW ACTUALLY DRAWN
class MyWindow : public Fl_Window {
char _drawn;
public:
MyWindow(int W,int H, const char *L=0):Fl_Window(W,H,L) { _drawn = 0; }
void draw() { Fl_Window::draw(); _drawn = 1; }
int drawn() { return _drawn; }
};
int main(int argc, char* argv[]) {
MyWindow *w = new MyWindow(300, 200); // MODIFIED
w->begin();
Fl_Tree* tree = new Fl_Tree(10, 10, 280, 180);
Fl_Tree_Item* p007 = NULL;
for (int i=30; i>=0; --i) {
char buf[10];
sprintf(buf, "%03d", i);
Fl_Tree_Item* p = tree->add(buf);
if (i == 7)
p007 = p;
}
p007->select();
w->end();
w->show();
while ( ! w->drawn() ) { Fl::wait(0.1); } // ADDED THIS
tree->show_item_middle(p007); // THIS SHOULD NOW WORK
return Fl::run();
}
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk