GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
driver/init.c
Go to the documentation of this file.
1 
2 /****************************************************************************
3  *
4  * MODULE: driver
5  * AUTHOR(S): Glynn Clements <glynn gclements.plus.com> (original contributor)
6  * Huidae Cho <grass4u gmail.com>
7  * PURPOSE:
8  * COPYRIGHT: (C) 2006-2006 by the GRASS Development Team
9  *
10  * This program is free software under the GNU General Public
11  * License (>=v2). Read the file COPYING that comes with GRASS
12  * for details.
13  *
14  *****************************************************************************/
15 #include <grass/config.h>
16 
17 #include <stdio.h>
18 #include <stdlib.h>
19 
20 #include <grass/gis.h>
21 #include <grass/freetypecap.h>
22 #include "driverlib.h"
23 #include "driver.h"
24 #include "pad.h"
25 
26 const struct driver *driver;
27 
28 struct GFONT_CAP *ftcap;
29 
30 int NCOLORS;
31 
36 
37 int cur_x;
38 int cur_y;
39 
40 double text_size_x;
41 double text_size_y;
43 
44 int mouse_button[3] = { 1, 2, 3 };
45 
46 int LIB_init(const struct driver *drv, int argc, char **argv)
47 {
48  const char *p;
49 
50  driver = drv;
52 
53  /* initialize graphics */
54 
55  p = getenv("GRASS_WIDTH");
56  screen_left = 0;
57  screen_right = (p && atoi(p)) ? atoi(p) : DEF_WIDTH;
58 
59  p = getenv("GRASS_HEIGHT");
60  screen_top = 0;
61  screen_bottom = (p && atoi(p)) ? atoi(p) : DEF_HEIGHT;
62 
63  /* read mouse button setting */
64  if ((p = getenv("GRASS_MOUSE_BUTTON"))) {
65  int i;
66 
67  for (i = 0; i < 3 && p[i]; i++) {
68  if (p[i] < '1' || p[i] > '3')
69  break;
70  }
71  if (i == 3 && p[0] != p[1] && p[1] != p[2] && p[0] != p[2]) {
72  for (i = 0; i < 3; i++)
73  mouse_button[i] = p[i] - '0';
74  }
75  }
76 
77  if (COM_Graph_set(argc, argv) < 0)
78  exit(1);
79 
80  /* initialize the pads */
81  create_pad(""); /* scratch pad */
82 
83  return 0;
84 }
int cur_y
Definition: driver/init.c:38
double text_size_y
Definition: driver/init.c:41
struct driver * driver
Definition: driver/init.c:26
int LIB_init(const struct driver *drv, int argc, char **argv)
Definition: driver/init.c:46
int mouse_button[]
Definition: driver/init.c:44
#define DEF_WIDTH
Definition: driverlib.h:2
int screen_top
Definition: driver/init.c:35
struct GFONT_CAP * ftcap
Definition: driver/init.c:28
double text_rotation
Definition: driver/init.c:42
int screen_left
Definition: driver/init.c:32
char * getenv()
double text_size_x
Definition: driver/init.c:40
int NCOLORS
Definition: driver/init.c:30
int screen_right
Definition: driver/init.c:33
int COM_Graph_set(int, char **)
Definition: driver/Graph.c:4
int cur_x
Definition: driver/init.c:37
Definition: driver.h:25
int screen_bottom
Definition: driver/init.c:34
struct GFONT_CAP * parse_freetypecap(void)
Definition: parse_ftcap.c:21
int create_pad(const char *name)
Definition: pad.c:167
#define DEF_HEIGHT
Definition: driverlib.h:3