ok, here’s an example of what im doing:
[code]#include “…/JuceLibraryCode/JuceHeader.h”
static const char* poo =
“The number of pensioners is forecast to rise by half by 2030, and over-85s to double, resulting in a sharp increase in those with multiple long-term health conditions.\nThe 105-page report from the House of Lords’ public service and demography committee makes a series of recommendations for the Government, employers and wider society.\nIt says: “The UK population is ageing rapidly, but we have concluded that the Government and our society are woefully underprepared. Longer lives can be a great benefit, but there has been a collective failure to address the implications and without urgent action this great boon could turn into a series of miserable crises.” The committee comprises former Cabinet ministers, mandarins and medical experts, and its recommendations will be closely studied by the Government.\nLord Filkin, its chairman, said: “The public are entitled to an honest conversation about the implications.”\nThe committee welcomes plans to cap the maximum bill for those requiring social care but warns that the flagship announcement “will not be sufficient”.\nThey call for a “ten year” spending deal for the NHS and social care to allow services to be properly planned.\nThe report highlights predictions that more than half as many extra people will be living with three or more long-term conditions in England by 2018, compared with 2008.\nIt also warns that the Government, pensions industry and employers need to overhaul the pension system so that those in defined contribution schemes, now the majority of company schemes, have a clearer idea of what income they can eventually expect.\nThe peers also say that the state cannot shoulder all the burden and suggest that pensioners should be offered cheap, risk-free schemes to release equity from their homes.\nMichelle Mitchell, charity director general at Age UK, praised the report, saying: “It’s the first time a group of senior policymakers in this country has shown it grasps the scale and nature of change needed across our society in response to the gift of longer lives.””;
class Panel;
// the square is the object in front of the text
class Square: public Component
{
public:
Square(Panel* p) : _host(p) {}
void paint(Graphics& g)
{
g.fillAll(Colours::red);
}
void mouseDown(const MouseEvent& e)
{
_bounds = getBoundsInParent();
}
void mouseDrag(const MouseEvent& e);
Panel* _host;
Rectangle<int> _bounds;
};
// draw some text in the background begind the square
class SomeText: public TextEditor
{
public:
SomeText() { _init(); }
void append(char c)
{
_s += c;
setText(_s);
}
private:
void _init()
{
setMultiLine(true);
setScrollbarsShown(false);
_font.setHeight(24);
setFont(_font);
_s = poo;
setText(_s);
}
Font _font;
String _s;
};
class Panel: public Component
{
public:
Panel() { _init(); }
void paint(Graphics& g)
{
g.fillAll(Colours::whitesmoke);
}
void add(Component* c, int w, int h)
{
c->setBounds(0,0,w,h);
addAndMakeVisible(c);
}
void move(Component* c, const Rectangle<int>& b)
{
// side effect of moving the square is changing the text
_stext->append('a');
// update the position of the square
c->setBounds(b);
// lets chivvy up the painting
// uncomment the next line to FORCE painting of the text
// (providing you've hacked your windows event loop!)
//_stext->getPeer()->performAnyPendingRepaintsNow();
}
private:
void _init()
{
int w = 640;
int h = 1024;
_sq = new Square(this);
_stext = new SomeText;
add(_stext, w, h);
add(_sq, 100,100);
}
Square* _sq;
SomeText* _stext;
};
void Square::mouseDrag(const MouseEvent& e)
{
Point dm = e.getOffsetFromDragStart();
_host->move(this, _bounds + dm);
}
[/code]
This code makes a Panel' withSomeText’ and a `Square’. The square can be moved in front of the text. in order to simulate the text component doing some work, the movement causes the text to change (add a single letter to the end).
When you run this, the red square moves very badly. hardly at all in fact, until you stop dragging, whence everything is fine.
However, if you comment in the last line of Panel::move, the square moves smoothly because im forcing through the repainting of the text.
so why do i need to do this? why arent the repaint calls being delivered to the text component in a timely way by default?
– hugh.