1 | /** |
---|
2 | * |
---|
3 | * The paper tape GTK widget |
---|
4 | * |
---|
5 | * This widget wraps the pure cairo widget "LOCHSTREIFEN" with some |
---|
6 | * GTK widgets (which implement scrolling, mouse events, menues for |
---|
7 | * changing parameters, etc.) and adds events and signals for simple |
---|
8 | * interaction and use in applications. |
---|
9 | * |
---|
10 | * It can produce high quality SVG and PNG files (apart from displaying |
---|
11 | * the paper tape on the screen) and is highly configurable. With |
---|
12 | * only a few lines of code you can use this widget in your own |
---|
13 | * programs, gtk.c shows an exemplar implementation in only about |
---|
14 | * 160 lines of C code. |
---|
15 | * |
---|
16 | * Started 05.06.2008 13:13 (the first new project in the SVN) |
---|
17 | * Copyright (C) 2008 Sven Köppel |
---|
18 | * |
---|
19 | * This program is free software; you can redistribute |
---|
20 | * it and/or modify it under the terms of the GNU General |
---|
21 | * Public License as published by the Free Software |
---|
22 | * Foundation; either version 3 of the License, or (at |
---|
23 | * your option) any later version. |
---|
24 | * |
---|
25 | * This program is distributed in the hope that it will |
---|
26 | * be useful, but WITHOUT ANY WARRANTY; without even the |
---|
27 | * implied warranty of MERCHANTABILITY or FITNESS FOR A |
---|
28 | * PARTICULAR PURPOSE. See the GNU General Public License |
---|
29 | * for more details. |
---|
30 | * |
---|
31 | * You should have received a copy of the GNU General |
---|
32 | * Public License along with this program; if not, see |
---|
33 | * <http://www.gnu.org/licenses/>. |
---|
34 | * |
---|
35 | **/ |
---|
36 | |
---|
37 | #ifndef GTK_PAPER_TAPE_H |
---|
38 | #define GTK_PAPER_TAPE_H |
---|
39 | |
---|
40 | #include <glib.h> |
---|
41 | #include <glib-object.h> |
---|
42 | #include <gtk/gtk.h> |
---|
43 | #include "lochstreifen.h" |
---|
44 | |
---|
45 | |
---|
46 | G_BEGIN_DECLS |
---|
47 | |
---|
48 | /*#define GTK_PAPER_TAPE_TYPE (gtk_paper_tape_get_type()) |
---|
49 | #define GTK_TYPE_PAPER_TAPE (gtk_paper_tape_get_type()) |
---|
50 | #define GTK_PAPER_TAPE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_PAPER_TAPE, GtkPaperTape)) |
---|
51 | #define GTK_PAPER_TAPE_CLASS(klasse) (G_TYPE_CHECK_CLASS_CAST((klasse), GTK_TYPE_PAPER_TAPE, GtkPaperTapeClass)) |
---|
52 | #define GTK_IS_PAPER_TAPE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GTK_TYPE_PAPER_TAPE)) |
---|
53 | #define GTK_IS_PAPER_TAPE_CLASS(klasse) (G_TYPE_CHECK_CLASS_TYPE((klasse), GTK_TYPE_PAPER_TAPE)) |
---|
54 | #define GTK_PAPER_TAPE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_TYPE_PAPER_TAPE, GtkPaperTapeClass))*/ |
---|
55 | |
---|
56 | #define GTK_PAPER_TAPE_TYPE (gtk_paper_tape_get_type ()) |
---|
57 | #define GTK_PAPER_TAPE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_PAPER_TAPE_TYPE, GtkPaperTape)) |
---|
58 | #define GTK_PAPER_TAPE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_PAPER_TAPE_TYPE, GtkPaperTapeClass)) |
---|
59 | #define GTK_IS_PAPER_TAPE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_PAPER_TAPE_TYPE)) |
---|
60 | #define GTK_IS_PAPER_TAPE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_PAPER_TAPE_TYPE)) |
---|
61 | |
---|
62 | typedef struct _GtkPaperTape GtkPaperTape; |
---|
63 | typedef struct _GtkPaperTapeClass GtkPaperTapeClass; |
---|
64 | |
---|
65 | struct _GtkPaperTape { |
---|
66 | //GObject parent; |
---|
67 | GtkWidget widget; // was GObject parent; |
---|
68 | // instance members |
---|
69 | |
---|
70 | /** Main window where this widget belongs to |
---|
71 | * (to be used e.g. for modal dialogs) */ |
---|
72 | GtkWidget *parent_window; |
---|
73 | |
---|
74 | /** The famous LOCHSTREIFEN widget */ |
---|
75 | LOCHSTREIFEN *lochstreifen; |
---|
76 | |
---|
77 | /** The Statusbar where the mouse movement messages appear */ |
---|
78 | GtkWidget *statusbar; |
---|
79 | |
---|
80 | /** |
---|
81 | * The GtkScrolledWindow where the |
---|
82 | * GtkDrawingArea resides |
---|
83 | */ |
---|
84 | GtkWidget *scroll; |
---|
85 | GtkWidget *draw; |
---|
86 | |
---|
87 | /*< private >*/ |
---|
88 | GtkWidget *menu_toggle_fit_screen; |
---|
89 | GTimer *last_statusbar_update; |
---|
90 | }; |
---|
91 | |
---|
92 | struct _GtkPaperTapeClass { |
---|
93 | GtkWidgetClass parent_class; //GObjectClass parent; |
---|
94 | }; |
---|
95 | |
---|
96 | GType gtk_paper_tape_get_type(void); |
---|
97 | |
---|
98 | GtkWidget* gtk_paper_tape_new(); |
---|
99 | |
---|
100 | void gtk_paper_tape_menu_export(GtkPaperTape *papertape, GtkWidget *target_menu); |
---|
101 | void gtk_paper_tape_menu_view(GtkPaperTape *papertape, GtkWidget *target_menu); |
---|
102 | void gtk_paper_tape_menu_colors(GtkPaperTape *papertape, GtkWidget *target_menu); |
---|
103 | |
---|
104 | /* fast "almost macro" functions */ |
---|
105 | GtkWidget *fast_color_menuitem(const GtkWidget *parentmenu, const char *dialog_title, const char *labeltext, GdkColor *initialColor, GtkSizeGroup *label_nice_sizegroup); |
---|
106 | GtkWidget *fast_stock_menuitem(const GtkWidget *parentmenu, const gchar *stock_id); |
---|
107 | GtkWidget *fast_menuitem(const GtkWidget *parentmenu, const gchar *label); |
---|
108 | GtkWidget *fast_menu_tearoff(const GtkWidget *parentmenu); |
---|
109 | GtkWidget *fast_menu_seperator(const GtkWidget *parentmenu); |
---|
110 | GdkColor *color_cairo2gdk(cairo_pattern_t *pattern); |
---|
111 | |
---|
112 | void gtk_paper_tape_set_data(GtkPaperTape* papertape, int length, byte_t *data); |
---|
113 | void gtk_paper_tape_set_null_bytes(GtkPaperTape *papertape, int beginning, int end); |
---|
114 | |
---|
115 | G_END_DECLS |
---|
116 | |
---|
117 | #endif /* GTK_PAPER_TAPE_H */ |
---|