1 /*
2  * go-gradient.c :
3  *
4  * Copyright (C) 2003-2004 Jody Goldberg (jody@gnome.org)
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation; either version 2 of the
9  * License, or (at your option) version 3.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
19  * USA
20  */
21 
22 #include <goffice/goffice-config.h>
23 #include <goffice/goffice.h>
24 
25 #ifdef GOFFICE_WITH_GTK
26 #include <goffice/gtk/go-combo-pixmaps.h>
27 #include <gdk-pixbuf/gdk-pixdata.h>
28 #endif
29 
30 #include <glib/gi18n-lib.h>
31 #include <string.h>
32 
33 /**
34  * GOGradientDirection:
35  * @GO_GRADIENT_N_TO_S: top to bottom.
36  * @GO_GRADIENT_S_TO_N: bottom to top.
37  * @GO_GRADIENT_N_TO_S_MIRRORED: top to bottom, mirrored.
38  * @GO_GRADIENT_S_TO_N_MIRRORED: bottom to top, mirrored.
39  * @GO_GRADIENT_W_TO_E: left to right.
40  * @GO_GRADIENT_E_TO_W: right to left.
41  * @GO_GRADIENT_W_TO_E_MIRRORED: left to right, mirrored.
42  * @GO_GRADIENT_E_TO_W_MIRRORED: right to left, mirrored.
43  * @GO_GRADIENT_NW_TO_SE: top left to bottom right.
44  * @GO_GRADIENT_SE_TO_NW: bottom right to top left.
45  * @GO_GRADIENT_NW_TO_SE_MIRRORED: top left to bottom right, mirrored.
46  * @GO_GRADIENT_SE_TO_NW_MIRRORED: bottom right to top left, mirrored.
47  * @GO_GRADIENT_NE_TO_SW: top right to bottom left.
48  * @GO_GRADIENT_SW_TO_NE: bottom left to top right.
49  * @GO_GRADIENT_SW_TO_NE_MIRRORED: top right to bottom left, mirrored.
50  * @GO_GRADIENT_NE_TO_SW_MIRRORED: bottom left to top right, mirrored.
51  * @GO_GRADIENT_MAX: maximum value, should not occur.
52 } ;
53  **/
54 
55 static char const *grad_dir_names[] = {
56 	"n-s",
57 	"s-n",
58 	"n-s-mirrored",
59 	"s-n-mirrored",
60 	"w-e",
61 	"e-w",
62 	"w-e-mirrored",
63 	"e-w-mirrored",
64 	"nw-se",
65 	"se-nw",
66 	"nw-se-mirrored",
67 	"se-nw-mirrored",
68 	"ne-sw",
69 	"sw-ne",
70 	"sw-ne-mirrored",
71 	"ne-sw-mirrored"
72 };
73 
74 GOGradientDirection
go_gradient_dir_from_str(char const * name)75 go_gradient_dir_from_str (char const *name)
76 {
77 	unsigned i;
78 	for (i = 0; i < GO_GRADIENT_MAX; i++)
79 		if (strcmp (grad_dir_names[i], name) == 0)
80 			return i;
81 	return GO_GRADIENT_N_TO_S;
82 }
83 
84 char const *
go_gradient_dir_as_str(GOGradientDirection dir)85 go_gradient_dir_as_str (GOGradientDirection dir)
86 {
87 	return (unsigned)dir >= GO_GRADIENT_MAX
88 		? "gradient"
89 		: grad_dir_names[dir];
90 }
91