]> Shamusworld >> Repos - ttedit/commitdiff
Converted project from wxWidgets to Qt. This will be the LAST time this
authorShamus Hammons <jlhamm@acm.org>
Fri, 13 Mar 2009 21:19:06 +0000 (21:19 +0000)
committerShamus Hammons <jlhamm@acm.org>
Fri, 13 Mar 2009 21:19:06 +0000 (21:19 +0000)
happens. Unless something better comes along. ;-)

28 files changed:
Makefile
res/act-back.png [new file with mode: 0644]
res/act-charwin.png [new file with mode: 0644]
res/act-forward.png [new file with mode: 0644]
res/cursor1.png [new file with mode: 0644]
res/cursor2.png [new file with mode: 0644]
res/cursor3.png [new file with mode: 0644]
res/cursor4.png [new file with mode: 0644]
res/cursor5.png [new file with mode: 0644]
res/cursor6.png [new file with mode: 0644]
res/cursor7.png [new file with mode: 0644]
res/cursor8.png [new file with mode: 0644]
res/toolpal1.png [new file with mode: 0644]
res/ttedit.png [new file with mode: 0644]
src/charnames.cpp
src/editwindow.cpp
src/editwindow.h
src/graphicprimitives.cpp
src/graphicprimitives.h
src/registry.cpp [deleted file]
src/registry.h [deleted file]
src/toolwindow.cpp
src/toolwindow.h
src/tte_res.h [deleted file]
src/ttedit.cpp
src/ttedit.h
ttedit.pro [new file with mode: 0644]
ttedit.qrc [new file with mode: 0644]

