theme.cpp (6593B)
1 // Copyright (c) 2003 - 2009 Anselm R Garbe <anselm@garbe.us> 2 // See LICENSE for license details. 3 4 #include "theme.h" 5 6 #include "logger.h" 7 #include "monitor.h" 8 #include "xcore.h" 9 10 Theme::Theme() { 11 } 12 13 Theme::~Theme() { 14 } 15 16 unsigned long Theme::allocateColor(string name, Colormap cmap) { 17 18 XColor color; 19 20 if (!XCORE->allocNamedColor(cmap, name, &color)) 21 { 22 Logger::instance()->error("cannot allocate color '" 23 + name + "'", true); 24 // exits WMI 25 } 26 27 return color.pixel; 28 } 29 30 void Theme::initTheme(MSettings *ts, Colormap cmap) { 31 32 BAR_BACKGROUND = allocateColor(Util::get(ts, "color.bar.background"), cmap); 33 BAR_TEXT = allocateColor(Util::get(ts, "color.bar.text"), cmap); 34 BAR_SHINE = allocateColor(Util::get(ts, "color.bar.shine"), cmap); 35 BAR_SHADOW = allocateColor(Util::get(ts, "color.bar.shadow"), cmap); 36 37 METER_BACKGROUND = allocateColor(Util::get(ts, "color.meter.background"), cmap); 38 METER_FIGURE_HIGH = allocateColor(Util::get(ts, "color.meter.figure.high"), cmap); 39 METER_FIGURE_NORMAL = allocateColor(Util::get(ts, "color.meter.figure.normal"), cmap); 40 METER_FIGURE_LOW = allocateColor(Util::get(ts, "color.meter.figure.low"), cmap); 41 METER_BORDER_SHINE= allocateColor(Util::get(ts, "color.meter.border.shine"), cmap); 42 METER_BORDER_SHADOW= allocateColor(Util::get(ts, "color.meter.border.shadow"), cmap); 43 44 FOCUSREQ_BACKGROUND = allocateColor(Util::get(ts, "color.focusreq.background"), cmap); 45 FOCUSREQ_TEXT = allocateColor(Util::get(ts, "color.focusreq.text"), cmap); 46 FOCUSREQ_SHINE = allocateColor(Util::get(ts, "color.focusreq.shine"), cmap); 47 FOCUSREQ_SHADOW = allocateColor(Util::get(ts, "color.focusreq.shadow"), cmap); 48 49 TILED_SHINE_FOCUSSED = allocateColor(Util::get(ts, "color.tiled.shine.focussed"), cmap); 50 TILED_SHADOW_FOCUSSED = allocateColor(Util::get(ts, "color.tiled.shadow.focussed"), cmap); 51 TILED_SHINE_NORMAL = allocateColor(Util::get(ts, "color.tiled.shine.normal"), cmap); 52 TILED_SHADOW_NORMAL = allocateColor(Util::get(ts, "color.tiled.shadow.normal"), cmap); 53 54 BUTTON_BACKGROUND_NORMAL = 55 allocateColor(Util::get(ts, "color.button.background.normal"), cmap); 56 BUTTON_BACKGROUND_PRESSED = 57 allocateColor(Util::get(ts, "color.button.background.pressed"), cmap); 58 BUTTON_SHINE_BORDER_NORMAL = 59 allocateColor(Util::get(ts, "color.button.border.shine.normal"), cmap); 60 BUTTON_SHINE_BORDER_PRESSED = 61 allocateColor(Util::get(ts, "color.button.border.shine.pressed"), cmap); 62 BUTTON_SHADOW_BORDER_NORMAL = 63 allocateColor(Util::get(ts, "color.button.border.shadow.normal"), cmap); 64 BUTTON_SHADOW_BORDER_PRESSED = 65 allocateColor(Util::get(ts, "color.button.border.shadow.pressed"), cmap); 66 BUTTON_SHINE_FIGURE_NORMAL = 67 allocateColor(Util::get(ts, "color.button.figure.shine.normal"), cmap); 68 BUTTON_SHINE_FIGURE_PRESSED = 69 allocateColor(Util::get(ts, "color.button.figure.shine.pressed"), cmap); 70 BUTTON_SHADOW_FIGURE_NORMAL = 71 allocateColor(Util::get(ts, "color.button.figure.shadow.normal"), cmap); 72 BUTTON_SHADOW_FIGURE_PRESSED = 73 allocateColor(Util::get(ts, "color.button.figure.shadow.pressed"), cmap); 74 75 FRAME_BACKGROUND_NORMAL = 76 allocateColor(Util::get(ts, "color.frame.background.normal"), cmap); 77 FRAME_BACKGROUND_FOCUSSED = 78 allocateColor(Util::get(ts, "color.frame.background.focussed"), cmap); 79 FRAME_SHINE_NORMAL = 80 allocateColor(Util::get(ts, "color.frame.shine.normal"), cmap); 81 FRAME_SHINE_FOCUSSED = 82 allocateColor(Util::get(ts, "color.frame.shine.focussed"), cmap); 83 FRAME_SHADOW_NORMAL = 84 allocateColor(Util::get(ts, "color.frame.shadow.normal"), cmap); 85 FRAME_SHADOW_FOCUSSED = 86 allocateColor(Util::get(ts, "color.frame.shadow.focussed"), cmap); 87 FRAME_PSEUDO = 88 allocateColor(Util::get(ts, "color.frame.pseudo"), cmap); 89 90 LABEL_BACKGROUND_NORMAL = 91 allocateColor(Util::get(ts, "color.label.background.normal"), cmap); 92 LABEL_BACKGROUND_FOCUSSED = 93 allocateColor(Util::get(ts, "color.label.background.focussed"), cmap); 94 LABEL_TEXT_NORMAL = 95 allocateColor(Util::get(ts, "color.label.text.normal"), cmap); 96 LABEL_TEXT_FOCUSSED = 97 allocateColor(Util::get(ts, "color.label.text.focussed"), cmap); 98 LABEL_SHINE_NORMAL = 99 allocateColor(Util::get(ts, "color.label.shine.normal"), cmap); 100 LABEL_SHINE_FOCUSSED = 101 allocateColor(Util::get(ts, "color.label.shine.focussed"), cmap); 102 LABEL_SHADOW_NORMAL = 103 allocateColor(Util::get(ts, "color.label.shadow.normal"), cmap); 104 LABEL_SHADOW_FOCUSSED = 105 allocateColor(Util::get(ts, "color.label.shadow.focussed"), cmap); 106 107 TAB_BACKGROUND_ACTIVE_NORMAL = 108 allocateColor(Util::get(ts, "color.tab.background.active.normal"), cmap); 109 TAB_BACKGROUND_INACTIVE_NORMAL = 110 allocateColor(Util::get(ts, "color.tab.background.inactive.normal"), cmap); 111 TAB_BACKGROUND_ACTIVE_FOCUSSED = 112 allocateColor(Util::get(ts, "color.tab.background.active.focussed"), cmap); 113 TAB_BACKGROUND_INACTIVE_FOCUSSED = 114 allocateColor(Util::get(ts, "color.tab.background.inactive.focussed"), cmap); 115 TAB_TEXT_ACTIVE_NORMAL = 116 allocateColor(Util::get(ts, "color.tab.text.active.normal"), cmap); 117 TAB_TEXT_INACTIVE_NORMAL = 118 allocateColor(Util::get(ts, "color.tab.text.inactive.normal"), cmap); 119 TAB_TEXT_ACTIVE_FOCUSSED = 120 allocateColor(Util::get(ts, "color.tab.text.active.focussed"), cmap); 121 TAB_TEXT_INACTIVE_FOCUSSED = 122 allocateColor(Util::get(ts, "color.tab.text.inactive.focussed"), cmap); 123 TAB_SHINE_ACTIVE_NORMAL = 124 allocateColor(Util::get(ts, "color.tab.shine.active.normal"), cmap); 125 TAB_SHINE_INACTIVE_NORMAL = 126 allocateColor(Util::get(ts, "color.tab.shine.inactive.normal"), cmap); 127 TAB_SHINE_ACTIVE_FOCUSSED = 128 allocateColor(Util::get(ts, "color.tab.shine.active.focussed"), cmap); 129 TAB_SHINE_INACTIVE_FOCUSSED = 130 allocateColor(Util::get(ts, "color.tab.shine.inactive.focussed"), cmap); 131 TAB_SHADOW_ACTIVE_NORMAL = 132 allocateColor(Util::get(ts, "color.tab.shadow.active.normal"), cmap); 133 TAB_SHADOW_INACTIVE_NORMAL = 134 allocateColor(Util::get(ts, "color.tab.shadow.inactive.normal"), cmap); 135 TAB_SHADOW_ACTIVE_FOCUSSED = 136 allocateColor(Util::get(ts, "color.tab.shadow.active.focussed"), cmap); 137 TAB_SHADOW_INACTIVE_FOCUSSED = 138 allocateColor(Util::get(ts, "color.tab.shadow.inactive.focussed"), cmap); 139 }