Status bar component


#1

Hello all!
After a couple of articles in the OpenSource Journal I become interested in JUCE. I’d like to find out: is there in it a standard component to create an application’s status bar (for display of hints of menu items, toolbar buttons etc)? If there’s no, what classes could you advise to create my own status bar class on the basis of the Label one, for example? Probably, someone can share the link to a code sample? Thanks in advance.


#2

(Really? didn’t know it had been namechecked in the OpenSource Journal, I’ll have to take a look…)

There isn’t actually a standard status bar component… Whenever I’ve needed to write a status bar, it has always been quite specific to the app I’ve been writing. I’m not really sure what form a general-purpose one would take.

I guess if you just want something that displays a message, then yep, a Label will do the job nicely. You might want to put it inside another component so it can be indented slightly, and maybe draw a background that suits your app. It feels like there’s very little that a “standard” status component could offer that would make it any easier to do that.


#3

I am afraid, it will be a little inconvenient to you, if you don’t know well Russian: articles are written in this language (within “Non-standard GUI tool-kits” series). But if you wish to look at, here links to issues’ archives:
OpenSource #71
OpenSource #72

To be continued…


#4

Ah, yes, my russian’s not too good!


#5

Well, I tried to create a primitive status bar on the basis of the Label component.
If something wrong, I ask not to hurl slippers on me: today is the third day of my acquaintance with JUCE.
For catching of necessity of the hints’ reflection on a status bar during mouse pointing on a toolbar button of a main application’s component (TCentralComponent class), I used the mouseMove function:

#ifndef _TCentralComponent_h_
#define _TCentralComponent_h_
//------------------------------------------------------------------------------
#include "../JuceLibraryCode/JuceHeader.h"
#include "TToolbarFactory.h"
//------------------------------------------------------------------------------
class TCentralComponent  : public Component,
                           public ButtonListener
{
public:
    TCentralComponent();
    ~TCentralComponent();

    void paint(Graphics&);
    void resized();
    void buttonClicked(Button*);
    void mouseMove(const MouseEvent&); // Reflects button's hints...

    juce_UseDebuggingNewOperator

private:
    Label* pInfoLabel;
    Toolbar* pToolbar;
    TToolbarFactory ToolbarFactory;
    Label* pStatusBar; // A primitive status bar

    TCentralComponent(const TCentralComponent&);
    const TCentralComponent& operator= (const TCentralComponent&);
};
//------------------------------------------------------------------------------
#endif

In the TCentralComponent class’s constructor I added an instance of the class as a mouse listener of the toolbar:

TCentralComponent::TCentralComponent() : Component("Central Component"),
                                         pInfoLabel(0),
                                         pToolbar(0),
                                         pStatusBar(0)
{
    pToolbar = new Toolbar();
    addAndMakeVisible(pToolbar);
    pToolbar->setVertical(false);
    pToolbar->addDefaultItems(ToolbarFactory);
    pToolbar->addMouseListener(this, true); // Listens mouse moves upon its children...

    ToolbarFactory.pFileNewButton->addButtonListener(this);
    ToolbarFactory.pFileQuitButton->addButtonListener(this);
    ToolbarFactory.pFileOpenButton->addButtonListener(this);
    ToolbarFactory.pViewOrientationButton->addButtonListener(this);
    
    pInfoLabel = new Label("Info Label", T("Click a toolbar button!"));
    addAndMakeVisible(pInfoLabel);
    pInfoLabel->setJustificationType(Justification::centred);
    pInfoLabel->setColour(TextEditor::backgroundColourId, Colours::azure);
    
    pStatusBar = new Label(T("Status Bar"), T(""));
    addAndMakeVisible(pStatusBar);
    pStatusBar->setFont(Font(15.0000f, Font::plain));
    pStatusBar->setJustificationType(Justification::centredLeft);
    pStatusBar->setEditable(false, false, false);
    pStatusBar->setColour(TextEditor::textColourId, Colours::black);
    pStatusBar->setColour(TextEditor::backgroundColourId, Colour(0x0));

    setSize(400, 200);
}

And how it works:

void TCentralComponent::mouseMove(const MouseEvent& Event)
{
    if(Event.source.getComponentUnderMouse() == ToolbarFactory.pFileQuitButton)
    {
        pStatusBar->setText(T("Press to finish working with the application"), false);
    }
    else if(Event.source.getComponentUnderMouse() == ToolbarFactory.pViewOrientationButton)
    {
        pStatusBar->setText(T("Press to set the toolbar veritically / horizontally"), false);
    }
    else
    {
        pStatusBar->setText(T("Ready"), false);
    }
}

And how programme’s work looks:

Any better ideas? :wink: