+dict_paint_action (void *closure, char *word, dict_entry_t *entry)
+{
+ dict_paint_cursor_t *cursor = closure;
+ cairo_t *cr = cursor->cr;
+ double new_x, new_y;
+ int found, show_blanks = FALSE;
+
+ if (strlen (word) < 3)
+ return;
+
+ found = *entry & RACK_DICT_ENTRY_FOUND;
+
+ cairo_set_source_rgb (cr, 0, 0, 0); /* black */
+
+ switch (cursor->show) {
+ case DICT_PAINT_CURSOR_SHOW_FOUND:
+ if (! found)
+ return;
+ break;
+ case DICT_PAINT_CURSOR_SHOW_UNFOUND_BLANKS:
+ if (found)
+ return;
+ show_blanks = TRUE;
+ break;
+ case DICT_PAINT_CURSOR_SHOW_ALL:
+ if (! found)
+ cairo_set_source_rgb (cr, 1, 0, 0); /* red */
+ break;
+ }
+
+ /* Don't bother displaying unfound obscure words. */
+ if (*entry & RACK_DICT_ENTRY_OBSCURE) {
+ if (! found)
+ return;
+ cairo_set_source_rgb (cr, 0, 1, 0); /* green */
+ }
+
+ cairo_move_to (cr, cursor->x, cursor->y);
+ if (show_blanks) {
+ int i, length = strlen (word);
+ for (i = 0; i < length; i++)
+ cairo_show_text (cr, "_");
+ } else {
+ cairo_show_text (cr, word);
+ }
+ cairo_get_current_point (cr, &new_x, &new_y);
+ if (new_x > cursor->max_column_width)
+ cursor->max_column_width = new_x;
+ cursor->y += cursor->line_height;
+ if (cursor->y > cursor->max_y) {
+ cursor->x = cursor->max_column_width + cursor->line_height / 2;
+ cursor->y = cursor->line_height;
+ }
+}
+
+#define SOLUTION_FONT_SIZE 12
+#define SOLUTION_LINE_HEIGHT (1.5 * SOLUTION_FONT_SIZE)
+
+static void
+dict_paint (cairo_t *cr, void *closure, double width, double height)
+{
+ rack_t *rack = closure;
+ dict_paint_cursor_t cursor;
+ int length, count;
+
+ cairo_save (cr);
+ cairo_set_source_rgb (cr, 0.0, 0.0, 0.0); /* black */
+
+ cursor.cr = cr;
+
+ cairo_select_font_face (cr, "mono", 0, 0);
+ cairo_set_font_size (cr, SOLUTION_FONT_SIZE);
+ cursor.line_height = SOLUTION_LINE_HEIGHT;
+
+ cursor.x = 0;
+ cursor.y = cursor.line_height;
+
+ cursor.max_column_width = 0;
+ cursor.max_y = height;
+
+ length = 1;
+ count = 0;
+ do {
+ if (rack->done)
+ cursor.show = DICT_PAINT_CURSOR_SHOW_ALL;
+ else
+ cursor.show = DICT_PAINT_CURSOR_SHOW_FOUND;
+ count += dict_for_each_of_length (&rack->solution,
+ dict_paint_action, &cursor,
+ length, length);
+ if (! rack->done) {
+ cursor.show = DICT_PAINT_CURSOR_SHOW_UNFOUND_BLANKS;
+ dict_for_each_of_length (&rack->solution,
+ dict_paint_action, &cursor,
+ length, length);
+ }
+ length++;
+ } while (count < rack->solution_total);
+
+ cairo_restore (cr);
+}
+
+static void
+tile_paint (cairo_t *cr, void *closure, double width, double height)