On 07/01/15 06:32, Alvin Beach wrote:
> Hello,
>
> When I try to change the default value for FL_SELECTION_COLOR,
> it will only stick if I set it after showing the window.
Yes, I think this is because calling wnd->show(argc,argv)
expects to parse the command line for options that can
affect color maps, and it also has the side effect of
initializing the colormap.
IIRC, this is NOT the case if you just call show(void).
So either:
a) use show(void) instead, and don't call show(argc,argv)..
then you can setup your map before calling show(void).
b) if you want to use show(argc,argv), then set up your map
AFTER that call.
> I cannot seem to find a way/trick to inject code after the wnd->show() and the return.
Write your own main() in fluid instead of using Fluid "blank as main" approach.
Just declare a function in fluid as you would any other, make the function name
"main" with the two argc/argv arguments, then add a Code block to it, and write
whatever code you want, including the call to win->show() and at the end,
call return Fl::run();
> My current workaround is to edit the .cxx file manually.
A do it yourself approach (besides the above) would be to make your own
main.cpp + main.h files in a text editor, and put your custom code in there,
referring to the fluid objects/functions as a separate module, where you
#include the fluid-generated .h file, and link in the compiled fluid generated
.cpp file. (Or I suppose you could cheat and try to #include the .cpp file
in your main() code if you don't want to deal with linking .o/.obj files)
> However, my change is lost when I regenerate the .cxx file via FLUID.
Yes, avoid ever editing the .cxx/.h files fluid generates
if you want to continue using fluid to manage the files.
Use #include approach as a workaround, or do the suggestion higher
up in this post where you can do the whole thing /within/ fluid
using a custom main(), instead of the automatically generated one.
Fluid can be used in several ways:
a) to manage an entire small app
b) manage only the GUI parts of your app,
and treat the fluid generated code as a separate module (.h / .obj)
You can also use fluid to manage just certain classes, so that you
can mix in hand-written fltk code in a text editor with fluid
managed classes, one fluid file per class.