420 |
andreas |
1 |
/*
|
|
|
2 |
* Copyright (C) 2022, 2023 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 __TQTEXTEDIT_H__
|
|
|
20 |
#define __TQTEXTEDIT_H__
|
|
|
21 |
|
|
|
22 |
#include <QWidget>
|
|
|
23 |
#include <QString>
|
|
|
24 |
|
|
|
25 |
QT_BEGIN_NAMESPACE
|
|
|
26 |
class QPixmap;
|
|
|
27 |
QT_END_NAMESPACE
|
|
|
28 |
|
421 |
andreas |
29 |
class TQTextEdit : public QWidget
|
420 |
andreas |
30 |
{
|
|
|
31 |
Q_OBJECT
|
|
|
32 |
|
|
|
33 |
public:
|
|
|
34 |
TQTextEdit(QWidget *parent=nullptr);
|
|
|
35 |
TQTextEdit(const QString& text, QWidget *parent=nullptr);
|
|
|
36 |
|
|
|
37 |
void setText(const QString& text);
|
|
|
38 |
QString& getText() { return mText; }
|
|
|
39 |
void setHandle(ulong handle) { mHandle = handle; }
|
|
|
40 |
ulong getHandle() { return mHandle; }
|
|
|
41 |
void setBackgroundPixmap(const QPixmap& pixmap);
|
|
|
42 |
QPixmap& getBackgroundPixmap() { return mBackground; }
|
|
|
43 |
void setAlignment(Qt::Alignment al);
|
|
|
44 |
void setPadding(int left, int top, int right, int bottom);
|
|
|
45 |
void setPasswordChar(char c) { mPwChar = (c > 0 ? c : '*'); }
|
|
|
46 |
|
|
|
47 |
signals:
|
|
|
48 |
void contentChanged(const QString& text);
|
|
|
49 |
|
|
|
50 |
protected:
|
|
|
51 |
virtual bool event(QEvent *event);
|
|
|
52 |
virtual void paintEvent(QPaintEvent *);
|
|
|
53 |
virtual void resizeEvent(QResizeEvent *);
|
|
|
54 |
void updateCoordinates();
|
|
|
55 |
|
|
|
56 |
private:
|
|
|
57 |
void init();
|
|
|
58 |
void append(const QString& txt);
|
|
|
59 |
void insert(const QString& txt, int pos=-1);
|
|
|
60 |
|
|
|
61 |
QString mText;
|
|
|
62 |
int mPos{0}; // The current cursor position
|
|
|
63 |
ulong mHandle{0};
|
|
|
64 |
QPixmap mBackground;
|
|
|
65 |
int mFontPointSize{8};
|
|
|
66 |
int mTextLength{0};
|
|
|
67 |
int mTextHeight{0};
|
|
|
68 |
Qt::Alignment mAlignment{Qt::AlignLeft | Qt::AlignHCenter};
|
|
|
69 |
int mPosX{0};
|
|
|
70 |
int mPosY{0};
|
|
|
71 |
int mPadLeft{0};
|
|
|
72 |
int mPadTop{0};
|
|
|
73 |
int mPadRight{0};
|
|
|
74 |
int mPadBottom{0};
|
|
|
75 |
bool mShift{false};
|
|
|
76 |
bool mCapsLock{false};
|
|
|
77 |
bool mCtrl{false};
|
|
|
78 |
char mPwChar{'*'};
|
|
|
79 |
};
|
|
|
80 |
|
|
|
81 |
#endif
|