> Sorry for the late reply. I also had the idea of overriding the draw()
> method. I coded it up late last night, but was too tired to e-mail it.
> You'll find a working example for fluid below. I did this in 1.3.
[..]
Harvey,
Thanks very much for your effort on this. It's a nice idea, but
unfortunately doesn't work in practice. To see this, replace
the stub check_file() with some code that actually checks for
the file. Then, at run time, create and delete some files. What
happens is that the menu item activation/deactivation doesn't happen
unless the window is manipulated enough to cause a redraw (I think
this makes sense when one thinks about it).
Here's a simplified example, in case I've missed something.
Thanks again,
Stan (still stumped)
// Top level callback replaced by code in draw() -- Doesn't work.
#include <FL/Fl.H>
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Menu_Bar.H>
#include <FL/Fl_Menu_Item.H>
#include <unistd.h>
char const* const filename = "file1.txt";
Fl_Menu_Item theMenu[] = {
{"View", 0, 0, 0, 64, FL_NORMAL_LABEL, 0, 14, 0},
{filename, 0, 0, 0, FL_MENU_TOGGLE | FL_MENU_VALUE,
FL_NORMAL_LABEL, 0, 14, 0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0}
};
class MyMenuBar : public Fl_Menu_Bar {
public:
MyMenuBar(int x, int y, int w, int h, char const* label = 0)
: Fl_Menu_Bar(x, y, w, h, label)
, view_file1_(&theMenu[1])
{
menu(theMenu);
view_file1_->clear();
}
private:
Fl_Menu_Item* view_file1_;
void draw()
{
if(!access(filename, R_OK)) {
view_file1_->activate();
}
else {
view_file1_->deactivate();
}
Fl_Menu_Bar::draw();
}
};
class Window : public Fl_Double_Window {
public:
Window(int w, int h)
: Fl_Double_Window(w, h)
, menu_bar_(0, 0, w, 30)
{
end();
}
private:
MyMenuBar menu_bar_;
};
int main()
{
Window win(300, 500);
win.resizable(&win);
win.show();
return Fl::run();
}
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk