X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fttedit.cpp;h=a657cad17a48bb10d259299b5ad786b1b68aadd3;hb=38fb522026b16fb83f49e2b2f32884ffaca177dd;hp=3c31541a8934d42c68804eac35c8e504ddb97afd;hpb=20195737e60552ca35c3212db45ece6c4db6bb1d;p=ttedit diff --git a/src/ttedit.cpp b/src/ttedit.cpp index 3c31541..a657cad 100755 --- a/src/ttedit.cpp +++ b/src/ttedit.cpp @@ -1,246 +1,66 @@ -// -// TTEDIT.CPP - The TrueType Editor -// by James L. Hammons -// (C) 2004 Underground Software -// -// JLH = James L. Hammons -// -// 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 -// - -// FIXED: -// -// - 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: -// -// - Fix bug in Glyphpoints when dragging on an empty canvas or loading a font -// - Fix scrolling, zooming, settings (ini) -// - Finish conversion to wxWidgets for cross-platform portability -// - Fix problem with owned window causing main window refresh problems -// (ironically enough, it doesn't seem to be a problem anymore...) -// - -// Uncomment this for debugging... -#define DEBUG -#define DEBUGFOO // Various tool debugging... -#define DEBUGTP // Toolpalette debugging... - -#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 - -bool TTEditApp::OnInit() -{ - wxLog * logTarget = new wxLogStderr();//fopen("!ttedit_log.txt", "wb")); - wxLog::SetActiveTarget(logTarget); -#ifdef DEBUG - OpenDebugLog(); -#endif - - // Initialize all the top-level window members to NULL. - mainFrame = NULL; - charWin = NULL; - toolPalette = NULL; - -//Shouldn't we check to see if it was successful? This just assumes - CreateResources(); - - mainFrame = new TTEditFrame(NULL, _("TTEdit"), wxPoint(155, 165), wxSize(300, 300), - wxDEFAULT_FRAME_STYLE | wxFULL_REPAINT_ON_RESIZE); -// wxMINIMIZE_BOX | wxRESIZE_BOX | wxMAXIMIZE_BOX | | wxSYSTEM_MENU | wxCAPTION); - -// charWin = new CharWindow(NULL);//, _T("Own3d W1nd0w"), wxDefaultPosition, wxDefaultSize); - charWin = new CharWindow(mainFrame, _("Own3d W1nd0w"), wxDefaultPosition, wxDefaultSize, - wxCAPTION | wxRESIZE_BORDER); - - toolPalette = new ToolWindow(mainFrame, _(""), wxDefaultPosition, wxDefaultSize, - wxBORDER_NONE | wxFRAME_NO_TASKBAR | wxFRAME_FLOAT_ON_PARENT); - - return true; -} - -int TTEditApp::OnExit() -{ -#ifdef DEBUG - CloseDebugLog(); -#endif - - return 0; -} - -void TTEditApp::CreateResources(void) -{ - // This is a sucky way to create cursors, but at least it's cross-platform... - // NOTE: Need to fix hotspots on a few... !!! FIX !!! - - wxBitmap cursorBM1(cur1_xpm); - wxImage cursorImage1 = cursorBM1.ConvertToImage(); - cursorImage1.SetMaskFromImage(cursorImage1, 0xFF, 0xFF, 0xFF); - cur[0] = new wxCursor(cursorImage1); - - wxBitmap cursorBM2(cur2_xpm); - wxImage cursorImage2 = cursorBM2.ConvertToImage(); - cursorImage2.SetMaskFromImage(cursorImage2, 0xFF, 0xFF, 0xFF); - cur[1] = new wxCursor(cursorImage2); - - wxBitmap cursorBM3(cur3_xpm); - wxImage cursorImage3 = cursorBM3.ConvertToImage(); - cursorImage3.SetMaskFromImage(cursorImage3, 0xFF, 0xFF, 0xFF); - cur[2] = new wxCursor(cursorImage3); - - wxBitmap cursorBM4(cur4_xpm); - wxImage cursorImage4 = cursorBM4.ConvertToImage(); - cursorImage4.SetMaskFromImage(cursorImage4, 0xFF, 0xFF, 0xFF); - cur[3] = new wxCursor(cursorImage4); - - wxBitmap cursorBM5(cur5_xpm); - wxImage cursorImage5 = cursorBM5.ConvertToImage(); - cursorImage5.SetMaskFromImage(cursorImage5, 0xFF, 0xFF, 0xFF); - cur[4] = new wxCursor(cursorImage5); - - wxBitmap cursorBM6(cur6_xpm); - wxImage cursorImage6 = cursorBM6.ConvertToImage(); - cursorImage6.SetMaskFromImage(cursorImage6, 0xFF, 0xFF, 0xFF); - cur[5] = new wxCursor(cursorImage6); - - wxBitmap cursorBM7(cur7_xpm); - wxImage cursorImage7 = cursorBM7.ConvertToImage(); - cursorImage7.SetMaskFromImage(cursorImage7, 0xFF, 0xFF, 0xFF); - cur[6] = new wxCursor(cursorImage7); - - wxBitmap cursorBM8(cur8_xpm); - wxImage cursorImage8 = cursorBM8.ConvertToImage(); - cursorImage8.SetMaskFromImage(cursorImage8, 0xFF, 0xFF, 0xFF); - cur[7] = new wxCursor(cursorImage8); -} - - -BEGIN_EVENT_TABLE(TTEditFrame, wxFrame) - EVT_MENU(IDM_OPEN, TTEditFrame::OnOpen) - EVT_MENU(IDM_EXIT, TTEditFrame::OnExit) - EVT_MENU(IDM_ABOUT, TTEditFrame::OnAbout) - EVT_CLOSE(TTEditFrame::OnCloseWindow) -END_EVENT_TABLE() - -TTEditFrame::TTEditFrame(wxFrame * parent, const wxString &title, const wxPoint &pos, - const wxSize &size, long style): wxFrame(parent, -1, title, pos, size, style), app(wxGetApp()), mainWindow(NULL) -{ - // Initialize child subwindow members (and hopefully avoid subtle bugs) -// mainWindow = NULL; - - SetIcon(wxICON(ttedit)); -// CreateStatusBar(2); // Create 2 panes - int widths[2] = { -1, 120 }; - wxStatusBar * sb = CreateStatusBar(2, 0); // Create 2 panes - sb->SetStatusWidths(2, widths); - wxToolBar * tb = CreateToolBar(); - - if (tb != NULL) - { - // Create buttons - - wxBitmap tool1(tool1_xpm); - wxBitmap tool2(tool2_xpm); - wxBitmap tool3(tool3_xpm); - - tb->AddTool(ID_TBLEFT, _("Prev char"), tool1, _("Go to prev char"), wxITEM_NORMAL); - tb->AddTool(ID_TBRIGHT, _("Next char"), tool2, _("Go to next char"), wxITEM_NORMAL); - tb->AddTool(ID_TBCHARWIN, _("Char Wnd"), tool3, _("Toggle char window"), wxITEM_NORMAL); - tb->Realize(); - } - - // Create a menu bar for the frame - menuBar = new wxMenuBar; - wxMenu * menu1 = new wxMenu; - menu1->Append(IDM_NEW, _("&New\tCtrl+N"), _("Create a new font.")); - menu1->Append(IDM_OPEN, _("&Open...\tCtrl+O"), _("Opens an existing font.")); - menu1->Append(IDM_SAVE, _("&Save\tCtrl+S"), _("Save the current font.")); - menu1->Append(IDM_SAVEAS, _("Save &As..."), _("Save the current font under a different name.")); - menu1->AppendSeparator(); - menu1->Append(IDM_EXIT, _("E&xit\tAlt+X"), _("Quits the TTEdit program.")); - menuBar->Append(menu1, _("&File")); - wxMenu * menu2 = new wxMenu; - menu2->Append(IDM_HELPTOPICS, _("&Help Topics"), _("Displays the Help contents and index.")); - menu2->AppendSeparator(); - menu2->Append(IDM_ABOUT, _("&About TTEdit"), _("Displays information about TTEdit.")); - menuBar->Append(menu2, _("&Help")); - SetMenuBar(menuBar); - - // Create child subwindows - mainWindow = new TTEditWindow(this); - - Centre(wxBOTH); // Centre frame on the screen - Show(true); // Show the frame -} - -TTEditFrame::~TTEditFrame() -{ -} - -void TTEditFrame::OnOpen(wxCommandEvent &e) -{ - wxFileDialog fd(this, _("Choose a font to load"), _(""), _(""), _("TTF files (*.ttf)|*.ttf|All files (*.*)|*.*"), wxOPEN); - - if (fd.ShowModal() != wxID_OK) - return; - -// Hmm. The font object is causing a massive crash... (gdb says it's in "Load") - if (app.font.Load((char *)fd.GetPath().c_str()) != true) - { - wxMessageDialog dlg(NULL, _("Load font failed!"), _("Houston, we have a problem..."), wxOK | wxICON_ERROR); - dlg.ShowModal(); - } - -//Huzzah! It works! Now just need scaling, scrolling, etc... -// pts = app.font.GetGlyphPoints(45); -} - -void TTEditFrame::OnAbout(wxCommandEvent &e) -{ - 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); - dlg.ShowModal(); -} - -void TTEditFrame::OnExit(wxCommandEvent &e) -{ - app.toolPalette->Destroy(); - this->Destroy(); -} - -void TTEditFrame::OnCloseWindow(wxCloseEvent &e) -{ - app.toolPalette->Destroy(); - this->Destroy(); -} +// +// TTEDIT.CPP - The TrueType Editor +// by James L. Hammons +// (C) 2004 Underground Software +// +// JLH = James L. Hammons +// +// 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 +// + +// FIXED: +// +// - 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: +// +// - Fix bug in Glyphpoints when dragging on an empty canvas or loading a font +// - Fix scrolling, zooming, settings (ini) +// - Finish conversion to wxWidgets for cross-platform portability +// - Fix problem with owned window causing main window refresh problems +// (ironically enough, it doesn't seem to be a problem anymore...) +// + +// Uncomment this for debugging... +//#define DEBUG +//#define DEBUGFOO // Various tool debugging... +//#define DEBUGTP // Toolpalette debugging... + +#include "ttedit.h" +#include +#include "ttemainwindow.h" +//#include "charwindow.h" + +// Main app constructor--we stick globally accessible stuff here... + +TTEdit::TTEdit(int argc, char * argv[]): QApplication(argc, argv), charWnd(NULL) +{ + mainWindow = new TTEMainWindow; +//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(); +} +