| 72 | private: |
| 73 | |
| 74 | void draw ( |
| 75 | const canvas& c |
| 76 | ) const |
| 77 | { |
| 78 | // The canvas is an object that represents a part of the parent window |
| 79 | // that needs to be redrawn. |
| 80 | |
| 81 | // The first thing I usually do is check if the draw call is for part |
| 82 | // of the window that overlaps with my widget. We don't have to do this |
| 83 | // but it is usually good to do as a speed hack. Also, the reason |
| 84 | // I don't have it set to only give you draw calls when it does indeed |
| 85 | // overlap is because you might want to do some drawing outside of your |
| 86 | // widget's rectangle. But usually you don't want to do that :) |
| 87 | rectangle area = c.intersect(rect); |
| 88 | if (area.is_empty() == true) |
| 89 | return; |
| 90 | |
| 91 | // This simple widget is just going to draw a box on the screen. |
| 92 | fill_rect(c,rect,rgb_pixel(red,green,blue)); |
| 93 | } |
| 94 | }; |
| 95 | |
| 96 | // ---------------------------------------------------------------------------- |