446 |
andreas |
1 |
/*
|
|
|
2 |
* Copyright (C) 2022 to 2024 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 |
|
|
|
24 |
#include <QWidget>
|
|
|
25 |
#include <QColor>
|
|
|
26 |
|
|
|
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
|
|
|
35 |
|
|
|
36 |
class TQEditLine : public QWidget
|
|
|
37 |
{
|
|
|
38 |
Q_OBJECT
|
|
|
39 |
|
|
|
40 |
public:
|
|
|
41 |
TQEditLine(QWidget *widget = nullptr, bool multiline=false);
|
|
|
42 |
TQEditLine(std::string &text, QWidget *widget = nullptr, bool multiline=false);
|
|
|
43 |
~TQEditLine();
|
|
|
44 |
|
|
|
45 |
void setText(std::string &text);
|
|
|
46 |
void setPlaceholderText(std::string& text);
|
|
|
47 |
void setObjectName(const std::string& name);
|
|
|
48 |
void setPasswordChar(uint c);
|
|
|
49 |
std::string& getText() { return mText; }
|
|
|
50 |
void setFixedSize(int w, int h);
|
|
|
51 |
void setFont(QFont &font);
|
|
|
52 |
void setTextColor(QColor col);
|
|
|
53 |
void setBgColor(QColor& col);
|
|
|
54 |
void setPalette(QPalette &pal);
|
|
|
55 |
void setBackgroundPixmap(QPixmap& pixmap);
|
|
|
56 |
void grabGesture(Qt::GestureType type, Qt::GestureFlags flags = Qt::GestureFlags());
|
|
|
57 |
void setPadding(int left, int top, int right, int bottom);
|
|
|
58 |
void setFrameSize(int s);
|
|
|
59 |
void setWordWrapMode(bool mode = false);
|
|
|
60 |
void clear();
|
|
|
61 |
void setInputMask(const std::string& mask);
|
|
|
62 |
void setNumericInput();
|
|
|
63 |
#ifndef __ANDROID__
|
|
|
64 |
void setCursor(const QCursor &qc);
|
|
|
65 |
void setClearButtonEnabled(bool state);
|
|
|
66 |
#else
|
|
|
67 |
inline void setCursor(const QCursor&) {}
|
|
|
68 |
inline void setClearButtonEnabled(bool) {}
|
|
|
69 |
#endif
|
|
|
70 |
void setHandle(ulong handle) { mHandle = handle; }
|
|
|
71 |
|
|
|
72 |
signals:
|
|
|
73 |
void inputChanged(ulong handle, std::string& text);
|
|
|
74 |
void cursorPositionChanged(ulong handle, int oldPos, int newPos);
|
|
|
75 |
void focusChanged(ulong handle, bool in);
|
|
|
76 |
|
|
|
77 |
protected:
|
|
|
78 |
void hideEvent(QHideEvent *event) override;
|
|
|
79 |
void leaveEvent(QEvent *event) override;
|
|
|
80 |
void closeEvent(QCloseEvent *event) override;
|
|
|
81 |
void paintEvent(QPaintEvent *event) override;
|
|
|
82 |
|
|
|
83 |
void onTextChanged(const QString &text);
|
|
|
84 |
void onTextAreaChanged();
|
|
|
85 |
void onCursorPositionChangedS(int oldPos, int newPos);
|
|
|
86 |
void onEditingFinished();
|
|
|
87 |
void onFocusChanged(bool in);
|
|
|
88 |
void onKeyPressed(int);
|
|
|
89 |
|
|
|
90 |
private:
|
|
|
91 |
void init();
|
|
|
92 |
void _end();
|
|
|
93 |
|
|
|
94 |
QHBoxLayout *mLayout{nullptr};
|
|
|
95 |
TQSingleLine *mEdit{nullptr};
|
|
|
96 |
TQMultiLine *mTextArea{nullptr};
|
|
|
97 |
QPixmap mBackground;
|
|
|
98 |
QColor mBgColor{Qt::transparent};
|
|
|
99 |
|
|
|
100 |
std::string mText;
|
|
|
101 |
ulong mHandle{0};
|
|
|
102 |
bool mChanged{false};
|
|
|
103 |
bool mMultiline{false};
|
|
|
104 |
|
|
|
105 |
int mPadLeft{0};
|
|
|
106 |
int mPadTop{0};
|
|
|
107 |
int mPadRight{0};
|
|
|
108 |
int mPadBottom{0};
|
|
|
109 |
int mWidth{0};
|
|
|
110 |
int mHeight{0};
|
|
|
111 |
int mPosX{0};
|
|
|
112 |
int mPosY{0};
|
|
|
113 |
};
|
|
|
114 |
|
|
|
115 |
#endif
|