home *** CD-ROM | disk | FTP | other *** search
/ Atari FTP / ATARI_FTP_0693.zip / ATARI_FTP_0693 / Mint / toswinsc.zoo / objwin.c < prev    next >
C/C++ Source or Header  |  1992-10-27  |  2KB  |  107 lines

  1. /*
  2.  * Copyright 1992 Eric R. Smith. All rights reserved.
  3.  * Redistribution is permitted only if the distribution
  4.  * is not for profit, and only if all documentation
  5.  * (including, in particular, the file "copying")
  6.  * is included in the distribution in unmodified form.
  7.  * THIS PROGRAM COMES WITH ABSOLUTELY NO WARRANTY, NOT
  8.  * EVEN THE IMPLIED WARRANTIES OF MERCHANTIBILITY OR
  9.  * FITNESS FOR A PARTICULAR PURPOSE. USE AT YOUR OWN
  10.  * RISK.
  11.  */
  12. #include <stdlib.h>
  13. #include <gemfast.h>
  14. #include <aesbind.h>
  15. #include <vdibind.h>
  16. #include <osbind.h>
  17. #include <string.h>
  18. #include "xgem.h"
  19.  
  20. static void
  21. draw_objwin(v, x, y, w, h)
  22.     WINDOW *v;
  23.     int x,y,w,h;
  24. {
  25.     OBJECT *t = (OBJECT *)v->extra;
  26.  
  27.     objc_draw(t, 0, 9, x, y, w, h);
  28. }
  29.  
  30. static void
  31. full_objwin(v)
  32.     WINDOW *v;
  33. {
  34.     int newx, newy, neww, newh;
  35.     OBJECT *t;
  36.  
  37.     if (v->flags & WFULLED) {
  38.         wind_get(v->wi_handle, WF_PREVXYWH, &newx, &newy, &neww,
  39.              &newh);
  40.     } else {
  41.         wind_get(v->wi_handle, WF_FULLXYWH, &newx, &newy, &neww,
  42.             &newh);
  43.     }
  44.  
  45.     wind_set(v->wi_handle, WF_CURRXYWH, newx, newy, neww, newh);
  46.     wind_get(v->wi_handle, WF_WORKXYWH, &v->wi_x, &v->wi_y, &v->wi_w,
  47.         &v->wi_h);
  48.  
  49.     v->flags ^= WFULLED;
  50.     t = v->extra;
  51.     t->ob_x = v->wi_x;
  52.     t->ob_y = v->wi_y;
  53. }
  54.  
  55. static void
  56. move_objwin(v, x, y, w, h)
  57.     WINDOW *v;
  58.     int x, y, w, h;
  59. {
  60.     int fullx, fully, fullw, fullh;
  61.     OBJECT *t;
  62.  
  63.     wind_get(v->wi_handle, WF_FULLXYWH, &fullx, &fully, &fullw, &fullh);
  64.  
  65.     if (w > fullw) w = fullw;
  66.     if (h > fullh) h = fullh;
  67.  
  68.     if (w != fullw || h != fullh)
  69.         v->flags &= ~WFULLED;
  70.  
  71.     wind_set(v->wi_handle, WF_CURRXYWH, x, y, w, h);
  72.     wind_get(v->wi_handle, WF_WORKXYWH, &v->wi_x, &v->wi_y,
  73.         &v->wi_w, &v->wi_h);
  74.  
  75.     t = v->extra;
  76.     t->ob_x = v->wi_x;
  77.     t->ob_y = v->wi_y;
  78. }
  79.  
  80. static void
  81. size_objwin(v, x, y, w, h)
  82.     WINDOW *v;
  83.     int x, y, w, h;
  84. {
  85.     move_objwin(v, x, y, w, h);
  86. }
  87.  
  88. WINDOW *
  89. create_objwin(tree, title, kind, wx, wy, ww, wh)
  90.     OBJECT *tree;
  91.     char *title;
  92.     int kind, wx, wy, ww, wh;
  93. {
  94.     WINDOW *v;
  95.  
  96.     v = create_window(title, kind, wx, wy, ww, wh);
  97.     if (!v) return v;
  98.     v->extra = tree;
  99.     v->wtype = OBJ_WIN;
  100.     v->draw = draw_objwin;
  101.     v->fulled = full_objwin;
  102.     v->sized = size_objwin;
  103.     v->moved = move_objwin;
  104.  
  105.     return v;
  106. }
  107.