Mercurial > cpython-lru_cache-weakref
annotate Modules/stdwinmodule.c @ 397:4cdcc16bd080 legacy-trunk
Added __dict__ attributes all over the place.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Sun, 20 Oct 1991 20:22:50 +0000 |
| parents | baada20762b0 |
| children | 34abca182f18 |
| rev | line source |
|---|---|
|
145
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
142
diff
changeset
|
1 /*********************************************************** |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
142
diff
changeset
|
2 Copyright 1991 by Stichting Mathematisch Centrum, Amsterdam, The |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
142
diff
changeset
|
3 Netherlands. |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
142
diff
changeset
|
4 |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
142
diff
changeset
|
5 All Rights Reserved |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
142
diff
changeset
|
6 |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
142
diff
changeset
|
7 Permission to use, copy, modify, and distribute this software and its |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
142
diff
changeset
|
8 documentation for any purpose and without fee is hereby granted, |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
142
diff
changeset
|
9 provided that the above copyright notice appear in all copies and that |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
142
diff
changeset
|
10 both that copyright notice and this permission notice appear in |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
142
diff
changeset
|
11 supporting documentation, and that the names of Stichting Mathematisch |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
142
diff
changeset
|
12 Centrum or CWI not be used in advertising or publicity pertaining to |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
142
diff
changeset
|
13 distribution of the software without specific, written prior permission. |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
142
diff
changeset
|
14 |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
142
diff
changeset
|
15 STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
142
diff
changeset
|
16 THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
142
diff
changeset
|
17 FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
142
diff
changeset
|
18 FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
142
diff
changeset
|
19 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
142
diff
changeset
|
20 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
142
diff
changeset
|
21 OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
142
diff
changeset
|
22 |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
142
diff
changeset
|
23 ******************************************************************/ |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
142
diff
changeset
|
24 |
| 6 | 25 /* Stdwin module */ |
| 26 | |
| 27 /* Stdwin itself is a module, not a separate object type. | |
| 28 Object types defined here: | |
| 29 wp: a window | |
| 30 dp: a drawing structure (only one can exist at a time) | |
| 31 mp: a menu | |
| 32 tp: a textedit block | |
| 33 */ | |
| 34 | |
| 35 /* Rules for translating C stdwin function calls into Python stwin: | |
| 36 - All names drop their initial letter 'w' | |
| 37 - Functions with a window as first parameter are methods of window objects | |
| 38 - There is no equivalent for wclose(); just delete the window object | |
| 39 (all references to it!) (XXX maybe this is a bad idea) | |
| 40 - w.begindrawing() returns a drawing object | |
| 41 - There is no equivalent for wenddrawing(win); just delete the drawing | |
| 42 object (all references to it!) (XXX maybe this is a bad idea) | |
| 43 - Functions that may only be used inside wbegindrawing / wendddrawing | |
| 44 are methods of the drawing object; this includes the text measurement | |
| 45 functions (which however have doubles as module functions). | |
| 46 - Methods of the drawing object drop an initial 'draw' from their name | |
| 47 if they have it, e.g., wdrawline() --> d.line() | |
| 48 - The obvious type conversions: int --> intobject; string --> stringobject | |
| 49 - A text parameter followed by a length parameter is only a text (string) | |
| 50 parameter in Python | |
| 51 - A point or other pair of horizontal and vertical coordinates is always | |
| 52 a pair of integers in Python | |
| 53 - Two points forming a rectangle or endpoints of a line segment are a | |
| 54 pair of points in Python | |
| 55 - The arguments to d.elarc() are three points. | |
| 56 - The functions wgetclip() and wsetclip() are translated into | |
| 57 stdwin.getcutbuffer() and stdwin.setcutbuffer(); 'clip' is really | |
| 58 a bad word for what these functions do (clipping has a different | |
| 59 meaning in the drawing world), while cutbuffer is standard X jargon. | |
|
50
b94822f54991
Change set/getcutbuffer to use the new stdwin interface.
Guido van Rossum <guido@python.org>
parents:
6
diff
changeset
|
60 XXX This must change again in the light of changes to stdwin! |
| 6 | 61 - For textedit, similar rules hold, but they are less strict. |
| 62 XXX more? | |
| 63 */ | |
| 64 | |
| 86 | 65 #include "allobjects.h" |
| 6 | 66 |
| 67 #include "modsupport.h" | |
| 68 | |
| 86 | 69 #include "stdwin.h" |
| 6 | 70 |
| 71 /* Window and menu object types declared here because of forward references */ | |
| 72 | |
| 73 typedef struct { | |
| 74 OB_HEAD | |
| 75 object *w_title; | |
| 76 WINDOW *w_win; | |
| 77 object *w_attr; /* Attributes dictionary */ | |
| 78 } windowobject; | |
| 79 | |
| 80 extern typeobject Windowtype; /* Really static, forward */ | |
| 81 | |
| 82 #define is_windowobject(wp) ((wp)->ob_type == &Windowtype) | |
| 83 | |
| 84 typedef struct { | |
| 85 OB_HEAD | |
| 86 MENU *m_menu; | |
| 87 int m_id; | |
| 88 object *m_attr; /* Attributes dictionary */ | |
| 89 } menuobject; | |
| 90 | |
| 91 extern typeobject Menutype; /* Really static, forward */ | |
| 92 | |
| 93 #define is_menuobject(mp) ((mp)->ob_type == &Menutype) | |
| 94 | |
| 95 | |
| 96 /* Strongly stdwin-specific argument handlers */ | |
| 97 | |
| 98 static int | |
| 99 getmousedetail(v, ep) | |
| 100 object *v; | |
| 101 EVENT *ep; | |
| 102 { | |
| 103 if (v == NULL || !is_tupleobject(v) || gettuplesize(v) != 4) | |
| 104 return err_badarg(); | |
| 105 return getintintarg(gettupleitem(v, 0), | |
| 106 &ep->u.where.h, &ep->u.where.v) && | |
| 107 getintarg(gettupleitem(v, 1), &ep->u.where.clicks) && | |
| 108 getintarg(gettupleitem(v, 2), &ep->u.where.button) && | |
| 109 getintarg(gettupleitem(v, 3), &ep->u.where.mask); | |
| 110 } | |
| 111 | |
| 112 static int | |
| 113 getmenudetail(v, ep) | |
| 114 object *v; | |
| 115 EVENT *ep; | |
| 116 { | |
| 117 object *mp; | |
| 118 if (v == NULL || !is_tupleobject(v) || gettuplesize(v) != 2) | |
| 119 return err_badarg(); | |
| 120 mp = gettupleitem(v, 0); | |
| 121 if (mp == NULL || !is_menuobject(mp)) | |
| 122 return err_badarg(); | |
| 123 ep->u.m.id = ((menuobject *)mp) -> m_id; | |
| 124 return getintarg(gettupleitem(v, 1), &ep->u.m.item); | |
| 125 } | |
| 126 | |
| 127 static int | |
| 128 geteventarg(v, ep) | |
| 129 object *v; | |
| 130 EVENT *ep; | |
| 131 { | |
| 132 object *wp, *detail; | |
| 133 int a[4]; | |
| 134 if (v == NULL || !is_tupleobject(v) || gettuplesize(v) != 3) | |
| 135 return err_badarg(); | |
| 136 if (!getintarg(gettupleitem(v, 0), &ep->type)) | |
| 137 return 0; | |
| 138 wp = gettupleitem(v, 1); | |
| 139 if (wp == None) | |
| 140 ep->window = NULL; | |
| 141 else if (wp == NULL || !is_windowobject(wp)) | |
| 142 return err_badarg(); | |
| 143 else | |
| 144 ep->window = ((windowobject *)wp) -> w_win; | |
| 145 detail = gettupleitem(v, 2); | |
| 146 switch (ep->type) { | |
| 147 case WE_CHAR: | |
| 148 if (!is_stringobject(detail) || getstringsize(detail) != 1) | |
| 149 return err_badarg(); | |
| 150 ep->u.character = getstringvalue(detail)[0]; | |
| 151 return 1; | |
| 152 case WE_COMMAND: | |
| 153 return getintarg(detail, &ep->u.command); | |
| 154 case WE_DRAW: | |
| 155 if (!getrectarg(detail, a)) | |
| 156 return 0; | |
| 157 ep->u.area.left = a[0]; | |
| 158 ep->u.area.top = a[1]; | |
| 159 ep->u.area.right = a[2]; | |
| 160 ep->u.area.bottom = a[3]; | |
| 161 return 1; | |
| 162 case WE_MOUSE_DOWN: | |
| 163 case WE_MOUSE_UP: | |
| 164 case WE_MOUSE_MOVE: | |
| 165 return getmousedetail(detail, ep); | |
| 166 case WE_MENU: | |
| 167 return getmenudetail(detail, ep); | |
| 168 default: | |
| 169 return 1; | |
| 170 } | |
| 171 } | |
| 172 | |
| 173 | |
| 174 /* Return construction tools */ | |
| 175 | |
| 176 static object * | |
| 177 makepoint(a, b) | |
| 178 int a, b; | |
| 179 { | |
| 180 object *v; | |
| 181 object *w; | |
| 182 if ((v = newtupleobject(2)) == NULL) | |
| 183 return NULL; | |
| 184 if ((w = newintobject((long)a)) == NULL || | |
| 185 settupleitem(v, 0, w) != 0 || | |
| 186 (w = newintobject((long)b)) == NULL || | |
| 187 settupleitem(v, 1, w) != 0) { | |
| 188 DECREF(v); | |
| 189 return NULL; | |
| 190 } | |
| 191 return v; | |
| 192 } | |
| 193 | |
| 194 static object * | |
| 195 makerect(a, b, c, d) | |
| 196 int a, b, c, d; | |
| 197 { | |
| 198 object *v; | |
| 199 object *w; | |
| 200 if ((v = newtupleobject(2)) == NULL) | |
| 201 return NULL; | |
| 202 if ((w = makepoint(a, b)) == NULL || | |
| 203 settupleitem(v, 0, w) != 0 || | |
| 204 (w = makepoint(c, d)) == NULL || | |
| 205 settupleitem(v, 1, w) != 0) { | |
| 206 DECREF(v); | |
| 207 return NULL; | |
| 208 } | |
| 209 return v; | |
| 210 } | |
| 211 | |
| 212 static object * | |
| 213 makemouse(hor, ver, clicks, button, mask) | |
| 214 int hor, ver, clicks, button, mask; | |
| 215 { | |
| 216 object *v; | |
| 217 object *w; | |
| 218 if ((v = newtupleobject(4)) == NULL) | |
| 219 return NULL; | |
| 220 if ((w = makepoint(hor, ver)) == NULL || | |
| 221 settupleitem(v, 0, w) != 0 || | |
| 222 (w = newintobject((long)clicks)) == NULL || | |
| 223 settupleitem(v, 1, w) != 0 || | |
| 224 (w = newintobject((long)button)) == NULL || | |
| 225 settupleitem(v, 2, w) != 0 || | |
| 226 (w = newintobject((long)mask)) == NULL || | |
| 227 settupleitem(v, 3, w) != 0) { | |
| 228 DECREF(v); | |
| 229 return NULL; | |
| 230 } | |
| 231 return v; | |
| 232 } | |
| 233 | |
| 234 static object * | |
| 235 makemenu(mp, item) | |
| 236 object *mp; | |
| 237 int item; | |
| 238 { | |
| 239 object *v; | |
| 240 object *w; | |
| 241 if ((v = newtupleobject(2)) == NULL) | |
| 242 return NULL; | |
| 243 INCREF(mp); | |
| 244 if (settupleitem(v, 0, mp) != 0 || | |
| 245 (w = newintobject((long)item)) == NULL || | |
| 246 settupleitem(v, 1, w) != 0) { | |
| 247 DECREF(v); | |
| 248 return NULL; | |
| 249 } | |
| 250 return v; | |
| 251 } | |
| 252 | |
| 253 | |
| 254 /* Drawing objects */ | |
| 255 | |
| 256 typedef struct { | |
| 257 OB_HEAD | |
| 258 windowobject *d_ref; | |
| 259 } drawingobject; | |
| 260 | |
| 261 static drawingobject *Drawing; /* Set to current drawing object, or NULL */ | |
| 262 | |
| 263 /* Drawing methods */ | |
| 264 | |
| 265 static void | |
| 266 drawing_dealloc(dp) | |
| 267 drawingobject *dp; | |
| 268 { | |
| 269 wenddrawing(dp->d_ref->w_win); | |
| 270 Drawing = NULL; | |
| 271 DECREF(dp->d_ref); | |
| 272 free((char *)dp); | |
| 273 } | |
| 274 | |
| 275 static object * | |
| 276 drawing_generic(dp, args, func) | |
| 277 drawingobject *dp; | |
| 278 object *args; | |
| 279 void (*func) FPROTO((int, int, int, int)); | |
| 280 { | |
| 281 int a[4]; | |
| 282 if (!getrectarg(args, a)) | |
| 283 return NULL; | |
| 284 (*func)(a[0], a[1], a[2], a[3]); | |
| 285 INCREF(None); | |
| 286 return None; | |
| 287 } | |
| 288 | |
| 289 static object * | |
| 290 drawing_line(dp, args) | |
| 291 drawingobject *dp; | |
| 292 object *args; | |
| 293 { | |
|
157
47cc0ce7999c
Return value of drawing_generic was ignored! Foo!
Guido van Rossum <guido@python.org>
parents:
145
diff
changeset
|
294 return drawing_generic(dp, args, wdrawline); |
| 6 | 295 } |
| 296 | |
| 297 static object * | |
| 298 drawing_xorline(dp, args) | |
| 299 drawingobject *dp; | |
| 300 object *args; | |
| 301 { | |
|
157
47cc0ce7999c
Return value of drawing_generic was ignored! Foo!
Guido van Rossum <guido@python.org>
parents:
145
diff
changeset
|
302 return drawing_generic(dp, args, wxorline); |
| 6 | 303 } |
| 304 | |
| 305 static object * | |
| 306 drawing_circle(dp, args) | |
| 307 drawingobject *dp; | |
| 308 object *args; | |
| 309 { | |
| 310 int a[3]; | |
| 311 if (!getpointintarg(args, a)) | |
| 312 return NULL; | |
| 313 wdrawcircle(a[0], a[1], a[2]); | |
| 314 INCREF(None); | |
| 315 return None; | |
| 316 } | |
| 244 | 317 |
|
207
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
318 static object * |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
319 drawing_fillcircle(dp, args) |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
320 drawingobject *dp; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
321 object *args; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
322 { |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
323 int a[3]; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
324 if (!getpointintarg(args, a)) |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
325 return NULL; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
326 wfillcircle(a[0], a[1], a[2]); |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
327 INCREF(None); |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
328 return None; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
329 } |
| 6 | 330 |
| 331 static object * | |
| 244 | 332 drawing_xorcircle(dp, args) |
| 333 drawingobject *dp; | |
| 334 object *args; | |
| 335 { | |
| 336 int a[3]; | |
| 337 if (!getpointintarg(args, a)) | |
| 338 return NULL; | |
| 339 wxorcircle(a[0], a[1], a[2]); | |
| 340 INCREF(None); | |
| 341 return None; | |
| 342 } | |
| 343 | |
| 344 static object * | |
| 6 | 345 drawing_elarc(dp, args) |
| 346 drawingobject *dp; | |
| 347 object *args; | |
| 348 { | |
| 349 int a[6]; | |
| 350 if (!get3pointarg(args, a)) | |
| 351 return NULL; | |
| 352 wdrawelarc(a[0], a[1], a[2], a[3], a[4], a[5]); | |
| 353 INCREF(None); | |
| 354 return None; | |
| 355 } | |
| 356 | |
| 357 static object * | |
|
207
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
358 drawing_fillelarc(dp, args) |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
359 drawingobject *dp; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
360 object *args; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
361 { |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
362 int a[6]; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
363 if (!get3pointarg(args, a)) |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
364 return NULL; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
365 wfillelarc(a[0], a[1], a[2], a[3], a[4], a[5]); |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
366 INCREF(None); |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
367 return None; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
368 } |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
369 |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
370 static object * |
| 244 | 371 drawing_xorelarc(dp, args) |
| 372 drawingobject *dp; | |
| 373 object *args; | |
| 374 { | |
| 375 int a[6]; | |
| 376 if (!get3pointarg(args, a)) | |
| 377 return NULL; | |
| 378 wxorelarc(a[0], a[1], a[2], a[3], a[4], a[5]); | |
| 379 INCREF(None); | |
| 380 return None; | |
| 381 } | |
| 382 | |
| 383 static object * | |
| 6 | 384 drawing_box(dp, args) |
| 385 drawingobject *dp; | |
| 386 object *args; | |
| 387 { | |
|
157
47cc0ce7999c
Return value of drawing_generic was ignored! Foo!
Guido van Rossum <guido@python.org>
parents:
145
diff
changeset
|
388 return drawing_generic(dp, args, wdrawbox); |
| 6 | 389 } |
| 390 | |
| 391 static object * | |
| 392 drawing_erase(dp, args) | |
| 393 drawingobject *dp; | |
| 394 object *args; | |
| 395 { | |
|
157
47cc0ce7999c
Return value of drawing_generic was ignored! Foo!
Guido van Rossum <guido@python.org>
parents:
145
diff
changeset
|
396 return drawing_generic(dp, args, werase); |
| 6 | 397 } |
| 398 | |
| 399 static object * | |
| 400 drawing_paint(dp, args) | |
| 401 drawingobject *dp; | |
| 402 object *args; | |
| 403 { | |
|
157
47cc0ce7999c
Return value of drawing_generic was ignored! Foo!
Guido van Rossum <guido@python.org>
parents:
145
diff
changeset
|
404 return drawing_generic(dp, args, wpaint); |
| 6 | 405 } |
| 406 | |
| 407 static object * | |
| 408 drawing_invert(dp, args) | |
| 409 drawingobject *dp; | |
| 410 object *args; | |
| 411 { | |
|
157
47cc0ce7999c
Return value of drawing_generic was ignored! Foo!
Guido van Rossum <guido@python.org>
parents:
145
diff
changeset
|
412 return drawing_generic(dp, args, winvert); |
| 6 | 413 } |
| 414 | |
|
207
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
415 static POINT * |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
416 getpointsarray(v, psize) |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
417 object *v; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
418 int *psize; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
419 { |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
420 int n = -1; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
421 object * (*getitem) PROTO((object *, int)); |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
422 int i; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
423 POINT *points; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
424 |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
425 if (v == NULL) |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
426 ; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
427 else if (is_listobject(v)) { |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
428 n = getlistsize(v); |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
429 getitem = getlistitem; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
430 } |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
431 else if (is_tupleobject(v)) { |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
432 n = gettuplesize(v); |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
433 getitem = gettupleitem; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
434 } |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
435 |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
436 if (n <= 0) { |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
437 (void) err_badarg(); |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
438 return NULL; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
439 } |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
440 |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
441 points = NEW(POINT, n); |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
442 if (points == NULL) { |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
443 (void) err_nomem(); |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
444 return NULL; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
445 } |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
446 |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
447 for (i = 0; i < n; i++) { |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
448 object *w = (*getitem)(v, i); |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
449 int a[2]; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
450 if (!getpointarg(w, a)) { |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
451 DEL(points); |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
452 return NULL; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
453 } |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
454 points[i].h = a[0]; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
455 points[i].v = a[1]; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
456 } |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
457 |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
458 *psize = n; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
459 return points; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
460 } |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
461 |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
462 static object * |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
463 drawing_poly(dp, args) |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
464 drawingobject *dp; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
465 object *args; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
466 { |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
467 int n; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
468 POINT *points = getpointsarray(args, &n); |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
469 if (points == NULL) |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
470 return NULL; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
471 wdrawpoly(n, points); |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
472 DEL(points); |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
473 INCREF(None); |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
474 return None; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
475 } |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
476 |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
477 static object * |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
478 drawing_fillpoly(dp, args) |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
479 drawingobject *dp; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
480 object *args; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
481 { |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
482 int n; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
483 POINT *points = getpointsarray(args, &n); |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
484 if (points == NULL) |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
485 return NULL; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
486 wfillpoly(n, points); |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
487 DEL(points); |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
488 INCREF(None); |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
489 return None; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
490 } |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
491 |
| 6 | 492 static object * |
| 244 | 493 drawing_xorpoly(dp, args) |
| 494 drawingobject *dp; | |
| 495 object *args; | |
| 496 { | |
| 497 int n; | |
| 498 POINT *points = getpointsarray(args, &n); | |
| 499 if (points == NULL) | |
| 500 return NULL; | |
| 501 wxorpoly(n, points); | |
| 502 DEL(points); | |
| 503 INCREF(None); | |
| 504 return None; | |
| 505 } | |
| 506 | |
| 507 static object * | |
| 6 | 508 drawing_cliprect(dp, args) |
| 509 drawingobject *dp; | |
| 510 object *args; | |
| 511 { | |
|
157
47cc0ce7999c
Return value of drawing_generic was ignored! Foo!
Guido van Rossum <guido@python.org>
parents:
145
diff
changeset
|
512 return drawing_generic(dp, args, wcliprect); |
| 6 | 513 } |
| 514 | |
| 515 static object * | |
| 516 drawing_noclip(dp, args) | |
| 517 drawingobject *dp; | |
| 518 object *args; | |
| 519 { | |
| 520 if (!getnoarg(args)) | |
| 521 return NULL; | |
| 522 wnoclip(); | |
| 523 INCREF(None); | |
| 524 return None; | |
| 525 } | |
| 526 | |
| 527 static object * | |
| 528 drawing_shade(dp, args) | |
| 529 drawingobject *dp; | |
| 530 object *args; | |
| 531 { | |
| 532 int a[5]; | |
| 533 if (!getrectintarg(args, a)) | |
| 534 return NULL; | |
| 535 wshade(a[0], a[1], a[2], a[3], a[4]); | |
| 536 INCREF(None); | |
| 537 return None; | |
| 538 } | |
| 539 | |
| 540 static object * | |
| 541 drawing_text(dp, args) | |
| 542 drawingobject *dp; | |
| 543 object *args; | |
| 544 { | |
| 545 int a[2]; | |
| 546 object *s; | |
| 547 if (!getpointstrarg(args, a, &s)) | |
| 548 return NULL; | |
| 549 wdrawtext(a[0], a[1], getstringvalue(s), (int)getstringsize(s)); | |
| 550 INCREF(None); | |
| 551 return None; | |
| 552 } | |
| 553 | |
| 554 /* The following four are also used as stdwin functions */ | |
| 555 | |
| 556 static object * | |
| 557 drawing_lineheight(dp, args) | |
| 558 drawingobject *dp; | |
| 559 object *args; | |
| 560 { | |
| 561 if (!getnoarg(args)) | |
| 562 return NULL; | |
| 563 return newintobject((long)wlineheight()); | |
| 564 } | |
| 565 | |
| 566 static object * | |
| 567 drawing_baseline(dp, args) | |
| 568 drawingobject *dp; | |
| 569 object *args; | |
| 570 { | |
| 571 if (!getnoarg(args)) | |
| 572 return NULL; | |
| 573 return newintobject((long)wbaseline()); | |
| 574 } | |
| 575 | |
| 576 static object * | |
| 577 drawing_textwidth(dp, args) | |
| 578 drawingobject *dp; | |
| 579 object *args; | |
| 580 { | |
| 581 object *s; | |
| 582 if (!getstrarg(args, &s)) | |
| 583 return NULL; | |
| 584 return newintobject( | |
| 585 (long)wtextwidth(getstringvalue(s), (int)getstringsize(s))); | |
| 586 } | |
| 587 | |
| 588 static object * | |
| 589 drawing_textbreak(dp, args) | |
| 590 drawingobject *dp; | |
| 591 object *args; | |
| 592 { | |
| 593 object *s; | |
| 594 int a; | |
| 595 if (!getstrintarg(args, &s, &a)) | |
| 596 return NULL; | |
| 597 return newintobject( | |
| 598 (long)wtextbreak(getstringvalue(s), (int)getstringsize(s), a)); | |
| 599 } | |
| 600 | |
|
171
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
601 static object * |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
602 drawing_setfont(self, args) |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
603 drawingobject *self; |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
604 object *args; |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
605 { |
|
184
1b08df41587b
More flexible font setting (mainly for the Mac).
Guido van Rossum <guido@python.org>
parents:
171
diff
changeset
|
606 object *font, *style; |
|
1b08df41587b
More flexible font setting (mainly for the Mac).
Guido van Rossum <guido@python.org>
parents:
171
diff
changeset
|
607 int size; |
|
1b08df41587b
More flexible font setting (mainly for the Mac).
Guido van Rossum <guido@python.org>
parents:
171
diff
changeset
|
608 if (args == NULL) { |
|
1b08df41587b
More flexible font setting (mainly for the Mac).
Guido van Rossum <guido@python.org>
parents:
171
diff
changeset
|
609 err_badarg(); |
|
1b08df41587b
More flexible font setting (mainly for the Mac).
Guido van Rossum <guido@python.org>
parents:
171
diff
changeset
|
610 return NULL; |
|
1b08df41587b
More flexible font setting (mainly for the Mac).
Guido van Rossum <guido@python.org>
parents:
171
diff
changeset
|
611 } |
|
1b08df41587b
More flexible font setting (mainly for the Mac).
Guido van Rossum <guido@python.org>
parents:
171
diff
changeset
|
612 if (is_stringobject(args)) { |
|
1b08df41587b
More flexible font setting (mainly for the Mac).
Guido van Rossum <guido@python.org>
parents:
171
diff
changeset
|
613 font = args; |
|
1b08df41587b
More flexible font setting (mainly for the Mac).
Guido van Rossum <guido@python.org>
parents:
171
diff
changeset
|
614 style = NULL; |
|
1b08df41587b
More flexible font setting (mainly for the Mac).
Guido van Rossum <guido@python.org>
parents:
171
diff
changeset
|
615 size = 0; |
|
1b08df41587b
More flexible font setting (mainly for the Mac).
Guido van Rossum <guido@python.org>
parents:
171
diff
changeset
|
616 } |
|
1b08df41587b
More flexible font setting (mainly for the Mac).
Guido van Rossum <guido@python.org>
parents:
171
diff
changeset
|
617 else if (is_tupleobject(args)) { |
|
1b08df41587b
More flexible font setting (mainly for the Mac).
Guido van Rossum <guido@python.org>
parents:
171
diff
changeset
|
618 int n = gettuplesize(args); |
|
1b08df41587b
More flexible font setting (mainly for the Mac).
Guido van Rossum <guido@python.org>
parents:
171
diff
changeset
|
619 if (n == 2) { |
|
1b08df41587b
More flexible font setting (mainly for the Mac).
Guido van Rossum <guido@python.org>
parents:
171
diff
changeset
|
620 if (!getstrintarg(args, &font, &size)) |
|
1b08df41587b
More flexible font setting (mainly for the Mac).
Guido van Rossum <guido@python.org>
parents:
171
diff
changeset
|
621 return NULL; |
|
1b08df41587b
More flexible font setting (mainly for the Mac).
Guido van Rossum <guido@python.org>
parents:
171
diff
changeset
|
622 style = NULL; |
|
1b08df41587b
More flexible font setting (mainly for the Mac).
Guido van Rossum <guido@python.org>
parents:
171
diff
changeset
|
623 } |
|
1b08df41587b
More flexible font setting (mainly for the Mac).
Guido van Rossum <guido@python.org>
parents:
171
diff
changeset
|
624 else if (!getstrstrintarg(args, &font, &style, &size)) |
|
1b08df41587b
More flexible font setting (mainly for the Mac).
Guido van Rossum <guido@python.org>
parents:
171
diff
changeset
|
625 return NULL; |
|
1b08df41587b
More flexible font setting (mainly for the Mac).
Guido van Rossum <guido@python.org>
parents:
171
diff
changeset
|
626 } |
|
1b08df41587b
More flexible font setting (mainly for the Mac).
Guido van Rossum <guido@python.org>
parents:
171
diff
changeset
|
627 else { |
|
1b08df41587b
More flexible font setting (mainly for the Mac).
Guido van Rossum <guido@python.org>
parents:
171
diff
changeset
|
628 err_badarg(); |
|
171
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
629 return NULL; |
|
184
1b08df41587b
More flexible font setting (mainly for the Mac).
Guido van Rossum <guido@python.org>
parents:
171
diff
changeset
|
630 } |
|
252
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
631 wsetfont(getstringvalue(font)); |
|
184
1b08df41587b
More flexible font setting (mainly for the Mac).
Guido van Rossum <guido@python.org>
parents:
171
diff
changeset
|
632 if (style != NULL) { |
|
1b08df41587b
More flexible font setting (mainly for the Mac).
Guido van Rossum <guido@python.org>
parents:
171
diff
changeset
|
633 switch (*getstringvalue(style)) { |
|
1b08df41587b
More flexible font setting (mainly for the Mac).
Guido van Rossum <guido@python.org>
parents:
171
diff
changeset
|
634 case 'b': |
|
1b08df41587b
More flexible font setting (mainly for the Mac).
Guido van Rossum <guido@python.org>
parents:
171
diff
changeset
|
635 wsetbold(); |
|
1b08df41587b
More flexible font setting (mainly for the Mac).
Guido van Rossum <guido@python.org>
parents:
171
diff
changeset
|
636 break; |
|
1b08df41587b
More flexible font setting (mainly for the Mac).
Guido van Rossum <guido@python.org>
parents:
171
diff
changeset
|
637 case 'i': |
|
1b08df41587b
More flexible font setting (mainly for the Mac).
Guido van Rossum <guido@python.org>
parents:
171
diff
changeset
|
638 wsetitalic(); |
|
1b08df41587b
More flexible font setting (mainly for the Mac).
Guido van Rossum <guido@python.org>
parents:
171
diff
changeset
|
639 break; |
|
1b08df41587b
More flexible font setting (mainly for the Mac).
Guido van Rossum <guido@python.org>
parents:
171
diff
changeset
|
640 case 'o': |
|
1b08df41587b
More flexible font setting (mainly for the Mac).
Guido van Rossum <guido@python.org>
parents:
171
diff
changeset
|
641 wsetbolditalic(); |
|
1b08df41587b
More flexible font setting (mainly for the Mac).
Guido van Rossum <guido@python.org>
parents:
171
diff
changeset
|
642 break; |
|
1b08df41587b
More flexible font setting (mainly for the Mac).
Guido van Rossum <guido@python.org>
parents:
171
diff
changeset
|
643 case 'u': |
|
1b08df41587b
More flexible font setting (mainly for the Mac).
Guido van Rossum <guido@python.org>
parents:
171
diff
changeset
|
644 wsetunderline(); |
|
1b08df41587b
More flexible font setting (mainly for the Mac).
Guido van Rossum <guido@python.org>
parents:
171
diff
changeset
|
645 break; |
|
1b08df41587b
More flexible font setting (mainly for the Mac).
Guido van Rossum <guido@python.org>
parents:
171
diff
changeset
|
646 default: |
|
1b08df41587b
More flexible font setting (mainly for the Mac).
Guido van Rossum <guido@python.org>
parents:
171
diff
changeset
|
647 wsetplain(); |
|
1b08df41587b
More flexible font setting (mainly for the Mac).
Guido van Rossum <guido@python.org>
parents:
171
diff
changeset
|
648 break; |
|
1b08df41587b
More flexible font setting (mainly for the Mac).
Guido van Rossum <guido@python.org>
parents:
171
diff
changeset
|
649 } |
|
1b08df41587b
More flexible font setting (mainly for the Mac).
Guido van Rossum <guido@python.org>
parents:
171
diff
changeset
|
650 } |
|
1b08df41587b
More flexible font setting (mainly for the Mac).
Guido van Rossum <guido@python.org>
parents:
171
diff
changeset
|
651 if (size != 0) |
|
1b08df41587b
More flexible font setting (mainly for the Mac).
Guido van Rossum <guido@python.org>
parents:
171
diff
changeset
|
652 wsetsize(size); |
|
171
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
653 INCREF(None); |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
654 return None; |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
655 } |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
656 |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
657 static object * |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
658 drawing_getbgcolor(self, args) |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
659 object *self; |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
660 object *args; |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
661 { |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
662 if (!getnoarg(args)) |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
663 return NULL; |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
664 return newintobject((long)wgetbgcolor()); |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
665 } |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
666 |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
667 static object * |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
668 drawing_getfgcolor(self, args) |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
669 object *self; |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
670 object *args; |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
671 { |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
672 if (!getnoarg(args)) |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
673 return NULL; |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
674 return newintobject((long)wgetfgcolor()); |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
675 } |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
676 |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
677 static object * |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
678 drawing_setbgcolor(self, args) |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
679 object *self; |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
680 object *args; |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
681 { |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
682 long color; |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
683 if (!getlongarg(args, &color)) |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
684 return NULL; |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
685 wsetbgcolor((COLOR)color); |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
686 INCREF(None); |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
687 return None; |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
688 } |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
689 |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
690 static object * |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
691 drawing_setfgcolor(self, args) |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
692 object *self; |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
693 object *args; |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
694 { |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
695 long color; |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
696 if (!getlongarg(args, &color)) |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
697 return NULL; |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
698 wsetfgcolor((COLOR)color); |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
699 INCREF(None); |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
700 return None; |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
701 } |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
702 |
| 6 | 703 static struct methodlist drawing_methods[] = { |
| 704 {"box", drawing_box}, | |
| 705 {"circle", drawing_circle}, | |
| 706 {"cliprect", drawing_cliprect}, | |
| 707 {"elarc", drawing_elarc}, | |
| 708 {"erase", drawing_erase}, | |
| 244 | 709 {"fillcircle", drawing_fillcircle}, |
|
207
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
710 {"fillelarc", drawing_fillelarc}, |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
711 {"fillpoly", drawing_fillpoly}, |
| 6 | 712 {"invert", drawing_invert}, |
| 713 {"line", drawing_line}, | |
| 714 {"noclip", drawing_noclip}, | |
| 715 {"paint", drawing_paint}, | |
|
207
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
716 {"poly", drawing_poly}, |
| 6 | 717 {"shade", drawing_shade}, |
| 718 {"text", drawing_text}, | |
| 244 | 719 {"xorcircle", drawing_xorcircle}, |
| 720 {"xorelarc", drawing_xorelarc}, | |
| 6 | 721 {"xorline", drawing_xorline}, |
| 244 | 722 {"xorpoly", drawing_xorpoly}, |
| 6 | 723 |
| 724 /* Text measuring methods: */ | |
| 725 {"baseline", drawing_baseline}, | |
| 726 {"lineheight", drawing_lineheight}, | |
| 727 {"textbreak", drawing_textbreak}, | |
| 728 {"textwidth", drawing_textwidth}, | |
|
171
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
729 |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
730 /* Font setting methods: */ |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
731 {"setfont", drawing_setfont}, |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
732 |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
733 /* Color methods: */ |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
734 {"getbgcolor", drawing_getbgcolor}, |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
735 {"getfgcolor", drawing_getfgcolor}, |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
736 {"setbgcolor", drawing_setbgcolor}, |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
737 {"setfgcolor", drawing_setfgcolor}, |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
738 |
| 6 | 739 {NULL, NULL} /* sentinel */ |
| 740 }; | |
| 741 | |
| 742 static object * | |
| 743 drawing_getattr(wp, name) | |
| 744 drawingobject *wp; | |
| 745 char *name; | |
| 746 { | |
| 747 return findmethod(drawing_methods, (object *)wp, name); | |
| 748 } | |
| 749 | |
|
233
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
750 typeobject Drawingtype = { |
| 6 | 751 OB_HEAD_INIT(&Typetype) |
| 752 0, /*ob_size*/ | |
| 753 "drawing", /*tp_name*/ | |
| 754 sizeof(drawingobject), /*tp_size*/ | |
| 755 0, /*tp_itemsize*/ | |
| 756 /* methods */ | |
| 757 drawing_dealloc, /*tp_dealloc*/ | |
| 758 0, /*tp_print*/ | |
| 759 drawing_getattr, /*tp_getattr*/ | |
| 760 0, /*tp_setattr*/ | |
| 761 0, /*tp_compare*/ | |
| 762 0, /*tp_repr*/ | |
| 763 }; | |
| 764 | |
| 765 | |
| 766 /* Text(edit) objects */ | |
| 767 | |
| 768 typedef struct { | |
| 769 OB_HEAD | |
| 770 TEXTEDIT *t_text; | |
| 771 windowobject *t_ref; | |
| 772 object *t_attr; /* Attributes dictionary */ | |
| 773 } textobject; | |
| 774 | |
| 775 extern typeobject Texttype; /* Really static, forward */ | |
| 776 | |
| 777 static textobject * | |
| 778 newtextobject(wp, left, top, right, bottom) | |
| 779 windowobject *wp; | |
| 780 int left, top, right, bottom; | |
| 781 { | |
| 782 textobject *tp; | |
| 783 tp = NEWOBJ(textobject, &Texttype); | |
| 784 if (tp == NULL) | |
| 785 return NULL; | |
| 786 tp->t_attr = NULL; | |
| 787 INCREF(wp); | |
| 788 tp->t_ref = wp; | |
| 789 tp->t_text = tecreate(wp->w_win, left, top, right, bottom); | |
| 790 if (tp->t_text == NULL) { | |
| 791 DECREF(tp); | |
| 792 return (textobject *) err_nomem(); | |
| 793 } | |
| 794 return tp; | |
| 795 } | |
| 796 | |
| 797 /* Text(edit) methods */ | |
| 798 | |
| 799 static void | |
| 800 text_dealloc(tp) | |
| 801 textobject *tp; | |
| 802 { | |
| 803 if (tp->t_text != NULL) | |
| 804 tefree(tp->t_text); | |
| 805 if (tp->t_attr != NULL) | |
| 806 DECREF(tp->t_attr); | |
| 807 DECREF(tp->t_ref); | |
| 808 DEL(tp); | |
| 809 } | |
| 810 | |
| 811 static object * | |
| 812 text_arrow(self, args) | |
| 813 textobject *self; | |
| 814 object *args; | |
| 815 { | |
| 816 int code; | |
| 817 if (!getintarg(args, &code)) | |
| 818 return NULL; | |
| 819 tearrow(self->t_text, code); | |
| 820 INCREF(None); | |
| 821 return None; | |
| 822 } | |
| 823 | |
| 824 static object * | |
| 825 text_draw(self, args) | |
| 826 textobject *self; | |
| 827 object *args; | |
| 828 { | |
| 829 register TEXTEDIT *tp = self->t_text; | |
| 830 int a[4]; | |
| 831 int left, top, right, bottom; | |
| 832 if (!getrectarg(args, a)) | |
| 833 return NULL; | |
| 834 if (Drawing != NULL) { | |
|
171
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
835 err_setstr(RuntimeError, "already drawing"); |
| 6 | 836 return NULL; |
| 837 } | |
| 838 /* Clip to text area and ignore if area is empty */ | |
| 839 left = tegetleft(tp); | |
| 840 top = tegettop(tp); | |
| 841 right = tegetright(tp); | |
| 842 bottom = tegetbottom(tp); | |
| 843 if (a[0] < left) a[0] = left; | |
| 844 if (a[1] < top) a[1] = top; | |
| 845 if (a[2] > right) a[2] = right; | |
| 846 if (a[3] > bottom) a[3] = bottom; | |
| 847 if (a[0] < a[2] && a[1] < a[3]) { | |
| 848 wbegindrawing(self->t_ref->w_win); | |
| 849 tedrawnew(tp, a[0], a[1], a[2], a[3]); | |
| 850 wenddrawing(self->t_ref->w_win); | |
| 851 } | |
| 852 INCREF(None); | |
| 853 return None; | |
| 854 } | |
| 855 | |
| 856 static object * | |
| 857 text_event(self, args) | |
| 858 textobject *self; | |
| 859 object *args; | |
| 860 { | |
| 861 register TEXTEDIT *tp = self->t_text; | |
| 862 EVENT e; | |
| 863 if (!geteventarg(args, &e)) | |
| 864 return NULL; | |
| 865 if (e.type == WE_MOUSE_DOWN) { | |
|
137
82ef94b8b902
Add getdefwinpos, getdefwinsize;
Guido van Rossum <guido@python.org>
parents:
114
diff
changeset
|
866 /* Cheat at the margins */ |
|
82ef94b8b902
Add getdefwinpos, getdefwinsize;
Guido van Rossum <guido@python.org>
parents:
114
diff
changeset
|
867 int width, height; |
|
82ef94b8b902
Add getdefwinpos, getdefwinsize;
Guido van Rossum <guido@python.org>
parents:
114
diff
changeset
|
868 wgetdocsize(e.window, &width, &height); |
| 6 | 869 if (e.u.where.h < 0 && tegetleft(tp) == 0) |
| 870 e.u.where.h = 0; | |
|
137
82ef94b8b902
Add getdefwinpos, getdefwinsize;
Guido van Rossum <guido@python.org>
parents:
114
diff
changeset
|
871 else if (e.u.where.h > width && tegetright(tp) == width) |
|
82ef94b8b902
Add getdefwinpos, getdefwinsize;
Guido van Rossum <guido@python.org>
parents:
114
diff
changeset
|
872 e.u.where.h = width; |
|
82ef94b8b902
Add getdefwinpos, getdefwinsize;
Guido van Rossum <guido@python.org>
parents:
114
diff
changeset
|
873 if (e.u.where.v < 0 && tegettop(tp) == 0) |
|
82ef94b8b902
Add getdefwinpos, getdefwinsize;
Guido van Rossum <guido@python.org>
parents:
114
diff
changeset
|
874 e.u.where.v = 0; |
|
82ef94b8b902
Add getdefwinpos, getdefwinsize;
Guido van Rossum <guido@python.org>
parents:
114
diff
changeset
|
875 else if (e.u.where.v > height && tegetright(tp) == height) |
|
82ef94b8b902
Add getdefwinpos, getdefwinsize;
Guido van Rossum <guido@python.org>
parents:
114
diff
changeset
|
876 e.u.where.v = height; |
| 6 | 877 } |
| 878 return newintobject((long) teevent(tp, &e)); | |
| 879 } | |
| 880 | |
| 881 static object * | |
| 882 text_getfocus(self, args) | |
| 883 textobject *self; | |
| 884 object *args; | |
| 885 { | |
| 886 if (!getnoarg(args)) | |
| 887 return NULL; | |
| 888 return makepoint(tegetfoc1(self->t_text), tegetfoc2(self->t_text)); | |
| 889 } | |
| 890 | |
| 891 static object * | |
| 892 text_getfocustext(self, args) | |
| 893 textobject *self; | |
| 894 object *args; | |
| 895 { | |
| 896 int f1, f2; | |
| 897 char *text; | |
| 898 if (!getnoarg(args)) | |
| 899 return NULL; | |
| 900 f1 = tegetfoc1(self->t_text); | |
| 901 f2 = tegetfoc2(self->t_text); | |
| 902 text = tegettext(self->t_text); | |
| 903 return newsizedstringobject(text + f1, f2-f1); | |
| 904 } | |
| 905 | |
| 906 static object * | |
| 907 text_getrect(self, args) | |
| 908 textobject *self; | |
| 909 object *args; | |
| 910 { | |
| 911 if (!getnoarg(args)) | |
| 912 return NULL; | |
| 913 return makerect(tegetleft(self->t_text), | |
| 914 tegettop(self->t_text), | |
| 915 tegetright(self->t_text), | |
| 916 tegetbottom(self->t_text)); | |
| 917 } | |
| 918 | |
| 919 static object * | |
| 920 text_gettext(self, args) | |
| 921 textobject *self; | |
| 922 object *args; | |
| 923 { | |
| 924 if (!getnoarg(args)) | |
| 925 return NULL; | |
| 926 return newsizedstringobject(tegettext(self->t_text), | |
| 927 tegetlen(self->t_text)); | |
| 928 } | |
| 929 | |
| 930 static object * | |
| 931 text_move(self, args) | |
| 932 textobject *self; | |
| 933 object *args; | |
| 934 { | |
| 935 int a[4]; | |
| 936 if (!getrectarg(args, a)) | |
| 937 return NULL; | |
| 938 temovenew(self->t_text, a[0], a[1], a[2], a[3]); | |
| 939 INCREF(None); | |
| 940 return None; | |
| 941 } | |
| 942 | |
| 943 static object * | |
|
248
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
944 text_replace(self, args) |
|
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
945 textobject *self; |
|
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
946 object *args; |
|
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
947 { |
|
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
948 object *text; |
|
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
949 if (!getstrarg(args, &text)) |
|
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
950 return NULL; |
|
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
951 tereplace(self->t_text, getstringvalue(text)); |
|
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
952 INCREF(None); |
|
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
953 return None; |
|
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
954 } |
|
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
955 |
|
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
956 static object * |
|
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
957 text_setactive(self, args) |
|
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
958 textobject *self; |
|
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
959 object *args; |
|
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
960 { |
|
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
961 int flag; |
|
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
962 if (!getintarg(args, &flag)) |
|
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
963 return NULL; |
|
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
964 tesetactive(self->t_text, flag); |
|
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
965 INCREF(None); |
|
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
966 return None; |
|
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
967 } |
|
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
968 |
|
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
969 static object * |
| 6 | 970 text_setfocus(self, args) |
| 971 textobject *self; | |
| 972 object *args; | |
| 973 { | |
| 974 int a[2]; | |
| 975 if (!getpointarg(args, a)) | |
| 976 return NULL; | |
| 977 tesetfocus(self->t_text, a[0], a[1]); | |
| 978 INCREF(None); | |
| 979 return None; | |
| 980 } | |
| 981 | |
| 982 static object * | |
|
233
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
983 text_settext(self, args) |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
984 textobject *self; |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
985 object *args; |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
986 { |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
987 object *text; |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
988 char *buf; |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
989 int size; |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
990 if (!getstrarg(args, &text)) |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
991 return NULL; |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
992 size = getstringsize(text); |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
993 if ((buf = NEW(char, size)) == NULL) { |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
994 err_set(MemoryError); |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
995 return NULL; |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
996 } |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
997 memcpy(buf, getstringvalue(text), size); |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
998 tesetbuf(self->t_text, buf, size); /* Becomes owner of buffer */ |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
999 INCREF(None); |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
1000 return None; |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
1001 } |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
1002 |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
1003 static object * |
|
248
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
1004 text_setview(self, args) |
| 6 | 1005 textobject *self; |
| 1006 object *args; | |
| 1007 { | |
|
248
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
1008 int a[4]; |
|
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
1009 if (args == None) |
|
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
1010 tenoview(self->t_text); |
|
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
1011 else { |
|
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
1012 if (!getrectarg(args, a)) |
|
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
1013 return NULL; |
|
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
1014 tesetview(self->t_text, a[0], a[1], a[2], a[3]); |
|
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
1015 } |
| 6 | 1016 INCREF(None); |
| 1017 return None; | |
| 1018 } | |
| 1019 | |
| 1020 static struct methodlist text_methods[] = { | |
| 1021 "arrow", text_arrow, | |
| 1022 "draw", text_draw, | |
| 1023 "event", text_event, | |
| 1024 "getfocus", text_getfocus, | |
| 1025 "getfocustext", text_getfocustext, | |
| 1026 "getrect", text_getrect, | |
| 1027 "gettext", text_gettext, | |
| 1028 "move", text_move, | |
| 1029 "replace", text_replace, | |
|
248
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
1030 "setactive", text_setactive, |
| 6 | 1031 "setfocus", text_setfocus, |
|
233
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
1032 "settext", text_settext, |
|
248
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
1033 "setview", text_setview, |
| 6 | 1034 {NULL, NULL} /* sentinel */ |
| 1035 }; | |
| 1036 | |
| 1037 static object * | |
| 1038 text_getattr(tp, name) | |
| 1039 textobject *tp; | |
| 1040 char *name; | |
| 1041 { | |
|
397
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1042 object *v = NULL; |
|
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1043 if (strcmp(name, "__dict__") == 0) { |
|
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1044 v = tp->t_attr; |
|
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1045 if (v == NULL) |
|
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1046 v = None; |
|
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1047 } |
|
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1048 else if (tp->t_attr != NULL) { |
|
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1049 v = dictlookup(tp->t_attr, name); |
|
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1050 } |
|
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1051 if (v != NULL) { |
|
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1052 INCREF(v); |
|
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1053 return v; |
| 6 | 1054 } |
| 1055 return findmethod(text_methods, (object *)tp, name); | |
| 1056 } | |
| 1057 | |
| 1058 static int | |
| 1059 text_setattr(tp, name, v) | |
| 1060 textobject *tp; | |
| 1061 char *name; | |
| 1062 object *v; | |
| 1063 { | |
| 1064 if (tp->t_attr == NULL) { | |
| 1065 tp->t_attr = newdictobject(); | |
| 1066 if (tp->t_attr == NULL) | |
| 1067 return -1; | |
| 1068 } | |
| 1069 if (v == NULL) | |
| 1070 return dictremove(tp->t_attr, name); | |
| 1071 else | |
| 1072 return dictinsert(tp->t_attr, name, v); | |
| 1073 } | |
| 1074 | |
|
233
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
1075 typeobject Texttype = { |
| 6 | 1076 OB_HEAD_INIT(&Typetype) |
| 1077 0, /*ob_size*/ | |
| 1078 "textedit", /*tp_name*/ | |
| 1079 sizeof(textobject), /*tp_size*/ | |
| 1080 0, /*tp_itemsize*/ | |
| 1081 /* methods */ | |
| 1082 text_dealloc, /*tp_dealloc*/ | |
| 1083 0, /*tp_print*/ | |
| 1084 text_getattr, /*tp_getattr*/ | |
| 1085 text_setattr, /*tp_setattr*/ | |
| 1086 0, /*tp_compare*/ | |
| 1087 0, /*tp_repr*/ | |
| 1088 }; | |
| 1089 | |
| 1090 | |
| 1091 /* Menu objects */ | |
| 1092 | |
|
142
c7ea60491e68
Call winit() here instead of in main initialization.
Guido van Rossum <guido@python.org>
parents:
137
diff
changeset
|
1093 #define IDOFFSET 10 /* Menu IDs we use start here */ |
|
207
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
1094 #define MAXNMENU 200 /* Max #menus we allow */ |
|
142
c7ea60491e68
Call winit() here instead of in main initialization.
Guido van Rossum <guido@python.org>
parents:
137
diff
changeset
|
1095 static menuobject *menulist[MAXNMENU]; |
| 6 | 1096 |
| 1097 static menuobject * | |
| 1098 newmenuobject(title) | |
| 1099 object *title; | |
| 1100 { | |
| 1101 int id; | |
| 1102 MENU *menu; | |
| 1103 menuobject *mp; | |
|
142
c7ea60491e68
Call winit() here instead of in main initialization.
Guido van Rossum <guido@python.org>
parents:
137
diff
changeset
|
1104 for (id = 0; id < MAXNMENU; id++) { |
| 6 | 1105 if (menulist[id] == NULL) |
| 1106 break; | |
| 1107 } | |
|
207
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
1108 if (id >= MAXNMENU) { |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
1109 err_setstr(MemoryError, "creating too many menus"); |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
1110 return NULL; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
1111 } |
|
142
c7ea60491e68
Call winit() here instead of in main initialization.
Guido van Rossum <guido@python.org>
parents:
137
diff
changeset
|
1112 menu = wmenucreate(id + IDOFFSET, getstringvalue(title)); |
| 6 | 1113 if (menu == NULL) |
| 1114 return (menuobject *) err_nomem(); | |
| 1115 mp = NEWOBJ(menuobject, &Menutype); | |
| 1116 if (mp != NULL) { | |
| 1117 mp->m_menu = menu; | |
|
142
c7ea60491e68
Call winit() here instead of in main initialization.
Guido van Rossum <guido@python.org>
parents:
137
diff
changeset
|
1118 mp->m_id = id + IDOFFSET; |
| 6 | 1119 mp->m_attr = NULL; |
| 1120 menulist[id] = mp; | |
| 1121 } | |
| 1122 else | |
| 1123 wmenudelete(menu); | |
| 1124 return mp; | |
| 1125 } | |
| 1126 | |
| 1127 /* Menu methods */ | |
| 1128 | |
| 1129 static void | |
| 1130 menu_dealloc(mp) | |
| 1131 menuobject *mp; | |
| 1132 { | |
| 1133 | |
|
142
c7ea60491e68
Call winit() here instead of in main initialization.
Guido van Rossum <guido@python.org>
parents:
137
diff
changeset
|
1134 int id = mp->m_id - IDOFFSET; |
|
c7ea60491e68
Call winit() here instead of in main initialization.
Guido van Rossum <guido@python.org>
parents:
137
diff
changeset
|
1135 if (id >= 0 && id < MAXNMENU && menulist[id] == mp) { |
| 6 | 1136 menulist[id] = NULL; |
| 1137 } | |
| 1138 wmenudelete(mp->m_menu); | |
| 1139 if (mp->m_attr != NULL) | |
| 1140 DECREF(mp->m_attr); | |
| 1141 DEL(mp); | |
| 1142 } | |
| 1143 | |
| 1144 static object * | |
| 1145 menu_additem(self, args) | |
| 1146 menuobject *self; | |
| 1147 object *args; | |
| 1148 { | |
| 1149 object *text; | |
| 1150 int shortcut; | |
| 1151 if (is_tupleobject(args)) { | |
| 1152 object *v; | |
| 1153 if (!getstrstrarg(args, &text, &v)) | |
| 1154 return NULL; | |
| 1155 if (getstringsize(v) != 1) { | |
| 1156 err_badarg(); | |
| 1157 return NULL; | |
| 1158 } | |
| 1159 shortcut = *getstringvalue(v) & 0xff; | |
| 1160 } | |
| 1161 else { | |
| 1162 if (!getstrarg(args, &text)) | |
| 1163 return NULL; | |
| 1164 shortcut = -1; | |
| 1165 } | |
| 1166 wmenuadditem(self->m_menu, getstringvalue(text), shortcut); | |
| 1167 INCREF(None); | |
| 1168 return None; | |
| 1169 } | |
| 1170 | |
| 1171 static object * | |
| 1172 menu_setitem(self, args) | |
| 1173 menuobject *self; | |
| 1174 object *args; | |
| 1175 { | |
| 1176 int index; | |
| 1177 object *text; | |
| 1178 if (!getintstrarg(args, &index, &text)) | |
| 1179 return NULL; | |
| 1180 wmenusetitem(self->m_menu, index, getstringvalue(text)); | |
| 1181 INCREF(None); | |
| 1182 return None; | |
| 1183 } | |
| 1184 | |
| 1185 static object * | |
| 1186 menu_enable(self, args) | |
| 1187 menuobject *self; | |
| 1188 object *args; | |
| 1189 { | |
| 1190 int index; | |
| 1191 int flag; | |
| 1192 if (!getintintarg(args, &index, &flag)) | |
| 1193 return NULL; | |
| 1194 wmenuenable(self->m_menu, index, flag); | |
| 1195 INCREF(None); | |
| 1196 return None; | |
| 1197 } | |
| 1198 | |
| 1199 static object * | |
| 1200 menu_check(self, args) | |
| 1201 menuobject *self; | |
| 1202 object *args; | |
| 1203 { | |
| 1204 int index; | |
| 1205 int flag; | |
| 1206 if (!getintintarg(args, &index, &flag)) | |
| 1207 return NULL; | |
| 1208 wmenucheck(self->m_menu, index, flag); | |
| 1209 INCREF(None); | |
| 1210 return None; | |
| 1211 } | |
| 1212 | |
| 1213 static struct methodlist menu_methods[] = { | |
| 1214 "additem", menu_additem, | |
| 1215 "setitem", menu_setitem, | |
| 1216 "enable", menu_enable, | |
| 1217 "check", menu_check, | |
| 1218 {NULL, NULL} /* sentinel */ | |
| 1219 }; | |
| 1220 | |
| 1221 static object * | |
| 1222 menu_getattr(mp, name) | |
| 1223 menuobject *mp; | |
| 1224 char *name; | |
| 1225 { | |
|
397
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1226 object *v = NULL; |
|
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1227 if (strcmp(name, "__dict__") == 0) { |
|
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1228 v = mp->m_attr; |
|
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1229 if (v == NULL) |
|
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1230 v = None; |
|
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1231 } |
|
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1232 else if (mp->m_attr != NULL) { |
|
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1233 v = dictlookup(mp->m_attr, name); |
|
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1234 } |
|
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1235 if (v != NULL) { |
|
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1236 INCREF(v); |
|
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1237 return v; |
| 6 | 1238 } |
| 1239 return findmethod(menu_methods, (object *)mp, name); | |
| 1240 } | |
| 1241 | |
| 1242 static int | |
| 1243 menu_setattr(mp, name, v) | |
| 1244 menuobject *mp; | |
| 1245 char *name; | |
| 1246 object *v; | |
| 1247 { | |
| 1248 if (mp->m_attr == NULL) { | |
| 1249 mp->m_attr = newdictobject(); | |
| 1250 if (mp->m_attr == NULL) | |
| 1251 return -1; | |
| 1252 } | |
| 1253 if (v == NULL) | |
| 1254 return dictremove(mp->m_attr, name); | |
| 1255 else | |
| 1256 return dictinsert(mp->m_attr, name, v); | |
| 1257 } | |
| 1258 | |
|
233
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
1259 typeobject Menutype = { |
| 6 | 1260 OB_HEAD_INIT(&Typetype) |
| 1261 0, /*ob_size*/ | |
| 1262 "menu", /*tp_name*/ | |
| 1263 sizeof(menuobject), /*tp_size*/ | |
| 1264 0, /*tp_itemsize*/ | |
| 1265 /* methods */ | |
| 1266 menu_dealloc, /*tp_dealloc*/ | |
| 1267 0, /*tp_print*/ | |
| 1268 menu_getattr, /*tp_getattr*/ | |
| 1269 menu_setattr, /*tp_setattr*/ | |
| 1270 0, /*tp_compare*/ | |
| 1271 0, /*tp_repr*/ | |
| 1272 }; | |
| 1273 | |
| 1274 | |
| 1275 /* Windows */ | |
| 1276 | |
| 1277 #define MAXNWIN 50 | |
| 1278 static windowobject *windowlist[MAXNWIN]; | |
| 1279 | |
| 1280 /* Window methods */ | |
| 1281 | |
| 1282 static void | |
| 1283 window_dealloc(wp) | |
| 1284 windowobject *wp; | |
| 1285 { | |
| 1286 if (wp->w_win != NULL) { | |
| 1287 int tag = wgettag(wp->w_win); | |
| 1288 if (tag >= 0 && tag < MAXNWIN) | |
| 1289 windowlist[tag] = NULL; | |
| 1290 else | |
| 1291 fprintf(stderr, "XXX help! tag %d in window_dealloc\n", | |
| 1292 tag); | |
| 1293 wclose(wp->w_win); | |
| 1294 } | |
| 1295 DECREF(wp->w_title); | |
| 1296 if (wp->w_attr != NULL) | |
| 1297 DECREF(wp->w_attr); | |
| 1298 free((char *)wp); | |
| 1299 } | |
| 1300 | |
|
285
85bd7dac13f3
printobject now returns an error code
Guido van Rossum <guido@python.org>
parents:
252
diff
changeset
|
1301 static int |
| 6 | 1302 window_print(wp, fp, flags) |
| 1303 windowobject *wp; | |
| 1304 FILE *fp; | |
| 1305 int flags; | |
| 1306 { | |
| 1307 fprintf(fp, "<window titled '%s'>", getstringvalue(wp->w_title)); | |
|
285
85bd7dac13f3
printobject now returns an error code
Guido van Rossum <guido@python.org>
parents:
252
diff
changeset
|
1308 return 0; |
| 6 | 1309 } |
| 1310 | |
| 1311 static object * | |
| 1312 window_begindrawing(wp, args) | |
| 1313 windowobject *wp; | |
| 1314 object *args; | |
| 1315 { | |
| 1316 drawingobject *dp; | |
| 1317 if (!getnoarg(args)) | |
| 1318 return NULL; | |
| 1319 if (Drawing != NULL) { | |
| 1320 err_setstr(RuntimeError, "already drawing"); | |
| 1321 return NULL; | |
| 1322 } | |
| 1323 dp = NEWOBJ(drawingobject, &Drawingtype); | |
| 1324 if (dp == NULL) | |
| 1325 return NULL; | |
| 1326 Drawing = dp; | |
| 1327 INCREF(wp); | |
| 1328 dp->d_ref = wp; | |
| 1329 wbegindrawing(wp->w_win); | |
| 1330 return (object *)dp; | |
| 1331 } | |
| 1332 | |
| 1333 static object * | |
| 1334 window_change(wp, args) | |
| 1335 windowobject *wp; | |
| 1336 object *args; | |
| 1337 { | |
| 1338 int a[4]; | |
| 1339 if (!getrectarg(args, a)) | |
| 1340 return NULL; | |
| 1341 wchange(wp->w_win, a[0], a[1], a[2], a[3]); | |
| 1342 INCREF(None); | |
| 1343 return None; | |
| 1344 } | |
| 1345 | |
| 1346 static object * | |
| 1347 window_gettitle(wp, args) | |
| 1348 windowobject *wp; | |
| 1349 object *args; | |
| 1350 { | |
| 1351 if (!getnoarg(args)) | |
| 1352 return NULL; | |
| 1353 INCREF(wp->w_title); | |
| 1354 return wp->w_title; | |
| 1355 } | |
| 1356 | |
| 1357 static object * | |
|
233
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
1358 window_getwinpos(wp, args) |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
1359 windowobject *wp; |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
1360 object *args; |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
1361 { |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
1362 int h, v; |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
1363 if (!getnoarg(args)) |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
1364 return NULL; |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
1365 wgetwinpos(wp->w_win, &h, &v); |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
1366 return makepoint(h, v); |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
1367 } |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
1368 |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
1369 static object * |
| 6 | 1370 window_getwinsize(wp, args) |
| 1371 windowobject *wp; | |
| 1372 object *args; | |
| 1373 { | |
| 1374 int width, height; | |
| 1375 if (!getnoarg(args)) | |
| 1376 return NULL; | |
| 1377 wgetwinsize(wp->w_win, &width, &height); | |
| 1378 return makepoint(width, height); | |
| 1379 } | |
| 1380 | |
| 1381 static object * | |
| 1382 window_getdocsize(wp, args) | |
| 1383 windowobject *wp; | |
| 1384 object *args; | |
| 1385 { | |
| 1386 int width, height; | |
| 1387 if (!getnoarg(args)) | |
| 1388 return NULL; | |
| 1389 wgetdocsize(wp->w_win, &width, &height); | |
| 1390 return makepoint(width, height); | |
| 1391 } | |
| 1392 | |
| 1393 static object * | |
| 1394 window_getorigin(wp, args) | |
| 1395 windowobject *wp; | |
| 1396 object *args; | |
| 1397 { | |
| 1398 int width, height; | |
| 1399 if (!getnoarg(args)) | |
| 1400 return NULL; | |
| 1401 wgetorigin(wp->w_win, &width, &height); | |
| 1402 return makepoint(width, height); | |
| 1403 } | |
| 1404 | |
| 1405 static object * | |
| 1406 window_scroll(wp, args) | |
| 1407 windowobject *wp; | |
| 1408 object *args; | |
| 1409 { | |
| 1410 int a[6]; | |
| 1411 if (!getrectpointarg(args, a)) | |
| 1412 return NULL; | |
| 1413 wscroll(wp->w_win, a[0], a[1], a[2], a[3], a[4], a[5]); | |
| 1414 INCREF(None); | |
| 1415 return None; | |
| 1416 } | |
| 1417 | |
| 1418 static object * | |
| 1419 window_setdocsize(wp, args) | |
| 1420 windowobject *wp; | |
| 1421 object *args; | |
| 1422 { | |
| 1423 int a[2]; | |
| 1424 if (!getpointarg(args, a)) | |
| 1425 return NULL; | |
| 1426 wsetdocsize(wp->w_win, a[0], a[1]); | |
| 1427 INCREF(None); | |
| 1428 return None; | |
| 1429 } | |
| 1430 | |
| 1431 static object * | |
| 1432 window_setorigin(wp, args) | |
| 1433 windowobject *wp; | |
| 1434 object *args; | |
| 1435 { | |
| 1436 int a[2]; | |
| 1437 if (!getpointarg(args, a)) | |
| 1438 return NULL; | |
| 1439 wsetorigin(wp->w_win, a[0], a[1]); | |
| 1440 INCREF(None); | |
| 1441 return None; | |
| 1442 } | |
| 1443 | |
| 1444 static object * | |
| 1445 window_settitle(wp, args) | |
| 1446 windowobject *wp; | |
| 1447 object *args; | |
| 1448 { | |
| 1449 object *title; | |
| 1450 if (!getstrarg(args, &title)) | |
| 1451 return NULL; | |
| 1452 DECREF(wp->w_title); | |
| 1453 INCREF(title); | |
| 1454 wp->w_title = title; | |
| 1455 wsettitle(wp->w_win, getstringvalue(title)); | |
| 1456 INCREF(None); | |
| 1457 return None; | |
| 1458 } | |
| 1459 | |
| 1460 static object * | |
| 1461 window_show(wp, args) | |
| 1462 windowobject *wp; | |
| 1463 object *args; | |
| 1464 { | |
| 1465 int a[4]; | |
| 1466 if (!getrectarg(args, a)) | |
| 1467 return NULL; | |
| 1468 wshow(wp->w_win, a[0], a[1], a[2], a[3]); | |
| 1469 INCREF(None); | |
| 1470 return None; | |
| 1471 } | |
| 1472 | |
| 1473 static object * | |
| 1474 window_settimer(wp, args) | |
| 1475 windowobject *wp; | |
| 1476 object *args; | |
| 1477 { | |
| 1478 int a; | |
| 1479 if (!getintarg(args, &a)) | |
| 1480 return NULL; | |
| 1481 wsettimer(wp->w_win, a); | |
| 1482 INCREF(None); | |
| 1483 return None; | |
| 1484 } | |
| 1485 | |
| 1486 static object * | |
| 1487 window_menucreate(self, args) | |
| 1488 windowobject *self; | |
| 1489 object *args; | |
| 1490 { | |
| 1491 menuobject *mp; | |
| 1492 object *title; | |
| 1493 if (!getstrarg(args, &title)) | |
| 1494 return NULL; | |
| 1495 wmenusetdeflocal(1); | |
| 1496 mp = newmenuobject(title); | |
| 1497 if (mp == NULL) | |
| 1498 return NULL; | |
| 1499 wmenuattach(self->w_win, mp->m_menu); | |
| 1500 return (object *)mp; | |
| 1501 } | |
| 1502 | |
| 1503 static object * | |
| 1504 window_textcreate(self, args) | |
| 1505 windowobject *self; | |
| 1506 object *args; | |
| 1507 { | |
| 1508 textobject *tp; | |
| 1509 int a[4]; | |
| 1510 if (!getrectarg(args, a)) | |
| 1511 return NULL; | |
| 1512 return (object *) | |
| 1513 newtextobject(self, a[0], a[1], a[2], a[3]); | |
| 1514 } | |
| 1515 | |
|
51
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
1516 static object * |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
1517 window_setselection(self, args) |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
1518 windowobject *self; |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
1519 object *args; |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
1520 { |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
1521 int sel; |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
1522 object *str; |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
1523 int ok; |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
1524 if (!getintstrarg(args, &sel, &str)) |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
1525 return NULL; |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
1526 ok = wsetselection(self->w_win, sel, |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
1527 getstringvalue(str), (int)getstringsize(str)); |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
1528 return newintobject(ok); |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
1529 } |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
1530 |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
1531 static object * |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
1532 window_setwincursor(self, args) |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
1533 windowobject *self; |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
1534 object *args; |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
1535 { |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
1536 object *str; |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
1537 CURSOR *c; |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
1538 if (!getstrarg(args, &str)) |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
1539 return NULL; |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
1540 c = wfetchcursor(getstringvalue(str)); |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
1541 if (c == NULL) { |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
1542 err_setstr(RuntimeError, "no such cursor"); |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
1543 return NULL; |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
1544 } |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
1545 wsetwincursor(self->w_win, c); |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
1546 INCREF(None); |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
1547 return None; |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
1548 } |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
1549 |
|
325
baada20762b0
Added getxwindowin() method
Guido van Rossum <guido@python.org>
parents:
285
diff
changeset
|
1550 #ifdef CWI_HACKS |
|
baada20762b0
Added getxwindowin() method
Guido van Rossum <guido@python.org>
parents:
285
diff
changeset
|
1551 static object * |
|
baada20762b0
Added getxwindowin() method
Guido van Rossum <guido@python.org>
parents:
285
diff
changeset
|
1552 window_getxwindowid(self, args) |
|
baada20762b0
Added getxwindowin() method
Guido van Rossum <guido@python.org>
parents:
285
diff
changeset
|
1553 windowobject *self; |
|
baada20762b0
Added getxwindowin() method
Guido van Rossum <guido@python.org>
parents:
285
diff
changeset
|
1554 object *args; |
|
baada20762b0
Added getxwindowin() method
Guido van Rossum <guido@python.org>
parents:
285
diff
changeset
|
1555 { |
|
baada20762b0
Added getxwindowin() method
Guido van Rossum <guido@python.org>
parents:
285
diff
changeset
|
1556 long wid = wgetxwindowid(self->w_win); |
|
baada20762b0
Added getxwindowin() method
Guido van Rossum <guido@python.org>
parents:
285
diff
changeset
|
1557 return newintobject(wid); |
|
baada20762b0
Added getxwindowin() method
Guido van Rossum <guido@python.org>
parents:
285
diff
changeset
|
1558 } |
|
baada20762b0
Added getxwindowin() method
Guido van Rossum <guido@python.org>
parents:
285
diff
changeset
|
1559 #endif |
|
baada20762b0
Added getxwindowin() method
Guido van Rossum <guido@python.org>
parents:
285
diff
changeset
|
1560 |
| 6 | 1561 static struct methodlist window_methods[] = { |
| 1562 {"begindrawing",window_begindrawing}, | |
| 1563 {"change", window_change}, | |
| 1564 {"getdocsize", window_getdocsize}, | |
| 1565 {"getorigin", window_getorigin}, | |
| 1566 {"gettitle", window_gettitle}, | |
|
233
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
1567 {"getwinpos", window_getwinpos}, |
| 6 | 1568 {"getwinsize", window_getwinsize}, |
| 1569 {"menucreate", window_menucreate}, | |
| 1570 {"scroll", window_scroll}, | |
| 1571 {"setdocsize", window_setdocsize}, | |
| 1572 {"setorigin", window_setorigin}, | |
|
51
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
1573 {"setselection",window_setselection}, |
| 6 | 1574 {"settimer", window_settimer}, |
| 1575 {"settitle", window_settitle}, | |
|
207
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
1576 {"setwincursor",window_setwincursor}, |
| 6 | 1577 {"show", window_show}, |
| 1578 {"textcreate", window_textcreate}, | |
|
325
baada20762b0
Added getxwindowin() method
Guido van Rossum <guido@python.org>
parents:
285
diff
changeset
|
1579 #ifdef CWI_HACKS |
|
baada20762b0
Added getxwindowin() method
Guido van Rossum <guido@python.org>
parents:
285
diff
changeset
|
1580 {"getxwindowid",window_getxwindowid}, |
|
baada20762b0
Added getxwindowin() method
Guido van Rossum <guido@python.org>
parents:
285
diff
changeset
|
1581 #endif |
| 6 | 1582 {NULL, NULL} /* sentinel */ |
| 1583 }; | |
| 1584 | |
| 1585 static object * | |
| 1586 window_getattr(wp, name) | |
| 1587 windowobject *wp; | |
| 1588 char *name; | |
| 1589 { | |
|
397
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1590 object *v = NULL; |
|
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1591 if (strcmp(name, "__dict__") == 0) { |
|
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1592 v = wp->w_attr; |
|
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1593 if (v == NULL) |
|
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1594 v = None; |
|
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1595 } |
|
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1596 else if (wp->w_attr != NULL) { |
|
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1597 v = dictlookup(wp->w_attr, name); |
|
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1598 } |
|
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1599 if (v != NULL) { |
|
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1600 INCREF(v); |
|
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1601 return v; |
| 6 | 1602 } |
| 1603 return findmethod(window_methods, (object *)wp, name); | |
| 1604 } | |
| 1605 | |
| 1606 static int | |
| 1607 window_setattr(wp, name, v) | |
| 1608 windowobject *wp; | |
| 1609 char *name; | |
| 1610 object *v; | |
| 1611 { | |
| 1612 if (wp->w_attr == NULL) { | |
| 1613 wp->w_attr = newdictobject(); | |
| 1614 if (wp->w_attr == NULL) | |
| 1615 return -1; | |
| 1616 } | |
| 1617 if (v == NULL) | |
| 1618 return dictremove(wp->w_attr, name); | |
| 1619 else | |
| 1620 return dictinsert(wp->w_attr, name, v); | |
| 1621 } | |
| 1622 | |
|
233
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
1623 typeobject Windowtype = { |
| 6 | 1624 OB_HEAD_INIT(&Typetype) |
| 1625 0, /*ob_size*/ | |
| 1626 "window", /*tp_name*/ | |
| 1627 sizeof(windowobject), /*tp_size*/ | |
| 1628 0, /*tp_itemsize*/ | |
| 1629 /* methods */ | |
| 1630 window_dealloc, /*tp_dealloc*/ | |
| 1631 window_print, /*tp_print*/ | |
| 1632 window_getattr, /*tp_getattr*/ | |
| 1633 window_setattr, /*tp_setattr*/ | |
| 1634 0, /*tp_compare*/ | |
| 1635 0, /*tp_repr*/ | |
| 1636 }; | |
| 1637 | |
| 1638 /* Stdwin methods */ | |
| 1639 | |
| 1640 static object * | |
| 1641 stdwin_open(sw, args) | |
| 1642 object *sw; | |
| 1643 object *args; | |
| 1644 { | |
| 1645 int tag; | |
| 1646 object *title; | |
| 1647 windowobject *wp; | |
| 1648 if (!getstrarg(args, &title)) | |
| 1649 return NULL; | |
| 1650 for (tag = 0; tag < MAXNWIN; tag++) { | |
| 1651 if (windowlist[tag] == NULL) | |
| 1652 break; | |
| 1653 } | |
|
207
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
1654 if (tag >= MAXNWIN) { |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
1655 err_setstr(MemoryError, "creating too many windows"); |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
1656 return NULL; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
1657 } |
| 6 | 1658 wp = NEWOBJ(windowobject, &Windowtype); |
| 1659 if (wp == NULL) | |
| 1660 return NULL; | |
| 1661 INCREF(title); | |
| 1662 wp->w_title = title; | |
| 1663 wp->w_win = wopen(getstringvalue(title), (void (*)()) NULL); | |
| 1664 wp->w_attr = NULL; | |
| 1665 if (wp->w_win == NULL) { | |
| 1666 DECREF(wp); | |
| 1667 return NULL; | |
| 1668 } | |
| 1669 windowlist[tag] = wp; | |
| 1670 wsettag(wp->w_win, tag); | |
| 1671 return (object *)wp; | |
| 1672 } | |
| 1673 | |
| 1674 static object * | |
|
252
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
1675 window2object(win) |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
1676 WINDOW *win; |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
1677 { |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
1678 object *w; |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
1679 if (win == NULL) |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
1680 w = None; |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
1681 else { |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
1682 int tag = wgettag(win); |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
1683 if (tag < 0 || tag >= MAXNWIN || windowlist[tag] == NULL || |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
1684 windowlist[tag]->w_win != win) |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
1685 w = None; |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
1686 else |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
1687 w = (object *)windowlist[tag]; |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
1688 #ifdef sgi |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
1689 /* XXX Trap for unexplained weird bug */ |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
1690 if ((long)w == (long)0x80000001) { |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
1691 err_setstr(SystemError, |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
1692 "bad pointer in stdwin.getevent()"); |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
1693 return NULL; |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
1694 } |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
1695 #endif |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
1696 } |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
1697 INCREF(w); |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
1698 return w; |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
1699 } |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
1700 |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
1701 static object * |
|
114
1efb8ed6afd3
Added pollevent(); returns None if no event available.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
1702 stdwin_get_poll_event(poll, args) |
|
1efb8ed6afd3
Added pollevent(); returns None if no event available.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
1703 int poll; |
| 6 | 1704 object *args; |
| 1705 { | |
| 1706 EVENT e; | |
| 1707 object *v, *w; | |
| 1708 if (!getnoarg(args)) | |
| 1709 return NULL; | |
| 1710 if (Drawing != NULL) { | |
| 1711 err_setstr(RuntimeError, "cannot getevent() while drawing"); | |
| 1712 return NULL; | |
| 1713 } | |
|
252
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
1714 again: |
|
114
1efb8ed6afd3
Added pollevent(); returns None if no event available.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
1715 if (poll) { |
|
1efb8ed6afd3
Added pollevent(); returns None if no event available.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
1716 if (!wpollevent(&e)) { |
|
1efb8ed6afd3
Added pollevent(); returns None if no event available.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
1717 INCREF(None); |
|
1efb8ed6afd3
Added pollevent(); returns None if no event available.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
1718 return None; |
|
1efb8ed6afd3
Added pollevent(); returns None if no event available.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
1719 } |
|
1efb8ed6afd3
Added pollevent(); returns None if no event available.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
1720 } |
|
1efb8ed6afd3
Added pollevent(); returns None if no event available.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
1721 else |
|
1efb8ed6afd3
Added pollevent(); returns None if no event available.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
1722 wgetevent(&e); |
| 6 | 1723 if (e.type == WE_COMMAND && e.u.command == WC_CANCEL) { |
| 1724 /* Turn keyboard interrupts into exceptions */ | |
| 1725 err_set(KeyboardInterrupt); | |
| 1726 return NULL; | |
| 1727 } | |
|
65
a72c0a7dc993
Turn close commands into WE_CLOSE events.
Guido van Rossum <guido@python.org>
parents:
51
diff
changeset
|
1728 if (e.type == WE_COMMAND && e.u.command == WC_CLOSE) { |
|
a72c0a7dc993
Turn close commands into WE_CLOSE events.
Guido van Rossum <guido@python.org>
parents:
51
diff
changeset
|
1729 /* Turn WC_CLOSE commands into WE_CLOSE events */ |
|
a72c0a7dc993
Turn close commands into WE_CLOSE events.
Guido van Rossum <guido@python.org>
parents:
51
diff
changeset
|
1730 e.type = WE_CLOSE; |
|
a72c0a7dc993
Turn close commands into WE_CLOSE events.
Guido van Rossum <guido@python.org>
parents:
51
diff
changeset
|
1731 } |
| 6 | 1732 v = newtupleobject(3); |
| 1733 if (v == NULL) | |
| 1734 return NULL; | |
| 1735 if ((w = newintobject((long)e.type)) == NULL) { | |
| 1736 DECREF(v); | |
| 1737 return NULL; | |
| 1738 } | |
| 1739 settupleitem(v, 0, w); | |
|
252
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
1740 settupleitem(v, 1, window2object(e.window)); |
| 6 | 1741 switch (e.type) { |
| 1742 case WE_CHAR: | |
| 1743 { | |
| 1744 char c[1]; | |
| 1745 c[0] = e.u.character; | |
| 1746 w = newsizedstringobject(c, 1); | |
| 1747 } | |
| 1748 break; | |
| 1749 case WE_COMMAND: | |
| 1750 w = newintobject((long)e.u.command); | |
| 1751 break; | |
| 1752 case WE_DRAW: | |
| 1753 w = makerect(e.u.area.left, e.u.area.top, | |
| 1754 e.u.area.right, e.u.area.bottom); | |
| 1755 break; | |
| 1756 case WE_MOUSE_DOWN: | |
| 1757 case WE_MOUSE_MOVE: | |
| 1758 case WE_MOUSE_UP: | |
| 1759 w = makemouse(e.u.where.h, e.u.where.v, | |
| 1760 e.u.where.clicks, | |
| 1761 e.u.where.button, | |
| 1762 e.u.where.mask); | |
| 1763 break; | |
| 1764 case WE_MENU: | |
|
142
c7ea60491e68
Call winit() here instead of in main initialization.
Guido van Rossum <guido@python.org>
parents:
137
diff
changeset
|
1765 if (e.u.m.id >= IDOFFSET && e.u.m.id < IDOFFSET+MAXNMENU && |
|
c7ea60491e68
Call winit() here instead of in main initialization.
Guido van Rossum <guido@python.org>
parents:
137
diff
changeset
|
1766 menulist[e.u.m.id - IDOFFSET] != NULL) |
|
c7ea60491e68
Call winit() here instead of in main initialization.
Guido van Rossum <guido@python.org>
parents:
137
diff
changeset
|
1767 w = (object *)menulist[e.u.m.id - IDOFFSET]; |
|
252
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
1768 else { |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
1769 /* Ghost menu event. |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
1770 Can occur only on the Mac if another part |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
1771 of the aplication has installed a menu; |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
1772 like the THINK C console library. */ |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
1773 DECREF(v); |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
1774 goto again; |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
1775 } |
| 6 | 1776 w = makemenu(w, e.u.m.item); |
| 1777 break; | |
|
51
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
1778 case WE_LOST_SEL: |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
1779 w = newintobject((long)e.u.sel); |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
1780 break; |
| 6 | 1781 default: |
| 1782 w = None; | |
| 1783 INCREF(w); | |
| 1784 break; | |
| 1785 } | |
| 1786 if (w == NULL) { | |
| 1787 DECREF(v); | |
| 1788 return NULL; | |
| 1789 } | |
| 1790 settupleitem(v, 2, w); | |
| 1791 return v; | |
| 1792 } | |
| 1793 | |
| 1794 static object * | |
|
114
1efb8ed6afd3
Added pollevent(); returns None if no event available.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
1795 stdwin_getevent(sw, args) |
|
1efb8ed6afd3
Added pollevent(); returns None if no event available.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
1796 object *sw; |
|
1efb8ed6afd3
Added pollevent(); returns None if no event available.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
1797 object *args; |
|
1efb8ed6afd3
Added pollevent(); returns None if no event available.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
1798 { |
|
1efb8ed6afd3
Added pollevent(); returns None if no event available.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
1799 return stdwin_get_poll_event(0, args); |
|
1efb8ed6afd3
Added pollevent(); returns None if no event available.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
1800 } |
|
1efb8ed6afd3
Added pollevent(); returns None if no event available.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
1801 |
|
1efb8ed6afd3
Added pollevent(); returns None if no event available.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
1802 static object * |
|
1efb8ed6afd3
Added pollevent(); returns None if no event available.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
1803 stdwin_pollevent(sw, args) |
|
1efb8ed6afd3
Added pollevent(); returns None if no event available.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
1804 object *sw; |
|
1efb8ed6afd3
Added pollevent(); returns None if no event available.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
1805 object *args; |
|
1efb8ed6afd3
Added pollevent(); returns None if no event available.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
1806 { |
|
1efb8ed6afd3
Added pollevent(); returns None if no event available.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
1807 return stdwin_get_poll_event(1, args); |
|
1efb8ed6afd3
Added pollevent(); returns None if no event available.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
1808 } |
|
1efb8ed6afd3
Added pollevent(); returns None if no event available.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
1809 |
|
1efb8ed6afd3
Added pollevent(); returns None if no event available.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
1810 static object * |
| 6 | 1811 stdwin_setdefwinpos(sw, args) |
| 1812 object *sw; | |
| 1813 object *args; | |
| 1814 { | |
| 1815 int a[2]; | |
| 1816 if (!getpointarg(args, a)) | |
| 1817 return NULL; | |
| 1818 wsetdefwinpos(a[0], a[1]); | |
| 1819 INCREF(None); | |
| 1820 return None; | |
| 1821 } | |
| 1822 | |
| 1823 static object * | |
| 1824 stdwin_setdefwinsize(sw, args) | |
| 1825 object *sw; | |
| 1826 object *args; | |
| 1827 { | |
| 1828 int a[2]; | |
| 1829 if (!getpointarg(args, a)) | |
| 1830 return NULL; | |
| 1831 wsetdefwinsize(a[0], a[1]); | |
| 1832 INCREF(None); | |
| 1833 return None; | |
| 1834 } | |
| 1835 | |
| 1836 static object * | |
|
171
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
1837 stdwin_setdefscrollbars(sw, args) |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
1838 object *sw; |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
1839 object *args; |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
1840 { |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
1841 int a[2]; |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
1842 if (!getpointarg(args, a)) |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
1843 return NULL; |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
1844 wsetdefscrollbars(a[0], a[1]); |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
1845 INCREF(None); |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
1846 return None; |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
1847 } |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
1848 |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
1849 static object * |
|
233
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
1850 stdwin_getdefwinpos(self, args) |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
1851 object *self; |
|
137
82ef94b8b902
Add getdefwinpos, getdefwinsize;
Guido van Rossum <guido@python.org>
parents:
114
diff
changeset
|
1852 object *args; |
|
82ef94b8b902
Add getdefwinpos, getdefwinsize;
Guido van Rossum <guido@python.org>
parents:
114
diff
changeset
|
1853 { |
|
82ef94b8b902
Add getdefwinpos, getdefwinsize;
Guido van Rossum <guido@python.org>
parents:
114
diff
changeset
|
1854 int h, v; |
|
82ef94b8b902
Add getdefwinpos, getdefwinsize;
Guido van Rossum <guido@python.org>
parents:
114
diff
changeset
|
1855 if (!getnoarg(args)) |
|
82ef94b8b902
Add getdefwinpos, getdefwinsize;
Guido van Rossum <guido@python.org>
parents:
114
diff
changeset
|
1856 return NULL; |
|
82ef94b8b902
Add getdefwinpos, getdefwinsize;
Guido van Rossum <guido@python.org>
parents:
114
diff
changeset
|
1857 wgetdefwinpos(&h, &v); |
|
82ef94b8b902
Add getdefwinpos, getdefwinsize;
Guido van Rossum <guido@python.org>
parents:
114
diff
changeset
|
1858 return makepoint(h, v); |
|
82ef94b8b902
Add getdefwinpos, getdefwinsize;
Guido van Rossum <guido@python.org>
parents:
114
diff
changeset
|
1859 } |
|
82ef94b8b902
Add getdefwinpos, getdefwinsize;
Guido van Rossum <guido@python.org>
parents:
114
diff
changeset
|
1860 |
|
82ef94b8b902
Add getdefwinpos, getdefwinsize;
Guido van Rossum <guido@python.org>
parents:
114
diff
changeset
|
1861 static object * |
|
233
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
1862 stdwin_getdefwinsize(self, args) |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
1863 object *self; |
|
137
82ef94b8b902
Add getdefwinpos, getdefwinsize;
Guido van Rossum <guido@python.org>
parents:
114
diff
changeset
|
1864 object *args; |
|
82ef94b8b902
Add getdefwinpos, getdefwinsize;
Guido van Rossum <guido@python.org>
parents:
114
diff
changeset
|
1865 { |
|
82ef94b8b902
Add getdefwinpos, getdefwinsize;
Guido van Rossum <guido@python.org>
parents:
114
diff
changeset
|
1866 int width, height; |
|
82ef94b8b902
Add getdefwinpos, getdefwinsize;
Guido van Rossum <guido@python.org>
parents:
114
diff
changeset
|
1867 if (!getnoarg(args)) |
|
82ef94b8b902
Add getdefwinpos, getdefwinsize;
Guido van Rossum <guido@python.org>
parents:
114
diff
changeset
|
1868 return NULL; |
|
82ef94b8b902
Add getdefwinpos, getdefwinsize;
Guido van Rossum <guido@python.org>
parents:
114
diff
changeset
|
1869 wgetdefwinsize(&width, &height); |
|
82ef94b8b902
Add getdefwinpos, getdefwinsize;
Guido van Rossum <guido@python.org>
parents:
114
diff
changeset
|
1870 return makepoint(width, height); |
|
82ef94b8b902
Add getdefwinpos, getdefwinsize;
Guido van Rossum <guido@python.org>
parents:
114
diff
changeset
|
1871 } |
|
82ef94b8b902
Add getdefwinpos, getdefwinsize;
Guido van Rossum <guido@python.org>
parents:
114
diff
changeset
|
1872 |
|
82ef94b8b902
Add getdefwinpos, getdefwinsize;
Guido van Rossum <guido@python.org>
parents:
114
diff
changeset
|
1873 static object * |
|
233
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
1874 stdwin_getdefscrollbars(self, args) |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
1875 object *self; |
|
171
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
1876 object *args; |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
1877 { |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
1878 int h, v; |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
1879 if (!getnoarg(args)) |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
1880 return NULL; |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
1881 wgetdefscrollbars(&h, &v); |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
1882 return makepoint(h, v); |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
1883 } |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
1884 |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
1885 static object * |
| 6 | 1886 stdwin_menucreate(self, args) |
| 1887 object *self; | |
| 1888 object *args; | |
| 1889 { | |
| 1890 object *title; | |
| 1891 if (!getstrarg(args, &title)) | |
| 1892 return NULL; | |
| 1893 wmenusetdeflocal(0); | |
| 1894 return (object *)newmenuobject(title); | |
| 1895 } | |
| 1896 | |
| 1897 static object * | |
| 1898 stdwin_askfile(self, args) | |
| 1899 object *self; | |
| 1900 object *args; | |
| 1901 { | |
| 1902 object *prompt, *dflt; | |
| 1903 int new, ret; | |
| 1904 char buf[256]; | |
| 1905 if (!getstrstrintarg(args, &prompt, &dflt, &new)) | |
| 1906 return NULL; | |
| 1907 strncpy(buf, getstringvalue(dflt), sizeof buf); | |
| 1908 buf[sizeof buf - 1] = '\0'; | |
| 1909 ret = waskfile(getstringvalue(prompt), buf, sizeof buf, new); | |
| 1910 if (!ret) { | |
| 1911 err_set(KeyboardInterrupt); | |
| 1912 return NULL; | |
| 1913 } | |
| 1914 return newstringobject(buf); | |
| 1915 } | |
| 1916 | |
| 1917 static object * | |
| 1918 stdwin_askync(self, args) | |
| 1919 object *self; | |
| 1920 object *args; | |
| 1921 { | |
| 1922 object *prompt; | |
| 1923 int new, ret; | |
| 1924 if (!getstrintarg(args, &prompt, &new)) | |
| 1925 return NULL; | |
| 1926 ret = waskync(getstringvalue(prompt), new); | |
| 1927 if (ret < 0) { | |
| 1928 err_set(KeyboardInterrupt); | |
| 1929 return NULL; | |
| 1930 } | |
| 1931 return newintobject((long)ret); | |
| 1932 } | |
| 1933 | |
| 1934 static object * | |
| 1935 stdwin_askstr(self, args) | |
| 1936 object *self; | |
| 1937 object *args; | |
| 1938 { | |
| 1939 object *prompt, *dflt; | |
| 1940 int ret; | |
| 1941 char buf[256]; | |
| 1942 if (!getstrstrarg(args, &prompt, &dflt)) | |
| 1943 return NULL; | |
| 1944 strncpy(buf, getstringvalue(dflt), sizeof buf); | |
| 1945 buf[sizeof buf - 1] = '\0'; | |
| 1946 ret = waskstr(getstringvalue(prompt), buf, sizeof buf); | |
| 1947 if (!ret) { | |
| 1948 err_set(KeyboardInterrupt); | |
| 1949 return NULL; | |
| 1950 } | |
| 1951 return newstringobject(buf); | |
| 1952 } | |
| 1953 | |
| 1954 static object * | |
| 1955 stdwin_message(self, args) | |
| 1956 object *self; | |
| 1957 object *args; | |
| 1958 { | |
| 1959 object *msg; | |
| 1960 if (!getstrarg(args, &msg)) | |
| 1961 return NULL; | |
| 1962 wmessage(getstringvalue(msg)); | |
| 1963 INCREF(None); | |
| 1964 return None; | |
| 1965 } | |
| 1966 | |
| 1967 static object * | |
| 1968 stdwin_fleep(self, args) | |
| 1969 object *self; | |
| 1970 object *args; | |
| 1971 { | |
| 1972 if (!getnoarg(args)) | |
| 1973 return NULL; | |
| 1974 wfleep(); | |
| 1975 INCREF(None); | |
| 1976 return None; | |
| 1977 } | |
| 1978 | |
| 1979 static object * | |
| 1980 stdwin_setcutbuffer(self, args) | |
| 1981 object *self; | |
| 1982 object *args; | |
| 1983 { | |
|
51
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
1984 int i; |
| 6 | 1985 object *str; |
|
65
a72c0a7dc993
Turn close commands into WE_CLOSE events.
Guido van Rossum <guido@python.org>
parents:
51
diff
changeset
|
1986 if (!getintstrarg(args, &i, &str)) |
|
a72c0a7dc993
Turn close commands into WE_CLOSE events.
Guido van Rossum <guido@python.org>
parents:
51
diff
changeset
|
1987 return NULL; |
|
51
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
1988 wsetcutbuffer(i, getstringvalue(str), getstringsize(str)); |
| 6 | 1989 INCREF(None); |
| 1990 return None; | |
| 1991 } | |
| 1992 | |
| 1993 static object * | |
|
252
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
1994 stdwin_getactive(self, args) |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
1995 object *self; |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
1996 object *args; |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
1997 { |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
1998 return window2object(wgetactive()); |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
1999 } |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
2000 |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
2001 static object * |
| 6 | 2002 stdwin_getcutbuffer(self, args) |
| 2003 object *self; | |
| 2004 object *args; | |
| 2005 { | |
|
51
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2006 int i; |
| 6 | 2007 char *str; |
|
50
b94822f54991
Change set/getcutbuffer to use the new stdwin interface.
Guido van Rossum <guido@python.org>
parents:
6
diff
changeset
|
2008 int len; |
|
65
a72c0a7dc993
Turn close commands into WE_CLOSE events.
Guido van Rossum <guido@python.org>
parents:
51
diff
changeset
|
2009 if (!getintarg(args, &i)) |
| 6 | 2010 return NULL; |
|
51
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2011 str = wgetcutbuffer(i, &len); |
|
50
b94822f54991
Change set/getcutbuffer to use the new stdwin interface.
Guido van Rossum <guido@python.org>
parents:
6
diff
changeset
|
2012 if (str == NULL) { |
| 6 | 2013 str = ""; |
|
50
b94822f54991
Change set/getcutbuffer to use the new stdwin interface.
Guido van Rossum <guido@python.org>
parents:
6
diff
changeset
|
2014 len = 0; |
|
b94822f54991
Change set/getcutbuffer to use the new stdwin interface.
Guido van Rossum <guido@python.org>
parents:
6
diff
changeset
|
2015 } |
|
b94822f54991
Change set/getcutbuffer to use the new stdwin interface.
Guido van Rossum <guido@python.org>
parents:
6
diff
changeset
|
2016 return newsizedstringobject(str, len); |
| 6 | 2017 } |
| 2018 | |
|
51
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2019 static object * |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2020 stdwin_rotatecutbuffers(self, args) |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2021 object *self; |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2022 object *args; |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2023 { |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2024 int i; |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2025 if (!getintarg(args, &i)) |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2026 return NULL; |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2027 wrotatecutbuffers(i); |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2028 INCREF(None); |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2029 return None; |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2030 } |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2031 |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2032 static object * |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2033 stdwin_getselection(self, args) |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2034 object *self; |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2035 object *args; |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2036 { |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2037 int sel; |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2038 char *data; |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2039 int len; |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2040 if (!getintarg(args, &sel)) |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2041 return NULL; |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2042 data = wgetselection(sel, &len); |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2043 if (data == NULL) { |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2044 data = ""; |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2045 len = 0; |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2046 } |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2047 return newsizedstringobject(data, len); |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2048 } |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2049 |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2050 static object * |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2051 stdwin_resetselection(self, args) |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2052 object *self; |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2053 object *args; |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2054 { |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2055 int sel; |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2056 if (!getintarg(args, &sel)) |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2057 return NULL; |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2058 wresetselection(sel); |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2059 INCREF(None); |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2060 return None; |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2061 } |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2062 |
|
171
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
2063 static object * |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
2064 stdwin_fetchcolor(self, args) |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
2065 object *self; |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
2066 object *args; |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
2067 { |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
2068 object *colorname; |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
2069 if (!getstrarg(args, &colorname)) |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
2070 return NULL; |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
2071 return newintobject((long)wfetchcolor(getstringvalue(colorname))); |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
2072 } |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
2073 |
|
233
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
2074 static object * |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
2075 stdwin_getscrsize(self, args) |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
2076 object *self; |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
2077 object *args; |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
2078 { |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
2079 int width, height; |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
2080 if (!getnoarg(args)) |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
2081 return NULL; |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
2082 wgetscrsize(&width, &height); |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
2083 return makepoint(width, height); |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
2084 } |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
2085 |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
2086 static object * |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
2087 stdwin_getscrmm(self, args) |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
2088 object *self; |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
2089 object *args; |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
2090 { |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
2091 int width, height; |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
2092 if (!getnoarg(args)) |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
2093 return NULL; |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
2094 wgetscrmm(&width, &height); |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
2095 return makepoint(width, height); |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
2096 } |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
2097 |
| 6 | 2098 static struct methodlist stdwin_methods[] = { |
| 2099 {"askfile", stdwin_askfile}, | |
| 2100 {"askstr", stdwin_askstr}, | |
| 2101 {"askync", stdwin_askync}, | |
|
207
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
2102 {"fetchcolor", stdwin_fetchcolor}, |
| 6 | 2103 {"fleep", stdwin_fleep}, |
|
252
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
2104 {"getactive", stdwin_getactive}, |
| 6 | 2105 {"getcutbuffer", stdwin_getcutbuffer}, |
|
171
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
2106 {"getdefscrollbars", stdwin_getdefscrollbars}, |
|
137
82ef94b8b902
Add getdefwinpos, getdefwinsize;
Guido van Rossum <guido@python.org>
parents:
114
diff
changeset
|
2107 {"getdefwinpos", stdwin_getdefwinpos}, |
|
82ef94b8b902
Add getdefwinpos, getdefwinsize;
Guido van Rossum <guido@python.org>
parents:
114
diff
changeset
|
2108 {"getdefwinsize", stdwin_getdefwinsize}, |
| 6 | 2109 {"getevent", stdwin_getevent}, |
|
233
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
2110 {"getscrmm", stdwin_getscrmm}, |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
2111 {"getscrsize", stdwin_getscrsize}, |
|
207
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
2112 {"getselection", stdwin_getselection}, |
| 6 | 2113 {"menucreate", stdwin_menucreate}, |
| 2114 {"message", stdwin_message}, | |
| 2115 {"open", stdwin_open}, | |
|
114
1efb8ed6afd3
Added pollevent(); returns None if no event available.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
2116 {"pollevent", stdwin_pollevent}, |
|
51
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2117 {"resetselection", stdwin_resetselection}, |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2118 {"rotatecutbuffers", stdwin_rotatecutbuffers}, |
| 6 | 2119 {"setcutbuffer", stdwin_setcutbuffer}, |
|
171
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
2120 {"setdefscrollbars", stdwin_setdefscrollbars}, |
| 6 | 2121 {"setdefwinpos", stdwin_setdefwinpos}, |
| 2122 {"setdefwinsize", stdwin_setdefwinsize}, | |
| 2123 | |
| 2124 /* Text measuring methods borrow code from drawing objects: */ | |
| 2125 {"baseline", drawing_baseline}, | |
| 2126 {"lineheight", drawing_lineheight}, | |
| 2127 {"textbreak", drawing_textbreak}, | |
| 2128 {"textwidth", drawing_textwidth}, | |
|
171
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
2129 |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
2130 /* Same for font setting methods: */ |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
2131 {"setfont", drawing_setfont}, |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
2132 |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
2133 /* Same for color setting/getting methods: */ |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
2134 {"getbgcolor", drawing_getbgcolor}, |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
2135 {"getfgcolor", drawing_getfgcolor}, |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
2136 {"setbgcolor", drawing_setbgcolor}, |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
2137 {"setfgcolor", drawing_setfgcolor}, |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
2138 |
| 6 | 2139 {NULL, NULL} /* sentinel */ |
| 2140 }; | |
| 2141 | |
| 2142 void | |
| 2143 initstdwin() | |
| 2144 { | |
|
142
c7ea60491e68
Call winit() here instead of in main initialization.
Guido van Rossum <guido@python.org>
parents:
137
diff
changeset
|
2145 static int inited; |
|
c7ea60491e68
Call winit() here instead of in main initialization.
Guido van Rossum <guido@python.org>
parents:
137
diff
changeset
|
2146 if (!inited) { |
|
c7ea60491e68
Call winit() here instead of in main initialization.
Guido van Rossum <guido@python.org>
parents:
137
diff
changeset
|
2147 winit(); |
|
c7ea60491e68
Call winit() here instead of in main initialization.
Guido van Rossum <guido@python.org>
parents:
137
diff
changeset
|
2148 inited = 1; |
|
c7ea60491e68
Call winit() here instead of in main initialization.
Guido van Rossum <guido@python.org>
parents:
137
diff
changeset
|
2149 } |
| 6 | 2150 initmodule("stdwin", stdwin_methods); |
| 2151 } |
