Hi,
I am using fluid to build an app with different widgets showing depending on 
compile options passed from the makefile and the code produced is not compiling.
I think fluid does not correctly write the code for the callbacks - if the 
class is inside a #if conditional block, then the callback functions should be 
also.
Here is an example small fluid file :

//*******************************
# data file for the Fltk User Interface Designer (fluid)
version 1.0107 
header_name {.h} 
code_name {.cxx}
declblock {\#if 1} {open public after {\#endif}
} {
  widget_class widgetclass {open
    xywh {349 29 100 100} type Double visible
  } {
    Fl_Button {} {
      label button
      callback {printf("Button pushed 1.\\n");}
      xywh {10 20 75 40}
    }
  }
} 

declblock {\#if 0} {open public after {\#endif}
} {
  widget_class widgetclass {open
    xywh {638 56 100 100} type Double visible
  } {
    Fl_Button {} {
      label button
      callback {printf("Button pushed 0.\\n");} selected
      xywh {10 20 75 40}
    }
  }
} 
//***************************

The header file produced is exactly correct :

//***************************

// generated by Fast Light User Interface Designer (fluid) version 1.0107

#ifndef test_h
#define test_h
#include <FL/Fl.H>
#include <FL/Fl_Group.H>
#include <FL/Fl_Button.H>
#if 1

class widgetclass : public Fl_Group {
public:
  widgetclass(int X, int Y, int W, int H, const char *L = 0);
private:
  void cb_button_i(Fl_Button*, void*);
  static void cb_button(Fl_Button*, void*);
};
#endif
#if 0

class widgetclass : public Fl_Group {
public:
  widgetclass(int X, int Y, int W, int H, const char *L = 0);
private:
  void cb_button1_i(Fl_Button*, void*);
  static void cb_button1(Fl_Button*, void*);
};
#endif
#endif
//***************************

...but the cxx file has all callbacks declared outside the #if blocks, so it 
will not compile :

//***************************
// generated by Fast Light User Interface Designer (fluid) version 1.0107

#include "test.h"

void widgetclass::cb_button_i(Fl_Button*, void*) {
  printf("Button pushed 1.\n");
}
void widgetclass::cb_button(Fl_Button* o, void* v) {
  ((widgetclass*)(o->parent()))->cb_button_i(o,v);
}
#if 1
widgetclass::widgetclass(int X, int Y, int W, int H, const char *L)
  : Fl_Group(X, Y, W, H, L) {
  widgetclass *o = this;
{ Fl_Button* o = new Fl_Button(10, 20, 75, 40, "button");
  o->callback((Fl_Callback*)cb_button);
}
end();
}
#endif

void widgetclass::cb_button1_i(Fl_Button*, void*) {
  printf("Button pushed 0.\n");
}
void widgetclass::cb_button1(Fl_Button* o, void* v) {
  ((widgetclass*)(o->parent()))->cb_button1_i(o,v);
}
#if 0
widgetclass::widgetclass(int X, int Y, int W, int H, const char *L)
  : Fl_Group(X, Y, W, H, L) {
  widgetclass *o = this;
{ Fl_Button* o = new Fl_Button(10, 20, 75, 40, "button");
  o->callback((Fl_Callback*)cb_button1);
}
end();
}
#endif
//***************************

The function declaration void widgetclass::cb_button1_i(Fl_Button*, void*) 
should be inside a #if(0), meaning that in this example, it will not get 
compiled.

Am I using fluid correctly, or is it a bug ? Does anyone have any ideas what I 
can do, other than use seperate .fl files and confitionally compile them - I 
could do that but it would be messy.

I have tried with 1.1.7 and the latest 1.1.8(r6020). Alternatively, if someone 
could point me in the right direction as to how I could fix fluid that would be 
great too.

Thanks for any help,
Darren.
[EMAIL PROTECTED] 


_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to