On 27.10.2014 13:50, John Longer wrote:
> Mmmm. Not sure if I should top or bottom post on here.
Neither. We like your replies intermixed with (trimmed) citations, so
that one can see what you're talking about. See my posts (and this one)
for an example.
> Thanks for the replies.
You're welcome.
> I tried all sorts of things with what I thought was the dials variable
> name using COUT and getting annoyed that I couldn't seem to get using
> namspace std to apply to all functions so had to keep retyping it for
> each cout as I was using it to test a number of things.. This included
> casting it etc.
Without seeing your code it's hard to say what went wrong. Usually you
don't need any "namespace std" with FLTK 1.3 code, but maybe, since
you're using cout, YMMV.
> The reason that I asked about function returns is that I do not know how
> the system handles them. For instance if calling a function from within
> another destroys it what I have done wouldn't cause any problems.
I don't understand this. What/who destroys what?
> It's
> clear from what I have done that simply entering code in the call back
> area looks after itself. What wasn't clear is what happens if I then
> enter another function but it sounds like all will be ok.
Of course.
> I asked the
> question because if have reworked the assembler output that some
> compilers can produce in the past so this area is a natural one for me
> to wonder about. There might have been some method of entering a
> function while destroying the one that was left.
Yes, in assembler you can use all kinds of branches and jumps, but in
C/C++ there is only calling with a defined return. Unless you're using
setjmp/longjmp from the C standard library or exception handling in C++.
Both methods can leave something on the heap (allocated with malloc
and/or new, for instance), but nothing on the stack.
> I do appreciate that
> there must be some mechanism to destroy it rather than just closing the
> window it's in. For all I know the size of the heap as PC people seem to
> call it might increase each time the dial setting is changed.
Yes, there is a way to destroy a window, but that is (as discussed here
and elsewhere very often) not necessary if you close the window and then
exit the program. Memory will released anyway, and often faster than if
you called d'tors yourself.
There's (usually) nothing allocated when changing the value of a widget,
and if it was, the widget would (have to) take care of this. FLTK takes
care of this in the class destructors, and you shouldn't find real
memory leaks in FLTK itself. And hey, we're not "PC people" who don't
care about memory consumption. FLTK is the "Fast and Light Tool Kit" and
is intended to be used on memory-constrained embedded platforms.
> I'm finding that there is plenty of helpful FLTK example on the web but
> little really on doing the same things from Fluid. Naturally as these
> involve typing most examples make use of classes. These examples are far
> more helpful than the bulk of docs provided with FLTK/Fluid. I have done
> a limited amount of gui type work in the past so have a general dislike
> of laying them out directly in code. It's too tedious. Actually I
> retired early and haven't written any code of any sort for around 10
> years now. I'm slightly amazed that I fancy doing any again ;-) and
> laying out several widgets directly in code would put me off
> immediately. Frankly I feel that that a visual approach is the only
> sensible way of handling this area.
Yes, that's what fluid is, the "FLtk User Interface Designer" tool. Feel
free to use it - my FLTK usage has been very differently in the past, so
I wrote my personal note in the previous message. There's nothing wrong
with using fluid though. The main point I wanted to say was that it's
difficult to learn if you don't know about the FLTK basics. You should
first know how a callback works, before you can efficiently use fluid to
define callbacks - however the GUI layout is more intuitively done
directly in fluid.
Again a personal opinion that some other people share: I recommend doing
as much GUI design as useful/necessary in fluid, but define your classes
elsewhere (in independent .h and .cxx files) and call the class methods
in the callback - i.e. make the code entered directly in fluid minimal.
So you can seperate the UI design and functional code, which will be an
advantage in larger projects.
> Fluid for several reason especially
> for maintenance concerns seems to be the most suitable OS candidate
> available.
That's fine. We appreciate this.
> QtCreator/Designer looked good but it changes too often even
> with my limited playing about. Oddly it's also harder to get into than
> FLTK even though setting up signals is very easy. I've found that the
> docs can be out of date too. Not much fun for a beginner that has
> problems understanding them anyway. Must admit I feel there is too
> little if you want to do this type documentation about so some of the
> tutorial type web pages are very helpful.
In FLTK there's a very basic tutorial in one of the first chapters of
the docs. There are many example programs in test/*.cxx (together with
some fluid files in test/*.fl), and ever more in examples/*.cxx that are
worth a look.
There's also "Erco's Cheat Page" with many examples and fluid video
tutorials. This may help you going on with FLTK and particularly with fluid.