On 02/25/13 22:00, Michael wrote:
> Hi guys,
> 
> Few days ago, I discovered FLTK through your tutorials and it was a real fun.
> 
> What I'm looking after is a "portable plotting widget" (Win, Linux, OSX), but 
> can't find one for FLTK.
> 
> Nothing really advanced, just to be able to plot RAM and CPU usage of my box.
> 
> Something in this spirit (or even simple):
> http://pcsupport.about.com/od/windowsvista/tp/vistagadgetssu.htm

        I was wondering which of those many examples you had in mind;
        the  horizontal 'bouncing bar' ("DriveInfo"),
        the vertical scrolling bar graph ("System Control A1"),
        the scrolling line graph (lower part of "All Cpu Meter")..

        There might be 3rd party widgets people have made for this already,
        though I usually like the challenge of making my own widgets to do
        what I want. So in that tradition...

        To make a scrolling line graph widget, you can derive a class from 
Fl_Box,
        and define your own draw() method to draw your graph based on an array
        that you regularly update using Fl::add_timeout()/Fl::repeat_timeout(),
        which can grab cpu/ram samples from the OS, and shove them into the 
array
        and trigger the widget to redraw().

        To make a scrolling bar graph widget, you could do just like the above,
        but us fl_rectf() to draw filled boxes for each sample instead of lines
        between them.

        For a "simple" bouncing horizontal bar, you could simply use an 
Fl_Progress()
        widget, e.g.
        http://seriss.com/people/erco/fltk/#Progress
        ..but I think it only handles a single bar.. if you want multiple bars
        in one (for instance, to show user cpu use vs. operating system cpu use)
        then you'd probably have to make a custom widget using fl_color() and 
fl_rectf()
        to draw the rectangles of the bar.

        If you wanted to make a bar graph that looks fancy shmancy, you can use
        fl_draw_image() to draw little images to build a nice looking bar graph
        with gradients and antialiased edges. I'm including some info I sent you
        off list for the benefit of folks reading the list:

* * *

>       To make nice looking 'rounded' multicolor progress bars, I've used a 
> custom
>       widget that derived from Fl_Box that manipulates alpha images for the
>       round endcaps, and uses a regular fl_rectf() to connect them, eg:
>       [ASCII art follows -- read with a fixed width font!]
>        _____________
>       (_|_________|_)
>        1     2     3
>
>       ..where 1 is the left end cap, 3 is the right end cap, and 2 is the 
> fl_rectf().
>
>       You can draw the art you want, then slap it up on the screen using 
> fltk's
>       alpha blending image drawing:
>       http://seriss.com/people/erco/fltk/#AlphaBlend
>
>       I've made simple multicolored progress bars using that technique which
>       look like this:
>       http://seriss.com/people/erco/fltk/tmp/alpha-progress-bar.jpg
>
>       To make nice looking widgets of other types, similar simple manipulation
>       of alpha blended images can get great results.
>
>       FLTK is not really designed to be 'skinned' easily, so to make nice
>       looking widgets, one has to make [custom widgets with images]. The nice 
> thing though
>       is that in FLTK it's easy to make custom widgets.
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to