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