index 2f25505ebb9a45fb6405fc3837e198d33448abb0..8dc2ae16b6cc65bcfb6f4bf6bd5f1335f0b66e88 100755 (executable)
--- a/Makefile
+++ b/Makefile
-#
-# Makefile for TrueType Edit
-#
-# Author:     James Hammons
-# Copyright:  (c) 2006 Underground Software
-#
-
-ifeq "$(OSTYPE)" "msys"                                                        # Win32
-
-SYSTYPE    = __GCCWIN32__
-EXESUFFIX  = .exe
-ICON       = obj/icon.o
-MSG        = Win32 on MinGW
-
-else
-#ifeq "$(OSTYPE)" "darwin"
-ifeq "darwin" "$(findstring darwin,$(OSTYPE))" # Should catch both 'darwin' and 'darwin7.0'
-
-SYSTYPE    = __GCCUNIX__ -D_OSX_
-EXESUFFIX  =
-ICON       =
-MSG        = Mac OS X
-
-else                                                                                   # *nix
-
-SYSTYPE    = __GCCUNIX__
-EXESUFFIX  =
-ICON       =
-MSG        = generic Unix/Linux
-
-endif
-endif
-
-# This is ugly, ugly, ugly. Find a way to fix this crap so it's more unified,
-# like the SDL based makefiles are... !!! FIX !!! [made initial stab at it]
-
-### Variables: ###
-
-#EXEEXT = .exe
-RESCOMP = windres
-srcdir = ./src
-top_srcdir = /local
-top_builddir = /local/
-CXX = g++
-TOOLKIT = MSW
-TOOLKIT_LOWERCASE = msw
-WX_RELEASE = 2.6
-WX_VERSION = $(WX_RELEASE).0
-
-# This is OK
-
-# Note that the -MMD flag is what gives us our automagic dependency information (*.d files)
-# Add -g to compile in debugging information
-CXXFLAGS = -MMD -Wall -Wno-switch -Wno-non-virtual-dtor -O2 `wx-config --cxxflags` -g
-INCS = -I.
-LIBS = `wx-config --libs`
-
-PROGRAM = ttedit
-
-# KO si sihT
-
-OBJECTS  =                  \
-       obj/charnames.o         \
-       obj/charwindow.o        \
-       obj/debug.o             \
-       obj/editwindow.o        \
-       obj/glyphpoints.o       \
-       obj/graphicprimitives.o \
-       obj/registry.o          \
-       obj/toolwindow.o        \
-       obj/ttf.o               \
-       obj/vector.o            \
-       obj/$(PROGRAM).o        \
-       $(ICON)
-
-BIN_PROGRAM = $(PROGRAM)$(EXESUFFIX)
-#Need to fix this shit
-ifneq "" "$(ICON)"
-RES_PROGRAM_OBJ = obj/$(PROGRAM)_resources.o
-else
-RES_PROGRAM_OBJ =
-endif
-BUNDLE = $(BIN_PROGRAM).app/Contents
-
-### Conditionally set variables: ###
-
-COND_TOOLKIT_MAC___MACOSX_RESOURCES_p_1 = $(RESCOMP) -d __DARWIN__ -t APPL -d \
-       __WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p_1) $(__EXCEPTIONS_DEFINE_p_1) \
-       $(__RTTI_DEFINE_p_1) $(__THREAD_DEFINE_p_1) -i $(srcdir) -d WXUSINGDLL -i \
-       $(srcdir)/../../samples -i $(top_srcdir)/include -o bombs$(EXEEXT) Carbon.r \
-       sample.r
-
-### Targets: ###
-
-all: checkenv message obj $(BIN_PROGRAM) $(__bombs_bundle___depname)
-       @echo
-       @echo "*** Looks like it compiled OK... Give it a whirl!"
-
-obj:
-       @mkdir obj
-
-#install: all
-
-# Check the compilation environment, barf if not appropriate
-
-checkenv:
-       @echo
-       @echo -en "\033[01;33m***\033[00;32m Checking compilation environment... \033[00m"
-ifeq "" "$(shell which wx-config)"
-       @echo
-       @echo
-       @echo -e "\033[01;33mIt seems that you don't have the wxWidget development libraries installed."
-       @echo -e "If you have installed them, make sure that the wx-config file is somewhere"
-       @echo -e "in your path and is executable.\033[00m"
-       @echo
-#Is there a better way to break out of the makefile?
-#      @break
-       @breakola!
-else
-       @echo -e "\033[01;37mOK\033[00m"
-endif
-
-message:
-#      @echo
-       @echo -e "\033[01;33m***\033[00;32m Building TTEdit for $(MSG)...\033[00m"
-       @echo
-
-clean:
-       @echo -en "\033[01;33m***\033[00;32m Cleaning out the garbage...\033[00m"
-       @rm -rf ./obj
-       @rm -f ./$(TARGET)$(EXESUFFIX)
-#      rm -rf bombs.app
-       @echo -e "\033[01;37mdone!\033[00m"
-
-## This is only done for Win32 at the moment...
-#
-#ifneq "" "$(ICON)"
-#$(ICON): res/$(TARGET).rc res/$(TARGET).ico
-#      @echo "*** Processing icon..."
-#      @windres -i res/$(TARGET).rc -o $(ICON) --include-dir=./res
-#endif
-
-# This is only done for Win32 at the moment...
-
-ifneq "" "$(ICON)"
-$(RES_PROGRAM_OBJ): res/$(PROGRAM).rc res/$(PROGRAM).ico
-       @echo -e "\033[01;33m***\033[00;32m Processing icon...\033[00m"
-       @$(RESCOMP) -i$< -o$@ --define __WX$(TOOLKIT)__ --include-dir ./res --define WXUSINGDLL --include-dir $(top_srcdir)/include/wx-2.6
-endif
-
-obj/%.o: $(srcdir)/%.cpp
-       @echo -e "\033[01;33m***\033[00;32m Compiling $<...\033[00m"
-       @$(CXX) -c -o $@ $(INCS) $(CXXFLAGS) $<
-
-$(BIN_PROGRAM): $(OBJECTS) $(RES_PROGRAM_OBJ)
-       @echo -e "\033[01;33m***\033[00;32m Linking it all together...\033[00m"
-       @$(CXX) -o $@ $(OBJECTS) $(RES_PROGRAM_OBJ) $(LIBS)
-#      $(_mac_rezcmd)
-#      $(_mac_setfilecmd)
-
-# Mac OSX bundling shit (figure out how to condense this so it works!)
-
-bombs.app/Contents/PkgInfo: bombs$(EXEEXT) $(top_srcdir)/src/mac/carbon/Info.plist.in $(top_srcdir)/src/mac/carbon/wxmac.icns
-       mkdir -p bombs.app/Contents
-       mkdir -p bombs.app/Contents/MacOS
-       mkdir -p bombs.app/Contents/Resources
-
-       sed -e "s/IDENTIFIER/`echo $(srcdir) | sed -e 's,\.\./,,g' | sed -e 's,/,.,g'`/" \
-       -e "s/EXECUTABLE/bombs/" \
-       -e "s/VERSION/$(WX_VERSION)/" \
-       $(top_srcdir)/src/mac/carbon/Info.plist.in >bombs.app/Contents/Info.plist
-
-       echo -n "APPL????" >bombs.app/Contents/PkgInfo
-
-       ln -f bombs$(EXEEXT) bombs.app/Contents/MacOS/bombs
-
-       cp -f $(top_srcdir)/src/mac/carbon/wxmac.icns bombs.app/Contents/Resources/wxmac.icns
-
-#bundle: $(_BUNDLE_TGT_REF_DEP)
-
-### Include dependency info, if present:
+#############################################################################
+# Makefile for building: ttedit
+# Generated by qmake (2.01a) (Qt 4.5.0-rc1) on: Fri Mar 13 16:09:54 2009
+# Project:  ttedit.pro
+# Template: app
+# Command: /usr/bin/qmake -unix -o Makefile ttedit.pro
+#############################################################################
+
+####### Compiler, tools and options
+
+CC            = gcc
+CXX           = g++
+DEFINES       = -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED
+CFLAGS        = -pipe -O2 -march=pentium-m -pipe -D_REENTRANT -Wall -W $(DEFINES)
+CXXFLAGS      = -pipe -O2 -march=pentium-m -pipe -D_REENTRANT -Wall -W $(DEFINES)
+INCPATH       = -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -Iobj -Iobj
+LINK          = g++
+LFLAGS        = -Wl,--as-needed
+LIBS          = $(SUBLIBS)  -L/usr/lib/qt4 -lQtGui -L/usr/lib/qt4 -L/usr/X11R6/lib -pthread -lpng -lfreetype -lgobject-2.0 -lSM -lICE -pthread -pthread -lXrender -lXrandr -lfontconfig -lXext -lX11 -lQtCore -lz -lm -pthread -lgthread-2.0 -lrt -lglib-2.0 -ldl -lpthread
+AR            = ar cqs
+RANLIB        = 
+QMAKE         = /usr/bin/qmake
+TAR           = tar -cf
+COMPRESS      = gzip -9f
+COPY          = cp -f
+SED           = sed
+COPY_FILE     = $(COPY)
+COPY_DIR      = $(COPY) -r
+INSTALL_FILE  = install -m 644 -p
+INSTALL_DIR   = $(COPY_DIR)
+INSTALL_PROGRAM = install -m 755 -p
+DEL_FILE      = rm -f
+SYMLINK       = ln -sf
+DEL_DIR       = rmdir
+MOVE          = mv -f
+CHK_DIR_EXISTS= test -d
+MKDIR         = mkdir -p
+
+####### Output directory
+
+OBJECTS_DIR   = obj/
+
+####### Files
+
+SOURCES       = src/ttedit.cpp \
+               src/editwindow.cpp \
+               src/glyphpoints.cpp \
+               src/debug.cpp \
+               src/toolwindow.cpp \
+               src/vector.cpp \
+               src/graphicprimitives.cpp obj/moc_ttedit.cpp \
+               obj/moc_editwindow.cpp \
+               obj/moc_toolwindow.cpp \
+               obj/qrc_ttedit.cpp
+OBJECTS       = obj/ttedit.o \
+               obj/editwindow.o \
+               obj/glyphpoints.o \
+               obj/debug.o \
+               obj/toolwindow.o \
+               obj/vector.o \
+               obj/graphicprimitives.o \
+               obj/moc_ttedit.o \
+               obj/moc_editwindow.o \
+               obj/moc_toolwindow.o \
+               obj/qrc_ttedit.o
+DIST          = /usr/share/qt4/mkspecs/common/g++.conf \
+               /usr/share/qt4/mkspecs/common/unix.conf \
+               /usr/share/qt4/mkspecs/common/linux.conf \
+               /usr/share/qt4/mkspecs/qconfig.pri \
+               /usr/share/qt4/mkspecs/features/qt_functions.prf \
+               /usr/share/qt4/mkspecs/features/qt_config.prf \
+               /usr/share/qt4/mkspecs/features/exclusive_builds.prf \
+               /usr/share/qt4/mkspecs/features/default_pre.prf \
+               /usr/share/qt4/mkspecs/features/release.prf \
+               /usr/share/qt4/mkspecs/features/default_post.prf \
+               /usr/share/qt4/mkspecs/features/qt.prf \
+               /usr/share/qt4/mkspecs/features/unix/thread.prf \
+               /usr/share/qt4/mkspecs/features/moc.prf \
+               /usr/share/qt4/mkspecs/features/warn_on.prf \
+               /usr/share/qt4/mkspecs/features/resources.prf \
+               /usr/share/qt4/mkspecs/features/uic.prf \
+               /usr/share/qt4/mkspecs/features/yacc.prf \
+               /usr/share/qt4/mkspecs/features/lex.prf \
+               ttedit.pro
+QMAKE_TARGET  = ttedit
+DESTDIR       = 
+TARGET        = ttedit
+
+first: all
+####### Implicit rules
+
+.SUFFIXES: .o .c .cpp .cc .cxx .C
+
+.cpp.o:
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
+
+.cc.o:
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
+
+.cxx.o:
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
+
+.C.o:
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
+
+.c.o:
+       $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
+
+####### Build rules
+
+all: Makefile $(TARGET)
+
+$(TARGET):  $(OBJECTS)  
+       $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
+
+Makefile: ttedit.pro  /usr/share/qt4/mkspecs/linux-g++/qmake.conf /usr/share/qt4/mkspecs/common/g++.conf \
+               /usr/share/qt4/mkspecs/common/unix.conf \
+               /usr/share/qt4/mkspecs/common/linux.conf \
+               /usr/share/qt4/mkspecs/qconfig.pri \
+               /usr/share/qt4/mkspecs/features/qt_functions.prf \
+               /usr/share/qt4/mkspecs/features/qt_config.prf \
+               /usr/share/qt4/mkspecs/features/exclusive_builds.prf \
+               /usr/share/qt4/mkspecs/features/default_pre.prf \
+               /usr/share/qt4/mkspecs/features/release.prf \
+               /usr/share/qt4/mkspecs/features/default_post.prf \
+               /usr/share/qt4/mkspecs/features/qt.prf \
+               /usr/share/qt4/mkspecs/features/unix/thread.prf \
+               /usr/share/qt4/mkspecs/features/moc.prf \
+               /usr/share/qt4/mkspecs/features/warn_on.prf \
+               /usr/share/qt4/mkspecs/features/resources.prf \
+               /usr/share/qt4/mkspecs/features/uic.prf \
+               /usr/share/qt4/mkspecs/features/yacc.prf \
+               /usr/share/qt4/mkspecs/features/lex.prf \
+               /usr/lib/qt4/libQtGui.prl \
+               /usr/lib/qt4/libQtCore.prl
+       $(QMAKE) -unix -o Makefile ttedit.pro
+/usr/share/qt4/mkspecs/common/g++.conf:
+/usr/share/qt4/mkspecs/common/unix.conf:
+/usr/share/qt4/mkspecs/common/linux.conf:
+/usr/share/qt4/mkspecs/qconfig.pri:
+/usr/share/qt4/mkspecs/features/qt_functions.prf:
+/usr/share/qt4/mkspecs/features/qt_config.prf:
+/usr/share/qt4/mkspecs/features/exclusive_builds.prf:
+/usr/share/qt4/mkspecs/features/default_pre.prf:
+/usr/share/qt4/mkspecs/features/release.prf:
+/usr/share/qt4/mkspecs/features/default_post.prf:
+/usr/share/qt4/mkspecs/features/qt.prf:
+/usr/share/qt4/mkspecs/features/unix/thread.prf:
+/usr/share/qt4/mkspecs/features/moc.prf:
+/usr/share/qt4/mkspecs/features/warn_on.prf:
+/usr/share/qt4/mkspecs/features/resources.prf:
+/usr/share/qt4/mkspecs/features/uic.prf:
+/usr/share/qt4/mkspecs/features/yacc.prf:
+/usr/share/qt4/mkspecs/features/lex.prf:
+/usr/lib/qt4/libQtGui.prl:
+/usr/lib/qt4/libQtCore.prl:
+qmake:  FORCE
+       @$(QMAKE) -unix -o Makefile ttedit.pro
+
+dist: 
+       @$(CHK_DIR_EXISTS) obj/ttedit1.0.0 || $(MKDIR) obj/ttedit1.0.0 
+       $(COPY_FILE) --parents $(SOURCES) $(DIST) obj/ttedit1.0.0/ && $(COPY_FILE) --parents src/ttedit.h src/editwindow.h src/glyphpoints.h src/types.h src/debug.h src/toolwindow.h src/vector.h src/graphicprimitives.h src/list.h obj/ttedit1.0.0/ && $(COPY_FILE) --parents ttedit.qrc obj/ttedit1.0.0/ && $(COPY_FILE) --parents src/ttedit.cpp src/editwindow.cpp src/glyphpoints.cpp src/debug.cpp src/toolwindow.cpp src/vector.cpp src/graphicprimitives.cpp obj/ttedit1.0.0/ && (cd `dirname obj/ttedit1.0.0` && $(TAR) ttedit1.0.0.tar ttedit1.0.0 && $(COMPRESS) ttedit1.0.0.tar) && $(MOVE) `dirname obj/ttedit1.0.0`/ttedit1.0.0.tar.gz . && $(DEL_FILE) -r obj/ttedit1.0.0
+
+
+clean:compiler_clean 
+       -$(DEL_FILE) $(OBJECTS)
+       -$(DEL_FILE) *~ core *.core
+
+
+####### Sub-libraries
+
+distclean: clean
+       -$(DEL_FILE) $(TARGET) 
+       -$(DEL_FILE) Makefile
+
+
+mocclean: compiler_moc_header_clean compiler_moc_source_clean
+
+mocables: compiler_moc_header_make_all compiler_moc_source_make_all
+
+compiler_moc_header_make_all: obj/moc_ttedit.cpp obj/moc_editwindow.cpp obj/moc_toolwindow.cpp
+compiler_moc_header_clean:
+       -$(DEL_FILE) obj/moc_ttedit.cpp obj/moc_editwindow.cpp obj/moc_toolwindow.cpp
+obj/moc_ttedit.cpp: src/ttedit.h
+       /usr/bin/moc $(DEFINES) $(INCPATH) src/ttedit.h -o obj/moc_ttedit.cpp
+
+obj/moc_editwindow.cpp: src/types.h \
+               src/toolwindow.h \
+               src/glyphpoints.h \
+               src/ttedit.h \
+               src/editwindow.h
+       /usr/bin/moc $(DEFINES) $(INCPATH) src/editwindow.h -o obj/moc_editwindow.cpp
+
+obj/moc_toolwindow.cpp: src/toolwindow.h
+       /usr/bin/moc $(DEFINES) $(INCPATH) src/toolwindow.h -o obj/moc_toolwindow.cpp
+
+compiler_rcc_make_all: obj/qrc_ttedit.cpp
+compiler_rcc_clean:
+       -$(DEL_FILE) obj/qrc_ttedit.cpp
+obj/qrc_ttedit.cpp: ttedit.qrc \
+               res/cursor3.png \
+               res/toolpal1.xpm \
+               res/cursor5.png \
+               res/cursor1.png \
+               res/toolpal1.png \
+               res/act-back.png \
+               res/ttedit.png \
+               res/cursor6.png \
+               res/cursor8.png \
+               res/cursor7.png \
+               res/act-charwin.png \
+               res/act-forward.png \
+               res/cursor2.png \
+               res/cursor4.png
+       /usr/bin/rcc -name ttedit ttedit.qrc -o obj/qrc_ttedit.cpp
+
+compiler_image_collection_make_all: qmake_image_collection.cpp
+compiler_image_collection_clean:
+       -$(DEL_FILE) qmake_image_collection.cpp
+compiler_moc_source_make_all:
+compiler_moc_source_clean:
+compiler_uic_make_all:
+compiler_uic_clean:
+compiler_yacc_decl_make_all:
+compiler_yacc_decl_clean:
+compiler_yacc_impl_make_all:
+compiler_yacc_impl_clean:
+compiler_lex_make_all:
+compiler_lex_clean:
+compiler_clean: compiler_moc_header_clean compiler_rcc_clean 
+
+####### Compile
+
+obj/ttedit.o: src/ttedit.cpp src/ttedit.h \
+               src/editwindow.h \
+               src/types.h \
+               src/toolwindow.h \
+               src/glyphpoints.h \
+               src/charwindow.h \
+               src/tte_res.h \
+               src/debug.h \
+               res/cur1.xpm \
+               res/cur2.xpm \
+               res/cur3.xpm \
+               res/cur4.xpm \
+               res/cur5.xpm \
+               res/cur6.xpm \
+               res/cur7.xpm \
+               res/cur8.xpm \
+               res/ttedit.xpm \
+               res/tool1.xpm \
+               res/tool2.xpm \
+               res/tool3.xpm
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/ttedit.o src/ttedit.cpp
+
+obj/editwindow.o: src/editwindow.cpp src/editwindow.h \
+               src/types.h \
+               src/toolwindow.h \
+               src/glyphpoints.h \
+               src/ttedit.h \
+               src/graphicprimitives.h \
+               src/debug.h \
+               src/vector.h
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/editwindow.o src/editwindow.cpp
+
+obj/glyphpoints.o: src/glyphpoints.cpp src/glyphpoints.h \
+               src/types.h \
+               src/debug.h
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/glyphpoints.o src/glyphpoints.cpp
+
+obj/debug.o: src/debug.cpp src/debug.h
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/debug.o src/debug.cpp
+
+obj/toolwindow.o: src/toolwindow.cpp src/toolwindow.h \
+               src/types.h
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/toolwindow.o src/toolwindow.cpp
+
+obj/vector.o: src/vector.cpp src/vector.h
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/vector.o src/vector.cpp
+
+obj/graphicprimitives.o: src/graphicprimitives.cpp src/graphicprimitives.h \
+               src/types.h
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/graphicprimitives.o src/graphicprimitives.cpp
+
+obj/moc_ttedit.o: obj/moc_ttedit.cpp 
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/moc_ttedit.o obj/moc_ttedit.cpp
+
+obj/moc_editwindow.o: obj/moc_editwindow.cpp 
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/moc_editwindow.o obj/moc_editwindow.cpp
+
+obj/moc_toolwindow.o: obj/moc_toolwindow.cpp 
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/moc_toolwindow.o obj/moc_toolwindow.cpp
+
+obj/qrc_ttedit.o: obj/qrc_ttedit.cpp 
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/qrc_ttedit.o obj/qrc_ttedit.cpp
+
+####### Install
+
+install:   FORCE
+
+uninstall:   FORCE
+
+FORCE:
 
