Source:NetHack 3.6.0/include/qttableview.h

From NetHackWiki
(Redirected from Source:Qttableview.h)
Jump to: navigation, search

Below is the full text to qttableview.h from the source code of NetHack 3.6.0. To link to a particular line, write [[Source:NetHack 3.6.0/include/qttableview.h#line123]], for example.

The NetHack General Public License applies to screenshots, source code and other content from NetHack.

This content was modified from the original NetHack source code distribution (by splitting up NetHack content between wiki pages, and possibly further editing). See the page history for a list of who changed it, and on what dates.

  1.  /**********************************************************************
  2.  ** $NHDT-Branch$:$NHDT-Revision$ $NHDT-Date$
  3.  ** $Id: qttableview.h,v 1.2 2002/03/09 03:13:13 jwalz Exp $
  4.  **
  5.  ** Definition of QtTableView class
  6.  **
  7.  ** Created : 941115
  8.  **
  9.  ** Copyright (C) 1992-2000 Trolltech AS.  All rights reserved.
  10.  **
  11.  ** This file contains a class moved out of the Qt GUI Toolkit API. It
  12.  ** may be used, distributed and modified without limitation.
  13.  **
  14.  **********************************************************************/
  15.  
  16.  #ifndef QTTABLEVIEW_H
  17.  #define QTTABLEVIEW_H
  18.  
  19.  #ifndef QT_H
  20.  #include <qframe.h>
  21.  #endif // QT_H
  22.  
  23.  #ifndef QT_NO_QTTABLEVIEW
  24.  
  25.  class QScrollBar;
  26.  class QCornerSquare;
  27.  
  28.  class QtTableView : public QFrame
  29.  {
  30.      Q_OBJECT
  31.    public:
  32.      virtual void setBackgroundColor(const QColor &);
  33.      virtual void setPalette(const QPalette &);
  34.      void show();
  35.  
  36.      void repaint(bool erase = TRUE);
  37.      void repaint(int x, int y, int w, int h, bool erase = TRUE);
  38.      void repaint(const QRect &, bool erase = TRUE);
  39.  
  40.    protected:
  41.      QtTableView(QWidget *parent = 0, const char *name = 0, WFlags f = 0);
  42.      ~QtTableView();
  43.  
  44.      int numRows() const;
  45.      virtual void setNumRows(int);
  46.      int numCols() const;
  47.      virtual void setNumCols(int);
  48.  
  49.      int topCell() const;
  50.      virtual void setTopCell(int row);
  51.      int leftCell() const;
  52.      virtual void setLeftCell(int col);
  53.      virtual void setTopLeftCell(int row, int col);
  54.  
  55.      int xOffset() const;
  56.      virtual void setXOffset(int);
  57.      int yOffset() const;
  58.      virtual void setYOffset(int);
  59.      virtual void setOffset(int x, int y, bool updateScrBars = TRUE);
  60.  
  61.      virtual int cellWidth(int col);
  62.      virtual int cellHeight(int row);
  63.      int cellWidth() const;
  64.      int cellHeight() const;
  65.      virtual void setCellWidth(int);
  66.      virtual void setCellHeight(int);
  67.  
  68.      virtual int totalWidth();
  69.      virtual int totalHeight();
  70.  
  71.      uint tableFlags() const;
  72.      bool testTableFlags(uint f) const;
  73.      virtual void setTableFlags(uint f);
  74.      void clearTableFlags(uint f = ~0);
  75.  
  76.      bool autoUpdate() const;
  77.      virtual void setAutoUpdate(bool);
  78.  
  79.      void updateCell(int row, int column, bool erase = TRUE);
  80.  
  81.      QRect cellUpdateRect() const;
  82.      QRect viewRect() const;
  83.  
  84.      int lastRowVisible() const;
  85.      int lastColVisible() const;
  86.  
  87.      bool rowIsVisible(int row) const;
  88.      bool colIsVisible(int col) const;
  89.  
  90.      QScrollBar *verticalScrollBar() const;
  91.      QScrollBar *horizontalScrollBar() const;
  92.  
  93.    private slots:
  94.      void horSbValue(int);
  95.      void horSbSliding(int);
  96.      void horSbSlidingDone();
  97.      void verSbValue(int);
  98.      void verSbSliding(int);
  99.      void verSbSlidingDone();
  100.  
  101.    protected:
  102.      virtual void paintCell(QPainter *, int row, int col) = 0;
  103.      virtual void setupPainter(QPainter *);
  104.  
  105.      void paintEvent(QPaintEvent *);
  106.      void resizeEvent(QResizeEvent *);
  107.  
  108.      int findRow(int yPos) const;
  109.      int findCol(int xPos) const;
  110.  
  111.      bool rowYPos(int row, int *yPos) const;
  112.      bool colXPos(int col, int *xPos) const;
  113.  
  114.      int maxXOffset();
  115.      int maxYOffset();
  116.      int maxColOffset();
  117.      int maxRowOffset();
  118.  
  119.      int minViewX() const;
  120.      int minViewY() const;
  121.      int maxViewX() const;
  122.      int maxViewY() const;
  123.      int viewWidth() const;
  124.      int viewHeight() const;
  125.  
  126.      void scroll(int xPixels, int yPixels);
  127.      void updateScrollBars();
  128.      void updateTableSize();
  129.  
  130.    private:
  131.      void coverCornerSquare(bool);
  132.      void snapToGrid(bool horizontal, bool vertical);
  133.      virtual void setHorScrollBar(bool on, bool update = TRUE);
  134.      virtual void setVerScrollBar(bool on, bool update = TRUE);
  135.      void updateView();
  136.      int findRawRow(int yPos, int *cellMaxY, int *cellMinY = 0,
  137.                     bool goOutsideView = FALSE) const;
  138.      int findRawCol(int xPos, int *cellMaxX, int *cellMinX = 0,
  139.                     bool goOutsideView = FALSE) const;
  140.      int maxColsVisible() const;
  141.  
  142.      void updateScrollBars(uint);
  143.      void updateFrameSize();
  144.  
  145.      void doAutoScrollBars();
  146.      void showOrHideScrollBars();
  147.  
  148.      int nRows;
  149.      int nCols;
  150.      int xOffs, yOffs;
  151.      int xCellOffs, yCellOffs;
  152.      short xCellDelta, yCellDelta;
  153.      short cellH, cellW;
  154.  
  155.      uint eraseInPaint : 1;
  156.      uint verSliding : 1;
  157.      uint verSnappingOff : 1;
  158.      uint horSliding : 1;
  159.      uint horSnappingOff : 1;
  160.      uint coveringCornerSquare : 1;
  161.      uint sbDirty : 8;
  162.      uint inSbUpdate : 1;
  163.  
  164.      uint tFlags;
  165.      QRect cellUpdateR;
  166.  
  167.      QScrollBar *vScrollBar;
  168.      QScrollBar *hScrollBar;
  169.      QCornerSquare *cornerSquare;
  170.  
  171.    private: // Disabled copy constructor and operator=
  172.  #if defined(Q_DISABLE_COPY)
  173.      QtTableView(const QtTableView &);
  174.      QtTableView &operator=(const QtTableView &);
  175.  #endif
  176.  };
  177.  
  178.  const uint Tbl_vScrollBar = 0x00000001;
  179.  const uint Tbl_hScrollBar = 0x00000002;
  180.  const uint Tbl_autoVScrollBar = 0x00000004;
  181.  const uint Tbl_autoHScrollBar = 0x00000008;
  182.  const uint Tbl_autoScrollBars = 0x0000000C;
  183.  
  184.  const uint Tbl_clipCellPainting = 0x00000100;
  185.  const uint Tbl_cutCellsV = 0x00000200;
  186.  const uint Tbl_cutCellsH = 0x00000400;
  187.  const uint Tbl_cutCells = 0x00000600;
  188.  
  189.  const uint Tbl_scrollLastHCell = 0x00000800;
  190.  const uint Tbl_scrollLastVCell = 0x00001000;
  191.  const uint Tbl_scrollLastCell = 0x00001800;
  192.  
  193.  const uint Tbl_smoothHScrolling = 0x00002000;
  194.  const uint Tbl_smoothVScrolling = 0x00004000;
  195.  const uint Tbl_smoothScrolling = 0x00006000;
  196.  
  197.  const uint Tbl_snapToHGrid = 0x00008000;
  198.  const uint Tbl_snapToVGrid = 0x00010000;
  199.  const uint Tbl_snapToGrid = 0x00018000;
  200.  
  201.  inline int
  202.  QtTableView::numRows() const
  203.  {
  204.      return nRows;
  205.  }
  206.  
  207.  inline int
  208.  QtTableView::numCols() const
  209.  {
  210.      return nCols;
  211.  }
  212.  
  213.  inline int
  214.  QtTableView::topCell() const
  215.  {
  216.      return yCellOffs;
  217.  }
  218.  
  219.  inline int
  220.  QtTableView::leftCell() const
  221.  {
  222.      return xCellOffs;
  223.  }
  224.  
  225.  inline int
  226.  QtTableView::xOffset() const
  227.  {
  228.      return xOffs;
  229.  }
  230.  
  231.  inline int
  232.  QtTableView::yOffset() const
  233.  {
  234.      return yOffs;
  235.  }
  236.  
  237.  inline int
  238.  QtTableView::cellHeight() const
  239.  {
  240.      return cellH;
  241.  }
  242.  
  243.  inline int
  244.  QtTableView::cellWidth() const
  245.  {
  246.      return cellW;
  247.  }
  248.  
  249.  inline uint
  250.  QtTableView::tableFlags() const
  251.  {
  252.      return tFlags;
  253.  }
  254.  
  255.  inline bool
  256.  QtTableView::testTableFlags(uint f) const
  257.  {
  258.      return (tFlags & f) != 0;
  259.  }
  260.  
  261.  inline QRect
  262.  QtTableView::cellUpdateRect() const
  263.  {
  264.      return cellUpdateR;
  265.  }
  266.  
  267.  inline bool
  268.  QtTableView::autoUpdate() const
  269.  {
  270.      return isUpdatesEnabled();
  271.  }
  272.  
  273.  inline void
  274.  QtTableView::repaint(bool erase)
  275.  {
  276.      repaint(0, 0, width(), height(), erase);
  277.  }
  278.  
  279.  inline void
  280.  QtTableView::repaint(const QRect &r, bool erase)
  281.  {
  282.      repaint(r.x(), r.y(), r.width(), r.height(), erase);
  283.  }
  284.  
  285.  inline void
  286.  QtTableView::updateScrollBars()
  287.  {
  288.      updateScrollBars(0);
  289.  }
  290.  
  291.  #endif // QT_NO_QTTABLEVIEW
  292.  
  293.  #endif // QTTABLEVIEW_H