File: get_win.c

package info (click to toggle)
grass 6.4.4-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 104,028 kB
  • ctags: 40,409
  • sloc: ansic: 419,980; python: 63,559; tcl: 46,692; cpp: 29,791; sh: 18,564; makefile: 7,000; xml: 3,505; yacc: 561; perl: 559; lex: 480; sed: 70; objc: 7
file content (49 lines) | stat: -rw-r--r-- 927 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <stdio.h>
#include <grass/raster.h>

int get_win_w_mouse(float *top, float *bottom, float *left, float *right)
{
    int button;
    int st, sb, sl, sr;
    int t, b, l, r;

    st = R_screen_top();
    sb = R_screen_bot();
    sl = R_screen_left();
    sr = R_screen_rite();

    fprintf(stderr, "\nButtons:\n");
    fprintf(stderr, "Left:   Establish a corner\n");
    fprintf(stderr, "Right:  Accept window\n");

    l = sl;
    b = sb;
    r = l + 10;
    t = b - 10;

    do {
	R_get_location_with_box(l, b, &r, &t, &button);
	if (button == 1) {
	    l = r;
	    b = t;
	}
    } while (button != 3);

    if (l > r) {
	button = l;
	l = r;
	r = button;
    }

    if (t > b) {
	button = t;
	t = b;
	b = button;
    }
    *bottom = 100. - 100. * (b - st) / (sb - st);
    *top = 100. - 100. * (t - st) / (sb - st);
    *left = 100. * (l - sl) / (sr - sl);
    *right = 100. * (r - sl) / (sr - sl);

    return 0;
}