--include ./obj/*.d
-
-### No idea what this does
-
-#.PHONY: all install uninstall clean distclean bundle
diff --git a/res/act-back.png b/res/act-back.png
new file mode 100644 (file)
index 0000000..1058352
Binary files /dev/null and b/res/act-back.png differ
diff --git a/res/act-charwin.png b/res/act-charwin.png
new file mode 100644 (file)
index 0000000..7ffff2a
Binary files /dev/null and b/res/act-charwin.png differ
diff --git a/res/act-forward.png b/res/act-forward.png
new file mode 100644 (file)
index 0000000..f80a9c2
Binary files /dev/null and b/res/act-forward.png differ
diff --git a/res/cursor1.png b/res/cursor1.png
new file mode 100644 (file)
index 0000000..f6e85fe
Binary files /dev/null and b/res/cursor1.png differ
diff --git a/res/cursor2.png b/res/cursor2.png
new file mode 100644 (file)
index 0000000..5cb650f
Binary files /dev/null and b/res/cursor2.png differ
diff --git a/res/cursor3.png b/res/cursor3.png
new file mode 100644 (file)
index 0000000..492b174
Binary files /dev/null and b/res/cursor3.png differ
diff --git a/res/cursor4.png b/res/cursor4.png
new file mode 100644 (file)
index 0000000..82c1751
Binary files /dev/null and b/res/cursor4.png differ
diff --git a/res/cursor5.png b/res/cursor5.png
new file mode 100644 (file)
index 0000000..234c1f3
Binary files /dev/null and b/res/cursor5.png differ
diff --git a/res/cursor6.png b/res/cursor6.png
new file mode 100644 (file)
index 0000000..88e94bb
Binary files /dev/null and b/res/cursor6.png differ
diff --git a/res/cursor7.png b/res/cursor7.png
new file mode 100644 (file)
index 0000000..b34c46d
Binary files /dev/null and b/res/cursor7.png differ
diff --git a/res/cursor8.png b/res/cursor8.png
new file mode 100644 (file)
index 0000000..1a7ffdc
Binary files /dev/null and b/res/cursor8.png differ
diff --git a/res/toolpal1.png b/res/toolpal1.png
new file mode 100644 (file)
index 0000000..1abc5b7
Binary files /dev/null and b/res/toolpal1.png differ
diff --git a/res/ttedit.png b/res/ttedit.png
new file mode 100644 (file)
index 0000000..f616d6b
Binary files /dev/null and b/res/ttedit.png differ
index 5fec44024f271ef2a3f51817a0c702ca9d05d768..56047bd8c811d151e75aa1883f8ab0f4b0c60ee4 100755 (executable)
@@ -803,7 +803,7 @@ unsigned char unicodeChars[] = {
        : 0061 030A
 00E6   LATIN SMALL LETTER AE (ash) *
        = LATIN SMALL LIGATURE AE
-       = ash (from Old English Ã¦sc)
+       = ash (from Old English ï¿½sc)
        * Danish, Norwegian, Icelandic, Faroese, Old English, French, IPA
        x (latin small ligature oe - 0153)
        x (cyrillic small ligature a ie - 04D5)
@@ -918,7 +918,7 @@ unsigned char unicodeChars[] = {
        x (latin small letter d with stroke - 0111)
        x (latin capital letter african d - 0189)
 0111   LATIN SMALL LETTER D WITH STROKE
-       * Croatian, Vietnamese, Sámi
+       * Croatian, Vietnamese, S�mi
        x (latin capital letter d with stroke - 0110)
        x (cyrillic small letter dje - 0452)
 0112   LATIN CAPITAL LETTER E WITH MACRON
@@ -1074,7 +1074,7 @@ unsigned char unicodeChars[] = {
 014A   LATIN CAPITAL LETTER ENG (Sami)
        * glyph may also have appearance of large form of the small letter
 014B   LATIN SMALL LETTER ENG (Sami)
-       * Sámi, Mende, IPA, ...
+       * S�mi, Mende, IPA, ...
 014C   LATIN CAPITAL LETTER O WITH MACRON
        : 004F 0304
 014D   LATIN SMALL LETTER O WITH MACRON
@@ -1093,7 +1093,7 @@ unsigned char unicodeChars[] = {
 0152   LATIN CAPITAL LIGATURE OE
 0153   LATIN SMALL LIGATURE OE
        = LATIN SMALL LETTER O E
-       = ethel (from Old English eðel)
+       = ethel (from Old English e�el)
        * French, IPA, Old Icelandic, Old English, ...
        x (latin small letter ae - 00E6)
        x (latin letter small capital oe - 0276)
@@ -1152,7 +1152,7 @@ unsigned char unicodeChars[] = {
        : 0074 030C
 0166   LATIN CAPITAL LETTER T WITH STROKE
 0167   LATIN SMALL LETTER T WITH STROKE
-       * Sámi
+       * S�mi
 0168   LATIN CAPITAL LETTER U WITH TILDE
        : 0055 0303
 0169   LATIN SMALL LETTER U WITH TILDE
@@ -1384,7 +1384,7 @@ unsigned char unicodeChars[] = {
        * handwritten variant of Latin "z"
        x (latin small letter z - 007A)
 01B7   LATIN CAPITAL LETTER EZH
-       * African, Skolt Sámi
+       * African, Skolt S�mi
        * lowercase is 0292
        x (latin capital letter yogh - 021C)
        x (cyrillic capital letter abkhasian dze - 04E0)
@@ -1526,22 +1526,22 @@ unsigned char unicodeChars[] = {
        : 00E6 0304
 01E4   LATIN CAPITAL LETTER G WITH STROKE
 01E5   LATIN SMALL LETTER G WITH STROKE
-       * Skolt Sámi
+       * Skolt S�mi
 01E6   LATIN CAPITAL LETTER G WITH CARON
        : 0047 030C
 01E7   LATIN SMALL LETTER G WITH CARON
-       * Skolt Sámi
+       * Skolt S�mi
        x (latin small letter g with breve - 011F)
        : 0067 030C
 01E8   LATIN CAPITAL LETTER K WITH CARON
        : 004B 030C
 01E9   LATIN SMALL LETTER K WITH CARON
-       * Skolt Sámi
+       * Skolt S�mi
        : 006B 030C
 01EA   LATIN CAPITAL LETTER O WITH OGONEK
        : 004F 0328
 01EB   LATIN SMALL LETTER O WITH OGONEK
-       * Sámi, Iroquoian, Old Icelandic
+       * S�mi, Iroquoian, Old Icelandic
        : 006F 0328
 01EC   LATIN CAPITAL LETTER O WITH OGONEK AND MACRON
        : 01EA 0304
@@ -1551,7 +1551,7 @@ unsigned char unicodeChars[] = {
 01EE   LATIN CAPITAL LETTER EZH WITH CARON
        : 01B7 030C
 01EF   LATIN SMALL LETTER EZH WITH CARON
-       * Skolt Sámi
+       * Skolt S�mi
        : 0292 030C
 01F0   LATIN SMALL LETTER J WITH CARON
        * IPA and many languages
@@ -1936,7 +1936,7 @@ unsigned char unicodeChars[] = {
        = dram
        * voiced postalveolar fricative
        * uppercase is 01B7
-       * Skolt Sámi
+       * Skolt S�mi
        x (latin small letter yogh - 021D)
        x (cyrillic small letter abkhasian dze - 04E1)
        x (ounce sign - 2125)
index a115f9682faab0043f9ae2b77434fb4d121ba07d..b0952ca6ded33e365a448da5b487dc8050a49f19 100755 (executable)
@@ -9,6 +9,7 @@
 // ---  ----------  -------------------------------------------------------------
 // JLH  08/28/2008  Created this file
 // JLH  09/02/2008  Separated scrolling from dedicated tool to MMB drag
+// JLH  03/13/2009  Converted from wxWidgets to Qt
 //
 
 // FIXED:
 #define DEBUGFOO            // Various tool debugging...
 #define DEBUGTP                                // Toolpalette debugging...
 
+#include "editwindow.h"
+//#include <QtGui>
+#include "graphicprimitives.h"
+#include "debug.h"
+#include "vector.h"
+
+EditWindow::EditWindow(QWidget * parent/*=NULL*/): QWidget(parent),
+       scale(1.0), offsetX(-10), offsetY(-10), tool(TOOLSelect),
+       ptHighlight(-1), oldPtHighlight(-1), ptNextHighlight(-1), oldPtNextHighlight(-1),
+       polyFirstPoint(true)
+{
+       setBackgroundRole(QPalette::Base);
+       setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+
+       toolPalette = new ToolWindow();
+       CreateCursors();
+       setCursor(cur[TOOLSelect]);
+       setMouseTracking(true);
+}
+
+QSize EditWindow::minimumSizeHint() const
+{
+       return QSize(50, 50);
+}
+
+QSize EditWindow::sizeHint() const
+{
+       return QSize(400, 400);
+}
+
+void EditWindow::CreateCursors(void)
+{
+       int hotx[8] = {  1,  1, 11, 15,  1,  1,  1,  1 };
+       int hoty[8] = {  1,  1, 11, 13,  1,  1,  1,  1 };
+
+       for(int i=0; i<8; i++)
+       {
+               QString s;
+               s.sprintf(":/res/cursor%u.png", i+1);
+               QPixmap pmTmp(s);
+               cur[i] = QCursor(pmTmp, hotx[i], hoty[i]);
+       }
+}
+
+QPoint EditWindow::GetAdjustedMousePosition(QMouseEvent * event)
+{
+       QSize winSize = size();
+       // This is undoing the transform, e.g. going from client coords to local coords.
+       // In essence, the height - y is height + (y * -1), the (y * -1) term doing the conversion
+       // of the y-axis from increasing bottom to top.
+       return QPoint(offsetX + event->x(), offsetY + (winSize.height() - event->y()));
+}
+
+QPoint EditWindow::GetAdjustedClientPosition(int x, int y)
+{
+       QSize winSize = size();
+
+       // VOODOO ALERT (ON Y COMPONENT!!!!)
+       return QPoint(-offsetX + x, (winSize.height() - (-offsetY + y)) * +1.0);
+}
+
+void EditWindow::paintEvent(QPaintEvent * /*event*/)
+{
+       QPainter p(this);
+//hm, causes lockup
+//     p.setRenderHint(QPainter::Antialiasing);
+//Doesn't do crap!
+//dc.SetBackground(*wxWHITE_BRUSH);
+
+// Due to the screwiness of wxWidgets coord system, the origin is ALWAYS
+// the upper left corner--regardless of axis orientation, etc...
+//     int width, height;
+//     dc.GetSize(&width, &height);
+       QSize winSize = size();
+
+//     dc.SetDeviceOrigin(-offsetX, height - (-offsetY));
+//     dc.SetAxisOrientation(true, true);
+       p.translate(QPoint(-offsetX, winSize.height() - (-offsetY)));
+       p.scale(1.0, -1.0);
+
+// Scrolling can be done by using OffsetViewportOrgEx
+// Scaling can be done by adjusting SetWindowExtEx (it's denominator of txform)
+// you'd use: % = ViewportExt / WindowExt
+// But it makes the window look like crap: fuggetuboutit.
+// Instead, we have to scale EVERYTHING by hand. Crap!
+// It's not *that* bad, but not as convenient either...
+
+//     dc.SetPen(*(wxThePenList->FindOrCreatePen(wxColour(0x00, 0x00, 0xFF), 1, wxDOT)));
+////   dc.DrawLine(0, 0, 10, 10);
+       p.setPen(QPen(Qt::blue, 1.0, Qt::DotLine));
+
+    // Draw coordinate axes
+
+//     dc.CrossHair(0, 0);
+       p.drawLine(0, -16384, 0, 16384);
+       p.drawLine(-16384, 0, 16384, 0);
+
+    // Draw points
+
+       for(int i=0; i<pts.GetNumPoints(); i++)
+       {
+               if (i == ptHighlight)
+               {
+//                     dc.SetPen(*(wxThePenList->FindOrCreatePen(wxColour(0xFF, 0x00, 0x00), 1, wxSOLID)));
+////                   SelectObject(hdc, hRedPen1);
+                       p.setPen(QPen(Qt::red, 1.0, Qt::SolidLine));
+
+                       if (pts.GetOnCurve(i))
+                       {
+                               DrawSquareDotN(p, pts.GetX(i), pts.GetY(i), 7);
+                               DrawSquareDotN(p, pts.GetX(i), pts.GetY(i), 9);
+                       }
+                       else
+                       {
+                               DrawRoundDotN(p, pts.GetX(i), pts.GetY(i), 7);
+                               DrawRoundDotN(p, pts.GetX(i), pts.GetY(i), 9);
+                       }
+               }
+               else if ((i == ptHighlight || i == ptNextHighlight) && tool == TOOLAddPt)
+               {
+//                     dc.SetPen(*(wxThePenList->FindOrCreatePen(wxColour(0x00, 0xAF, 0x00), 1, wxSOLID)));
+////                   SelectObject(hdc, hGreenPen1);
+                       p.setPen(QPen(Qt::green, 1.0, Qt::SolidLine));
+
+                       if (pts.GetOnCurve(i))
+                       {
+                               DrawSquareDotN(p, pts.GetX(i), pts.GetY(i), 7);
+                               DrawSquareDotN(p, pts.GetX(i), pts.GetY(i), 9);
+                       }
+                       else
+                       {
+                               DrawRoundDotN(p, pts.GetX(i), pts.GetY(i), 7);
+                               DrawRoundDotN(p, pts.GetX(i), pts.GetY(i), 9);
+                       }
+               }
+               else
+               {
+//                     dc.SetPen(*(wxThePenList->FindOrCreatePen(wxColour(0x00, 0x00, 0x00), 1, wxSOLID)));
+////                   SelectObject(hdc, hBlackPen1);
+                       p.setPen(QPen(Qt::black, 1.0, Qt::SolidLine));
+
+                       if (pts.GetOnCurve(i))
+                               DrawSquareDot(p, pts.GetX(i), pts.GetY(i));
+                       else
+                               DrawRoundDot(p, pts.GetX(i), pts.GetY(i));
+               }
+
+               if (tool == TOOLDelPt && i == ptHighlight)
+               {
+#if 0
+                       dc.SetPen(*(wxThePenList->FindOrCreatePen(wxColour(0xFF, 0x00, 0x00), 1, wxSOLID)));
+//                     SelectObject(hdc, hRedPen1);
+//                     MoveToEx(hdc, pts.GetX(i) - 5, pts.GetY(i) - 5, NULL);
+//                     LineTo(hdc, pts.GetX(i) + 5, pts.GetY(i) + 5);
+//                     LineTo(hdc, pts.GetX(i) - 5, pts.GetY(i) - 5);//Lameness!
+//                     MoveToEx(hdc, pts.GetX(i) - 5, pts.GetY(i) + 5, NULL);
+//                     LineTo(hdc, pts.GetX(i) + 5, pts.GetY(i) - 5);
+//                     LineTo(hdc, pts.GetX(i) - 5, pts.GetY(i) + 5);//More lameness!!
+#endif
+                       p.setPen(QPen(Qt::red, 1.0, Qt::SolidLine));
+                       p.drawLine(pts.GetX(i) - 5, pts.GetY(i) - 5, pts.GetX(i) + 5, pts.GetY(i) + 5);
+                       p.drawLine(pts.GetX(i) + 5, pts.GetY(i) - 5, pts.GetX(i) - 5, pts.GetY(i) + 5);
+               }
+       }
+
+////           SelectObject(hdc, hBlackPen1);
+//     dc.SetPen(*(wxThePenList->FindOrCreatePen(wxColour(0x00, 0x00, 0x00), 1, wxSOLID)));
+       p.setPen(QPen(Qt::black, 1.0, Qt::SolidLine));
+
+       // Draw curve formed by points
+
+       for(int poly=0; poly<pts.GetNumPolys(); poly++)
+       {
+               if (pts.GetNumPoints(poly) > 2)
+               {
+                       // Initial move...
+                       // If it's not on curve, then move to it, otherwise move to last point...
+
+                       int x, y;
+
+                       if (pts.GetOnCurve(poly, pts.GetNumPoints(poly) - 1))
+                               x = (int)pts.GetX(poly, pts.GetNumPoints(poly) - 1), y = (int)pts.GetY(poly, pts.GetNumPoints(poly) - 1);
+                       else
+                               x = (int)pts.GetX(poly, 0), y = (int)pts.GetY(poly, 0);
+
+                       for(int i=0; i<pts.GetNumPoints(poly); i++)
+                       {
+                               if (pts.GetOnCurve(poly, i))
+//                                     LineTo(hdc, pts.GetX(poly, i), pts.GetY(poly, i));
+                               {
+                                       p.drawLine(x, y, pts.GetX(poly, i), pts.GetY(poly, i));
+                                       x = (int)pts.GetX(poly, i), y = (int)pts.GetY(poly, i);
+                               }
+                               else
+                               {
+                                       uint32 prev = pts.GetPrev(poly, i), next = pts.GetNext(poly, i);
+                                       float px = pts.GetX(poly, prev), py = pts.GetY(poly, prev),
+                                               nx = pts.GetX(poly, next), ny = pts.GetY(poly, next);
+
+                                       if (!pts.GetOnCurve(poly, prev))
+                                               px = (px + pts.GetX(poly, i)) / 2.0f,
+                                               py = (py + pts.GetY(poly, i)) / 2.0f;
+
+                                       if (!pts.GetOnCurve(poly, next))
+                                               nx = (nx + pts.GetX(poly, i)) / 2.0f,
+                                               ny = (ny + pts.GetY(poly, i)) / 2.0f;
+
+                                       Bezier(p, point(px, py), point(pts.GetX(poly, i), pts.GetY(poly, i)), point(nx, ny));
+                                       x = (int)nx, y = (int)ny;
+
+                                       if (pts.GetOnCurve(poly, next))
+                                               i++;                                    // Following point is on curve, so move past it
+                               }
+                       }
+               }
+       }
+}
+
+void EditWindow::mousePressEvent(QMouseEvent * event)
+{
+       if (event->button() == Qt::RightButton)
+       {
+               toolPalette->move(event->globalPos());
+               toolPalette->setVisible(true);
+               setCursor(cur[TOOLSelect]);
+               toolPalette->prevTool = TOOLSelect;
+       }
+       else if (event->button() == Qt::MidButton)
+       {
+               setCursor(cur[2]);                                                      // Scrolling cursor
+       }
+       else if (event->button() == Qt::LeftButton)
+       {
+               if (tool == TOOLScroll || tool == TOOLZoom)
+;//meh                 CaptureMouse();                                         // Make sure we capture the mouse when in scroll/zoom mode
+               else if (tool == TOOLAddPt)             // "Add Point" tool
+               {
+                       if (pts.GetNumPoints() > 0)
+                       {
+                               QPoint pt = GetAdjustedMousePosition(event);
+                               pts.InsertPoint(pts.GetNext(ptHighlight), pt.x(), pt.y(), ((event->modifiers() == Qt::ShiftModifier || event->modifiers() == Qt::ControlModifier) ? false : true));
+                               ptHighlight = ptNextHighlight;
+                               update();
+                       }
+               }
+               else if (tool == TOOLAddPoly)   // "Add Poly" tool
+               {
+#ifdef DEBUGFOO
+WriteLogMsg("Adding point... # polys: %u, # points: %u", pts.GetNumPolys(), pts.GetNumPoints());
+#endif
+                       if (polyFirstPoint)
+                       {
+                               polyFirstPoint = false;
+                               pts.AddNewPolyAtEnd();
+                       }
+
+                       QPoint pt = GetAdjustedMousePosition(event);
+//printf("GetAdjustedMousePosition = %i, %i\n", pt.x(), pt.y());
+                       // Append a point to the end of the structure
+                       pts += IPoint(pt.x(), pt.y(), ((event->modifiers() == Qt::ShiftModifier || event->modifiers() == Qt::ControlModifier) ? false : true));
+                       ptHighlight = pts.GetNumPoints() - 1;
+                       update();
+#ifdef DEBUGFOO
+WriteLogMsg(" --> [# polys: %u, # points: %u]\n", pts.GetNumPolys(), pts.GetNumPoints());
+#endif
+               }
+               else if (tool == TOOLSelect || tool == TOOLPolySelect)
+               {
+                       if (pts.GetNumPoints() > 0)
+                       {
+                               pt = GetAdjustedClientPosition(pts.GetX(ptHighlight), pts.GetY(ptHighlight));
+//printf("GetAdjustedClientPosition = %i, %i\n", pt.x(), pt.y());
+//                             WarpPointer(pt.x, pt.y);
+                               QCursor::setPos(mapToGlobal(pt));
+
+                               if (event->modifiers() == Qt::ShiftModifier || event->modifiers() == Qt::ControlModifier)
+                               {
+                                       pts.SetOnCurve(ptHighlight, !pts.GetOnCurve(ptHighlight));
+                                       update();
+                               }
+                       }
+               }
+               else if (tool == TOOLDelPt)
+               {
+                       if (pts.GetNumPoints() > 0)
+//Or could use:
+//                     if (ptHighlight != -1)
+                       {
+//This assumes that WM_MOUSEMOVE happens before this!
+//The above commented out line should take care of this contingency... !!! FIX !!!
+                               pts.DeletePoint(ptHighlight);
+                               update();
+                       }
+               }
+       }
+
+       event->accept();
+}
+
+void EditWindow::mouseMoveEvent(QMouseEvent * event)
+{
+       if (event->buttons() == Qt::RightButton)
+       {
+               ToolType newTool = toolPalette->FindSelectedTool();
+
+               if (newTool != toolPalette->prevTool)
+               {
+                       toolPalette->prevTool = newTool;
+                       toolPalette->repaint();
+               }
+       }
+       else if (event->buttons() == Qt::MidButton)
+       {
+               // Calc offset from previous point
+               pt = event->pos();
+               ptOffset = QPoint(pt.x() - ptPrevious.x(), pt.y() - ptPrevious.y());
+
+// Then multiply it by the scaling factor. Whee!
+               // This looks wacky because we're using screen coords for the offset...
+               // Otherwise, we would subtract both offsets!
+               offsetX -= ptOffset.x(), offsetY += ptOffset.y();
+               update();
+               ptPrevious = pt;
+       }
+       else if (event->buttons() == Qt::LeftButton)
+       {
+#if 0
+                       if (tool == TOOLScroll)
+                       {
+                           // Extract current point from lParam/calc offset from previous point
+
+                               pt = e.GetPosition();
+                               ptOffset.x = pt.x - ptPrevious.x,
+                               ptOffset.y = pt.y - ptPrevious.y;
+
+                               // NOTE: OffsetViewportOrg operates in DEVICE UNITS...
+
+//Seems there's no equivalent for this in wxWidgets...!
+//!!! FIX !!!
+//                             hdc = GetDC(hWnd);
+//                             OffsetViewportOrgEx(hdc, ptOffset.x, ptOffset.y, NULL);
+//                             ReleaseDC(hWnd, hdc);
+
+// this shows that it works, so the logic above must be faulty...
+// And it is. It should convert the coords first, then do the subtraction to figure the offset...
+// Above: DONE
+// Then multiply it by the scaling factor. Whee!
+                               // This looks wacky because we're using screen coords for the offset...
+                               // Otherwise, we would subtract both offsets!
+                               offsetX -= ptOffset.x, offsetY += ptOffset.y;
+                               Refresh();
+                       }
+                       else
+#endif
+                       if (tool == TOOLAddPt || tool == TOOLAddPoly || tool == TOOLSelect)
+                       {
+                               if (tool != TOOLAddPt || pts.GetNumPoints() > 0)//yecch.
+                               {
+//temporary, for testing. BTW, Select drag bug is here...!
+#if 1
+                                       QPoint pt2 = GetAdjustedMousePosition(event);
+                                       pts.SetXY(ptHighlight, pt2.x(), pt2.y());
+                                       update();
+#endif
+                               }
+                       }
+                       else if (tool == TOOLPolySelect)
+                       {
+                               if (pts.GetNumPoints() > 0)
+                               {
+                                       QPoint pt2 = GetAdjustedMousePosition(event);
+                                       // Should also set onCurve here as well, depending on keystate
+//Or should we?
+                                       pts.OffsetPoly(pts.GetPoly(ptHighlight), pt2.x() - pts.GetX(ptHighlight), pt2.y() - pts.GetY(ptHighlight));
+                                       update();
+                               }
+                       }
+       }
+       else if (event->buttons() == Qt::NoButton)
+       {
+               // Moving, not dragging...
+               if (tool == TOOLSelect || tool == TOOLDelPt || tool == TOOLAddPt
+                       || tool == TOOLPolySelect)// || tool == TOOLAddPoly)
+               {
+                       QPoint pt2 = GetAdjustedMousePosition(event);
+                       double closest = 1.0e+99;
+
+                       for(int i=0; i<pts.GetNumPoints(); i++)
+                       {
+                               double dist = ((pt2.x() - pts.GetX(i)) * (pt2.x() - pts.GetX(i)))
+                                       + ((pt2.y() - pts.GetY(i)) * (pt2.y() - pts.GetY(i)));
+
+                               if (dist < closest)
+                                       closest = dist, ptHighlight = i;
+                       }
+
+                       if (ptHighlight != oldPtHighlight)
+                       {
+                               oldPtHighlight = ptHighlight;
+                               update();
+                       }
+
+                       // What follows here looks like voodoo, but is really simple. What we do is
+                       // check to see if the mouse point has a perpendicular intersection with any of
+                       // the line segments. If it does, calculate the length of the perpendicular
+                       // and choose the smallest length. If there is no perpendicular, then choose the
+                       // length of line connecting the closer of either the first endpoint or the
+                       // second and choose the smallest of those.
+
+                       // There is one bit of math that looks like voodoo to me ATM--will explain once
+                       // I understand it better (the calculation of the length of the perpendicular).
+
+                       if (pts.GetNumPoints() > 1 && tool == TOOLAddPt)
+                       {
+                               double smallest = 1.0e+99;
+
+                               for(int i=0; i<pts.GetNumPoints(); i++)
+                               {
+                                       int32 p1x = pts.GetX(i), p1y = pts.GetY(i),
+                                               p2x = pts.GetX(pts.GetNext(i)), p2y = pts.GetY(pts.GetNext(i));
+
+                                       vector ls(p2x, p2y, 0, p1x, p1y, 0), v1(pt2.x(), pt2.y(), 0, p1x, p1y, 0),
+                                               v2(pt2.x(), pt2.y(), 0, p2x, p2y, 0);
+                                       double pp = ls.dot(v1) / ls.length(), dist;
+// Geometric interpretation:
+// pp is the paremeterized point on the vector ls where the perpendicular intersects ls.
+// If pp < 0, then the perpendicular lies beyond the 1st endpoint. If pp > length of ls,
+// then the perpendicular lies beyond the 2nd endpoint.
+
+                                       if (pp < 0.0)
+                                               dist = v1.length();
+                                       else if (pp > ls.length())
+                                               dist = v2.length();
+                                       else                                    // distance = ?Det?(ls, v1) / |ls|
+                                               dist = fabs((ls.x * v1.y - v1.x * ls.y) / ls.length());
+
+//The answer to the above looks like it might be found here:
+//
+//If the segment endpoints are s and e, and the point is p, then the test for the perpendicular
+//intercepting the segment is equivalent to insisting that the two dot products {s-e}.{s-p} and
+//{e-s}.{e-p} are both non-negative.  Perpendicular distance from the point to the segment is
+//computed by first computing the area of the triangle the three points form, then dividing by the
+//length of the segment.  Distances are done just by the Pythagorean theorem.  Twice the area of the
+//triangle formed by three points is the determinant of the following matrix:
+//
+//sx sy 1
+//ex ey 1
+//px py 1
+//
+//(???) By translating the start point to the origin, this can be rewritten as:
+//By subtracting row 1 from all rows, you get the following:
+//
+//0         0         0
+//(ex - sx) (ey - sy) 0
+//(px - sx) (py - sy) 0
+//
+//which greatly simplifies the calculation of the determinant.
+
+                                       if (dist < smallest)
+                                               smallest = dist, ptNextHighlight = pts.GetNext(i), ptHighlight = i;
+                               }
+
+                               if (ptNextHighlight != oldPtNextHighlight)
+                               {
+                                       oldPtNextHighlight = ptNextHighlight;
+                                       update();
+                               }
+                       }
+               }
+
+               ptPrevious = event->pos();
+       }
+
+       event->accept();
+}
+
+void EditWindow::mouseReleaseEvent(QMouseEvent * event)
+{
+       if (event->button() == Qt::RightButton)
+       {
+               ToolType newTool = toolPalette->FindSelectedTool();
+
+               // We only change the tool if a new one was actually selected. Otherwise, we do nothing.
+               if (newTool != TOOLNone)
+               {
+                       tool = newTool;
+
+                       if (tool == TOOLScroll || tool == TOOLZoom || tool == TOOLAddPoly
+                               || tool == TOOLDelPoly)
+                               ptHighlight = -1;
+
+                       if (tool == TOOLAddPoly)
+                               polyFirstPoint = true;
+               }
+
+               toolPalette->setVisible(false);
+               setCursor(cur[tool]);
+               // Just in case we changed highlighting style with the new tool...
+               update();
+       }
+       else if (event->button() == Qt::MidButton)
+       {
+               setCursor(cur[tool]);                                           // Restore previous cursor
+       }
+       else if (event->button() == Qt::LeftButton)
+       {
+//             if (tool == TOOLScroll || tool == TOOLZoom)
+//                     ReleaseMouse();
+       }
+
+       event->accept();
+}
+
+
+
+#if 0
 #include "editwindow.h"
 #include "graphicprimitives.h"
 #include "toolwindow.h"
