// JLH = James L. Hammons <jlhamm@acm.org>
//
// Who When What
-// --- ---------- -------------------------------------------------------------
+// --- ---------- -----------------------------------------------------------
// JLH 04/10/2002 Created this file
// JLH 05/10/2004 Translated file from ASM to CPP
// JLH 05/14/2004 Added rudimentary editing capability to tool palette tools
// FIXED:
//
-// - Fix problem with tool palette not getting focus 1st time it's called up [DONE]
+// - Fix problem with tool palette not getting focus 1st time it's called up
+// [DONE]
// - Split out windows/classes defined here into their own files [DONE]
//
// STILL TO BE DONE:
((TTEdit *)qApp)->charWnd = new CharWindow(this);
editWnd = new EditWindow(this);
setCentralWidget(editWnd);
+ editWnd->setFocus();
setWindowIcon(QIcon(":/res/ttedit.png"));
- setWindowTitle("TTEdit!");
+ setWindowTitle("TTEdit! - Untitled");
#if 0
// createActions();
#endif
// Create status bar
+ scaleIndicator = new QLabel("Scale: 100%");
+ statusBar()->addPermanentWidget(scaleIndicator);
statusBar()->showMessage(tr("Ready"));
ReadSettings();
//
// Consolidates action creation from a multi-step process to a single-step one.
//
-QAction * MainWindow::CreateAction(QString name, QString tooltip, QString statustip,
- QIcon icon, QKeySequence key, bool checkable/*= false*/)
+QAction * MainWindow::CreateAction(QString name, QString tooltip, QString
+ statustip, QIcon icon, QKeySequence key, bool checkable/*= false*/)
{
QAction * action = new QAction(icon, name, this);
action->setToolTip(tooltip);
// This is essentially the same as the previous function, but this allows more
// than one key sequence to be added as key shortcuts.
//
-QAction * MainWindow::CreateAction(QString name, QString tooltip, QString statustip,
- QIcon icon, QKeySequence key1, QKeySequence key2, bool checkable/*= false*/)
+QAction * MainWindow::CreateAction(QString name, QString tooltip, QString
+ statustip, QIcon icon, QKeySequence key1, QKeySequence key2, bool
+ checkable/*= false*/)
{
QAction * action = new QAction(icon, name, this);
action->setToolTip(tooltip);
void MainWindow::CreateActions(void)
{
newGlyphAct = CreateAction("&New Glyph", "New Glyph", "Create a new glyph", QIcon(), QKeySequence());
- openFileAct = CreateAction("&Open File", "Open File", "Open a glyph file", QIcon(), QKeySequence());
- saveFileAct = CreateAction("&Save File", "Save File", "Save a glyph file", QIcon(), QKeySequence());
+ openFileAct = CreateAction("&Open File", "Open File", "Open a glyph file", QIcon(), QKeySequence("ctrl+o"));
+ saveFileAct = CreateAction("&Save File", "Save File", "Save a glyph file", QIcon(), QKeySequence("ctrl+s"));
+ quitAct = CreateAction("&Quit", "Quit", "Exits from the TTEdit application", QIcon(), QKeySequence("ctrl+q"));
+ zoomInAct = CreateAction("Zoom In", "Zoom In", "Zoom into the canvas", QIcon(), QKeySequence("+"), QKeySequence("="));
+ zoomOutAct = CreateAction("Zoom Out", "Zoom Out", "Zoom out of canvas", QIcon(), QKeySequence("-"));
connect(newGlyphAct, SIGNAL(triggered()), this, SLOT(NewGlyph()));
connect(openFileAct, SIGNAL(triggered()), this, SLOT(OpenFile()));
connect(saveFileAct, SIGNAL(triggered()), this, SLOT(SaveFile()));
+ connect(quitAct, SIGNAL(triggered()), this, SLOT(close()));
+ connect(zoomInAct, SIGNAL(triggered()), this, SLOT(ZoomIn()));
+ connect(zoomOutAct, SIGNAL(triggered()), this, SLOT(ZoomOut()));
}
menu->addAction(newGlyphAct);
menu->addAction(openFileAct);
menu->addAction(saveFileAct);
+ menu->addSeparator();
+ menu->addAction(quitAct);
// menu->addAction(fileSaveAsAct);
// menu->addAction(fileCloseAct);
+ menu = menuBar()->addMenu(tr("&View"));
+ menu->addAction(zoomInAct);
+ menu->addAction(zoomOutAct);
}
editWnd->pts.Clear();
((TTEdit *)qApp)->charWnd->MakePathFromPoints(&(editWnd->pts));
((TTEdit *)qApp)->charWnd->update();
+// editWnd->polyFirstPoint = true;
editWnd->update();
+ setWindowTitle("TTEdit! - Untitled");
+ editWnd->setFocus();
}
{
QString filename = QFileDialog::getOpenFileName(this, tr("Open Glyph File"),
"./", tr("Glyph files (*.glyph)"));
- FILE * file = fopen(filename.toAscii().data(), "r");
+ FILE * file = fopen(filename.toUtf8().data(), "r");
//need to pop an error box here...
if (file == 0)
((TTEdit *)qApp)->charWnd->MakePathFromPoints(&(editWnd->pts));
((TTEdit *)qApp)->charWnd->update();
editWnd->update();
+ setWindowTitle(QString("TTEdit! - %1").arg(filename));
+ editWnd->setFocus();
}
{
QString filename = QFileDialog::getSaveFileName(this, tr("Save Glyph File"),
"./", tr("Glyph files (*.glyph)"));
- FILE * file = fopen(filename.toAscii().data(), "w");
+ FILE * file = fopen(filename.toUtf8().data(), "w");
//need to pop an error box here...
if (file == 0)
editWnd->pts.SaveGlyphToFile(file);
fclose(file);
+ setWindowTitle(QString("TTEdit! - %1").arg(filename));
+ editWnd->setFocus();
+}
+
+
+void MainWindow::ZoomIn(void)
+{
+ if (editWnd->scale == 4.0)
+ return;
+
+ editWnd->scale *= 2.0;
+ scaleIndicator->setText(QString("Scale: %1%").arg(editWnd->scale * 100.0));
+ editWnd->update();
+}
+
+
+void MainWindow::ZoomOut(void)
+{
+ if (editWnd->scale == 0.25)
+ return;
+
+ editWnd->scale *= 0.5;
+ scaleIndicator->setText(QString("Scale: %1%").arg(editWnd->scale * 100.0));
+ editWnd->update();
}
#if 0
-#include "ttedit.h"
-#include "charwindow.h"
-#include "toolwindow.h"
-#include "editwindow.h"
-#include "tte_res.h" // Resource IDs
-#ifdef DEBUG
-#include "debug.h"
-#endif
-
-// Pixmap resouces
-
-#include "res/cur1.xpm"
-#include "res/cur2.xpm"
-#include "res/cur3.xpm"
-#include "res/cur4.xpm"
-#include "res/cur5.xpm"
-#include "res/cur6.xpm"
-#include "res/cur7.xpm"
-#include "res/cur8.xpm"
-#include "res/ttedit.xpm" // *nix only, but small enough to not matter
-#include "res/tool1.xpm"
-#include "res/tool2.xpm"
-#include "res/tool3.xpm"
IMPLEMENT_APP(TTEditApp) // Run the main application loop