1 | #include "gtk/gtk.h" |
---|
2 | |
---|
3 | #include <locale.h> |
---|
4 | #include <stdlib.h> |
---|
5 | #include <string.h> |
---|
6 | |
---|
7 | PangoFontDescription *fontlucidagranderegular11; |
---|
8 | GdkRGBA WindowBackgroundColor; |
---|
9 | |
---|
10 | GtkWidget *AnzeigeVerlaufWindow; |
---|
11 | GtkWidget *AnzeigeVerlaufWindowFixedLayout; |
---|
12 | GtkWidget *Label_AnzeigeVerlaufWindowWorking; |
---|
13 | GtkWidget *DArea_AnzeigeVerlaufWindowDecoration; |
---|
14 | |
---|
15 | long AnzeigeIntervall; |
---|
16 | |
---|
17 | static gboolean anzeigeverlaufwindowexposeeventcallback (GtkWidget *pwidget, GdkEventExpose *pevent, gpointer pdata) |
---|
18 | { |
---|
19 | cairo_t *lcairo_t; |
---|
20 | |
---|
21 | lcairo_t = gdk_cairo_create (gtk_widget_get_window (GTK_WIDGET(pwidget))); |
---|
22 | |
---|
23 | cairo_set_source_rgb (lcairo_t, 0.0, 0.0, 0.0); |
---|
24 | cairo_move_to (lcairo_t, 1, 0); cairo_line_to (lcairo_t, 1, 100); |
---|
25 | cairo_stroke (lcairo_t); |
---|
26 | |
---|
27 | cairo_set_source_rgb (lcairo_t, 1.0, 1.0, 1.0); |
---|
28 | cairo_move_to (lcairo_t, 1, 99); cairo_line_to (lcairo_t, 300, 99); |
---|
29 | cairo_stroke (lcairo_t); |
---|
30 | |
---|
31 | cairo_set_source_rgb (lcairo_t, 0.3, 0.3, 0.3); |
---|
32 | cairo_move_to (lcairo_t, 2, 0); cairo_line_to (lcairo_t, 2, 99); |
---|
33 | cairo_stroke (lcairo_t); |
---|
34 | |
---|
35 | cairo_set_source_rgb (lcairo_t, 0.9, 0.9, 0.9); |
---|
36 | cairo_move_to (lcairo_t, 2, 98); cairo_line_to (lcairo_t, 300, 98); |
---|
37 | cairo_stroke (lcairo_t); |
---|
38 | |
---|
39 | cairo_set_source_rgb (lcairo_t, 0.6, 0.6, 0.6); |
---|
40 | cairo_move_to (lcairo_t, 3, 0); cairo_line_to (lcairo_t, 3, 98); |
---|
41 | cairo_stroke (lcairo_t); |
---|
42 | |
---|
43 | cairo_set_source_rgb (lcairo_t, 209.0/255.0, 210.0/255.0, 218.0/255.0); |
---|
44 | cairo_move_to (lcairo_t, 3, 97); cairo_line_to (lcairo_t, 300, 97); |
---|
45 | cairo_stroke (lcairo_t); |
---|
46 | |
---|
47 | cairo_set_source_rgb (lcairo_t, 209.0/255.0, 210.0/255.0, 218.0/255.0); |
---|
48 | cairo_move_to (lcairo_t, 4, 0); cairo_line_to (lcairo_t, 4, 97); |
---|
49 | cairo_stroke (lcairo_t); |
---|
50 | |
---|
51 | cairo_set_source_rgb (lcairo_t, 0.0, 0.0, 0.0); |
---|
52 | cairo_move_to (lcairo_t, 0, 1); cairo_line_to (lcairo_t, 300, 1); |
---|
53 | cairo_stroke (lcairo_t); |
---|
54 | |
---|
55 | cairo_set_source_rgb (lcairo_t, 1.0, 1.0, 1.0); |
---|
56 | cairo_move_to (lcairo_t, 299, 1); cairo_line_to (lcairo_t, 299, 100); |
---|
57 | cairo_stroke (lcairo_t); |
---|
58 | |
---|
59 | cairo_set_source_rgb (lcairo_t, 0.3, 0.3, 0.3); |
---|
60 | cairo_move_to (lcairo_t, 1, 2); cairo_line_to (lcairo_t, 299, 2); |
---|
61 | cairo_stroke (lcairo_t); |
---|
62 | |
---|
63 | cairo_set_source_rgb (lcairo_t, 0.9, 0.9, 0.9); |
---|
64 | cairo_move_to (lcairo_t, 298, 2); cairo_line_to (lcairo_t, 298, 99); |
---|
65 | cairo_stroke (lcairo_t); |
---|
66 | |
---|
67 | cairo_set_source_rgb (lcairo_t, 0.6, 0.6, 0.6); |
---|
68 | cairo_move_to (lcairo_t, 2, 3); cairo_line_to (lcairo_t, 298, 3); |
---|
69 | cairo_stroke (lcairo_t); |
---|
70 | |
---|
71 | cairo_set_source_rgb (lcairo_t, 209.0/255.0, 210.0/255.0, 218.0/255.0); |
---|
72 | cairo_move_to (lcairo_t, 297, 3); cairo_line_to (lcairo_t, 297, 99); |
---|
73 | cairo_stroke (lcairo_t); |
---|
74 | |
---|
75 | cairo_set_source_rgb (lcairo_t, 209.0/255.0, 210.0/255.0, 218.0/255.0); |
---|
76 | cairo_move_to (lcairo_t, 3, 4); cairo_line_to (lcairo_t, 297, 4); |
---|
77 | cairo_stroke (lcairo_t); |
---|
78 | |
---|
79 | cairo_destroy (lcairo_t); |
---|
80 | |
---|
81 | return TRUE; |
---|
82 | } |
---|
83 | |
---|
84 | static void AnzeigeVerlaufAnfang (unsigned int psleep) |
---|
85 | { |
---|
86 | AnzeigeVerlaufWindow = gtk_window_new (GTK_WINDOW_TOPLEVEL); |
---|
87 | gtk_widget_override_background_color (AnzeigeVerlaufWindow, GTK_STATE_FLAG_NORMAL, &WindowBackgroundColor); |
---|
88 | |
---|
89 | gtk_window_move (GTK_WINDOW (AnzeigeVerlaufWindow), 100, 100); |
---|
90 | gtk_window_resize (GTK_WINDOW(AnzeigeVerlaufWindow), 300, 100); |
---|
91 | gtk_window_set_decorated (GTK_WINDOW (AnzeigeVerlaufWindow), FALSE); |
---|
92 | |
---|
93 | AnzeigeVerlaufWindowFixedLayout = gtk_fixed_new (); |
---|
94 | |
---|
95 | DArea_AnzeigeVerlaufWindowDecoration = gtk_drawing_area_new (); |
---|
96 | gtk_widget_set_size_request(DArea_AnzeigeVerlaufWindowDecoration, 300, 100); |
---|
97 | gtk_fixed_put (GTK_FIXED(AnzeigeVerlaufWindowFixedLayout), DArea_AnzeigeVerlaufWindowDecoration, 0, 0); |
---|
98 | g_signal_connect (G_OBJECT (DArea_AnzeigeVerlaufWindowDecoration), "draw", G_CALLBACK (anzeigeverlaufwindowexposeeventcallback), NULL); |
---|
99 | |
---|
100 | Label_AnzeigeVerlaufWindowWorking = gtk_label_new (""); |
---|
101 | gtk_widget_set_size_request (Label_AnzeigeVerlaufWindowWorking, 300, 0); |
---|
102 | gtk_misc_set_alignment ((GtkMisc *)Label_AnzeigeVerlaufWindowWorking, 0.5, 0.0); |
---|
103 | gtk_fixed_put (GTK_FIXED (AnzeigeVerlaufWindowFixedLayout), Label_AnzeigeVerlaufWindowWorking, 0, 45); |
---|
104 | |
---|
105 | gtk_container_add (GTK_CONTAINER(AnzeigeVerlaufWindow), AnzeigeVerlaufWindowFixedLayout); |
---|
106 | |
---|
107 | gtk_widget_show_all (AnzeigeVerlaufWindow); |
---|
108 | |
---|
109 | gtk_label_set_text (GTK_LABEL (Label_AnzeigeVerlaufWindowWorking), ""); |
---|
110 | |
---|
111 | usleep (psleep); |
---|
112 | while (gtk_events_pending ()) |
---|
113 | gtk_main_iteration (); |
---|
114 | |
---|
115 | AnzeigeIntervall = 0; |
---|
116 | } |
---|
117 | |
---|
118 | static void AnzeigeVerlaufAnzeige (char *panzeigetext, unsigned int psleep, long panzeigeintervall) |
---|
119 | { |
---|
120 | AnzeigeIntervall++; |
---|
121 | |
---|
122 | if (panzeigeintervall == AnzeigeIntervall) |
---|
123 | { |
---|
124 | gtk_label_set_text (GTK_LABEL (Label_AnzeigeVerlaufWindowWorking), panzeigetext); |
---|
125 | |
---|
126 | usleep (psleep); |
---|
127 | while (gtk_events_pending ()) |
---|
128 | gtk_main_iteration (); |
---|
129 | |
---|
130 | AnzeigeIntervall = 0; |
---|
131 | } |
---|
132 | } |
---|
133 | |
---|
134 | static void AnzeigeVerlaufEnde () |
---|
135 | { |
---|
136 | gtk_widget_destroy (AnzeigeVerlaufWindow); |
---|
137 | } |
---|
138 | |
---|
139 | static void InitiateEnvironment (int argc, char **argv) |
---|
140 | { |
---|
141 | char localbuffer[10005]; |
---|
142 | |
---|
143 | strcpy (localbuffer, argv[0]); |
---|
144 | |
---|
145 | while (localbuffer[strlen(localbuffer)-1] != '/') |
---|
146 | localbuffer[strlen(localbuffer)-1] = '\000'; |
---|
147 | |
---|
148 | chdir (localbuffer); |
---|
149 | |
---|
150 | gtk_init (&argc, &argv); |
---|
151 | g_object_set (gtk_settings_get_default (), "gtk-font-name", "Lucida Grande 8.5", NULL); |
---|
152 | |
---|
153 | setlocale (LC_NUMERIC, "C"); |
---|
154 | |
---|
155 | fontlucidagranderegular11 = pango_font_description_from_string ("Lucida Grande 7.5"); |
---|
156 | |
---|
157 | WindowBackgroundColor.red = 0.823529411764706; |
---|
158 | WindowBackgroundColor.green = 0.823529411764706; |
---|
159 | WindowBackgroundColor.blue = 0.823529411764706; |
---|
160 | WindowBackgroundColor.alpha = 1.0; |
---|
161 | } |
---|
162 | |
---|
163 | int main (int argc, char **argv) |
---|
164 | { |
---|
165 | long i; |
---|
166 | char lzwbuffer[1001]; |
---|
167 | |
---|
168 | InitiateEnvironment (argc, argv); |
---|
169 | |
---|
170 | AnzeigeVerlaufAnfang (1); |
---|
171 | |
---|
172 | AnzeigeVerlaufAnzeige ("einfacheintext", 25000, 1); |
---|
173 | |
---|
174 | for (i=1; i<=1000; i++) |
---|
175 | { |
---|
176 | sprintf (lzwbuffer, "Durchlauf : %ld", i); |
---|
177 | AnzeigeVerlaufAnzeige (lzwbuffer, 25000, 1); |
---|
178 | } |
---|
179 | |
---|
180 | usleep (5000000); |
---|
181 | |
---|
182 | AnzeigeVerlaufEnde (); |
---|
183 | |
---|
184 | return 0; |
---|
185 | } |
---|