summaryrefslogtreecommitdiffstats
path: root/Modules/stdwinmodule.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1991-02-13 23:19:39 (GMT)
committerGuido van Rossum <guido@python.org>1991-02-13 23:19:39 (GMT)
commit33f1770ed8f7d1febc7814e087ca7ba8ddce26df (patch)
treeb898d8582e7ee16dc9ee6f9c70e10fd0b5a75e1a /Modules/stdwinmodule.c
parent253919f3b71657fb328890326dec14e5bb3f7dd0 (diff)
downloadcpython-33f1770ed8f7d1febc7814e087ca7ba8ddce26df.zip
cpython-33f1770ed8f7d1febc7814e087ca7ba8ddce26df.tar.gz
cpython-33f1770ed8f7d1febc7814e087ca7ba8ddce26df.tar.bz2
Add getdefwinpos, getdefwinsize;
and improve mouse clipping for textedit blocks.
Diffstat (limited to 'Modules/stdwinmodule.c')
-rw-r--r--Modules/stdwinmodule.c38
1 files changed, 35 insertions, 3 deletions
diff --git a/Modules/stdwinmodule.c b/Modules/stdwinmodule.c
index 5403fb7..4d28f97 100644
--- a/Modules/stdwinmodule.c
+++ b/Modules/stdwinmodule.c
@@ -584,11 +584,17 @@ text_event(self, args)
if (!geteventarg(args, &e))
return NULL;
if (e.type == WE_MOUSE_DOWN) {
- /* Cheat at the left margin */
+ /* Cheat at the margins */
+ int width, height;
+ wgetdocsize(e.window, &width, &height);
if (e.u.where.h < 0 && tegetleft(tp) == 0)
e.u.where.h = 0;
- /* XXX should also check right margin and bottom,
- but we have no wgetdocsize() yet */
+ else if (e.u.where.h > width && tegetright(tp) == width)
+ e.u.where.h = width;
+ if (e.u.where.v < 0 && tegettop(tp) == 0)
+ e.u.where.v = 0;
+ else if (e.u.where.v > height && tegetright(tp) == height)
+ e.u.where.v = height;
}
return newintobject((long) teevent(tp, &e));
}
@@ -1433,6 +1439,30 @@ stdwin_setdefwinsize(sw, args)
}
static object *
+stdwin_getdefwinpos(wp, args)
+ windowobject *wp;
+ object *args;
+{
+ int h, v;
+ if (!getnoarg(args))
+ return NULL;
+ wgetdefwinpos(&h, &v);
+ return makepoint(h, v);
+}
+
+static object *
+stdwin_getdefwinsize(wp, args)
+ windowobject *wp;
+ object *args;
+{
+ int width, height;
+ if (!getnoarg(args))
+ return NULL;
+ wgetdefwinsize(&width, &height);
+ return makepoint(width, height);
+}
+
+static object *
stdwin_menucreate(self, args)
object *self;
object *args;
@@ -1609,6 +1639,8 @@ static struct methodlist stdwin_methods[] = {
{"fleep", stdwin_fleep},
{"getselection", stdwin_getselection},
{"getcutbuffer", stdwin_getcutbuffer},
+ {"getdefwinpos", stdwin_getdefwinpos},
+ {"getdefwinsize", stdwin_getdefwinsize},
{"getevent", stdwin_getevent},
{"menucreate", stdwin_menucreate},
{"message", stdwin_message},