Mercurial > cpython-lru_cache-weakref
annotate Modules/stdwinmodule.c @ 4439:fb1237bf7022 legacy-trunk
Changed version to plain "1.4".
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Tue, 22 Oct 1996 03:09:46 +0000 |
| parents | 82356bddf712 |
| children | 65d2d8e67da3 |
| rev | line source |
|---|---|
|
145
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
142
diff
changeset
|
1 /*********************************************************** |
|
2061
172ba04a5191
Added 1995 to copyright message.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
2 Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam, |
|
172ba04a5191
Added 1995 to copyright message.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
3 The Netherlands. |
|
145
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 | |
|
1211
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
33 bp: a bitmap |
| 6 | 34 */ |
| 35 | |
| 36 /* Rules for translating C stdwin function calls into Python stwin: | |
| 37 - All names drop their initial letter 'w' | |
| 38 - Functions with a window as first parameter are methods of window objects | |
| 39 - There is no equivalent for wclose(); just delete the window object | |
| 40 (all references to it!) (XXX maybe this is a bad idea) | |
| 41 - w.begindrawing() returns a drawing object | |
| 42 - There is no equivalent for wenddrawing(win); just delete the drawing | |
| 43 object (all references to it!) (XXX maybe this is a bad idea) | |
| 44 - Functions that may only be used inside wbegindrawing / wendddrawing | |
| 45 are methods of the drawing object; this includes the text measurement | |
| 46 functions (which however have doubles as module functions). | |
| 47 - Methods of the drawing object drop an initial 'draw' from their name | |
| 48 if they have it, e.g., wdrawline() --> d.line() | |
| 49 - The obvious type conversions: int --> intobject; string --> stringobject | |
| 50 - A text parameter followed by a length parameter is only a text (string) | |
| 51 parameter in Python | |
| 52 - A point or other pair of horizontal and vertical coordinates is always | |
| 53 a pair of integers in Python | |
| 54 - Two points forming a rectangle or endpoints of a line segment are a | |
| 55 pair of points in Python | |
| 56 - The arguments to d.elarc() are three points. | |
| 57 - The functions wgetclip() and wsetclip() are translated into | |
| 58 stdwin.getcutbuffer() and stdwin.setcutbuffer(); 'clip' is really | |
| 59 a bad word for what these functions do (clipping has a different | |
| 60 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
|
61 XXX This must change again in the light of changes to stdwin! |
| 6 | 62 - For textedit, similar rules hold, but they are less strict. |
| 63 XXX more? | |
| 64 */ | |
| 65 | |
| 86 | 66 #include "allobjects.h" |
| 6 | 67 #include "modsupport.h" |
| 926 | 68 #include "ceval.h" |
|
1353
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
69 #include "sysmodule.h" |
|
2975
82356bddf712
Shuffled include's around (name conflict on Mac wrt teclick())
Jack Jansen <jack.jansen@cwi.nl>
parents:
2506
diff
changeset
|
70 #ifdef macintosh |
|
82356bddf712
Shuffled include's around (name conflict on Mac wrt teclick())
Jack Jansen <jack.jansen@cwi.nl>
parents:
2506
diff
changeset
|
71 #include "macglue.h" |
|
82356bddf712
Shuffled include's around (name conflict on Mac wrt teclick())
Jack Jansen <jack.jansen@cwi.nl>
parents:
2506
diff
changeset
|
72 #endif |
| 6 | 73 |
|
1191
38f0054f44a7
Added separate main program for the Mac: macmain.c
Guido van Rossum <guido@python.org>
parents:
1051
diff
changeset
|
74 #ifdef macintosh |
|
1332
e5fb9cdbe050
Final touch before release.
Guido van Rossum <guido@python.org>
parents:
1313
diff
changeset
|
75 #include ":::stdwin:H:stdwin.h" |
|
1191
38f0054f44a7
Added separate main program for the Mac: macmain.c
Guido van Rossum <guido@python.org>
parents:
1051
diff
changeset
|
76 #else /* !macintosh */ |
| 86 | 77 #include "stdwin.h" |
|
1332
e5fb9cdbe050
Final touch before release.
Guido van Rossum <guido@python.org>
parents:
1313
diff
changeset
|
78 #define HAVE_BITMAPS |
|
1191
38f0054f44a7
Added separate main program for the Mac: macmain.c
Guido van Rossum <guido@python.org>
parents:
1051
diff
changeset
|
79 #endif /* !macintosh */ |
| 6 | 80 |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
81 #ifdef WITH_THREAD |
| 926 | 82 |
| 83 #include "thread.h" | |
| 84 | |
| 85 static type_lock StdwinLock; /* Lock held when interpreter not locked */ | |
| 86 | |
| 87 #define BGN_STDWIN BGN_SAVE acquire_lock(StdwinLock, 1); | |
| 88 #define RET_STDWIN release_lock(StdwinLock); RET_SAVE | |
| 89 #define END_STDWIN release_lock(StdwinLock); END_SAVE | |
| 90 | |
| 91 #else | |
| 92 | |
| 93 #define BGN_STDWIN BGN_SAVE | |
| 94 #define RET_STDWIN RET_SAVE | |
| 95 #define END_STDWIN END_SAVE | |
| 96 | |
| 97 #endif | |
| 98 | |
|
1313
6ee380349c84
* Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents:
1211
diff
changeset
|
99 #define getpointarg(v, a) getargs(v, "(ii)", a, (a)+1) |
|
6ee380349c84
* Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents:
1211
diff
changeset
|
100 #define get3pointarg(v, a) getargs(v, "((ii)(ii)(ii))", \ |
|
6ee380349c84
* Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents:
1211
diff
changeset
|
101 a, a+1, a+2, a+3, a+4, a+5) |
|
6ee380349c84
* Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents:
1211
diff
changeset
|
102 #define getrectarg(v, a) getargs(v, "((ii)(ii))", a, a+1, a+2, a+3) |
|
6ee380349c84
* Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents:
1211
diff
changeset
|
103 #define getrectintarg(v, a) getargs(v, "(((ii)(ii))i)", a, a+1, a+2, a+3, a+4) |
|
6ee380349c84
* Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents:
1211
diff
changeset
|
104 #define getpointintarg(v, a) getargs(v, "((ii)i)", a, a+1, a+2) |
|
6ee380349c84
* Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents:
1211
diff
changeset
|
105 #define getrectpointarg(v, a) getargs(v, "(((ii)(ii))(ii))", \ |
|
6ee380349c84
* Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents:
1211
diff
changeset
|
106 a, a+1, a+2, a+3, a+4, a+5) |
|
6ee380349c84
* Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents:
1211
diff
changeset
|
107 |
|
499
80e2e5d67b49
Change errors into new StdwinError.
Guido van Rossum <guido@python.org>
parents:
475
diff
changeset
|
108 static object *StdwinError; /* Exception stdwin.error */ |
| 475 | 109 |
| 6 | 110 /* Window and menu object types declared here because of forward references */ |
| 111 | |
| 112 typedef struct { | |
| 113 OB_HEAD | |
| 114 object *w_title; | |
| 115 WINDOW *w_win; | |
| 116 object *w_attr; /* Attributes dictionary */ | |
| 117 } windowobject; | |
| 118 | |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
119 staticforward typeobject Windowtype; |
| 6 | 120 |
| 121 #define is_windowobject(wp) ((wp)->ob_type == &Windowtype) | |
| 122 | |
| 123 typedef struct { | |
| 124 OB_HEAD | |
| 125 MENU *m_menu; | |
| 126 int m_id; | |
| 127 object *m_attr; /* Attributes dictionary */ | |
| 128 } menuobject; | |
| 129 | |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
130 staticforward typeobject Menutype; |
| 6 | 131 |
| 132 #define is_menuobject(mp) ((mp)->ob_type == &Menutype) | |
| 133 | |
|
1211
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
134 typedef struct { |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
135 OB_HEAD |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
136 BITMAP *b_bitmap; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
137 object *b_attr; /* Attributes dictionary */ |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
138 } bitmapobject; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
139 |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
140 staticforward typeobject Bitmaptype; |
|
1211
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
141 |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
142 #define is_bitmapobject(mp) ((mp)->ob_type == &Bitmaptype) |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
143 |
| 6 | 144 |
| 145 /* Strongly stdwin-specific argument handlers */ | |
| 146 | |
| 147 static int | |
| 148 getmenudetail(v, ep) | |
| 149 object *v; | |
| 150 EVENT *ep; | |
| 151 { | |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
152 menuobject *mp; |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
153 if (!getargs(v, "(Oi)", &mp, &ep->u.m.item)) |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
154 return 0; |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
155 if (!is_menuobject(mp)) |
| 6 | 156 return err_badarg(); |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
157 ep->u.m.id = mp->m_id; |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
158 return 1; |
| 6 | 159 } |
| 160 | |
| 161 static int | |
| 162 geteventarg(v, ep) | |
| 163 object *v; | |
| 164 EVENT *ep; | |
| 165 { | |
| 166 object *wp, *detail; | |
| 167 int a[4]; | |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
168 if (!getargs(v, "(iOO)", &ep->type, &wp, &detail)) |
| 6 | 169 return 0; |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
170 if (is_windowobject(wp)) |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
171 ep->window = ((windowobject *)wp) -> w_win; |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
172 else if (wp == None) |
| 6 | 173 ep->window = NULL; |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
174 else |
| 6 | 175 return err_badarg(); |
| 176 switch (ep->type) { | |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
177 case WE_CHAR: { |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
178 char c; |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
179 if (!getargs(detail, "c", &c)) |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
180 return 0; |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
181 ep->u.character = c; |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
182 return 1; |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
183 } |
| 6 | 184 case WE_COMMAND: |
| 185 return getintarg(detail, &ep->u.command); | |
| 186 case WE_DRAW: | |
| 187 if (!getrectarg(detail, a)) | |
| 188 return 0; | |
| 189 ep->u.area.left = a[0]; | |
| 190 ep->u.area.top = a[1]; | |
| 191 ep->u.area.right = a[2]; | |
| 192 ep->u.area.bottom = a[3]; | |
| 193 return 1; | |
| 194 case WE_MOUSE_DOWN: | |
| 195 case WE_MOUSE_UP: | |
| 196 case WE_MOUSE_MOVE: | |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
197 return getargs(detail, "((ii)iii)", |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
198 &ep->u.where.h, &ep->u.where.v, |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
199 &ep->u.where.clicks, |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
200 &ep->u.where.button, |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
201 &ep->u.where.mask); |
| 6 | 202 case WE_MENU: |
| 203 return getmenudetail(detail, ep); | |
|
907
32010d355fb6
added WE_KEY detail format to stdwinmodule.c.
Guido van Rossum <guido@python.org>
parents:
902
diff
changeset
|
204 case WE_KEY: |
|
32010d355fb6
added WE_KEY detail format to stdwinmodule.c.
Guido van Rossum <guido@python.org>
parents:
902
diff
changeset
|
205 return getargs(detail, "(ii)", |
|
32010d355fb6
added WE_KEY detail format to stdwinmodule.c.
Guido van Rossum <guido@python.org>
parents:
902
diff
changeset
|
206 &ep->u.key.code, &ep->u.key.mask); |
| 6 | 207 default: |
| 208 return 1; | |
| 209 } | |
| 210 } | |
| 211 | |
| 212 | |
| 213 /* Return construction tools */ | |
| 214 | |
| 215 static object * | |
| 216 makepoint(a, b) | |
| 217 int a, b; | |
| 218 { | |
|
818
e157c12cd6e7
Use mkvalue() instead of painfully constructing values
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
219 return mkvalue("(ii)", a, b); |
| 6 | 220 } |
| 221 | |
| 222 static object * | |
| 223 makerect(a, b, c, d) | |
| 224 int a, b, c, d; | |
| 225 { | |
|
818
e157c12cd6e7
Use mkvalue() instead of painfully constructing values
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
226 return mkvalue("((ii)(ii))", a, b, c, d); |
| 6 | 227 } |
| 228 | |
| 229 | |
| 230 /* Drawing objects */ | |
| 231 | |
| 232 typedef struct { | |
| 233 OB_HEAD | |
| 234 windowobject *d_ref; | |
| 235 } drawingobject; | |
| 236 | |
| 237 static drawingobject *Drawing; /* Set to current drawing object, or NULL */ | |
| 238 | |
| 239 /* Drawing methods */ | |
| 240 | |
|
453
34abca182f18
Enclosed method lists in braces.
Guido van Rossum <guido@python.org>
parents:
397
diff
changeset
|
241 static object * |
|
34abca182f18
Enclosed method lists in braces.
Guido van Rossum <guido@python.org>
parents:
397
diff
changeset
|
242 drawing_close(dp) |
|
34abca182f18
Enclosed method lists in braces.
Guido van Rossum <guido@python.org>
parents:
397
diff
changeset
|
243 drawingobject *dp; |
|
34abca182f18
Enclosed method lists in braces.
Guido van Rossum <guido@python.org>
parents:
397
diff
changeset
|
244 { |
|
34abca182f18
Enclosed method lists in braces.
Guido van Rossum <guido@python.org>
parents:
397
diff
changeset
|
245 if (dp->d_ref != NULL) { |
|
34abca182f18
Enclosed method lists in braces.
Guido van Rossum <guido@python.org>
parents:
397
diff
changeset
|
246 wenddrawing(dp->d_ref->w_win); |
|
34abca182f18
Enclosed method lists in braces.
Guido van Rossum <guido@python.org>
parents:
397
diff
changeset
|
247 Drawing = NULL; |
|
34abca182f18
Enclosed method lists in braces.
Guido van Rossum <guido@python.org>
parents:
397
diff
changeset
|
248 DECREF(dp->d_ref); |
|
34abca182f18
Enclosed method lists in braces.
Guido van Rossum <guido@python.org>
parents:
397
diff
changeset
|
249 dp->d_ref = NULL; |
|
34abca182f18
Enclosed method lists in braces.
Guido van Rossum <guido@python.org>
parents:
397
diff
changeset
|
250 } |
|
34abca182f18
Enclosed method lists in braces.
Guido van Rossum <guido@python.org>
parents:
397
diff
changeset
|
251 INCREF(None); |
|
34abca182f18
Enclosed method lists in braces.
Guido van Rossum <guido@python.org>
parents:
397
diff
changeset
|
252 return None; |
|
34abca182f18
Enclosed method lists in braces.
Guido van Rossum <guido@python.org>
parents:
397
diff
changeset
|
253 } |
|
594
47c42ea67a8b
Added close method for menus.
Guido van Rossum <guido@python.org>
parents:
499
diff
changeset
|
254 |
| 6 | 255 static void |
| 256 drawing_dealloc(dp) | |
| 257 drawingobject *dp; | |
| 258 { | |
|
453
34abca182f18
Enclosed method lists in braces.
Guido van Rossum <guido@python.org>
parents:
397
diff
changeset
|
259 if (dp->d_ref != NULL) { |
|
34abca182f18
Enclosed method lists in braces.
Guido van Rossum <guido@python.org>
parents:
397
diff
changeset
|
260 wenddrawing(dp->d_ref->w_win); |
|
34abca182f18
Enclosed method lists in braces.
Guido van Rossum <guido@python.org>
parents:
397
diff
changeset
|
261 Drawing = NULL; |
|
34abca182f18
Enclosed method lists in braces.
Guido van Rossum <guido@python.org>
parents:
397
diff
changeset
|
262 DECREF(dp->d_ref); |
|
34abca182f18
Enclosed method lists in braces.
Guido van Rossum <guido@python.org>
parents:
397
diff
changeset
|
263 dp->d_ref = NULL; |
|
34abca182f18
Enclosed method lists in braces.
Guido van Rossum <guido@python.org>
parents:
397
diff
changeset
|
264 } |
| 6 | 265 free((char *)dp); |
| 266 } | |
| 267 | |
| 268 static object * | |
| 269 drawing_generic(dp, args, func) | |
| 270 drawingobject *dp; | |
| 271 object *args; | |
| 272 void (*func) FPROTO((int, int, int, int)); | |
| 273 { | |
| 274 int a[4]; | |
| 275 if (!getrectarg(args, a)) | |
| 276 return NULL; | |
| 277 (*func)(a[0], a[1], a[2], a[3]); | |
| 278 INCREF(None); | |
| 279 return None; | |
| 280 } | |
| 281 | |
| 282 static object * | |
| 283 drawing_line(dp, args) | |
| 284 drawingobject *dp; | |
| 285 object *args; | |
| 286 { | |
|
157
47cc0ce7999c
Return value of drawing_generic was ignored! Foo!
Guido van Rossum <guido@python.org>
parents:
145
diff
changeset
|
287 return drawing_generic(dp, args, wdrawline); |
| 6 | 288 } |
| 289 | |
| 290 static object * | |
| 291 drawing_xorline(dp, args) | |
| 292 drawingobject *dp; | |
| 293 object *args; | |
| 294 { | |
|
157
47cc0ce7999c
Return value of drawing_generic was ignored! Foo!
Guido van Rossum <guido@python.org>
parents:
145
diff
changeset
|
295 return drawing_generic(dp, args, wxorline); |
| 6 | 296 } |
| 297 | |
| 298 static object * | |
| 299 drawing_circle(dp, args) | |
| 300 drawingobject *dp; | |
| 301 object *args; | |
| 302 { | |
| 303 int a[3]; | |
| 304 if (!getpointintarg(args, a)) | |
| 305 return NULL; | |
| 306 wdrawcircle(a[0], a[1], a[2]); | |
| 307 INCREF(None); | |
| 308 return None; | |
| 309 } | |
| 244 | 310 |
|
207
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
311 static object * |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
312 drawing_fillcircle(dp, args) |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
313 drawingobject *dp; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
314 object *args; |
|
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 int a[3]; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
317 if (!getpointintarg(args, a)) |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
318 return NULL; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
319 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
|
320 INCREF(None); |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
321 return None; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
322 } |
| 6 | 323 |
| 324 static object * | |
| 244 | 325 drawing_xorcircle(dp, args) |
| 326 drawingobject *dp; | |
| 327 object *args; | |
| 328 { | |
| 329 int a[3]; | |
| 330 if (!getpointintarg(args, a)) | |
| 331 return NULL; | |
| 332 wxorcircle(a[0], a[1], a[2]); | |
| 333 INCREF(None); | |
| 334 return None; | |
| 335 } | |
| 336 | |
| 337 static object * | |
| 6 | 338 drawing_elarc(dp, args) |
| 339 drawingobject *dp; | |
| 340 object *args; | |
| 341 { | |
| 342 int a[6]; | |
| 343 if (!get3pointarg(args, a)) | |
| 344 return NULL; | |
| 345 wdrawelarc(a[0], a[1], a[2], a[3], a[4], a[5]); | |
| 346 INCREF(None); | |
| 347 return None; | |
| 348 } | |
| 349 | |
| 350 static object * | |
|
207
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
351 drawing_fillelarc(dp, args) |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
352 drawingobject *dp; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
353 object *args; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
354 { |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
355 int a[6]; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
356 if (!get3pointarg(args, a)) |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
357 return NULL; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
358 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
|
359 INCREF(None); |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
360 return None; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
361 } |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
362 |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
363 static object * |
| 244 | 364 drawing_xorelarc(dp, args) |
| 365 drawingobject *dp; | |
| 366 object *args; | |
| 367 { | |
| 368 int a[6]; | |
| 369 if (!get3pointarg(args, a)) | |
| 370 return NULL; | |
| 371 wxorelarc(a[0], a[1], a[2], a[3], a[4], a[5]); | |
| 372 INCREF(None); | |
| 373 return None; | |
| 374 } | |
| 375 | |
| 376 static object * | |
| 6 | 377 drawing_box(dp, args) |
| 378 drawingobject *dp; | |
| 379 object *args; | |
| 380 { | |
|
157
47cc0ce7999c
Return value of drawing_generic was ignored! Foo!
Guido van Rossum <guido@python.org>
parents:
145
diff
changeset
|
381 return drawing_generic(dp, args, wdrawbox); |
| 6 | 382 } |
| 383 | |
| 384 static object * | |
| 385 drawing_erase(dp, args) | |
| 386 drawingobject *dp; | |
| 387 object *args; | |
| 388 { | |
|
157
47cc0ce7999c
Return value of drawing_generic was ignored! Foo!
Guido van Rossum <guido@python.org>
parents:
145
diff
changeset
|
389 return drawing_generic(dp, args, werase); |
| 6 | 390 } |
| 391 | |
| 392 static object * | |
| 393 drawing_paint(dp, args) | |
| 394 drawingobject *dp; | |
| 395 object *args; | |
| 396 { | |
|
157
47cc0ce7999c
Return value of drawing_generic was ignored! Foo!
Guido van Rossum <guido@python.org>
parents:
145
diff
changeset
|
397 return drawing_generic(dp, args, wpaint); |
| 6 | 398 } |
| 399 | |
| 400 static object * | |
| 401 drawing_invert(dp, args) | |
| 402 drawingobject *dp; | |
| 403 object *args; | |
| 404 { | |
|
157
47cc0ce7999c
Return value of drawing_generic was ignored! Foo!
Guido van Rossum <guido@python.org>
parents:
145
diff
changeset
|
405 return drawing_generic(dp, args, winvert); |
| 6 | 406 } |
| 407 | |
|
207
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
408 static POINT * |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
409 getpointsarray(v, psize) |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
410 object *v; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
411 int *psize; |
|
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 = -1; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
414 object * (*getitem) PROTO((object *, int)); |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
415 int i; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
416 POINT *points; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
417 |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
418 if (v == NULL) |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
419 ; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
420 else if (is_listobject(v)) { |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
421 n = getlistsize(v); |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
422 getitem = getlistitem; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
423 } |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
424 else if (is_tupleobject(v)) { |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
425 n = gettuplesize(v); |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
426 getitem = gettupleitem; |
|
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 |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
429 if (n <= 0) { |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
430 (void) err_badarg(); |
|
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 } |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
433 |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
434 points = NEW(POINT, n); |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
435 if (points == NULL) { |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
436 (void) err_nomem(); |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
437 return NULL; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
438 } |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
439 |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
440 for (i = 0; i < n; i++) { |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
441 object *w = (*getitem)(v, i); |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
442 int a[2]; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
443 if (!getpointarg(w, a)) { |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
444 DEL(points); |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
445 return NULL; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
446 } |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
447 points[i].h = a[0]; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
448 points[i].v = a[1]; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
449 } |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
450 |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
451 *psize = n; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
452 return points; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
453 } |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
454 |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
455 static object * |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
456 drawing_poly(dp, args) |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
457 drawingobject *dp; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
458 object *args; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
459 { |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
460 int n; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
461 POINT *points = getpointsarray(args, &n); |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
462 if (points == NULL) |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
463 return NULL; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
464 wdrawpoly(n, points); |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
465 DEL(points); |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
466 INCREF(None); |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
467 return None; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
468 } |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
469 |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
470 static object * |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
471 drawing_fillpoly(dp, args) |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
472 drawingobject *dp; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
473 object *args; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
474 { |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
475 int n; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
476 POINT *points = getpointsarray(args, &n); |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
477 if (points == NULL) |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
478 return NULL; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
479 wfillpoly(n, points); |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
480 DEL(points); |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
481 INCREF(None); |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
482 return None; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
483 } |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
484 |
| 6 | 485 static object * |
| 244 | 486 drawing_xorpoly(dp, args) |
| 487 drawingobject *dp; | |
| 488 object *args; | |
| 489 { | |
| 490 int n; | |
| 491 POINT *points = getpointsarray(args, &n); | |
| 492 if (points == NULL) | |
| 493 return NULL; | |
| 494 wxorpoly(n, points); | |
| 495 DEL(points); | |
| 496 INCREF(None); | |
| 497 return None; | |
| 498 } | |
| 499 | |
| 500 static object * | |
| 6 | 501 drawing_cliprect(dp, args) |
| 502 drawingobject *dp; | |
| 503 object *args; | |
| 504 { | |
|
157
47cc0ce7999c
Return value of drawing_generic was ignored! Foo!
Guido van Rossum <guido@python.org>
parents:
145
diff
changeset
|
505 return drawing_generic(dp, args, wcliprect); |
| 6 | 506 } |
| 507 | |
| 508 static object * | |
| 509 drawing_noclip(dp, args) | |
| 510 drawingobject *dp; | |
| 511 object *args; | |
| 512 { | |
| 513 if (!getnoarg(args)) | |
| 514 return NULL; | |
| 515 wnoclip(); | |
| 516 INCREF(None); | |
| 517 return None; | |
| 518 } | |
| 519 | |
| 520 static object * | |
| 521 drawing_shade(dp, args) | |
| 522 drawingobject *dp; | |
| 523 object *args; | |
| 524 { | |
| 525 int a[5]; | |
| 526 if (!getrectintarg(args, a)) | |
| 527 return NULL; | |
| 528 wshade(a[0], a[1], a[2], a[3], a[4]); | |
| 529 INCREF(None); | |
| 530 return None; | |
| 531 } | |
| 532 | |
| 533 static object * | |
| 534 drawing_text(dp, args) | |
| 535 drawingobject *dp; | |
| 536 object *args; | |
| 537 { | |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
538 int h, v, size; |
|
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 if (!getargs(args, "((ii)s#)", &h, &v, &text, &size)) |
| 6 | 541 return NULL; |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
542 wdrawtext(h, v, text, size); |
| 6 | 543 INCREF(None); |
| 544 return None; | |
| 545 } | |
| 546 | |
| 547 /* The following four are also used as stdwin functions */ | |
| 548 | |
| 549 static object * | |
| 550 drawing_lineheight(dp, args) | |
| 551 drawingobject *dp; | |
| 552 object *args; | |
| 553 { | |
| 554 if (!getnoarg(args)) | |
| 555 return NULL; | |
| 556 return newintobject((long)wlineheight()); | |
| 557 } | |
| 558 | |
| 559 static object * | |
| 560 drawing_baseline(dp, args) | |
| 561 drawingobject *dp; | |
| 562 object *args; | |
| 563 { | |
| 564 if (!getnoarg(args)) | |
| 565 return NULL; | |
| 566 return newintobject((long)wbaseline()); | |
| 567 } | |
| 568 | |
| 569 static object * | |
| 570 drawing_textwidth(dp, args) | |
| 571 drawingobject *dp; | |
| 572 object *args; | |
| 573 { | |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
574 char *text; |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
575 int size; |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
576 if (!getargs(args, "s#", &text, &size)) |
| 6 | 577 return NULL; |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
578 return newintobject((long)wtextwidth(text, size)); |
| 6 | 579 } |
| 580 | |
| 581 static object * | |
| 582 drawing_textbreak(dp, args) | |
| 583 drawingobject *dp; | |
| 584 object *args; | |
| 585 { | |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
586 char *text; |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
587 int size, width; |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
588 if (!getargs(args, "(s#i)", &text, &size, &width)) |
| 6 | 589 return NULL; |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
590 return newintobject((long)wtextbreak(text, size, width)); |
| 6 | 591 } |
| 592 | |
|
171
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
593 static object * |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
594 drawing_setfont(self, args) |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
595 drawingobject *self; |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
596 object *args; |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
597 { |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
598 char *font; |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
599 char style = '\0'; |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
600 int size = 0; |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
601 if (args == NULL || !is_tupleobject(args)) { |
|
657
3e626c413bbf
Fixed getargs() call in setfont.
Guido van Rossum <guido@python.org>
parents:
635
diff
changeset
|
602 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
|
603 return NULL; |
|
1b08df41587b
More flexible font setting (mainly for the Mac).
Guido van Rossum <guido@python.org>
parents:
171
diff
changeset
|
604 } |
|
1b08df41587b
More flexible font setting (mainly for the Mac).
Guido van Rossum <guido@python.org>
parents:
171
diff
changeset
|
605 else { |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
606 int n = gettuplesize(args); |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
607 if (n == 2) { |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
608 if (!getargs(args, "(zi)", &font, &size)) |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
609 return NULL; |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
610 } |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
611 else if (!getargs(args, "(zic)", &font, &size, &style)) { |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
612 err_clear(); |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
613 if (!getargs(args, "(zci)", &font, &style, &size)) |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
614 return NULL; |
|
184
1b08df41587b
More flexible font setting (mainly for the Mac).
Guido van Rossum <guido@python.org>
parents:
171
diff
changeset
|
615 } |
|
1b08df41587b
More flexible font setting (mainly for the Mac).
Guido van Rossum <guido@python.org>
parents:
171
diff
changeset
|
616 } |
|
1191
38f0054f44a7
Added separate main program for the Mac: macmain.c
Guido van Rossum <guido@python.org>
parents:
1051
diff
changeset
|
617 if (font != NULL) { |
|
38f0054f44a7
Added separate main program for the Mac: macmain.c
Guido van Rossum <guido@python.org>
parents:
1051
diff
changeset
|
618 if (!wsetfont(font)) { |
|
38f0054f44a7
Added separate main program for the Mac: macmain.c
Guido van Rossum <guido@python.org>
parents:
1051
diff
changeset
|
619 err_setstr(StdwinError, "font not found"); |
|
38f0054f44a7
Added separate main program for the Mac: macmain.c
Guido van Rossum <guido@python.org>
parents:
1051
diff
changeset
|
620 return NULL; |
|
38f0054f44a7
Added separate main program for the Mac: macmain.c
Guido van Rossum <guido@python.org>
parents:
1051
diff
changeset
|
621 } |
|
38f0054f44a7
Added separate main program for the Mac: macmain.c
Guido van Rossum <guido@python.org>
parents:
1051
diff
changeset
|
622 } |
|
184
1b08df41587b
More flexible font setting (mainly for the Mac).
Guido van Rossum <guido@python.org>
parents:
171
diff
changeset
|
623 if (size != 0) |
|
1b08df41587b
More flexible font setting (mainly for the Mac).
Guido van Rossum <guido@python.org>
parents:
171
diff
changeset
|
624 wsetsize(size); |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
625 switch (style) { |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
626 case 'b': |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
627 wsetbold(); |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
628 break; |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
629 case 'i': |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
630 wsetitalic(); |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
631 break; |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
632 case 'o': |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
633 wsetbolditalic(); |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
634 break; |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
635 case 'u': |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
636 wsetunderline(); |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
637 break; |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
638 case 'p': |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
639 wsetplain(); |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
640 break; |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
641 } |
|
171
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
642 INCREF(None); |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
643 return None; |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
644 } |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
645 |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
646 static object * |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
647 drawing_getbgcolor(self, args) |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
648 object *self; |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
649 object *args; |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
650 { |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
651 if (!getnoarg(args)) |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
652 return NULL; |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
653 return newintobject((long)wgetbgcolor()); |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
654 } |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
655 |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
656 static object * |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
657 drawing_getfgcolor(self, args) |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
658 object *self; |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
659 object *args; |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
660 { |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
661 if (!getnoarg(args)) |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
662 return NULL; |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
663 return newintobject((long)wgetfgcolor()); |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
664 } |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
665 |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
666 static object * |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
667 drawing_setbgcolor(self, args) |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
668 object *self; |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
669 object *args; |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
670 { |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
671 long color; |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
672 if (!getlongarg(args, &color)) |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
673 return NULL; |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
674 wsetbgcolor((COLOR)color); |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
675 INCREF(None); |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
676 return None; |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
677 } |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
678 |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
679 static object * |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
680 drawing_setfgcolor(self, args) |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
681 object *self; |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
682 object *args; |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
683 { |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
684 long color; |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
685 if (!getlongarg(args, &color)) |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
686 return NULL; |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
687 wsetfgcolor((COLOR)color); |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
688 INCREF(None); |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
689 return None; |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
690 } |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
691 |
|
1332
e5fb9cdbe050
Final touch before release.
Guido van Rossum <guido@python.org>
parents:
1313
diff
changeset
|
692 #ifdef HAVE_BITMAPS |
|
e5fb9cdbe050
Final touch before release.
Guido van Rossum <guido@python.org>
parents:
1313
diff
changeset
|
693 |
|
1211
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
694 static object * |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
695 drawing_bitmap(self, args) |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
696 object *self; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
697 object *args; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
698 { |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
699 int h, v; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
700 object *bp; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
701 object *mask = NULL; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
702 if (!getargs(args, "((ii)O)", &h, &v, &bp)) { |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
703 err_clear(); |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
704 if (!getargs(args, "((ii)OO)", &h, &v, &bp, &mask)) |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
705 return NULL; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
706 if (mask == None) |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
707 mask = NULL; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
708 else if (!is_bitmapobject(mask)) { |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
709 err_badarg(); |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
710 return NULL; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
711 } |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
712 } |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
713 if (!is_bitmapobject(bp)) { |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
714 err_badarg(); |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
715 return NULL; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
716 } |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
717 if (((bitmapobject *)bp)->b_bitmap == NULL || |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
718 mask != NULL && ((bitmapobject *)mask)->b_bitmap == NULL) { |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
719 err_setstr(StdwinError, "bitmap object already close"); |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
720 return NULL; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
721 } |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
722 if (mask == NULL) |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
723 wdrawbitmap(h, v, ((bitmapobject *)bp)->b_bitmap, ALLBITS); |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
724 else |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
725 wdrawbitmap(h, v, |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
726 ((bitmapobject *)bp)->b_bitmap, |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
727 ((bitmapobject *)bp)->b_bitmap); |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
728 INCREF(None); |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
729 return None; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
730 } |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
731 |
|
1332
e5fb9cdbe050
Final touch before release.
Guido van Rossum <guido@python.org>
parents:
1313
diff
changeset
|
732 #endif /* HAVE_BITMAPS */ |
|
e5fb9cdbe050
Final touch before release.
Guido van Rossum <guido@python.org>
parents:
1313
diff
changeset
|
733 |
| 6 | 734 static struct methodlist drawing_methods[] = { |
|
1332
e5fb9cdbe050
Final touch before release.
Guido van Rossum <guido@python.org>
parents:
1313
diff
changeset
|
735 #ifdef HAVE_BITMAPS |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
736 {"bitmap", (method)drawing_bitmap}, |
|
1332
e5fb9cdbe050
Final touch before release.
Guido van Rossum <guido@python.org>
parents:
1313
diff
changeset
|
737 #endif |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
738 {"box", (method)drawing_box}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
739 {"circle", (method)drawing_circle}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
740 {"cliprect", (method)drawing_cliprect}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
741 {"close", (method)drawing_close}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
742 {"elarc", (method)drawing_elarc}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
743 {"enddrawing", (method)drawing_close}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
744 {"erase", (method)drawing_erase}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
745 {"fillcircle", (method)drawing_fillcircle}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
746 {"fillelarc", (method)drawing_fillelarc}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
747 {"fillpoly", (method)drawing_fillpoly}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
748 {"invert", (method)drawing_invert}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
749 {"line", (method)drawing_line}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
750 {"noclip", (method)drawing_noclip}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
751 {"paint", (method)drawing_paint}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
752 {"poly", (method)drawing_poly}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
753 {"shade", (method)drawing_shade}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
754 {"text", (method)drawing_text}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
755 {"xorcircle", (method)drawing_xorcircle}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
756 {"xorelarc", (method)drawing_xorelarc}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
757 {"xorline", (method)drawing_xorline}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
758 {"xorpoly", (method)drawing_xorpoly}, |
| 6 | 759 |
| 760 /* Text measuring methods: */ | |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
761 {"baseline", (method)drawing_baseline}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
762 {"lineheight", (method)drawing_lineheight}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
763 {"textbreak", (method)drawing_textbreak}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
764 {"textwidth", (method)drawing_textwidth}, |
|
171
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
765 |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
766 /* Font setting methods: */ |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
767 {"setfont", (method)drawing_setfont}, |
|
171
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
768 |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
769 /* Color methods: */ |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
770 {"getbgcolor", (method)drawing_getbgcolor}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
771 {"getfgcolor", (method)drawing_getfgcolor}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
772 {"setbgcolor", (method)drawing_setbgcolor}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
773 {"setfgcolor", (method)drawing_setfgcolor}, |
|
171
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
774 |
| 6 | 775 {NULL, NULL} /* sentinel */ |
| 776 }; | |
| 777 | |
| 778 static object * | |
|
594
47c42ea67a8b
Added close method for menus.
Guido van Rossum <guido@python.org>
parents:
499
diff
changeset
|
779 drawing_getattr(dp, name) |
|
47c42ea67a8b
Added close method for menus.
Guido van Rossum <guido@python.org>
parents:
499
diff
changeset
|
780 drawingobject *dp; |
| 6 | 781 char *name; |
| 782 { | |
|
594
47c42ea67a8b
Added close method for menus.
Guido van Rossum <guido@python.org>
parents:
499
diff
changeset
|
783 if (dp->d_ref == NULL) { |
|
47c42ea67a8b
Added close method for menus.
Guido van Rossum <guido@python.org>
parents:
499
diff
changeset
|
784 err_setstr(StdwinError, "drawing object already closed"); |
|
47c42ea67a8b
Added close method for menus.
Guido van Rossum <guido@python.org>
parents:
499
diff
changeset
|
785 return NULL; |
|
47c42ea67a8b
Added close method for menus.
Guido van Rossum <guido@python.org>
parents:
499
diff
changeset
|
786 } |
|
47c42ea67a8b
Added close method for menus.
Guido van Rossum <guido@python.org>
parents:
499
diff
changeset
|
787 return findmethod(drawing_methods, (object *)dp, name); |
| 6 | 788 } |
| 789 | |
|
233
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
790 typeobject Drawingtype = { |
| 6 | 791 OB_HEAD_INIT(&Typetype) |
| 792 0, /*ob_size*/ | |
| 793 "drawing", /*tp_name*/ | |
| 794 sizeof(drawingobject), /*tp_size*/ | |
| 795 0, /*tp_itemsize*/ | |
| 796 /* methods */ | |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
797 (destructor)drawing_dealloc, /*tp_dealloc*/ |
| 6 | 798 0, /*tp_print*/ |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
799 (getattrfunc)drawing_getattr, /*tp_getattr*/ |
| 6 | 800 0, /*tp_setattr*/ |
| 801 0, /*tp_compare*/ | |
| 802 0, /*tp_repr*/ | |
| 803 }; | |
| 804 | |
| 805 | |
| 806 /* Text(edit) objects */ | |
| 807 | |
| 808 typedef struct { | |
| 809 OB_HEAD | |
| 810 TEXTEDIT *t_text; | |
| 811 windowobject *t_ref; | |
| 812 object *t_attr; /* Attributes dictionary */ | |
| 813 } textobject; | |
| 814 | |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
815 staticforward typeobject Texttype; |
| 6 | 816 |
| 817 static textobject * | |
| 818 newtextobject(wp, left, top, right, bottom) | |
| 819 windowobject *wp; | |
| 820 int left, top, right, bottom; | |
| 821 { | |
| 822 textobject *tp; | |
| 823 tp = NEWOBJ(textobject, &Texttype); | |
| 824 if (tp == NULL) | |
| 825 return NULL; | |
| 826 tp->t_attr = NULL; | |
| 827 INCREF(wp); | |
| 828 tp->t_ref = wp; | |
| 829 tp->t_text = tecreate(wp->w_win, left, top, right, bottom); | |
| 830 if (tp->t_text == NULL) { | |
| 831 DECREF(tp); | |
| 832 return (textobject *) err_nomem(); | |
| 833 } | |
| 834 return tp; | |
| 835 } | |
| 836 | |
| 837 /* Text(edit) methods */ | |
| 838 | |
| 839 static void | |
| 840 text_dealloc(tp) | |
| 841 textobject *tp; | |
| 842 { | |
| 843 if (tp->t_text != NULL) | |
| 844 tefree(tp->t_text); | |
|
453
34abca182f18
Enclosed method lists in braces.
Guido van Rossum <guido@python.org>
parents:
397
diff
changeset
|
845 XDECREF(tp->t_attr); |
|
34abca182f18
Enclosed method lists in braces.
Guido van Rossum <guido@python.org>
parents:
397
diff
changeset
|
846 XDECREF(tp->t_ref); |
|
34abca182f18
Enclosed method lists in braces.
Guido van Rossum <guido@python.org>
parents:
397
diff
changeset
|
847 DEL(tp); |
|
34abca182f18
Enclosed method lists in braces.
Guido van Rossum <guido@python.org>
parents:
397
diff
changeset
|
848 } |
|
34abca182f18
Enclosed method lists in braces.
Guido van Rossum <guido@python.org>
parents:
397
diff
changeset
|
849 |
|
34abca182f18
Enclosed method lists in braces.
Guido van Rossum <guido@python.org>
parents:
397
diff
changeset
|
850 static object * |
|
34abca182f18
Enclosed method lists in braces.
Guido van Rossum <guido@python.org>
parents:
397
diff
changeset
|
851 text_close(tp, args) |
|
34abca182f18
Enclosed method lists in braces.
Guido van Rossum <guido@python.org>
parents:
397
diff
changeset
|
852 textobject *tp; |
|
34abca182f18
Enclosed method lists in braces.
Guido van Rossum <guido@python.org>
parents:
397
diff
changeset
|
853 object *args; |
|
34abca182f18
Enclosed method lists in braces.
Guido van Rossum <guido@python.org>
parents:
397
diff
changeset
|
854 { |
|
34abca182f18
Enclosed method lists in braces.
Guido van Rossum <guido@python.org>
parents:
397
diff
changeset
|
855 if (tp->t_text != NULL) { |
|
34abca182f18
Enclosed method lists in braces.
Guido van Rossum <guido@python.org>
parents:
397
diff
changeset
|
856 tefree(tp->t_text); |
|
34abca182f18
Enclosed method lists in braces.
Guido van Rossum <guido@python.org>
parents:
397
diff
changeset
|
857 tp->t_text = NULL; |
|
34abca182f18
Enclosed method lists in braces.
Guido van Rossum <guido@python.org>
parents:
397
diff
changeset
|
858 } |
|
34abca182f18
Enclosed method lists in braces.
Guido van Rossum <guido@python.org>
parents:
397
diff
changeset
|
859 if (tp->t_attr != NULL) { |
| 6 | 860 DECREF(tp->t_attr); |
|
453
34abca182f18
Enclosed method lists in braces.
Guido van Rossum <guido@python.org>
parents:
397
diff
changeset
|
861 tp->t_attr = NULL; |
|
34abca182f18
Enclosed method lists in braces.
Guido van Rossum <guido@python.org>
parents:
397
diff
changeset
|
862 } |
|
34abca182f18
Enclosed method lists in braces.
Guido van Rossum <guido@python.org>
parents:
397
diff
changeset
|
863 if (tp->t_ref != NULL) { |
|
34abca182f18
Enclosed method lists in braces.
Guido van Rossum <guido@python.org>
parents:
397
diff
changeset
|
864 DECREF(tp->t_ref); |
|
34abca182f18
Enclosed method lists in braces.
Guido van Rossum <guido@python.org>
parents:
397
diff
changeset
|
865 tp->t_ref = NULL; |
|
34abca182f18
Enclosed method lists in braces.
Guido van Rossum <guido@python.org>
parents:
397
diff
changeset
|
866 } |
|
34abca182f18
Enclosed method lists in braces.
Guido van Rossum <guido@python.org>
parents:
397
diff
changeset
|
867 INCREF(None); |
|
34abca182f18
Enclosed method lists in braces.
Guido van Rossum <guido@python.org>
parents:
397
diff
changeset
|
868 return None; |
| 6 | 869 } |
| 870 | |
| 871 static object * | |
| 872 text_arrow(self, args) | |
| 873 textobject *self; | |
| 874 object *args; | |
| 875 { | |
| 876 int code; | |
| 877 if (!getintarg(args, &code)) | |
| 878 return NULL; | |
| 879 tearrow(self->t_text, code); | |
| 880 INCREF(None); | |
| 881 return None; | |
| 882 } | |
| 883 | |
| 884 static object * | |
| 885 text_draw(self, args) | |
| 886 textobject *self; | |
| 887 object *args; | |
| 888 { | |
| 889 register TEXTEDIT *tp = self->t_text; | |
| 890 int a[4]; | |
| 891 int left, top, right, bottom; | |
| 892 if (!getrectarg(args, a)) | |
| 893 return NULL; | |
| 894 if (Drawing != NULL) { | |
| 475 | 895 err_setstr(StdwinError, "already drawing"); |
| 6 | 896 return NULL; |
| 897 } | |
| 898 /* Clip to text area and ignore if area is empty */ | |
| 899 left = tegetleft(tp); | |
| 900 top = tegettop(tp); | |
| 901 right = tegetright(tp); | |
| 902 bottom = tegetbottom(tp); | |
| 903 if (a[0] < left) a[0] = left; | |
| 904 if (a[1] < top) a[1] = top; | |
| 905 if (a[2] > right) a[2] = right; | |
| 906 if (a[3] > bottom) a[3] = bottom; | |
| 907 if (a[0] < a[2] && a[1] < a[3]) { | |
| 908 wbegindrawing(self->t_ref->w_win); | |
| 909 tedrawnew(tp, a[0], a[1], a[2], a[3]); | |
| 910 wenddrawing(self->t_ref->w_win); | |
| 911 } | |
| 912 INCREF(None); | |
| 913 return None; | |
| 914 } | |
| 915 | |
| 916 static object * | |
| 917 text_event(self, args) | |
| 918 textobject *self; | |
| 919 object *args; | |
| 920 { | |
| 921 register TEXTEDIT *tp = self->t_text; | |
| 922 EVENT e; | |
| 923 if (!geteventarg(args, &e)) | |
| 924 return NULL; | |
| 925 if (e.type == WE_MOUSE_DOWN) { | |
|
137
82ef94b8b902
Add getdefwinpos, getdefwinsize;
Guido van Rossum <guido@python.org>
parents:
114
diff
changeset
|
926 /* Cheat at the margins */ |
|
82ef94b8b902
Add getdefwinpos, getdefwinsize;
Guido van Rossum <guido@python.org>
parents:
114
diff
changeset
|
927 int width, height; |
|
82ef94b8b902
Add getdefwinpos, getdefwinsize;
Guido van Rossum <guido@python.org>
parents:
114
diff
changeset
|
928 wgetdocsize(e.window, &width, &height); |
| 6 | 929 if (e.u.where.h < 0 && tegetleft(tp) == 0) |
| 930 e.u.where.h = 0; | |
|
137
82ef94b8b902
Add getdefwinpos, getdefwinsize;
Guido van Rossum <guido@python.org>
parents:
114
diff
changeset
|
931 else if (e.u.where.h > width && tegetright(tp) == width) |
|
82ef94b8b902
Add getdefwinpos, getdefwinsize;
Guido van Rossum <guido@python.org>
parents:
114
diff
changeset
|
932 e.u.where.h = width; |
|
82ef94b8b902
Add getdefwinpos, getdefwinsize;
Guido van Rossum <guido@python.org>
parents:
114
diff
changeset
|
933 if (e.u.where.v < 0 && tegettop(tp) == 0) |
|
82ef94b8b902
Add getdefwinpos, getdefwinsize;
Guido van Rossum <guido@python.org>
parents:
114
diff
changeset
|
934 e.u.where.v = 0; |
|
82ef94b8b902
Add getdefwinpos, getdefwinsize;
Guido van Rossum <guido@python.org>
parents:
114
diff
changeset
|
935 else if (e.u.where.v > height && tegetright(tp) == height) |
|
82ef94b8b902
Add getdefwinpos, getdefwinsize;
Guido van Rossum <guido@python.org>
parents:
114
diff
changeset
|
936 e.u.where.v = height; |
| 6 | 937 } |
| 938 return newintobject((long) teevent(tp, &e)); | |
| 939 } | |
| 940 | |
| 941 static object * | |
| 942 text_getfocus(self, args) | |
| 943 textobject *self; | |
| 944 object *args; | |
| 945 { | |
| 946 if (!getnoarg(args)) | |
| 947 return NULL; | |
| 948 return makepoint(tegetfoc1(self->t_text), tegetfoc2(self->t_text)); | |
| 949 } | |
| 950 | |
| 951 static object * | |
| 952 text_getfocustext(self, args) | |
| 953 textobject *self; | |
| 954 object *args; | |
| 955 { | |
| 956 int f1, f2; | |
| 957 char *text; | |
| 958 if (!getnoarg(args)) | |
| 959 return NULL; | |
| 960 f1 = tegetfoc1(self->t_text); | |
| 961 f2 = tegetfoc2(self->t_text); | |
| 962 text = tegettext(self->t_text); | |
| 963 return newsizedstringobject(text + f1, f2-f1); | |
| 964 } | |
| 965 | |
| 966 static object * | |
| 967 text_getrect(self, args) | |
| 968 textobject *self; | |
| 969 object *args; | |
| 970 { | |
| 971 if (!getnoarg(args)) | |
| 972 return NULL; | |
| 973 return makerect(tegetleft(self->t_text), | |
| 974 tegettop(self->t_text), | |
| 975 tegetright(self->t_text), | |
| 976 tegetbottom(self->t_text)); | |
| 977 } | |
| 978 | |
| 979 static object * | |
| 980 text_gettext(self, args) | |
| 981 textobject *self; | |
| 982 object *args; | |
| 983 { | |
| 984 if (!getnoarg(args)) | |
| 985 return NULL; | |
| 986 return newsizedstringobject(tegettext(self->t_text), | |
| 987 tegetlen(self->t_text)); | |
| 988 } | |
| 989 | |
| 990 static object * | |
| 991 text_move(self, args) | |
| 992 textobject *self; | |
| 993 object *args; | |
| 994 { | |
| 995 int a[4]; | |
| 996 if (!getrectarg(args, a)) | |
| 997 return NULL; | |
| 998 temovenew(self->t_text, a[0], a[1], a[2], a[3]); | |
| 999 INCREF(None); | |
| 1000 return None; | |
| 1001 } | |
| 1002 | |
| 1003 static object * | |
|
248
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
1004 text_replace(self, args) |
|
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
1005 textobject *self; |
|
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
1006 object *args; |
|
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
1007 { |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
1008 char *text; |
|
248
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
1009 if (!getstrarg(args, &text)) |
|
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
1010 return NULL; |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
1011 tereplace(self->t_text, text); |
|
248
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
1012 INCREF(None); |
|
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
1013 return None; |
|
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
1014 } |
|
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
1015 |
|
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
1016 static object * |
|
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
1017 text_setactive(self, args) |
|
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
1018 textobject *self; |
|
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
1019 object *args; |
|
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
1020 { |
|
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
1021 int flag; |
|
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
1022 if (!getintarg(args, &flag)) |
|
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
1023 return NULL; |
|
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
1024 tesetactive(self->t_text, flag); |
|
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
1025 INCREF(None); |
|
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
1026 return None; |
|
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
1027 } |
|
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
1028 |
|
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
1029 static object * |
| 6 | 1030 text_setfocus(self, args) |
| 1031 textobject *self; | |
| 1032 object *args; | |
| 1033 { | |
| 1034 int a[2]; | |
| 1035 if (!getpointarg(args, a)) | |
| 1036 return NULL; | |
| 1037 tesetfocus(self->t_text, a[0], a[1]); | |
| 1038 INCREF(None); | |
| 1039 return None; | |
| 1040 } | |
| 1041 | |
| 1042 static object * | |
|
233
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
1043 text_settext(self, args) |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
1044 textobject *self; |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
1045 object *args; |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
1046 { |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
1047 char *text; |
|
233
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
1048 char *buf; |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
1049 int size; |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
1050 if (!getargs(args, "s#", &text, &size)) |
|
233
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
1051 return NULL; |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
1052 if ((buf = NEW(char, size)) == NULL) { |
| 475 | 1053 return err_nomem(); |
|
233
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
1054 } |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
1055 memcpy(buf, text, size); |
|
233
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
1056 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
|
1057 INCREF(None); |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
1058 return None; |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
1059 } |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
1060 |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
1061 static object * |
|
248
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
1062 text_setview(self, args) |
| 6 | 1063 textobject *self; |
| 1064 object *args; | |
| 1065 { | |
|
248
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
1066 int a[4]; |
|
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
1067 if (args == None) |
|
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
1068 tenoview(self->t_text); |
|
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
1069 else { |
|
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
1070 if (!getrectarg(args, a)) |
|
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
1071 return NULL; |
|
9eb13c67ae6f
Added text.setactive and text.setview.
Guido van Rossum <guido@python.org>
parents:
244
diff
changeset
|
1072 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
|
1073 } |
| 6 | 1074 INCREF(None); |
| 1075 return None; | |
| 1076 } | |
| 1077 | |
| 1078 static struct methodlist text_methods[] = { | |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
1079 {"arrow", (method)text_arrow}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
1080 {"close", (method)text_close}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
1081 {"draw", (method)text_draw}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
1082 {"event", (method)text_event}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
1083 {"getfocus", (method)text_getfocus}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
1084 {"getfocustext",(method)text_getfocustext}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
1085 {"getrect", (method)text_getrect}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
1086 {"gettext", (method)text_gettext}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
1087 {"move", (method)text_move}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
1088 {"replace", (method)text_replace}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
1089 {"setactive", (method)text_setactive}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
1090 {"setfocus", (method)text_setfocus}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
1091 {"settext", (method)text_settext}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
1092 {"setview", (method)text_setview}, |
| 6 | 1093 {NULL, NULL} /* sentinel */ |
| 1094 }; | |
| 1095 | |
| 1096 static object * | |
| 1097 text_getattr(tp, name) | |
| 1098 textobject *tp; | |
| 1099 char *name; | |
| 1100 { | |
|
397
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1101 object *v = NULL; |
|
594
47c42ea67a8b
Added close method for menus.
Guido van Rossum <guido@python.org>
parents:
499
diff
changeset
|
1102 if (tp->t_ref == NULL) { |
|
47c42ea67a8b
Added close method for menus.
Guido van Rossum <guido@python.org>
parents:
499
diff
changeset
|
1103 err_setstr(StdwinError, "text object already closed"); |
|
47c42ea67a8b
Added close method for menus.
Guido van Rossum <guido@python.org>
parents:
499
diff
changeset
|
1104 return NULL; |
|
47c42ea67a8b
Added close method for menus.
Guido van Rossum <guido@python.org>
parents:
499
diff
changeset
|
1105 } |
|
397
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1106 if (strcmp(name, "__dict__") == 0) { |
|
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1107 v = tp->t_attr; |
|
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1108 if (v == NULL) |
|
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1109 v = None; |
|
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1110 } |
|
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1111 else if (tp->t_attr != NULL) { |
|
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1112 v = dictlookup(tp->t_attr, name); |
|
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1113 } |
|
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1114 if (v != NULL) { |
|
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1115 INCREF(v); |
|
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1116 return v; |
| 6 | 1117 } |
| 1118 return findmethod(text_methods, (object *)tp, name); | |
| 1119 } | |
| 1120 | |
| 1121 static int | |
| 1122 text_setattr(tp, name, v) | |
| 1123 textobject *tp; | |
| 1124 char *name; | |
| 1125 object *v; | |
| 1126 { | |
| 1127 if (tp->t_attr == NULL) { | |
| 1128 tp->t_attr = newdictobject(); | |
| 1129 if (tp->t_attr == NULL) | |
| 1130 return -1; | |
| 1131 } | |
|
1031
7a11a70f7f44
classobject.c moduleobject.c stdwinmodule.c xxobject.c:
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1132 if (v == NULL) { |
|
7a11a70f7f44
classobject.c moduleobject.c stdwinmodule.c xxobject.c:
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1133 int rv = dictremove(tp->t_attr, name); |
|
7a11a70f7f44
classobject.c moduleobject.c stdwinmodule.c xxobject.c:
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1134 if (rv < 0) |
|
7a11a70f7f44
classobject.c moduleobject.c stdwinmodule.c xxobject.c:
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1135 err_setstr(AttributeError, |
|
7a11a70f7f44
classobject.c moduleobject.c stdwinmodule.c xxobject.c:
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1136 "delete non-existing text object attribute"); |
|
7a11a70f7f44
classobject.c moduleobject.c stdwinmodule.c xxobject.c:
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1137 return rv; |
|
7a11a70f7f44
classobject.c moduleobject.c stdwinmodule.c xxobject.c:
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1138 } |
| 6 | 1139 else |
| 1140 return dictinsert(tp->t_attr, name, v); | |
| 1141 } | |
| 1142 | |
| 2506 | 1143 statichere typeobject Texttype = { |
| 6 | 1144 OB_HEAD_INIT(&Typetype) |
| 1145 0, /*ob_size*/ | |
| 1146 "textedit", /*tp_name*/ | |
| 1147 sizeof(textobject), /*tp_size*/ | |
| 1148 0, /*tp_itemsize*/ | |
| 1149 /* methods */ | |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
1150 (destructor)text_dealloc, /*tp_dealloc*/ |
| 6 | 1151 0, /*tp_print*/ |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
1152 (getattrfunc)text_getattr, /*tp_getattr*/ |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
1153 (setattrfunc)text_setattr, /*tp_setattr*/ |
| 6 | 1154 0, /*tp_compare*/ |
| 1155 0, /*tp_repr*/ | |
| 1156 }; | |
| 1157 | |
| 1158 | |
| 1159 /* Menu objects */ | |
| 1160 | |
|
142
c7ea60491e68
Call winit() here instead of in main initialization.
Guido van Rossum <guido@python.org>
parents:
137
diff
changeset
|
1161 #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
|
1162 #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
|
1163 static menuobject *menulist[MAXNMENU]; |
| 6 | 1164 |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
1165 static menuobject *newmenuobject PROTO((char *)); |
| 6 | 1166 static menuobject * |
| 1167 newmenuobject(title) | |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
1168 char *title; |
| 6 | 1169 { |
| 1170 int id; | |
| 1171 MENU *menu; | |
| 1172 menuobject *mp; | |
|
142
c7ea60491e68
Call winit() here instead of in main initialization.
Guido van Rossum <guido@python.org>
parents:
137
diff
changeset
|
1173 for (id = 0; id < MAXNMENU; id++) { |
| 6 | 1174 if (menulist[id] == NULL) |
| 1175 break; | |
| 1176 } | |
|
207
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
1177 if (id >= MAXNMENU) { |
| 475 | 1178 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
|
1179 return NULL; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
1180 } |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
1181 menu = wmenucreate(id + IDOFFSET, title); |
| 6 | 1182 if (menu == NULL) |
| 1183 return (menuobject *) err_nomem(); | |
| 1184 mp = NEWOBJ(menuobject, &Menutype); | |
| 1185 if (mp != NULL) { | |
| 1186 mp->m_menu = menu; | |
|
142
c7ea60491e68
Call winit() here instead of in main initialization.
Guido van Rossum <guido@python.org>
parents:
137
diff
changeset
|
1187 mp->m_id = id + IDOFFSET; |
| 6 | 1188 mp->m_attr = NULL; |
| 1189 menulist[id] = mp; | |
| 1190 } | |
| 1191 else | |
| 1192 wmenudelete(menu); | |
| 1193 return mp; | |
| 1194 } | |
| 1195 | |
| 1196 /* Menu methods */ | |
| 1197 | |
| 1198 static void | |
| 1199 menu_dealloc(mp) | |
| 1200 menuobject *mp; | |
| 1201 { | |
| 1202 | |
|
142
c7ea60491e68
Call winit() here instead of in main initialization.
Guido van Rossum <guido@python.org>
parents:
137
diff
changeset
|
1203 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
|
1204 if (id >= 0 && id < MAXNMENU && menulist[id] == mp) { |
| 6 | 1205 menulist[id] = NULL; |
| 1206 } | |
|
594
47c42ea67a8b
Added close method for menus.
Guido van Rossum <guido@python.org>
parents:
499
diff
changeset
|
1207 if (mp->m_menu != NULL) |
|
47c42ea67a8b
Added close method for menus.
Guido van Rossum <guido@python.org>
parents:
499
diff
changeset
|
1208 wmenudelete(mp->m_menu); |
|
47c42ea67a8b
Added close method for menus.
Guido van Rossum <guido@python.org>
parents:
499
diff
changeset
|
1209 XDECREF(mp->m_attr); |
| 6 | 1210 DEL(mp); |
| 1211 } | |
| 1212 | |
| 1213 static object * | |
|
594
47c42ea67a8b
Added close method for menus.
Guido van Rossum <guido@python.org>
parents:
499
diff
changeset
|
1214 menu_close(mp, args) |
|
47c42ea67a8b
Added close method for menus.
Guido van Rossum <guido@python.org>
parents:
499
diff
changeset
|
1215 menuobject *mp; |
|
47c42ea67a8b
Added close method for menus.
Guido van Rossum <guido@python.org>
parents:
499
diff
changeset
|
1216 object *args; |
|
47c42ea67a8b
Added close method for menus.
Guido van Rossum <guido@python.org>
parents:
499
diff
changeset
|
1217 { |
|
47c42ea67a8b
Added close method for menus.
Guido van Rossum <guido@python.org>
parents:
499
diff
changeset
|
1218 int id = mp->m_id - IDOFFSET; |
|
47c42ea67a8b
Added close method for menus.
Guido van Rossum <guido@python.org>
parents:
499
diff
changeset
|
1219 if (id >= 0 && id < MAXNMENU && menulist[id] == mp) { |
|
47c42ea67a8b
Added close method for menus.
Guido van Rossum <guido@python.org>
parents:
499
diff
changeset
|
1220 menulist[id] = NULL; |
|
47c42ea67a8b
Added close method for menus.
Guido van Rossum <guido@python.org>
parents:
499
diff
changeset
|
1221 } |
|
47c42ea67a8b
Added close method for menus.
Guido van Rossum <guido@python.org>
parents:
499
diff
changeset
|
1222 mp->m_id = -1; |
|
47c42ea67a8b
Added close method for menus.
Guido van Rossum <guido@python.org>
parents:
499
diff
changeset
|
1223 if (mp->m_menu != NULL) |
|
47c42ea67a8b
Added close method for menus.
Guido van Rossum <guido@python.org>
parents:
499
diff
changeset
|
1224 wmenudelete(mp->m_menu); |
|
47c42ea67a8b
Added close method for menus.
Guido van Rossum <guido@python.org>
parents:
499
diff
changeset
|
1225 mp->m_menu = NULL; |
|
47c42ea67a8b
Added close method for menus.
Guido van Rossum <guido@python.org>
parents:
499
diff
changeset
|
1226 XDECREF(mp->m_attr); |
|
47c42ea67a8b
Added close method for menus.
Guido van Rossum <guido@python.org>
parents:
499
diff
changeset
|
1227 mp->m_attr = NULL; |
|
47c42ea67a8b
Added close method for menus.
Guido van Rossum <guido@python.org>
parents:
499
diff
changeset
|
1228 INCREF(None); |
|
47c42ea67a8b
Added close method for menus.
Guido van Rossum <guido@python.org>
parents:
499
diff
changeset
|
1229 return None; |
|
47c42ea67a8b
Added close method for menus.
Guido van Rossum <guido@python.org>
parents:
499
diff
changeset
|
1230 } |
|
47c42ea67a8b
Added close method for menus.
Guido van Rossum <guido@python.org>
parents:
499
diff
changeset
|
1231 |
|
47c42ea67a8b
Added close method for menus.
Guido van Rossum <guido@python.org>
parents:
499
diff
changeset
|
1232 static object * |
| 6 | 1233 menu_additem(self, args) |
| 1234 menuobject *self; | |
| 1235 object *args; | |
| 1236 { | |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
1237 char *text; |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
1238 int shortcut = -1; |
| 6 | 1239 if (is_tupleobject(args)) { |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
1240 char c; |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
1241 if (!getargs(args, "(sc)", &text, &c)) |
| 6 | 1242 return NULL; |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
1243 shortcut = c; |
| 6 | 1244 } |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
1245 else if (!getstrarg(args, &text)) |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
1246 return NULL; |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
1247 wmenuadditem(self->m_menu, text, shortcut); |
| 6 | 1248 INCREF(None); |
| 1249 return None; | |
| 1250 } | |
| 1251 | |
| 1252 static object * | |
| 1253 menu_setitem(self, args) | |
| 1254 menuobject *self; | |
| 1255 object *args; | |
| 1256 { | |
| 1257 int index; | |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
1258 char *text; |
|
1313
6ee380349c84
* Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents:
1211
diff
changeset
|
1259 if (!getargs(args, "(is)", &index, &text)) |
| 6 | 1260 return NULL; |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
1261 wmenusetitem(self->m_menu, index, text); |
| 6 | 1262 INCREF(None); |
| 1263 return None; | |
| 1264 } | |
| 1265 | |
| 1266 static object * | |
| 1267 menu_enable(self, args) | |
| 1268 menuobject *self; | |
| 1269 object *args; | |
| 1270 { | |
| 1271 int index; | |
| 1272 int flag; | |
|
1313
6ee380349c84
* Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents:
1211
diff
changeset
|
1273 if (!getargs(args, "(ii)", &index, &flag)) |
| 6 | 1274 return NULL; |
| 1275 wmenuenable(self->m_menu, index, flag); | |
| 1276 INCREF(None); | |
| 1277 return None; | |
| 1278 } | |
| 1279 | |
| 1280 static object * | |
| 1281 menu_check(self, args) | |
| 1282 menuobject *self; | |
| 1283 object *args; | |
| 1284 { | |
| 1285 int index; | |
| 1286 int flag; | |
|
1313
6ee380349c84
* Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents:
1211
diff
changeset
|
1287 if (!getargs(args, "(ii)", &index, &flag)) |
| 6 | 1288 return NULL; |
| 1289 wmenucheck(self->m_menu, index, flag); | |
| 1290 INCREF(None); | |
| 1291 return None; | |
| 1292 } | |
| 1293 | |
| 1294 static struct methodlist menu_methods[] = { | |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
1295 {"additem", (method)menu_additem}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
1296 {"setitem", (method)menu_setitem}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
1297 {"enable", (method)menu_enable}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
1298 {"check", (method)menu_check}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
1299 {"close", (method)menu_close}, |
| 6 | 1300 {NULL, NULL} /* sentinel */ |
| 1301 }; | |
| 1302 | |
| 1303 static object * | |
| 1304 menu_getattr(mp, name) | |
| 1305 menuobject *mp; | |
| 1306 char *name; | |
| 1307 { | |
|
397
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1308 object *v = NULL; |
|
594
47c42ea67a8b
Added close method for menus.
Guido van Rossum <guido@python.org>
parents:
499
diff
changeset
|
1309 if (mp->m_menu == NULL) { |
|
47c42ea67a8b
Added close method for menus.
Guido van Rossum <guido@python.org>
parents:
499
diff
changeset
|
1310 err_setstr(StdwinError, "menu object already closed"); |
|
47c42ea67a8b
Added close method for menus.
Guido van Rossum <guido@python.org>
parents:
499
diff
changeset
|
1311 return NULL; |
|
47c42ea67a8b
Added close method for menus.
Guido van Rossum <guido@python.org>
parents:
499
diff
changeset
|
1312 } |
|
397
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1313 if (strcmp(name, "__dict__") == 0) { |
|
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1314 v = mp->m_attr; |
|
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1315 if (v == NULL) |
|
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1316 v = None; |
|
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1317 } |
|
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1318 else if (mp->m_attr != NULL) { |
|
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1319 v = dictlookup(mp->m_attr, name); |
|
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1320 } |
|
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1321 if (v != NULL) { |
|
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1322 INCREF(v); |
|
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1323 return v; |
| 6 | 1324 } |
| 1325 return findmethod(menu_methods, (object *)mp, name); | |
| 1326 } | |
| 1327 | |
| 1328 static int | |
| 1329 menu_setattr(mp, name, v) | |
| 1330 menuobject *mp; | |
| 1331 char *name; | |
| 1332 object *v; | |
| 1333 { | |
| 1334 if (mp->m_attr == NULL) { | |
| 1335 mp->m_attr = newdictobject(); | |
| 1336 if (mp->m_attr == NULL) | |
| 1337 return -1; | |
| 1338 } | |
|
1031
7a11a70f7f44
classobject.c moduleobject.c stdwinmodule.c xxobject.c:
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1339 if (v == NULL) { |
|
7a11a70f7f44
classobject.c moduleobject.c stdwinmodule.c xxobject.c:
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1340 int rv = dictremove(mp->m_attr, name); |
|
7a11a70f7f44
classobject.c moduleobject.c stdwinmodule.c xxobject.c:
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1341 if (rv < 0) |
|
7a11a70f7f44
classobject.c moduleobject.c stdwinmodule.c xxobject.c:
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1342 err_setstr(AttributeError, |
|
7a11a70f7f44
classobject.c moduleobject.c stdwinmodule.c xxobject.c:
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1343 "delete non-existing menu object attribute"); |
|
7a11a70f7f44
classobject.c moduleobject.c stdwinmodule.c xxobject.c:
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1344 return rv; |
|
7a11a70f7f44
classobject.c moduleobject.c stdwinmodule.c xxobject.c:
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1345 } |
| 6 | 1346 else |
| 1347 return dictinsert(mp->m_attr, name, v); | |
| 1348 } | |
| 1349 | |
| 2506 | 1350 statichere typeobject Menutype = { |
| 6 | 1351 OB_HEAD_INIT(&Typetype) |
| 1352 0, /*ob_size*/ | |
| 1353 "menu", /*tp_name*/ | |
| 1354 sizeof(menuobject), /*tp_size*/ | |
| 1355 0, /*tp_itemsize*/ | |
| 1356 /* methods */ | |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
1357 (destructor)menu_dealloc, /*tp_dealloc*/ |
| 6 | 1358 0, /*tp_print*/ |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
1359 (getattrfunc)menu_getattr, /*tp_getattr*/ |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
1360 (setattrfunc)menu_setattr, /*tp_setattr*/ |
| 6 | 1361 0, /*tp_compare*/ |
| 1362 0, /*tp_repr*/ | |
| 1363 }; | |
| 1364 | |
| 1365 | |
|
1332
e5fb9cdbe050
Final touch before release.
Guido van Rossum <guido@python.org>
parents:
1313
diff
changeset
|
1366 #ifdef HAVE_BITMAPS |
|
e5fb9cdbe050
Final touch before release.
Guido van Rossum <guido@python.org>
parents:
1313
diff
changeset
|
1367 |
|
1211
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1368 /* Bitmaps objects */ |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1369 |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1370 static bitmapobject *newbitmapobject PROTO((int, int)); |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1371 static bitmapobject * |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1372 newbitmapobject(width, height) |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1373 int width, height; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1374 { |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1375 BITMAP *bitmap; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1376 bitmapobject *bp; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1377 bitmap = wnewbitmap(width, height); |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1378 if (bitmap == NULL) |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1379 return (bitmapobject *) err_nomem(); |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1380 bp = NEWOBJ(bitmapobject, &Bitmaptype); |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1381 if (bp != NULL) { |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1382 bp->b_bitmap = bitmap; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1383 bp->b_attr = NULL; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1384 } |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1385 else |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1386 wfreebitmap(bitmap); |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1387 return bp; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1388 } |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1389 |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1390 /* Bitmap methods */ |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1391 |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1392 static void |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1393 bitmap_dealloc(bp) |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1394 bitmapobject *bp; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1395 { |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1396 if (bp->b_bitmap != NULL) |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1397 wfreebitmap(bp->b_bitmap); |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1398 XDECREF(bp->b_attr); |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1399 DEL(bp); |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1400 } |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1401 |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1402 static object * |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1403 bitmap_close(bp, args) |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1404 bitmapobject *bp; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1405 object *args; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1406 { |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1407 if (bp->b_bitmap != NULL) |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1408 wfreebitmap(bp->b_bitmap); |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1409 bp->b_bitmap = NULL; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1410 XDECREF(bp->b_attr); |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1411 bp->b_attr = NULL; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1412 INCREF(None); |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1413 return None; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1414 } |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1415 |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1416 static object * |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1417 bitmap_setbit(self, args) |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1418 bitmapobject *self; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1419 object *args; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1420 { |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1421 int a[3]; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1422 if (!getpointintarg(args, a)) |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1423 return NULL; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1424 wsetbit(self->b_bitmap, a[0], a[1], a[2]); |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1425 INCREF(None); |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1426 return None; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1427 } |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1428 |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1429 static object * |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1430 bitmap_getbit(self, args) |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1431 bitmapobject *self; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1432 object *args; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1433 { |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1434 int a[2]; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1435 if (!getpointarg(args, a)) |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1436 return NULL; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1437 return newintobject((long) wgetbit(self->b_bitmap, a[0], a[1])); |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1438 } |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1439 |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1440 static object * |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1441 bitmap_getsize(self, args) |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1442 bitmapobject *self; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1443 object *args; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1444 { |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1445 int width, height; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1446 if (!getnoarg(args)) |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1447 return NULL; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1448 wgetbitmapsize(self->b_bitmap, &width, &height); |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1449 return mkvalue("(ii)", width, height); |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1450 } |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1451 |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1452 static struct methodlist bitmap_methods[] = { |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
1453 {"close", (method)bitmap_close}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
1454 {"getsize", (method)bitmap_getsize}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
1455 {"getbit", (method)bitmap_getbit}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
1456 {"setbit", (method)bitmap_setbit}, |
|
1211
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1457 {NULL, NULL} /* sentinel */ |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1458 }; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1459 |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1460 static object * |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1461 bitmap_getattr(bp, name) |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1462 bitmapobject *bp; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1463 char *name; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1464 { |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1465 object *v = NULL; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1466 if (bp->b_bitmap == NULL) { |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1467 err_setstr(StdwinError, "bitmap object already closed"); |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1468 return NULL; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1469 } |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1470 if (strcmp(name, "__dict__") == 0) { |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1471 v = bp->b_attr; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1472 if (v == NULL) |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1473 v = None; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1474 } |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1475 else if (bp->b_attr != NULL) { |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1476 v = dictlookup(bp->b_attr, name); |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1477 } |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1478 if (v != NULL) { |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1479 INCREF(v); |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1480 return v; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1481 } |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1482 return findmethod(bitmap_methods, (object *)bp, name); |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1483 } |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1484 |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1485 static int |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1486 bitmap_setattr(bp, name, v) |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1487 bitmapobject *bp; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1488 char *name; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1489 object *v; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1490 { |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1491 if (bp->b_attr == NULL) { |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1492 bp->b_attr = newdictobject(); |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1493 if (bp->b_attr == NULL) |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1494 return -1; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1495 } |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1496 if (v == NULL) { |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1497 int rv = dictremove(bp->b_attr, name); |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1498 if (rv < 0) |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1499 err_setstr(AttributeError, |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1500 "delete non-existing bitmap object attribute"); |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1501 return rv; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1502 } |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1503 else |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1504 return dictinsert(bp->b_attr, name, v); |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1505 } |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1506 |
| 2506 | 1507 statichere typeobject Bitmaptype = { |
|
1211
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1508 OB_HEAD_INIT(&Typetype) |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1509 0, /*ob_size*/ |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1510 "bitmap", /*tp_name*/ |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1511 sizeof(bitmapobject), /*tp_size*/ |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1512 0, /*tp_itemsize*/ |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1513 /* methods */ |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
1514 (destructor)bitmap_dealloc, /*tp_dealloc*/ |
|
1211
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1515 0, /*tp_print*/ |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
1516 (getattrfunc)bitmap_getattr, /*tp_getattr*/ |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
1517 (setattrfunc)bitmap_setattr, /*tp_setattr*/ |
|
1211
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1518 0, /*tp_compare*/ |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1519 0, /*tp_repr*/ |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1520 }; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1521 |
|
1332
e5fb9cdbe050
Final touch before release.
Guido van Rossum <guido@python.org>
parents:
1313
diff
changeset
|
1522 #endif /* HAVE_BITMAPS */ |
|
e5fb9cdbe050
Final touch before release.
Guido van Rossum <guido@python.org>
parents:
1313
diff
changeset
|
1523 |
|
1211
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1524 |
| 6 | 1525 /* Windows */ |
| 1526 | |
| 1527 #define MAXNWIN 50 | |
| 1528 static windowobject *windowlist[MAXNWIN]; | |
| 1529 | |
| 1530 /* Window methods */ | |
| 1531 | |
| 1532 static void | |
| 1533 window_dealloc(wp) | |
| 1534 windowobject *wp; | |
| 1535 { | |
| 1536 if (wp->w_win != NULL) { | |
| 1537 int tag = wgettag(wp->w_win); | |
| 1538 if (tag >= 0 && tag < MAXNWIN) | |
| 1539 windowlist[tag] = NULL; | |
| 1540 else | |
| 1541 fprintf(stderr, "XXX help! tag %d in window_dealloc\n", | |
| 1542 tag); | |
| 1543 wclose(wp->w_win); | |
| 1544 } | |
| 1545 DECREF(wp->w_title); | |
| 1546 if (wp->w_attr != NULL) | |
| 1547 DECREF(wp->w_attr); | |
| 1548 free((char *)wp); | |
| 1549 } | |
| 1550 | |
| 1551 static object * | |
|
453
34abca182f18
Enclosed method lists in braces.
Guido van Rossum <guido@python.org>
parents:
397
diff
changeset
|
1552 window_close(wp, args) |
|
34abca182f18
Enclosed method lists in braces.
Guido van Rossum <guido@python.org>
parents:
397
diff
changeset
|
1553 windowobject *wp; |
|
34abca182f18
Enclosed method lists in braces.
Guido van Rossum <guido@python.org>
parents:
397
diff
changeset
|
1554 object *args; |
|
34abca182f18
Enclosed method lists in braces.
Guido van Rossum <guido@python.org>
parents:
397
diff
changeset
|
1555 { |
|
34abca182f18
Enclosed method lists in braces.
Guido van Rossum <guido@python.org>
parents:
397
diff
changeset
|
1556 if (wp->w_win != NULL) { |
|
34abca182f18
Enclosed method lists in braces.
Guido van Rossum <guido@python.org>
parents:
397
diff
changeset
|
1557 int tag = wgettag(wp->w_win); |
|
34abca182f18
Enclosed method lists in braces.
Guido van Rossum <guido@python.org>
parents:
397
diff
changeset
|
1558 if (tag >= 0 && tag < MAXNWIN) |
|
34abca182f18
Enclosed method lists in braces.
Guido van Rossum <guido@python.org>
parents:
397
diff
changeset
|
1559 windowlist[tag] = NULL; |
|
34abca182f18
Enclosed method lists in braces.
Guido van Rossum <guido@python.org>
parents:
397
diff
changeset
|
1560 wclose(wp->w_win); |
|
34abca182f18
Enclosed method lists in braces.
Guido van Rossum <guido@python.org>
parents:
397
diff
changeset
|
1561 wp->w_win = NULL; |
|
34abca182f18
Enclosed method lists in braces.
Guido van Rossum <guido@python.org>
parents:
397
diff
changeset
|
1562 } |
|
34abca182f18
Enclosed method lists in braces.
Guido van Rossum <guido@python.org>
parents:
397
diff
changeset
|
1563 INCREF(None); |
|
34abca182f18
Enclosed method lists in braces.
Guido van Rossum <guido@python.org>
parents:
397
diff
changeset
|
1564 return None; |
|
34abca182f18
Enclosed method lists in braces.
Guido van Rossum <guido@python.org>
parents:
397
diff
changeset
|
1565 } |
|
34abca182f18
Enclosed method lists in braces.
Guido van Rossum <guido@python.org>
parents:
397
diff
changeset
|
1566 |
|
34abca182f18
Enclosed method lists in braces.
Guido van Rossum <guido@python.org>
parents:
397
diff
changeset
|
1567 static object * |
| 6 | 1568 window_begindrawing(wp, args) |
| 1569 windowobject *wp; | |
| 1570 object *args; | |
| 1571 { | |
| 1572 drawingobject *dp; | |
| 1573 if (!getnoarg(args)) | |
| 1574 return NULL; | |
| 1575 if (Drawing != NULL) { | |
| 475 | 1576 err_setstr(StdwinError, "already drawing"); |
| 6 | 1577 return NULL; |
| 1578 } | |
| 1579 dp = NEWOBJ(drawingobject, &Drawingtype); | |
| 1580 if (dp == NULL) | |
| 1581 return NULL; | |
| 1582 Drawing = dp; | |
| 1583 INCREF(wp); | |
| 1584 dp->d_ref = wp; | |
| 1585 wbegindrawing(wp->w_win); | |
| 1586 return (object *)dp; | |
| 1587 } | |
| 1588 | |
| 1589 static object * | |
| 1590 window_change(wp, args) | |
| 1591 windowobject *wp; | |
| 1592 object *args; | |
| 1593 { | |
| 1594 int a[4]; | |
| 1595 if (!getrectarg(args, a)) | |
| 1596 return NULL; | |
| 1597 wchange(wp->w_win, a[0], a[1], a[2], a[3]); | |
| 1598 INCREF(None); | |
| 1599 return None; | |
| 1600 } | |
| 1601 | |
| 1602 static object * | |
| 1603 window_gettitle(wp, args) | |
| 1604 windowobject *wp; | |
| 1605 object *args; | |
| 1606 { | |
| 1607 if (!getnoarg(args)) | |
| 1608 return NULL; | |
| 1609 INCREF(wp->w_title); | |
| 1610 return wp->w_title; | |
| 1611 } | |
| 1612 | |
| 1613 static object * | |
|
233
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
1614 window_getwinpos(wp, args) |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
1615 windowobject *wp; |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
1616 object *args; |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
1617 { |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
1618 int h, v; |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
1619 if (!getnoarg(args)) |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
1620 return NULL; |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
1621 wgetwinpos(wp->w_win, &h, &v); |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
1622 return makepoint(h, v); |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
1623 } |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
1624 |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
1625 static object * |
| 6 | 1626 window_getwinsize(wp, args) |
| 1627 windowobject *wp; | |
| 1628 object *args; | |
| 1629 { | |
| 1630 int width, height; | |
| 1631 if (!getnoarg(args)) | |
| 1632 return NULL; | |
| 1633 wgetwinsize(wp->w_win, &width, &height); | |
| 1634 return makepoint(width, height); | |
| 1635 } | |
| 1636 | |
| 1637 static object * | |
|
1211
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1638 window_setwinpos(wp, args) |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1639 windowobject *wp; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1640 object *args; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1641 { |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1642 int a[2]; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1643 if (!getpointarg(args, a)) |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1644 return NULL; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1645 wsetwinpos(wp->w_win, a[0], a[1]); |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1646 INCREF(None); |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1647 return None; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1648 } |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1649 |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1650 static object * |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1651 window_setwinsize(wp, args) |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1652 windowobject *wp; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1653 object *args; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1654 { |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1655 int a[2]; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1656 if (!getpointarg(args, a)) |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1657 return NULL; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1658 wsetwinsize(wp->w_win, a[0], a[1]); |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1659 INCREF(None); |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1660 return None; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1661 } |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1662 |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
1663 static object * |
| 6 | 1664 window_getdocsize(wp, args) |
| 1665 windowobject *wp; | |
| 1666 object *args; | |
| 1667 { | |
| 1668 int width, height; | |
| 1669 if (!getnoarg(args)) | |
| 1670 return NULL; | |
| 1671 wgetdocsize(wp->w_win, &width, &height); | |
| 1672 return makepoint(width, height); | |
| 1673 } | |
| 1674 | |
| 1675 static object * | |
| 1676 window_getorigin(wp, args) | |
| 1677 windowobject *wp; | |
| 1678 object *args; | |
| 1679 { | |
| 1680 int width, height; | |
| 1681 if (!getnoarg(args)) | |
| 1682 return NULL; | |
| 1683 wgetorigin(wp->w_win, &width, &height); | |
| 1684 return makepoint(width, height); | |
| 1685 } | |
| 1686 | |
| 1687 static object * | |
| 1688 window_scroll(wp, args) | |
| 1689 windowobject *wp; | |
| 1690 object *args; | |
| 1691 { | |
| 1692 int a[6]; | |
| 1693 if (!getrectpointarg(args, a)) | |
| 1694 return NULL; | |
| 1695 wscroll(wp->w_win, a[0], a[1], a[2], a[3], a[4], a[5]); | |
| 1696 INCREF(None); | |
| 1697 return None; | |
| 1698 } | |
| 1699 | |
| 1700 static object * | |
| 1701 window_setdocsize(wp, args) | |
| 1702 windowobject *wp; | |
| 1703 object *args; | |
| 1704 { | |
| 1705 int a[2]; | |
| 1706 if (!getpointarg(args, a)) | |
| 1707 return NULL; | |
| 1708 wsetdocsize(wp->w_win, a[0], a[1]); | |
| 1709 INCREF(None); | |
| 1710 return None; | |
| 1711 } | |
| 1712 | |
| 1713 static object * | |
| 1714 window_setorigin(wp, args) | |
| 1715 windowobject *wp; | |
| 1716 object *args; | |
| 1717 { | |
| 1718 int a[2]; | |
| 1719 if (!getpointarg(args, a)) | |
| 1720 return NULL; | |
| 1721 wsetorigin(wp->w_win, a[0], a[1]); | |
| 1722 INCREF(None); | |
| 1723 return None; | |
| 1724 } | |
| 1725 | |
| 1726 static object * | |
| 1727 window_settitle(wp, args) | |
| 1728 windowobject *wp; | |
| 1729 object *args; | |
| 1730 { | |
| 1731 object *title; | |
|
1313
6ee380349c84
* Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents:
1211
diff
changeset
|
1732 if (!getargs(args, "S", &title)) |
| 6 | 1733 return NULL; |
| 1734 DECREF(wp->w_title); | |
| 1735 INCREF(title); | |
| 1736 wp->w_title = title; | |
| 1737 wsettitle(wp->w_win, getstringvalue(title)); | |
| 1738 INCREF(None); | |
| 1739 return None; | |
| 1740 } | |
| 1741 | |
| 1742 static object * | |
| 1743 window_show(wp, args) | |
| 1744 windowobject *wp; | |
| 1745 object *args; | |
| 1746 { | |
| 1747 int a[4]; | |
| 1748 if (!getrectarg(args, a)) | |
| 1749 return NULL; | |
| 1750 wshow(wp->w_win, a[0], a[1], a[2], a[3]); | |
| 1751 INCREF(None); | |
| 1752 return None; | |
| 1753 } | |
| 1754 | |
| 1755 static object * | |
| 1756 window_settimer(wp, args) | |
| 1757 windowobject *wp; | |
| 1758 object *args; | |
| 1759 { | |
| 1760 int a; | |
| 1761 if (!getintarg(args, &a)) | |
| 1762 return NULL; | |
| 1763 wsettimer(wp->w_win, a); | |
| 1764 INCREF(None); | |
| 1765 return None; | |
| 1766 } | |
| 1767 | |
| 1768 static object * | |
| 1769 window_menucreate(self, args) | |
| 1770 windowobject *self; | |
| 1771 object *args; | |
| 1772 { | |
| 1773 menuobject *mp; | |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
1774 char *title; |
| 6 | 1775 if (!getstrarg(args, &title)) |
| 1776 return NULL; | |
| 1777 wmenusetdeflocal(1); | |
| 1778 mp = newmenuobject(title); | |
| 1779 if (mp == NULL) | |
| 1780 return NULL; | |
| 1781 wmenuattach(self->w_win, mp->m_menu); | |
| 1782 return (object *)mp; | |
| 1783 } | |
| 1784 | |
| 1785 static object * | |
| 1786 window_textcreate(self, args) | |
| 1787 windowobject *self; | |
| 1788 object *args; | |
| 1789 { | |
| 1790 int a[4]; | |
| 1791 if (!getrectarg(args, a)) | |
| 1792 return NULL; | |
| 1793 return (object *) | |
| 1794 newtextobject(self, a[0], a[1], a[2], a[3]); | |
| 1795 } | |
| 1796 | |
|
51
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
1797 static object * |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
1798 window_setselection(self, args) |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
1799 windowobject *self; |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
1800 object *args; |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
1801 { |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
1802 int sel, size, ok; |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
1803 char *text; |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
1804 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
|
1805 return NULL; |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
1806 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
|
1807 return newintobject(ok); |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
1808 } |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
1809 |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
1810 static object * |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
1811 window_setwincursor(self, args) |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
1812 windowobject *self; |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
1813 object *args; |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
1814 { |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
1815 char *name; |
|
51
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
1816 CURSOR *c; |
|
657
3e626c413bbf
Fixed getargs() call in setfont.
Guido van Rossum <guido@python.org>
parents:
635
diff
changeset
|
1817 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
|
1818 return NULL; |
|
657
3e626c413bbf
Fixed getargs() call in setfont.
Guido van Rossum <guido@python.org>
parents:
635
diff
changeset
|
1819 if (name == NULL) |
|
3e626c413bbf
Fixed getargs() call in setfont.
Guido van Rossum <guido@python.org>
parents:
635
diff
changeset
|
1820 c = NULL; |
|
3e626c413bbf
Fixed getargs() call in setfont.
Guido van Rossum <guido@python.org>
parents:
635
diff
changeset
|
1821 else { |
|
3e626c413bbf
Fixed getargs() call in setfont.
Guido van Rossum <guido@python.org>
parents:
635
diff
changeset
|
1822 c = wfetchcursor(name); |
|
3e626c413bbf
Fixed getargs() call in setfont.
Guido van Rossum <guido@python.org>
parents:
635
diff
changeset
|
1823 if (c == NULL) { |
|
3e626c413bbf
Fixed getargs() call in setfont.
Guido van Rossum <guido@python.org>
parents:
635
diff
changeset
|
1824 err_setstr(StdwinError, "no such cursor"); |
|
3e626c413bbf
Fixed getargs() call in setfont.
Guido van Rossum <guido@python.org>
parents:
635
diff
changeset
|
1825 return NULL; |
|
3e626c413bbf
Fixed getargs() call in setfont.
Guido van Rossum <guido@python.org>
parents:
635
diff
changeset
|
1826 } |
|
51
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
1827 } |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
1828 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
|
1829 INCREF(None); |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
1830 return None; |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
1831 } |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
1832 |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
1833 static object * |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
1834 window_setactive(self, args) |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
1835 windowobject *self; |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
1836 object *args; |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
1837 { |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
1838 if (!getnoarg(args)) |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
1839 return NULL; |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
1840 wsetactive(self->w_win); |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
1841 INCREF(None); |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
1842 return None; |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
1843 } |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
1844 |
|
325
baada20762b0
Added getxwindowin() method
Guido van Rossum <guido@python.org>
parents:
285
diff
changeset
|
1845 #ifdef CWI_HACKS |
|
baada20762b0
Added getxwindowin() method
Guido van Rossum <guido@python.org>
parents:
285
diff
changeset
|
1846 static object * |
|
baada20762b0
Added getxwindowin() method
Guido van Rossum <guido@python.org>
parents:
285
diff
changeset
|
1847 window_getxwindowid(self, args) |
|
baada20762b0
Added getxwindowin() method
Guido van Rossum <guido@python.org>
parents:
285
diff
changeset
|
1848 windowobject *self; |
|
baada20762b0
Added getxwindowin() method
Guido van Rossum <guido@python.org>
parents:
285
diff
changeset
|
1849 object *args; |
|
baada20762b0
Added getxwindowin() method
Guido van Rossum <guido@python.org>
parents:
285
diff
changeset
|
1850 { |
|
baada20762b0
Added getxwindowin() method
Guido van Rossum <guido@python.org>
parents:
285
diff
changeset
|
1851 long wid = wgetxwindowid(self->w_win); |
|
baada20762b0
Added getxwindowin() method
Guido van Rossum <guido@python.org>
parents:
285
diff
changeset
|
1852 return newintobject(wid); |
|
baada20762b0
Added getxwindowin() method
Guido van Rossum <guido@python.org>
parents:
285
diff
changeset
|
1853 } |
|
baada20762b0
Added getxwindowin() method
Guido van Rossum <guido@python.org>
parents:
285
diff
changeset
|
1854 #endif |
|
baada20762b0
Added getxwindowin() method
Guido van Rossum <guido@python.org>
parents:
285
diff
changeset
|
1855 |
| 6 | 1856 static struct methodlist window_methods[] = { |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
1857 {"begindrawing",(method)window_begindrawing}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
1858 {"change", (method)window_change}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
1859 {"close", (method)window_close}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
1860 {"getdocsize", (method)window_getdocsize}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
1861 {"getorigin", (method)window_getorigin}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
1862 {"gettitle", (method)window_gettitle}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
1863 {"getwinpos", (method)window_getwinpos}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
1864 {"getwinsize", (method)window_getwinsize}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
1865 {"menucreate", (method)window_menucreate}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
1866 {"scroll", (method)window_scroll}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
1867 {"setactive", (method)window_setactive}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
1868 {"setdocsize", (method)window_setdocsize}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
1869 {"setorigin", (method)window_setorigin}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
1870 {"setselection",(method)window_setselection}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
1871 {"settimer", (method)window_settimer}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
1872 {"settitle", (method)window_settitle}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
1873 {"setwincursor",(method)window_setwincursor}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
1874 {"setwinpos", (method)window_setwinpos}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
1875 {"setwinsize", (method)window_setwinsize}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
1876 {"show", (method)window_show}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
1877 {"textcreate", (method)window_textcreate}, |
|
325
baada20762b0
Added getxwindowin() method
Guido van Rossum <guido@python.org>
parents:
285
diff
changeset
|
1878 #ifdef CWI_HACKS |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
1879 {"getxwindowid",(method)window_getxwindowid}, |
|
325
baada20762b0
Added getxwindowin() method
Guido van Rossum <guido@python.org>
parents:
285
diff
changeset
|
1880 #endif |
| 6 | 1881 {NULL, NULL} /* sentinel */ |
| 1882 }; | |
| 1883 | |
| 1884 static object * | |
| 1885 window_getattr(wp, name) | |
| 1886 windowobject *wp; | |
| 1887 char *name; | |
| 1888 { | |
|
397
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1889 object *v = NULL; |
|
594
47c42ea67a8b
Added close method for menus.
Guido van Rossum <guido@python.org>
parents:
499
diff
changeset
|
1890 if (wp->w_win == NULL) { |
|
47c42ea67a8b
Added close method for menus.
Guido van Rossum <guido@python.org>
parents:
499
diff
changeset
|
1891 err_setstr(StdwinError, "window already closed"); |
|
47c42ea67a8b
Added close method for menus.
Guido van Rossum <guido@python.org>
parents:
499
diff
changeset
|
1892 return NULL; |
|
47c42ea67a8b
Added close method for menus.
Guido van Rossum <guido@python.org>
parents:
499
diff
changeset
|
1893 } |
|
397
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1894 if (strcmp(name, "__dict__") == 0) { |
|
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1895 v = wp->w_attr; |
|
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1896 if (v == NULL) |
|
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1897 v = None; |
|
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1898 } |
|
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1899 else if (wp->w_attr != NULL) { |
|
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1900 v = dictlookup(wp->w_attr, name); |
|
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1901 } |
|
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1902 if (v != NULL) { |
|
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1903 INCREF(v); |
|
4cdcc16bd080
Added __dict__ attributes all over the place.
Guido van Rossum <guido@python.org>
parents:
325
diff
changeset
|
1904 return v; |
| 6 | 1905 } |
| 1906 return findmethod(window_methods, (object *)wp, name); | |
| 1907 } | |
| 1908 | |
| 1909 static int | |
| 1910 window_setattr(wp, name, v) | |
| 1911 windowobject *wp; | |
| 1912 char *name; | |
| 1913 object *v; | |
| 1914 { | |
| 1915 if (wp->w_attr == NULL) { | |
| 1916 wp->w_attr = newdictobject(); | |
| 1917 if (wp->w_attr == NULL) | |
| 1918 return -1; | |
| 1919 } | |
|
1031
7a11a70f7f44
classobject.c moduleobject.c stdwinmodule.c xxobject.c:
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1920 if (v == NULL) { |
|
7a11a70f7f44
classobject.c moduleobject.c stdwinmodule.c xxobject.c:
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1921 int rv = dictremove(wp->w_attr, name); |
|
7a11a70f7f44
classobject.c moduleobject.c stdwinmodule.c xxobject.c:
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1922 if (rv < 0) |
|
7a11a70f7f44
classobject.c moduleobject.c stdwinmodule.c xxobject.c:
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1923 err_setstr(AttributeError, |
|
7a11a70f7f44
classobject.c moduleobject.c stdwinmodule.c xxobject.c:
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1924 "delete non-existing menu object attribute"); |
|
7a11a70f7f44
classobject.c moduleobject.c stdwinmodule.c xxobject.c:
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1925 return rv; |
|
7a11a70f7f44
classobject.c moduleobject.c stdwinmodule.c xxobject.c:
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1926 } |
| 6 | 1927 else |
| 1928 return dictinsert(wp->w_attr, name, v); | |
| 1929 } | |
| 1930 | |
| 2506 | 1931 statichere typeobject Windowtype = { |
| 6 | 1932 OB_HEAD_INIT(&Typetype) |
| 1933 0, /*ob_size*/ | |
| 1934 "window", /*tp_name*/ | |
| 1935 sizeof(windowobject), /*tp_size*/ | |
| 1936 0, /*tp_itemsize*/ | |
| 1937 /* methods */ | |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
1938 (destructor)window_dealloc, /*tp_dealloc*/ |
|
1051
f54e64c8b9b7
* Makefile: added IMGFILE; moved some stuff around.
Guido van Rossum <guido@python.org>
parents:
1031
diff
changeset
|
1939 0, /*tp_print*/ |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
1940 (getattrfunc)window_getattr, /*tp_getattr*/ |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
1941 (setattrfunc)window_setattr, /*tp_setattr*/ |
| 6 | 1942 0, /*tp_compare*/ |
| 1943 0, /*tp_repr*/ | |
| 1944 }; | |
| 1945 | |
| 1946 /* Stdwin methods */ | |
| 1947 | |
| 1948 static object * | |
|
1353
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
1949 stdwin_done(sw, args) |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
1950 object *sw; |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
1951 object *args; |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
1952 { |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
1953 if (!getnoarg(args)) |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
1954 return NULL; |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
1955 wdone(); |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
1956 /* XXX There is no protection against continued use of |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
1957 XXX stdwin functions or objects after this call is made. |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
1958 XXX Use at own risk */ |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
1959 INCREF(None); |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
1960 return None; |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
1961 } |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
1962 |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
1963 static object * |
| 6 | 1964 stdwin_open(sw, args) |
| 1965 object *sw; | |
| 1966 object *args; | |
| 1967 { | |
| 1968 int tag; | |
| 1969 object *title; | |
| 1970 windowobject *wp; | |
|
1313
6ee380349c84
* Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents:
1211
diff
changeset
|
1971 if (!getargs(args, "S", &title)) |
| 6 | 1972 return NULL; |
| 1973 for (tag = 0; tag < MAXNWIN; tag++) { | |
| 1974 if (windowlist[tag] == NULL) | |
| 1975 break; | |
| 1976 } | |
|
207
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
1977 if (tag >= MAXNWIN) { |
| 475 | 1978 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
|
1979 return NULL; |
|
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
1980 } |
| 6 | 1981 wp = NEWOBJ(windowobject, &Windowtype); |
| 1982 if (wp == NULL) | |
| 1983 return NULL; | |
| 1984 INCREF(title); | |
| 1985 wp->w_title = title; | |
| 1986 wp->w_win = wopen(getstringvalue(title), (void (*)()) NULL); | |
| 1987 wp->w_attr = NULL; | |
| 1988 if (wp->w_win == NULL) { | |
| 1989 DECREF(wp); | |
| 1990 return NULL; | |
| 1991 } | |
| 1992 windowlist[tag] = wp; | |
| 1993 wsettag(wp->w_win, tag); | |
| 1994 return (object *)wp; | |
| 1995 } | |
| 1996 | |
| 1997 static object * | |
|
252
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
1998 window2object(win) |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
1999 WINDOW *win; |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
2000 { |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
2001 object *w; |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
2002 if (win == NULL) |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
2003 w = None; |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
2004 else { |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
2005 int tag = wgettag(win); |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
2006 if (tag < 0 || tag >= MAXNWIN || windowlist[tag] == NULL || |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
2007 windowlist[tag]->w_win != win) |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
2008 w = None; |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
2009 else |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
2010 w = (object *)windowlist[tag]; |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
2011 } |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
2012 INCREF(w); |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
2013 return w; |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
2014 } |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
2015 |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
2016 static object * |
|
114
1efb8ed6afd3
Added pollevent(); returns None if no event available.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
2017 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
|
2018 int poll; |
| 6 | 2019 object *args; |
| 2020 { | |
| 2021 EVENT e; | |
|
818
e157c12cd6e7
Use mkvalue() instead of painfully constructing values
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
2022 object *u, *v, *w; |
| 6 | 2023 if (!getnoarg(args)) |
| 2024 return NULL; | |
| 2025 if (Drawing != NULL) { | |
| 475 | 2026 err_setstr(StdwinError, "cannot getevent() while drawing"); |
| 6 | 2027 return NULL; |
| 2028 } | |
|
252
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
2029 again: |
| 926 | 2030 BGN_STDWIN |
|
114
1efb8ed6afd3
Added pollevent(); returns None if no event available.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
2031 if (poll) { |
|
1efb8ed6afd3
Added pollevent(); returns None if no event available.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
2032 if (!wpollevent(&e)) { |
| 926 | 2033 RET_STDWIN |
|
114
1efb8ed6afd3
Added pollevent(); returns None if no event available.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
2034 INCREF(None); |
|
1efb8ed6afd3
Added pollevent(); returns None if no event available.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
2035 return None; |
|
1efb8ed6afd3
Added pollevent(); returns None if no event available.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
2036 } |
|
1efb8ed6afd3
Added pollevent(); returns None if no event available.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
2037 } |
|
1efb8ed6afd3
Added pollevent(); returns None if no event available.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
2038 else |
|
1efb8ed6afd3
Added pollevent(); returns None if no event available.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
2039 wgetevent(&e); |
| 926 | 2040 END_STDWIN |
| 6 | 2041 if (e.type == WE_COMMAND && e.u.command == WC_CANCEL) { |
| 2042 /* Turn keyboard interrupts into exceptions */ | |
| 2043 err_set(KeyboardInterrupt); | |
| 2044 return NULL; | |
| 2045 } | |
|
65
a72c0a7dc993
Turn close commands into WE_CLOSE events.
Guido van Rossum <guido@python.org>
parents:
51
diff
changeset
|
2046 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
|
2047 /* 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
|
2048 e.type = WE_CLOSE; |
|
a72c0a7dc993
Turn close commands into WE_CLOSE events.
Guido van Rossum <guido@python.org>
parents:
51
diff
changeset
|
2049 } |
|
818
e157c12cd6e7
Use mkvalue() instead of painfully constructing values
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
2050 v = window2object(e.window); |
| 6 | 2051 switch (e.type) { |
| 2052 case WE_CHAR: | |
| 2053 { | |
| 2054 char c[1]; | |
| 2055 c[0] = e.u.character; | |
| 2056 w = newsizedstringobject(c, 1); | |
| 2057 } | |
| 2058 break; | |
| 2059 case WE_COMMAND: | |
| 2060 w = newintobject((long)e.u.command); | |
| 2061 break; | |
| 2062 case WE_DRAW: | |
| 2063 w = makerect(e.u.area.left, e.u.area.top, | |
| 2064 e.u.area.right, e.u.area.bottom); | |
| 2065 break; | |
| 2066 case WE_MOUSE_DOWN: | |
| 2067 case WE_MOUSE_MOVE: | |
| 2068 case WE_MOUSE_UP: | |
|
818
e157c12cd6e7
Use mkvalue() instead of painfully constructing values
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
2069 w = mkvalue("((ii)iii)", |
|
e157c12cd6e7
Use mkvalue() instead of painfully constructing values
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
2070 e.u.where.h, e.u.where.v, |
| 6 | 2071 e.u.where.clicks, |
| 2072 e.u.where.button, | |
| 2073 e.u.where.mask); | |
| 2074 break; | |
| 2075 case WE_MENU: | |
|
142
c7ea60491e68
Call winit() here instead of in main initialization.
Guido van Rossum <guido@python.org>
parents:
137
diff
changeset
|
2076 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
|
2077 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
|
2078 w = mkvalue("(Oi)", |
|
e157c12cd6e7
Use mkvalue() instead of painfully constructing values
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
2079 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
|
2080 else { |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
2081 /* Ghost menu event. |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
2082 Can occur only on the Mac if another part |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
2083 of the aplication has installed a menu; |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
2084 like the THINK C console library. */ |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
2085 DECREF(v); |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
2086 goto again; |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
2087 } |
| 6 | 2088 break; |
|
907
32010d355fb6
added WE_KEY detail format to stdwinmodule.c.
Guido van Rossum <guido@python.org>
parents:
902
diff
changeset
|
2089 case WE_KEY: |
|
32010d355fb6
added WE_KEY detail format to stdwinmodule.c.
Guido van Rossum <guido@python.org>
parents:
902
diff
changeset
|
2090 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
|
2091 break; |
|
51
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2092 case WE_LOST_SEL: |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2093 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
|
2094 break; |
| 6 | 2095 default: |
| 2096 w = None; | |
| 2097 INCREF(w); | |
| 2098 break; | |
| 2099 } | |
| 2100 if (w == NULL) { | |
| 2101 DECREF(v); | |
| 2102 return NULL; | |
| 2103 } | |
|
818
e157c12cd6e7
Use mkvalue() instead of painfully constructing values
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
2104 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
|
2105 XDECREF(v); |
|
e157c12cd6e7
Use mkvalue() instead of painfully constructing values
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
2106 XDECREF(w); |
|
e157c12cd6e7
Use mkvalue() instead of painfully constructing values
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
2107 return u; |
| 6 | 2108 } |
| 2109 | |
| 2110 static object * | |
|
114
1efb8ed6afd3
Added pollevent(); returns None if no event available.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
2111 stdwin_getevent(sw, args) |
|
1efb8ed6afd3
Added pollevent(); returns None if no event available.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
2112 object *sw; |
|
1efb8ed6afd3
Added pollevent(); returns None if no event available.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
2113 object *args; |
|
1efb8ed6afd3
Added pollevent(); returns None if no event available.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
2114 { |
|
1efb8ed6afd3
Added pollevent(); returns None if no event available.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
2115 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
|
2116 } |
|
1efb8ed6afd3
Added pollevent(); returns None if no event available.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
2117 |
|
1efb8ed6afd3
Added pollevent(); returns None if no event available.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
2118 static object * |
|
1efb8ed6afd3
Added pollevent(); returns None if no event available.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
2119 stdwin_pollevent(sw, args) |
|
1efb8ed6afd3
Added pollevent(); returns None if no event available.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
2120 object *sw; |
|
1efb8ed6afd3
Added pollevent(); returns None if no event available.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
2121 object *args; |
|
1efb8ed6afd3
Added pollevent(); returns None if no event available.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
2122 { |
|
1efb8ed6afd3
Added pollevent(); returns None if no event available.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
2123 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
|
2124 } |
|
1efb8ed6afd3
Added pollevent(); returns None if no event available.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
2125 |
|
1efb8ed6afd3
Added pollevent(); returns None if no event available.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
2126 static object * |
| 6 | 2127 stdwin_setdefwinpos(sw, args) |
| 2128 object *sw; | |
| 2129 object *args; | |
| 2130 { | |
| 2131 int a[2]; | |
| 2132 if (!getpointarg(args, a)) | |
| 2133 return NULL; | |
| 2134 wsetdefwinpos(a[0], a[1]); | |
| 2135 INCREF(None); | |
| 2136 return None; | |
| 2137 } | |
| 2138 | |
| 2139 static object * | |
| 2140 stdwin_setdefwinsize(sw, args) | |
| 2141 object *sw; | |
| 2142 object *args; | |
| 2143 { | |
| 2144 int a[2]; | |
| 2145 if (!getpointarg(args, a)) | |
| 2146 return NULL; | |
| 2147 wsetdefwinsize(a[0], a[1]); | |
| 2148 INCREF(None); | |
| 2149 return None; | |
| 2150 } | |
| 2151 | |
| 2152 static object * | |
|
171
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
2153 stdwin_setdefscrollbars(sw, args) |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
2154 object *sw; |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
2155 object *args; |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
2156 { |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
2157 int a[2]; |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
2158 if (!getpointarg(args, a)) |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
2159 return NULL; |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
2160 wsetdefscrollbars(a[0], a[1]); |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
2161 INCREF(None); |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
2162 return None; |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
2163 } |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
2164 |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
2165 static object * |
|
233
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
2166 stdwin_getdefwinpos(self, args) |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
2167 object *self; |
|
137
82ef94b8b902
Add getdefwinpos, getdefwinsize;
Guido van Rossum <guido@python.org>
parents:
114
diff
changeset
|
2168 object *args; |
|
82ef94b8b902
Add getdefwinpos, getdefwinsize;
Guido van Rossum <guido@python.org>
parents:
114
diff
changeset
|
2169 { |
|
82ef94b8b902
Add getdefwinpos, getdefwinsize;
Guido van Rossum <guido@python.org>
parents:
114
diff
changeset
|
2170 int h, v; |
|
82ef94b8b902
Add getdefwinpos, getdefwinsize;
Guido van Rossum <guido@python.org>
parents:
114
diff
changeset
|
2171 if (!getnoarg(args)) |
|
82ef94b8b902
Add getdefwinpos, getdefwinsize;
Guido van Rossum <guido@python.org>
parents:
114
diff
changeset
|
2172 return NULL; |
|
82ef94b8b902
Add getdefwinpos, getdefwinsize;
Guido van Rossum <guido@python.org>
parents:
114
diff
changeset
|
2173 wgetdefwinpos(&h, &v); |
|
82ef94b8b902
Add getdefwinpos, getdefwinsize;
Guido van Rossum <guido@python.org>
parents:
114
diff
changeset
|
2174 return makepoint(h, v); |
|
82ef94b8b902
Add getdefwinpos, getdefwinsize;
Guido van Rossum <guido@python.org>
parents:
114
diff
changeset
|
2175 } |
|
82ef94b8b902
Add getdefwinpos, getdefwinsize;
Guido van Rossum <guido@python.org>
parents:
114
diff
changeset
|
2176 |
|
82ef94b8b902
Add getdefwinpos, getdefwinsize;
Guido van Rossum <guido@python.org>
parents:
114
diff
changeset
|
2177 static object * |
|
233
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
2178 stdwin_getdefwinsize(self, args) |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
2179 object *self; |
|
137
82ef94b8b902
Add getdefwinpos, getdefwinsize;
Guido van Rossum <guido@python.org>
parents:
114
diff
changeset
|
2180 object *args; |
|
82ef94b8b902
Add getdefwinpos, getdefwinsize;
Guido van Rossum <guido@python.org>
parents:
114
diff
changeset
|
2181 { |
|
82ef94b8b902
Add getdefwinpos, getdefwinsize;
Guido van Rossum <guido@python.org>
parents:
114
diff
changeset
|
2182 int width, height; |
|
82ef94b8b902
Add getdefwinpos, getdefwinsize;
Guido van Rossum <guido@python.org>
parents:
114
diff
changeset
|
2183 if (!getnoarg(args)) |
|
82ef94b8b902
Add getdefwinpos, getdefwinsize;
Guido van Rossum <guido@python.org>
parents:
114
diff
changeset
|
2184 return NULL; |
|
82ef94b8b902
Add getdefwinpos, getdefwinsize;
Guido van Rossum <guido@python.org>
parents:
114
diff
changeset
|
2185 wgetdefwinsize(&width, &height); |
|
82ef94b8b902
Add getdefwinpos, getdefwinsize;
Guido van Rossum <guido@python.org>
parents:
114
diff
changeset
|
2186 return makepoint(width, height); |
|
82ef94b8b902
Add getdefwinpos, getdefwinsize;
Guido van Rossum <guido@python.org>
parents:
114
diff
changeset
|
2187 } |
|
82ef94b8b902
Add getdefwinpos, getdefwinsize;
Guido van Rossum <guido@python.org>
parents:
114
diff
changeset
|
2188 |
|
82ef94b8b902
Add getdefwinpos, getdefwinsize;
Guido van Rossum <guido@python.org>
parents:
114
diff
changeset
|
2189 static object * |
|
233
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
2190 stdwin_getdefscrollbars(self, args) |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
2191 object *self; |
|
171
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
2192 object *args; |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
2193 { |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
2194 int h, v; |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
2195 if (!getnoarg(args)) |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
2196 return NULL; |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
2197 wgetdefscrollbars(&h, &v); |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
2198 return makepoint(h, v); |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
2199 } |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
2200 |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
2201 static object * |
| 6 | 2202 stdwin_menucreate(self, args) |
| 2203 object *self; | |
| 2204 object *args; | |
| 2205 { | |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
2206 char *title; |
| 6 | 2207 if (!getstrarg(args, &title)) |
| 2208 return NULL; | |
| 2209 wmenusetdeflocal(0); | |
| 2210 return (object *)newmenuobject(title); | |
| 2211 } | |
| 2212 | |
| 2213 static object * | |
| 2214 stdwin_askfile(self, args) | |
| 2215 object *self; | |
| 2216 object *args; | |
| 2217 { | |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
2218 char *prompt, *dflt; |
| 6 | 2219 int new, ret; |
| 2220 char buf[256]; | |
|
1313
6ee380349c84
* Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents:
1211
diff
changeset
|
2221 if (!getargs(args, "(ssi)", &prompt, &dflt, &new)) |
| 6 | 2222 return NULL; |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
2223 strncpy(buf, dflt, sizeof buf); |
| 6 | 2224 buf[sizeof buf - 1] = '\0'; |
| 926 | 2225 BGN_STDWIN |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
2226 ret = waskfile(prompt, buf, sizeof buf, new); |
| 926 | 2227 END_STDWIN |
| 6 | 2228 if (!ret) { |
| 2229 err_set(KeyboardInterrupt); | |
| 2230 return NULL; | |
| 2231 } | |
| 2232 return newstringobject(buf); | |
| 2233 } | |
| 2234 | |
| 2235 static object * | |
| 2236 stdwin_askync(self, args) | |
| 2237 object *self; | |
| 2238 object *args; | |
| 2239 { | |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
2240 char *prompt; |
| 6 | 2241 int new, ret; |
|
1313
6ee380349c84
* Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents:
1211
diff
changeset
|
2242 if (!getargs(args, "(si)", &prompt, &new)) |
| 6 | 2243 return NULL; |
| 926 | 2244 BGN_STDWIN |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
2245 ret = waskync(prompt, new); |
| 926 | 2246 END_STDWIN |
| 6 | 2247 if (ret < 0) { |
| 2248 err_set(KeyboardInterrupt); | |
| 2249 return NULL; | |
| 2250 } | |
| 2251 return newintobject((long)ret); | |
| 2252 } | |
| 2253 | |
| 2254 static object * | |
| 2255 stdwin_askstr(self, args) | |
| 2256 object *self; | |
| 2257 object *args; | |
| 2258 { | |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
2259 char *prompt, *dflt; |
| 6 | 2260 int ret; |
| 2261 char buf[256]; | |
|
1313
6ee380349c84
* Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents:
1211
diff
changeset
|
2262 if (!getargs(args, "(ss)", &prompt, &dflt)) |
| 6 | 2263 return NULL; |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
2264 strncpy(buf, dflt, sizeof buf); |
| 6 | 2265 buf[sizeof buf - 1] = '\0'; |
| 926 | 2266 BGN_STDWIN |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
2267 ret = waskstr(prompt, buf, sizeof buf); |
| 926 | 2268 END_STDWIN |
| 6 | 2269 if (!ret) { |
| 2270 err_set(KeyboardInterrupt); | |
| 2271 return NULL; | |
| 2272 } | |
| 2273 return newstringobject(buf); | |
| 2274 } | |
| 2275 | |
| 2276 static object * | |
| 2277 stdwin_message(self, args) | |
| 2278 object *self; | |
| 2279 object *args; | |
| 2280 { | |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
2281 char *msg; |
| 6 | 2282 if (!getstrarg(args, &msg)) |
| 2283 return NULL; | |
| 926 | 2284 BGN_STDWIN |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
2285 wmessage(msg); |
| 926 | 2286 END_STDWIN |
| 6 | 2287 INCREF(None); |
| 2288 return None; | |
| 2289 } | |
| 2290 | |
| 2291 static object * | |
| 2292 stdwin_fleep(self, args) | |
| 2293 object *self; | |
| 2294 object *args; | |
| 2295 { | |
| 2296 if (!getnoarg(args)) | |
| 2297 return NULL; | |
| 2298 wfleep(); | |
| 2299 INCREF(None); | |
| 2300 return None; | |
| 2301 } | |
| 2302 | |
| 2303 static object * | |
| 2304 stdwin_setcutbuffer(self, args) | |
| 2305 object *self; | |
| 2306 object *args; | |
| 2307 { | |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
2308 int i, size; |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
2309 char *str; |
|
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
2310 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
|
2311 return NULL; |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
2312 wsetcutbuffer(i, str, size); |
| 6 | 2313 INCREF(None); |
| 2314 return None; | |
| 2315 } | |
| 2316 | |
| 2317 static object * | |
|
252
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
2318 stdwin_getactive(self, args) |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
2319 object *self; |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
2320 object *args; |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
2321 { |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
2322 return window2object(wgetactive()); |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
2323 } |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
2324 |
|
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
2325 static object * |
| 6 | 2326 stdwin_getcutbuffer(self, args) |
| 2327 object *self; | |
| 2328 object *args; | |
| 2329 { | |
|
51
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2330 int i; |
| 6 | 2331 char *str; |
|
50
b94822f54991
Change set/getcutbuffer to use the new stdwin interface.
Guido van Rossum <guido@python.org>
parents:
6
diff
changeset
|
2332 int len; |
|
65
a72c0a7dc993
Turn close commands into WE_CLOSE events.
Guido van Rossum <guido@python.org>
parents:
51
diff
changeset
|
2333 if (!getintarg(args, &i)) |
| 6 | 2334 return NULL; |
|
51
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2335 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
|
2336 if (str == NULL) { |
| 6 | 2337 str = ""; |
|
50
b94822f54991
Change set/getcutbuffer to use the new stdwin interface.
Guido van Rossum <guido@python.org>
parents:
6
diff
changeset
|
2338 len = 0; |
|
b94822f54991
Change set/getcutbuffer to use the new stdwin interface.
Guido van Rossum <guido@python.org>
parents:
6
diff
changeset
|
2339 } |
|
b94822f54991
Change set/getcutbuffer to use the new stdwin interface.
Guido van Rossum <guido@python.org>
parents:
6
diff
changeset
|
2340 return newsizedstringobject(str, len); |
| 6 | 2341 } |
| 2342 | |
|
51
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2343 static object * |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2344 stdwin_rotatecutbuffers(self, args) |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2345 object *self; |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2346 object *args; |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2347 { |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2348 int i; |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2349 if (!getintarg(args, &i)) |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2350 return NULL; |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2351 wrotatecutbuffers(i); |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2352 INCREF(None); |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2353 return None; |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2354 } |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2355 |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2356 static object * |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2357 stdwin_getselection(self, args) |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2358 object *self; |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2359 object *args; |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2360 { |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2361 int sel; |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2362 char *data; |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2363 int len; |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2364 if (!getintarg(args, &sel)) |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2365 return NULL; |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2366 data = wgetselection(sel, &len); |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2367 if (data == NULL) { |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2368 data = ""; |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2369 len = 0; |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2370 } |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2371 return newsizedstringobject(data, len); |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2372 } |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2373 |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2374 static object * |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2375 stdwin_resetselection(self, args) |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2376 object *self; |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2377 object *args; |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2378 { |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2379 int sel; |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2380 if (!getintarg(args, &sel)) |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2381 return NULL; |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2382 wresetselection(sel); |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2383 INCREF(None); |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2384 return None; |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2385 } |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2386 |
|
171
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
2387 static object * |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
2388 stdwin_fetchcolor(self, args) |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
2389 object *self; |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
2390 object *args; |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
2391 { |
|
635
784a09a52375
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
629
diff
changeset
|
2392 char *colorname; |
|
1198
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1191
diff
changeset
|
2393 COLOR color; |
|
171
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
2394 if (!getstrarg(args, &colorname)) |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
2395 return NULL; |
|
1198
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1191
diff
changeset
|
2396 color = wfetchcolor(colorname); |
|
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1191
diff
changeset
|
2397 #ifdef BADCOLOR |
|
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1191
diff
changeset
|
2398 if (color == BADCOLOR) { |
|
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1191
diff
changeset
|
2399 err_setstr(StdwinError, "color name not found"); |
|
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1191
diff
changeset
|
2400 return NULL; |
|
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1191
diff
changeset
|
2401 } |
|
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1191
diff
changeset
|
2402 #endif |
|
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1191
diff
changeset
|
2403 return newintobject((long)color); |
|
171
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
2404 } |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
2405 |
|
233
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
2406 static object * |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
2407 stdwin_getscrsize(self, args) |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
2408 object *self; |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
2409 object *args; |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
2410 { |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
2411 int width, height; |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
2412 if (!getnoarg(args)) |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
2413 return NULL; |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
2414 wgetscrsize(&width, &height); |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
2415 return makepoint(width, height); |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
2416 } |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
2417 |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
2418 static object * |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
2419 stdwin_getscrmm(self, args) |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
2420 object *self; |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
2421 object *args; |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
2422 { |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
2423 int width, height; |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
2424 if (!getnoarg(args)) |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
2425 return NULL; |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
2426 wgetscrmm(&width, &height); |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
2427 return makepoint(width, height); |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
2428 } |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
2429 |
|
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
|
2430 #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
|
2431 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
|
2432 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
|
2433 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
|
2434 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
|
2435 { |
|
a4793ae26682
Changes for new UNIX-specific built-in module 'select' and new header for
Guido van Rossum <guido@python.org>
parents:
818
diff
changeset
|
2436 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
|
2437 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
|
2438 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
|
2439 } |
|
a4793ae26682
Changes for new UNIX-specific built-in module 'select' and new header for
Guido van Rossum <guido@python.org>
parents:
818
diff
changeset
|
2440 #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
|
2441 |
|
1211
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
2442 static object * |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
2443 stdwin_listfontnames(self, args) |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
2444 object *self; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
2445 object *args; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
2446 { |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
2447 char *pattern; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
2448 char **fontnames; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
2449 int count; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
2450 object *list; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
2451 if (!getargs(args, "z", &pattern)) |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
2452 return NULL; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
2453 fontnames = wlistfontnames(pattern, &count); |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
2454 list = newlistobject(count); |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
2455 if (list != NULL) { |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
2456 int i; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
2457 for (i = 0; i < count; i++) { |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
2458 object *v = newstringobject(fontnames[i]); |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
2459 if (v == NULL) { |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
2460 DECREF(list); |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
2461 list = NULL; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
2462 break; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
2463 } |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
2464 setlistitem(list, i, v); |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
2465 } |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
2466 } |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
2467 return list; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
2468 } |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
2469 |
|
1332
e5fb9cdbe050
Final touch before release.
Guido van Rossum <guido@python.org>
parents:
1313
diff
changeset
|
2470 #ifdef HAVE_BITMAPS |
|
1211
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
2471 static object * |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
2472 stdwin_newbitmap(self, args) |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
2473 object *self; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
2474 object *args; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
2475 { |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
2476 int width, height; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
2477 bitmapobject *bp; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
2478 if (!getargs(args, "(ii)", &width, &height)) |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
2479 return NULL; |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
2480 return (object *)newbitmapobject(width, height); |
|
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
2481 } |
|
1332
e5fb9cdbe050
Final touch before release.
Guido van Rossum <guido@python.org>
parents:
1313
diff
changeset
|
2482 #endif |
|
1211
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
2483 |
| 6 | 2484 static struct methodlist stdwin_methods[] = { |
| 2485 {"askfile", stdwin_askfile}, | |
| 2486 {"askstr", stdwin_askstr}, | |
| 2487 {"askync", stdwin_askync}, | |
|
1353
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2488 {"done", stdwin_done}, |
|
207
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
2489 {"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
|
2490 #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
|
2491 {"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
|
2492 {"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
|
2493 #endif |
| 6 | 2494 {"fleep", stdwin_fleep}, |
|
252
6811912f672d
Don't suppress wsetfont("");
Guido van Rossum <guido@python.org>
parents:
248
diff
changeset
|
2495 {"getactive", stdwin_getactive}, |
| 6 | 2496 {"getcutbuffer", stdwin_getcutbuffer}, |
|
171
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
2497 {"getdefscrollbars", stdwin_getdefscrollbars}, |
|
137
82ef94b8b902
Add getdefwinpos, getdefwinsize;
Guido van Rossum <guido@python.org>
parents:
114
diff
changeset
|
2498 {"getdefwinpos", stdwin_getdefwinpos}, |
|
82ef94b8b902
Add getdefwinpos, getdefwinsize;
Guido van Rossum <guido@python.org>
parents:
114
diff
changeset
|
2499 {"getdefwinsize", stdwin_getdefwinsize}, |
| 6 | 2500 {"getevent", stdwin_getevent}, |
|
233
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
2501 {"getscrmm", stdwin_getscrmm}, |
|
8f62a5457319
Added many new functions
Guido van Rossum <guido@python.org>
parents:
207
diff
changeset
|
2502 {"getscrsize", stdwin_getscrsize}, |
|
207
9ab329697dda
Add filled drawing methods and polygon methods.
Guido van Rossum <guido@python.org>
parents:
186
diff
changeset
|
2503 {"getselection", stdwin_getselection}, |
|
1211
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
2504 {"listfontnames", stdwin_listfontnames}, |
| 6 | 2505 {"menucreate", stdwin_menucreate}, |
| 2506 {"message", stdwin_message}, | |
|
1332
e5fb9cdbe050
Final touch before release.
Guido van Rossum <guido@python.org>
parents:
1313
diff
changeset
|
2507 #ifdef HAVE_BITMAPS |
|
1211
406860dfaac7
* stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
2508 {"newbitmap", stdwin_newbitmap}, |
|
1332
e5fb9cdbe050
Final touch before release.
Guido van Rossum <guido@python.org>
parents:
1313
diff
changeset
|
2509 #endif |
| 6 | 2510 {"open", stdwin_open}, |
|
114
1efb8ed6afd3
Added pollevent(); returns None if no event available.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
2511 {"pollevent", stdwin_pollevent}, |
|
51
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2512 {"resetselection", stdwin_resetselection}, |
|
ebcb626cfddf
Added w.setwincursor(), selection, and new cut buffer interface.
Guido van Rossum <guido@python.org>
parents:
50
diff
changeset
|
2513 {"rotatecutbuffers", stdwin_rotatecutbuffers}, |
| 6 | 2514 {"setcutbuffer", stdwin_setcutbuffer}, |
|
171
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
2515 {"setdefscrollbars", stdwin_setdefscrollbars}, |
| 6 | 2516 {"setdefwinpos", stdwin_setdefwinpos}, |
| 2517 {"setdefwinsize", stdwin_setdefwinsize}, | |
| 2518 | |
| 2519 /* Text measuring methods borrow code from drawing objects: */ | |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
2520 {"baseline", (method)drawing_baseline}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
2521 {"lineheight", (method)drawing_lineheight}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
2522 {"textbreak", (method)drawing_textbreak}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
2523 {"textwidth", (method)drawing_textwidth}, |
|
171
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
2524 |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
2525 /* Same for font setting methods: */ |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
2526 {"setfont", (method)drawing_setfont}, |
|
171
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
2527 |
|
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
2528 /* Same for color setting/getting methods: */ |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
2529 {"getbgcolor", (method)drawing_getbgcolor}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
2530 {"getfgcolor", (method)drawing_getfgcolor}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
2531 {"setbgcolor", (method)drawing_setbgcolor}, |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
2532 {"setfgcolor", (method)drawing_setfgcolor}, |
|
171
0cee01b68d9c
Added font, color and default scroll bars interfaces.
Guido van Rossum <guido@python.org>
parents:
157
diff
changeset
|
2533 |
| 6 | 2534 {NULL, NULL} /* sentinel */ |
| 2535 }; | |
| 2536 | |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
2537 #ifndef macintosh |
|
1353
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2538 static int |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2539 checkstringlist(args, ps, pn) |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2540 object *args; |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2541 char ***ps; |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2542 int *pn; |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2543 { |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2544 int i, n; |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2545 char **s; |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2546 if (!is_listobject(args)) { |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2547 err_setstr(TypeError, "list of strings expected"); |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2548 return 0; |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2549 } |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2550 n = getlistsize(args); |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2551 s = NEW(char *, n+1); |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2552 if (s == NULL) { |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2553 err_nomem(); |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2554 return 0; |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2555 } |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2556 for (i = 0; i < n; i++) { |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2557 object *item = getlistitem(args, i); |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2558 if (!is_stringobject(item)) { |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2559 err_setstr(TypeError, "list of strings expected"); |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2560 return 0; |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2561 } |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2562 s[i] = getstringvalue(item); |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2563 } |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2564 s[n] = NULL; /* In case caller wants a NULL-terminated list */ |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2565 *ps = s; |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2566 *pn = n; |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2567 return 1; |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2568 } |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2569 |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2570 static int |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2571 putbackstringlist(list, s, n) |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2572 object *list; |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2573 char **s; |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2574 int n; |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2575 { |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2576 int oldsize = getlistsize(list); |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2577 object *newlist; |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2578 int i; |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2579 if (n == oldsize) |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2580 return 1; |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2581 newlist = newlistobject(n); |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2582 for (i = 0; i < n && newlist != NULL; i++) { |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2583 object *item = newstringobject(s[i]); |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2584 if (item == NULL) { |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2585 DECREF(newlist); |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2586 newlist = NULL; |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2587 } |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2588 else |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2589 setlistitem(newlist, i, item); |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2590 } |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2591 if (newlist == NULL) |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2592 return 0; |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2593 (*list->ob_type->tp_as_sequence->sq_ass_slice) |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2594 (list, 0, oldsize, newlist); |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2595 DECREF(newlist); |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2596 return 1; |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2597 } |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
2598 #endif /* macintosh */ |
|
1353
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2599 |
| 6 | 2600 void |
| 2601 initstdwin() | |
| 2602 { | |
|
499
80e2e5d67b49
Change errors into new StdwinError.
Guido van Rossum <guido@python.org>
parents:
475
diff
changeset
|
2603 object *m, *d; |
|
80e2e5d67b49
Change errors into new StdwinError.
Guido van Rossum <guido@python.org>
parents:
475
diff
changeset
|
2604 static int inited = 0; |
|
80e2e5d67b49
Change errors into new StdwinError.
Guido van Rossum <guido@python.org>
parents:
475
diff
changeset
|
2605 |
|
142
c7ea60491e68
Call winit() here instead of in main initialization.
Guido van Rossum <guido@python.org>
parents:
137
diff
changeset
|
2606 if (!inited) { |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
2607 #ifdef macintosh |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
2608 winit(); |
|
2263
7895a97313e5
Changed the way mac mainloop event checking is turned off
Jack Jansen <jack.jansen@cwi.nl>
parents:
2253
diff
changeset
|
2609 PyMac_DoYieldEnabled = 0; |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
2610 #else |
| 2235 | 2611 char buf[1000]; |
|
1353
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2612 int argc = 0; |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2613 char **argv = NULL; |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2614 object *sys_argv = sysget("argv"); |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2615 if (sys_argv != NULL) { |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2616 if (!checkstringlist(sys_argv, &argv, &argc)) |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2617 err_clear(); |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2618 } |
|
1410
315272ec4d5b
* import.c (get_module): total rewrite, to ensure proper search order: for
Guido van Rossum <guido@python.org>
parents:
1353
diff
changeset
|
2619 if (argc > 0) { |
|
315272ec4d5b
* import.c (get_module): total rewrite, to ensure proper search order: for
Guido van Rossum <guido@python.org>
parents:
1353
diff
changeset
|
2620 /* If argv[0] has a ".py" suffix, remove the suffix */ |
|
315272ec4d5b
* import.c (get_module): total rewrite, to ensure proper search order: for
Guido van Rossum <guido@python.org>
parents:
1353
diff
changeset
|
2621 char *p = strrchr(argv[0], '.'); |
|
315272ec4d5b
* import.c (get_module): total rewrite, to ensure proper search order: for
Guido van Rossum <guido@python.org>
parents:
1353
diff
changeset
|
2622 if (p != NULL && strcmp(p, ".py") == 0) { |
|
315272ec4d5b
* import.c (get_module): total rewrite, to ensure proper search order: for
Guido van Rossum <guido@python.org>
parents:
1353
diff
changeset
|
2623 int n = p - argv[0]; |
|
315272ec4d5b
* import.c (get_module): total rewrite, to ensure proper search order: for
Guido van Rossum <guido@python.org>
parents:
1353
diff
changeset
|
2624 if (n >= sizeof(buf)) |
|
315272ec4d5b
* import.c (get_module): total rewrite, to ensure proper search order: for
Guido van Rossum <guido@python.org>
parents:
1353
diff
changeset
|
2625 n = sizeof(buf)-1; |
|
315272ec4d5b
* import.c (get_module): total rewrite, to ensure proper search order: for
Guido van Rossum <guido@python.org>
parents:
1353
diff
changeset
|
2626 strncpy(buf, argv[0], n); |
|
315272ec4d5b
* import.c (get_module): total rewrite, to ensure proper search order: for
Guido van Rossum <guido@python.org>
parents:
1353
diff
changeset
|
2627 buf[n] = '\0'; |
|
315272ec4d5b
* import.c (get_module): total rewrite, to ensure proper search order: for
Guido van Rossum <guido@python.org>
parents:
1353
diff
changeset
|
2628 argv[0] = buf; |
|
315272ec4d5b
* import.c (get_module): total rewrite, to ensure proper search order: for
Guido van Rossum <guido@python.org>
parents:
1353
diff
changeset
|
2629 } |
|
315272ec4d5b
* import.c (get_module): total rewrite, to ensure proper search order: for
Guido van Rossum <guido@python.org>
parents:
1353
diff
changeset
|
2630 } |
|
1353
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2631 winitargs(&argc, &argv); |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2632 if (argv != NULL) { |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2633 if (!putbackstringlist(sys_argv, argv, argc)) |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2634 err_clear(); |
|
a6355c83578d
* stdwinmodule.c (stdwin_done): interface to shutdown stdwin (now this is
Guido van Rossum <guido@python.org>
parents:
1332
diff
changeset
|
2635 } |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
2636 #endif |
|
142
c7ea60491e68
Call winit() here instead of in main initialization.
Guido van Rossum <guido@python.org>
parents:
137
diff
changeset
|
2637 inited = 1; |
|
c7ea60491e68
Call winit() here instead of in main initialization.
Guido van Rossum <guido@python.org>
parents:
137
diff
changeset
|
2638 } |
|
499
80e2e5d67b49
Change errors into new StdwinError.
Guido van Rossum <guido@python.org>
parents:
475
diff
changeset
|
2639 m = initmodule("stdwin", stdwin_methods); |
|
80e2e5d67b49
Change errors into new StdwinError.
Guido van Rossum <guido@python.org>
parents:
475
diff
changeset
|
2640 d = getmoduledict(m); |
|
80e2e5d67b49
Change errors into new StdwinError.
Guido van Rossum <guido@python.org>
parents:
475
diff
changeset
|
2641 |
|
80e2e5d67b49
Change errors into new StdwinError.
Guido van Rossum <guido@python.org>
parents:
475
diff
changeset
|
2642 /* Initialize stdwin.error exception */ |
|
80e2e5d67b49
Change errors into new StdwinError.
Guido van Rossum <guido@python.org>
parents:
475
diff
changeset
|
2643 StdwinError = newstringobject("stdwin.error"); |
|
80e2e5d67b49
Change errors into new StdwinError.
Guido van Rossum <guido@python.org>
parents:
475
diff
changeset
|
2644 if (StdwinError == NULL || dictinsert(d, "error", StdwinError) != 0) |
|
80e2e5d67b49
Change errors into new StdwinError.
Guido van Rossum <guido@python.org>
parents:
475
diff
changeset
|
2645 fatal("can't define stdwin.error"); |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1410
diff
changeset
|
2646 #ifdef WITH_THREAD |
| 926 | 2647 StdwinLock = allocate_lock(); |
| 2648 if (StdwinLock == NULL) | |
| 2649 fatal("can't allocate stdwin lock"); | |
| 2650 #endif | |
| 6 | 2651 } |
