< prev index next >

src/java.desktop/windows/native/libawt/windows/awt_TextArea.cpp

Print this page




 208             cr.cpMin = lCurPos;
 209             cr.cpMax = lCurPos;
 210             EditSetSel(cr);
 211         }
 212 
 213         /*
 214          * Cleanup the state variables when left mouse button is released.
 215          * These state variables are designed to reflect the selection state
 216          * while the left mouse button is pressed and be set to -1 otherwise.
 217          */
 218         SetStartSelectionPos(-1);
 219         SetEndSelectionPos(-1);
 220         SetLastSelectionPos(-1);
 221 
 222         delete msg;
 223         return mrConsume;
 224     } else if (msg->message == WM_MOUSEMOVE && (msg->wParam & MK_LBUTTON)) {
 225 
 226         /*
 227          * We consume WM_MOUSEMOVE while the left mouse button is pressed,
 228          * so we have to simulate autoscrolling when mouse is moved outside
 229          * of the client area.
 230          */
 231         POINT p;
 232         RECT r;
 233         BOOL bScrollLeft = FALSE;
 234         BOOL bScrollRight = FALSE;
 235         BOOL bScrollUp = FALSE;
 236         BOOL bScrollDown = FALSE;
 237 
 238         p.x = msg->pt.x;
 239         p.y = msg->pt.y;
 240         VERIFY(::GetClientRect(GetHWnd(), &r));
 241 
 242         if (p.x < 0) {
 243             bScrollLeft = TRUE;
 244             p.x = 0;
 245         } else if (p.x > r.right) {
 246             bScrollRight = TRUE;
 247             p.x = r.right - 1;
 248         }
 249         if (p.y < 0) {
 250             bScrollUp = TRUE;
 251             p.y = 0;
 252         } else if (p.y > r.bottom) {
 253             bScrollDown = TRUE;
 254             p.y = r.bottom - 1;
 255         }
 256 
 257         LONG lCurPos = EditGetCharFromPos(p);
 258 
 259         if (GetStartSelectionPos() != -1 &&
 260             GetEndSelectionPos() != -1 &&
 261             lCurPos != GetLastSelectionPos()) {
 262 
 263             CHARRANGE cr;
 264 
 265             SetLastSelectionPos(lCurPos);
 266 
 267             cr.cpMin = GetStartSelectionPos();
 268             cr.cpMax = GetLastSelectionPos();
 269 
 270             EditSetSel(cr);
 271         }
 272 
 273         if (bScrollLeft == TRUE || bScrollRight == TRUE) {
 274             SCROLLINFO si;
 275             memset(&si, 0, sizeof(si));
 276             si.cbSize = sizeof(si);
 277             si.fMask = SIF_PAGE | SIF_POS | SIF_RANGE;
 278 
 279             VERIFY(::GetScrollInfo(GetHWnd(), SB_HORZ, &si));
 280             if (bScrollLeft == TRUE) {
 281                 si.nPos = si.nPos - si.nPage / 2;
 282                 si.nPos = max(si.nMin, si.nPos);
 283             } else if (bScrollRight == TRUE) {
 284                 si.nPos = si.nPos + si.nPage / 2;
 285                 si.nPos = min(si.nPos, si.nMax);
 286             }
 287             /*
 288              * Okay to use 16-bit position since RichEdit control adjusts
 289              * its scrollbars so that their range is always 16-bit.
 290              */
 291             DASSERT(abs(si.nPos) < 0x8000);
 292             SendMessage(WM_HSCROLL,
 293                         MAKEWPARAM(SB_THUMBPOSITION, LOWORD(si.nPos)));
 294         }
 295         if (bScrollUp == TRUE) {
 296             SendMessage(EM_LINESCROLL, 0, -1);
 297         } else if (bScrollDown == TRUE) {
 298             SendMessage(EM_LINESCROLL, 0, 1);
 299         }
 300         delete msg;
 301         return mrConsume;
 302     } else if (msg->message == WM_MOUSEWHEEL) {
 303         // 4417236: If there is an old version of RichEd32.dll which
 304         // does not provide the mouse wheel scrolling we have to
 305         // interpret WM_MOUSEWHEEL as a sequence of scroll messages.
 306         // kdm@sparc.spb.su
 307         UINT platfScrollLines = 3;
 308         // Retrieve a number of scroll lines.
 309         ::SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0,
 310                                &platfScrollLines, 0);
 311 
 312         if (platfScrollLines > 0) {
 313             HWND hWnd = GetHWnd();
 314             LONG styles = ::GetWindowLong(hWnd, GWL_STYLE);
 315 
 316             RECT rect;
 317             // rect.left and rect.top are zero.
 318             // rect.right and rect.bottom contain the width and height




 208             cr.cpMin = lCurPos;
 209             cr.cpMax = lCurPos;
 210             EditSetSel(cr);
 211         }
 212 
 213         /*
 214          * Cleanup the state variables when left mouse button is released.
 215          * These state variables are designed to reflect the selection state
 216          * while the left mouse button is pressed and be set to -1 otherwise.
 217          */
 218         SetStartSelectionPos(-1);
 219         SetEndSelectionPos(-1);
 220         SetLastSelectionPos(-1);
 221 
 222         delete msg;
 223         return mrConsume;
 224     } else if (msg->message == WM_MOUSEMOVE && (msg->wParam & MK_LBUTTON)) {
 225 
 226         /*
 227          * We consume WM_MOUSEMOVE while the left mouse button is pressed,
 228          * so we have to simulate selection autoscrolling when mouse is moved
 229          * outside of the client area.
 230          */
 231         POINT p;






 232         p.x = msg->pt.x;
 233         p.y = msg->pt.y;

















 234         LONG lCurPos = EditGetCharFromPos(p);
 235 
 236         if (GetStartSelectionPos() != -1 &&
 237             GetEndSelectionPos() != -1 &&
 238             lCurPos != GetLastSelectionPos()) {
 239 
 240             CHARRANGE cr;
 241 
 242             SetLastSelectionPos(lCurPos);
 243 
 244             cr.cpMin = GetStartSelectionPos();
 245             cr.cpMax = GetLastSelectionPos();
 246 
 247             EditSetSel(cr);




























 248         }
 249         delete msg;
 250         return mrConsume;
 251     } else if (msg->message == WM_MOUSEWHEEL) {
 252         // 4417236: If there is an old version of RichEd32.dll which
 253         // does not provide the mouse wheel scrolling we have to
 254         // interpret WM_MOUSEWHEEL as a sequence of scroll messages.
 255         // kdm@sparc.spb.su
 256         UINT platfScrollLines = 3;
 257         // Retrieve a number of scroll lines.
 258         ::SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0,
 259                                &platfScrollLines, 0);
 260 
 261         if (platfScrollLines > 0) {
 262             HWND hWnd = GetHWnd();
 263             LONG styles = ::GetWindowLong(hWnd, GWL_STYLE);
 264 
 265             RECT rect;
 266             // rect.left and rect.top are zero.
 267             // rect.right and rect.bottom contain the width and height


< prev index next >