diff options
Diffstat (limited to 'apps/plugins/puzzles/src/puzzles.h')
-rw-r--r-- | apps/plugins/puzzles/src/puzzles.h | 88 |
1 files changed, 63 insertions, 25 deletions
diff --git a/apps/plugins/puzzles/src/puzzles.h b/apps/plugins/puzzles/src/puzzles.h index 2c52bc6cde..44a056d78f 100644 --- a/apps/plugins/puzzles/src/puzzles.h +++ b/apps/plugins/puzzles/src/puzzles.h | |||
@@ -266,6 +266,8 @@ void draw_rect(drawing *dr, int x, int y, int w, int h, int colour); | |||
266 | void draw_line(drawing *dr, int x1, int y1, int x2, int y2, int colour); | 266 | void draw_line(drawing *dr, int x1, int y1, int x2, int y2, int colour); |
267 | void draw_polygon(drawing *dr, const int *coords, int npoints, | 267 | void draw_polygon(drawing *dr, const int *coords, int npoints, |
268 | int fillcolour, int outlinecolour); | 268 | int fillcolour, int outlinecolour); |
269 | void draw_polygon_fallback(drawing *dr, const int *coords, int npoints, | ||
270 | int fillcolour, int outlinecolour); | ||
269 | void draw_circle(drawing *dr, int cx, int cy, int radius, | 271 | void draw_circle(drawing *dr, int cx, int cy, int radius, |
270 | int fillcolour, int outlinecolour); | 272 | int fillcolour, int outlinecolour); |
271 | void draw_thick_line(drawing *dr, float thickness, | 273 | void draw_thick_line(drawing *dr, float thickness, |
@@ -454,6 +456,9 @@ char *button2label(int button); | |||
454 | * standard per clause 7.26.11.1.) */ | 456 | * standard per clause 7.26.11.1.) */ |
455 | void swap_regions(void *av, void *bv, size_t size); | 457 | void swap_regions(void *av, void *bv, size_t size); |
456 | 458 | ||
459 | /* comparator for sorting ints with qsort() */ | ||
460 | int compare_integers(const void *av, const void *bv); | ||
461 | |||
457 | /* | 462 | /* |
458 | * dsf.c | 463 | * dsf.c |
459 | */ | 464 | */ |
@@ -752,43 +757,76 @@ struct game { | |||
752 | int flags; | 757 | int flags; |
753 | }; | 758 | }; |
754 | 759 | ||
760 | #define GET_HANDLE_AS_TYPE(dr, type) ((type*)((dr)->handle)) | ||
761 | |||
762 | struct drawing { | ||
763 | const drawing_api *api; | ||
764 | void *handle; | ||
765 | }; | ||
766 | |||
755 | /* | 767 | /* |
756 | * Data structure containing the drawing API implemented by the | 768 | * Data structure containing the drawing API implemented by the |
757 | * front end and also by cross-platform printing modules such as | 769 | * front end and also by cross-platform printing modules such as |
758 | * PostScript. | 770 | * PostScript. |
759 | */ | 771 | */ |
760 | struct drawing_api { | 772 | struct drawing_api { |
761 | void (*draw_text)(void *handle, int x, int y, int fonttype, int fontsize, | 773 | /* |
774 | * API version. Increment this when there is a breaking change to | ||
775 | * this API which requires front ends to change. | ||
776 | * | ||
777 | * There is expliclty not a public LATEST_API_VERSION define, so | ||
778 | * that front end authors will need to manually intervene when the | ||
779 | * version number changes. Naturally, this should be done | ||
780 | * sparingly. | ||
781 | * | ||
782 | * If a function is ever added to this API, please move this field | ||
783 | * to the _end_ of the structure, so that changes thereafter will | ||
784 | * shift the position of the version and lead to a compilation | ||
785 | * error if old implementations are not updated. Then remove this | ||
786 | * comment. | ||
787 | * | ||
788 | * The latest version number is 1. | ||
789 | * | ||
790 | * Change log: | ||
791 | * | ||
792 | * Version 1 (2024-08-14): Introduction of version number, in | ||
793 | * conjunction with changing every API function to take `drawing | ||
794 | * *` instead of `void *`. See commit f379130 for the detailed | ||
795 | * rationale behind this change. | ||
796 | */ | ||
797 | int version; | ||
798 | |||
799 | void (*draw_text)(drawing *dr, int x, int y, int fonttype, int fontsize, | ||
762 | int align, int colour, const char *text); | 800 | int align, int colour, const char *text); |
763 | void (*draw_rect)(void *handle, int x, int y, int w, int h, int colour); | 801 | void (*draw_rect)(drawing *dr, int x, int y, int w, int h, int colour); |
764 | void (*draw_line)(void *handle, int x1, int y1, int x2, int y2, | 802 | void (*draw_line)(drawing *dr, int x1, int y1, int x2, int y2, |
765 | int colour); | 803 | int colour); |
766 | void (*draw_polygon)(void *handle, const int *coords, int npoints, | 804 | void (*draw_polygon)(drawing *dr, const int *coords, int npoints, |
767 | int fillcolour, int outlinecolour); | 805 | int fillcolour, int outlinecolour); |
768 | void (*draw_circle)(void *handle, int cx, int cy, int radius, | 806 | void (*draw_circle)(drawing *dr, int cx, int cy, int radius, |
769 | int fillcolour, int outlinecolour); | 807 | int fillcolour, int outlinecolour); |
770 | void (*draw_update)(void *handle, int x, int y, int w, int h); | 808 | void (*draw_update)(drawing *dr, int x, int y, int w, int h); |
771 | void (*clip)(void *handle, int x, int y, int w, int h); | 809 | void (*clip)(drawing *dr, int x, int y, int w, int h); |
772 | void (*unclip)(void *handle); | 810 | void (*unclip)(drawing *dr); |
773 | void (*start_draw)(void *handle); | 811 | void (*start_draw)(drawing *dr); |
774 | void (*end_draw)(void *handle); | 812 | void (*end_draw)(drawing *dr); |
775 | void (*status_bar)(void *handle, const char *text); | 813 | void (*status_bar)(drawing *dr, const char *text); |
776 | blitter *(*blitter_new)(void *handle, int w, int h); | 814 | blitter *(*blitter_new)(drawing *dr, int w, int h); |
777 | void (*blitter_free)(void *handle, blitter *bl); | 815 | void (*blitter_free)(drawing *dr, blitter *bl); |
778 | void (*blitter_save)(void *handle, blitter *bl, int x, int y); | 816 | void (*blitter_save)(drawing *dr, blitter *bl, int x, int y); |
779 | void (*blitter_load)(void *handle, blitter *bl, int x, int y); | 817 | void (*blitter_load)(drawing *dr, blitter *bl, int x, int y); |
780 | void (*begin_doc)(void *handle, int pages); | 818 | void (*begin_doc)(drawing *dr, int pages); |
781 | void (*begin_page)(void *handle, int number); | 819 | void (*begin_page)(drawing *dr, int number); |
782 | void (*begin_puzzle)(void *handle, float xm, float xc, | 820 | void (*begin_puzzle)(drawing *dr, float xm, float xc, |
783 | float ym, float yc, int pw, int ph, float wmm); | 821 | float ym, float yc, int pw, int ph, float wmm); |
784 | void (*end_puzzle)(void *handle); | 822 | void (*end_puzzle)(drawing *dr); |
785 | void (*end_page)(void *handle, int number); | 823 | void (*end_page)(drawing *dr, int number); |
786 | void (*end_doc)(void *handle); | 824 | void (*end_doc)(drawing *dr); |
787 | void (*line_width)(void *handle, float width); | 825 | void (*line_width)(drawing *dr, float width); |
788 | void (*line_dotted)(void *handle, bool dotted); | 826 | void (*line_dotted)(drawing *dr, bool dotted); |
789 | char *(*text_fallback)(void *handle, const char *const *strings, | 827 | char *(*text_fallback)(drawing *dr, const char *const *strings, |
790 | int nstrings); | 828 | int nstrings); |
791 | void (*draw_thick_line)(void *handle, float thickness, | 829 | void (*draw_thick_line)(drawing *dr, float thickness, |
792 | float x1, float y1, float x2, float y2, | 830 | float x1, float y1, float x2, float y2, |
793 | int colour); | 831 | int colour); |
794 | }; | 832 | }; |