Improve docs about subclassing

- fix syntax errors in example code, e.g.: children_ is private
- use FLTK coding style
- improve alignment
This commit is contained in:
Albrecht Schlosser 2024-10-24 17:59:18 +02:00
parent eb545c981b
commit f9f89be7d7

View File

@ -118,16 +118,16 @@ see what parts of your widget need redrawing.</I> The \p handle()
method can then set individual damage bits to limit the amount of drawing
that needs to be done:
\code
MyClass::handle(int event) {
...
int MyClass::handle(int event) {
// ...
if (change_to_part1) damage(1);
if (change_to_part2) damage(2);
if (change_to_part3) damage(4);
}
MyClass::draw() {
void MyClass::draw() {
if (damage() & FL_DAMAGE_ALL) {
... draw frame/box and other static stuff ...
// ... draw frame/box and other static stuff ...
}
if (damage() & (FL_DAMAGE_ALL | 1)) draw_part1();
@ -416,14 +416,16 @@ that a child needs to be drawn. It is fastest if you avoid
drawing anything else in this case:
\code
int MyClass::draw() {
void MyClass::draw() {
Fl_Widget *const*a = array();
if (damage() == FL_DAMAGE_CHILD) { // only redraw some children
for (int i = children(); i --; a ++) update_child(**a);
for (int i = children(); i--; a++) {
update_child(**a);
}
} else { // total redraw
... draw background graphics ...
// ... draw background graphics ...
// now draw all the children atop the background:
for (int i = children_; i --; a ++) {
for (int i = children(); i--; a++) {
draw_child(**a);
draw_outside_label(**a); // you may not need to do this
}