1 | #include "gtk/gtk.h" |
---|
2 | |
---|
3 | #include <stdlib.h> |
---|
4 | #include <string.h> |
---|
5 | |
---|
6 | /************************************************************************************ |
---|
7 | CSS Konstanten |
---|
8 | ************************************************************************************/ |
---|
9 | char gwindowdecoration[] = "window {background-color: rgb(210, 210, 210); border-top: 3px ridge #555555; border-left: 3px ridge #555555; border-bottom: 3px ridge #999999; border-right: 3px ridge #999999;}"; |
---|
10 | |
---|
11 | char gentrydecoration[] = "window entry {background-color: white; border-top: 1px solid #000000; border-left: 1px solid #000000; border-bottom: 1px solid #aaaaaa; border-right: 1px solid #aaaaaa;}"; |
---|
12 | |
---|
13 | char ggreyscalebuttonnotchoosen[] = "window label {background: linear-gradient(white, rgb(170, 170, 170)); border-radius: 3px; border: 1px solid #000000;}"; |
---|
14 | char ggreyscalebuttonchoosen[] = "window label {background: linear-gradient(rgb(170, 170, 170), white); border-radius: 3px; border: 1px solid #000000;}"; |
---|
15 | |
---|
16 | /************************************************************************************ |
---|
17 | Window Prototyp |
---|
18 | ************************************************************************************/ |
---|
19 | GtkWidget *Window_Prototyp; |
---|
20 | GtkCssProvider *WindowCssProvider_Prototyp = NULL; |
---|
21 | |
---|
22 | GtkWidget *FixedLayout_Prototyp; |
---|
23 | |
---|
24 | GtkWidget *Label_PrototypUeberschrift; |
---|
25 | |
---|
26 | GtkWidget *LEdit_PrototypEntry; |
---|
27 | |
---|
28 | GtkWidget *PBut_PrototypAbbrechen; |
---|
29 | GtkWidget *PButLabel_PrototypAbbrechen; |
---|
30 | GtkCssProvider *PButLabelCssProvider_PrototypAbbrechen; |
---|
31 | |
---|
32 | static void draganddropcallback (GtkWidget *pwidget, GdkEvent *pevent, gpointer pdata) |
---|
33 | { |
---|
34 | gtk_window_begin_move_drag(GTK_WINDOW(gtk_widget_get_toplevel(pwidget)), pevent->button.button, pevent->button.x_root, pevent->button.y_root, pevent->button.time); |
---|
35 | } |
---|
36 | |
---|
37 | static void Prototypdoit (GtkWidget *pwidget, GdkEvent *pevent, gpointer pdata) |
---|
38 | { |
---|
39 | if (pwidget == PBut_PrototypAbbrechen) |
---|
40 | { |
---|
41 | gtk_widget_destroy (Window_Prototyp); |
---|
42 | gtk_main_quit (); |
---|
43 | return; |
---|
44 | } |
---|
45 | } |
---|
46 | |
---|
47 | static void Prototypdoenter (GtkWidget *pwidget, GdkEvent *pevent, gpointer pdata) |
---|
48 | { |
---|
49 | if (pwidget == PBut_PrototypAbbrechen) |
---|
50 | { |
---|
51 | gtk_style_context_remove_provider (gtk_widget_get_style_context (PButLabel_PrototypAbbrechen), GTK_STYLE_PROVIDER (PButLabelCssProvider_PrototypAbbrechen)); |
---|
52 | gtk_css_provider_load_from_data (PButLabelCssProvider_PrototypAbbrechen, ggreyscalebuttonchoosen, -1, NULL); |
---|
53 | gtk_style_context_add_provider (gtk_widget_get_style_context (PButLabel_PrototypAbbrechen), GTK_STYLE_PROVIDER (PButLabelCssProvider_PrototypAbbrechen), GTK_STYLE_PROVIDER_PRIORITY_USER); |
---|
54 | return; |
---|
55 | } |
---|
56 | } |
---|
57 | |
---|
58 | static void Prototypdoleave (GtkWidget *pwidget, GdkEvent *pevent, gpointer pdata) |
---|
59 | { |
---|
60 | if (pwidget == PBut_PrototypAbbrechen) |
---|
61 | { |
---|
62 | gtk_style_context_remove_provider (gtk_widget_get_style_context (PButLabel_PrototypAbbrechen), GTK_STYLE_PROVIDER (PButLabelCssProvider_PrototypAbbrechen)); |
---|
63 | gtk_css_provider_load_from_data (PButLabelCssProvider_PrototypAbbrechen, ggreyscalebuttonnotchoosen, -1, NULL); |
---|
64 | gtk_style_context_add_provider (gtk_widget_get_style_context (PButLabel_PrototypAbbrechen), GTK_STYLE_PROVIDER (PButLabelCssProvider_PrototypAbbrechen), GTK_STYLE_PROVIDER_PRIORITY_USER); |
---|
65 | return; |
---|
66 | } |
---|
67 | } |
---|
68 | |
---|
69 | int main (int argc, char *argv[]) |
---|
70 | { |
---|
71 | gtk_init (&argc, &argv); |
---|
72 | |
---|
73 | g_object_set (gtk_settings_get_default (), "gtk-font-name", "Helvetica 12", NULL); |
---|
74 | |
---|
75 | Window_Prototyp = gtk_window_new (GTK_WINDOW_TOPLEVEL); |
---|
76 | gtk_window_move (GTK_WINDOW (Window_Prototyp), 50, 50); |
---|
77 | gtk_window_resize (GTK_WINDOW(Window_Prototyp), 500, 500); |
---|
78 | gtk_widget_add_events (Window_Prototyp, GDK_BUTTON_PRESS_MASK); |
---|
79 | g_signal_connect (Window_Prototyp, "button-press-event", G_CALLBACK(draganddropcallback), NULL); |
---|
80 | gtk_window_set_decorated (GTK_WINDOW (Window_Prototyp), FALSE); |
---|
81 | WindowCssProvider_Prototyp = gtk_css_provider_new (); |
---|
82 | gtk_css_provider_load_from_data (WindowCssProvider_Prototyp, gwindowdecoration, -1, NULL); |
---|
83 | gtk_style_context_add_provider (gtk_widget_get_style_context (Window_Prototyp), GTK_STYLE_PROVIDER (WindowCssProvider_Prototyp), GTK_STYLE_PROVIDER_PRIORITY_USER); |
---|
84 | g_object_unref (WindowCssProvider_Prototyp); |
---|
85 | |
---|
86 | FixedLayout_Prototyp = gtk_fixed_new (); |
---|
87 | |
---|
88 | Label_PrototypUeberschrift = gtk_label_new ("Überschrift"); |
---|
89 | gtk_widget_set_size_request (Label_PrototypUeberschrift, 480, 0); |
---|
90 | gtk_fixed_put (GTK_FIXED (FixedLayout_Prototyp), Label_PrototypUeberschrift, 10, 40); |
---|
91 | |
---|
92 | // LEdit_PrototypEntry = gtk_entry_new (); |
---|
93 | // gtk_fixed_put (GTK_FIXED (FixedLayout_Prototyp), LEdit_PrototypEntry, 150, 80); |
---|
94 | |
---|
95 | PBut_PrototypAbbrechen = gtk_event_box_new (); |
---|
96 | PButLabel_PrototypAbbrechen = gtk_label_new ("Abbrechen"); |
---|
97 | gtk_widget_set_size_request (PButLabel_PrototypAbbrechen, 152, 22); |
---|
98 | PButLabelCssProvider_PrototypAbbrechen = gtk_css_provider_new (); |
---|
99 | gtk_css_provider_load_from_data (PButLabelCssProvider_PrototypAbbrechen, ggreyscalebuttonnotchoosen, -1, NULL); |
---|
100 | gtk_style_context_add_provider (gtk_widget_get_style_context (PButLabel_PrototypAbbrechen), GTK_STYLE_PROVIDER (PButLabelCssProvider_PrototypAbbrechen), GTK_STYLE_PROVIDER_PRIORITY_USER); |
---|
101 | gtk_container_add (GTK_CONTAINER (PBut_PrototypAbbrechen), PButLabel_PrototypAbbrechen); |
---|
102 | gtk_fixed_put (GTK_FIXED(FixedLayout_Prototyp), PBut_PrototypAbbrechen, 175, 400); |
---|
103 | g_signal_connect (G_OBJECT (PBut_PrototypAbbrechen), "button-press-event", G_CALLBACK (Prototypdoit), NULL); |
---|
104 | g_signal_connect (G_OBJECT (PBut_PrototypAbbrechen), "enter-notify-event", G_CALLBACK (Prototypdoenter), NULL); |
---|
105 | g_signal_connect (G_OBJECT (PBut_PrototypAbbrechen), "leave-notify-event", G_CALLBACK (Prototypdoleave), NULL); |
---|
106 | |
---|
107 | gtk_container_add (GTK_CONTAINER(Window_Prototyp), FixedLayout_Prototyp); |
---|
108 | |
---|
109 | gtk_widget_show_all (Window_Prototyp); |
---|
110 | |
---|
111 | gtk_main (); |
---|
112 | |
---|
113 | return 0; |
---|
114 | } |
---|