home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 300-399 / ff386.lzh / XLispStat / src3.lzh / Mac / macwindows.c < prev    next >
C/C++ Source or Header  |  1990-07-30  |  5KB  |  165 lines

  1. /* macwindows - Macintosh 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.                       */
  6.  
  7. #ifdef MPWC
  8. # include <Windows.h>
  9. # include <Menus.h>
  10. # include <OSUtils.h>
  11. # include <Strings.h>
  12. # include <Script.h>
  13. # define screenBits qd.screenBits
  14. # define MBarHeight GetMBarHeight()
  15. CtoPstr(s) char *s; {c2pstr(s);}
  16. PtoCstr(s) char *s; {p2cstr(s);}
  17. #else
  18. # include <WindowMgr.h>
  19. # include <MenuMgr.h>
  20. # include <OSUtil.h>
  21. # include <Color.h>
  22. # include <strings.h>
  23. #endif MPWC
  24. # include "xlisp.h"
  25. # include "windows.h"
  26.  
  27. # define nil 0L
  28.  
  29. /* external variables */
  30. extern LVAL s_true, sk_update, sk_close, sk_activate;
  31.  
  32. /**************************************************************************/
  33. /**                                                                      **/
  34. /**                           Utility Functions                          **/
  35. /**                                                                      **/
  36. /**************************************************************************/
  37.  
  38. static GrafPtr current_port()
  39. {
  40.   GrafPtr port;
  41.   
  42.   GetPort(&port);
  43.   return(port);
  44. }
  45.  
  46. /**************************************************************************/
  47. /**                                                                      **/
  48. /**                        Window Data Functions                         **/
  49. /**                                                                      **/
  50. /**************************************************************************/
  51.  
  52. LVAL get_window_object(w)
  53.     WindowPtr w;
  54. {
  55.   WindowData data;
  56.   
  57.   data = (WindowData) get_window_data(w);
  58.   if (data == nil || ! objectp((LVAL) data->object)) return(NIL);
  59.   else return((LVAL) data->object);
  60. }
  61.  
  62. set_window_object(w, object)
  63.     WindowPtr w;
  64.     LVAL object;
  65. {
  66.   WindowData data;
  67.   
  68.   data = (WindowData) get_window_data(w);
  69.   if (data == nil) return;
  70.   else data->object = (char *) object;
  71. }
  72.  
  73. /**************************************************************************/
  74. /**                                                                      **/
  75. /**                       Standard Event Handlers                        **/
  76. /**                                                                      **/
  77. /**************************************************************************/
  78.  
  79. mac_update_action(resized)
  80.     int resized;
  81. {
  82.   LVAL object = get_window_object(current_port());
  83.  
  84.   if (! mobject_p(object)) return;
  85.   send_message_1L(object, sk_update, (resized) ? s_true : NIL);
  86. }
  87.  
  88. mac_activate_action(active)
  89.     int active;
  90. {
  91.   LVAL object = get_window_object(current_port());
  92.   
  93.   if (! mobject_p(object)) return;
  94.   send_message_1L(object, sk_activate, (active) ? s_true : NIL);
  95. }
  96.  
  97. mac_close_action()
  98. {
  99.   LVAL object = get_window_object(current_port());
  100.   
  101.   if (! mobject_p(object)) return;
  102.   send_message(object, sk_close);
  103. }
  104.  
  105. /**************************************************************************/
  106. /**                                                                      **/
  107. /**                 General Window Information Functions                 **/
  108. /**                                                                      **/
  109. /**************************************************************************/
  110.  
  111. StShowWindow(w)
  112.     WindowPtr w;
  113. {
  114.   MyShowWindow(w);
  115. }
  116.  
  117. StHideWindow(w)
  118.     WindowPtr w;
  119. {
  120.   HideWindow(w);
  121. }
  122.  
  123. StWSetTitle(w, str)
  124.     WindowPtr w;
  125.     char *str;
  126. {
  127.   CtoPstr(str);
  128.   SetWTitle(w, str);
  129.   PtoCstr(str);
  130. }
  131.  
  132. /**************************************************************************/
  133. /**                                                                      **/
  134. /**                         Screen Info Functions                        **/
  135. /**                                                                      **/
  136. /**************************************************************************/
  137.  
  138. StGetScreenSize(width, height)
  139.     int *width, *height;
  140. {
  141.   if (width != nil) *width = screenBits.bounds.right - screenBits.bounds.left;
  142.   if (height != nil) *height = screenBits.bounds.bottom - screenBits.bounds.top - MBarHeight;
  143. }
  144.  
  145. StScreenHasColor()
  146. {
  147.   SysEnvRec r;
  148.   GDHandle gd;
  149.   static inited = FALSE, has_color = FALSE;
  150.  
  151.   if (! inited) {
  152.     SysEnvirons(1, &r);
  153.     if ((int) r.hasColorQD) {
  154.       gd = GetGDevice();
  155.       has_color = ((*(*gd)->gdPMap)->pixelSize > 1) ? TRUE : FALSE;
  156.     }
  157.     else has_color = FALSE;
  158.     inited = TRUE;
  159.   }
  160.   return(has_color);
  161. }
  162.  
  163. StHasWindows() { return(TRUE); }
  164. StFlushGraphics(){}
  165.