FLUID custom widget: the generated code seems troublesome

26 views
Skip to first unread message

S ET

unread,
Sep 29, 2026, 7:09:41 AMSep 29
to fltk.general
Hello,

I tried generating code from FLUID to use a custom widget.

From internet sources, the custom widget has been specified as in this image.

FLUID_UseCustomWidget.png

The resulting code is:

// -------------------------- HEADER ---------------------------------
// generated by Fast Light User Interface Designer (fluid) version 1.0405

#ifndef TestFluidCustomWidget_h
#define TestFluidCustomWidget_h
#include <FL/Fl.H>
#include <FL/Fl_Double_Window.H>

class Test_UI {
public:
  Fl_Double_Window* make_window();
};
#endif

// ---------------------------- CXX -----------------------------------
// generated by Fast Light User Interface Designer (fluid) version 1.0405

#include "TestFluidCustomWidget.h"

Fl_Double_Window* Test_UI::make_window() {
  Fl_Double_Window* w;
  { Fl_Double_Window* o = new Fl_Double_Window(480, 320);
    w = o; (void)w;
    o->user_data((void*)(this));
    { TestWidget* o = new TestWidget(25, 25, 64, 22, "Button");
      o->box(FL_UP_BOX);
      o->color(FL_BACKGROUND_COLOR);
      o->selection_color(FL_BACKGROUND_COLOR);
      o->labeltype(FL_NORMAL_LABEL);
      o->labelfont(0);
      o->labelsize(14);
      o->labelcolor(FL_FOREGROUND_COLOR);
      o->align(Fl_Align(FL_ALIGN_CENTER));
      o->when(FL_WHEN_RELEASE);
      TestWidget.h
    } // TestWidget* o
    o->end();
  } // Fl_Double_Window* o
  return w;
}

The line "TestWidget.h" should probably have been an include in the header file.
As such, nothing builds; it succeeds if this line is removed and

#include "TestWidget.h"

is added to the header file. It gets obviously overwritten the next time FLUID code is generated.

It could be that I am not using FLUID rightly.

Please instruct about the right way to do that.

Thank you.

Matthias Melcher

unread,
Sep 29, 2026, 9:49:35 AMSep 29
to fltk.general
In "Extra Code", type the full statement: #include "TestWidget.h" . Fluid will recognize that this is an include statement and put it in your header file. If you have multiple widgets, Fluid will emit the include statement only once.

If you want more control, add a declaration node at the beginning and put your include statement there. You can the choose if you want it in the header or source file.

S ET

unread,
Sep 29, 2026, 10:46:02 AMSep 29
to fltk.general
Yes, this solves the problem and avoid swapping code downstream.

Thank you very much.

Reply all
Reply to author
Forward
0 new messages