26 #include <qfileinfo.h>
27 #include <qtabwidget.h>
28 #include <qmessagebox.h>
29 #include <qpaintdevicemetrics.h>
31 #include <qpopupmenu.h>
32 #include <qsyntaxhighlighter.h>
46 TextFont.setStyleHint(QFont::Courier);
61 QFileInfo Info (Name_);
66 QObject::tr(
"untitled"));
72 viewport()->setFocus();
74 setWordWrap(QTextEdit::NoWrap);
77 connect(
this, SIGNAL(cursorPositionChanged(
int,
int)),
88 delete syntaxHighlight;
96 QFileInfo Info (FileName);
97 QString ext = Info.extension (
false);
98 if (ext ==
"vhd" || ext ==
"vhdl")
102 else if (ext ==
"va")
104 else if (ext ==
"m" || ext ==
"oct")
120 if (!file.open (IO_WriteOnly))
123 QTextStream stream (&file);
124 stream <<
"Textfile settings file, Qucs " PACKAGE_VERSION
"\n"
126 <<
"Duration=" <<
SimTime <<
"\n"
128 <<
"Library=" <<
Library <<
"\n"
132 <<
"Icon=" <<
Icon <<
"\n"
134 <<
"DeviceType=" <<
devtype <<
"\n";
145 if (!file.open (IO_ReadOnly))
148 QTextStream stream (&file);
149 QString
Line, Setting;
152 while (!stream.atEnd ()) {
153 Line = stream.readLine ();
154 Setting = Line.section (
'=', 0, 0);
155 Line = Line.section (
'=', 1).stripWhiteSpace ();
156 if (Setting ==
"Simulation") {
158 }
else if (Setting ==
"Duration") {
160 }
else if (Setting ==
"Module") {
161 }
else if (Setting ==
"Library") {
163 }
else if (Setting ==
"Libraries") {
165 }
else if (Setting ==
"ShortDesc") {
167 }
else if (Setting ==
"LongDesc") {
169 }
else if (Setting ==
"Icon") {
171 }
else if (Setting ==
"Recreate") {
173 }
else if (Setting ==
"DeviceType") {
192 DataSet = Info.baseName (
true) +
".dat";
194 if(Info.extension(
false) ==
"m" || Info.extension(
false) ==
"oct")
202 getCursorPosition (&x, &y);
204 viewport()->setFocus ();
206 if (isUndoAvailable ())
210 if (isRedoAvailable ())
216 App->
symEdit->setMenuText (tr(
"Edit Text Symbol"));
217 App->
symEdit->setStatusTip (tr(
"Edits the symbol for this text document"));
219 tr(
"Edit Text Symbol\n\nEdits the symbol for this text document"));
223 App->
insEntity->setStatusTip (tr(
"Inserts skeleton of VHDL entity"));
225 tr(
"VHDL entity\n\nInserts the skeleton of a VHDL entity"));
229 App->
insEntity->setStatusTip (tr(
"Inserts skeleton of Verilog module"));
231 tr(
"Verilog module\n\nInserts the skeleton of a Verilog module"));
235 App->
insEntity->setStatusTip (tr(
"Inserts skeleton of Octave function"));
237 tr(
"Octave function\n\nInserts the skeleton of a Octave function"));
247 clearParagraphBackground(
tmpPosX);
250 clearParagraphBackground(z);
252 setParagraphBackgroundColor(x, QColor(240, 240, 255));
270 App->
undo->setEnabled(isUndoAvailable());
271 App->
redo->setEnabled(isRedoAvailable());
277 QPopupMenu *popup = QTextEdit::createPopupMenu( pos );
288 if (!file.open (IO_ReadOnly))
292 QTextStream stream (&file);
293 setText (stream.read ());
297 lastSaved = QDateTime::currentDateTime ();
310 if (!file.open (IO_WriteOnly))
314 QTextStream stream (&file);
332 QPaintDeviceMetrics smetrics(QPainter(
this).device());
333 QPaintDeviceMetrics pmetrics(Painter->device());
335 int marginX = margin * pmetrics.logicalDpiX() / smetrics.logicalDpiX();
336 int marginY = margin * pmetrics.logicalDpiY() / smetrics.logicalDpiY();
338 marginX, marginY, pmetrics.width() - 2*marginX,
339 pmetrics.height() - 2*marginY - Painter->fontMetrics().lineSpacing());
341 int linesPerPage = printArea.height() / Painter->fontMetrics().lineSpacing();
343 int PageCount, PageNo = 1;
344 QString
s, printText;
347 PageCount = paragraphs();
350 int line1, col1, line2, col2;
351 printText = selectedText();
352 getSelection(&line1, &col1, &line2, &col2);
354 QMessageBox::critical(
this, tr(
"Error"), tr(
"There is no selection!"));
357 PageCount = line2 - line1 + 1;
359 PageCount = (PageCount + linesPerPage - 1) / linesPerPage;
362 if(Printer->aborted())
364 Painter->drawText(printArea, 0, printText.section(
'\n', 0, linesPerPage-1));
365 printText = printText.section(
'\n', linesPerPage);
367 s = tr(
"Page %1 of %2").arg(PageNo).arg(PageCount);
368 Painter->drawText(printArea.right() - Painter->fontMetrics().width(s),
369 printArea.bottom() + Painter->fontMetrics().lineSpacing(),
s);
370 if(printText.isEmpty())
380 if(s < 1.0f) s = -1.0f/
s;
384 zoomTo((
int)(
Scale+0.5f));
392 Scale *= float(visibleHeight()) / float(contentsHeight());
395 zoomTo((
int)(
Scale+0.5f));
419 QString
s = selectedText ();
442 if (s.left (cl) == co)
447 for (
int i = s.length () - cl;
i >= 0;
i--)
448 if (s.at (
i) ==
'\n') {
449 if (s.mid (
i+1, cl) == co)
461 insert (
"entity is\n port ( : in bit);\nend;\n"
462 "architecture of is\n signal : bit;\nbegin\n\nend;\n\n");
464 insert (
"module ( );\ninput ;\noutput ;\nbegin\n\nend\n"
467 insert (
"function = ( )\n"
493 return Info.baseName (
true);