OSDN Git Service

37c17a1ba439758a3e78dbb3fd51340423e4c76a
[gefu/Gefu.git] / hexview.h
1 #ifndef HEXVIEW_H
2 #define HEXVIEW_H
3
4 #include <QWidget>
5 class QScrollArea;
6
7 class HexView : public QWidget
8 {
9     Q_OBJECT
10 public:
11     explicit HexView(QScrollArea *parent = 0);
12
13     void    setData(const QByteArray &data);
14
15 private:
16     QScrollArea*    m_scrollArea;
17     QByteArray      m_data;
18     int             m_charHeight;
19     int             m_charWidth;
20     int             m_selectionBegin;
21     int             m_selectionEnd;
22     int             m_selectionInit;
23
24     int     addressChars() const;
25     void    adjust();
26     int     cursorPos(const QPoint &pos);
27     void    resetSelection(int index);
28     void    setSelection(int index);
29     int     xPosHex() const;
30     int     xPosAscii() const;
31
32
33 signals:
34     void    copyAvailable(bool);
35     void    statusChanged(const QString &text);
36
37 public slots:
38     void    onCopy();
39     void    onScaleDown();
40     void    onScaleUp();
41     void    onSelectAll();
42
43     // QWidget interface
44 public slots:
45     void setVisible(bool visible);
46
47 protected:
48     void mousePressEvent(QMouseEvent *e);
49     void mouseDoubleClickEvent(QMouseEvent *e);
50     void mouseMoveEvent(QMouseEvent *e);
51     void keyPressEvent(QKeyEvent *);
52     void paintEvent(QPaintEvent *e);
53 };
54
55 #endif // HEXVIEW_H