@@ -49,7 +566,7 @@ TTEditWindow::TTEditWindow(wxFrame * parent, const wxPoint &pos, const wxSize &s
        app(wxGetApp()), scale(1.0), offsetX(-10), offsetY(-10), tool(TOOLSelect),
        ptHighlight(-1), oldPtHighlight(-1), ptNextHighlight(-1), oldPtNextHighlight(-1),
        polyFirstPoint(true), bmp(NULL)
-{ 
+{
        SetCursor(*(app.cur[tool]));
        SetBackgroundColour(wxColour(0xFF, 0xFF, 0xFF));
 
@@ -167,12 +684,12 @@ void TTEditWindow::OnPaint(wxPaintEvent &e)
                        // If it's not on curve, then move to it, otherwise move to last point...
 
                        wxCoord x, y;
-       
+
                        if (pts.GetOnCurve(poly, pts.GetNumPoints(poly) - 1))
                                x = (wxCoord)pts.GetX(poly, pts.GetNumPoints(poly) - 1), y = (wxCoord)pts.GetY(poly, pts.GetNumPoints(poly) - 1);
                        else
                                x = (wxCoord)pts.GetX(poly, 0), y = (wxCoord)pts.GetY(poly, 0);
-       
+
                        for(int i=0; i<pts.GetNumPoints(poly); i++)
                        {
                                if (pts.GetOnCurve(poly, i))
@@ -186,18 +703,18 @@ void TTEditWindow::OnPaint(wxPaintEvent &e)
                                        uint32 prev = pts.GetPrev(poly, i), next = pts.GetNext(poly, i);
                                        float px = pts.GetX(poly, prev), py = pts.GetY(poly, prev),
                                                nx = pts.GetX(poly, next), ny = pts.GetY(poly, next);
-       
+
                                        if (!pts.GetOnCurve(poly, prev))
                                                px = (px + pts.GetX(poly, i)) / 2.0f,
                                                py = (py + pts.GetY(poly, i)) / 2.0f;
-       
+
                                        if (!pts.GetOnCurve(poly, next))
                                                nx = (nx + pts.GetX(poly, i)) / 2.0f,
                                                ny = (ny + pts.GetY(poly, i)) / 2.0f;
-       
+
                                        Bezier(dc, point(px, py), point(pts.GetX(poly, i), pts.GetY(poly, i)), point(nx, ny));
                                        x = (wxCoord)nx, y = (wxCoord)ny;
-       
+
                                        if (pts.GetOnCurve(poly, next))
                                                i++;                                    // Following point is on curve, so move past it
                                }
@@ -635,7 +1152,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT msgID, WPARAM wParam, LPARAM lParam)
                        ptWinOffset.x = rc2.left - rc1.left;
                        ptWinOffset.y = rc2.top - rc1.top;
                }
-                   
+
                // Let Windows do its thing with this msg, or weird things will happen...
 
                DefWindowProc(hWnd, msgID, wParam, lParam);
@@ -743,12 +1260,12 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT msgID, WPARAM wParam, LPARAM lParam)
                        {
                                // Initial move...
                                // If it's not on curve, then move to it, otherwise move to last point...
-       
+
                                if (pts.GetOnCurve(poly, pts.GetNumPoints(poly) - 1))
                                        MoveToEx(hdc, pts.GetX(poly, pts.GetNumPoints(poly) - 1), pts.GetY(poly, pts.GetNumPoints(poly) - 1), NULL);
                                else
                                        MoveToEx(hdc, pts.GetX(poly, 0), pts.GetY(poly, 0), NULL);
-       
+
                                for(int i=0; i<pts.GetNumPoints(poly); i++)
                                {
                                        if (pts.GetOnCurve(poly, i))
@@ -758,17 +1275,17 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT msgID, WPARAM wParam, LPARAM lParam)
                                                uint32 prev = pts.GetPrev(poly, i), next = pts.GetNext(poly, i);
                                                float px = pts.GetX(poly, prev), py = pts.GetY(poly, prev),
                                                        nx = pts.GetX(poly, next), ny = pts.GetY(poly, next);
-       
+
                                                if (!pts.GetOnCurve(poly, prev))
                                                        px = (px + pts.GetX(poly, i)) / 2.0f,
                                                        py = (py + pts.GetY(poly, i)) / 2.0f;
-       
+
                                                if (!pts.GetOnCurve(poly, next))
                                                        nx = (nx + pts.GetX(poly, i)) / 2.0f,
                                                        ny = (ny + pts.GetY(poly, i)) / 2.0f;
-       
+
                                                Bezier(hdc, point(px, py), point(pts.GetX(poly, i), pts.GetY(poly, i)), point(nx, ny));
-       
+
                                                if (pts.GetOnCurve(poly, next))
                                                        i++;                                    // Following point is on curve, so move past it
                                        }
