| 1 |
// ---------------------------------------------------------------------------- |
| 2 |
// |
| 3 |
// Copyright (C) 2003-2013 Fons Adriaensen <[email protected]> |
| 4 |
// |
| 5 |
// This program is free software; you can redistribute it and/or modify |
| 6 |
// it under the terms of the GNU General Public License as published by |
| 7 |
// the Free Software Foundation; either version 3 of the License, or |
| 8 |
// (at your option) any later version. |
| 9 |
// |
| 10 |
// This program is distributed in the hope that it will be useful, |
| 11 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
// GNU General Public License for more details. |
| 14 |
// |
| 15 |
// You should have received a copy of the GNU General Public License |
| 16 |
// along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 |
// |
| 18 |
// ---------------------------------------------------------------------------- |
| 19 |
|
| 20 |
|
| 21 |
#include "styles.h" |
| 22 |
|
| 23 |
|
| 24 |
struct colors Colors; |
| 25 |
struct fonts Fonts; |
| 26 |
struct xft_colors XftColors; |
| 27 |
struct xft_fonts XftFonts; |
| 28 |
|
| 29 |
|
| 30 |
X_button_style Bst0, Bst1, Bst2; |
| 31 |
X_textln_style Tst0, Tst1; |
| 32 |
X_menuwin_style Mst1, Mst2; |
| 33 |
X_scale_style Slevel, Sprogr; |
| 34 |
X_meter_style Mlevel, Mprogr; |
| 35 |
X_mclist_style Lst0; |
| 36 |
|
| 37 |
|
| 38 |
void init_styles (X_display *disp, X_resman *xrm) |
| 39 |
{ |
| 40 |
Colors.black = disp->blackpixel (); |
| 41 |
Colors.white = disp->whitepixel (); |
| 42 |
Colors.main_ds = disp->alloc_color (xrm->get (".color.main.ds", "gray20"), Colors.black); |
| 43 |
Colors.main_ls = disp->alloc_color (xrm->get (".color.main.ls", "white"), Colors.white); |
| 44 |
Colors.text_bg = disp->alloc_color (xrm->get (".color.text.bg", "white"), Colors.white); |
| 45 |
Colors.text_hl = disp->alloc_color (xrm->get (".color.text.hl", "#c0ffa0"), Colors.white); |
| 46 |
Colors.text_mk = disp->alloc_color (xrm->get (".color.text.mk", "red"), Colors.black); |
| 47 |
Colors.spla_bg = disp->alloc_color (xrm->get (".color.splash.bg", "white"), Colors.white); |
| 48 |
Colors.spla_bd = disp->alloc_color (xrm->get (".color.splash.bd", "black"), Colors.black); |
| 49 |
Colors.plot_bg = disp->alloc_color (xrm->get (".color.plot.bg", "white"), Colors.white); |
| 50 |
Colors.plot_gr = disp->alloc_color (xrm->get (".color.plot.gr", "gray90"), Colors.black); |
| 51 |
Colors.plot_da [0] = disp->alloc_color (xrm->get (".color.plot.da0", "red"), Colors.black); |
| 52 |
Colors.plot_da [1] = disp->alloc_color (xrm->get (".color.plot.da1", "#00b000"), Colors.black); |
| 53 |
Colors.plot_mk [0] = disp->alloc_color (xrm->get (".color.plot.mk0", "blue"), Colors.black); |
| 54 |
Colors.plot_mk [1] = disp->alloc_color (xrm->get (".color.plot.mk1", "#908000"), Colors.black); |
| 55 |
Colors.meter_bg = disp->alloc_color (xrm->get (".color.meter.bg" , "gray10"), Colors.black); |
| 56 |
Colors.meter_ds = disp->alloc_color (xrm->get (".color.meter.ds" , "black"), Colors.black); |
| 57 |
Colors.meter_ls = disp->alloc_color (xrm->get (".color.meter.ls" , "gray50"), Colors.white); |
| 58 |
Colors.meter_offc0 = disp->alloc_color (xrm->get (".color.meter.offc0", "gray30"), Colors.black); |
| 59 |
Colors.meter_offc1 = disp->alloc_color (xrm->get (".color.meter.offc1", "gray30"), Colors.black); |
| 60 |
Colors.meter_offmk = disp->alloc_color (xrm->get (".color.meter.offmk", "gray40"), Colors.white); |
| 61 |
Colors.meter_actc0 = disp->alloc_color (xrm->get (".color.meter.actc0", "green"), Colors.white); |
| 62 |
Colors.meter_actc1 = disp->alloc_color (xrm->get (".color.meter.actc1", "yellow"), Colors.white); |
| 63 |
Colors.meter_actmk = disp->alloc_color (xrm->get (".color.meter.actmk", "white"), Colors.white); |
| 64 |
|
| 65 |
XftColors.white = disp->alloc_xftcolor ("white", 0); |
| 66 |
XftColors.black = disp->alloc_xftcolor ("black", 0); |
| 67 |
XftColors.main_bg = disp->alloc_xftcolor (xrm->get (".color.main.bg", "#ece8dc"), XftColors.white); |
| 68 |
XftColors.main_fg = disp->alloc_xftcolor (xrm->get (".color.main.fg", "black"), XftColors.black); |
| 69 |
XftColors.meter_fg = disp->alloc_xftcolor (xrm->get (".color.meter.fg", "#a0a0ff"), XftColors.white); |
| 70 |
XftColors.tick0 = disp->alloc_xftcolor (xrm->get (".color.tick0", "gray70"), XftColors.white); |
| 71 |
XftColors.tick1 = disp->alloc_xftcolor (xrm->get (".color.tick1", "red"), XftColors.black); |
| 72 |
XftColors.text_fg = disp->alloc_xftcolor (xrm->get (".color.text.fg", "black"), XftColors.black); |
| 73 |
XftColors.spla_fg = disp->alloc_xftcolor (xrm->get (".color.splash.fg", "blue"), XftColors.black); |
| 74 |
XftColors.butt_bg [0] = disp->alloc_xftcolor (xrm->get (".color.butt.bg0", "#e0d8d0"), XftColors.white); |
| 75 |
XftColors.butt_bg [1] = disp->alloc_xftcolor (xrm->get (".color.butt.bg1", "#8080ff"), XftColors.white); |
| 76 |
XftColors.butt_bg [2] = disp->alloc_xftcolor (xrm->get (".color.butt.bg2", "#ffff80"), XftColors.white); |
| 77 |
XftColors.butt_bg [3] = disp->alloc_xftcolor (xrm->get (".color.butt.bg3", "#e0d8d0"), XftColors.white); |
| 78 |
XftColors.butt_fg [0] = disp->alloc_xftcolor (xrm->get (".color.butt.fg0", "black"), XftColors.black); |
| 79 |
XftColors.butt_fg [1] = disp->alloc_xftcolor (xrm->get (".color.butt.fg1", "white"), XftColors.white); |
| 80 |
XftColors.butt_fg [2] = disp->alloc_xftcolor (xrm->get (".color.butt.fg2", "black"), XftColors.black); |
| 81 |
XftColors.butt_fg [3] = disp->alloc_xftcolor (xrm->get (".color.butt.fg3", "gray60"), XftColors.white); |
| 82 |
XftColors.menu_bg = disp->alloc_xftcolor (xrm->get (".color.menu.bg", "#ece8dc"), XftColors.white); |
| 83 |
XftColors.menu_fg [0] = disp->alloc_xftcolor (xrm->get (".color.menu.fg0", "black"), XftColors.black); |
| 84 |
XftColors.menu_fg [1] = disp->alloc_xftcolor (xrm->get (".color.menu.fg1", "blue"), XftColors.black); |
| 85 |
XftColors.menu_fg [2] = disp->alloc_xftcolor (xrm->get (".color.menu.fg2", "red"), XftColors.black); |
| 86 |
XftColors.menu_fg [3] = disp->alloc_xftcolor (xrm->get (".color.menu.fg3", "red"), XftColors.black); |
| 87 |
XftColors.menu_mm = disp->alloc_xftcolor (xrm->get (".color.menu.mm", "gray70"), XftColors.white); |
| 88 |
XftColors.mark_fg = disp->alloc_xftcolor (xrm->get (".color.plot.mkfg", "white"), XftColors.white); |
| 89 |
XftColors.plot_sc = disp->alloc_xftcolor (xrm->get (".color.plot.sc", "black"), XftColors.black); |
| 90 |
|
| 91 |
XftFonts.spla1 = disp->alloc_xftfont (xrm->get (".font.splash1", "times:pixelsize=24")); |
| 92 |
XftFonts.spla2 = disp->alloc_xftfont (xrm->get (".font.splash2", "times:pixelsize=14")); |
| 93 |
XftFonts.button = disp->alloc_xftfont (xrm->get (".font.button", "luxi:pixelsize=13")); |
| 94 |
XftFonts.labels = disp->alloc_xftfont (xrm->get (".font.labels", "luxi:pixelsize=13")); |
| 95 |
XftFonts.scales = disp->alloc_xftfont (xrm->get (".font.scales", "luxi:pixelsize=10")); |
| 96 |
XftFonts.files = disp->alloc_xftfont (xrm->get (".font.files", "luxi:bold:pixelsize=13")); |
| 97 |
XftFonts.menus = disp->alloc_xftfont (xrm->get (".font.files", "luxi:pixelsize=13")); |
| 98 |
|
| 99 |
Bst0.font = XftFonts.button; |
| 100 |
Bst0.color.bg [0] = XftColors.butt_bg [0]->pixel; |
| 101 |
Bst0.color.fg [0] = XftColors.butt_fg [0]; |
| 102 |
Bst0.color.bg [1] = XftColors.butt_bg [1]->pixel; |
| 103 |
Bst0.color.fg [1] = XftColors.butt_fg [1]; |
| 104 |
Bst0.color.bg [2] = XftColors.butt_bg [2]->pixel; |
| 105 |
Bst0.color.fg [2] = XftColors.butt_fg [2]; |
| 106 |
Bst0.color.bg [3] = XftColors.butt_bg [3]->pixel; |
| 107 |
Bst0.color.fg [3] = XftColors.butt_fg [3]; |
| 108 |
Bst0.color.shadow.bgnd = XftColors.main_bg->pixel; |
| 109 |
Bst0.color.shadow.lite = Colors.main_ls; |
| 110 |
Bst0.color.shadow.dark = Colors.main_ds; |
| 111 |
Bst0.type = X_button_style::RAISED; |
| 112 |
|
| 113 |
Bst1.font = XftFonts.button; |
| 114 |
Bst1.color.bg [0] = XftColors.main_bg->pixel; |
| 115 |
Bst1.color.fg [0] = XftColors.main_fg; |
| 116 |
Bst1.color.bg [1] = XftColors.butt_bg [0]->pixel; |
| 117 |
Bst1.color.fg [1] = XftColors.main_fg; |
| 118 |
Bst1.color.shadow.bgnd = XftColors.main_bg->pixel; |
| 119 |
Bst1.color.shadow.lite = Colors.main_ls; |
| 120 |
Bst1.color.shadow.dark = Colors.main_ds; |
| 121 |
Bst1.type = X_button_style::RAISED; |
| 122 |
|
| 123 |
Bst2.font = 0; |
| 124 |
Bst2.color.bg [0] = XftColors.main_bg->pixel; |
| 125 |
Bst2.color.fg [0] = XftColors.tick0; |
| 126 |
Bst2.color.bg [1] = XftColors.main_bg->pixel; |
| 127 |
Bst2.color.fg [1] = XftColors.tick1; |
| 128 |
Bst2.type = X_button_style::PLAIN; |
| 129 |
Bst0.size.x = 15; |
| 130 |
Bst0.size.y = 15; |
| 131 |
|
| 132 |
Tst0.font = XftFonts.labels; |
| 133 |
Tst0.color.normal.bgnd = XftColors.main_bg->pixel; |
| 134 |
Tst0.color.normal.text = XftColors.main_fg; |
| 135 |
Tst0.color.shadow.lite = Colors.main_ls; |
| 136 |
Tst0.color.shadow.dark = Colors.main_ds; |
| 137 |
Tst0.color.shadow.bgnd = XftColors.main_bg->pixel; |
| 138 |
|
| 139 |
Tst1.font = XftFonts.labels; |
| 140 |
Tst1.color.normal.bgnd = Colors.text_bg; |
| 141 |
Tst1.color.normal.text = XftColors.text_fg; |
| 142 |
Tst1.color.focus.bgnd = Colors.text_hl; |
| 143 |
Tst1.color.focus.text = XftColors.text_fg; |
| 144 |
Tst1.color.focus.line = Colors.text_mk; |
| 145 |
Tst1.color.shadow.lite = XftColors.main_bg->pixel; |
| 146 |
Tst1.color.shadow.dark = Colors.main_ds; |
| 147 |
Tst1.color.shadow.bgnd = Colors.main_ls; |
| 148 |
|
| 149 |
Mst1.font = XftFonts.menus; |
| 150 |
Mst1.step = 20; |
| 151 |
Mst1.type = X_menuwin_style::RAISED; |
| 152 |
Mst1.color.bg = XftColors.menu_bg; |
| 153 |
Mst1.color.fg [0] = XftColors.menu_fg [0]; |
| 154 |
Mst1.color.fg [1] = XftColors.menu_fg [1]; |
| 155 |
Mst1.color.fg [2] = XftColors.menu_fg [2]; |
| 156 |
Mst1.color.fg [3] = XftColors.menu_fg [3]; |
| 157 |
Mst1.color.mm = XftColors.menu_mm; |
| 158 |
Mst1.color.shadow.bgnd = XftColors.main_bg->pixel; |
| 159 |
Mst1.color.shadow.lite = Colors.main_ls; |
| 160 |
Mst1.color.shadow.dark = Colors.main_ds; |
| 161 |
|
| 162 |
Lst0.font = XftFonts.files; |
| 163 |
Lst0.bg = Colors.white; |
| 164 |
Lst0.fg [0] = XftColors.black; |
| 165 |
Lst0.fg [1] = disp->alloc_xftcolor ("blue", XftColors.black); |
| 166 |
Lst0.fg [2] = disp->alloc_xftcolor ("purple", XftColors.black); |
| 167 |
Lst0.fg [3] = disp->alloc_xftcolor ("red", XftColors.black); |
| 168 |
Lst0.dy = Lst0.font->ascent + Lst0.font->descent + 2; |
| 169 |
|
| 170 |
Mlevel.bg = Colors.meter_bg; |
| 171 |
Mlevel.off.c0 = Colors.meter_offc0; |
| 172 |
Mlevel.off.c1 = Colors.meter_offc1; |
| 173 |
Mlevel.off.mk = Colors.meter_offmk; |
| 174 |
Mlevel.act.c0 = Colors.meter_actc0; |
| 175 |
Mlevel.act.c1 = Colors.meter_actc1; |
| 176 |
Mlevel.act.mk = Colors.meter_actmk; |
| 177 |
|
| 178 |
Slevel.bg = Colors.meter_bg; |
| 179 |
Slevel.fg = XftColors.meter_fg; |
| 180 |
Slevel.marg = 7; |
| 181 |
Slevel.font = XftFonts.scales; |
| 182 |
Slevel.nseg = 9; |
| 183 |
Slevel.set_tick ( 0, 1, 0.001f, 0 ); |
| 184 |
Slevel.set_tick ( 1, 16, 3.16e-3f, "-50"); |
| 185 |
Slevel.set_tick ( 2, 46, 1.00e-2f, "-40"); |
| 186 |
Slevel.set_tick ( 3, 81, 3.16e-2f, "-30"); |
| 187 |
Slevel.set_tick ( 4, 116, 1.00e-1f, "-20"); |
| 188 |
Slevel.set_tick ( 5, 141, 1.78e-1f, "-15"); |
| 189 |
Slevel.set_tick ( 6, 171, 3.16e-1f, "-10"); |
| 190 |
Slevel.set_tick ( 7, 199, 5.00e-1f, "-6" ); |
| 191 |
Slevel.set_tick ( 8, 220, 7.07e01f, "-3" ); |
| 192 |
Slevel.set_tick ( 9, 241, 1.000f, "0" ); |
| 193 |
|
| 194 |
Mprogr.bg = Colors.meter_bg; |
| 195 |
Mprogr.off.c0 = Colors.meter_offc0; |
| 196 |
Mprogr.off.c1 = Colors.meter_offc0; |
| 197 |
Mprogr.off.mk = Colors.meter_offc0; |
| 198 |
Mprogr.act.c0 = Colors.meter_actc0; |
| 199 |
Mprogr.act.c1 = Colors.meter_actc0; |
| 200 |
Mprogr.act.mk = Colors.meter_actc0; |
| 201 |
|
| 202 |
Sprogr.bg = Colors.meter_bg; |
| 203 |
Sprogr.fg = XftColors.meter_fg; |
| 204 |
Sprogr.marg = 1; |
| 205 |
Sprogr.font = 0; |
| 206 |
Sprogr.nseg = 10; |
| 207 |
Sprogr.set_tick ( 0, 1, 0.0f, 0); |
| 208 |
Sprogr.set_tick ( 1, 31, 0.1f, 0); |
| 209 |
Sprogr.set_tick ( 2, 61, 0.2f, 0); |
| 210 |
Sprogr.set_tick ( 3, 91, 0.3f, 0); |
| 211 |
Sprogr.set_tick ( 4, 121, 0.4f, 0); |
| 212 |
Sprogr.set_tick ( 5, 151, 0.5f, 0); |
| 213 |
Sprogr.set_tick ( 6, 181, 0.6f, 0); |
| 214 |
Sprogr.set_tick ( 7, 211, 0.7f, 0); |
| 215 |
Sprogr.set_tick ( 8, 241, 0.8f, 0); |
| 216 |
Sprogr.set_tick ( 9, 271, 0.9f, 0); |
| 217 |
Sprogr.set_tick (10, 301, 1.0f, 0); |
| 218 |
} |
| 219 |
|