Debian Codegraph @

src/quteconsole.cpp

raw symbols SCIP
1 /*
2 Copyright (C) 2008, 2009 Andres Cabrera
3 [email protected]
4
5 This file is part of CsoundQt.
6
7 CsoundQt is free software; you can redistribute it
8 and/or modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
11
12 CsoundQt is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with Csound; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20 02111-1307 USA
21 */
22
23 #include "quteconsole.h"
24
25 QuteConsole::QuteConsole(QWidget *parent) : QuteWidget(parent)
26 {
27 m_widget = new ConsoleWidget(this);
28 m_widget->setAutoFillBackground(true);
29 m_widget->setMouseTracking(true); // Necessary to pass mouse tracking to widget panel for _MouseX channels
30 canFocus(false);
31 setProperty("QCS_font", "Courier");
32 setProperty("QCS_fontsize", 8.0);
33 setProperty("QCS_bgcolor", QColor(Qt::white));
34 setProperty("QCS_bgcolormode", false);
35 setProperty("QCS_color", QColor(Qt::black));
36 // connect(static_cast<ConsoleWidget *>(m_widget), SIGNAL(popUpMenu(QPoint)), this, SLOT(popUpMenu(QPoint)));
37 }
38
39 QuteConsole::~QuteConsole()
40 {
41 }
42
43 QString QuteConsole::getWidgetLine()
44 {
45 #ifdef USE_WIDGET_MUTEX
46 widgetLock.lockForRead();
47 #endif
48 QString line = "ioListing {" + QString::number(x()) + ", " + QString::number(y()) + "} ";
49 line += "{"+ QString::number(width()) +", "+ QString::number(height()) +"}";
50 // qDebug("QuteText::getWidgetLine() %s", line.toStdString().c_str());
51 #ifdef USE_WIDGET_MUTEX
52 widgetLock.unlock();
53 #endif
54 return line;
55 }
56
57 QString QuteConsole::getWidgetXmlText()
58 {
59 // Consoles are not implemented in blue
60 xmlText = "";
61 QXmlStreamWriter s(&xmlText);
62 createXmlWriter(s);
63 #ifdef USE_WIDGET_MUTEX
64 widgetLock.lockForRead();
65 #endif
66 s.writeTextElement("font", property("QCS_font").toString());
67 s.writeTextElement("fontsize", QString::number(property("QCS_fontsize").toInt()));
68
69 QColor color = property("QCS_color").value<QColor>();
70 s.writeStartElement("color");
71 s.writeTextElement("r", QString::number(color.red()));
72 s.writeTextElement("g", QString::number(color.green()));
73 s.writeTextElement("b", QString::number(color.blue()));
74 s.writeEndElement();
75 color = property("QCS_bgcolor").value<QColor>();
76 s.writeStartElement("bgcolor");
77 s.writeAttribute("mode", property("QCS_bgcolormode").toBool()? "background":"nobackground");
78 s.writeTextElement("r", QString::number(color.red()));
79 s.writeTextElement("g", QString::number(color.green()));
80 s.writeTextElement("b", QString::number(color.blue()));
81 s.writeEndElement();
82
83 s.writeEndElement();
84 #ifdef USE_WIDGET_MUTEX
85 widgetLock.unlock();
86 #endif
87 return xmlText;
88 }
89
90 QString QuteConsole::getWidgetType()
91 {
92 return QString("BSBConsole");
93 }
94
95 void QuteConsole::appendMessage(QString message)
96 {
97 static_cast<ConsoleWidget *>(m_widget)->appendMessage(message);
98 }
99
100 void QuteConsole::scrollToEnd()
101 {
102 //qDebug() << "QuteConsole::refresh()";
103 static_cast<ConsoleWidget *>(m_widget)->scrollToEnd();
104 }
105
106 void QuteConsole::setWidgetGeometry(int x,int y,int width,int height)
107 {
108 QuteWidget::setWidgetGeometry(x,y,width, height);
109 static_cast<ConsoleWidget *>(m_widget)->setWidgetGeometry(x,y,width, height);
110 }
111
112 QString QuteConsole::getCabbageLine()
113 {
114 #ifdef USE_WIDGET_MUTEX
115 widgetLock.lockForWrite();
116 #endif
117 QString line = "csoundoutput ";
118 line += QString("bounds(%1,%2,%3,%4), ").arg(x()).arg(y()).arg(width()).arg(height());
119 line += "text(\"Csound output\")";
120 #ifdef USE_WIDGET_MUTEX
121 widgetLock.unlock();
122 #endif
123 return line;
124 }
125