00001 #ifndef QHEXEDIT_H 00002 #define QHEXEDIT_H 00003 00004 #include <QHBoxLayout> 00005 #include "qhexedit_p.h" 00006 00047 class QHexEdit : public QScrollArea 00048 { 00049 Q_OBJECT 00053 Q_PROPERTY(QByteArray data READ data WRITE setData) 00054 00055 00060 Q_PROPERTY(int addressOffset READ addressOffset WRITE setAddressOffset) 00061 00065 Q_PROPERTY(QColor addressAreaColor READ addressAreaColor WRITE setAddressAreaColor) 00066 00070 Q_PROPERTY(int cursorPosition READ cursorPosition WRITE setCursorPosition) 00071 00076 Q_PROPERTY(QColor highlightingColor READ highlightingColor WRITE setHighlightingColor) 00077 00082 Q_PROPERTY(QColor selectionColor READ selectionColor WRITE setSelectionColor) 00083 00089 Q_PROPERTY(bool overwriteMode READ overwriteMode WRITE setOverwriteMode) 00090 00096 Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly) 00097 00099 Q_PROPERTY(QFont font READ font WRITE setFont) 00100 00101 00102 public: 00106 QHexEdit(QWidget *parent = 0); 00107 00115 int indexOf(const QByteArray & ba, int from = 0) const; 00116 00123 void insert(int i, const QByteArray & ba); 00124 00131 void insert(int i, char ch); 00132 00140 int lastIndexOf(const QByteArray & ba, int from = 0) const; 00141 00147 void remove(int pos, int len=1); 00148 00151 void replace( int pos, int len, const QByteArray & after); 00152 00155 QString toReadableString(); 00156 00159 QString selectionToReadableString(); 00160 00162 void setAddressOffset(int offset); 00163 int addressOffset(); 00164 void setCursorPosition(int cusorPos); 00165 int cursorPosition(); 00166 void setData(QByteArray const &data); 00167 QByteArray data(); 00168 void setAddressAreaColor(QColor const &color); 00169 QColor addressAreaColor(); 00170 void setHighlightingColor(QColor const &color); 00171 QColor highlightingColor(); 00172 void setSelectionColor(QColor const &color); 00173 QColor selectionColor(); 00174 void setOverwriteMode(bool); 00175 bool overwriteMode(); 00176 void setReadOnly(bool); 00177 bool isReadOnly(); 00178 const QFont &font() const; 00179 void setFont(const QFont &); 00182 public slots: 00186 void redo(); 00187 00191 void setAddressWidth(int addressWidth); 00192 00196 void setAddressArea(bool addressArea); 00197 00201 void setAsciiArea(bool asciiArea); 00202 00206 void setHighlighting(bool mode); 00207 00211 void undo(); 00212 00213 signals: 00214 00216 void currentAddressChanged(int address); 00217 00219 void currentSizeChanged(int size); 00220 00222 void dataChanged(); 00223 00225 void overwriteModeChanged(bool state); 00226 00227 private: 00229 QHexEditPrivate *qHexEdit_p; 00230 QHBoxLayout *layout; 00231 QScrollArea *scrollArea; 00233 }; 00234 00235 #endif 00236