@@ -1343,7 +1860,7 @@ WriteLogMsg(strBuf);
 int32 FindSelectedTool(void)
 {
        POINT pt;
-               
+
        GetCursorPos(&pt);
        ScreenToClient(hToolPalWnd, &pt);
 
@@ -1628,3 +2145,4 @@ bool Initialization(void)
 }
 
 #endif
+#endif
index 846e891608342f6084855e7b8d5c83bb9f94dd60..f31298cc1305d5d041d200d6a1806194e11ec4a9 100755 (executable)
@@ -8,6 +8,47 @@
 #ifndef __EDITWINDOW_H__
 #define __EDITWINDOW_H__
 
+#include <QtGui>
+#include "types.h"
+//#include "ttedit.h"                                                          // For TTEditApp
+#include "toolwindow.h"                                                        // For ToolType enum
+#include "glyphpoints.h"
+
+class EditWindow: public QWidget
+{
+       Q_OBJECT
+
+       public:
+               EditWindow(QWidget * parent = NULL);
+               QSize minimumSizeHint() const;
+               QSize sizeHint() const;
+
+       protected:
+               void paintEvent(QPaintEvent * event);
+               void mousePressEvent(QMouseEvent * event);
+               void mouseMoveEvent(QMouseEvent * event);
+               void mouseReleaseEvent(QMouseEvent * event);
+
+       private:
+               void CreateCursors(void);
+               QPoint GetAdjustedMousePosition(QMouseEvent * event);
+               QPoint GetAdjustedClientPosition(int x, int y);
+
+               QImage image;
+               QPoint pt, ptOffset, ptPrevious;
+//             TTEditApp & app;                                                // Reference to the application object
+               double scale;                                                   // Window scaling factor
+               int32 offsetX, offsetY;                                 // Window offsets
+               ToolType tool;                                                  // Current tool
+               GlyphPoints pts;                                                // Glyph point structure
+               int32 ptHighlight, oldPtHighlight, ptNextHighlight, oldPtNextHighlight;
+               bool polyFirstPoint;
+
+               ToolWindow * toolPalette;
+               QCursor cur[8];
+};
+
+#if 0
 #include <wx/wx.h>                                                             // So that whoever uses this can without having
                                                                                                // to pull in a bunch of references manually
 #include "types.h"
