home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / developm / source / suntar1.cpt / gc / my ANSI / my window.c < prev   
Encoding:
C/C++ Source or Header  |  1992-06-06  |  3.1 KB  |  103 lines

  1. /*
  2.  
  3. By Gabriele Speranza: a more easily usable interface to some "hooks" inserted 
  4. into console.c
  5.  
  6. */
  7.  
  8.  
  9.  
  10. #include <MacHeaders>
  11. #include "stdio.h"
  12. #include "console.h"
  13.  
  14. void screen_size(int*,int*);
  15. void set_arrow_cursor(void);
  16. void config_console(int,int,char*,int,int,int,int,int,int);
  17. FILE* fopen_win(int,int,char*,int,int,int,int,int);
  18.  
  19. #define    _MBARHEIGHT    (ROM85==-1?20:MBarHeight)
  20. #define _TITLEBARHEIGHT    20
  21. #define MAX(a,b) (a)<(b)?(b):(a)
  22. #define hiword(x)        (((short *) &(x))[0])
  23. #define loword(x)        (((short *) &(x))[1])
  24. extern long my_current_size,my_current_A5;
  25. void init_all(void);
  26. void __open_std(void);
  27. void *memcpy(void*, void *, size_t );
  28.  
  29. /******* screen_size: returns the screen size (Symantec puts QuickDraw globals
  30. in a nonstandard place, so screenBits contains zeroes...) Really, I could have
  31. avoided to patch console.c to get the pointer in my_current_A5, by using
  32. the method that Quickdraw uses to find those data, but when I wrote it I
  33. did not know how Quickdraw did **********/
  34.  
  35. void screen_size(width,heigth)
  36. int* width,*heigth;
  37. {
  38. *width= ( (BitMap*)(my_current_A5-122L) )->bounds.right;
  39. *heigth=( (BitMap*)(my_current_A5-122L) )->bounds.bottom;
  40. }
  41.  
  42. /******* set_arrow_cursor: the cursor becomes the usual arrow (arrows contains zeros...*/
  43. void set_arrow_cursor()
  44. {
  45. SetCursor( (Cursor*) (my_current_A5-122L+sizeof(BitMap)) );
  46. }
  47.  
  48. /********* config_console: set attributes of the console window ********/
  49.  
  50. void config_console(top,left,        /* position */
  51. title,
  52. pId,                    /* procId, identifies the kind of window */
  53. rows,cols,                /* maximum size */
  54. cur_rows,cur_cols,        /* current size: as you surely know, ANSI library windows
  55.                         can be resized, by clicking where the grow box should be; 
  56.                         to have them smaller than the max size is boring since what
  57.                         is outside can't be seen unless you resize them, but if you 
  58.                         wish an initial size less than the maximum, you can */
  59. pressreturn                /* display or not the "press return to exit" message */
  60. )
  61. char *title;
  62. {
  63. struct __copt temp;
  64. int mintop=_MBARHEIGHT + _TITLEBARHEIGHT -4;
  65.  
  66. memcpy((void*)&temp,(void*)&console_options,sizeof(struct __copt));
  67. console_options.top=MAX(mintop,top);
  68. console_options.left=left;
  69. if(title) console_options.title=title;
  70. if(pId>=0) console_options.procID=pId;
  71. console_options.nrows=MAX(rows,cur_rows);
  72. console_options.ncols=MAX(cols,cur_cols);
  73. console_options.pause_atexit=pressreturn;
  74. loword(my_current_size)=cur_rows;
  75. hiword(my_current_size)=cur_cols;
  76. __open_std();
  77. memcpy((void*)&console_options,(void*)&temp,sizeof(struct __copt));
  78.  
  79. }
  80.  
  81. /********* fopen_win: open another window and set its attributes ********/
  82.  
  83. FILE* fopen_win(top,left,title,pId,rows,cols,cur_rows,cur_cols)
  84. char *title;
  85. {
  86. FILE*p;
  87. struct __copt temp;
  88. int mintop=_MBARHEIGHT + _TITLEBARHEIGHT -4;
  89.  
  90. memcpy((void*)&temp,(void*)&console_options,sizeof(struct __copt));
  91. console_options.top=MAX(mintop,top);
  92. console_options.left=left;
  93. console_options.title=title;
  94. if(pId>=0) console_options.procID=pId;
  95. console_options.nrows=MAX(rows,cur_rows);
  96. console_options.ncols=MAX(cols,cur_cols);
  97. loword(my_current_size)=cur_rows;
  98. hiword(my_current_size)=cur_cols;
  99. p=fopenc();
  100. memcpy((void*)&console_options,(void*)&temp,sizeof(struct __copt));
  101. return p;
  102. }
  103.