gui_style.c 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. #include <gtk/gtk.h>
  13. #include "inst.h"
  14. #include "gui_util.h"
  15. #include "gui.h"
  16. #include "gui_style.h"
  17. GdkGC *gc_bg, *gc_bg_error;
  18. GdkGC *gc_drag;
  19. GdkGC *gc_highlight;
  20. GdkGC *gc_active_frame;
  21. GdkGC *gc_vec[mode_n];
  22. GdkGC *gc_obj[mode_n];
  23. GdkGC *gc_pad[mode_n];
  24. GdkGC *gc_pad_bare[mode_n];
  25. GdkGC *gc_pad_trace[mode_n];
  26. GdkGC *gc_pad_mask[mode_n];
  27. GdkGC *gc_ptext[mode_n];
  28. GdkGC *gc_rim[mode_n];
  29. GdkGC *gc_hole[mode_n];
  30. GdkGC *gc_meas[mode_n];
  31. GdkGC *gc_frame[mode_n];
  32. PangoFontDescription *item_list_font;
  33. static GdkGC *gc(const char *spec, int width)
  34. {
  35. GdkGCValues gc_values = {
  36. .background = get_color("black"),
  37. .foreground = get_color(spec),
  38. .line_width = width,
  39. };
  40. return gdk_gc_new_with_values(root->window, &gc_values,
  41. GDK_GC_FOREGROUND | GDK_GC_BACKGROUND | GDK_GC_LINE_WIDTH);
  42. }
  43. static void style(GdkGC *gcs[mode_n],
  44. const char *in, const char *act, const char *sel, int width)
  45. {
  46. gcs[mode_inactive] = gc(in, width);
  47. gcs[mode_active] = gc(act, width);
  48. gcs[mode_selected] = gc(sel, 2*width);
  49. }
  50. void gui_setup_style(GdkDrawable *drawable)
  51. {
  52. gc_bg = gc("#000000", 0);
  53. gc_bg_error = gc("#000040", 0);
  54. gc_drag = gc("#ffffff", 2);
  55. /* inactive active selected width */
  56. style(gc_vec, "#202000", "#b0b050", "#ffff80", 1);
  57. style(gc_obj, "#006060", "#00ffff", "#ffff80", 1);
  58. style(gc_pad, "#400000", "#ff0000", "#ffff80", 1);
  59. style(gc_pad_bare, "#402000", "#ff6000", "#ffff80", 1);
  60. style(gc_pad_trace, "#304000", "#80c000", "#ffff80", 1);
  61. style(gc_pad_mask, "#000040", "#0000ff", "#ffff80", 2);
  62. style(gc_ptext, "#404040", "#ffffff", "#ffffff", 1);
  63. style(gc_hole, "#000000", "#000000", "#000000", 0);
  64. style(gc_rim, "#303030", "#606060", "#ffff80", 3);
  65. style(gc_meas, "#280040", "#ff00ff", "#ffff80", 1);
  66. style(gc_frame, "#005000", "#009000", "#ffff80", 1);
  67. gc_active_frame = gc("#00ff00", 2);
  68. // gc_highlight = gc("#ff8020", 2);
  69. gc_highlight = gc("#ff90d0", 2);
  70. gc_frame[mode_hover] = gc_vec[mode_hover] = gc("#c00000", 2);
  71. item_list_font = pango_font_description_from_string(ITEM_LIST_FONT);
  72. }
  73. void gui_cleanup_style(void)
  74. {
  75. pango_font_description_free(item_list_font);
  76. }