I've read on how to do this for FLTK 1.*, but not FLTK 2.0. Basically, instead 
of writing seperate functions for items to callback, they will all call one. 
This one function will 'know' what was calling it and then perform the specific 
functions accordingly.

I'm still unfamiliar with FLTK, let alone FLTK 2.0, so I keep on getting 
difficult errors while making a bunch of code snippets I can use for my 
programs.

I've tried making the following code:
+-+-+-+-+-+-+-+-+-+
#include <fltk/run.h>
#include <fltk/Item.h>
#include <fltk/ItemGroup.h>
#include <fltk/Window.h>
#include <fltk/Widget.h>
#include <fltk/MenuBar.h>

#define WIDTH 640
#define HEIGHT 480

class app
{
    public:
        void m_cbAll();
        app(const char * win_name);
};

app::app(const char * win_name)
{
    fltk::Window *win = new fltk::Window(WIDTH,HEIGHT);
    win->label(win_name);
    win->begin();
        fltk::MenuBar mbar_main(0,0,WIDTH,HEIGHT);
        mbar_main.begin();
            new fltk::Item("File/New",COMMAND+'o', m_cbAll);
            new fltk::Item("File/Open",COMMAND+'o', m_cbAll);
            new fltk::Item("File/Save",COMMAND+'s', m_cbAll);
            new fltk::Item("File/Quit",COMMAND+'q', m_cbAll);
        mbar_main.end();
    win->end();
    win->show(); //show() is not part of fltk
}

void app::m_cbAll(){}

int main(){ new app("Test"); return fltk::run();}
+-+-+-+-+-+-+-+-+-+

I get the following build errors:
-=-=-=-=-=-=-=-=-=-=
..\memorspace\main.cpp:33: error: `COMMAND' undeclared (first use this function)
..\memorspace\main.cpp:33: error: (Each undeclared identifier is reported only 
once for each function it appears in.)
:: === Build finished: 2 errors, 0 warnings ===
-=-=-=-=-=-=-=-=-=-=

The code isn't complete, since I have to find out why I keep on getting that 
COMMAND error in the fltk::Item. It's worked for my other code snippets, so I'm 
trying to figure out why it doesn't for this particular example. It might be 
something obvious, or that I've misunderstood a concept...
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to