File: textedit.cpp

package info (click to toggle)
ams 1.8.7-5
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,880 kB
  • ctags: 2,171
  • sloc: cpp: 17,793; makefile: 433; sh: 101
file content (117 lines) | stat: -rw-r--r-- 2,709 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <qwidget.h>
#include <qpainter.h>
#include <qstring.h>
#include <qslider.h>
#include <qcheckbox.h>
#include <qlabel.h>
#include <qvbox.h>
#include <qhbox.h>
#include <qspinbox.h>
#include <qradiobutton.h>
#include <qtextedit.h>
#include <qpushbutton.h>
#include <alsa/asoundlib.h>
#include "synthdata.h"
#include "textedit.h"

TextEdit::TextEdit(QWidget* parent, const char *name, SynthData *p_synthdata) : QVBox(parent, name) {

  synthdata = p_synthdata;
  setMargin(5);
  setSpacing(5);
//  synthdata->incTextEditCount();
//  textEditID = synthdata->getTextEditID();
//  synthdata->textEditList.append(this);
  textEditID = 0;  // TODO assign this 
  setPalette(QPalette(QColor(77, 70, 64), QColor(77, 70, 64)));
  setGeometry(TEXTEDIT_NEW_X, TEXTEDIT_NEW_Y, TEXTEDIT_DEFAULT_WIDTH, TEXTEDIT_DEFAULT_HEIGHT);
  drag = false;
  sizeDrag = false;
  QHBox *editBox = new QHBox(this);
  editBox->setMargin(5);
  textEdit = new QTextEdit(editBox);
//  textEdit->setColor(QColor(0, 0, 0));
//  textEdit->setPaper(QBrush(QColor(250, 250, 250)));
  textEdit->setPalette(QPalette(QColor(77, 70, 64), QColor(250, 250, 250)));
  QHBox *buttonBox = new QHBox(this);
  buttonBox->setMargin(5);
  new QWidget(buttonBox);
  QPushButton *removeButton = new QPushButton("Remove Comment", buttonBox);
  QObject::connect(removeButton, SIGNAL(clicked()), this, SLOT(removeThisTextEdit()));
  new QWidget(buttonBox);
}

TextEdit::~TextEdit() {

//  synthdata->textEditListList.removeRef(this);
//  synthdata->decTextEditCount();
}

void TextEdit::paintEvent(QPaintEvent *ev) {
  
  QPainter p(this);
  int l1;

  for (l1 = 0; l1 < 4; l1++) { 
    p.setPen(QColor(195 + 20*l1, 195 + 20*l1, 195 + 20*l1));
    p.drawRect(l1, l1, width()-2*l1, height()-2*l1);
  }
}

void TextEdit::mousePressEvent(QMouseEvent *ev) {
  
  switch (ev->button()) {
  case Qt::LeftButton:   
    raise();
    drag = true;
    mousePressPos = ev->pos();
    break;
  case Qt::RightButton:
    break;
  case Qt::MidButton:
    sizeDrag = true;
    mousePressPos = ev->pos();
    break;
  default:
    break;
  }
}  

void TextEdit::mouseReleaseEvent(QMouseEvent *ev) {
  
  switch (ev->button()) {
  case Qt::LeftButton:   
    drag = false;
    break;
  case Qt::RightButton:
    break;
  case Qt::MidButton:
    sizeDrag = false;
    break;
  default:
    break;
  }
}  
   
void TextEdit::mouseMoveEvent(QMouseEvent *ev) {

  if (drag) {
    emit dragged(ev->pos());
  }
  if (sizeDrag) {   
    emit sizeDragged(ev->pos());  
  }
}  
            
QPoint TextEdit::getMousePressPos() {

  return(mousePressPos);
}

void TextEdit::removeThisTextEdit() {

  emit removeTextEdit();
}