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