/* _mou_lup.c *********** Copyright 1991-1993 by Vermont Creative Software *********** _mou_lup() Performs function for a left mouse up Call #include #include int _mou_lup(kcp, eventp) KEYCTRLPTR kcp Key control pointer EVENTPTR eventp Pointer to event structure Returns 1 Success 0 Error Description In most cases _mou_lup() does nothing. In the case of dragging and resizing then actual work is done. The outline being dragged around is removed and memory for it is freed. The mask is restore to the state before the dragging process so that movements are not recorded. We then determine if the window coordinates have actually changed. If so, we figure its old and new coordinates and redraw where the window is now and any uncovered regions of the screen. */ #include #include #include int FASTCALL _mou_lup(kcp, eventp) KEYCTRLPTR kcp; EVENTPTR eventp; { int retval = 1; int x; /* Work variable */ int mou_row, mou_col; /*mouse row and column positions */ int delta_r, delta_c; /*Amount changed */ int old_rb, old_cb, old_re, old_ce; /* Where window was */ int new_rb, new_cb, new_re, new_ce; /* Where window will be */ ULONG flags; /*temporary storage for wnp->flags */ #ifndef NO_DEBUG_CODE static UCHAR fn[] = "_mou_lup"; #endif INIT_MODULE(fn); if (_wn_mange & RESIZE_MODE || _wn_mange & DRAG_MODE || _wn_mange & DRAG_HTHUMB || _wn_mange & DRAG_VTHUMB || _wn_mange & MARKREGION || (_vv_clipsize && _mark_loc->mark_type & REGIONMARKED)) _mou_setmask(_mou_mask); /*reset mask - no movement */ if (_wn_mange & DRAG_MODE || _wn_mange & RESIZE_MODE) { _mou_move(kcp, eventp); /*make sure we got all movements in */ mou_col = eventp->x / _mou_cellhorz; mou_row = eventp->y / _mou_cellvert; /*--------------------------------------------------------------------*/ /* Need to work on full dimeninsions for all windows being dragged */ /*--------------------------------------------------------------------*/ flags = _outwnp->flags; _outwnp->flags = (flags | FULL) & ~BUFFERED; mem_free(_mou_outbufp); /*free the outline buffer */ old_rb = _outwnp->rbf; /* assume window hasn't moved */ old_cb = _outwnp->cbf; old_re = _outwnp->ref; old_ce = _outwnp->cef; if (_wn_mange & DRAG_MODE) /*Dragging the window */ { /*--------------------------------------------------------------------*/ /* Determine distance moved and old window coordinates */ /*--------------------------------------------------------------------*/ if (delta_r = mou_row - _drag_loc.out_row) { old_rb -= delta_r; old_re -= delta_r; } if (delta_c = mou_col - _drag_loc.out_col) { old_cb -= delta_c; old_ce -= delta_c; } } else if (_wn_mange & RESIZE_MODE) { /*----------------------------------------------------------------*/ /* Determine the new coordinates of the window */ /*----------------------------------------------------------------*/ if ((_wn_mange & (RESIZE_COR1 | RESIZE_COR2)) && (delta_r = _outwnp->rbf - _drag_loc.out_row)) old_rb -= delta_r; if ((_wn_mange & (RESIZE_COR1 | RESIZE_COR3)) && (delta_c = _outwnp->cbf - _drag_loc.out_col)) old_cb -= delta_c; if ((_wn_mange & (RESIZE_COR2 | RESIZE_COR4)) && (delta_c = _outwnp->cef - _drag_loc.out_col)) old_ce -= delta_c; if ((_wn_mange & (RESIZE_COR3 | RESIZE_COR4)) && (delta_r = _outwnp->ref - _drag_loc.out_row)) old_re -= delta_r; } if ((delta_r) || (delta_c)) { /*----------------------------------------------------------------*/ /* The window has been changed. Figure new inside and cursor, */ /* then redraw the new window, then redraw where it came from. */ /*----------------------------------------------------------------*/ _sw_inside(_outwnp); if (delta_r) { /* Adjust window origin and cursor row*/ if ((_outwnp->bufp) && (_outwnp->row_org > (x = _outwnp->bufp->row_q - _wi_rowq(_outwnp)))) _outwnp->row_org = max(0, x); _outwnp->r = min(_outwnp->r, _outwnp->row_org + _wi_rowq(_outwnp) - 1); } if (delta_c) { /* Adjust window origin and cursor col*/ if ((_outwnp->bufp) && (_outwnp->col_org > (x = _outwnp->bufp->col_q - _wi_colq(_outwnp)))) _outwnp->col_org = max(0, x); _outwnp->c = min(_outwnp->c, _outwnp->col_org + _wi_colq(_outwnp) - 1); } _outwnp->flags |= WNHIDDEN; /* Stop echo of border to screen */ v_bdr(_outwnp); /* Prepare border VST for new size */ if (!(flags & WNHIDDEN)) /* If window wasn't already hidden */ { _outwnp->flags &= ~WNHIDDEN; /* Unset WNHIDDEN flag */ new_rb = _outwnp->rbf; /* Save new coordinates */ new_re = _outwnp->ref; new_cb = _outwnp->cbf; new_ce = _outwnp->cef; _outwnp->rbf = old_rb; /* restore coords to remove shadow */ _outwnp->ref = old_re; _outwnp->cbf = old_cb; _outwnp->cef = old_ce; _shad_updn(DOWN, _outwnp); _outwnp->rbf = new_rb; /* restore new coordinates */ _outwnp->ref = new_re; _outwnp->cbf = new_cb; _outwnp->cef = new_ce; _shad_updn(UP, _outwnp); _wn_redraw(LOWERWN, _outwnp, old_rb, old_cb, old_re, old_ce); _wn_redraw(WNCHILDREN, _outwnp, _outwnp->rbf, _outwnp->cbf, _outwnp->ref, _outwnp->cef); } } else v_bdr(_outwnp); /* Restore original border */ _outwnp->flags = flags; /* restore window flags */ } if (_i_ismarkon()) /*call cleanup routine for VV CB */ { /*if button released in same position */ /*as it was pressed, exit mark mode */ if ((_mark_loc->start_row == _mark_loc->end_row) && (_mark_loc->start_col == _mark_loc->end_col)) { retval = _evnt_send(kcp, AC_ENDMARK, 0, 0); _mark_loc->mark_type &= ~REGIONMARKED; } else /*otherwise, leave marking on region */ _mark_loc->mark_type |= REGIONMARKED; _wn_mange &= ~MARKREGION; /*turn off marking */ _mark_loc->mark_type &= ~CLIPMOUSE; } _wn_mange &= ~(RESIZE_MODE | DRAG_MODE | DRAG_VTHUMB | DRAG_HTHUMB | RESIZE_COR1 | RESIZE_COR2 | RESIZE_COR3 | RESIZE_COR4); EXIT_NOERRH(fn); return(retval); }