[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[mgp-users-jp 00102] orthogonal rakugaki
- To: mgp-users-jp@mew.org
- Subject: [mgp-users-jp 00102] orthogonal rakugaki
- From: Tsutomu OKUMURA <oku@ostrich.nml.t.u-tokyo.ac.jp>
- Date: Mon, 19 Jan 1998 20:51:50 +0900
- Posted: Mon, 19 Jan 1998 20:51:18 +0900
- Reply-to: mgp-users-jp@mew.org
$B1|B<$G$9!#(B
Shift$B$r2!$7$J$,$iMn=q$9$k$3$H$K$h$C$F!"?bD>$+?eJ?$N@~$r0z$1(B
$B$k$h$&$K$7$F$_$^$7$?!#%"%s%@!<%i%$%s$r0z$/;~$J$IJXMx$@$H;W$&(B
$B$N$G$9$,!"$I$&$G$7$g$&$+!#(B1.02a$B$KBP$9$k%Q%C%A$G$9!#(B
$B$H$3$m$G!"(B1.02a $B$G$O(B X $B$GMn=q$N%Z%s$N?'$,JQ$($i$l$k$h$&$K$J$C(B
$B$F$?$s$G$9$M(B \(^^)/
# $B%=!<%98+$k$^$G5$$E$+$J$+$C$?$G$9(B :-)
--- mgp.c.orig Mon Jan 19 16:20:35 1998
+++ mgp.c Mon Jan 19 20:47:56 1998
@@ -81,7 +81,7 @@
static void mgp_show_version __P((char *));
static void beep __P((void));
static void main_loop __P((u_int));
-static void rakugaki_update __P((XEvent *));
+static void rakugaki_update __P((XEvent *, u_int));
static void rakugaki_updatecolor __P((Cursor));
static RETSIGTYPE waitkids __P((int));
@@ -521,7 +521,7 @@
case ButtonPress:
if (rakugaki && e.xany.window == window) {
- rakugaki_update(&e);
+ rakugaki_update(&e, shift);
break;
}
@@ -567,14 +567,14 @@
case ButtonRelease:
if (rakugaki && e.xany.window == window)
- rakugaki_update(&e);
+ rakugaki_update(&e, shift);
break;
case MotionNotify:
if (!rakugaki)
break;
if (e.xany.window == window)
- rakugaki_update(&e);
+ rakugaki_update(&e, shift);
break;
case KeyPress:
@@ -802,10 +802,12 @@
}
static void
-rakugaki_update(e)
+rakugaki_update(e, orth)
XEvent *e;
+ u_int orth;
{
int x, y;
+ static int startx=-1, starty=-1, direc=-1;
if (e->type == MotionNotify) {
XMotionEvent *em;
@@ -820,9 +822,32 @@
return;
}
- if (rakugaki_x < 0 || rakugaki_y < 0)
+ if (rakugaki_x < 0 || rakugaki_y < 0) {
XDrawRectangle(display, window, gcpen, x, y, 2, 2);
- else {
+ startx = x;
+ starty = y;
+ direc = -1;
+ } else {
+ if (!orth)
+ startx = starty = direc = -1;
+ else if (startx<0 && starty<0) {
+ startx = x;
+ starty = y;
+ direc = -1;
+ } else if (direc<0 && (abs(x-startx)>5 || abs(y-starty)>5)) {
+ if (abs(x-startx) >= abs(y-starty)) {
+ direc = 0;
+ y = starty;
+ } else {
+ direc = 1;
+ x = startx;
+ }
+ } else {
+ if (direc == 0)
+ y = starty;
+ else
+ x = startx;
+ }
XDrawLine(display, window, gcpen,
x, y,
rakugaki_x, rakugaki_y);
--
$B1|B<(B $BEX(B / oku@nml.t.u-tokyo.ac.jp