#ifndef CODEEDITOR_H
#define CODEEDITOR_H

#include <QPlainTextEdit>
#include <QObject>
#include "highlighter.h"

QT_BEGIN_NAMESPACE
class QPaintEvent;
class QResizeEvent;
class QSize;
class QWidget;
QT_END_NAMESPACE

class LineNumberArea;

//![codeeditordefinition]

class CodeEditor : public QPlainTextEdit
{
    Q_OBJECT

public:
    CodeEditor(QWidget *parent = 0);
    char          c_code_data[4095];
    unsigned char iMode;
    Highlighter   *highlighter;

    void lineNumberAreaPaintEvent(QPaintEvent *event);
    int  lineNumberAreaWidth();
    void setFileName(QString sfileName);

protected:
    void resizeEvent(QResizeEvent *event);

public slots:
    void updateLineNumberAreaWidth(int newBlockCount);
    void highlightCurrentLine();
    void updateLineNumberArea(const QRect &, int);
    void saveFile();
    void CurrentDBGLine(int i);
    void mPropagateHIDClickSlot(int);



    void setMode(quint16 mode)
    {
        iMode = mode;
    }
    void slot_mouseDoubleClickEvent(QMouseEvent *e);

private:
    QWidget *lineNumberArea;
    QString sfileName;
signals:
    void code_edit_text_changed();
    void current_line_changed(QString);
    void mPropagateHIDClick(int);
};

//![codeeditordefinition]
//![extraarea]

class LineNumberArea : public QWidget
{
public:
    LineNumberArea(CodeEditor *editor)
        : QWidget(editor)
    {
        codeEditor = editor;
    }



    QSize sizeHint() const
    {
        return (QSize(codeEditor->lineNumberAreaWidth(), 0));
    }

protected:
    void paintEvent(QPaintEvent *event)
    {
        codeEditor->lineNumberAreaPaintEvent(event);
    }

private:
    CodeEditor *codeEditor;
};

//![extraarea]

#endif
