Root/
Source at commit a3b3ed4925927211fbb2a114cf183678bfc30346 created 13 years 5 months ago. By Xiangfu Liu, use the new version rules. | |
---|---|
1 | /* * gui_style.c - GUI, style definitions |
2 | * |
3 | * Written 2009, 2010 by Werner Almesberger |
4 | * Copyright 2009, 2010 by Werner Almesberger |
5 | * |
6 | * This program is free software; you can redistribute it and/or modify |
7 | * it under the terms of the GNU General Public License as published by |
8 | * the Free Software Foundation; either version 2 of the License, or |
9 | * (at your option) any later version. |
10 | */ |
11 | |
12 | |
13 | #include <gtk/gtk.h> |
14 | |
15 | #include "inst.h" |
16 | #include "gui_util.h" |
17 | #include "gui.h" |
18 | #include "gui_style.h" |
19 | |
20 | |
21 | GdkGC *gc_bg, *gc_bg_error; |
22 | GdkGC *gc_drag; |
23 | GdkGC *gc_highlight; |
24 | GdkGC *gc_active_frame; |
25 | GdkGC *gc_vec[mode_n]; |
26 | GdkGC *gc_obj[mode_n]; |
27 | GdkGC *gc_pad[mode_n]; |
28 | GdkGC *gc_pad_bare[mode_n]; |
29 | GdkGC *gc_pad_mask[mode_n]; |
30 | GdkGC *gc_ptext[mode_n]; |
31 | GdkGC *gc_rim[mode_n]; |
32 | GdkGC *gc_hole[mode_n]; |
33 | GdkGC *gc_meas[mode_n]; |
34 | GdkGC *gc_frame[mode_n]; |
35 | |
36 | PangoFontDescription *item_list_font; |
37 | |
38 | |
39 | static GdkGC *gc(const char *spec, int width) |
40 | { |
41 | GdkGCValues gc_values = { |
42 | .background = get_color("black"), |
43 | .foreground = get_color(spec), |
44 | .line_width = width, |
45 | }; |
46 | |
47 | return gdk_gc_new_with_values(root->window, &gc_values, |
48 | GDK_GC_FOREGROUND | GDK_GC_BACKGROUND | GDK_GC_LINE_WIDTH); |
49 | } |
50 | |
51 | |
52 | static void style(GdkGC *gcs[mode_n], |
53 | const char *in, const char *act, const char *sel, int width) |
54 | { |
55 | gcs[mode_inactive] = gc(in, width); |
56 | gcs[mode_active] = gc(act, width); |
57 | gcs[mode_selected] = gc(sel, 2*width); |
58 | } |
59 | |
60 | |
61 | void gui_setup_style(GdkDrawable *drawable) |
62 | { |
63 | gc_bg = gc("#000000", 0); |
64 | gc_bg_error = gc("#000040", 0); |
65 | gc_drag = gc("#ffffff", 2); |
66 | /* inactive active selected width */ |
67 | style(gc_vec, "#202000", "#b0b050", "#ffff80", 1); |
68 | style(gc_obj, "#006060", "#00ffff", "#ffff80", 1); |
69 | style(gc_pad, "#400000", "#ff0000", "#ffff80", 1); |
70 | style(gc_pad_bare, "#402000", "#ff6000", "#ffff80", 1); |
71 | style(gc_pad_mask, "#000040", "#0000ff", "#ffff80", 2); |
72 | style(gc_ptext, "#404040", "#ffffff", "#ffffff", 1); |
73 | style(gc_hole, "#000000", "#000000", "#000000", 0); |
74 | style(gc_rim, "#303030", "#606060", "#ffff80", 3); |
75 | style(gc_meas, "#280040", "#ff00ff", "#ffff80", 1); |
76 | style(gc_frame, "#005000", "#009000", "#ffff80", 1); |
77 | |
78 | gc_active_frame = gc("#00ff00", 2); |
79 | // gc_highlight = gc("#ff8020", 2); |
80 | gc_highlight = gc("#ff90d0", 2); |
81 | gc_frame[mode_hover] = gc_vec[mode_hover] = gc("#c00000", 2); |
82 | |
83 | item_list_font = pango_font_description_from_string(ITEM_LIST_FONT); |
84 | } |
85 | |
86 | |
87 | void gui_cleanup_style(void) |
88 | { |
89 | pango_font_description_free(item_list_font); |
90 | } |
91 |
Branches:
master