home *** CD-ROM | disk | FTP | other *** search
/ Dream 48 / Amiga_Dream_48.iso / Atari / c / libs / xaes_new.lzh / CONTROL.C < prev    next >
C/C++ Source or Header  |  1994-12-27  |  24KB  |  668 lines

  1. /********************************************************************
  2.  *                                                                1.10*
  3.  *    XAES: Control station                                            *
  4.  *    Code by Ken Hollis, GNU C Extensions by Sascha Blank            *
  5.  *                                                                    *
  6.  *    Copyright (c) 1994, Bitgate Software.  All Rights Reserved.        *
  7.  *                                                                    *
  8.  *    This code was originally taken from the original version of        *
  9.  *    XAES (WinLIB PRO) and was greatly optimized and modified to        *
  10.  *    work with XAES's custom windows and window routines.  This is    *
  11.  *    not the prettiest piece of code, but it works.  Code            *
  12.  *    beautification comes in a later release...  Maybe I can 'borrow'*
  13.  *    some of Christian Grunenberg's routines.                        *
  14.  *                                                                    *
  15.  ********************************************************************/
  16.  
  17. #include <stdio.h>
  18. #include <stddef.h>
  19. #include <time.h>
  20.  
  21. #include "xaes.h"
  22. #include "nkcc.h"
  23.  
  24. #ifdef __TURBOC__
  25. #pragma warn -pia
  26. #pragma warn -sus
  27. #endif
  28.  
  29. /*
  30.  *    This routine returns the WINDOW structure of the window if the
  31.  *    given handle is indeed an XAES window.
  32.  */
  33. GLOBAL WINDOW *WFindHandle(int handle)
  34. {
  35.     WINDOW *ptr = WindowChain;
  36.  
  37.     while (ptr)
  38.         if (ptr->handle == handle)
  39.             return ptr;
  40.         else
  41.             ptr = ptr->next;
  42.  
  43.     return (WINDOW *) FALSE;
  44. }
  45.  
  46. /*
  47.  *    This routine returns the window state of a window.
  48.  */
  49. GLOBAL int WFindState(int window)
  50. {
  51.     WINDOW *ptr = WindowChain;
  52.  
  53.     while(ptr)
  54.         if (ptr->handle == window)
  55.             return(ptr->state);
  56.         else
  57.             ptr = ptr->next;
  58.  
  59.     return 0;
  60. }
  61.  
  62. /*
  63.  *    This is various cruft.  The heart-and-soul of XAES's internal
  64.  *    window and dialog handler.  I could optimize it, but then, why
  65.  *    should I?  It's fast enough as it is.  :-)
  66.  */
  67. GLOBAL int WDoDial(void)
  68. {
  69.     EVENT event;
  70.  
  71.     Life = TRUE;
  72.     Return = 0;
  73.  
  74.     event.ev_mbclicks = 0x0102;
  75.     event.ev_bmask = 3;
  76.     event.ev_mbstate = 0;
  77.  
  78.     while (Life) {
  79.         WINDOW *win;
  80.         int message, hand;
  81.         GRECT old_rect;
  82.         BOOL owner;
  83.  
  84.         old_rect.g_x = old_rect.g_y = old_rect.g_w = old_rect.g_h = 0;
  85.  
  86.         event.ev_mflags = MU_MESAG | MU_TIMER | MU_BUTTON | MU_KEYBD;
  87.  
  88.         if ((win!=NULL) && (win->timer.status != T_NOTEXIST)) {
  89.             long tcount;
  90.  
  91.             tcount = win->timer.clock - (clock() * 1000 / CLK_TCK);
  92.             
  93.             if (tcount > 0) {
  94.                 event.ev_mtlocount = (int) (tcount & 0xffffL);
  95.                 event.ev_mthicount = (int) (tcount >> 16);
  96.             } else
  97.                 event.ev_mtlocount = event.ev_mthicount = 0;
  98.         } else
  99.             event.ev_mtlocount = event.ev_mthicount = 0;
  100.  
  101.         message = EvntMulti(&event);
  102.  
  103.         hand = wind_find(event.ev_mmox, event.ev_mmoy);
  104.         owner = WFindOwner(hand);
  105.  
  106.         if (owner) {
  107.             win = WFindHandle(hand);
  108.             WMoveWindow(win, -1, -1, -1, -1);
  109.         }
  110.  
  111.         if ((win->handle != 0) && (message & MU_BUTTON))
  112.             if ((win->state & W_ICONIFIED) && (win->iconify))
  113.                 if (objc_find(win->iconify, 0, 99, event.ev_mmox, event.ev_mmoy) == win->icon_num) {
  114.                     if (event.ev_mbreturn == 1)
  115.                         WDoIconHandle(win);
  116.  
  117.                     if (event.ev_mbreturn == 2)
  118.                         WWindSet(win, WF_UNICONIFIED, 1);
  119.                 }
  120.  
  121.         if (win)
  122.             if ((event.ev_mmobutton == 2) && ((win->style & W_CUSTOMWINDOW) || (win->handle == 0))) {
  123.                 WDoRightHandle();
  124.                 goto exit_kbd;
  125.             }
  126.         else {
  127.         if (message & MU_MESAG)
  128.             switch (event.ev_mmgpbuf[0]) {
  129.                 case WM_TOPPED:
  130.                     if ((win = WFindHandle(event.ev_mmgpbuf[3])) && (win->state & W_OPEN)) {
  131.                         if (win->state & W_BEVENT) {
  132.                             int dummy;
  133.                             long applrecord[] =    {
  134.                                                     1, 0x010000L,
  135.                                                     0, 16,
  136.                                                     1, 0x100001L
  137.                                                 };
  138.                             GRECT rect;
  139.  
  140.                             graf_mkstate(&event.ev_mmox, &event.ev_mmoy, &event.ev_mmobutton, &event.ev_mmokstate);
  141.  
  142.                             if (!event.ev_mmobutton) {
  143.                                 WMsgWindow(win, event.ev_mmgpbuf);
  144.                                 break;
  145.                             }
  146.  
  147.                             if (event.ev_mmobutton & 1) {
  148.                                 if (AES_VERSION > 0x0100)
  149.                                     appl_tplay(applrecord, 3, 100);
  150.  
  151.                                 WMoveWindow(win, -1, -1, -1, -1);
  152.  
  153.                                 if (win) {
  154.                                     WWindGet(win, WF_WORKXYWH, &rect.g_x, &rect.g_y, &rect.g_w, &rect.g_h);
  155.                                     if (rc_inside(event.ev_mmox, event.ev_mmoy, &rect) && (!win->tree) || (!win->iconify))
  156.                                         goto button;
  157.  
  158.                                     wind_get(win->handle, WF_WORKXYWH, &rect.g_x, &rect.g_y, &rect.g_w, &rect.g_h);
  159.                                     if (rc_inside(event.ev_mmox, event.ev_mmoy, &rect) && (
  160.                                             ((((win->state & W_ICONIFIED) && (win->iconify)) ? win->iconify : win->tree) && (dummy = objc_find(((win->state & W_ICONIFIED) ? win->iconify : win->tree), 0, 99, event.ev_mmox, event.ev_mmoy)) != -1 &&
  161.                                                 (((win->state & W_ICONIFIED) && (win->iconify)) ? win->iconify[dummy].ob_flags & (SELECTABLE | EXIT) : win->tree[dummy].ob_flags & (SELECTABLE | EXIT)))))
  162.                                     {
  163. button:                                    message |= MU_BUTTON;
  164.                                         event.ev_mbreturn = 1;
  165.                                     }
  166.  
  167.                                     if (win->style & W_CUSTOMWINDOW) {
  168.                                         dummy = objc_find(win->wind, 0, 99, event.ev_mmox, event.ev_mmoy);
  169.  
  170.                                         if (win->wind && dummy != -1 && dummy != 25 && ((event.ev_mbreturn == 1) || (event.ev_mmobutton)))
  171.                                             WForm_window(win, dummy, event.ev_mbreturn);
  172.                                     }
  173.  
  174.                                     dummy = objc_find((((win->state & W_ICONIFIED) && (win->iconify)) ? win->iconify : win->tree), 0, 99, event.ev_mmox, event.ev_mmoy);
  175.  
  176.                                     if ((((win->state & W_ICONIFIED) && (win->iconify)) ? win->iconify[dummy].ob_flags & TOUCHEXIT : win->tree[dummy].ob_flags & TOUCHEXIT)) {
  177.                                         int type;
  178.  
  179.                                         graf_mkstate(&event.ev_mmox, &event.ev_mmoy, &type, &type);
  180.                                         dummy = objc_find((((win->state & W_ICONIFIED) && (win->iconify)) ? win->iconify : win->tree), 0, 99, event.ev_mmox, event.ev_mmoy);
  181.  
  182.                                         if (dummy!=-1) {
  183.                                             int d, button;
  184.  
  185.                                             if ((((win->state & W_ICONIFIED) && (win->iconify)) ? win->iconify[dummy].ob_flags & SELECTABLE : win->tree[dummy].ob_flags & SELECTABLE))
  186.                                                 Objc_Change(win, dummy, 0, (((win->state & W_ICONIFIED) && (win->iconify)) ? win->iconify[dummy].ob_state | SELECTED : win->tree[dummy].ob_state | SELECTABLE), 1);
  187.  
  188.                                             do {
  189.                                                 switch((((win->state & W_ICONIFIED) && (win->iconify)) ? win->iconify[dummy].ob_type >> 8 : win->tree[dummy].ob_type >> 8)) {
  190.                                                     case SLIDERLEFT:
  191.                                                     case SLIDERRIGHT:
  192.                                                     case SLIDERUP:
  193.                                                     case SLIDERDOWN:
  194.                                                     case SLIDERTRACK:
  195.                                                         WHandleSlider(win, dummy);
  196.                                                         break;
  197.  
  198.                                                     case SLIDERSLIDE:
  199.                                                         if (xaes.config1 & X_MOUSESLIDERS) {
  200.                                                             EXTINFO *ex = (EXTINFO *)((((win->state & W_ICONIFIED) && (win->iconify)) ? win->iconify[dummy].ob_spec.userblk->ub_parm : win->tree[dummy].ob_spec.userblk->ub_parm));
  201.  
  202.                                                             if (ex->te_slider.slide_type == SLIDER_HOR)
  203.                                                                 WGrafMouse(LRSLIDE_MOUSE);
  204.                                                             if (ex->te_slider.slide_type == SLIDER_VER)
  205.                                                                 WGrafMouse(UDSLIDE_MOUSE);
  206.                                                         }
  207.  
  208.                                                         WHandleSlider(win, dummy);
  209.                                                         break;
  210.  
  211.                                                 }
  212.                                                 graf_mkstate(&d, &d, &button, &d);
  213. /*                                                WCallDlgDispatcher(win, dummy); */
  214.                                             } while (button);
  215.  
  216.                                             WGrafMouse(ARROW);
  217.  
  218.                                             if ((((win->state & W_ICONIFIED) && (win->iconify)) ? win->iconify[dummy].ob_flags & SELECTABLE : win->tree[dummy].ob_flags & SELECTABLE))
  219.                                                 Objc_Change(win, dummy, 0, (((win->state & W_ICONIFIED) && (win->iconify)) ? win->iconify[dummy].ob_state & ~SELECTED : win->tree[dummy].ob_state & ~SELECTED), 1);
  220.                                         }
  221.                                     }
  222.                                 }
  223.                             }
  224.                             break;
  225.                         }
  226.  
  227.                         WMsgWindow(win, event.ev_mmgpbuf);
  228.                     }
  229.                     break;
  230.  
  231.                 case WM_CLOSED:
  232.                     if (win = WFindHandle(event.ev_mmgpbuf[3]))
  233.                         WCloseWindow(win, WC_OBJECTABLE, K_ASK);
  234.                     break;
  235.  
  236.                 case WM_REDRAW:            /* Handle window messages */
  237.                 case WM_NEWTOP:
  238.                 case WM_ARROWED:
  239.                 case WM_VSLID:
  240.                 case WM_SIZED:
  241.                 case WM_FULLED:
  242.                 case WM_HSLID:
  243.                 case WM_MOVED:
  244.                 case WM_CREATED:
  245.                     if (win = WFindHandle(event.ev_mmgpbuf[3]))
  246.                         WMsgWindow(win, event.ev_mmgpbuf);
  247.                     break;
  248.  
  249.                 case AP_DRAGDROP:
  250.                     if (win = WFindHandle(event.ev_mmgpbuf[3]))
  251.                         WMsgWindow(win, event.ev_mmgpbuf);
  252.                     else
  253.                         WCallEtcDispatcher(event.ev_mmgpbuf);
  254.                     break;
  255.  
  256.                 case AC_OPEN:                /* Program/environmental messages */
  257.                 case AC_CLOSE:
  258.                     switch(event.ev_mmgpbuf[0]) {
  259.                         case AC_CLOSE:    if (WCallEtcDispatcher(event.ev_mmgpbuf))
  260.                                             WKillAllWindows(K_ACC);
  261.                                         break;
  262.  
  263.                         case AC_OPEN:    WCallEtcDispatcher(event.ev_mmgpbuf);
  264.                                         break;
  265.                     }
  266.                     break;
  267.  
  268.                 case MN_SELECTED:        /* Menu messages */
  269.                     if (WCallEtcDispatcher(event.ev_mmgpbuf))
  270.                         menu_tnormal(wl_menubar, event.ev_mmgpbuf[3], 1);
  271.                     break;
  272.             }
  273.  
  274.         if ((owner) || (message & MU_TIMER)) {
  275.             if (win)
  276.                 if (win->timer.status != T_NOTEXIST) {
  277.                     WStartTimer(win);
  278.                     WCallTmrDispatcher(win);
  279.                 } else {
  280.                     int mx, my, co, tophandle;
  281.  
  282.                     graf_mkstate(&mx,&my,&co,&co);
  283.  
  284.                     if ((xaes.config1 & X_AUTOCHANGE) && (!(win->state & W_ICONIFIED)) && (win->style & W_CUSTOMWINDOW)) {
  285.                         co = objc_find(win->wind, 0, 99, mx, my);
  286.                         WChangeMouseElement(win, co);
  287.                     } else
  288.                         if (xaes.config1 & X_AUTOCHANGE) {
  289.                             int ts;
  290.  
  291.                             co = wind_find(mx, my);
  292.                             ts = WFindState(co);
  293.                             if (((ts & W_ICONIFIED) && (!(ts & W_DESKTOP))) ||
  294.                                 ((!(win->style & W_CUSTOMWINDOW)) && (!(ts & W_DESKTOP)) &&
  295.                                 (cur_mouse_form != TEXT_CRSR)))
  296.                                 WGrafMouse(ARROW);
  297.                             else if (co == -1)
  298.                                 WChangeMouseElement(win, co);
  299.  
  300.                             if (ts & W_DESKTOP)
  301.                                 WGrafMouse(NOWINDOW_MOUSE);
  302.                         }
  303.  
  304.                     if (win) {
  305.                         WWindGet(win, WF_TOP, &tophandle);
  306.  
  307.                         if ((win->state & W_OPEN) && (win->handle == tophandle) && (win->handle != 0) && (win->edobject) && !rc_inside(mx,my,&old_rect)) {
  308.                             co = objc_find((((win->state & W_ICONIFIED) && (win->iconify)) ? win->iconify : win->tree), 0, 99, mx, my);
  309.  
  310.                             if (co != -1) {
  311.                                 if (win->style & W_CUSTOMWINDOW)
  312.                                     if ((win->wind_type == WC_WINDOW) || (win->wind_type == WC_SWINDOW)) {
  313.                                         old_rect.g_x = win->size.g_x + win->wind[25].ob_x + ((co) ? win->tree[co].ob_x - 1 : 0);
  314.                                         old_rect.g_y = win->size.g_y + win->wind[25].ob_y + ((co) ? win->tree[co].ob_y - 1 : 0);
  315.                                     }
  316.                                 else
  317.                                     old_rect.g_x = (((win->state & W_ICONIFIED) && (win->iconify)) ? win->iconify->ob_x : win->tree->ob_x) + ((co) ? ((win->state & W_ICONIFIED) ? win->iconify[co].ob_x - 1 : win->tree[co].ob_x - 1) : 0);
  318.                                     old_rect.g_y = (((win->state & W_ICONIFIED) && (win->iconify)) ? win->iconify->ob_y : win->tree->ob_y) + ((co) ? ((win->state & W_ICONIFIED) ? win->iconify[co].ob_y - 1 : win->tree[co].ob_y - 1) : 0);
  319.  
  320.                                 old_rect.g_w = (((win->state & W_ICONIFIED) && (win->iconify)) ? win->iconify[co].ob_width + 1 : win->tree[co].ob_width + 1);
  321.                                 old_rect.g_h = (((win->state & W_ICONIFIED) && (win->iconify)) ? win->iconify[co].ob_height + 1 : win->tree[co].ob_height + 1);
  322.     
  323.                                 if ((((win->state & W_ICONIFIED) && (win->iconify)) ? win->iconify[co].ob_flags & EDITABLE : win->tree[co].ob_flags & EDITABLE))
  324.                                     WGrafMouse((helpmode) ? IBARHELP_MOUSE : TEXT_CRSR);
  325.                                 else
  326.                                     WGrafMouse((helpmode) ? HELP_MOUSE : ARROW);
  327.                             
  328.                                 }
  329.                             }
  330.                         }
  331.                 }
  332.  
  333.         if (message & MU_KEYBD) {
  334.             int    n_key, nxtobj, nxtchr;
  335.  
  336.             win = WindowChain;
  337.             if (win)
  338.             if (!(win->state & W_MINIMIZED)) {
  339.             n_key = nkc_tconv((event.ev_mkreturn & 0xff) | (((long) event.ev_mkreturn & 0xff00) << 8) | ((long) event.ev_mmokstate << 24));
  340.  
  341.             WMoveWindow(win, -1, -1, -1, -1);
  342.  
  343.             if ((n_key & NKF_ALT) && (n_key & NKF_CTRL)) {
  344.                 switch(n_key & 0xFF) {
  345.                     case NK_UP:
  346.                     case '8':        if ((((n_key & 0xFF) == '8') && (n_key & NKF_NUM)) || ((n_key & 0xFF) == NK_UP)) {
  347.                                         int m[8];
  348.  
  349.                                         m[0] = WM_ARROWED;
  350.                                         m[4] = ((n_key & NKF_RSH) || (n_key & NKF_LSH)) ? WA_UPPAGE : WA_UPLINE;
  351.  
  352.                                         WMsgWindow(win, m);
  353.                                     }
  354.                                     goto exit_kbd;
  355.  
  356.                     case NK_DOWN:
  357.                     case '2':        if ((((n_key & 0xFF) == '2') && (n_key & NKF_NUM)) || ((n_key & 0xFF) == NK_DOWN)) {
  358.                                         int m[8];
  359.  
  360.                                         m[0] = WM_ARROWED;
  361.                                         m[4] = ((n_key & NKF_RSH) || (n_key & NKF_LSH)) ? WA_DNPAGE : WA_DNLINE;
  362.  
  363.                                         WMsgWindow(win, m);
  364.                                     }
  365.                                     goto exit_kbd;
  366.  
  367.                     case '*':        if ((n_key & NKF_NUM) && (win->handle!=0) && (win->kind & FULLER)) {
  368.                                         int m[8];
  369.  
  370.                                         m[0] = WM_FULLED;
  371.                                         m[3] = win->handle;
  372.  
  373.                                         WMsgWindow(win, m);
  374.                                     }
  375.                                     goto exit_kbd;
  376.  
  377.                     case NK_F5:        /*Change3DType(L_MULTITOS);*/
  378.                                     WRedrawAllWindows();
  379.                                     goto exit_kbd;
  380.  
  381.                     case NK_F6:        /*Change3DType(L_CUSTOM);*/
  382.                                     WRedrawAllWindows();
  383.                                     goto exit_kbd;
  384.  
  385.                     case NK_F7:        if (num_colors>4) {
  386.                                     /*    Change3DType(L_MOTIF); */
  387.                                         WRedrawAllWindows();
  388.                                     } /*else
  389.                                         WFormCustAlert(3,
  390.                                                         " Motif look ",
  391.                                                         "Sorry, the Motif 3D style look",
  392.                                                         "is  only available  in a color",
  393.                                                         "mode with  more than 4 colors.",
  394.                                                         "Please change mode or resolut-",
  395.                                                         "ions   to    see   the   mode.",
  396.                                                         " ", "Okay", " "); */
  397.                                     goto exit_kbd;
  398.  
  399.                     case NK_F8:        /*Change3DType(L_GENEVA);*/
  400.                                     WRedrawAllWindows();
  401.                                     goto exit_kbd;
  402.  
  403.                     case NK_F9:        /*Change3DType(L_WINLIB);*/
  404.                                     WRedrawAllWindows();
  405.                                     goto exit_kbd;
  406.  
  407.                     case NK_F10:    /*Change3DType(L_STANDARD);*/
  408.                                     WRedrawAllWindows();
  409.                                     goto exit_kbd;
  410.  
  411.                     case ' ':        WRedrawAllWindows();
  412.                                     goto exit_kbd;
  413.  
  414.                     case 'Q':
  415.                     case 'q':        WDie(FORCE_EXIT);
  416.                                     goto exit_kbd;
  417.  
  418.                     case NK_ESC:    WCloseWindow(win, WC_OBJECTABLE, K_ASK);
  419.                                     goto exit_kbd;
  420.  
  421.                     case NK_TAB:    WTopWindow(NULL);
  422.                                     goto exit_kbd;
  423.  
  424.                     case NK_BS:        WKillAllWindows(K_ASK);
  425.                                     goto exit_kbd;
  426.  
  427. /*                    case NK_HELP:    CallInternalHelp();
  428.                                     goto exit_kbd; */
  429.  
  430.                     case NK_ENTER:    {
  431.                                         int x, y, w, h;
  432.  
  433.                                         if (win->handle != 0) {
  434.                                             WWindGet(win, WF_WORKXYWH, &x, &y, &w, &h);
  435.                                             WRedrawWindow(win, x, y, w, h);
  436.                                         }
  437.                                     }
  438.  
  439.                                     goto exit_kbd;
  440.                 }
  441.             }
  442.  
  443.             if (win->state & W_OPEN) {
  444.                 nxtobj = 0;
  445.  
  446.                 if (WCallWKeyDispatcher(win, n_key))
  447.                     if (WCallKeyDispatcher(n_key))
  448.                         if (win->tree)
  449.                             if (WForm_keybd(win, event.ev_mkreturn, event.ev_mmokstate, &nxtobj, &nxtchr)) {
  450.                                 if ((nxtchr) && (win->edobject))
  451.                                     WObjc_Edit(win, ED_CHAR, event.ev_mkreturn, event.ev_mmokstate);
  452.  
  453.                                 if ((nxtobj != win->edobject) && (win->edobject != 0) && (nxtobj != 0)) {
  454.                                     register char *t;
  455.                                     register int pos;
  456.  
  457.                                     win->edobject = nxtobj;
  458.  
  459.                                     t = win->tree[win->edobject].ob_spec.tedinfo->te_ptext;
  460.                                     t += pos = find_position(win->tree, win->edobject, event.ev_mmox);
  461.  
  462.                                     edit_pos(win, pos);
  463.                                     win->edobject = nxtobj;
  464.                                 }
  465.                             } else {
  466.                                 if (!(win->tree[nxtobj].ob_flags & RBUTTON)) {
  467.                                     if (nxtobj != 0)
  468.                                         Objc_Change(win->tree, nxtobj, 0, win->tree[nxtobj].ob_state ^ SELECTED, 1);
  469.                                 } else {
  470.                                     int act = nxtobj, lst, new;
  471.                                     OBJECT *obptr = win->tree + nxtobj;
  472.  
  473.                                     if (!(win->tree[nxtobj].ob_state & SELECTED))
  474.                                         Objc_Change(win->tree, nxtobj, 0, win->tree[nxtobj].ob_state | SELECTED, 1);
  475.  
  476.                                     for(;;) {
  477.                                         lst = act;
  478.                                         new = obptr->ob_next;
  479.  
  480.                                         for(;;)    {
  481.                                             act = new;
  482.                                             obptr = win->tree + act;
  483.  
  484.                                             if (obptr->ob_tail == lst) {
  485.                                                 new = obptr->ob_head;
  486.                                                 lst = act;
  487.                                             } else {
  488.                                                 if (act == nxtobj)
  489.                                                     goto rb_exit;
  490.  
  491.                                                 if ((obptr->ob_state & SELECTED) && (obptr->ob_flags & RBUTTON)) {
  492.                                                     Objc_Change(win->tree, act, 0, obptr->ob_state ^ SELECTED, 1);
  493.                                                     goto rb_exit;
  494.                                                 } else break;
  495.                                             }
  496.                                         }
  497.                                     }
  498.                                 }
  499.  
  500.                                 if (!(win->tree[nxtobj].ob_flags & RBUTTON || win->tree[nxtobj].ob_type & 0x8000)) {
  501.                                     int st = win->tree[nxtobj].ob_state;
  502.  
  503.                                     st &= ~SELECTED;
  504.                                     Objc_Change(win->tree, nxtobj, 0, st, 1);
  505.                                 }
  506.  
  507. rb_exit:                        WCallDlgDispatcher(win, nxtobj);
  508.                             }
  509.             } else
  510.                 WCallKeyDispatcher(n_key);
  511.             }
  512.         }
  513.  
  514. exit_kbd:
  515.         if (message & MU_BUTTON) {
  516.             int nxtobj, tophandle;
  517.  
  518.             if (wind_find(event.ev_mmox, event.ev_mmoy) == 0) {
  519.                 int endx, endy;
  520.  
  521.                 WGraf_Rubberbox(event.ev_mmox, event.ev_mmoy, &endx, &endy);
  522.             }
  523.  
  524.             if (win)
  525.             if (!(win->state & W_MINIMIZED)) {
  526.             if (!(win = WFindHandle(wind_find(event.ev_mmox, event.ev_mmoy))))
  527.                 win = WindowChain;
  528.  
  529.             if (win->style & W_CUSTOMWINDOW)
  530.                 nxtobj = objc_find(win->wind, 0, 99, event.ev_mmox, event.ev_mmoy);
  531.  
  532.             WMoveWindow(win, -1, -1, -1, -1);
  533.  
  534.             if (win->wind && win->handle != 0 && nxtobj != -1 && nxtobj != 25 && ((event.ev_mbreturn == 1) || (event.ev_mmobutton)) && (win->style & W_CUSTOMWINDOW)) {
  535.                 EXTINFO *ex = (EXTINFO *)(win->wind[nxtobj].ob_spec.userblk->ub_parm);
  536.  
  537.                 if (ex->te_routines.mouse_down)
  538.                     ex->te_routines.mouse_down(event.ev_mmox, event.ev_mmoy, event.ev_mbreturn, event.ev_mmokstate, nxtobj);
  539.  
  540.                 WForm_window(win, nxtobj, event.ev_mbreturn);
  541.  
  542.                 if (ex->te_routines.mouse_up)
  543.                     ex->te_routines.mouse_up(event.ev_mmox, event.ev_mmoy, event.ev_mbreturn, event.ev_mmokstate, nxtobj);
  544.             } else if (win->handle != 0) {
  545.                 WWindGet(win, WF_TOP, &tophandle);
  546.  
  547.                 if ((((win->state & W_ICONIFIED) && (win->iconify)) ? win->iconify : win->tree) && (nxtobj = objc_find(((win->state & W_ICONIFIED) ? win->iconify : win->tree), 0, 99, event.ev_mmox, event.ev_mmoy)) != -1 && event.ev_mbreturn==1)
  548.                     if ((((win->state & W_ICONIFIED) && (win->iconify)) ? win->iconify[nxtobj].ob_flags & (SELECTABLE | EDITABLE) : win->tree[nxtobj].ob_flags & (SELECTABLE | EDITABLE))) {
  549.                         int oldobj;
  550.  
  551.                         if (((((win->state & W_ICONIFIED) && (win->iconify)) ? win->iconify[nxtobj].ob_type & 0xFF : win->tree[nxtobj].ob_type & 0xFF)) == G_USERDEF) {
  552.                             EXTINFO *ex = (EXTINFO *)((((win->state & W_ICONIFIED) && (win->iconify)) ? win->iconify[nxtobj].ob_spec.userblk->ub_parm : win->tree[nxtobj].ob_spec.userblk->ub_parm));
  553.  
  554.                             if (ex->te_routines.mouse_down)
  555.                                 ex->te_routines.mouse_down(event.ev_mmox, event.ev_mmoy, event.ev_mbreturn, event.ev_mmokstate, nxtobj);
  556.                         }
  557.  
  558.                         oldobj = nxtobj;
  559.                         WForm_button(win, nxtobj, event.ev_mbreturn, &nxtobj);
  560.  
  561.                         if (((((win->state & W_ICONIFIED) && (win->iconify)) ? win->iconify[oldobj].ob_type & 0xFF : win->tree[oldobj].ob_type & 0xFF)) == G_USERDEF) {
  562.                             EXTINFO *ex = (EXTINFO *)((((win->state & W_ICONIFIED) && (win->iconify)) ? win->iconify[oldobj].ob_spec.userblk->ub_parm : win->tree[oldobj].ob_spec.userblk->ub_parm));
  563.  
  564.                             if (ex->te_routines.mouse_up)
  565.                                 ex->te_routines.mouse_up(event.ev_mmox, event.ev_mmoy, event.ev_mbreturn, event.ev_mmokstate, oldobj);
  566.                         }
  567.  
  568.                         if ((win->tree[nxtobj].ob_flags & EDITABLE) && nxtobj != win->edobject)
  569.                             if (win->handle == tophandle) {
  570.                                 register char *t;
  571.                                 register int pos;
  572.  
  573.                                 WObjc_Edit(win, ED_END, 0, 0);
  574.                                 win->edobject = nxtobj;
  575.  
  576.                                 t = win->tree[win->edobject].ob_spec.tedinfo->te_ptext;
  577.                                 t += pos = find_position(win->tree, win->edobject, event.ev_mmox);
  578.  
  579.                                 edit_pos(win, pos);
  580.                                 win->edobject = nxtobj;
  581.                             } else
  582.                                 win->edobject = nxtobj;
  583.  
  584.                         if (win->tree[nxtobj].ob_flags & EDITABLE)
  585.                             if (win->handle == tophandle) {
  586.                                 register char *t = win->tree[win->edobject].ob_spec.tedinfo->te_ptext;
  587.                                 register int pos;
  588.  
  589.                                 t += pos = find_position(win->tree, win->edobject, event.ev_mmox);
  590.  
  591.                                 edit_pos(win, pos);
  592.                                 win->edobject = nxtobj;
  593.                             } else win->edobject = nxtobj;
  594.  
  595.                         if ((((win->state & W_ICONIFIED) && (win->iconify)) ? win->iconify[nxtobj].ob_flags & SELECTABLE : win->tree[nxtobj].ob_flags & SELECTABLE)
  596.                             && !((((win->state & W_ICONIFIED) && (win->iconify)) ? win->iconify[nxtobj].ob_flags & RBUTTON : win->tree[nxtobj].ob_flags & RBUTTON) ||
  597.                                  (((win->state & W_ICONIFIED) && (win->iconify)) ? win->iconify[nxtobj].ob_type & 0x8000 : win->tree[nxtobj].ob_type & 0x8000))) {
  598.                                 int st = (((win->state & W_ICONIFIED) && (win->iconify)) ? win->iconify[nxtobj].ob_state : win->tree[nxtobj].ob_state);
  599.  
  600.                                 st &= ~SELECTED;
  601.                                 Objc_Change(win, nxtobj, 0, st, 1);
  602.                             }
  603.  
  604.                         if ((((win->state & W_ICONIFIED) && (win->iconify)) ? win->iconify[nxtobj].ob_flags & EXIT : win->tree[nxtobj].ob_flags & EXIT))
  605.                             WCallDlgDispatcher(win, nxtobj);
  606.                     } else
  607.                         if ((((win->state & W_ICONIFIED) && (win->iconify)) ? win->iconify[nxtobj].ob_flags & TOUCHEXIT : win->tree[nxtobj].ob_flags & TOUCHEXIT)) {
  608.                             int dummy, button;
  609.  
  610.                             if (((((win->state & W_ICONIFIED) && (win->iconify)) ? win->iconify[nxtobj].ob_type & 0xFF : win->tree[nxtobj].ob_type & 0xFF)) == G_USERDEF) {
  611.                                 EXTINFO *ex = (EXTINFO *)((((win->state & W_ICONIFIED) && (win->iconify)) ? win->iconify[nxtobj].ob_spec.userblk->ub_parm : win->tree[nxtobj].ob_spec.userblk->ub_parm));
  612.  
  613.                                 if (ex->te_routines.mouse_down)
  614.                                     ex->te_routines.mouse_down(event.ev_mmox, event.ev_mmoy, event.ev_mbreturn, event.ev_mmokstate, nxtobj);
  615.                             }
  616.  
  617.                             Objc_Change(win, nxtobj, 0, (((win->state & W_ICONIFIED) && (win->iconify)) ? win->iconify[nxtobj].ob_state | SELECTED : win->tree[nxtobj].ob_state | SELECTED), 1);
  618.  
  619.                             do {
  620.                                 switch((((win->state & W_ICONIFIED) && (win->iconify)) ? win->iconify[nxtobj].ob_type >> 8 : win->tree[nxtobj].ob_type >> 8)) {
  621.                                     case SLIDERLEFT:
  622.                                     case SLIDERRIGHT:
  623.                                     case SLIDERUP:
  624.                                     case SLIDERDOWN:
  625.                                     case SLIDERTRACK:
  626.                                         WHandleSlider(win, nxtobj);
  627.                                         break;
  628.  
  629.                                     case SLIDERSLIDE:
  630.                                         if (xaes.config1 & X_MOUSESLIDERS) {
  631.                                             EXTINFO *ex = (EXTINFO *)((((win->state & W_ICONIFIED) && (win->iconify)) ? win->iconify[nxtobj].ob_spec.userblk->ub_parm : win->tree[nxtobj].ob_spec.userblk->ub_parm));
  632.  
  633.                                             if (ex->te_slider.slide_type == SLIDER_HOR)
  634.                                                 WGrafMouse(LRSLIDE_MOUSE);
  635.                                             if (ex->te_slider.slide_type == SLIDER_VER)
  636.                                                 WGrafMouse(UDSLIDE_MOUSE);
  637.                                         }
  638.  
  639.                                         WHandleSlider(win, nxtobj);
  640.                                         break;
  641.                                 }
  642.                                 graf_mkstate(&dummy, &dummy, &button, &dummy);
  643.                                 WCallDlgDispatcher(win, nxtobj);
  644.                             } while (button == 1);
  645.  
  646.                             WGrafMouse(ARROW);
  647.  
  648.                             Objc_Change(win, nxtobj, 0, (((win->state & W_ICONIFIED) && (win->iconify)) ? win->iconify[nxtobj].ob_state & ~SELECTED : win->tree[nxtobj].ob_state & ~SELECTED), 1);
  649.  
  650.                             if (((((win->state & W_ICONIFIED) && (win->iconify)) ? win->iconify[nxtobj].ob_type & 0xFF : win->tree[nxtobj].ob_type & 0xFF)) == G_USERDEF) {
  651.                                 EXTINFO *ex = (EXTINFO *)((((win->state & W_ICONIFIED) && (win->iconify)) ? win->iconify[nxtobj].ob_spec.userblk->ub_parm : win->tree[nxtobj].ob_spec.userblk->ub_parm));
  652.  
  653.                                 if (ex->te_routines.mouse_up)
  654.                                     ex->te_routines.mouse_up(event.ev_mmox, event.ev_mmoy, event.ev_mbreturn, event.ev_mmokstate, nxtobj);
  655.                             }
  656.                         }
  657.                 else
  658.                     WCallBtnDispatcher(win, event.ev_mmox, event.ev_mmoy, event.ev_mmobutton, event.ev_mmokstate, event.ev_mbreturn);
  659.             }
  660.             }
  661.         }
  662.         }
  663.     }
  664.     }
  665.  
  666.     return Return;
  667. }
  668.