Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Developing U++ » External resources » JUCE (widgets and library) GNU Public Licence
Re: JUCE (widgets and library) GNU Public Licence [message #7405 is a reply to message #7404] Wed, 27 December 2006 09:01 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 14267
Registered: November 2005
Ultimate Member
JUCE code:

    class RatingColumnCustomComponent    : public Component,
                                           public ComboBoxListener
    {
    public:
        RatingColumnCustomComponent (TableDemoComponent& owner_)
            : owner (owner_)
        {
            // just put a combo box inside this component
            addAndMakeVisible (comboBox = new ComboBox (String::empty));
            comboBox->addItem (T("fab"), 1);
            comboBox->addItem (T("groovy"), 2);
            comboBox->addItem (T("hep"), 3);
            comboBox->addItem (T("neat"), 4);
            comboBox->addItem (T("wild"), 5);
            comboBox->addItem (T("swingin"), 6);
            comboBox->addItem (T("mad for it"), 7);

            // when the combo is changed, we'll get a callback.
            comboBox->addListener (this);
            comboBox->setWantsKeyboardFocus (false);
        }

        ~RatingColumnCustomComponent()
        {
            deleteAllChildren();
        }

        void resized()
        {
            comboBox->setBoundsInset (BorderSize (2));
        }

        // Our demo code will call this when we may need to update our contents
        void setRowAndColumn (const int newRow, const int newColumn)
        {
            row = newRow;
            columnId = newColumn;
            comboBox->setSelectedId (owner.getRating (row, columnId), true);
        }

        void comboBoxChanged (ComboBox* comboBoxThatHasChanged)
        {
            owner.setRating (row, columnId, comboBox->getSelectedId());
        }

    private:
        TableDemoComponent& owner;
        ComboBox* comboBox;
        int row, columnId;
    };


Now this has all quirks we are trying to avoid. Why is comboBox allocated on the heap? Why should I test in comboBoxChanged which combobox did? - BTW the only purpose of this class seems to be to isolate particular combobox in the dialog. Why should I take care about "deleting all children" in destructor?

In U++, 50% of above code is unnecessary.

OTOH, of course, MacOS X is something JUCE has and U++ does not - something to add quickly...
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Interesteing RwLock implementation
Next Topic: XVT comparison missing
Goto Forum:
  


Current Time: Thu Aug 14 03:51:35 CEST 2025

Total time taken to generate the page: 0.08293 seconds