home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 2 / crawlyvol2.bin / program / c / xaes_new / messages.c < prev    next >
C/C++ Source or Header  |  1994-12-04  |  9KB  |  296 lines

  1. /********************************************************************
  2.  *                                                                1.00*
  3.  *    XAES: Handle all messages (boy is this fun!)                    *
  4.  *    Code by Ken Hollis, Bug checking by Sascha Blank                *
  5.  *                                                                    *
  6.  *    Copyright (c) 1994, Bitgate Software.  All Rights Reserved.        *
  7.  *                                                                    *
  8.  *    This is the message control module.  This routine controls the    *
  9.  *    powerhouse of the most common messages.  I will add compat-        *
  10.  *    ibility for other desktops, but not at this time...                *
  11.  *                                                                    *
  12.  ********************************************************************/
  13.  
  14. #include <stdio.h>
  15. #include <stddef.h>
  16. #include <stdlib.h>
  17. #include "xaes.h"
  18.  
  19. GLOBAL void WMsgWindow(WINDOW *win, int msg_buf[8])
  20. {
  21.     int tophandle;
  22.  
  23.     if (win) {
  24.         WMoveWindow(win, -1, -1, -1, -1);
  25.  
  26.         switch (msg_buf[0]) {
  27.             GRECT *realrect, temp, work;
  28.             int pxyarray[4];
  29.             BOOL ret;
  30.  
  31.             case WM_REDRAW:        WWindGet(win, WF_TOP, &tophandle);
  32.                                 if (win->edobject && win->edit_disp && win->handle == tophandle && !(win->state & W_MINIMIZED)) {
  33.                                     WObjc_Edit(win, ED_END, 0, 0);
  34.                                     win->edit_disp = FALSE;
  35.                                 }
  36.  
  37.                                 realrect = (GRECT *) (msg_buf + 4);        /* nasty */
  38.                                 WMoveWindow(win, -1, -1, -1, -1);
  39.  
  40.                                 if (rc_intersect(realrect, &desk)) {
  41.                                     wind_get(win->handle, WF_WORKXYWH, &work.g_x, &work.g_y, &work.g_w, &work.g_h);
  42.  
  43.                                 if (rc_intersect(realrect, &work))
  44.                                     if (msg_buf[7] > 0 && WCallWndDispatcher(win, msg_buf))
  45.                                         if ((win->wind) || (win->tree) || (win->iconify))
  46.                                             WUpdateWindow(win, msg_buf[4], msg_buf[5], msg_buf[6], msg_buf[7], 0);
  47.                                         else {
  48.                                             wind_update(BEG_UPDATE);
  49.                                             graf_mouse(M_OFF, NULL);
  50.  
  51.                                             vsf_interior(VDIhandle, FIS_SOLID);
  52.                                             vswr_mode(VDIhandle, MD_REPLACE);
  53.                                             vsf_color(VDIhandle, 0);
  54.  
  55.                                             wind_get(win->handle, WF_FIRSTXYWH, &temp.g_x, &temp.g_y, &temp.g_w, &temp.g_h);
  56.                                             while (temp.g_w && temp.g_h) {
  57.                                                 if (rc_intersect(&temp, realrect)) {
  58.                                                     pxyarray[0] = temp.g_x;
  59.                                                     pxyarray[1] = temp.g_y;
  60.                                                     pxyarray[2] = temp.g_x + temp.g_w - 1;
  61.                                                     pxyarray[3] = temp.g_y + temp.g_h - 1;
  62.  
  63.                                                     v_bar(VDIhandle, pxyarray);
  64.                                                 }
  65.                                                 wind_get(win->handle, WF_NEXTXYWH, &temp.g_x, &temp.g_y, &temp.g_w, &temp.g_h);
  66.                                             }
  67.  
  68.                                             graf_mouse(M_ON, NULL);
  69.                                             wind_update(END_UPDATE);
  70.                                         }
  71.                             }
  72.  
  73.                             if (win->edobject && !win->edit_disp && win->handle == tophandle && !(win->state & W_MINIMIZED)) {
  74.                                 WObjc_Edit(win, ED_INIT, 0, 0);
  75.                                 win->edit_disp = TRUE;
  76.                             }
  77.  
  78.                             msg_buf[0] = WM_PAINT;
  79.                             msg_buf[1] = Ap_ID;
  80.                             msg_buf[3] = win->handle;
  81.  
  82.                             WMsgWindow(win, msg_buf);
  83.  
  84.                         break;
  85.  
  86.         case WM_CLOSED:    
  87.                             if (WCallWndDispatcher(win, msg_buf)) {    
  88.                                 WCruelCloseWindow(win, FALSE);
  89.  
  90.                                 unfix_object(win->tree);
  91.                                 unfix_object(win->iconify);
  92.  
  93.                                 WKillWindow(win);
  94.                             }
  95.  
  96.                         break;
  97.  
  98.         case WM_KILL:    WCallWndDispatcher(win, msg_buf);
  99.  
  100.                         if (win->state & W_OPEN)                /* Close window if it isn't already closed */
  101.                             WCruelCloseWindow(win, FALSE);
  102.  
  103.                         free(win->WndDispatcher);
  104.                         wind_delete(win->handle);                /* Delete window for good */
  105.  
  106.                         owned_winds[win->handle].handle = win->handle;
  107.                         owned_winds[win->handle].owner  = W_NOTOWNER;
  108.  
  109.                         if (win->prev)                            /* Remove window from chain */
  110.                             win->prev->next = win->next;
  111.                         win->next->prev = win->prev;
  112.  
  113.                         if (WindowChain == win)                    /* Make sure WindowChain doesn't point to the removed window */
  114.                             WindowChain = win->next;
  115.  
  116.                         free(win);                                /* And free memory */
  117.  
  118.                         break;
  119.  
  120.         case WM_NEWTOP:    
  121.                             WWindGet(win, WF_TOP, &tophandle);
  122.                             WCallWndDispatcher(win, msg_buf);
  123.                         break;
  124.  
  125.         case WM_ONTOP:    
  126.                             WWindGet(win, WF_TOP, &tophandle);
  127.                             WCallWndDispatcher(win, msg_buf);
  128.                         break;
  129.  
  130.         case WM_CREATED:WWindGet(win, WF_TOP, &tophandle);
  131.                         WCallWndDispatcher(win, msg_buf);
  132.                         break;
  133.  
  134.         case WM_COPIED:    WWindGet(win, WF_TOP, &tophandle);
  135.                         WCallWndDispatcher(win, msg_buf);
  136.                         break;
  137.  
  138.         case WM_PAINT:    WCallWndDispatcher(win, msg_buf);
  139.                         break;
  140.  
  141.         case WM_UNTOPPED:
  142.                             WCallWndDispatcher(win, msg_buf);
  143.                         break;
  144.  
  145.         case WM_ARROWED:
  146.                             WWindGet(win, WF_TOP, &tophandle);
  147.  
  148.                             if (win->edobject && win->edit_disp && win->handle == tophandle && !(win->state & W_MINIMIZED)) {
  149.                                 WObjc_Edit(win, ED_END, 0, 0);
  150.                                 win->edit_disp = FALSE;
  151.                             }
  152.  
  153.                             WCallWndDispatcher(win, msg_buf);
  154.  
  155.                             if (win->edobject && !win->edit_disp && win->handle == tophandle && !(win->state & W_MINIMIZED)) {
  156.                                 WObjc_Edit(win, ED_INIT, 0, 0);
  157.                                 win->edit_disp = TRUE;
  158.                             }
  159.                         break;
  160.  
  161.         case WM_VSLID:    
  162.                             WWindGet(win, WF_TOP, &tophandle);
  163.  
  164.                             if (win->edobject && win->edit_disp && win->handle == tophandle && !(win->state & W_MINIMIZED)) {
  165.                                 WObjc_Edit(win, ED_END, 0, 0);
  166.                                 win->edit_disp = FALSE;
  167.                             }
  168.  
  169.                             WCallWndDispatcher(win, msg_buf);
  170.  
  171.                             if (win->edobject && !win->edit_disp && win->handle == tophandle && !(win->state & W_MINIMIZED)) {
  172.                                 WObjc_Edit(win, ED_INIT, 0, 0);
  173.                                 win->edit_disp = TRUE;
  174.                             }
  175.                         break;
  176.  
  177.         case WM_HSLID:    
  178.                             WWindGet(win, WF_TOP, &tophandle);
  179.                             if (win->edobject && win->edit_disp && win->handle == tophandle && !(win->state & W_MINIMIZED)) {
  180.                                 WObjc_Edit(win, ED_END, 0, 0);
  181.                                 win->edit_disp = FALSE;
  182.                             }
  183.  
  184.                             WCallWndDispatcher(win, msg_buf);
  185.  
  186.                             if (win->edobject && !win->edit_disp && win->handle == tophandle && !(win->state & W_MINIMIZED)) {
  187.                                 WObjc_Edit(win, ED_INIT, 0, 0);
  188.                                 win->edit_disp = TRUE;
  189.                             }
  190.                         break;
  191.  
  192.         case WM_SIZED:    
  193.                             WWindGet(win, WF_TOP, &tophandle);
  194.                             if (win->edobject && win->edit_disp && win->handle == tophandle && !(win->state & W_MINIMIZED)) {
  195.                                 WObjc_Edit(win, ED_END, 0, 0);
  196.                                 win->edit_disp = FALSE;
  197.                             }
  198.  
  199.                             if (WCallWndDispatcher(win, msg_buf))
  200.                                 WMoveWindow(win, -1, -1, msg_buf[6], msg_buf[7]);
  201.  
  202.                             if (win->edobject && !win->edit_disp && win->handle == tophandle && !(win->state & W_MINIMIZED)) {
  203.                                 WObjc_Edit(win, ED_INIT, 0, 0);
  204.                                 win->edit_disp = TRUE;
  205.                             }
  206.                         break;
  207.  
  208.         case WM_MOVED:    
  209.                             if (WCallWndDispatcher(win, msg_buf))
  210.                                 if ((win->state & W_ICONIFIED) && (win->iconify))
  211.                                     WMoveWindow(win, msg_buf[4], msg_buf[5], win->iconify->ob_width, win->iconify->ob_height);
  212.                                 else
  213.                                     WMoveWindow(win, msg_buf[4], msg_buf[5], -1, -1);
  214.  
  215.                         break;
  216.  
  217.         case WM_TOPPED:    
  218.                             WWindGet(win, WF_TOP, &tophandle);
  219.                             if (win->edobject && win->edit_disp && win->handle == tophandle && !(win->state & W_MINIMIZED)) {
  220.                                 WObjc_Edit(win, ED_END, 0, 0);
  221.                                 win->edit_disp = FALSE;
  222.                             }
  223.  
  224.                             if (WindowChain != win && ! (win->state & W_UNUNTOPPABLE) && WindowChain->state & W_UNUNTOPPABLE) {
  225.                                 win = WindowChain;
  226.                                 msg_buf[3] = win->handle;
  227.                             }
  228.  
  229.                             if (WCallWndDispatcher(win, msg_buf))
  230.                                 WTopWindow(win);
  231.  
  232.                             WMoveWindow(win, -1, -1, -1, -1);
  233.  
  234.                             if (win->edobject && !win->edit_disp && win->handle == tophandle && !(win->state & W_MINIMIZED)) {
  235.                                 WObjc_Edit(win, ED_INIT, 0, 0);
  236.                                 win->edit_disp = TRUE;
  237.                             }
  238.                         break;
  239.  
  240.         case WM_FULLED:    
  241.                             WWindGet(win, WF_TOP, &tophandle);
  242.                             if (win->edobject && win->edit_disp && win->handle == tophandle && !(win->state & W_MINIMIZED)) {
  243.                                 WObjc_Edit(win, ED_END, 0, 0);
  244.                                 win->edit_disp = FALSE;
  245.                             }
  246.  
  247.                             if (WCallWndDispatcher(win, msg_buf)) {
  248.                                 int x, y, w, h;
  249.  
  250.                                 WWindGet(win, WF_CURRXYWH, &x, &y, &w, &h);
  251.                                 if (x == desk.g_x && y == desk.g_y && w == desk.g_w && h == desk.g_h)
  252.                                     WWindGet(win, WF_PREVXYWH, &x, &y, &w, &h);
  253.                                 else {
  254.                                     x = desk.g_x;
  255.                                     y = desk.g_y;
  256.                                     w = desk.g_w;
  257.                                     h = desk.g_h;
  258.                                 }
  259.  
  260.                                 WMoveWindow(win, x, y, w, h);
  261.                             }
  262.  
  263.                             if (win->edobject && !win->edit_disp && win->handle == tophandle && !(win->state & W_MINIMIZED)) {
  264.                                 WObjc_Edit(win, ED_INIT, 0, 0);
  265.                                 win->edit_disp = TRUE;
  266.                             }
  267.                         break;
  268.  
  269.         case AP_DRAGDROP:
  270.                             WWindGet(win, WF_TOP, &tophandle);
  271.                             if (win->edobject && win->edit_disp && win->handle == tophandle && !(win->state & W_MINIMIZED)) {
  272.                                 WObjc_Edit(win, ED_END, 0, 0);
  273.                                 win->edit_disp = FALSE;
  274.                             }
  275.  
  276.                             if (WCallWndDispatcher(win, msg_buf)) 
  277.                                 WCallEtcDispatcher(msg_buf);
  278.  
  279.                             if (win->edobject && !win->edit_disp && win->handle == tophandle && !(win->state & W_MINIMIZED)) {
  280.                                 WObjc_Edit(win, ED_INIT, 0, 0);
  281.                                 win->edit_disp = TRUE;
  282.                             }
  283.                         break;
  284.         }
  285.     }
  286. }
  287.  
  288. GLOBAL int WFindOwner(int handle)
  289. {
  290.     if ((owned_winds[handle].owner == Ap_ID) && (owned_winds[handle].owner != W_NOTOWNER))
  291.         return TRUE;
  292.     else if (handle == 0)
  293.         return TRUE;
  294.  
  295.     return FALSE;
  296. }