00001 #ifndef QHEXEDIT_P_H
00002 #define QHEXEDIT_P_H
00003
00006 #include <QtGui>
00007 #include <QWidget>
00008 #include <QScrollArea>
00009 #include <QUndoStack>
00010 #include "xbytearray.h"
00011
00012 class QHexEditPrivate : public QWidget
00013 {
00014 Q_OBJECT
00015
00016 public:
00017 QHexEditPrivate(QScrollArea *parent);
00018
00019 void setAddressAreaColor(QColor const &color);
00020 QColor addressAreaColor();
00021
00022 void setAddressOffset(int offset);
00023 int addressOffset();
00024
00025 void setCursorPos(int position);
00026 int cursorPos();
00027
00028 void setData(QByteArray const &data);
00029 QByteArray data();
00030
00031 void setHighlightingColor(QColor const &color);
00032 QColor highlightingColor();
00033
00034 void setOverwriteMode(bool overwriteMode);
00035 bool overwriteMode();
00036
00037 void setReadOnly(bool readOnly);
00038 bool isReadOnly();
00039
00040 void setSelectionColor(QColor const &color);
00041 QColor selectionColor();
00042
00043 XByteArray & xData();
00044
00045 int indexOf(const QByteArray & ba, int from = 0);
00046 void insert(int index, const QByteArray & ba);
00047 void insert(int index, char ch);
00048 int lastIndexOf(const QByteArray & ba, int from = 0);
00049 void remove(int index, int len=1);
00050 void replace(int index, char ch);
00051 void replace(int index, const QByteArray & ba);
00052 void replace(int pos, int len, const QByteArray & after);
00053
00054 void setAddressArea(bool addressArea);
00055 void setAddressWidth(int addressWidth);
00056 void setAsciiArea(bool asciiArea);
00057 void setHighlighting(bool mode);
00058 virtual void setFont(const QFont &font);
00059
00060 void undo();
00061 void redo();
00062
00063 QString toRedableString();
00064 QString selectionToReadableString();
00065
00066 signals:
00067 void currentAddressChanged(int address);
00068 void currentSizeChanged(int size);
00069 void dataChanged();
00070 void overwriteModeChanged(bool state);
00071
00072 protected:
00073 void keyPressEvent(QKeyEvent * event);
00074 void mouseMoveEvent(QMouseEvent * event);
00075 void mousePressEvent(QMouseEvent * event);
00076
00077 void paintEvent(QPaintEvent *event);
00078
00079 int cursorPos(QPoint pos);
00080
00081 void resetSelection(int pos);
00082 void resetSelection();
00083 void setSelection(int pos);
00084 int getSelectionBegin();
00085 int getSelectionEnd();
00086
00087
00088 private slots:
00089 void updateCursor();
00090 void adjust();
00091
00092 private:
00093 void ensureVisible();
00094
00095 QColor _addressAreaColor;
00096 QColor _highlightingColor;
00097 QColor _selectionColor;
00098 QScrollArea *_scrollArea;
00099 QTimer _cursorTimer;
00100 QUndoStack *_undoStack;
00101
00102 XByteArray _xData;
00103
00104 bool _blink;
00105 bool _renderingRequired;
00106 bool _addressArea;
00107 bool _asciiArea;
00108 bool _highlighting;
00109 bool _overwriteMode;
00110 bool _readOnly;
00111
00112 int _charWidth, _charHeight;
00113 int _cursorX, _cursorY;
00114 int _cursorPosition;
00115 int _xPosAdr, _xPosHex, _xPosAscii;
00116
00117 int _selectionBegin;
00118 int _selectionEnd;
00119 int _selectionInit;
00120
00121 int _size;
00122 };
00123
00126 #endif
00127