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