Root/gui_style.c

Source at commit a9ed5b30aa457704a4c0c912367bfe8c57db8d03 created 3 years 4 months ago.
By Werner Almesberger, fped.1: update for new options; fix typo; bump date
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
22GdkGC *gc_bg, *gc_bg_error;
23GdkGC *gc_drag;
24GdkGC *gc_highlight;
25GdkGC *gc_active_frame;
26GdkGC *gc_vec[mode_n];
27GdkGC *gc_obj[mode_n];
28GdkGC *gc_pad[mode_n];
29GdkGC *gc_pad_bare[mode_n];
30GdkGC *gc_pad_trace[mode_n];
31GdkGC *gc_pad_mask[mode_n];
32GdkGC *gc_ptext[mode_n];
33GdkGC *gc_rim[mode_n];
34GdkGC *gc_hole[mode_n];
35GdkGC *gc_meas[mode_n];
36GdkGC *gc_frame[mode_n];
37
38PangoFontDescription *item_list_font;
39
40
41static 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
54static 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
63void 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
90void gui_cleanup_style(void)
91{
92    pango_font_description_free(item_list_font);
93}
94

Archive Download this file

Branches:
master



interactive