@@ -44,5 +85,6 @@ class TTEditWindow: public wxWindow
 
        DECLARE_EVENT_TABLE()
 };
+#endif
 
 #endif // __EDITWINDOW_H__
index 6eb84a23770a39552862be9d63b6ee8e6283daa7..82e15ab323db6b2bf70e569808fa5707c94ced22 100755 (executable)
@@ -27,13 +27,14 @@ double abs(double n)                                                        // Helper function
 // This function takes three points and draws a curve using a second order
 // Bezier function.
 //
-void Bezier(wxDC &dc, point p1, point p2, point p3)
+void Bezier(QPainter &p, point p1, point p2, point p3)
 {
        double step = abs(p1.x - p3.x), tmp = abs(p1.y - p3.y);
        step = (tmp > step ? tmp : step);                       // Get the larger of the two...
        step = (step > 0 ? 1/step : 1);                         // & convert to valid step value
+       step *= 2.0;                                                            // (double it to draw less...)
 
-       wxCoord prevX = (wxCoord)p1.x, prevY = (wxCoord)p1.y;
+       int prevX = (int)p1.x, prevY = (int)p1.y;
 
        for(double u=0; u<=1; u+=step)
        {
@@ -41,67 +42,68 @@ void Bezier(wxDC &dc, point p1, point p2, point p3)
                double x = (p1.x * (1 - _2u + _uu)) + (p2.x * (_2u - _2uu)) + (p3.x * _uu);
                double y = (p1.y * (1 - _2u + _uu)) + (p2.y * (_2u - _2uu)) + (p3.y * _uu);
 
-               dc.DrawLine(prevX, prevY, (wxCoord)x, (wxCoord)y);
-               prevX = (wxCoord)x, prevY = (wxCoord)y;
+               p.drawLine(prevX, prevY, (int)x, (int)y);
+               prevX = (int)x, prevY = (int)y;
        }
 
-       dc.DrawLine(prevX, prevY, (wxCoord)p3.x, (wxCoord)p3.y);
+       p.drawLine(prevX, prevY, (int)p3.x, (int)p3.y);
 }
 
 //
 // Draw a round dot (5x5, centered on [x, y])
 //
-void DrawRoundDot(wxDC &dc, int32 x, int32 y)
+void DrawRoundDot(QPainter &p, int32 x, int32 y)
 {
-       wxPoint pt[8];
-
-       pt[0].x = x - 1, pt[0].y = y - 2;
-       pt[1].x = x + 1, pt[1].y = y - 2;
-       pt[2].x = x + 2, pt[2].y = y - 1;
-       pt[3].x = x + 2, pt[3].y = y + 1;
-       pt[4].x = x + 1, pt[4].y = y + 2;
-       pt[5].x = x - 1, pt[5].y = y + 2;
-       pt[6].x = x - 2, pt[6].y = y + 1;
-       pt[7].x = x - 2, pt[7].y = y - 1;
-
-       dc.DrawPolygon(8, pt);
+       QPoint pt[8];
+
+       pt[0] = QPoint(x - 1, y - 2);
+       pt[1] = QPoint(x + 1, y - 2);
+       pt[2] = QPoint(x + 2, y - 1);
+       pt[3] = QPoint(x + 2, y + 1);
+       pt[4] = QPoint(x + 1, y + 2);
+       pt[5] = QPoint(x - 1, y + 2);
+       pt[6] = QPoint(x - 2, y + 1);
+       pt[7] = QPoint(x - 2, y - 1);
+
+       p.drawPolygon(pt, 8);
 }
 
 //
 // Draw a sqaure dot (5x5, centered on [x, y])
 //
-void DrawSquareDot(wxDC &dc, int32 x, int32 y)
+void DrawSquareDot(QPainter &p, int32 x, int32 y)
 {
-       wxPoint pt[4];
+       QPoint pt[4];
 
-       pt[0].x = x - 2, pt[0].y = y - 2;
-       pt[1].x = x + 2, pt[1].y = y - 2;
-       pt[2].x = x + 2, pt[2].y = y + 2;
-       pt[3].x = x - 2, pt[3].y = y + 2;
+       pt[0] = QPoint(x - 2, y - 2);
+       pt[1] = QPoint(x + 2, y - 2);
+       pt[2] = QPoint(x + 2, y + 2);
+       pt[3] = QPoint(x - 2, y + 2);
 
-       dc.DrawPolygon(4, pt);
+       p.drawPolygon(pt, 4);
 }
 
 //
 // Draw a sqaure dot (nxn, centered on [x, y])
 //
-void DrawSquareDotN(wxDC &dc, int32 x, int32 y, uint32 n)
+void DrawSquareDotN(QPainter &p, int32 x, int32 y, uint32 n)
 {
-       wxPoint pt[4];
+       QPoint pt[4];
        uint32 offset = (n - 1) / 2;
 
-       pt[0].x = x - offset, pt[0].y = y - offset;
-       pt[1].x = x + offset, pt[1].y = y - offset;
-       pt[2].x = x + offset, pt[2].y = y + offset;
-       pt[3].x = x - offset, pt[3].y = y + offset;
+       pt[0] = QPoint(x - offset, y - offset);
+       pt[1] = QPoint(x + offset, y - offset);
+       pt[2] = QPoint(x + offset, y + offset);
+       pt[3] = QPoint(x - offset, y + offset);
 
-       dc.DrawPolygon(4, pt);
+       p.drawPolygon(pt, 4);
 }
 
 //
 // Draw a round dot (nxn, centered on [x, y])
 //
