]> www.fi.muni.cz Git - evince.git/blob - backend/dvi/mdvi-lib/dvimisc.c
06250cac6c8b036f66c4f39fe2b58f6ffab7fffb
[evince.git] / backend / dvi / mdvi-lib / dvimisc.c
1 /*
2  * Copyright (C) 2000, Matias Atria
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  */
18
19 #include "mdvi.h"
20
21 void    mdvi_set_color(DviContext *dvi, Ulong fg, Ulong bg)
22 {
23         if(dvi->curr_fg != fg || dvi->curr_bg != bg) {
24                 DEBUG((DBG_DEVICE, "setting color to (%lu,%lu)\n", fg, bg));
25                 if(dvi->device.set_color)
26                         dvi->device.set_color(dvi->device.device_data, fg, bg);
27                 dvi->curr_fg = fg;
28                 dvi->curr_bg = bg;
29         }
30 }
31
32 void    mdvi_push_color(DviContext *dvi, Ulong fg, Ulong bg)
33 {
34         if(dvi->color_top == dvi->color_size) {
35                 dvi->color_size += 32;
36                 dvi->color_stack = mdvi_realloc(dvi->color_stack,
37                         dvi->color_size * sizeof(DviColorPair));
38         }
39         dvi->color_stack[dvi->color_top].fg = dvi->curr_fg;
40         dvi->color_stack[dvi->color_top].bg = dvi->curr_bg;
41         dvi->color_top++;
42         mdvi_set_color(dvi, fg, bg);
43 }
44
45 void    mdvi_pop_color(DviContext *dvi)
46 {
47         Ulong   fg, bg;
48         
49         if(dvi->color_top == 0)
50                 return;
51         dvi->color_top--;
52         fg = dvi->color_stack[dvi->color_top].fg;
53         bg = dvi->color_stack[dvi->color_top].bg;
54         mdvi_set_color(dvi, fg, bg);
55 }
56
57 void    mdvi_reset_color(DviContext *dvi)
58 {
59         dvi->color_top = 0;
60         mdvi_set_color(dvi, dvi->params.fg, dvi->params.bg);
61 }
62