annotate Modules/stdwinmodule.c @ 4566:6403c94de50d legacy-trunk

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