-void DrawRoundDotN(wxDC &dc, int32 x, int32 y, uint32 n)
+void DrawRoundDotN(QPainter &p, int32 x, int32 y, uint32 n)
 {
-       dc.DrawCircle(x, y, (n / 2) + 1);
+       int radius = (n / 2) + 1;
+       p.drawEllipse(x - radius, y - radius, n, n);
 }
index 81e15abf8da68afecde87fafbda8549de4d0e0ea..1513ebbe4ba23c4617f31e5891fca79e2008e8c5 100755 (executable)
@@ -8,7 +8,7 @@
 #ifndef __GRAPHICPRIMITIVES_H__
 #define __GRAPHICPRIMITIVES_H__
 
-#include <wx/wx.h>                                                             // For device context
+#include <QtGui>                                                               // For QPainter
 #include "types.h"                                                             // For int32
 
 struct point
@@ -18,10 +18,10 @@ struct point
        point(float xx = 0, float yy = 0): x(xx), y(yy) {}
 };
 
-void Bezier(wxDC &, point, point, point);
-void DrawRoundDot(wxDC &, int32, int32);
-void DrawSquareDot(wxDC &, int32, int32);
-void DrawRoundDotN(wxDC &, int32, int32, uint32);
-void DrawSquareDotN(wxDC &, int32, int32, uint32);
+void Bezier(QPainter &, point, point, point);
+void DrawRoundDot(QPainter &, int32, int32);
+void DrawSquareDot(QPainter &, int32, int32);
+void DrawRoundDotN(QPainter &, int32, int32, uint32);
+void DrawSquareDotN(QPainter &, int32, int32, uint32);
 
 #endif // __GRAPHICPRIMITIVES_H__
diff --git a/src/registry.cpp b/src/registry.cpp
deleted file mode 100755 (executable)
index 576207a..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-//
-// REGISTRY.CPP - Win32 support file
-// by James L. Hammons
-// (C) 2002 Underground Software
-//
-//   JLH = James Hammons <jlhamm@acm.org>
-//
-// Who  When        What
-// ---  ----------  ------------------------------------------------------------
-// JLH  05/16/2002  Created this file
-// JLH  12/10/2002  Updated InitINIFile to take a parameter so that you can open
-//                  an .INI file that doesn't belong to the current module
-//
-// STILL TO BE DONE:
-//
-// - Convert to wxWidgets...
-//
-
-#warning This file not yet converted to wxWidgets!!!
-
-#if 0
-#include <windows.h>
-#include "registry.h"
-
-// Local data
-
-static char INIPath[MAX_PATH];
-static char str[4096];
-
-//
-// Initialize the application .INI file
-// Returns TRUE if succesful, FALSE otherwise...
-//
-void InitINIFile(char * path/*= NULL*/)
-{
-       if (!GetModuleFileName(NULL, INIPath, MAX_PATH))
-               return;
-
-       if (path == NULL)
-       {
-               int len = lstrlen(INIPath);
-               lstrcpy(INIPath + len - 4, ".ini");
-       }
-       else
-       {
-               for(int i=lstrlen(INIPath); i>=0; i--)
-               {
-                       if (INIPath[i] == '\\')
-                       {
-                               lstrcpy(INIPath + i + 1, path);
-                               break;
-                       }
-               }
-       }
-}
-
-//
-// Write an int value to our .INI file
-//
-void SetINIInt(char * section, char * entry, int32 value)
-{
-       const char fmtStr[] = "%d";
-       char strVal[20];
-
-       wsprintf(strVal, fmtStr, value);
-       WritePrivateProfileString(section, entry, strVal, INIPath);
-}
-
-//
-// Write a string value to our .INI file
-//
-void SetINIString(char * section, char * entry, char * value)
-{
-       WritePrivateProfileString(section, entry, value, INIPath);
-}
-
-//
-// Get an int value from our .INI file
-//
-int32 GetINIInt(char * section, char * entry, int32 _default)
-{
-       return GetPrivateProfileInt(section, entry, _default, INIPath);
-}
-
-//
-// Get a string value from our .INI file
-//
-const char * GetINIString(char * section, char * entry, char * _default)
-{
-       GetPrivateProfileString(section, entry, _default, str, 4096, INIPath);
-
-       return str;
-}
-#endif
diff --git a/src/registry.h b/src/registry.h
deleted file mode 100755 (executable)
index 526713b..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-//
-// REGISTRY.H - Win32 support file header
-// by James L. Hammons
-// (C) 2002 Underground Software
-//
-//   JLH = James Hammons <jlhamm@acm.org>
-//
-
-#ifndef __REGISTRY_H__
-#define __REGISTRY_H__
-
-#include "types.h"
-
-// Function prototypes
-
-void InitINIFile(char * path = NULL);
-void SetINIInt(char *, char *, int32);
-void SetINIString(char *, char *, char *);
-int32 GetINIInt(char *, char *, int32);
-const char * GetINIString(char *, char *, char *);
-
-#endif // __REGISTRY_H__
index 80f90e429a5edf8b1ff0c14841808cfc2325396a..75eaa0e1a3c129aec0d176ac9f7979e0cfb1c956 100755 (executable)
@@ -8,6 +8,7 @@
 // Who  When        What
 // ---  ----------  -------------------------------------------------------------
 // JLH  08/28/2008  Created this file
+// JLH  03/11/2009  Converted from wxWidgets to Qt
 //
 
 // FIXED:
 #include "toolwindow.h"
 #include "types.h"
 
-// Pixmap resources
 
-#include "res/toolpal1.xpm"                                            // Docs say this is portable... Let's see!
-
-
-BEGIN_EVENT_TABLE(ToolWindow, wxFrame)
-       EVT_PAINT(ToolWindow::OnPaint)
-END_EVENT_TABLE()
-
-
-ToolWindow::ToolWindow(wxFrame * parent, const wxString &title, const wxPoint &pos,
-       const wxSize &size, long style): wxFrame(parent, -1, title, pos, size, style),
-       bmp(NULL), prevTool(TOOLNone)
+ToolWindow::ToolWindow(void): QWidget(NULL, Qt::Window | Qt::FramelessWindowHint),
+       prevTool(TOOLNone)
 {
-       bmp = new wxBitmap(toolpal1_xpm);
+       img = QImage(":/res/toolpal1.xpm");
 
        // Set up sizes
 
-       sizeTPBM.x = bmp->GetWidth(), sizeTPBM.y = bmp->GetHeight();
-       sizeStamp.x = sizeTPBM.x / 4, sizeStamp.y = sizeTPBM.y / 2;
+       sizeTPBM.rx() = img.width(), sizeTPBM.ry() = img.height();
+       sizeStamp.rx() = sizeTPBM.x() / 4, sizeStamp.ry() = sizeTPBM.y() / 2;
 
-       SetSize(0, 0, sizeTPBM.x, sizeTPBM.y);
-       Show(false);
+       setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
+       setVisible(false);
 }
 
-ToolWindow::~ToolWindow()
+QSize ToolWindow::sizeHint() const
 {
-       if (bmp)
-               delete bmp;
+       return QSize(sizeTPBM.x(), sizeTPBM.y());
 }
 
-void ToolWindow::OnPaint(wxPaintEvent &e)
+void ToolWindow::paintEvent(QPaintEvent * event)
 {
-       wxPaintDC dc(this);
-
-       wxMemoryDC memDC;
-       memDC.SelectObject(*bmp);
-       dc.Blit(0, 0, sizeTPBM.x, sizeTPBM.y, &memDC, 0, 0, wxCOPY);
+       QPainter p(this);
+       p.drawImage(QPoint(0, 0), img);
 
        if (prevTool != -1)
        {
            //need ul corner of bitmap, ul corner of dest, width/height
-               wxPoint pt(sizeStamp.x * (prevTool & 0x03), sizeStamp.y * (prevTool >> 2));
-               dc.Blit(pt.x, pt.y, sizeStamp.x, sizeStamp.y, &memDC, pt.x, pt.y, wxSRC_INVERT);
+               p.setCompositionMode(QPainter::RasterOp_NotSource);
+               QPoint pt(sizeStamp.x() * (prevTool & 0x03), sizeStamp.y() * (prevTool >> 2));
+               p.drawImage(pt.x(), pt.y(), img, pt.x(), pt.y(), sizeStamp.x(), sizeStamp.y());
        }
-
-       memDC.SelectObject(wxNullBitmap);
 }
 
 //
