specials: convert stippled_hr object to new style
[monky] / src / specials.h
1 /* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
2  *
3  * Conky, a system monitor, based on torsmo
4  *
5  * Any original torsmo code is licensed under the BSD license
6  *
7  * All code written since the fork of torsmo is licensed under the GPL
8  *
9  * Please see COPYING for details
10  *
11  * Copyright (c) 2004, Hannu Saransaari and Lauri Hakkarainen
12  * Copyright (c) 2005-2009 Brenden Matthews, Philip Kovacs, et. al.
13  *      (see AUTHORS)
14  * All rights reserved.
15  *
16  * This program is free software: you can redistribute it and/or modify
17  * it under the terms of the GNU General Public License as published by
18  * the Free Software Foundation, either version 3 of the License, or
19  * (at your option) any later version.
20  *
21  * This program is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24  * GNU General Public License for more details.
25  * You should have received a copy of the GNU General Public License
26  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
27  *
28  */
29 #ifndef _SPECIALS_H
30 #define _SPECIALS_H
31
32 /* special stuff in text_buffer */
33
34 #define SPECIAL_CHAR '\x01'
35
36 #define MAX_GRAPH_DEPTH 512
37
38 // don't use spaces in LOGGRAPH or NORMGRAPH if you change them
39 #define LOGGRAPH "-l"
40 #define TEMPGRAD "-t"
41
42 enum special_types {
43         HORIZONTAL_LINE = 1,
44         STIPPLED_HR,
45         BAR,
46         FG,
47         BG,
48         OUTLINE,
49         ALIGNR,
50         ALIGNC,
51         GAUGE,
52         GRAPH,
53         OFFSET,
54         VOFFSET,
55         FONT,
56         GOTO,
57         TAB,
58 };
59
60 struct special_t {
61         int type;
62         short height;
63         short width;
64         long arg;
65         double *graph;
66         double graph_scale;
67         short show_scale;
68         int graph_width;
69         int scaled;
70         unsigned long first_colour;     // for graph gradient
71         unsigned long last_colour;
72         short font_added;
73         char tempgrad;
74 };
75
76 /* direct access to the registered specials (FIXME: bad encapsulation) */
77 extern struct special_t *specials;
78 extern int special_count;
79
80 extern int default_bar_width;
81 extern int default_bar_height;
82 #ifdef X11
83 extern int default_graph_width;
84 extern int default_graph_height;
85 extern int default_gauge_width;
86 extern int default_gauge_height;
87 #endif
88
89 /* set the obj's default width and height (FIXME: referencing the global obj is evil) */
90 #define SIZE_DEFAULTS(arg) { \
91         obj->a = default_##arg##_width; \
92         obj->b = default_##arg##_height; \
93 }
94
95 /* forward declare to avoid mutual inclusion between specials.h and text_object.h */
96 struct text_object;
97
98 /* max number of specials allowed (TODO: use linked list instead) */
99 extern int max_specials;
100
101 /* scanning special arguments */
102 const char *scan_bar(struct text_object *, const char *);
103 #ifdef X11
104 const char *scan_gauge(struct text_object *, const char *);
105 char *scan_font(const char *);
106 char *scan_graph(struct text_object *, const char *);
107 void scan_tab(struct text_object *, const char *);
108 void scan_stippled_hr(struct text_object *, const char*);
109
110 /* printing specials */
111 void new_gauge(struct text_object *, char *, int);
112 void new_bar(struct text_object *, char *, int);
113 void new_font(char *, char *);
114 void new_graph(struct text_object *, char *, double);
115 void new_hr(char *, int);
116 void new_stippled_hr(struct text_object *, char *);
117 #endif
118 void new_bar_in_shell(struct text_object *, char *, int, double);
119 void new_fg(char *, long);
120 void new_bg(char *, long);
121 void new_outline(char *, long);
122 void new_offset(char *, long);
123 void new_voffset(char *, long);
124 void new_alignr(char *, long);
125 void new_alignc(char *, long);
126 void new_goto(char *, long);
127 void new_tab(struct text_object *, char *);
128
129 #endif /* _SPECIALS_H */