Yet what i try to do is not that complicated. I'd just like to have an abstract class "Widget" which i'll derive into "Grid" and "Palette".
Yet, when i just write
Code: Select all
class Widget {
protected:
uint16 xbase, ybase;
uint16 width, height;
public:
Widget(uint16 xb, uint16 yb) {xbase = xb ; ybase =yb;}
Widget() {xbase = 0; ybase=0; width=1; height=1;};
virtual void render(void)=0;
static void prepare(void);
virtual ~Widget();
virtual bool here(touchPosition touch) {
uint16 x=touch.x, y=touch.y;
return x>=xbase && y>=ybase && x<xbase+width && y<ybase+height;
}
virtual void handle(touchPosition touch)=0;
};
Widget::~Widget() {
}
class Palette : public Widget {
static const uint COLORS_PER_LINE=16;
static const uint NUM_OF_TILES=64;
static const uint TILES_PER_LINE=4;
public:
Palette() {width=4*8; height=16*8;};
virtual ~Palette() {};
};
void Palette::render(void) {
// stuff
}
void Palette::handle(touchPosition touch) {
// more stuff
}
Somehow, i'd have expected that having "void render(void)" in Widget class definition would be enough, but no: i have to edit the "Palette" class and write it like
Code: Select all
class Palette : public Widget {
static const uint COLORS_PER_LINE=16;
static const uint NUM_OF_TILES=64;
static const uint TILES_PER_LINE=4;
public:
static void prepare(void); // ???
void render(void); // ???
Palette() {width=4*8; height=16*8;};
virtual ~Palette() {};
};