@@ -79,10 +65,12 @@ void ToolWindow::OnPaint(wxPaintEvent &e)
 ToolType ToolWindow::FindSelectedTool(void)
 {
        // Get mouse coords relative to the tool palette window
-       wxPoint pt = ScreenToClient(wxGetMousePosition());
+//     wxPoint pt = ScreenToClient(wxGetMousePosition());
+       QPoint pt = mapFromGlobal(QCursor::pos());
+//printf("pt = %u, %u\n", pt.x(), pt.y());
 
        // Divide mouse coords by the bitmap stamp size to find which one is pointed to
-       uint32 x = (uint32)pt.x / sizeStamp.x, y = (uint32)pt.y / sizeStamp.y;
+       uint32 x = (uint32)pt.x() / sizeStamp.x(), y = (uint32)pt.y() / sizeStamp.y();
 
        // Preset failure into newTool, in case no new tool is selected
        ToolType newTool = TOOLNone;
index d4eab9f0371fd400ef9a40e91b3d50663348057b..1623eb44bc6edb3ec6f5c76bc382407c9ccbd8b3 100755 (executable)
@@ -2,16 +2,15 @@
 // TOOLWINDOW.H: Header file
 //
 // by James L. Hammons
-// (C) 2008 Underground Software
+// (C) 2009 Underground Software
 //
 
 #ifndef __TOOLWINDOW_H__
 #define __TOOLWINDOW_H__
 
-#include <wx/wx.h>                                                             // So that whoever uses this can without having
-                                                                                               // to pull in a bunch of references manually
+#include <QtGui>
 
-// Enumerations (prolly go into ToolWindow class--?)
+// Enumerations
 
 enum ToolType {
        TOOLNone = -1,                                                  // No tool
@@ -25,23 +24,24 @@ enum ToolType {
        TOOLDelPoly                                                             // Delete polygon tool
 };
 
-class ToolWindow: public wxFrame
+class ToolWindow: public QWidget
 {
-       private:
-       protected:
+       Q_OBJECT
+
        public:
-               wxBitmap * bmp;
-               wxPoint sizeStamp, sizeTPBM;
-               ToolType prevTool;
+               ToolWindow(void);
+               ToolType FindSelectedTool(void);
 
-               // Constructor and destructor
-               ToolWindow(wxFrame * parent, const wxString &title, const wxPoint &pos, const wxSize &size, long style);
-               ~ToolWindow(void);
+       protected:
+               QSize sizeHint() const;
+               void paintEvent(QPaintEvent * event);
 
-               void OnPaint(wxPaintEvent &e);
-               ToolType FindSelectedTool(void);
+       public:
+               ToolType prevTool;
 
-       DECLARE_EVENT_TABLE()
+       private:
+               QImage img;
+               QPoint sizeStamp, sizeTPBM;
 };
 
 #endif // __TOOLWINDOW_H__
diff --git a/src/tte_res.h b/src/tte_res.h
deleted file mode 100755 (executable)
index 9efa641..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-//
-// Resource includes
-//
-// by James L. Hammons
-//
-
-// Uncomment this to debug logging...
-//Actually, this is done on a file by file basis and NOT here...
-//#define DEBUG
-
-//
-// Common equates also used in the resource file
-//
-
-#define        IDI_ICON                        0x01L           // IDs same as in ttedit.asm
-#define        IDM_MENU                        0x02L
-#define        IDA_ACCEL                       0x03L
-#define        IDD_ABOUT                       0x04L
-#define IDR_TOOLBAR1           0x05L
-#define IDB_TOOLBAR1           0x06L
-#define IDB_TOOLPAL1           0x07L
-#define IDC_CURSOR1                    0x08L
-#define IDC_CURSOR2                    0x09L
-#define IDC_CURSOR3                    0x0AL
-#define IDC_CURSOR4                    0x0BL
-#define IDC_CURSOR5                    0x0CL
-#define IDC_CURSOR6                    0x0DL
-#define IDC_CURSOR7                    0x0EL
-#define IDC_CURSOR8                    0x0FL
-
-#define        IDS_SYSMENU                     0x010L
-#define        IDM_FILEMENU            0x011L
-#define        IDM_HELPMENU            0x012L
-
-#define        IDM_NEW                         0x020L
-#define        IDM_OPEN                        0x021L
-#define        IDM_SAVE                        0x022L
-#define        IDM_SAVEAS                      0x023L
-#define        IDM_EXIT                        0x024L
-#define        IDM_HELPTOPICS          0x025L
-#define        IDM_ABOUT                       0x026L
-
-#define        ID_TBLEFT                       0x030L
-#define        ID_TBRIGHT                      0x031L
-#define        ID_TBCHARWIN            0x032L
-
index 17617f167e9c2a225070a9f517cdcfbefc4eb52a..c8123773ce2bfd885d23197e36a42ae2f99c9c74 100755 (executable)
@@ -13,6 +13,7 @@
 // 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:
 #define DEBUGFOO                       // Various tool debugging...
 #define DEBUGTP                                // Toolpalette debugging...
 
+//#include <QtGui>
+#include "ttedit.h"
+#include <QApplication>
+#include "editwindow.h"
+
+// 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);
+       TTEMainWindow TTEWin;
+       TTEWin.show();
+       return app.exec();
+}
+
+
+TTEMainWindow::TTEMainWindow()
+{
+       editWnd = new EditWindow(this);
+       setCentralWidget(editWnd);
+       setWindowIcon(QIcon(":/res/ttedit.png"));
+       setWindowTitle("TTEdit!");
+
+#if 0
+//     createActions();
+       newAct = new QAction(QIcon(":/images/new.png"), tr("&New"), this);
+       newAct->setShortcuts(QKeySequence::New);
+       newAct->setStatusTip(tr("Create a new file"));
+       connect(newAct, SIGNAL(triggered()), this, SLOT(newFile()));
+
+       openAct = new QAction(QIcon(":/images/open.png"), tr("&Open..."), this);
+       openAct->setShortcuts(QKeySequence::Open);
+       openAct->setStatusTip(tr("Open an existing file"));
+       connect(openAct, SIGNAL(triggered()), this, SLOT(open()));
+
+       aboutQtAct = new QAction(tr("About &Qt"), this);
+       aboutQtAct->setStatusTip(tr("Show the Qt library's About box"));
+       connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
+
+//     createMenus();
+       fileMenu = menuBar()->addMenu(tr("&File"));
+       fileMenu->addAction(newAct);
+       fileMenu->addAction(openAct);
+       fileMenu->addAction(saveAct);
+       fileMenu->addAction(saveAsAct);
+       fileMenu->addSeparator();
+       fileMenu->addAction(exitAct);
+
+       editMenu = menuBar()->addMenu(tr("&Edit"));
+       editMenu->addAction(cutAct);
+       editMenu->addAction(copyAct);
+       editMenu->addAction(pasteAct);
+
+       menuBar()->addSeparator();
+
+       helpMenu = menuBar()->addMenu(tr("&Help"));
+       helpMenu->addAction(aboutAct);
+       helpMenu->addAction(aboutQtAct);
+
+//     createToolBars();
+       fileToolBar = addToolBar(tr("File"));
+       fileToolBar->addAction(newAct);
+       fileToolBar->addAction(openAct);
+       fileToolBar->addAction(saveAct);
+
+       editToolBar = addToolBar(tr("Edit"));
+       editToolBar->addAction(cutAct);
+       editToolBar->addAction(copyAct);
+       editToolBar->addAction(pasteAct);
+#endif
+
+       //      Create status bar
+       statusBar()->showMessage(tr("Ready"));
+
+       ReadSettings();
+
+//     connect(textEdit->document(), SIGNAL(contentsChanged()),
+//                     this, SLOT(documentWasModified()));
+
+//     setCurrentFile("");
+       setUnifiedTitleAndToolBarOnMac(true);
+}
+
+void TTEMainWindow::closeEvent(QCloseEvent * event)
+{
+       WriteSettings();
+       event->accept(); // ignore() if can't close for some reason
+}
+
+void TTEMainWindow::Open(void)
+{
+}
+
+void TTEMainWindow::ReadSettings(void)
+{
+       QSettings settings("Underground Software", "TTEdit");
+       QPoint pos = settings.value("pos", QPoint(200, 200)).toPoint();
+       QSize size = settings.value("size", QSize(400, 400)).toSize();
+       resize(size);
+       move(pos);
+}
+
+void TTEMainWindow::WriteSettings(void)
+{
+       QSettings settings("Underground Software", "TTEdit");
+       settings.setValue("pos", pos());
+       settings.setValue("size", size());
+}
+
+
+#if 0
 #include "ttedit.h"
 #include "charwindow.h"
 #include "toolwindow.h"
@@ -237,3 +350,4 @@ void TTEditFrame::OnCloseWindow(wxCloseEvent &e)
        app.toolPalette->Destroy();
        this->Destroy();
 }
+#endif
index fc0fb3ef8e65b5e7466722dd872168d82f42b55b..d92c33aa611d28f98a35570201b0b44e37a4dbb0 100755 (executable)
@@ -2,27 +2,31 @@
 // TTEDIT.H: Header file
 //
 // by James L. Hammons
-// (C) 2008 Underground Software
+// (C) 2009 Underground Software
 //
 
 #ifndef __TTEDIT_H__
 #define __TTEDIT_H__
 
-#include <wx/wx.h>                                                             // So that whoever uses this can without having
+//Hrm. uh??? I thought this wasn't the way to do this stuff...???
+#include <QtGui>
+
+#if 0
+//#include <wx/wx.h>                                                           // So that whoever uses this can without having
                                                                                                // to pull in a bunch of references manually
-#include "ttf.h"
+//#include "ttf.h"
 
 // Forward declarations
 
-class TTEditFrame;
-class TTEditWindow;
-class CharWindow;
-class ToolWindow;
+//class TTEditWin;
+//class TTEditWindow;
+//class CharWindow;
+//class ToolWindow;
 
 //
 // Class representing the entire Application
 //
-class TTEditApp: public wxApp
+class TTEditApp: public QMainWindow
 {
        public:
                TTEditFrame * mainFrame;
@@ -37,9 +41,33 @@ class TTEditApp: public wxApp
 };
 
 DECLARE_APP(TTEditApp)
+#endif
+// Forward declarations
+
+//class TTEditWin;
+class EditWindow;
 
-class TTEditFrame: public wxFrame
+
+class TTEMainWindow: public QMainWindow
 {
+       // All Qt apps require this macro
+       Q_OBJECT
+
+       public:
+               TTEMainWindow();
+
+       protected:
+               void closeEvent(QCloseEvent * event);
+
+       private slots:
+               void Open();
+
+       private:
+               void ReadSettings(void);
+               void WriteSettings(void);
+
+               EditWindow * editWnd;
+#if 0
        private:
        protected:
        public:
@@ -59,6 +87,7 @@ class TTEditFrame: public wxFrame
                void OnCharWindow(wxCommandEvent &e);
 
        DECLARE_EVENT_TABLE()
+#endif
 };
 
 #endif // __TTEDIT_H__
diff --git a/ttedit.pro b/ttedit.pro
new file mode 100644 (file)
index 0000000..7315add
--- /dev/null
@@ -0,0 +1,28 @@
+# Use 'qmake -o Makefile ttedit.pro'
+
+CONFIG += qt
+
+HEADERS += src/ttedit.h
+HEADERS += src/editwindow.h
+HEADERS += src/glyphpoints.h
+HEADERS += src/types.h
+HEADERS += src/debug.h
+HEADERS += src/toolwindow.h
+HEADERS += src/vector.h
+HEADERS += src/graphicprimitives.h
+HEADERS += src/list.h
+
+SOURCES += src/ttedit.cpp
+SOURCES += src/editwindow.cpp
+SOURCES += src/glyphpoints.cpp
+SOURCES += src/debug.cpp
+SOURCES += src/toolwindow.cpp
+SOURCES += src/vector.cpp
+SOURCES += src/graphicprimitives.cpp
+
+RESOURCES += ttedit.qrc
+
+OBJECTS_DIR = ./obj
+MOC_DIR = ./obj
+RCC_DIR = ./obj
+UI_DIR = ./obj
diff --git a/ttedit.qrc b/ttedit.qrc
new file mode 100644 (file)
index 0000000..ca2b69b
--- /dev/null
@@ -0,0 +1,18 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+       <file>res/cursor1.png</file>
+       <file>res/cursor2.png</file>
+       <file>res/cursor3.png</file>
+       <file>res/cursor4.png</file>
+       <file>res/cursor5.png</file>
+       <file>res/cursor6.png</file>
+       <file>res/cursor7.png</file>
+       <file>res/cursor8.png</file>
+       <file>res/act-back.png</file>
+       <file>res/act-forward.png</file>
+       <file>res/act-charwin.png</file>
+       <file>res/toolpal1.png</file>
+       <file>res/toolpal1.xpm</file>
+       <file>res/ttedit.png</file>
+</qresource>
+</RCC>