Check that the cursor is visible (called, when editing text) If it's not, shift scroll positions, so it will be visible once again
| 1406 | // Check that the cursor is visible (called, when editing text) |
| 1407 | // If it's not, shift scroll positions, so it will be visible once again |
| 1408 | void TextareaData::ScrollToCursor() |
| 1409 | { |
| 1410 | bool updated = false; |
| 1411 | if(RichTextarea::charHeight && int(cursorCharY) > (areaHeight-32) / RichTextarea::charHeight + shiftCharY) |
| 1412 | { |
| 1413 | shiftCharY = cursorCharY - (areaHeight-32) / RichTextarea::charHeight; |
| 1414 | updated = true; |
| 1415 | } |
| 1416 | if(int(cursorCharY) < shiftCharY) |
| 1417 | { |
| 1418 | shiftCharY = cursorCharY - 1; |
| 1419 | updated = true; |
| 1420 | } |
| 1421 | if(RichTextarea::charWidth && int(cursorCharX) > (areaWidth-32) / RichTextarea::charWidth + shiftCharX) |
| 1422 | { |
| 1423 | shiftCharX = cursorCharX - (areaWidth-32) / RichTextarea::charWidth; |
| 1424 | updated = true; |
| 1425 | } |
| 1426 | if(int(cursorCharX) < shiftCharX) |
| 1427 | { |
| 1428 | shiftCharX = cursorCharX - 1; |
| 1429 | updated = true; |
| 1430 | } |
| 1431 | if(!updated) |
| 1432 | return; |
| 1433 | ClampShift(); |
| 1434 | InvalidateRect(areaWnd, NULL, false); |
| 1435 | UpdateScrollBar(); |
| 1436 | } |
| 1437 | |
| 1438 | // Convert cursor position to local pixel coordinates |
| 1439 | void TextareaData::CursorToClient(unsigned int xCursor, unsigned int yCursor, int &xPos, int &yPos) |