On 11/10/12 09:59, Patrick wrote:
> Thanks again to Ian for answering my last post. I would have been stuck 
> on that for a long time but now it's so obvious. I was creating two 
> pointers with the same name.
> 
> I hope I am not wearing out my welcome... I have another question... if 
> someone can even spare a "yes or no" response it will help a lot.
> 
> I am wondering if I am on the right track regarding status bars. I found 
> this post here:
> http://www.gidforums.com/t-26030.html?highlight=status
> 
> This person was using a button for a status bar. There does not seem to 
> be a native status bar in FLTK but is this the best way to simulate one?

        I've used Fl_Box for status bars, eg:

statusbar = new Fl_Box(0,H-20,W,20);
statusbar->box(FL_FLAT_BOX);                    // make the box 'flat' (no 
decorations)
statusbar->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE);// align status text to 
left/top of widget
statusbar->color(48-2);                         // slightly darker than default 
FLTK widget color (48)

        ..where W,H are the width/height of your window, and '20' is
        about how "thick" you probably want the status bar to be to show
        a single line of text. (Use a larger number to support more lines of 
text)

        Then you can just call the following to change the message:

    statusbar->copy_label(msg);
    statusbar->redraw();

        If you put that into a function called e.g. 'StatusMessage()',
        then you can just call that with a string to change the status message, 
e.g.

void StatusMessage(const char *msg) {
    statusbar->copy_label(msg);
    statusbar->redraw();
}

        Both Fl_Box and Fl_Group will act similarly; you can probably 
interchange
        them without any different effect.

        If you want multiline, you can just make the status bar 'thicker';
        I believe the label() method will handle crlf's normally, eg:

                StatusMessage("This is line one\n"
                              "This is line two");

        ..which would show both lines of text, assuming the bar is thick enough.

        Usually status bars don't need to be copy/paste-able, but if it did,
        use Fl_Output, as it supports mouse highlighting and keyboard nav 
selection
        IIRC.

        Here's a small test program:

---- snip
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Box.H>
#define W 600
#define H 300

Fl_Box *G_statusbar = 0;                                // global!

void StatusMessage(const char *msg) {
    G_statusbar->copy_label(msg);
    G_statusbar->redraw();
}

int main() {
    Fl_Window win(W,H,"Test1");
    G_statusbar = new Fl_Box(0,H-35,W,35);
    G_statusbar->box(FL_FLAT_BOX);                      // make the box 'flat' 
(no decorations)
    G_statusbar->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE);  // align status text to 
left/top of widget
    G_statusbar->color(48-2);                           // slightly darker than 
default FLTK widget color (48)
    win.show();
    StatusMessage("Started: OK");                       // single line of 
status text
    //StatusMessage("Started: OK\nInitialized: OK");    // two lines of status 
text should work too
    return (Fl::run());
}
---- snip
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to