File: macwindows.c

package info (click to toggle)
xlispstat 3.52.14-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 7,560 kB
  • ctags: 12,676
  • sloc: ansic: 91,357; lisp: 21,759; sh: 1,525; makefile: 521; csh: 1
file content (143 lines) | stat: -rw-r--r-- 4,573 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/* macwindows - Macintosh window functions                             */
/* XLISP-STAT 2.1 Copyright (c) 1990, by Luke Tierney                  */
/* Additions to Xlisp 2.1, Copyright (c) 1989 by David Michael Betz    */
/* You may give out copies of this software; for conditions see the    */
/* file COPYING included with this distribution.                       */
 
#include "xlisp.h"
#include "xlstat.h"
#include "xlgraph.h"

# define screenBits qd.screenBits
#ifdef applec
VOID CtoPstr(s) char *s; {c2pstr(s);}
VOID PtoCstr(s) StringPtr s; {p2cstr(s);}
#endif /* applec */

/* external variables */
extern LVAL s_true, sk_update, sk_close, sk_activate;
extern int color_allowed;

/**************************************************************************/
/**                                                                      **/
/**                           Utility Functions                          **/
/**                                                                      **/
/**************************************************************************/

static GrafPtr current_port(void)
{
  GrafPtr port;
  
  GetPort(&port);
  return(port);
}

/**************************************************************************/
/**                                                                      **/
/**                        Window Data Functions                         **/
/**                                                                      **/
/**************************************************************************/

LVAL get_window_object(WindowPtr w)
{
  WindowData data;
  
  data = (WindowData) get_window_data(w);
  if (data == nil || ! objectp((LVAL) data->object)) return(NIL);
  else return((LVAL) data->object);
}

VOID set_window_object(WindowPtr w, LVAL object)
{
  WindowData data;
  
  data = (WindowData) get_window_data(w);
  if (data == nil) return;
  else data->object = (char *) object;
}

/**************************************************************************/
/**                                                                      **/
/**                       Standard Event Handlers                        **/
/**                                                                      **/
/**************************************************************************/

pascal VOID mac_update_action(Boolean resized)
{
  LVAL object = get_window_object(current_port());

  if (! objectp(object)) return;
  send_message_1L(object, sk_update, (resized) ? s_true : NIL);
}

pascal VOID mac_activate_action(Boolean active)
{
  LVAL object = get_window_object(current_port());
  
  if (! objectp(object)) return;
  send_message_1L(object, sk_activate, (active) ? s_true : NIL);
}

pascal VOID mac_close_action(void)
{
  LVAL object = get_window_object(current_port());
  
  if (! objectp(object)) return;
  send_message(object, sk_close);
}

/**************************************************************************/
/**                                                                      **/
/**                 General Window Information Functions                 **/
/**                                                                      **/
/**************************************************************************/

VOID StShowWindow(WindowPtr w)
{
  MyShowWindow(w);
}

VOID StHideWindow(WindowPtr w)
{
  HideWindow(w);
}

VOID StWSetTitle(WindowPtr w, char *str)
{
  Str255 pbuf;
  CintoPstring(str, pbuf, sizeof pbuf, FALSE);
  SetWTitle(w, pbuf);
}

/**************************************************************************/
/**                                                                      **/
/**                         Screen Info Functions                        **/
/**                                                                      **/
/**************************************************************************/

VOID StGetScreenSize(int *width, int *height)
{
  if (width != nil) *width = screenBits.bounds.right - screenBits.bounds.left;
  if (height != nil) *height = screenBits.bounds.bottom - screenBits.bounds.top - GetMBarHeight();
}

int StScreenHasColor(void)
{
  SysEnvRec r;
  GDHandle gd;
  static inited = FALSE, has_color = FALSE;

  if (! inited) {
    SysEnvirons(1, &r);
    if ((int) r.hasColorQD && color_allowed) {
      gd = GetGDevice();
      has_color = ((*(*gd)->gdPMap)->pixelSize > 1) ? TRUE : FALSE;
    }
    else has_color = FALSE;
    inited = TRUE;
  }
  return(has_color);
}

int StHasWindows(void) { return(TRUE); }
VOID StFlushGraphics(void) {}