Subversion Repositories tpanel

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
188 andreas 1
/*
2
 * Copyright (C) 2022 by Andreas Theofilu <andreas@theosys.at>
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>
23
#include <QWidget>
24
 
25
QT_BEGIN_NAMESPACE
26
class QLineEdit;
192 andreas 27
class QTextEdit;
189 andreas 28
class QLabel;
188 andreas 29
class QHBoxLayout;
310 andreas 30
class TQSingleLine;
31
class TQMultiLine;
188 andreas 32
QT_END_NAMESPACE
33
 
191 andreas 34
class TQEditLine : public QWidget
188 andreas 35
{
303 andreas 36
    Q_OBJECT
37
 
188 andreas 38
    public:
192 andreas 39
        TQEditLine(QWidget *widget = nullptr, bool multiline=false);
40
        TQEditLine(std::string &text, QWidget *widget = nullptr, bool multiline=false);
188 andreas 41
        ~TQEditLine();
42
 
43
        void setText(std::string &text);
266 andreas 44
        void setObjectName(const std::string& name);
192 andreas 45
        void setPasswordChar(uint c);
190 andreas 46
        std::string& getText() { return mText; }
188 andreas 47
        void setFixedSize(int w, int h);
48
        void setFont(QFont &font);
310 andreas 49
        void setTextColor(QColor col);
188 andreas 50
        void setPalette(QPalette &pal);
51
        void grabGesture(Qt::GestureType type, Qt::GestureFlags flags = Qt::GestureFlags());
52
        void setPadding(int left, int top, int right, int bottom);
190 andreas 53
        void setFrameSize(int s);
192 andreas 54
        void setWordWrapMode(bool mode = false);
188 andreas 55
        void clear();
213 andreas 56
        void setInputMask(const std::string& mask);
57
        void setNumericInput();
58
#ifndef __ANDROID__
59
        void setCursor(const QCursor &qc);
60
        void setClearButtonEnabled(bool state);
61
#else
62
        inline void setCursor(const QCursor&) {}
63
        inline void setClearButtonEnabled(bool) {}
64
#endif
192 andreas 65
        void setHandle(ulong handle) { mHandle = handle; }
188 andreas 66
 
189 andreas 67
    signals:
303 andreas 68
        void inputChanged(ulong handle, std::string& text);
309 andreas 69
        void cursorPositionChanged(ulong handle, int oldPos, int newPos);
70
        void focusChanged(ulong handle, bool in);
303 andreas 71
 
72
    protected:
73
        void hideEvent(QHideEvent *event) override;
74
        void leaveEvent(QEvent *event) override;
75
        void closeEvent(QCloseEvent *event) override;
76
 
189 andreas 77
        void onTextChanged(const QString &text);
192 andreas 78
        void onTextAreaChanged();
309 andreas 79
        void onCursorPositionChangedS(int oldPos, int newPos);
80
        void onEditingFinished();
310 andreas 81
        void onFocusChanged(bool in);
82
        void onKeyPressed(int);
189 andreas 83
 
188 andreas 84
    private:
85
        void init();
303 andreas 86
        void _end();
188 andreas 87
 
88
        QHBoxLayout *mLayout{nullptr};
310 andreas 89
        TQSingleLine *mEdit{nullptr};
90
        TQMultiLine *mTextArea{nullptr};
188 andreas 91
 
92
        std::string mText;
192 andreas 93
        ulong mHandle{0};
94
        bool mChanged{false};
95
        bool mMultiline{false};
188 andreas 96
 
97
        int mPadLeft{0};
98
        int mPadTop{0};
99
        int mPadRight{0};
100
        int mPadBottom{0};
101
        int mWidth{0};
102
        int mHeight{0};
103
        int mPosX{0};
104
        int mPosY{0};
105
};
106
 
107
#endif