Ken Yarnall wrote:

> Folks,
> 
> In the past, I've used fluid to generate positioning code, pasted that
> into my code, and otherwise ignored what Fluid generates.  I've recently
> begun looking for better ways to use fluid.
> 
> My chief problem is that I don't want to "code" in Fluid;  I want to
> write the functions that lay out my widgets in Fluid, and leave the
> coding of callbacks and other functions to my IDE.  However, If I
> generate a class in Fluid, then add functions to class, I cannot go back
> and modify my GUI in fluid, since the generated code will wipe out my
> outside-of-fluid changes.
> 
> The "obvious" solution is to use the fluid-generated class as a base
> class.  However, my derived class would need access to the data members
> (widgets) in this class, so they have to be public -- can we add an
> option to make something protected in Fluid?  I can hack the code to
> change the private field to protected, but that's not a real solution.
> 
> I'm interested in hearing how others solve this problem and use Fluid
> more effectively than I do.
> 
> Cheers,
> Ken

I use FLUID to create the UI. Depending on the app's size, I either use a OO
design or a C design (just functions that create the windows, etc.).

The trick is to not use Functions, rather use Declarations. In the
Declaration dialog box write out the full prototype:
e.g. void file_exit();

Then, create a separate implementation file, I use something like:
MyApp_callbacks.cpp or MyApp_implementation.cpp.

In the implementation file, simply include the FLUID-generated header file:
#include "MyApp.h"

If you use the OO design for your app, simple treat the implementation file
as another .cpp in the usual .h/.cpp pairing. To continue with my previous
examples, I would have:

   #include "MyApp.h" // created by FLUID from MyApp.fl

   void MyApp::file_exit()
   {
      // Make sure that preferences are sync'd to disk
      prefs.flush();

      // avoid calling the dtors, we are closing down
      _exit(0);
   }

With this method, I am able to use KDevelop to handle my projects, but use
FLUID to manage the UI.

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

Reply via email to