Root/gui_util.h

Source at commit 1d7eccb06b61f239b9671617488f33910286f0f1 created 5 years 7 months ago.
By Werner Almesberger, dump.c: add dumping of %iprint
1/*
2 * gui_util.h - GUI helper functions
3 *
4 * Written 2009, 2010 by Werner Almesberger
5 * Copyright 2009, 2010 by Werner Almesberger
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 */
12
13
14#ifndef GUI_UTIL_H
15#define GUI_UTIL_H
16
17#include <gtk/gtk.h>
18
19#include "coord.h"
20
21
22struct draw_ctx {
23    GtkWidget *widget;
24    int scale;
25    struct coord center;
26};
27
28struct pix_buf {
29    GdkDrawable *da;
30    int x, y;
31    GdkPixbuf *buf;
32};
33
34
35extern struct draw_ctx draw_ctx;
36
37
38#define DA GDK_DRAWABLE(draw_ctx.widget->window)
39
40
41GdkColor get_color(const char *spec);
42
43void set_width(GdkGC *gc, int width);
44
45void free_pix_buf(struct pix_buf *buf);
46struct pix_buf *save_pix_buf(GdkDrawable *da, int xa, int ya, int xb, int yb,
47    int border);
48void restore_pix_buf(struct pix_buf *buf);
49
50void draw_arc(GdkDrawable *da, GdkGC *gc, int fill,
51    int x, int y, int r, double a1, double a2);
52void draw_circle(GdkDrawable *da, GdkGC *gc, int fill,
53    int x, int y, int r);
54
55/* tooltips are optional (use NULL for none) */
56
57GtkWidget *label_in_box_new(const char *s, const char *tooltip);
58GtkWidget *box_of_label(GtkWidget *label);
59void label_in_box_fg(GtkWidget *box, const char *color);
60void label_in_box_bg(GtkWidget *box, const char *color);
61
62void vacate_widget(GtkWidget *widget);
63
64GtkWidget *make_image(GdkDrawable *drawable, char **xpm, const char *tooltip);
65GtkWidget *make_transparent_image(GdkDrawable *drawable, char **xpm,
66    const char *tooltip);
67void set_image(GtkWidget *widget, GtkWidget *image);
68GtkWidget *tool_button(GtkWidget *bar, GdkDrawable *drawable,
69    char **xpm, const char *tooltip,
70    gboolean (*cb)(GtkWidget *widget, GdkEventButton *event, gpointer data),
71    gpointer data);
72
73void render_text(GdkDrawable *da, GdkGC *gc, int x, int y, double angle,
74    const char *s, const char *font, double xalign, double yalign,
75    int xmax, int ymax);
76
77void debug_save_pixbuf(GdkPixbuf *buf);
78void debug_save_widget(GtkWidget *widget);
79
80void destroy_all_children(GtkContainer *container);
81
82int get_widget_width(GtkWidget *widget);
83
84#endif /* !GUI_UTIL_H */
85

Archive Download this file

Branches:
master



interactive