Пример #1
0
/*
 * Internal process context used to control the screen for use by
 * the menu manager, and the window manager.
 * This process never terminates and forms an integral part of
 * the system.
 */
void ctlmgr(void)
{
    WORD    ev_which;
    WORD    rets[6];
    WORD    i, wh;

    /*
     * set defaults for multi wait
     */
    gl_ctwait.m_out = FALSE;
    rc_copy(&gl_rmenu, (GRECT *)&gl_ctwait.m_x);
    while(TRUE)
    {
        /* fix up ctrl rect */
        w_setactive();
        /*
         * wait for something to happen, keys need to be eaten
         * inc. fake key sent by ... or if button already down,
         * then let other guys run then do it
         */
        if (button)
        {
            for (i = 0; i < (totpds*2); i++)
                dsptch();

            ev_which = MU_BUTTON;
            rets[0] = xrat;
            rets[1] = yrat;
        }
        else
        {
            ev_which = MU_KEYBD | MU_BUTTON;
            if ( gl_mntree != 0x0L )    /* only wait on bar when there  */
                ev_which |= MU_M1;      /* is a menu                    */
            ev_which = ev_multi(ev_which, &gl_ctwait, &gl_ctwait,
                                0x0L, 0x0001ff01L, 0x0L, rets);
        }

        ct_mouse(TRUE);                 /* grab screen sink     */
        /*
         * button down over area ctrl mgr owns.  find out which
         * window the mouse clicked over and handle it
         */
        if (ev_which & MU_BUTTON)
        {
            wh = wm_find(rets[0], rets[1]);
            if (wh > 0)
                hctl_window( wh, rets[0], rets[1] );
        }
                                        /* mouse over menu bar  */
        if (ev_which & MU_M1)
            hctl_rect();
        ct_mouse(FALSE);                /* give up screen sink  */
    }
}
Пример #2
0
void draw_change(WORD w_handle, GRECT *pt)
{
        GRECT           c, pprev;
        register GRECT  *pw;
        register WORD   start;
        WORD            stop, moved;
        WORD            oldtop, clrold, diffbord, wasclr;

        wasclr = !(D.w_win[w_handle].w_flags & VF_BROKEN);
                                                /* save old size        */
        w_getsize(WS_CURR, w_handle, &c);
        w_setsize(WS_PREV, w_handle, &c);
                                                /* set new size's       */
        w_setsize(WS_CURR, w_handle, pt);
        pw = (GRECT *) w_getxptr(WS_WORK, w_handle);
        wm_calc(WC_WORK, D.w_win[w_handle].w_kind, 
                        pt->g_x, pt->g_y, pt->g_w, pt->g_h, 
                        &pw->g_x, &pw->g_y, &pw->g_w, &pw->g_h);
                                                /* update rect. lists   */
        everyobj(gl_wtree, ROOT, NIL, (void(*)())newrect, 0, 0, MAX_DEPTH);
                                                /* remember oldtop      */
        oldtop = gl_wtop;
        gl_wtop = W_TREE[ROOT].ob_tail;
                                                /* if new top then      */
                                                /*   change men         */
        if (gl_wtop != oldtop)
          w_menufix();
                                                /* set ctrl rect and    */
                                                /*   mouse owner        */
        w_setactive();
                                                /* init. starting window*/
        start = w_handle;
                                                /* stop at the top      */
        stop = DESKWH;
                                                /* set flag to say we   */
                                                /*   haven't moved      */
                                                /*   the top window     */
        moved = FALSE;
                                                /* if same upper left   */
                                                /*   corner and not     */
                                                /*   zero size window   */
                                                /*   then its a size or */
                                                /*   top request, else  */
                                                /*   its a move, grow,  */
                                                /*   open or close.     */
        if ( (!rc_equal(&gl_rzero, pt)) &&
              (pt->g_x == c.g_x) && 
              (pt->g_y == c.g_y) )
        {
                                                /* size or top request  */
          if ( (pt->g_w == c.g_w) && (pt->g_h == c.g_h) )
          {
                                                /* sizes of prev and    */
                                                /*  current are the same*/
                                                /*  so its a top request*/

                                                /* return if this isn't */
                                                /*   a top request      */
            if ( (w_handle != W_TREE[ROOT].ob_tail) ||
                 (w_handle == oldtop) )

              return;
                                                /* say when borders will*/
                                                /*   change             */
            diffbord = !( (D.w_win[oldtop].w_flags & VF_SUBWIN) &&
                          (D.w_win[gl_wtop].w_flags & VF_SUBWIN) );
                                                /* draw oldtop covered  */
                                                /*   with deactivated   */
                                                /*   borders            */
            if (oldtop != NIL)
            {
              if (diffbord)
                w_clipdraw(oldtop, 0, MAX_DEPTH, 2);
              clrold = !(D.w_win[oldtop].w_flags & VF_BROKEN);
            }
            else
              clrold = TRUE;
                                                /* if oldtop isn't      */
                                                /*   overlapped and new */
                                                /*   top was clear then */
                                                /*   just draw activated*/
                                                /*   borders            */
            if ( (clrold) && 
                 (wasclr) )
            {
              w_clipdraw(gl_wtop, 0, MAX_DEPTH, 1);
              return;
            }
          }
          else
                                                /* size change          */
          {
                                                /* stop before current  */
                                                /*   window if shrink   */
                                                /*   was a pure subset  */
            if ( (pt->g_w <= c.g_w) && (pt->g_h <= c.g_h) )
            {
              stop = w_handle;
              w_clipdraw(gl_wtop, 0, MAX_DEPTH, 2);
              moved = TRUE;
            }
                                                /* start at bottom if   */
                                                /*   a shrink occurred  */
            if ( (pt->g_w < c.g_w) || (pt->g_h < c.g_h) )
              start = DESKWH;
                                                /* update rect. is the  */
                                                /*   union of two sizes */
                                                /*   + the drop shadow  */
            c.g_w = max(pt->g_w, c.g_w) + 2; 
            c.g_h = max(pt->g_h, c.g_h) + 2; 
          }
        }
        else
        {
                                                /* move or grow or open */
                                                /*   or close           */
          if ( !(c.g_w && c.g_h) ||
                ( (pt->g_x <= c.g_x) && 
                  (pt->g_y <= c.g_y) &&
                  (pt->g_x+pt->g_w >= c.g_x+c.g_w) && 
                  (pt->g_y+pt->g_h >= c.g_y+c.g_h)))
          {
                                                /* a grow that is a     */
                                                /*  superset or an open */
            rc_copy(pt, &c);
          }
          else
          {
                                                /* move, close or shrink*/
                                                /* do a move of top guy */
            if ( (pt->g_w == c.g_w) && 
                 (pt->g_h == c.g_h) &&
                 (gl_wtop == w_handle) )
            {
              moved = w_move(w_handle, &stop, &c);
              start = DESKWH;
            }
                                                /* check for a close    */
            if ( !(pt->g_w && pt->g_h) )
              start = DESKWH;
                                                /* handle other moves   */
                                                /*   and shrinks        */
            if ( start != DESKWH )
            {
              rc_union(pt, &c);
              if ( !rc_equal(pt, &c) )
                start = DESKWH;
            }
          }
        }
                                                /* update gl_wtop       */
                                                /*   after close,       */
                                                /*   or open            */
        if ( oldtop != W_TREE[ROOT].ob_tail )
        {
          if (gl_wtop != NIL)
          {
                                                /* open or close with   */
                                                /*   other windows open */
            w_getsize(WS_CURR, gl_wtop, pt);
            rc_union(pt, &c);
                                                /* if it was an open    */
                                                /*   then draw the      */
                                                /*   old top guy        */
                                                /*   covered            */
            if ( (oldtop != NIL ) &&
                 (oldtop != w_handle) )
            {
                                                /* BUGFIX 2/20/86 LKW   */
                                                /* only an open if prev */
                                                /*  size was zero.      */
              w_getsize(WS_PREV, gl_wtop, &pprev);
              if (rc_equal(&pprev, &gl_rzero))
                w_clipdraw(oldtop, 0, MAX_DEPTH, 2);    /* */
            }
          }
        }
        c.g_w += 2;                             /* account for drop shadow*/
        c.g_h += 2;                             /* BUGFIX in 2.1        */
                                                
                                                /* update the desktop   */
                                                /*   background         */
        if (start == DESKWH)
          w_drawdesk(&c);

                                                /* start the redrawing  */
        w_update(start, &c, stop, moved, TRUE);
}