MCPcopy Create free account
hub / github.com/NetHack/NetHack / setOffset

Method setOffset

outdated/win/Qt3/qt3tableview.cpp:474–542  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

472*/
473
474void QtTableView::setOffset( int x, int y, bool updateScrBars )
475{
476 if ( (!testTableFlags(Tbl_snapToHGrid) || xCellDelta == 0) &&
477 (!testTableFlags(Tbl_snapToVGrid) || yCellDelta == 0) &&
478 (x == xOffs && y == yOffs) )
479 return;
480
481 if ( x < 0 )
482 x = 0;
483 if ( y < 0 )
484 y = 0;
485
486 if ( cellW ) {
487 if ( x > maxXOffset() )
488 x = maxXOffset();
489 xCellOffs = x / cellW;
490 if ( !testTableFlags(Tbl_snapToHGrid) ) {
491 xCellDelta = (short)(x % cellW);
492 } else {
493 x = xCellOffs*cellW;
494 xCellDelta = 0;
495 }
496 } else {
497 int xn=0, xcd=0, col = 0;
498 while ( col < nCols-1 && x >= xn+(xcd=cellWidth(col)) ) {
499 xn += xcd;
500 col++;
501 }
502 xCellOffs = col;
503 if ( testTableFlags(Tbl_snapToHGrid) ) {
504 xCellDelta = 0;
505 x = xn;
506 } else {
507 xCellDelta = (short)(x-xn);
508 }
509 }
510 if ( cellH ) {
511 if ( y > maxYOffset() )
512 y = maxYOffset();
513 yCellOffs = y / cellH;
514 if ( !testTableFlags(Tbl_snapToVGrid) ) {
515 yCellDelta = (short)(y % cellH);
516 } else {
517 y = yCellOffs*cellH;
518 yCellDelta = 0;
519 }
520 } else {
521 int yn=0, yrd=0, row=0;
522 while ( row < nRows-1 && y >= yn+(yrd=cellHeight(row)) ) {
523 yn += yrd;
524 row++;
525 }
526 yCellOffs = row;
527 if ( testTableFlags(Tbl_snapToVGrid) ) {
528 yCellDelta = 0;
529 y = yn;
530 } else {
531 yCellDelta = (short)(y-yn);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected