Subversion Repositories tpanel

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
188 andreas 1
/*
425 andreas 2
 * Copyright (C) 2022, 2023 by Andreas Theofilu <andreas@theosys.at>
188 andreas 3
 *
4
 * This program is free software; you can redistribute it and/or modify
5
 * it under the terms of the GNU General Public License as published by
6
 * the Free Software Foundation; either version 3 of the License, or
7
 * (at your option) any later version.
8
 *
9
 * This program is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 * GNU General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU General Public License
15
 * along with this program; if not, write to the Free Software Foundation,
16
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
17
 */
18
 
19
#ifndef __TQEDITLINE_H__
20
#define __TQEDITLINE_H__
21
 
22
#include <string>
425 andreas 23
 
188 andreas 24
#include <QWidget>
425 andreas 25
#include <QColor>
188 andreas 26
 
419 andreas 27
QT_BEGIN_NAMESPACE
28
class QLineEdit;
29
class QTextEdit;
30
class QLabel;
31
class QHBoxLayout;
32
class TQSingleLine;
33
class TQMultiLine;
34
QT_END_NAMESPACE
188 andreas 35
 
191 andreas 36
class TQEditLine : public QWidget
188 andreas 37
{
303 andreas 38
    Q_OBJECT
39
 
188 andreas 40
    public:
192 andreas 41
        TQEditLine(QWidget *widget = nullptr, bool multiline=false);
42
        TQEditLine(std::string &text, QWidget *widget = nullptr, bool multiline=false);
188 andreas 43
        ~TQEditLine();
44
 
45
        void setText(std::string &text);
266 andreas 46
        void setObjectName(const std::string& name);
192 andreas 47
        void setPasswordChar(uint c);
190 andreas 48
        std::string& getText() { return mText; }
188 andreas 49
        void setFixedSize(int w, int h);
50
        void setFont(QFont &font);
310 andreas 51
        void setTextColor(QColor col);
425 andreas 52
        void setBgColor(QColor& col);
188 andreas 53
        void setPalette(QPalette &pal);
421 andreas 54
        void setBackgroundPixmap(QPixmap& pixmap);
188 andreas 55
        void grabGesture(Qt::GestureType type, Qt::GestureFlags flags = Qt::GestureFlags());
56
        void setPadding(int left, int top, int right, int bottom);
190 andreas 57
        void setFrameSize(int s);
419 andreas 58
        void setWordWrapMode(bool mode = false);
188 andreas 59
        void clear();
213 andreas 60
        void setInputMask(const std::string& mask);
61
        void setNumericInput();
419 andreas 62
#ifndef __ANDROID__
213 andreas 63
        void setCursor(const QCursor &qc);
64
        void setClearButtonEnabled(bool state);
65
#else
66
        inline void setCursor(const QCursor&) {}
67
        inline void setClearButtonEnabled(bool) {}
68
#endif
192 andreas 69
        void setHandle(ulong handle) { mHandle = handle; }
188 andreas 70
 
189 andreas 71
    signals:
303 andreas 72
        void inputChanged(ulong handle, std::string& text);
309 andreas 73
        void cursorPositionChanged(ulong handle, int oldPos, int newPos);
74
        void focusChanged(ulong handle, bool in);
303 andreas 75
 
76
    protected:
77
        void hideEvent(QHideEvent *event) override;
78
        void leaveEvent(QEvent *event) override;
79
        void closeEvent(QCloseEvent *event) override;
421 andreas 80
        void paintEvent(QPaintEvent *event) override;
303 andreas 81
 
189 andreas 82
        void onTextChanged(const QString &text);
192 andreas 83
        void onTextAreaChanged();
309 andreas 84
        void onCursorPositionChangedS(int oldPos, int newPos);
85
        void onEditingFinished();
310 andreas 86
        void onFocusChanged(bool in);
87
        void onKeyPressed(int);
189 andreas 88
 
188 andreas 89
    private:
90
        void init();
303 andreas 91
        void _end();
188 andreas 92
 
419 andreas 93
        QHBoxLayout *mLayout{nullptr};
310 andreas 94
        TQSingleLine *mEdit{nullptr};
95
        TQMultiLine *mTextArea{nullptr};
421 andreas 96
        QPixmap mBackground;
425 andreas 97
        QColor mBgColor{Qt::transparent};
188 andreas 98
 
99
        std::string mText;
192 andreas 100
        ulong mHandle{0};
101
        bool mChanged{false};
102
        bool mMultiline{false};
188 andreas 103
 
104
        int mPadLeft{0};
105
        int mPadTop{0};
106
        int mPadRight{0};
107
        int mPadBottom{0};
108
        int mWidth{0};
109
        int mHeight{0};
110
        int mPosX{0};
111
        int mPosY{0};
112
};
113
 
114
#endif