MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); network_ = new Network(this); connect(network_,SIGNAL(listUpdated()), this,SLOT(onRedraw())); this->setFixedSize(this->size()); //QTextCodec::setCodecForLocale(QTextCodec::codecForName("CP-866")); QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); ui->listWidget->setContextMenuPolicy(Qt::CustomContextMenu); QAction *act; modeMenu_ = new QMenu(this); act = new QAction(tr("Telnet mode"),this); connect(act,SIGNAL(triggered()),this,SLOT(runTelnet())); modeMenu_->addAction(act); act = new QAction(tr("File mode"),this); connect(act,SIGNAL(triggered()),this,SLOT(runFile())); modeMenu_->addAction(act); act = new QAction(tr("Graphics mode"),this); connect(act,SIGNAL(triggered()),this,SLOT(runGraph())); modeMenu_->addAction(act); modeMenu_->addSeparator(); act = new QAction(tr("Options"),this); connect(act,SIGNAL(triggered()),this,SLOT(runOptions())); modeMenu_->addAction(act); }
void Drawer::redraw() { if(disconnected()) throw RobotException("Drawer::startDrawing called without connected window!"); HDC canvas = GetDC(drawTo); if(canvas == NULL) throw RobotException("Tried to call Drawer::startDrawing but couldn't get canvas!"); // Select and draw into our buffer HDC bufCanvas = CreateCompatibleDC(canvas); HBITMAP oldBuf = (HBITMAP)SelectObject(bufCanvas, buffer); onRedraw(bufCanvas, bufSize); /* THIS IS CODE FOR SOME SEEMINGLY CLEVER ANTIALIASING - BUT IT DEPENDS A LOT ON BEING ABLE TO REPRODUCE AN IDENTICAL IMAGE SCALED UP, SO I MIGHT NOT USE IT // select and draw into the aliasing buffer HDC aliasCanvas = CreateCompatibleDC(canvas); HBITMAP oldAlBuf = (HBITMAP)SelectObject(aliasCanvas, aliasBuffer); onRedraw(aliasCanvas, alBufSize); // StretchBlit the aliasing buffer into the standard buffer SetStretchBltMode(bufCanvas, HALFTONE); StretchBlt(bufCanvas, 0, 0, bufSize.right, bufSize.bottom, aliasCanvas, 0, 0, alBufSize.right, alBufSize.bottom, SRCINVERT); */ // Blit out the buffer onto the screen BitBlt(canvas, 0, 0, bufSize.right, bufSize.bottom, bufCanvas, 0, 0, SRCCOPY); // unselect the buffer from bufCanvas SelectObject(bufCanvas, oldBuf); DeleteObject(bufCanvas); /* MORE ANTIALIASING CODE SelectObject(aliasCanvas, oldAlBuf); DeleteObject(aliasCanvas); */ ReleaseDC(drawTo, canvas); }