2012-01-04 22:13:01 +00:00
|
|
|
/* byte_view_text.h
|
|
|
|
*
|
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2012-06-28 22:56:06 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2012-01-04 22:13:01 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef BYTE_VIEW_TEXT_H
|
|
|
|
#define BYTE_VIEW_TEXT_H
|
|
|
|
|
2015-04-26 17:21:09 +00:00
|
|
|
#include <config.h>
|
2012-01-04 22:13:01 +00:00
|
|
|
|
|
|
|
#include <epan/packet.h>
|
|
|
|
#include <epan/proto.h>
|
|
|
|
#include <epan/tvbuff.h>
|
|
|
|
|
|
|
|
#include "proto_tree.h"
|
2015-12-17 19:41:46 +00:00
|
|
|
#include "ui/recent.h"
|
2014-10-24 20:24:23 +00:00
|
|
|
|
|
|
|
#include <QAbstractScrollArea>
|
2014-10-27 17:28:45 +00:00
|
|
|
#include <QMenu>
|
|
|
|
|
|
|
|
class QActionGroup;
|
2012-01-04 22:13:01 +00:00
|
|
|
|
|
|
|
// XXX - Is there any reason we shouldn't add ByteViewImage, etc?
|
|
|
|
|
2014-10-24 20:24:23 +00:00
|
|
|
class ByteViewText : public QAbstractScrollArea
|
2012-01-04 22:13:01 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2012-10-30 19:21:24 +00:00
|
|
|
explicit ByteViewText(QWidget *parent = 0, tvbuff_t *tvb = NULL, proto_tree *tree = NULL, QTreeWidget *protoTree = NULL, packet_char_enc encoding = PACKET_CHAR_ENC_CHAR_ASCII);
|
2015-12-22 13:51:08 +00:00
|
|
|
~ByteViewText();
|
|
|
|
|
2014-10-24 20:24:23 +00:00
|
|
|
bool hasDataSource(const tvbuff_t *ds_tvb = NULL);
|
2012-10-30 19:21:24 +00:00
|
|
|
void setFormat(bytes_view_type format);
|
2014-10-24 20:24:23 +00:00
|
|
|
void setHighlightStyle(bool bold) { bold_highlight_ = bold; }
|
2012-10-30 19:21:24 +00:00
|
|
|
void setProtocolHighlight(int start, int end);
|
|
|
|
void setFieldHighlight(int start, int end, guint32 mask = 0, int mask_le = 0);
|
|
|
|
void setFieldAppendixHighlight(int start, int end);
|
2015-05-29 18:33:16 +00:00
|
|
|
bool isEmpty() { return tvb_ == NULL || proto_tree_ == NULL; }
|
2015-07-29 23:24:39 +00:00
|
|
|
const guint8 *dataAndLength(guint *data_len_ptr);
|
2012-01-04 22:13:01 +00:00
|
|
|
|
2014-10-27 01:48:14 +00:00
|
|
|
signals:
|
2015-03-04 23:43:33 +00:00
|
|
|
void byteFieldHovered(const QString &);
|
2014-10-27 01:48:14 +00:00
|
|
|
|
2014-09-23 20:35:10 +00:00
|
|
|
public slots:
|
|
|
|
void setMonospaceFont(const QFont &mono_font);
|
|
|
|
|
2014-10-24 20:24:23 +00:00
|
|
|
protected:
|
|
|
|
virtual void paintEvent(QPaintEvent *);
|
|
|
|
virtual void resizeEvent(QResizeEvent *);
|
2014-10-27 01:48:14 +00:00
|
|
|
virtual void mousePressEvent (QMouseEvent * event);
|
|
|
|
virtual void mouseMoveEvent (QMouseEvent * event);
|
|
|
|
virtual void leaveEvent(QEvent *event);
|
2014-10-27 17:28:45 +00:00
|
|
|
virtual void contextMenuEvent(QContextMenuEvent *event);
|
2014-10-24 20:24:23 +00:00
|
|
|
|
2012-01-04 22:13:01 +00:00
|
|
|
private:
|
2012-10-30 19:21:24 +00:00
|
|
|
typedef enum {
|
|
|
|
StateNormal,
|
|
|
|
StateField,
|
2014-10-24 20:24:23 +00:00
|
|
|
StateProtocol,
|
|
|
|
StateOffsetNormal,
|
|
|
|
StateOffsetField
|
2012-10-30 19:21:24 +00:00
|
|
|
} highlight_state;
|
|
|
|
|
2014-10-24 20:24:23 +00:00
|
|
|
void drawOffsetLine(QPainter &painter, const guint offset, const int row_y);
|
2016-03-31 00:06:47 +00:00
|
|
|
qreal flushOffsetFragment(QPainter &painter, qreal x, int y, highlight_state state, gboolean extra_highlight, QString &text);
|
2012-10-30 19:21:24 +00:00
|
|
|
void scrollToByte(int byte);
|
2014-10-24 20:24:23 +00:00
|
|
|
int offsetChars();
|
|
|
|
int offsetPixels();
|
|
|
|
int hexPixels();
|
|
|
|
int asciiPixels();
|
|
|
|
int totalPixels();
|
|
|
|
void updateScrollbars();
|
2016-03-31 00:06:47 +00:00
|
|
|
int byteOffsetAtPixel(QPoint &pos);
|
2014-10-27 01:48:14 +00:00
|
|
|
field_info *fieldAtPixel(QPoint &pos);
|
2014-10-24 20:24:23 +00:00
|
|
|
|
|
|
|
static const int separator_interval_;
|
2012-10-30 19:21:24 +00:00
|
|
|
tvbuff_t *tvb_;
|
|
|
|
proto_tree *proto_tree_;
|
|
|
|
QTreeWidget *tree_widget_;
|
2014-10-25 19:36:32 +00:00
|
|
|
|
|
|
|
// Fonts and colors
|
|
|
|
QFont mono_font_;
|
|
|
|
// QFont mono_bold_font_;
|
|
|
|
QBrush offset_normal_fg_;
|
|
|
|
QBrush offset_field_fg_;
|
2012-10-30 19:21:24 +00:00
|
|
|
|
|
|
|
gboolean bold_highlight_;
|
|
|
|
|
2014-10-27 01:48:14 +00:00
|
|
|
// Data
|
2014-10-27 17:28:45 +00:00
|
|
|
QActionGroup *format_actions_;
|
2016-06-30 16:24:57 +00:00
|
|
|
QActionGroup *encoding_actions_;
|
|
|
|
packet_char_enc encoding_; // ASCII or EBCDIC
|
2014-10-27 17:28:45 +00:00
|
|
|
QMenu ctx_menu_;
|
2012-10-30 19:21:24 +00:00
|
|
|
|
2014-10-27 01:48:14 +00:00
|
|
|
// Data highlight
|
2016-09-17 15:48:41 +00:00
|
|
|
guint hovered_byte_offset_;
|
|
|
|
bool hovered_byte_lock_;
|
2014-10-27 01:48:14 +00:00
|
|
|
QPair<guint,guint> p_bound_;
|
|
|
|
QPair<guint,guint> f_bound_;
|
|
|
|
QPair<guint,guint> fa_bound_;
|
|
|
|
QPair<guint,guint> p_bound_save_;
|
|
|
|
QPair<guint,guint> f_bound_save_;
|
|
|
|
QPair<guint,guint> fa_bound_save_;
|
2014-10-24 20:24:23 +00:00
|
|
|
|
|
|
|
bool show_offset_; // Should we show the byte offset?
|
|
|
|
bool show_hex_; // Should we show the hex display?
|
|
|
|
bool show_ascii_; // Should we show the ASCII display?
|
|
|
|
guint row_width_; // Number of bytes per line
|
|
|
|
int one_em_; // Font character height
|
|
|
|
qreal font_width_; // Font character width
|
2014-10-25 19:36:32 +00:00
|
|
|
int line_spacing_; // Font line spacing
|
2014-10-24 20:24:23 +00:00
|
|
|
int margin_; // Text margin
|
|
|
|
|
|
|
|
// Data selection
|
|
|
|
QMap<int,int> x_pos_to_column_;
|
2012-01-04 22:13:01 +00:00
|
|
|
|
2014-10-27 17:28:45 +00:00
|
|
|
private slots:
|
|
|
|
void setHexDisplayFormat(QAction *action);
|
2016-06-30 16:24:57 +00:00
|
|
|
void setCharacterEncoding(QAction *action);
|
|
|
|
|
2012-01-04 22:13:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // BYTE_VIEW_TEXT_H
|
2012-09-04 08:18:31 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Editor modelines
|
|
|
|
*
|
|
|
|
* Local Variables:
|
|
|
|
* c-basic-offset: 4
|
|
|
|
* tab-width: 8
|
|
|
|
* indent-tabs-mode: nil
|
|
|
|
* End:
|
|
|
|
*
|
|
|
|
* ex: set shiftwidth=4 tabstop=8 expandtab:
|
|
|
|
* :indentSize=4:tabSize=8:noTabs=true:
|
|
|
|
*/
|