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