Initial commit, 3-52-19 alpha
[cls.git] / src / c / windows.c
blob6b9cf1559d4b865e97be390e70318bd5d56b0c34
1 /* windows - general window functions */
2 /* XLISP-STAT 2.1 Copyright (c) 1990, by Luke Tierney */
3 /* Additions to Xlisp 2.1, Copyright (c) 1989 by David Michael Betz */
4 /* You may give out copies of this software; for conditions see the */
5 /* file COPYING included with this distribution. */
7 #include "xlisp.h"
8 #include "xlstat.h"
10 /* external variables */
11 extern LVAL s_true, s_title, s_size, s_location, sk_allocate;
13 /**************************************************************************/
14 /** **/
15 /** Utility Functions **/
16 /** **/
17 /**************************************************************************/
19 VOID get_window_bounds P5C(LVAL, object, int *, left, int *, top, int *, width, int *, height)
21 LVAL size, location;
23 size = slot_value(object, s_size);
24 location = slot_value(object, s_location);
25 if (consp(size) && fixp(car(size)) && consp(cdr(size)) && fixp(car(cdr(size)))) {
26 *width = getfixnum(car(size));
27 *height = getfixnum(car(cdr(size)));
29 if (consp(location) && fixp(car(location))
30 && consp(cdr(location)) && fixp(car(cdr(location)))) {
31 *left = getfixnum(car(location));
32 *top = getfixnum(car(cdr(location)));
36 /***********************************************************************/
37 /** **/
38 /** General Window Methods Functions **/
39 /** **/
40 /***********************************************************************/
42 LVAL xsshowwindow(V)
44 LVAL object = xlgaobject();
45 IVIEW_WINDOW w = (IVIEW_WINDOW) GETWINDOWADDRESS(object);
47 if (IVIEW_WINDOW_NULL(w)) {
48 send_message(object, sk_allocate);
49 w = (IVIEW_WINDOW) GETWINDOWADDRESS(object);
51 if (! IVIEW_WINDOW_NULL(w)) StShowWindow(w);
52 return(NIL);
55 LVAL xshidewindow(V)
57 LVAL object = xlgaobject();
58 IVIEW_WINDOW w = (IVIEW_WINDOW) GETWINDOWADDRESS(object);
60 if (! IVIEW_WINDOW_NULL(w)) StHideWindow(w);
61 return(NIL);
64 LVAL xswindow_title(V)
66 IVIEW_WINDOW w;
67 LVAL object, title;
68 char *str;
70 object = xlgaobject();
71 w = (IVIEW_WINDOW) GETWINDOWADDRESS(object);
72 if (moreargs()) {
73 title = xlgastring();
74 set_slot_value(object, s_title, title);
75 if (! IVIEW_WINDOW_NULL(w)) {
76 str = (char *) getstring(title);
77 StWSetTitle(w, str);
80 return(slot_value(object, s_title));
83 static LVAL window_dimensions P2C(int, which, int, frame)
85 LVAL object, slot;
86 IVIEW_WINDOW w;
87 int a, b, set = FALSE;
89 object = xlgaobject();
90 if (moreargs()) {
91 set = TRUE;
92 a = getfixnum(xlgafixnum());
93 b = getfixnum(xlgafixnum());
95 xllastarg();
97 w = (IVIEW_WINDOW) GETWINDOWADDRESS(object);
98 slot = (which == 'L') ? s_location : s_size;
100 if (set) {
101 if (! frame) set_slot_value(object, slot, integer_list_2(a, b));
102 if (! IVIEW_WINDOW_NULL(w)) {
103 switch (which) {
104 case 'L': StWSetLocation(w, a, b, frame); break;
105 case 'S': StWSetSize(w, a, b, frame); break;
109 if (! IVIEW_WINDOW_NULL(w)) {
110 switch (which) {
111 case 'L':
112 StWGetLocation(w, &a, &b, FALSE);
113 set_slot_value(object, slot, integer_list_2(a, b));
114 if (frame) StWGetLocation(w, &a, &b, TRUE);
115 break;
116 case 'S':
117 StWGetSize(w, &a, &b, FALSE);
118 set_slot_value(object, slot, integer_list_2(a, b));
119 if (frame) StWGetSize(w, &a, &b, TRUE);
120 break;
122 return(integer_list_2(a, b));
124 else return(slot_value(object, slot));
127 LVAL xswindow_location(V) { return(window_dimensions('L', FALSE)); }
128 LVAL xswindow_size(V) { return(window_dimensions('S', FALSE)); }
129 LVAL xswindow_frame_location(V) { return(window_dimensions('L', TRUE)); }
130 LVAL xswindow_frame_size(V) { return(window_dimensions('S', TRUE)); }
132 /**************************************************************************/
133 /** **/
134 /** Screen Info Functions **/
135 /** **/
136 /**************************************************************************/
138 LVAL xsscreen_size(V)
140 int width, height;
142 StGetScreenSize(&width, &height);
143 return(integer_list_2(width, height));
146 LVAL xsscreen_has_color(V)
148 return((StScreenHasColor()) ? s_true : NIL);
151 LVAL xssystem_has_windows(V)
153 return((StHasWindows()) ? s_true : NIL);
156 LVAL xsflush_graphics(V)
158 StFlushGraphics();
159 return(NIL);