-//\r
-// TTEDIT.CPP - The TrueType Editor\r
-// by James L. Hammons\r
-// (C) 2004 Underground Software\r
-//\r
-// JLH = James L. Hammons <jlhamm@acm.org>\r
-//\r
-// Who When What\r
-// --- ---------- -------------------------------------------------------------\r
-// JLH 04/10/2002 Created this file\r
-// JLH 05/10/2004 Translated file from ASM to CPP\r
-// JLH 05/14/2004 Added rudimentary editing capability to tool palette tools\r
-// JLH 11/18/2006 Initial port to Linux\r
-// JLH 08/27/2008 Fixed tool palette focus problems\r
-// JLH 08/28/2008 Split out classes defined here into separate files\r
-//\r
-\r
-// FIXED:\r
-//\r
-// - Fix problem with tool palette not getting focus 1st time it's called up [DONE]\r
-// - Split out windows/classes defined here into their own files [DONE]\r
-//\r
-// STILL TO BE DONE:\r
-//\r
-// - Fix bug in Glyphpoints when dragging on an empty canvas or loading a font\r
-// - Fix scrolling, zooming, settings (ini)\r
-// - Finish conversion to wxWidgets for cross-platform portability\r
-// - Fix problem with owned window causing main window refresh problems\r
-// (ironically enough, it doesn't seem to be a problem anymore...)\r
-//\r
-\r
-// Uncomment this for debugging...\r
-#define DEBUG\r
-#define DEBUGFOO // Various tool debugging...\r
-#define DEBUGTP // Toolpalette debugging...\r
-\r
-#include "ttedit.h"\r
-#include "charwindow.h"\r
-#include "toolwindow.h"\r
-#include "editwindow.h"\r
-#include "tte_res.h" // Resource IDs\r
-#ifdef DEBUG\r
-#include "debug.h"\r
-#endif\r
-\r
-// Pixmap resouces\r
-\r
-#include "res/cur1.xpm"\r
-#include "res/cur2.xpm"\r
-#include "res/cur3.xpm"\r
-#include "res/cur4.xpm"\r
-#include "res/cur5.xpm"\r
-#include "res/cur6.xpm"\r
-#include "res/cur7.xpm"\r
-#include "res/cur8.xpm"\r
-#include "res/ttedit.xpm" // *nix only, but small enough to not matter\r
-#include "res/tool1.xpm"\r
-#include "res/tool2.xpm"\r
-#include "res/tool3.xpm"\r
-\r
-\r
-IMPLEMENT_APP(TTEditApp) // Run the main application loop\r
-\r
-bool TTEditApp::OnInit()\r
-{\r
- wxLog * logTarget = new wxLogStderr();//fopen("!ttedit_log.txt", "wb"));\r
- wxLog::SetActiveTarget(logTarget);\r
-#ifdef DEBUG\r
- OpenDebugLog();\r
-#endif\r
-\r
- // Initialize all the top-level window members to NULL.\r
- mainFrame = NULL;\r
- charWin = NULL;\r
- toolPalette = NULL;\r
-\r
-//Shouldn't we check to see if it was successful? This just assumes\r
- CreateResources();\r
-\r
- mainFrame = new TTEditFrame(NULL, _("TTEdit"), wxPoint(155, 165), wxSize(300, 300),\r
- wxDEFAULT_FRAME_STYLE | wxFULL_REPAINT_ON_RESIZE);\r
-// wxMINIMIZE_BOX | wxRESIZE_BOX | wxMAXIMIZE_BOX | | wxSYSTEM_MENU | wxCAPTION);\r
-\r
-// charWin = new CharWindow(NULL);//, _T("Own3d W1nd0w"), wxDefaultPosition, wxDefaultSize);\r
- charWin = new CharWindow(mainFrame, _("Own3d W1nd0w"), wxDefaultPosition, wxDefaultSize,\r
- wxCAPTION | wxRESIZE_BORDER);\r
-\r
- toolPalette = new ToolWindow(mainFrame, _(""), wxDefaultPosition, wxDefaultSize,\r
- wxBORDER_NONE | wxFRAME_NO_TASKBAR | wxFRAME_FLOAT_ON_PARENT);\r
-\r
- return true;\r
-}\r
-\r
-int TTEditApp::OnExit()\r
-{\r
-#ifdef DEBUG\r
- CloseDebugLog();\r
-#endif\r
-\r
- return 0;\r
-}\r
-\r
-void TTEditApp::CreateResources(void)\r
-{\r
- // This is a sucky way to create cursors, but at least it's cross-platform...\r
- // NOTE: Need to fix hotspots on a few... !!! FIX !!!\r
-\r
- wxBitmap cursorBM1(cur1_xpm);\r
- wxImage cursorImage1 = cursorBM1.ConvertToImage();\r
- cursorImage1.SetMaskFromImage(cursorImage1, 0xFF, 0xFF, 0xFF);\r
- cur[0] = new wxCursor(cursorImage1);\r
-\r
- wxBitmap cursorBM2(cur2_xpm);\r
- wxImage cursorImage2 = cursorBM2.ConvertToImage();\r
- cursorImage2.SetMaskFromImage(cursorImage2, 0xFF, 0xFF, 0xFF);\r
- cur[1] = new wxCursor(cursorImage2);\r
-\r
- wxBitmap cursorBM3(cur3_xpm);\r
- wxImage cursorImage3 = cursorBM3.ConvertToImage();\r
- cursorImage3.SetMaskFromImage(cursorImage3, 0xFF, 0xFF, 0xFF);\r
- cur[2] = new wxCursor(cursorImage3);\r
-\r
- wxBitmap cursorBM4(cur4_xpm);\r
- wxImage cursorImage4 = cursorBM4.ConvertToImage();\r
- cursorImage4.SetMaskFromImage(cursorImage4, 0xFF, 0xFF, 0xFF);\r
- cur[3] = new wxCursor(cursorImage4);\r
-\r
- wxBitmap cursorBM5(cur5_xpm);\r
- wxImage cursorImage5 = cursorBM5.ConvertToImage();\r
- cursorImage5.SetMaskFromImage(cursorImage5, 0xFF, 0xFF, 0xFF);\r
- cur[4] = new wxCursor(cursorImage5);\r
-\r
- wxBitmap cursorBM6(cur6_xpm);\r
- wxImage cursorImage6 = cursorBM6.ConvertToImage();\r
- cursorImage6.SetMaskFromImage(cursorImage6, 0xFF, 0xFF, 0xFF);\r
- cur[5] = new wxCursor(cursorImage6);\r
-\r
- wxBitmap cursorBM7(cur7_xpm);\r
- wxImage cursorImage7 = cursorBM7.ConvertToImage();\r
- cursorImage7.SetMaskFromImage(cursorImage7, 0xFF, 0xFF, 0xFF);\r
- cur[6] = new wxCursor(cursorImage7);\r
-\r
- wxBitmap cursorBM8(cur8_xpm);\r
- wxImage cursorImage8 = cursorBM8.ConvertToImage();\r
- cursorImage8.SetMaskFromImage(cursorImage8, 0xFF, 0xFF, 0xFF);\r
- cur[7] = new wxCursor(cursorImage8);\r
-}\r
-\r
-\r
-BEGIN_EVENT_TABLE(TTEditFrame, wxFrame)\r
- EVT_MENU(IDM_OPEN, TTEditFrame::OnOpen)\r
- EVT_MENU(IDM_EXIT, TTEditFrame::OnExit)\r
- EVT_MENU(IDM_ABOUT, TTEditFrame::OnAbout)\r
- EVT_CLOSE(TTEditFrame::OnCloseWindow)\r
-END_EVENT_TABLE()\r
-\r
-TTEditFrame::TTEditFrame(wxFrame * parent, const wxString &title, const wxPoint &pos,\r
- const wxSize &size, long style): wxFrame(parent, -1, title, pos, size, style), app(wxGetApp()), mainWindow(NULL)\r
-{\r
- // Initialize child subwindow members (and hopefully avoid subtle bugs)\r
-// mainWindow = NULL;\r
-\r
- SetIcon(wxICON(ttedit));\r
-// CreateStatusBar(2); // Create 2 panes\r
- int widths[2] = { -1, 120 };\r
- wxStatusBar * sb = CreateStatusBar(2, 0); // Create 2 panes\r
- sb->SetStatusWidths(2, widths);\r
- wxToolBar * tb = CreateToolBar();\r
-\r
- if (tb != NULL)\r
- {\r
- // Create buttons\r
-\r
- wxBitmap tool1(tool1_xpm);\r
- wxBitmap tool2(tool2_xpm);\r
- wxBitmap tool3(tool3_xpm);\r
-\r
- tb->AddTool(ID_TBLEFT, _("Prev char"), tool1, _("Go to prev char"), wxITEM_NORMAL);\r
- tb->AddTool(ID_TBRIGHT, _("Next char"), tool2, _("Go to next char"), wxITEM_NORMAL);\r
- tb->AddTool(ID_TBCHARWIN, _("Char Wnd"), tool3, _("Toggle char window"), wxITEM_NORMAL);\r
- tb->Realize();\r
- }\r
-\r
- // Create a menu bar for the frame\r
- menuBar = new wxMenuBar;\r
- wxMenu * menu1 = new wxMenu;\r
- menu1->Append(IDM_NEW, _("&New\tCtrl+N"), _("Create a new font."));\r
- menu1->Append(IDM_OPEN, _("&Open...\tCtrl+O"), _("Opens an existing font."));\r
- menu1->Append(IDM_SAVE, _("&Save\tCtrl+S"), _("Save the current font."));\r
- menu1->Append(IDM_SAVEAS, _("Save &As..."), _("Save the current font under a different name."));\r
- menu1->AppendSeparator();\r
- menu1->Append(IDM_EXIT, _("E&xit\tAlt+X"), _("Quits the TTEdit program."));\r
- menuBar->Append(menu1, _("&File"));\r
- wxMenu * menu2 = new wxMenu;\r
- menu2->Append(IDM_HELPTOPICS, _("&Help Topics"), _("Displays the Help contents and index."));\r
- menu2->AppendSeparator();\r
- menu2->Append(IDM_ABOUT, _("&About TTEdit"), _("Displays information about TTEdit."));\r
- menuBar->Append(menu2, _("&Help"));\r
- SetMenuBar(menuBar);\r
-\r
- // Create child subwindows\r
- mainWindow = new TTEditWindow(this);\r
-\r
- Centre(wxBOTH); // Centre frame on the screen\r
- Show(true); // Show the frame\r
-}\r
-\r
-TTEditFrame::~TTEditFrame()\r
-{\r
-}\r
-\r
-void TTEditFrame::OnOpen(wxCommandEvent &e)\r
-{\r
- wxFileDialog fd(this, _("Choose a font to load"), _(""), _(""), _("TTF files (*.ttf)|*.ttf|All files (*.*)|*.*"), wxOPEN);\r
-\r
- if (fd.ShowModal() != wxID_OK)\r
- return;\r
-\r
-// Hmm. The font object is causing a massive crash... (gdb says it's in "Load")\r
- if (app.font.Load((char *)fd.GetPath().c_str()) != true)\r
- {\r
- wxMessageDialog dlg(NULL, _("Load font failed!"), _("Houston, we have a problem..."), wxOK | wxICON_ERROR);\r
- dlg.ShowModal();\r
- }\r
-\r
-//Huzzah! It works! Now just need scaling, scrolling, etc...\r
-// pts = app.font.GetGlyphPoints(45);\r
-}\r
-\r
-void TTEditFrame::OnAbout(wxCommandEvent &e)\r
-{\r
- wxMessageDialog dlg(NULL, _("TrueType Edit v1.0.1\n\nA handy tool for editing TrueType fonts!\nby James \"Shamus\" Hammons\n(C) 2006 Underground Software"), _("About TrueType Edit"), wxOK | wxICON_INFORMATION);\r
- dlg.ShowModal();\r
-}\r
-\r
-void TTEditFrame::OnExit(wxCommandEvent &e)\r
-{\r
- app.toolPalette->Destroy();\r
- this->Destroy();\r
-}\r
-\r
-void TTEditFrame::OnCloseWindow(wxCloseEvent &e)\r
-{\r
- app.toolPalette->Destroy();\r
- this->Destroy();\r
-}\r
+//
+// TTEDIT.CPP - The TrueType Editor
+// by James L. Hammons
+// (C) 2004 Underground Software
+//
+// 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
+// JLH 11/18/2006 Initial port to Linux
+// JLH 08/27/2008 Fixed tool palette focus problems
+// JLH 08/28/2008 Split out classes defined here into separate files
+// JLH 03/05/2009 Initial conversion from wxWidgets to Qt
+//
+
+#include "ttedit.h"
+#include <QApplication>
+#include "mainwindow.h"
+
+// Main app constructor--we stick globally accessible stuff here...
+
+TTEdit::TTEdit(int & argc, char * argv[]): QApplication(argc, argv), charWnd(NULL)
+{
+ mainWindow = new MainWindow;
+//printf("mainWindow.show();\n");
+ mainWindow->show();
+}
+
+
+// Here's the main application loop--short and simple...
+int main(int argc, char * argv[])
+{
+ Q_INIT_RESOURCE(ttedit); // This must the same name as the exe filename
+
+// QApplication app(argc, argv);
+//printf("TTEdit app(argc, argv);\n");
+ TTEdit app(argc, argv);
+//printf("TTEMainWindow mainWindow;\n");
+//OK, it gets to here at least...
+//printf("return app.exec();\n");
+ return app.exec();
+}