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