SplashScreen methods


#1

Hi Jules,

Is there any chance you could modify SplashScreen to declare these methods as virtual:

~SplashScreen()
Paint(…)
timerCallback(…)

Will help in customisation without having to hack together new classes. Many thanks. :slight_smile:

Pete


#2

they’re already virtual, pete… if a method overrides a virtual method, then it becomes virtual by default - adding the keyword is optional.


#3

Hi Jules,

Well, the virtual keyword isn’t in the .h files … I must be losing my marbles. :slight_smile:

class JUCE_API  SplashScreen  : public Component,
                                private Timer,
                                private DeletedAtShutdown
{
public:
     ...
     ...
     ...

    /** Destructor. */
    ~SplashScreen();

     ...
     ...
     ...

      void paint (Graphics& g)

So there is no declaration of paint etc. as being virtual (that is to say, overridable by classes that themselves derive from SplashScreen). I know that the base class from which SplashScreen dereives, declares those as virtual.

My local file matches what is in SVN; I think I must be missing something…?! :slight_smile:

Pete


#4

Either you’re confused, or I am…

If you create base class with a method marked virtual, then any method that overrides it, directly or indirectly, will also be virtual. Only the base class actually needs the keyword.

paint() and timerCallback() derive from Component and Timer, where they’re marked as virtual, so the virtualness gets inherited here by default.

Sure, it wouldn’t do any harm to add an extra ‘virtual’ keyword here, but I don’t normally bother putting it in the derived classes.


#5

Hi Jules,

Must be me then!!

The compiler was complaining that I couldn’t override Paint, as it was a non-virtual method. (Vis studio 2005).

I’ll have to have another look…!

Pete


#6

Oh - it derives privately from Timer, that’s probably why you can’t override timerCallback. I’ll change that to public. You can override paint(), though…


#7

Thanks Jules!


#8