Something like:
[code]class FilmStripKnob : public Slider
{
public:
FilmStripKnob(File const& image, const int numFrames, const bool stripIsHorizontal)
: Slider(image.getFullPathName() + T(" FilmStripKnob")),
filmStrip(image.exists() ? ImageFileFormat::loadFrom(image) : 0),
numFrames_(numFrames),
isHorizontal_(stripIsHorizontal)
{
if(filmStrip)
{
setTextBoxStyle(NoTextBox, 0, 0, 0);
if(isHorizontal_) {
frameHeight = filmStrip->getHeight();
frameWidth = filmStrip->getWidth() / numFrames_;
} else {
frameHeight = filmStrip->getHeight() / numFrames_;
frameWidth = filmStrip->getWidth();
}
}
}
~FilmStripKnob() { delete filmStrip; }
void paint(Graphics& g)
{
if(filmStrip) {
int value = (getValue() - getMinimum()) / (getMaximum() - getMinimum()) * (numFrames_ - 1);
if(isHorizontal_) {
g.drawImage(filmStrip, 0, 0, getWidth(), getHeight(),
value * frameWidth, 0, frameWidth, frameHeight);
} else {
g.drawImage(filmStrip, 0, 0, getWidth(), getHeight(),
0, value * frameHeight, frameWidth, frameHeight);
}
}
}
int getFrameWidth() const { return filmStrip ? frameWidth : 100; }
int getFrameHeight() const { return filmStrip ? frameHeight : 24; }
private:
Image* filmStrip;
const int numFrames_;
const bool isHorizontal_;
int frameWidth, frameHeight;
};[/code]
…then used something like this:
[code]class MainComponent : public Component
{
private:
public:
MainComponent ()
{
addAndMakeVisible(filmStripKnob = new FilmStripKnob(String("~/Desktop/knobs/20070917sample2.jpg"),
4,
true));
}
~MainComponent ()
{
deleteAllChildren();
}
void resized ()
{
filmStripKnob->setBounds(20,
20,
filmStripKnob->getFrameWidth(),
filmStripKnob->getFrameHeight());
}
private:
FilmStripKnob *filmStripKnob;
};[/code]
… where the file “20070917sample2.jpg” is one of the sample files on http://www.g200kg.com/en/software/knobman.html (which is a horizontally orgnaised series of four frames).