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
|
// -*-C++-*-
// This file is part of the gmod package
// Copyright (C) 1997 by Andrew J. Robinson
#include "CommentShell.h"
CommentShell::CommentShell(QWidget *w) : QWidget(w, "commentShell")
{
setMinimumSize(60, 40);
setCaption("Xgmod Comment");
commentEdit = new QMultiLineEdit(this, "commentLabel");
commentEdit->setGeometry(5, 5, 200, 160);
commentEdit->setReadOnly(TRUE);
commentEdit->setFrameStyle(QFrame::Panel | QFrame::Sunken);
closeButton = new QPushButton(this, "closeButton");
closeButton->setText("Close");
closeButton->setGeometry(75, 200, 60, 25);
closeButton->connect(closeButton, SIGNAL(clicked()), this, SLOT(closeCommentShell()));
resize(210, 200);
}
void
CommentShell::setComment(char *text, int lineLen)
{
char *beginLine, *endLine;
char oldChar;
beginLine = text;
commentEdit->setAutoUpdate(FALSE);
commentEdit->clear();
if (!*beginLine || !lineLen)
commentEdit->setText(text);
else
while (*beginLine)
{
endLine = beginLine + 1;
while (*endLine && (*endLine != '\n') &&
(endLine < (beginLine + lineLen)))
endLine++;
oldChar = *endLine;
*endLine = 0;
commentEdit->insertLine(beginLine);
*endLine = oldChar;
if (oldChar == '\n')
endLine++;
beginLine = endLine;
}
commentEdit->repaint();
commentEdit->setAutoUpdate(TRUE);
}
void
CommentShell::showCommentShell()
{
show();
}
void
CommentShell::closeCommentShell()
{
close();
}
void
CommentShell::resizeEvent(QResizeEvent *)
{
closeButton->move((width() - 60) / 2, height() - 30);
commentEdit->resize(width() - 10, height() - 40);
}
#ifndef DEPEND
#include "CommentShell.moc"
#endif
|