source: projects/paper-tape/userspace-driver/old implementation/gtkpapertape-private.h @ 29

Last change on this file since 29 was 29, checked in by sven, 11 years ago

I think that was the some kind of

File size: 9.3 KB
Line 
1#define GTK_PAPER_TAPE_UPDATE_GTK  { while (gtk_events_pending ()) gtk_main_iteration (); }
2
3
4#define _(a) a
5
6/********************************************************************
7     Internal Predeclarations and data types
8*********************************************************************/
9
10enum GTK_PAPER_TAPE_SIZE_CHANGED {
11        PAPER_TAPE_SIZE_CHANGED,
12        PAPER_TAPE_SIZE_NOT_CHANGED
13};
14
15/**
16 * a dummy structure for g_signal_connect to get both the instance from the
17 * calling GtkMenuButtons and from the current PaperTape and additional user
18 * data.
19 */
20struct GTK_PAPER_TAPE_INSTANCE_AND_DATA {
21        GtkPaperTape *papertape;
22        gpointer data;
23};
24
25enum GTK_PAPER_TAPE_VIEW_ACTION {
26        PAPER_TAPE_ZOOM_IN,
27        PAPER_TAPE_ZOOM_OUT,
28        PAPER_TAPE_ZOOM_100,
29        PAPER_TAPE_ZOOM_FIT,
30        PAPER_TAPE_ROTATE_CLOCKWISE,
31        PAPER_TAPE_ROTATE_ANTICLOCKWISE,
32        PAPER_TAPE_MIRROR_HORIZONTALLY,
33        PAPER_TAPE_MIRROR_VERTICALLY,
34        PAPER_TAPE_TOGGLE_STATUS_BAR
35};
36
37struct GTK_PAPER_TAPE_INSTANCE_AND_ACTION {
38        GtkPaperTape *papertape;
39        enum GTK_PAPER_TAPE_VIEW_ACTION action;
40};
41
42struct GTK_PAPER_TAPE_INSTANCE_AND_DATA* gtk_paper_tape_instance_and_data(GtkPaperTape *papertape, gpointer data) {
43        struct GTK_PAPER_TAPE_INSTANCE_AND_DATA* a = g_new(struct GTK_PAPER_TAPE_INSTANCE_AND_DATA, 1);
44        a->papertape = papertape;
45        a->data = data;
46        return a;
47};
48
49struct GTK_PAPER_TAPE_INSTANCE_AND_ACTION* gtk_paper_tape_instance_and_action(GtkPaperTape *papertape, enum GTK_PAPER_TAPE_VIEW_ACTION action) {
50        struct GTK_PAPER_TAPE_INSTANCE_AND_ACTION* a = g_new(struct GTK_PAPER_TAPE_INSTANCE_AND_ACTION, 1);
51        a->papertape = papertape;
52        a->action = action;
53        return a;
54};
55
56// Ereignisse:
57//gtk_paper_tape_expose // expose_event
58//gtk_paper_tape_hover // motion-notify (mausbewegungen => Meldung cursorposition => aktuelles byte hovern)
59//gtk_paper_tape_scroll // scroll-event (Scrollbewegungen => weitergeben an SCROLLfenster)
60
61// Menues (EXTERN GEBEN)
62gboolean gtk_paper_tape_export(GtkWidget *menu_widget, struct GTK_PAPER_TAPE_INSTANCE_AND_DATA* d);
63void gtk_paper_tape_set_colors(GtkWidget *menu_widget, struct GTK_PAPER_TAPE_INSTANCE_AND_DATA* d);
64
65
66// Signals
67gboolean gtk_paper_tape_export_png(GtkWidget *widget, GtkPaperTape *papertape);
68gboolean gtk_paper_tape_export_svg(GtkWidget *widget, GtkPaperTape *papertape);
69
70// Zeichenfunktionen, werden so bleiben
71gboolean gtk_paper_tape_expose(GtkPaperTape *papertape, GdkEventExpose *event, gpointer data);
72gboolean gtk_paper_tape_scroll(GtkPaperTape *papertape, GdkEventScroll *event, gpointer user_data);
73gboolean gtk_paper_tape_hover(GtkPaperTape *papertape, GdkEventMotion *event, gpointer egal);
74
75void gtk_paper_tape_change_view(GtkWidget *menu_widget, struct GTK_PAPER_TAPE_INSTANCE_AND_ACTION* d);
76
77void change_constant_gui(GtkWidget *widget, gpointer data);
78void  gtk_paper_tape_redraw(GtkPaperTape *papertape, enum GTK_PAPER_TAPE_SIZE_CHANGED changed);
79void gtk_paper_tape_change_constants(GtkWidget *menu_widget, GtkPaperTape *papertape);
80
81void gtk_paper_tape_message(GtkPaperTape *papertape, char *msg);
82
83//
84gboolean gtk_paper_tape_null_bytes_dialog(GtkWidget *menu_widget, GtkPaperTape *papertape);
85void gtk_paper_tape_scroll_to(GtkPaperTape* papertape, int byte_number);
86
87int fast_get_dpi();
88
89
90
91
92/********************************************************************
93     GLIB Class Construction
94*********************************************************************/
95
96static GtkWidgetClass *parent_class = NULL;
97
98
99/**
100 * Menu UI Generator
101 *
102 **/
103
104static const gchar *gtk_paper_tape_menu_ui_info = 
105"<ui>"
106"  <menubar name='MenuBar'>"
107"    <menu action='FileMenu'>"
108"      <menuitem action='NewWin'/>"
109"      <separator/>"
110"      <menuitem action='New'/>"
111"      <menuitem action='NewFont'/>"
112"      <separator/>"
113"      <menuitem action='Open'/>"
114"      <menuitem action='Reload'/>"
115"      <menuitem action='SetNullBytes'/>"
116"      <separator/>"
117"      <menuitem action='Save'/>"
118"      <menuitem action='SaveAs'/>"
119"      <separator/>"
120"      <menuitem action='ExportSVG'/>"
121"      <menuitem action='ExportPNG'/>"
122"      <separator/>"
123"      <menuitem action='Close'/>"
124"      <menuitem action='Quit'/>"
125"    </menu>"
126"    <menu action='EditMenu'>"
127"      <menuitem action='EnableEditor'/>"
128"      <separator/>"
129"      <menuitem action='Undo'/>"
130"      <menuitem action='Redo'/>"
131"      <separator/>"
132"      <menuitem action='Cut'/>"
133"      <menuitem action='Copy'/>"
134"      <menuitem action='Paste'/>"
135"      <menuitem action='Delete'/>"
136"      <menuitem action='Clear'/>"
137"      <separator/>"
138"      <menuitem action='SelectAll'/>"
139"      <menuitem action='SelectInvert'/>"
140"      <menuitem action='SelectNone'/>"
141"      <separator/>"
142"      <menuitem action='InsertBytes'/>"
143"      <menuitem action='InsertFont'/>"
144"    </menu>"
145"    <menu action='ViewMenu'>"
146"      <menuitem action='ZoomIn'/>"
147"      <menuitem action='ZoomOut'/>"
148"      <menuitem action='ZoomReal'/>"
149"      <menuitem action='ZoomFit'/>"
150"      <menuitem action='SetZoom'/>"
151"      <separator/>"
152"      <menuitem action='RotateClockwise'/>"
153"      <menuitem action='RotateAntiClockwise'/>"
154"      <menuitem action='MirrorHorizontally'/>"
155"      <menuitem action='MirrorVertically'/>"
156"      <separator/>"
157"      <menuitem action='EnableStatusbar'/>"
158"      <menuitem action='EnableEffects'/>"
159"      <menuitem action='SetQuality'/>"
160"    </menu>"
161"    <menu action='ColorMenu'>"
162"    </menu>"
163"    <menu action='HelpMenu'>"
164"      <menuitem action='About'/>"
165"    </menu>"
166"  </menubar>"
167"  <toolbar name='ToolBar'>"
168"    <toolitem action='New'/>"
169"    <toolitem action='NewFont'/>"
170"    <toolitem action='Open'/>"
171"    <separator/>"
172"    <toolitem action='ZoomIn'/>"
173"    <toolitem action='ZoomOut'/>"
174"    <separator expand='true'/>"
175"    <toolitem action='EnableEditor'/>"
176"  </toolbar>"
177"  <popup name='PopUp'>"
178"      <menuitem action='Cut'/>"
179"      <menuitem action='Copy'/>"
180"      <menuitem action='Insert'/>"
181"      <menuitem action='Clear'/>"
182"      <menuitem action='Delete'/>"
183"      <menuitem action='InsertByte'/>"
184"  </popup>"
185"</ui>";
186
187/** Now the ActionEntries */
188/* { name, stock_id, label, acclerator, tooltip, callback } */
189static GtkActionEntry gtk_paper_tape_menu_ui_common_entries[] = {
190        { "NewWin", NULL, "New _Window", "<Ctrl>n", "Open new papertape window", G_CALLBACK(gtk_paper_tape_open_file_dialog) },
191        { "New", GTK_STOCK_NEW, "New File", NULL, "Start with a new empty file" },
192        { "NewFont", NULL, "New Label", NULL, "Start with a new empty file and start typing a label", G_CALLBACK(gtk_paper_tape_create_label_dialog) },
193        { "Open", GTK_STOCK_OPEN, NULL, "<Ctrl>o", "Open and display an existing binary file" },
194        { "Reload", GTK_STOCK_REVERT_TO_SAVED, NULL, NULL, "Reload file from disk. Discard ALL changes" },
195        { "SetNullBytes", NULL, "Set number of null bytes", NULL, "Set number of virtual Empty bytes to display at start and end " },
196        { "Quit", GTK_STOCK_QUIT },
197       
198        { "ZoomIn", GTK_STOCK_ZOOM_IN },
199        { "ZoomOut", GTK_STOCK_ZOOM_OUT },
200        { "ZoomReal", GTK_STOCK_ZOOOM_100 },
201        { "SetZoom", GTK_STOCK_PROPERTIES, "Set Zoom level", "<ctrl>z" }
202
203        { "RotateClockwise", GTK_STOCK_ORIENTATION_LANDSCAPE, "Rotate clockwise" },
204        { "RotateAntiClockwise", GTK_STOCK_ORIENTATION_REVERSE_LANDSCAPE, "Rotate anticlockwise" },
205        { "MirrorHorizontally", GTK_STOCK_ORIENTATION_PORTRAIT, "Flip horizontally" },
206        { "MirrorVertically", GTK_STOCK_ORIENTATION_REVERSE_PORTRAIT, "Flip verticall" },
207
208        { "SetQuality", NULL, "Set display rendering quality" },
209        { "About", GTK_STOCK_ABOUT }
210};
211
212static GtkActionEntry gtk_paper_tape_menu_ui_file_entries[] = {
213        { "Save", GTK_STOCK_SAVE },
214        { "SaveAs", GKT_STOCK_SAVE_AS },
215        // Problem: G_CALLBACK(gtk_paper_tape_export), gtk_paper_tape_instance_and_data(papertape, "PNG"));
216        { "ExportSVG", NULL, "Export to PNG...", NULL, "Export complete papertape with current settings to PNG graphics", G_CALLBACK(gtk_paper_tape_export) },
217        // Problem: G_CALLBACK(gtk_paper_tape_export), gtk_paper_tape_instance_and_data(papertape, "SVG"));
218        { "ExportPNG", NULL, "Export to SVG...", NULL, "Export complete papertape with current settings to SVG graphics", G_CALLBACK(gtk_paper_tape_export) },
219        // GGF. LOESUNG: Action label bekommen und auslesen!
220        { "Close", GTK_STOCK_CLOSE, "Close", NULL, "Close opened file.", G_CALLBACK(gtk_paper_tape_close_file_dialog) },
221}
222
223static GtkActionEntry gtk_paper_tape_menu_ui_editor_entries[] = {
224        { "Undo", GTK_STOCK_UNDO },
225        { "Redo", GTK_STOCK_REDO },
226        { "Cut", GTK_STOCK_CUT },
227        { "Copy", GTK_STOCK_COPY },
228        { "Paste", GTK_STOCK_PASTE },
229        { "Delete", GTK_STOCK_DELETE },
230        { "Clear", NULL, "Clear", NULL, "Clear all selected bytes to Null bytes (0x00)" },
231        { "SelectAll", GTK_STOCK_SELECT_ALL },
232        { "SelectInvert", NULL, "Invert selection", NULL, "Invert current selection" },
233        { "SelectNone", NULL, "Remove selection", NULL, "Select nothing" },
234        { "InsertBytes", GTK_STOCK_ADD, "Insert blank bytes", NULL, "Insert a number of blank bytes after the current position" },
235        { "InsertFont", GTK_STOCK_ADD, "Insert label", NULL, "Insert a label (generated paper tape font)" },
236};
237
238/* { name, stock_id, label, accelerator, tooltip, callback, is_active } */
239static GtkToggleActionEntry gtk_paper_tape_menu_ui_toggle_entries[] = {
240        { "EnableEditor", GTK_STOCK_EDIT, "Enable editing", NULL, "Don't treat paper tape file as read only, but change bits and bytes interactively" };
241        { "ZoomFit", GTK_STOCK_ZOOM_FIT },
242        { "EnableStatusbar", NULL, "Enable Statusbar" },
243        { "EnableEffects", NULL, "Enable Effects" },
244};
Note: See TracBrowser for help on using the repository browser.
© 2008 - 2013 technikum29 • Sven Köppel • Some rights reserved
Powered by Trac
Expect where otherwise noted, content on this site is licensed under a Creative Commons 3.0 License