Can't see TabbedComponent in the Jucer preferences panel


#1

Hi,
I want to extend the misc page from the preferences panel of the Jucer with a TabbedComponent, but it is not visible.

#include "../jucer_Headers.h"
#include "jucer_PrefsPanel.h"


class MiscPage : public Component
{
public:

    /* Constructor */
    MiscPage(void) :
        m_templateDir("C++ template folder:",
                      StoredSettings::getInstance()->getTemplatesDir(),
                      true,
                      true,
                      false,
                      "*.*",
                      String::empty,
                      "(Select the directory containing template .cpp and .h files)"
                      ),
        m_label(String::empty, m_templateDir.getName()),
        m_tabbedComponent(0)
    {
        addAndMakeVisible(m_tabbedComponent = new TabbedComponent(TabbedButtonBar::TabsAtLeft));
        m_tabbedComponent->setTabBarDepth(30);
        m_tabbedComponent->addTab(("Tabs"), Colours::lightgrey, new Component(), true);
        m_tabbedComponent->addTab(("Template"), Colours::lightgrey, &m_templateDir, false);
        m_tabbedComponent->setCurrentTabIndex(0);
        //m_tabbedComponent->setSize(getWidth(), getHeight());
        m_tabbedComponent->setVisible(true);
        //addAndMakeVisible(&m_templateDir);
        //m_label.attachToComponent(&m_templateDir, true);
    }

    /* Destructor */
    ~MiscPage(void)
    {
        StoredSettings::getInstance()->setTemplatesDir(m_templateDir.getCurrentFile());
        deleteAndZero(m_tabbedComponent);
    }

    void resized(void)
    {
        m_templateDir.setBounds(150, 16, getWidth() - 160, 22);
    }

private:

    TabbedComponent *m_tabbedComponent;
    FilenameComponent m_templateDir;
    Label m_label;
};

static const char *miscPage = "Misc";
static const char *keysPage = "Keys";

class PrefsTabComp : public PreferencesPanel
{
public:

    /* Constructor */
    PrefsTabComp(void)
    {
        addSettingsPage(miscPage, BinaryData::prefs_misc_png, BinaryData::prefs_misc_pngSize);
        addSettingsPage(keysPage, BinaryData::prefs_keys_png, BinaryData::prefs_keys_pngSize);
    }

    /* Destructor */
    ~PrefsTabComp(void)
    {
        StoredSettings::getInstance()->flush();
    }

    Component *createComponentForPage(const String &pageName)
    {
        if (pageName == miscPage)
        {
            return new MiscPage();
        }
        else if (pageName == keysPage)
        {
            return new KeyMappingEditorComponent(*commandManager->getKeyMappings(), true);
        }

        return new Component();
    }
};





static String prefsWindowPos;


/* Constructor */
PrefsPanel::PrefsPanel(void) :
    DialogWindow("Jucer Preferences", Colour::greyLevel (0.92f), true)
{
    PrefsTabComp *const p = new PrefsTabComp();
    p->setSize(456, 510);

    setContentOwned(p, true);

    if (!restoreWindowStateFromString(prefsWindowPos))
    {
        centreAroundComponent(0, getWidth(), getHeight());
    }

    setResizable(true, true);
    setResizeLimits(400, 400, 1000, 800);
}

/* Destructor */
PrefsPanel::~PrefsPanel(void)
{
    prefsWindowPos = getWindowStateAsString();
}

void PrefsPanel::closeButtonPressed(void)
{
    setVisible(false);
}

void PrefsPanel::show(void)
{
    PrefsPanel pp;
    pp.runModalLoop();
}

The misc page is empty and the keys page works.
When I uncomment ‘addAndMakeVisible(&m_templateDir);’, the ‘FilenameComponent’ is visible, but no tabbed component.
Please, can somebody help me?
Have I to set a size for the tabbed component or some colour?

Thanks,
Thomas


#2

yes, of course you have to give it a size!


#3

yes, of course you have to give it a size![/quote]

It works. :slight_smile:
I have added the line

into the resized function.

Thanks,
Thomas