From 3599953dec39d0ae662b039378a0b3eda39424e8 Mon Sep 17 00:00:00 2001 From: Shamus Hammons Date: Fri, 13 Mar 2009 21:19:06 +0000 Subject: [PATCH] Converted project from wxWidgets to Qt. This will be the LAST time this happens. Unless something better comes along. ;-) --- Makefile | 489 +++++++++++++++++++++------------- res/act-back.png | Bin 0 -> 169 bytes res/act-charwin.png | Bin 0 -> 204 bytes res/act-forward.png | Bin 0 -> 170 bytes res/cursor1.png | Bin 0 -> 259 bytes res/cursor2.png | Bin 0 -> 316 bytes res/cursor3.png | Bin 0 -> 323 bytes res/cursor4.png | Bin 0 -> 395 bytes res/cursor5.png | Bin 0 -> 327 bytes res/cursor6.png | Bin 0 -> 336 bytes res/cursor7.png | Bin 0 -> 316 bytes res/cursor8.png | Bin 0 -> 322 bytes res/toolpal1.png | Bin 0 -> 694 bytes res/ttedit.png | Bin 0 -> 399 bytes src/charnames.cpp | 24 +- src/editwindow.cpp | 548 ++++++++++++++++++++++++++++++++++++-- src/editwindow.h | 42 +++ src/graphicprimitives.cpp | 70 ++--- src/graphicprimitives.h | 12 +- src/registry.cpp | 94 ------- src/registry.h | 22 -- src/toolwindow.cpp | 52 ++-- src/toolwindow.h | 32 +-- src/tte_res.h | 46 ---- src/ttedit.cpp | 114 ++++++++ src/ttedit.h | 47 +++- ttedit.pro | 28 ++ ttedit.qrc | 18 ++ 28 files changed, 1166 insertions(+), 472 deletions(-) create mode 100644 res/act-back.png create mode 100644 res/act-charwin.png create mode 100644 res/act-forward.png create mode 100644 res/cursor1.png create mode 100644 res/cursor2.png create mode 100644 res/cursor3.png create mode 100644 res/cursor4.png create mode 100644 res/cursor5.png create mode 100644 res/cursor6.png create mode 100644 res/cursor7.png create mode 100644 res/cursor8.png create mode 100644 res/toolpal1.png create mode 100644 res/ttedit.png delete mode 100755 src/registry.cpp delete mode 100755 src/registry.h delete mode 100755 src/tte_res.h create mode 100644 ttedit.pro create mode 100644 ttedit.qrc diff --git a/Makefile b/Makefile index 2f25505..8dc2ae1 100755 --- a/Makefile +++ b/Makefile @@ -1,187 +1,304 @@ -# -# 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 index 0000000000000000000000000000000000000000..1058352805d312dd96327e880ce55da923aaf3cc GIT binary patch literal 169 zcmeAS@N?(olHy`uVBq!ia0vp^0zk~q!3HGX7W?Z1DaPU;cPEB*=VV?2Ic!PZ?k)`f zL2$v|<&%LToCO|{#S9GG!XV7ZFl&wkP>{XE)7O>#CNmF{fXSRhfu%qpO-~oc5RLQ6 z2@gTe~ HDWM4f+tDlp literal 0 HcmV?d00001 diff --git a/res/act-charwin.png b/res/act-charwin.png new file mode 100644 index 0000000000000000000000000000000000000000..7ffff2aa46266b736a80ab4cb3faf7c3b01fe8d7 GIT binary patch literal 204 zcmeAS@N?(olHy`uVBq!ia0vp^0zk~q!3HGX7W?Z1DaPU;cPEB*=VV?2Ic!PZ?k)`f zL2$v|<&%LToCO|{#S9GG!XV7ZFl&wkP>{XE)7O>#CNmF{5bOWWB3Yo2kEe@ch{pM~ zlRfzu6gZd{zWl$xC)_sU!bIsr-|0OaToNgcKNAzrb;|9Fth%$a$m+qf2WCEwqNyy& s3R+5m2WPGd7B_hovOYh~{XE)7O>#CNmF{pjd!Z0#JlO%hSa%MB{vN zf&}Z4hW`OR(#{f|1`Mn1++?^qSbIcvH?)RGv+Ibp83Ubin3GxkzQh@jHcwYSmvv4F FO#oGjC^rBA literal 0 HcmV?d00001 diff --git a/res/cursor1.png b/res/cursor1.png new file mode 100644 index 0000000000000000000000000000000000000000..f6e85fe49a9e0a3369e0f7ca0a8df9f8f4a24b46 GIT binary patch literal 259 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}Y)RhkE({MD z0vG~bD``Eqvo3EX*n-Clz9Btn7LE($qPT0vW>P{x>+#|^BcsJpV<{>S!Rq3ipspdrw7W4-;P|6yGKw)=0#i$>SXA;uy>~aHRBT-> y{_&&JHo<#snN$D&oS*R0ereFk5Ur^pR*Y|XV?OQJJ*N-o90pHUKbLh*2~7a$6j9;; literal 0 HcmV?d00001 diff --git a/res/cursor2.png b/res/cursor2.png new file mode 100644 index 0000000000000000000000000000000000000000..5cb650fda4b06ce5345ae72642e79c2acca2a661 GIT binary patch literal 316 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}Y)RhkE*uA@Iy*cxm!8o4-8DT}U<*HkyVAj5&skWa z-OX73TN*3gn0=z@L52}?(`MF-0yUd7gqr-t-5g&$nUsN40t@Jv$e;frG)tCC4VS>8hnl(#kgs zlQwzZZ+*Iw%Tp%g(uDA3U*&!7vfITo>Hh9_yZmdPIq!6#wJi?CmxQh_v=dN2^*FRk zhs}D@`nO4IZ%^IzM6P|J>oH%JmNM(>dmq%7AJSa+l%1XZ_9Hg)OTXsWiQ3HudWXT& L)z4*}Q$iB}4o!FB literal 0 HcmV?d00001 diff --git a/res/cursor4.png b/res/cursor4.png new file mode 100644 index 0000000000000000000000000000000000000000..82c1751bd81e1d7699ac9fed11edc315e9ed6ea9 GIT binary patch literal 395 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}Y)RhkE)4%c zaKYZ?lYt_f1s;*b3=G`DAk4@xYmNj^kiEpy*OmPyGY=D|-Y;f{<3LlmJzX3_A`U+d zf6H~)fTKt8{r^+j?L9XvGJdwYS(fM2waQnqTb70}GITa}Xv8{*EqN)F?>=$r>ApGd zTr#Jg_Pe6;&g%mk*ZMDMPi-5Q6@C%<@H@OF$R*%A|Cu?_Jkd(em>J&6eUn|}$um1Z zc{$fRMHb#EsRjBI+>TAQDB_83YWlOV(p%|PtIq20yB18$mvou)`kBm$X?0;!tyjO7 zy}%Tua(r6wRq3xn*WRD|cI1j-kAv~@)F&TQN;*~wo>U17QOw=<+0%Rn_p|<$7v2^A z_4PN1_$Y8A?-l!G=7YvxF3H?Ty!E(0Wz&j&t;ucLK6VpVWEcr literal 0 HcmV?d00001 diff --git a/res/cursor5.png b/res/cursor5.png new file mode 100644 index 0000000000000000000000000000000000000000..234c1f3a53d75b9a1837097d05cbf404555501e7 GIT binary patch literal 327 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}Y)RhkE)4%c zaKYZ?lYt_f1s;*b3=G`DAk4@xYmNj^kiEpy*OmPyGY=D&*&(NHkh#Y_T^vIq4!@mt zo9~DMhfCt7|Nl?F@y@-&nY~uLV&alcSEb{E`btVkX=;&Ws@ruqrnIeErqTFIotf!P zM_a@5o|Xgq`!qPVSSc%f5ZNHjWa}t*L`&lf+ckl-wAE97+RT~6vv8i!s#VbpUO`^p z7N62#sW|qPCGwefqxG^a=^_qu_oOTI&Ggh$S~Rak$MkTatk3lWvl%7wToudq3wNFW z?Y2GTwcdrW*n)%ac5z=jWmUwt#qZb^^Cw+j_iulw;PN6!*1GJ?4YS`&A6~Biy3SOo Q1?VLPPgg&ebxsLQ0M`_I(f|Me literal 0 HcmV?d00001 diff --git a/res/cursor6.png b/res/cursor6.png new file mode 100644 index 0000000000000000000000000000000000000000..88e94bbfaa4a0130667375b23d5b17b3bd8f393b GIT binary patch literal 336 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}Y)RhkE)4%c zaKYZ?lYt_f1s;*b3=G`DAk4@xYmNj^kiEpy*OmPyGY=EDZlF!^f1uC>PZ!6Kh{JEg zE^-}E;P|rS|NqqQM($gprmc$;VoTj%?SHwW!^5Se>?W_?ZjTLm3^{>KpU?6M#aM++ zelTmZyV4|u?R-%xE-p%;kJcX+TEWt*z}UN@I8@$gtMQjQgVhe}TADN^W2+CGWr@02 zeXz4*lIt&_4}Q{H*lb)TDHdI+seG%USkCoHCVE|x%jZWcvifFptmj-Azf|1jUy=RN z1KUox-{)MLVXIYhmTAoj?jDUvBqFe5gC?YhUU2YWZwpJ`7%-X|NK aC4T47xy$O3M-Kq~#^CAd=d#Wzp$Pz{SARzU literal 0 HcmV?d00001 diff --git a/res/cursor7.png b/res/cursor7.png new file mode 100644 index 0000000000000000000000000000000000000000..b34c46dfa35371361cdaffb6ad3e25d3fbb23e61 GIT binary patch literal 316 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}Y)RhkE)4%c zaKYZ?lYt_f1s;*b3=G`DAk4@xYmNj^kiEpy*OmPyGY=Dwh+{>r0Z?d-M(X+lSt;cg&f?9456z8t4xOPgg&ebxsLQ E0LU_M+yDRo literal 0 HcmV?d00001 diff --git a/res/cursor8.png b/res/cursor8.png new file mode 100644 index 0000000000000000000000000000000000000000..1a7ffdc7834a833c72a3f129a0670c6cff2c039b GIT binary patch literal 322 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}Y)RhkE)4%c zaKYZ?lYt_f1s;*b3=G`DAk4@xYmNj^kiEpy*OmPyGY=Clqv^gKvw%W}JY5_^A`ZU| z3*>7x;8=X*cf4f19OuD@+?#smn;KqBycFc1qNF4!`07x9%r2J=_ZTt?o8CINb9`gp z?fT(G!E%m1rrjSA~<#aN4CGJ$?wlkama|Uh`6~9-; zSoVe0sBgwbZu_vCZTsw2&dcE1RQs{tCfY2-z3f|&m4$`HjXvpnleT`!InW0RB?eDd KKbLh*2~7Z44tP`m literal 0 HcmV?d00001 diff --git a/res/toolpal1.png b/res/toolpal1.png new file mode 100644 index 0000000000000000000000000000000000000000..1abc5b7001250e38086fdf4625f9bdb6893aa682 GIT binary patch literal 694 zcmV;n0!jUeP)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2iXG* z0u?uSAGKNl00K5iL_t(|+U;9GlEfegRLlQ=**&@Cx`{T30TZm6!(@_HX%GlZ3?Y=@ zLv7^tODQs3#27EHJN|$C=oVnW0!k?%#wf~g#dQ2Je&U$osUyZ{ZcmAO9{P|WHlY(p zFIYoJ((_lrmr{O@6e@Po658pO)e63il3L#(O2Ek^^bV9NBvl`9Ith2t%L)mzh=_un zcPwBPPa+X&Lr6qWlKWw2!j?!_xo2i!qie{XW_bZcHp$ZQ(c@L8rlp-`EntU0q%bSa zl}4l2(0Tf2`%o9b%$Bud#ll*lNE{Uuvg>yQKcN#LPLjHKDkeu*cM*xC54*|-(0wKC z<7O76Nce%C1nB@`w#N|(i6VSyE4b63w+uvHDSTw0R`+ypk-6r)a}#f~hS7fVmjq;S z-CmNkl!$rJ{CRx00OgTf1bzhh5#)NPYysZ4qlfQ4z@6}4&5(GL4>HFqk0A7|ZTlOiB8K44DsGvpP0|JVep3?Fs#Zf$!nkvch#%pz zTN6*{Y(qO7cFwU}l0;2dO8Zgswm49WWBY)&w}?FD_{})sk%Kzb3Rs!&E_S~@kkewR zD`Mq1LVGt)BEIk7K-QhOOrGEib|qrS^C$^f(wroxlKQ##l<EZyD2Ur)XeANrEqE55i?^j{k+2JU_x+=1ydIz(CEbjsO4v literal 0 HcmV?d00001 diff --git a/res/ttedit.png b/res/ttedit.png new file mode 100644 index 0000000000000000000000000000000000000000..f616d6bb37ed627e750c26da26155ebd70324862 GIT binary patch literal 399 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}Y)RhkE)4%c zaKYZ?lYt_f1s;*b3=G`DAk4@xYmNj^kiEpy*OmPyGdGKd)VZRkvw)`Xd%8G=L>zuQ z^=9r710EOoW?i4TE~`=|daZfeGS}BGMfua#iTnpR9{m*Lxn1>S!lDP))<%n;W>9jh zt~<9wmiNKqEOxnUN#EGY@9QEbF(ft3IqSxkv$1&d*GUsZf*YBSL^M_Y*_PP;JwV{Z zfm5%{>gKI4J?5(#5v-(8v#0Xq151$&hptLlJU^)!5fuBJ@A#_x>>E+N_nXhol6_Gi z#P}x#o+1c=d#Wzp$Pye!J+a1 literal 0 HcmV?d00001 diff --git a/src/charnames.cpp b/src/charnames.cpp index 5fec440..56047bd 100755 --- a/src/charnames.cpp +++ b/src/charnames.cpp @@ -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) diff --git a/src/editwindow.cpp b/src/editwindow.cpp index a115f96..b0952ca 100755 --- a/src/editwindow.cpp +++ b/src/editwindow.cpp @@ -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: @@ -32,6 +33,522 @@ #define DEBUGFOO // Various tool debugging... #define DEBUGTP // Toolpalette debugging... +#include "editwindow.h" +//#include +#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; iFindOrCreatePen(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 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; ibutton() == 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 1 && tool == TOOLAddPt) + { + double smallest = 1.0e+99; + + for(int i=0; i 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 +#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 // 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__ diff --git a/src/graphicprimitives.cpp b/src/graphicprimitives.cpp index 6eb84a2..82e15ab 100755 --- a/src/graphicprimitives.cpp +++ b/src/graphicprimitives.cpp @@ -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); } diff --git a/src/graphicprimitives.h b/src/graphicprimitives.h index 81e15ab..1513ebb 100755 --- a/src/graphicprimitives.h +++ b/src/graphicprimitives.h @@ -8,7 +8,7 @@ #ifndef __GRAPHICPRIMITIVES_H__ #define __GRAPHICPRIMITIVES_H__ -#include // For device context +#include // 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 index 576207a..0000000 --- a/src/registry.cpp +++ /dev/null @@ -1,94 +0,0 @@ -// -// REGISTRY.CPP - Win32 support file -// by James L. Hammons -// (C) 2002 Underground Software -// -// JLH = James Hammons -// -// 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 -#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 index 526713b..0000000 --- a/src/registry.h +++ /dev/null @@ -1,22 +0,0 @@ -// -// REGISTRY.H - Win32 support file header -// by James L. Hammons -// (C) 2002 Underground Software -// -// JLH = James Hammons -// - -#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__ diff --git a/src/toolwindow.cpp b/src/toolwindow.cpp index 80f90e4..75eaa0e 100755 --- a/src/toolwindow.cpp +++ b/src/toolwindow.cpp @@ -8,6 +8,7 @@ // Who When What // --- ---------- ------------------------------------------------------------- // JLH 08/28/2008 Created this file +// JLH 03/11/2009 Converted from wxWidgets to Qt // // FIXED: @@ -24,53 +25,38 @@ #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; diff --git a/src/toolwindow.h b/src/toolwindow.h index d4eab9f..1623eb4 100755 --- a/src/toolwindow.h +++ b/src/toolwindow.h @@ -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 // So that whoever uses this can without having - // to pull in a bunch of references manually +#include -// 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 index 9efa641..0000000 --- a/src/tte_res.h +++ /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 - diff --git a/src/ttedit.cpp b/src/ttedit.cpp index 17617f1..c812377 100755 --- a/src/ttedit.cpp +++ b/src/ttedit.cpp @@ -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: @@ -34,6 +35,118 @@ #define DEBUGFOO // Various tool debugging... #define DEBUGTP // Toolpalette debugging... +//#include +#include "ttedit.h" +#include +#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 diff --git a/src/ttedit.h b/src/ttedit.h index fc0fb3e..d92c33a 100755 --- a/src/ttedit.h +++ b/src/ttedit.h @@ -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 // So that whoever uses this can without having +//Hrm. uh??? I thought this wasn't the way to do this stuff...??? +#include + +#if 0 +//#include // 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 index 0000000..7315add --- /dev/null +++ b/ttedit.pro @@ -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 index 0000000..ca2b69b --- /dev/null +++ b/ttedit.qrc @@ -0,0 +1,18 @@ + + + res/cursor1.png + res/cursor2.png + res/cursor3.png + res/cursor4.png + res/cursor5.png + res/cursor6.png + res/cursor7.png + res/cursor8.png + res/act-back.png + res/act-forward.png + res/act-charwin.png + res/toolpal1.png + res/toolpal1.xpm + res/ttedit.png + + -- 2.37.2