lots'o' wxpython modules files
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3345 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
05394a18d4
commit
4b123bb9cc
365
utils/wxPython/modules/glcanvas/Makefile.pre.in
Normal file
365
utils/wxPython/modules/glcanvas/Makefile.pre.in
Normal file
@ -0,0 +1,365 @@
|
||||
# Universal Unix Makefile for Python extensions
|
||||
# =============================================
|
||||
|
||||
# Short Instructions
|
||||
# ------------------
|
||||
|
||||
# 1. Build and install Python (1.5 or newer).
|
||||
# 2. "make -f Makefile.pre.in boot"
|
||||
# 3. "make"
|
||||
# You should now have a shared library.
|
||||
|
||||
# Long Instructions
|
||||
# -----------------
|
||||
|
||||
# Build *and install* the basic Python 1.5 distribution. See the
|
||||
# Python README for instructions. (This version of Makefile.pre.in
|
||||
# only withs with Python 1.5, alpha 3 or newer.)
|
||||
|
||||
# Create a file Setup.in for your extension. This file follows the
|
||||
# format of the Modules/Setup.in file; see the instructions there.
|
||||
# For a simple module called "spam" on file "spammodule.c", it can
|
||||
# contain a single line:
|
||||
# spam spammodule.c
|
||||
# You can build as many modules as you want in the same directory --
|
||||
# just have a separate line for each of them in the Setup.in file.
|
||||
|
||||
# If you want to build your extension as a shared library, insert a
|
||||
# line containing just the string
|
||||
# *shared*
|
||||
# at the top of your Setup.in file.
|
||||
|
||||
# Note that the build process copies Setup.in to Setup, and then works
|
||||
# with Setup. It doesn't overwrite Setup when Setup.in is changed, so
|
||||
# while you're in the process of debugging your Setup.in file, you may
|
||||
# want to edit Setup instead, and copy it back to Setup.in later.
|
||||
# (All this is done so you can distribute your extension easily and
|
||||
# someone else can select the modules they actually want to build by
|
||||
# commenting out lines in the Setup file, without editing the
|
||||
# original. Editing Setup is also used to specify nonstandard
|
||||
# locations for include or library files.)
|
||||
|
||||
# Copy this file (Misc/Makefile.pre.in) to the directory containing
|
||||
# your extension.
|
||||
|
||||
# Run "make -f Makefile.pre.in boot". This creates Makefile
|
||||
# (producing Makefile.pre and sedscript as intermediate files) and
|
||||
# config.c, incorporating the values for sys.prefix, sys.exec_prefix
|
||||
# and sys.version from the installed Python binary. For this to work,
|
||||
# the python binary must be on your path. If this fails, try
|
||||
# make -f Makefile.pre.in Makefile VERSION=1.5 installdir=<prefix>
|
||||
# where <prefix> is the prefix used to install Python for installdir
|
||||
# (and possibly similar for exec_installdir=<exec_prefix>).
|
||||
|
||||
# Note: "make boot" implies "make clobber" -- it assumes that when you
|
||||
# bootstrap you may have changed platforms so it removes all previous
|
||||
# output files.
|
||||
|
||||
# If you are building your extension as a shared library (your
|
||||
# Setup.in file starts with *shared*), run "make" or "make sharedmods"
|
||||
# to build the shared library files. If you are building a statically
|
||||
# linked Python binary (the only solution of your platform doesn't
|
||||
# support shared libraries, and sometimes handy if you want to
|
||||
# distribute or install the resulting Python binary), run "make
|
||||
# python".
|
||||
|
||||
# Note: Each time you edit Makefile.pre.in or Setup, you must run
|
||||
# "make Makefile" before running "make".
|
||||
|
||||
# Hint: if you want to use VPATH, you can start in an empty
|
||||
# subdirectory and say (e.g.):
|
||||
# make -f ../Makefile.pre.in boot srcdir=.. VPATH=..
|
||||
|
||||
|
||||
# === Bootstrap variables (edited through "make boot") ===
|
||||
|
||||
# The prefix used by "make inclinstall libainstall" of core python
|
||||
installdir= /usr/local
|
||||
|
||||
# The exec_prefix used by the same
|
||||
exec_installdir=$(installdir)
|
||||
|
||||
# Source directory and VPATH in case you want to use VPATH.
|
||||
# (You will have to edit these two lines yourself -- there is no
|
||||
# automatic support as the Makefile is not generated by
|
||||
# config.status.)
|
||||
srcdir= .
|
||||
VPATH= .
|
||||
|
||||
# === Variables that you may want to customize (rarely) ===
|
||||
|
||||
# (Static) build target
|
||||
TARGET= python
|
||||
|
||||
# Installed python binary (used only by boot target)
|
||||
PYTHON= python
|
||||
|
||||
# Add more -I and -D options here
|
||||
CFLAGS= $(OPT) -I$(INCLUDEPY) -I$(EXECINCLUDEPY) $(DEFS)
|
||||
|
||||
# These two variables can be set in Setup to merge extensions.
|
||||
# See example[23].
|
||||
BASELIB=
|
||||
BASESETUP=
|
||||
|
||||
# === Variables set by makesetup ===
|
||||
|
||||
MODOBJS= _MODOBJS_
|
||||
MODLIBS= _MODLIBS_
|
||||
|
||||
# === Definitions added by makesetup ===
|
||||
|
||||
# === Variables from configure (through sedscript) ===
|
||||
|
||||
VERSION= @VERSION@
|
||||
CC= @CC@
|
||||
LINKCC= @LINKCC@
|
||||
SGI_ABI= @SGI_ABI@
|
||||
OPT= @OPT@
|
||||
LDFLAGS= @LDFLAGS@
|
||||
LDLAST= @LDLAST@
|
||||
DEFS= @DEFS@
|
||||
LIBS= @LIBS@
|
||||
LIBM= @LIBM@
|
||||
LIBC= @LIBC@
|
||||
RANLIB= @RANLIB@
|
||||
MACHDEP= @MACHDEP@
|
||||
SO= @SO@
|
||||
LDSHARED= @LDSHARED@
|
||||
CCSHARED= @CCSHARED@
|
||||
LINKFORSHARED= @LINKFORSHARED@
|
||||
#@SET_CCC@
|
||||
|
||||
# Install prefix for architecture-independent files
|
||||
prefix= /usr/local
|
||||
|
||||
# Install prefix for architecture-dependent files
|
||||
exec_prefix= $(prefix)
|
||||
|
||||
# === Fixed definitions ===
|
||||
|
||||
# Shell used by make (some versions default to the login shell, which is bad)
|
||||
SHELL= /bin/sh
|
||||
|
||||
# Expanded directories
|
||||
BINDIR= $(exec_installdir)/bin
|
||||
LIBDIR= $(exec_prefix)/lib
|
||||
MANDIR= $(installdir)/man
|
||||
INCLUDEDIR= $(installdir)/include
|
||||
SCRIPTDIR= $(prefix)/lib
|
||||
|
||||
# Detailed destination directories
|
||||
BINLIBDEST= $(LIBDIR)/python$(VERSION)
|
||||
LIBDEST= $(SCRIPTDIR)/python$(VERSION)
|
||||
INCLUDEPY= $(INCLUDEDIR)/python$(VERSION)
|
||||
EXECINCLUDEPY= $(exec_installdir)/include/python$(VERSION)
|
||||
LIBP= $(exec_installdir)/lib/python$(VERSION)
|
||||
DESTSHARED= $(BINLIBDEST)/site-packages
|
||||
|
||||
LIBPL= $(LIBP)/config
|
||||
|
||||
PYTHONLIBS= $(LIBPL)/libpython$(VERSION).a
|
||||
|
||||
MAKESETUP= $(LIBPL)/makesetup
|
||||
MAKEFILE= $(LIBPL)/Makefile
|
||||
CONFIGC= $(LIBPL)/config.c
|
||||
CONFIGCIN= $(LIBPL)/config.c.in
|
||||
SETUP= $(LIBPL)/Setup
|
||||
|
||||
SYSLIBS= $(LIBM) $(LIBC)
|
||||
|
||||
ADDOBJS= $(LIBPL)/python.o config.o
|
||||
|
||||
# Portable install script (configure doesn't always guess right)
|
||||
INSTALL= $(LIBPL)/install-sh -c
|
||||
# Shared libraries must be installed with executable mode on some systems;
|
||||
# rather than figuring out exactly which, we always give them executable mode.
|
||||
# Also, making them read-only seems to be a good idea...
|
||||
INSTALL_SHARED= ${INSTALL} -m 555
|
||||
|
||||
#---------------------------------------------------
|
||||
# Possibly change some definintions for C++
|
||||
ifdef MY_LDSHARED
|
||||
LDSHARED=$(MY_LDSHARED)
|
||||
endif
|
||||
ifdef MY_LINKCC
|
||||
LINKCC=$(MY_LINKCC)
|
||||
endif
|
||||
|
||||
|
||||
# === Fixed rules ===
|
||||
|
||||
# Default target. This builds shared libraries only
|
||||
default: sharedmods
|
||||
|
||||
# Build everything
|
||||
all: static sharedmods
|
||||
|
||||
# Build shared libraries from our extension modules
|
||||
sharedmods: $(SHAREDMODS)
|
||||
|
||||
# Build a static Python binary containing our extension modules
|
||||
static: $(TARGET)
|
||||
$(TARGET): $(ADDOBJS) lib.a $(PYTHONLIBS) Makefile $(BASELIB)
|
||||
$(LINKCC) $(LDFLAGS) $(LINKFORSHARED) \
|
||||
$(ADDOBJS) lib.a $(PYTHONLIBS) \
|
||||
$(LINKPATH) $(BASELIB) $(MODLIBS) $(LIBS) $(SYSLIBS) \
|
||||
-o $(TARGET) $(LDLAST)
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#------------------------------------------------------------------------
|
||||
# This is a default version of the install target for wxPython. It just
|
||||
# redirects to wxInstall below...
|
||||
|
||||
install: wxInstall
|
||||
|
||||
#install: sharedmods
|
||||
# if test ! -d $(DESTSHARED) ; then \
|
||||
# mkdir $(DESTSHARED) ; else true ; fi
|
||||
# -for i in X $(SHAREDMODS); do \
|
||||
# if test $$i != X; \
|
||||
# then $(INSTALL_SHARED) $$i $(DESTSHARED)/$$i; \
|
||||
# fi; \
|
||||
# done
|
||||
|
||||
|
||||
# Build the library containing our extension modules
|
||||
lib.a: $(MODOBJS)
|
||||
-rm -f lib.a
|
||||
ar cr lib.a $(MODOBJS)
|
||||
-$(RANLIB) lib.a
|
||||
|
||||
# This runs makesetup *twice* to use the BASESETUP definition from Setup
|
||||
config.c Makefile: Makefile.pre Setup $(BASESETUP) $(MAKESETUP)
|
||||
$(MAKESETUP) \
|
||||
-m Makefile.pre -c $(CONFIGCIN) Setup -n $(BASESETUP) $(SETUP)
|
||||
$(MAKE) -f Makefile do-it-again
|
||||
|
||||
# Internal target to run makesetup for the second time
|
||||
do-it-again:
|
||||
$(MAKESETUP) \
|
||||
-m Makefile.pre -c $(CONFIGCIN) Setup -n $(BASESETUP) $(SETUP)
|
||||
|
||||
# Make config.o from the config.c created by makesetup
|
||||
config.o: config.c
|
||||
$(CC) $(CFLAGS) -c config.c
|
||||
|
||||
# Setup is copied from Setup.in *only* if it doesn't yet exist
|
||||
Setup:
|
||||
cp Setup.in Setup
|
||||
|
||||
# Make the intermediate Makefile.pre from Makefile.pre.in
|
||||
Makefile.pre: Makefile.pre.in sedscript
|
||||
sed -f sedscript Makefile.pre.in >Makefile.pre
|
||||
|
||||
# Shortcuts to make the sed arguments on one line
|
||||
P=prefix
|
||||
E=exec_prefix
|
||||
H=Generated automatically from Makefile.pre.in by sedscript.
|
||||
L=LINKFORSHARED
|
||||
|
||||
# Make the sed script used to create Makefile.pre from Makefile.pre.in
|
||||
sedscript: $(MAKEFILE)
|
||||
sed -n \
|
||||
-e '1s/.*/1i\\/p' \
|
||||
-e '2s%.*%# $H%p' \
|
||||
-e '/^VERSION=/s/^VERSION=[ ]*\(.*\)/s%@VERSION[@]%\1%/p' \
|
||||
-e '/^CC=/s/^CC=[ ]*\(.*\)/s%@CC[@]%\1%/p' \
|
||||
-e '/^CCC=/s/^CCC=[ ]*\(.*\)/s%#@SET_CCC[@]%CCC=\1%/p' \
|
||||
-e '/^LINKCC=/s/^LINKCC=[ ]*\(.*\)/s%@LINKCC[@]%\1%/p' \
|
||||
-e '/^OPT=/s/^OPT=[ ]*\(.*\)/s%@OPT[@]%\1%/p' \
|
||||
-e '/^LDFLAGS=/s/^LDFLAGS=[ ]*\(.*\)/s%@LDFLAGS[@]%\1%/p' \
|
||||
-e '/^DEFS=/s/^DEFS=[ ]*\(.*\)/s%@DEFS[@]%\1%/p' \
|
||||
-e '/^LIBS=/s/^LIBS=[ ]*\(.*\)/s%@LIBS[@]%\1%/p' \
|
||||
-e '/^LIBM=/s/^LIBM=[ ]*\(.*\)/s%@LIBM[@]%\1%/p' \
|
||||
-e '/^LIBC=/s/^LIBC=[ ]*\(.*\)/s%@LIBC[@]%\1%/p' \
|
||||
-e '/^RANLIB=/s/^RANLIB=[ ]*\(.*\)/s%@RANLIB[@]%\1%/p' \
|
||||
-e '/^MACHDEP=/s/^MACHDEP=[ ]*\(.*\)/s%@MACHDEP[@]%\1%/p' \
|
||||
-e '/^SO=/s/^SO=[ ]*\(.*\)/s%@SO[@]%\1%/p' \
|
||||
-e '/^LDSHARED=/s/^LDSHARED=[ ]*\(.*\)/s%@LDSHARED[@]%\1%/p' \
|
||||
-e '/^CCSHARED=/s/^CCSHARED=[ ]*\(.*\)/s%@CCSHARED[@]%\1%/p' \
|
||||
-e '/^$L=/s/^$L=[ ]*\(.*\)/s%@$L[@]%\1%/p' \
|
||||
-e '/^$P=/s/^$P=\(.*\)/s%^$P=.*%$P=\1%/p' \
|
||||
-e '/^$E=/s/^$E=\(.*\)/s%^$E=.*%$E=\1%/p' \
|
||||
$(MAKEFILE) >sedscript
|
||||
echo "/^#@SET_CCC@/d" >>sedscript
|
||||
echo "/^installdir=/s%=.*%= $(installdir)%" >>sedscript
|
||||
echo "/^exec_installdir=/s%=.*%=$(exec_installdir)%" >>sedscript
|
||||
echo "/^srcdir=/s%=.*%= $(srcdir)%" >>sedscript
|
||||
echo "/^VPATH=/s%=.*%= $(VPATH)%" >>sedscript
|
||||
echo "/^LINKPATH=/s%=.*%= $(LINKPATH)%" >>sedscript
|
||||
echo "/^BASELIB=/s%=.*%= $(BASELIB)%" >>sedscript
|
||||
echo "/^BASESETUP=/s%=.*%= $(BASESETUP)%" >>sedscript
|
||||
|
||||
# Bootstrap target
|
||||
boot: clobber
|
||||
VERSION=`$(PYTHON) -c "import sys; print sys.version[:3]"`; \
|
||||
installdir=`$(PYTHON) -c "import sys; print sys.prefix"`; \
|
||||
exec_installdir=`$(PYTHON) -c "import sys; print sys.exec_prefix"`; \
|
||||
$(MAKE) -f Makefile.pre.in VPATH=$(VPATH) srcdir=$(srcdir) \
|
||||
VERSION=$$VERSION \
|
||||
installdir=$$installdir \
|
||||
exec_installdir=$$exec_installdir \
|
||||
Makefile
|
||||
|
||||
# Handy target to remove intermediate files and backups
|
||||
clean:
|
||||
-rm -f *.o *~
|
||||
|
||||
# Handy target to remove everything that is easily regenerated
|
||||
clobber: clean
|
||||
-rm -f *.a tags TAGS config.c Makefile.pre $(TARGET) sedscript
|
||||
-rm -f *.so *.sl so_locations
|
||||
|
||||
|
||||
# Handy target to remove everything you don't want to distribute
|
||||
distclean: clobber
|
||||
-rm -f Makefile Setup
|
||||
|
||||
|
||||
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#------------------------------------------------------------------------
|
||||
# Custom rules and dependencies added for wxPython
|
||||
#
|
||||
|
||||
WXP_VERSION=2.1b2
|
||||
|
||||
# WXP_SRCDIR=../wxPython/src
|
||||
|
||||
SWIGFLAGS=-c++ -shadow -python -dnone -I$(WXP_SRCDIR) -D__WXGTK__ $(SEPARATE)
|
||||
|
||||
|
||||
# Implicit rules to run SWIG
|
||||
$(GENCODEDIR)/%.cpp : %.i
|
||||
swig $(SWIGFLAGS) -c -o $@ $<
|
||||
|
||||
$(GENCODEDIR)/%.py : %.i
|
||||
swig $(SWIGFLAGS) -c -o $@ $<
|
||||
$(GENCODEDIR)/%.py : %.i
|
||||
swig $(SWIGFLAGS) -c -o $(GENCODEDIR)/tmp_wrap.cpp $<
|
||||
rm $(GENCODEDIR)/tmp_wrap.cpp
|
||||
|
||||
|
||||
wxInstall : sharedmods $(PYMODULES)
|
||||
if test ! -d $(TARGETDIR) ; then \
|
||||
mkdir $(TARGETDIR) ; else true ; fi
|
||||
if [ "$(SHAREDMODS)" != "" ]; then \
|
||||
chmod 755 $(SHAREDMODS); \
|
||||
cp $(SHAREDMODS) $(TARGETDIR); fi
|
||||
-for i in $(PYMODULES); do \
|
||||
cp $$i $(TARGETDIR); \
|
||||
done
|
||||
if [ "$(TARGETDIR)" != ".." ]; then \
|
||||
python $(LIBDEST)/compileall.py $(TARGETDIR); \
|
||||
python -O $(LIBDEST)/compileall.py $(TARGETDIR); \
|
||||
else \
|
||||
python $(LIBDEST)/compileall.py -l $(TARGETDIR); \
|
||||
python -O $(LIBDEST)/compileall.py -l $(TARGETDIR);\
|
||||
fi
|
||||
|
||||
$(GENCODEDIR)/_glcanvas.cpp:
|
||||
-cp $(WXWIN)/utils/glcanvas/$(GENCODEDIR)/glcanvas.cpp $@
|
||||
-cp $(WXWIN)/utils/glcanvas/$(GENCODEDIR)/glcanvas.h $(GENCODEDIR)/glcanvas.h
|
||||
|
52
utils/wxPython/modules/glcanvas/Setup.in
Normal file
52
utils/wxPython/modules/glcanvas/Setup.in
Normal file
@ -0,0 +1,52 @@
|
||||
## This file gives the details of what is needed to build this extension
|
||||
## module so the Makefile can be created.
|
||||
|
||||
## If you have not done "make install" for wxWindows then see Setup.in.linux
|
||||
## for a more verbose version of this file.
|
||||
|
||||
*shared*
|
||||
|
||||
CCC=c++
|
||||
WXWIN=../../../..
|
||||
GENCODEDIR=gtk
|
||||
# srcdir=$(GENCODEDIR)
|
||||
WX_CONFIG_CFLAGS=`wx-config --cflags`
|
||||
WX_CONFIG_LIBS=`wx-config --libs`
|
||||
|
||||
|
||||
## Depending on how your Python was built, you may have to set this
|
||||
## value to use the C++ driver to link with instead of the default
|
||||
## C driver. For example:
|
||||
MY_LDSHARED=$(CCC) -shared
|
||||
|
||||
## Same as above, but for statically linking Python and wxPython together,
|
||||
## in other words, if you comment out the *shared* above. If this is the
|
||||
## case then you should ensure that the main() function is Python's, not
|
||||
## wxWindows'. You can rebuild $(WXWIN)/src/gtk/app.cpp with NOMAIN defined
|
||||
## to force this...
|
||||
MY_LINKCC=$(CCC)
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
#
|
||||
# Below follow settings that may be specific for a wxPython module
|
||||
#
|
||||
#--------------------------------------------------------------------
|
||||
|
||||
## Pick one of these, or set your own. This is where the wxPython module
|
||||
## should be installed. It should be a subdirectory named wxPython.
|
||||
#TARGETDIR=../..
|
||||
TARGETDIR=$(BINLIBDEST)/site-packages/wxPython
|
||||
|
||||
# The location of the wxPython source dir
|
||||
WXP_SRCDIR=../../src
|
||||
|
||||
# These defines are usually best left alone
|
||||
C_DEFINES = -DSWIG_GLOBAL -DWXP_USE_THREAD -DSEPARATE
|
||||
C_FLAGS = -I. -I$(WXP_SRCDIR) $(WX_CONFIG_CFLAGS)
|
||||
# Add a couple of GL libraries
|
||||
C_LIBS = -lwxPyHelpers -lMesaGL -lMesaGLU $(WX_CONFIG_LIBS)
|
||||
|
||||
PYMODULES = $(GENCODEDIR)/glcanvas.py
|
||||
|
||||
glcanvasc $(GENCODEDIR)/glcanvas.cpp $(GENCODEDIR)/_glcanvas.cpp \
|
||||
$(C_DEFINES) $(C_FLAGS) -Xlinker $(C_LIBS)
|
1104
utils/wxPython/modules/glcanvas/glcanvas.i
Normal file
1104
utils/wxPython/modules/glcanvas/glcanvas.i
Normal file
File diff suppressed because it is too large
Load Diff
2
utils/wxPython/modules/glcanvas/glcanvasc.def
Normal file
2
utils/wxPython/modules/glcanvas/glcanvasc.def
Normal file
@ -0,0 +1,2 @@
|
||||
EXPORTS
|
||||
initglcanvasc
|
38
utils/wxPython/modules/glcanvas/makefile.vc
Normal file
38
utils/wxPython/modules/glcanvas/makefile.vc
Normal file
@ -0,0 +1,38 @@
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
TARGET = glcanvasc
|
||||
|
||||
OBJECTS = glcanvas.obj
|
||||
|
||||
PYMODULES = $(TARGETDIR)\html.py $(TARGETDIR)\htmlhelper.py
|
||||
|
||||
SOURCES = $(GENCODEDIR)\html.cpp
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
!include ..\makeinc.vc
|
||||
|
||||
# override this
|
||||
EXTRAINC = $(EXTRAINC) -I$(WXDIR)\utils\glcanvas\win
|
||||
GLLIBS=$(WXDIR)\lib\glcanvas.lib glu32.lib opengl32.lib
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
default: $(TARGETDIR)\$(TARGET).pyd pycfiles
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
$(TARGETDIR)\$(TARGET).pyd : $(DUMMYOBJ) $(WXLIB) $(OBJECTS) # $(TARGET).res
|
||||
$(link) @<<
|
||||
/out:$@ /dll
|
||||
$(LFLAGS) /def:$(TARGET).def /implib:./$(TARGET).lib
|
||||
$(DUMMYOBJ) $(OBJECTS)
|
||||
$(LIBS) $(GLLIBS)
|
||||
<<
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
23
utils/wxPython/modules/html/BUGS
Normal file
23
utils/wxPython/modules/html/BUGS
Normal file
@ -0,0 +1,23 @@
|
||||
Known bugs
|
||||
|
||||
html, all:
|
||||
- keys can move the vertical scrollbar, but the window moveth not.
|
||||
problem in wxHTML.
|
||||
|
||||
- widgets are not removed when the HTML contents is changed
|
||||
(this can be fixed by adding ~HtmlWidgetCell { wnd->Destroy(); } )
|
||||
|
||||
- potential problem with the use of ThreadState in html.i
|
||||
(mainly because I don't really know what I'm doing there)
|
||||
|
||||
html, msw:
|
||||
- vertical scrollbar behaves erratically when content smaller than
|
||||
window
|
||||
|
||||
- page with widgets takes forever to draw when constructed
|
||||
in frame constructor
|
||||
|
||||
- sometimes the python scripts with html crash on startup, before
|
||||
the window is displayed (illegal operation). this seems mainly to
|
||||
happen when the various libs are not yet in the disk cache. race
|
||||
condition?
|
363
utils/wxPython/modules/html/Makefile.pre.in
Normal file
363
utils/wxPython/modules/html/Makefile.pre.in
Normal file
@ -0,0 +1,363 @@
|
||||
# Universal Unix Makefile for Python extensions
|
||||
# =============================================
|
||||
|
||||
# Short Instructions
|
||||
# ------------------
|
||||
|
||||
# 1. Build and install Python (1.5 or newer).
|
||||
# 2. "make -f Makefile.pre.in boot"
|
||||
# 3. "make"
|
||||
# You should now have a shared library.
|
||||
|
||||
# Long Instructions
|
||||
# -----------------
|
||||
|
||||
# Build *and install* the basic Python 1.5 distribution. See the
|
||||
# Python README for instructions. (This version of Makefile.pre.in
|
||||
# only withs with Python 1.5, alpha 3 or newer.)
|
||||
|
||||
# Create a file Setup.in for your extension. This file follows the
|
||||
# format of the Modules/Setup.in file; see the instructions there.
|
||||
# For a simple module called "spam" on file "spammodule.c", it can
|
||||
# contain a single line:
|
||||
# spam spammodule.c
|
||||
# You can build as many modules as you want in the same directory --
|
||||
# just have a separate line for each of them in the Setup.in file.
|
||||
|
||||
# If you want to build your extension as a shared library, insert a
|
||||
# line containing just the string
|
||||
# *shared*
|
||||
# at the top of your Setup.in file.
|
||||
|
||||
# Note that the build process copies Setup.in to Setup, and then works
|
||||
# with Setup. It doesn't overwrite Setup when Setup.in is changed, so
|
||||
# while you're in the process of debugging your Setup.in file, you may
|
||||
# want to edit Setup instead, and copy it back to Setup.in later.
|
||||
# (All this is done so you can distribute your extension easily and
|
||||
# someone else can select the modules they actually want to build by
|
||||
# commenting out lines in the Setup file, without editing the
|
||||
# original. Editing Setup is also used to specify nonstandard
|
||||
# locations for include or library files.)
|
||||
|
||||
# Copy this file (Misc/Makefile.pre.in) to the directory containing
|
||||
# your extension.
|
||||
|
||||
# Run "make -f Makefile.pre.in boot". This creates Makefile
|
||||
# (producing Makefile.pre and sedscript as intermediate files) and
|
||||
# config.c, incorporating the values for sys.prefix, sys.exec_prefix
|
||||
# and sys.version from the installed Python binary. For this to work,
|
||||
# the python binary must be on your path. If this fails, try
|
||||
# make -f Makefile.pre.in Makefile VERSION=1.5 installdir=<prefix>
|
||||
# where <prefix> is the prefix used to install Python for installdir
|
||||
# (and possibly similar for exec_installdir=<exec_prefix>).
|
||||
|
||||
# Note: "make boot" implies "make clobber" -- it assumes that when you
|
||||
# bootstrap you may have changed platforms so it removes all previous
|
||||
# output files.
|
||||
|
||||
# If you are building your extension as a shared library (your
|
||||
# Setup.in file starts with *shared*), run "make" or "make sharedmods"
|
||||
# to build the shared library files. If you are building a statically
|
||||
# linked Python binary (the only solution of your platform doesn't
|
||||
# support shared libraries, and sometimes handy if you want to
|
||||
# distribute or install the resulting Python binary), run "make
|
||||
# python".
|
||||
|
||||
# Note: Each time you edit Makefile.pre.in or Setup, you must run
|
||||
# "make Makefile" before running "make".
|
||||
|
||||
# Hint: if you want to use VPATH, you can start in an empty
|
||||
# subdirectory and say (e.g.):
|
||||
# make -f ../Makefile.pre.in boot srcdir=.. VPATH=..
|
||||
|
||||
|
||||
# === Bootstrap variables (edited through "make boot") ===
|
||||
|
||||
# The prefix used by "make inclinstall libainstall" of core python
|
||||
installdir= /usr/local
|
||||
|
||||
# The exec_prefix used by the same
|
||||
exec_installdir=$(installdir)
|
||||
|
||||
# Source directory and VPATH in case you want to use VPATH.
|
||||
# (You will have to edit these two lines yourself -- there is no
|
||||
# automatic support as the Makefile is not generated by
|
||||
# config.status.)
|
||||
srcdir= .
|
||||
VPATH= .
|
||||
|
||||
# === Variables that you may want to customize (rarely) ===
|
||||
|
||||
# (Static) build target
|
||||
TARGET= python
|
||||
|
||||
# Installed python binary (used only by boot target)
|
||||
PYTHON= python
|
||||
|
||||
# Add more -I and -D options here
|
||||
CFLAGS= $(OPT) -I$(INCLUDEPY) -I$(EXECINCLUDEPY) $(DEFS)
|
||||
|
||||
# These two variables can be set in Setup to merge extensions.
|
||||
# See example[23].
|
||||
BASELIB=
|
||||
BASESETUP=
|
||||
|
||||
# === Variables set by makesetup ===
|
||||
|
||||
MODOBJS= _MODOBJS_
|
||||
MODLIBS= _MODLIBS_
|
||||
|
||||
# === Definitions added by makesetup ===
|
||||
|
||||
# === Variables from configure (through sedscript) ===
|
||||
|
||||
VERSION= @VERSION@
|
||||
CC= @CC@
|
||||
LINKCC= @LINKCC@
|
||||
SGI_ABI= @SGI_ABI@
|
||||
OPT= @OPT@
|
||||
LDFLAGS= @LDFLAGS@
|
||||
LDLAST= @LDLAST@
|
||||
DEFS= @DEFS@
|
||||
LIBS= @LIBS@
|
||||
LIBM= @LIBM@
|
||||
LIBC= @LIBC@
|
||||
RANLIB= @RANLIB@
|
||||
MACHDEP= @MACHDEP@
|
||||
SO= @SO@
|
||||
LDSHARED= @LDSHARED@
|
||||
CCSHARED= @CCSHARED@
|
||||
LINKFORSHARED= @LINKFORSHARED@
|
||||
#@SET_CCC@
|
||||
|
||||
# Install prefix for architecture-independent files
|
||||
prefix= /usr/local
|
||||
|
||||
# Install prefix for architecture-dependent files
|
||||
exec_prefix= $(prefix)
|
||||
|
||||
# === Fixed definitions ===
|
||||
|
||||
# Shell used by make (some versions default to the login shell, which is bad)
|
||||
SHELL= /bin/sh
|
||||
|
||||
# Expanded directories
|
||||
BINDIR= $(exec_installdir)/bin
|
||||
LIBDIR= $(exec_prefix)/lib
|
||||
MANDIR= $(installdir)/man
|
||||
INCLUDEDIR= $(installdir)/include
|
||||
SCRIPTDIR= $(prefix)/lib
|
||||
|
||||
# Detailed destination directories
|
||||
BINLIBDEST= $(LIBDIR)/python$(VERSION)
|
||||
LIBDEST= $(SCRIPTDIR)/python$(VERSION)
|
||||
INCLUDEPY= $(INCLUDEDIR)/python$(VERSION)
|
||||
EXECINCLUDEPY= $(exec_installdir)/include/python$(VERSION)
|
||||
LIBP= $(exec_installdir)/lib/python$(VERSION)
|
||||
DESTSHARED= $(BINLIBDEST)/site-packages
|
||||
|
||||
LIBPL= $(LIBP)/config
|
||||
|
||||
PYTHONLIBS= $(LIBPL)/libpython$(VERSION).a
|
||||
|
||||
MAKESETUP= $(LIBPL)/makesetup
|
||||
MAKEFILE= $(LIBPL)/Makefile
|
||||
CONFIGC= $(LIBPL)/config.c
|
||||
CONFIGCIN= $(LIBPL)/config.c.in
|
||||
SETUP= $(LIBPL)/Setup
|
||||
|
||||
SYSLIBS= $(LIBM) $(LIBC)
|
||||
|
||||
ADDOBJS= $(LIBPL)/python.o config.o
|
||||
|
||||
# Portable install script (configure doesn't always guess right)
|
||||
INSTALL= $(LIBPL)/install-sh -c
|
||||
# Shared libraries must be installed with executable mode on some systems;
|
||||
# rather than figuring out exactly which, we always give them executable mode.
|
||||
# Also, making them read-only seems to be a good idea...
|
||||
INSTALL_SHARED= ${INSTALL} -m 555
|
||||
|
||||
#---------------------------------------------------
|
||||
# Possibly change some definintions for C++
|
||||
ifdef MY_LDSHARED
|
||||
LDSHARED=$(MY_LDSHARED)
|
||||
endif
|
||||
ifdef MY_LINKCC
|
||||
LINKCC=$(MY_LINKCC)
|
||||
endif
|
||||
|
||||
|
||||
# === Fixed rules ===
|
||||
|
||||
# Default target. This builds shared libraries only
|
||||
default: sharedmods
|
||||
|
||||
# Build everything
|
||||
all: static sharedmods
|
||||
|
||||
# Build shared libraries from our extension modules
|
||||
sharedmods: $(SHAREDMODS)
|
||||
|
||||
# Build a static Python binary containing our extension modules
|
||||
static: $(TARGET)
|
||||
$(TARGET): $(ADDOBJS) lib.a $(PYTHONLIBS) Makefile $(BASELIB)
|
||||
$(LINKCC) $(LDFLAGS) $(LINKFORSHARED) \
|
||||
$(ADDOBJS) lib.a $(PYTHONLIBS) \
|
||||
$(LINKPATH) $(BASELIB) $(MODLIBS) $(LIBS) $(SYSLIBS) \
|
||||
-o $(TARGET) $(LDLAST)
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#------------------------------------------------------------------------
|
||||
# This is a default version of the install target for wxPython. It just
|
||||
# redirects to wxInstall below...
|
||||
|
||||
install: wxInstall
|
||||
|
||||
#install: sharedmods
|
||||
# if test ! -d $(DESTSHARED) ; then \
|
||||
# mkdir $(DESTSHARED) ; else true ; fi
|
||||
# -for i in X $(SHAREDMODS); do \
|
||||
# if test $$i != X; \
|
||||
# then $(INSTALL_SHARED) $$i $(DESTSHARED)/$$i; \
|
||||
# fi; \
|
||||
# done
|
||||
|
||||
|
||||
# Build the library containing our extension modules
|
||||
lib.a: $(MODOBJS)
|
||||
-rm -f lib.a
|
||||
ar cr lib.a $(MODOBJS)
|
||||
-$(RANLIB) lib.a
|
||||
|
||||
# This runs makesetup *twice* to use the BASESETUP definition from Setup
|
||||
config.c Makefile: Makefile.pre Setup $(BASESETUP) $(MAKESETUP)
|
||||
$(MAKESETUP) \
|
||||
-m Makefile.pre -c $(CONFIGCIN) Setup -n $(BASESETUP) $(SETUP)
|
||||
$(MAKE) -f Makefile do-it-again
|
||||
|
||||
# Internal target to run makesetup for the second time
|
||||
do-it-again:
|
||||
$(MAKESETUP) \
|
||||
-m Makefile.pre -c $(CONFIGCIN) Setup -n $(BASESETUP) $(SETUP)
|
||||
|
||||
# Make config.o from the config.c created by makesetup
|
||||
config.o: config.c
|
||||
$(CC) $(CFLAGS) -c config.c
|
||||
|
||||
# Setup is copied from Setup.in *only* if it doesn't yet exist
|
||||
Setup:
|
||||
cp Setup.in Setup
|
||||
|
||||
# Make the intermediate Makefile.pre from Makefile.pre.in
|
||||
Makefile.pre: Makefile.pre.in sedscript
|
||||
sed -f sedscript Makefile.pre.in >Makefile.pre
|
||||
|
||||
# Shortcuts to make the sed arguments on one line
|
||||
P=prefix
|
||||
E=exec_prefix
|
||||
H=Generated automatically from Makefile.pre.in by sedscript.
|
||||
L=LINKFORSHARED
|
||||
|
||||
# Make the sed script used to create Makefile.pre from Makefile.pre.in
|
||||
sedscript: $(MAKEFILE)
|
||||
sed -n \
|
||||
-e '1s/.*/1i\\/p' \
|
||||
-e '2s%.*%# $H%p' \
|
||||
-e '/^VERSION=/s/^VERSION=[ ]*\(.*\)/s%@VERSION[@]%\1%/p' \
|
||||
-e '/^CC=/s/^CC=[ ]*\(.*\)/s%@CC[@]%\1%/p' \
|
||||
-e '/^CCC=/s/^CCC=[ ]*\(.*\)/s%#@SET_CCC[@]%CCC=\1%/p' \
|
||||
-e '/^LINKCC=/s/^LINKCC=[ ]*\(.*\)/s%@LINKCC[@]%\1%/p' \
|
||||
-e '/^OPT=/s/^OPT=[ ]*\(.*\)/s%@OPT[@]%\1%/p' \
|
||||
-e '/^LDFLAGS=/s/^LDFLAGS=[ ]*\(.*\)/s%@LDFLAGS[@]%\1%/p' \
|
||||
-e '/^DEFS=/s/^DEFS=[ ]*\(.*\)/s%@DEFS[@]%\1%/p' \
|
||||
-e '/^LIBS=/s/^LIBS=[ ]*\(.*\)/s%@LIBS[@]%\1%/p' \
|
||||
-e '/^LIBM=/s/^LIBM=[ ]*\(.*\)/s%@LIBM[@]%\1%/p' \
|
||||
-e '/^LIBC=/s/^LIBC=[ ]*\(.*\)/s%@LIBC[@]%\1%/p' \
|
||||
-e '/^RANLIB=/s/^RANLIB=[ ]*\(.*\)/s%@RANLIB[@]%\1%/p' \
|
||||
-e '/^MACHDEP=/s/^MACHDEP=[ ]*\(.*\)/s%@MACHDEP[@]%\1%/p' \
|
||||
-e '/^SO=/s/^SO=[ ]*\(.*\)/s%@SO[@]%\1%/p' \
|
||||
-e '/^LDSHARED=/s/^LDSHARED=[ ]*\(.*\)/s%@LDSHARED[@]%\1%/p' \
|
||||
-e '/^CCSHARED=/s/^CCSHARED=[ ]*\(.*\)/s%@CCSHARED[@]%\1%/p' \
|
||||
-e '/^$L=/s/^$L=[ ]*\(.*\)/s%@$L[@]%\1%/p' \
|
||||
-e '/^$P=/s/^$P=\(.*\)/s%^$P=.*%$P=\1%/p' \
|
||||
-e '/^$E=/s/^$E=\(.*\)/s%^$E=.*%$E=\1%/p' \
|
||||
$(MAKEFILE) >sedscript
|
||||
echo "/^#@SET_CCC@/d" >>sedscript
|
||||
echo "/^installdir=/s%=.*%= $(installdir)%" >>sedscript
|
||||
echo "/^exec_installdir=/s%=.*%=$(exec_installdir)%" >>sedscript
|
||||
echo "/^srcdir=/s%=.*%= $(srcdir)%" >>sedscript
|
||||
echo "/^VPATH=/s%=.*%= $(VPATH)%" >>sedscript
|
||||
echo "/^LINKPATH=/s%=.*%= $(LINKPATH)%" >>sedscript
|
||||
echo "/^BASELIB=/s%=.*%= $(BASELIB)%" >>sedscript
|
||||
echo "/^BASESETUP=/s%=.*%= $(BASESETUP)%" >>sedscript
|
||||
|
||||
# Bootstrap target
|
||||
boot: clobber
|
||||
VERSION=`$(PYTHON) -c "import sys; print sys.version[:3]"`; \
|
||||
installdir=`$(PYTHON) -c "import sys; print sys.prefix"`; \
|
||||
exec_installdir=`$(PYTHON) -c "import sys; print sys.exec_prefix"`; \
|
||||
$(MAKE) -f Makefile.pre.in VPATH=$(VPATH) srcdir=$(srcdir) \
|
||||
VERSION=$$VERSION \
|
||||
installdir=$$installdir \
|
||||
exec_installdir=$$exec_installdir \
|
||||
Makefile
|
||||
|
||||
# Handy target to remove intermediate files and backups
|
||||
clean:
|
||||
-rm -f *.o *~
|
||||
|
||||
# Handy target to remove everything that is easily regenerated
|
||||
clobber: clean
|
||||
-rm -f *.a tags TAGS config.c Makefile.pre $(TARGET) sedscript
|
||||
-rm -f *.so *.sl so_locations
|
||||
|
||||
|
||||
# Handy target to remove everything you don't want to distribute
|
||||
distclean: clobber
|
||||
-rm -f Makefile Setup
|
||||
|
||||
|
||||
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#------------------------------------------------------------------------
|
||||
# Custom rules and dependencies added for wxPython
|
||||
#
|
||||
|
||||
WXP_VERSION=2.1b2
|
||||
|
||||
# WXP_SRCDIR=../wxPython/src
|
||||
|
||||
SWIGFLAGS=-c++ -shadow -python -dnone -I$(WXP_SRCDIR) -D__WXGTK__ $(SEPARATE)
|
||||
|
||||
|
||||
# Implicit rules to run SWIG
|
||||
$(GENCODEDIR)/%.cpp : %.i
|
||||
swig $(SWIGFLAGS) -c -o $@ $<
|
||||
|
||||
$(GENCODEDIR)/%.py : %.i
|
||||
swig $(SWIGFLAGS) -c -o $@ $<
|
||||
$(GENCODEDIR)/%.py : %.i
|
||||
swig $(SWIGFLAGS) -c -o $(GENCODEDIR)/tmp_wrap.cpp $<
|
||||
rm $(GENCODEDIR)/tmp_wrap.cpp
|
||||
|
||||
|
||||
wxInstall : sharedmods $(PYMODULES)
|
||||
if test ! -d $(TARGETDIR) ; then \
|
||||
mkdir $(TARGETDIR) ; else true ; fi
|
||||
if [ "$(SHAREDMODS)" != "" ]; then \
|
||||
chmod 755 $(SHAREDMODS); \
|
||||
cp $(SHAREDMODS) $(TARGETDIR); fi
|
||||
-for i in $(PYMODULES); do \
|
||||
cp $$i $(TARGETDIR); \
|
||||
done
|
||||
if [ "$(TARGETDIR)" != ".." ]; then \
|
||||
python $(LIBDEST)/compileall.py $(TARGETDIR); \
|
||||
python -O $(LIBDEST)/compileall.py $(TARGETDIR); \
|
||||
else \
|
||||
python $(LIBDEST)/compileall.py -l $(TARGETDIR); \
|
||||
python -O $(LIBDEST)/compileall.py -l $(TARGETDIR);\
|
||||
fi
|
||||
|
||||
|
||||
|
11
utils/wxPython/modules/html/README
Normal file
11
utils/wxPython/modules/html/README
Normal file
@ -0,0 +1,11 @@
|
||||
Aug. 2 1999 Harm van der Heijden
|
||||
|
||||
What's in here:
|
||||
|
||||
html
|
||||
-- minimal wrap of Vaclaf Slavik's wxHTML (now part of
|
||||
wxWindows); only parts of the wxHtmlWindow class are used.
|
||||
Testsample htmlview.py.
|
||||
There's also a python tag handler, see htmlwidget.py for
|
||||
a demonstration.
|
||||
|
45
utils/wxPython/modules/html/Setup.in
Normal file
45
utils/wxPython/modules/html/Setup.in
Normal file
@ -0,0 +1,45 @@
|
||||
## This file gives the details of what is needed to build this extension
|
||||
## module so the Makefile can be created.
|
||||
|
||||
## If you have not done "make install" for wxWindows then see Setup.in.linux
|
||||
## for a more verbose version of this file.
|
||||
|
||||
*shared*
|
||||
|
||||
CCC=c++
|
||||
WXWIN=../../..
|
||||
GENCODEDIR=gtk
|
||||
# srcdir=$(GENCODEDIR)
|
||||
WX_CONFIG_CFLAGS=`wx-config --cflags`
|
||||
WX_CONFIG_LIBS=`wx-config --libs`
|
||||
|
||||
|
||||
## Depending on how your Python was built, you may have to set this
|
||||
## value to use the C++ driver to link with instead of the default
|
||||
## C driver. For example:
|
||||
MY_LDSHARED=$(CCC) -shared
|
||||
|
||||
## Same as above, but for statically linking Python and wxPython together,
|
||||
## in other words, if you comment out the *shared* above. If this is the
|
||||
## case then you should ensure that the main() function is Python's, not
|
||||
## wxWindows'. You can rebuild $(WXWIN)/src/gtk/app.cpp with NOMAIN defined
|
||||
## to force this...
|
||||
MY_LINKCC=$(CCC)
|
||||
|
||||
|
||||
## Pick one of these, or set your own. This is where the wxPython module
|
||||
## should be installed. It should be a subdirectory named wxPython.
|
||||
#TARGETDIR=..
|
||||
TARGETDIR=$(BINLIBDEST)/site-packages/wxPython
|
||||
|
||||
# The location of the wxPython source dir
|
||||
WXP_SRCDIR=../../src
|
||||
|
||||
C_DEFINES = -DSWIG_GLOBAL -DWXP_USE_THREAD -DSEPARATE
|
||||
C_FLAGS = -I. -I$(WXP_SRCDIR) $(WX_CONFIG_CFLAGS)
|
||||
C_LIBS = -lwxPyHelpers $(WX_CONFIG_LIBS)
|
||||
|
||||
PYMODULES = $(GENCODEDIR)/html.py htmlhelper.py
|
||||
|
||||
htmlc $(GENCODEDIR)/html.cpp \
|
||||
$(C_DEFINES) $(C_FLAGS) -Xlinker $(C_LIBS)
|
259
utils/wxPython/modules/html/html.i
Normal file
259
utils/wxPython/modules/html/html.i
Normal file
@ -0,0 +1,259 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: html.i
|
||||
// Purpose: SWIG definitions of html classes
|
||||
//
|
||||
// Author: Robin Dunn
|
||||
//
|
||||
// Created: 25-nov-1998
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 1998 by Total Control Software
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
%module html
|
||||
|
||||
%{
|
||||
#include "helpers.h"
|
||||
#include <wx/html/htmlwin.h>
|
||||
#include <wx/image.h>
|
||||
#include <wx/fs_zip.h>
|
||||
#include <wx/fs_inet.h>
|
||||
%}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
%include typemaps.i
|
||||
%include my_typemaps.i
|
||||
|
||||
%extern wx.i
|
||||
%extern windows.i
|
||||
%extern _defs.i
|
||||
%extern events.i
|
||||
//%extern windows2.i
|
||||
//%extern windows3.i
|
||||
//%extern frames.i
|
||||
//%extern misc.i
|
||||
//%extern gdi.i
|
||||
//%extern controls.i
|
||||
|
||||
|
||||
%{
|
||||
#ifdef __WXMSW__
|
||||
static wxString wxPyEmptyStr("");
|
||||
static wxPoint wxPyDefaultPosition(wxDefaultPosition);
|
||||
static wxSize wxPyDefaultSize(wxDefaultSize);
|
||||
#endif
|
||||
static PyThreadState* wxPyThreadState;
|
||||
%}
|
||||
|
||||
%pragma(python) code = "import wx,htmlhelper"
|
||||
%pragma(python) code = "widget = htmlc"
|
||||
|
||||
%{
|
||||
|
||||
static PyObject* mod_dict = NULL; // will be set by init
|
||||
|
||||
#include <wx/html/mod_templ.h>
|
||||
|
||||
TAG_HANDLER_BEGIN(PYTHONTAG, "PYTHON")
|
||||
TAG_HANDLER_PROC(tag)
|
||||
{
|
||||
wxWindow *wnd;
|
||||
wxString errmsg;
|
||||
char pbuf[256];
|
||||
|
||||
int fl = 0;
|
||||
|
||||
while (1) {
|
||||
#ifdef WXP_WITH_THREAD
|
||||
PyEval_RestoreThread(wxPyThreadState);
|
||||
#endif
|
||||
if (tag.HasParam("FLOAT"))
|
||||
tag.ScanParam("FLOAT", "%i", &fl);
|
||||
PyObject* pyfunc = PyDict_GetItemString(mod_dict, "WidgetStarter");
|
||||
if (pyfunc == NULL) {
|
||||
errmsg = "Could not find object WidgetStarter";
|
||||
break;
|
||||
}
|
||||
if (! PyCallable_Check(pyfunc)) {
|
||||
errmsg = "WidgetStarter does not appear to be callable";
|
||||
break;
|
||||
}
|
||||
SWIG_MakePtr(pbuf, m_WParser->GetWindow(), "_wxHtmlWindow_p");
|
||||
PyObject* arglist = Py_BuildValue("(s,s)", pbuf,
|
||||
(const char*)tag.GetAllParams());
|
||||
if (! arglist) {
|
||||
errmsg = "Failed making argument list";
|
||||
break;
|
||||
}
|
||||
PyObject* ret = PyEval_CallObject(pyfunc, arglist);
|
||||
Py_DECREF(arglist);
|
||||
if (ret == NULL) {
|
||||
errmsg = "An error occured while calling WidgetStarter";
|
||||
if (PyErr_Occurred())
|
||||
PyErr_Print();
|
||||
break;
|
||||
}
|
||||
wnd = NULL;
|
||||
if (PyString_Check(ret)) {
|
||||
char* thisc = PyString_AsString(ret);
|
||||
SWIG_GetPtr(thisc, (void**)&wnd, "_wxWindow_p");
|
||||
}
|
||||
Py_DECREF(ret);
|
||||
if (! wnd) {
|
||||
errmsg = "Could not make a wxWindow pointer from return ptr";
|
||||
break;
|
||||
}
|
||||
#ifdef WXP_WITH_THREAD
|
||||
PyEval_SaveThread();
|
||||
#endif
|
||||
wnd -> Show(TRUE);
|
||||
m_WParser->OpenContainer()->InsertCell(new wxHtmlWidgetCell(wnd, fl));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* we got out of the loop. Must be an error. Show a box stating it. */
|
||||
|
||||
#ifdef WXP_WITH_THREAD
|
||||
PyEval_SaveThread();
|
||||
#endif
|
||||
|
||||
wnd = new wxTextCtrl( m_WParser -> GetWindow(), -1,
|
||||
errmsg, wxPoint(0,0),
|
||||
wxSize(300, 100), wxTE_MULTILINE );
|
||||
wnd -> Show(TRUE);
|
||||
m_WParser->OpenContainer()->InsertCell(new wxHtmlWidgetCell(wnd, 100));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
TAG_HANDLER_END(PYTHONTAG)
|
||||
|
||||
TAGS_MODULE_BEGIN(PythonTag)
|
||||
|
||||
TAGS_MODULE_ADD(PYTHONTAG)
|
||||
|
||||
TAGS_MODULE_END(PythonTag)
|
||||
|
||||
// Note: see also the init function where we add the module!
|
||||
|
||||
%}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
// item of history list
|
||||
class HtmlHistoryItem
|
||||
{
|
||||
public:
|
||||
HtmlHistoryItem(const char* p, const char* a);
|
||||
int GetPos() const {return m_Pos;}
|
||||
void SetPos(int p) {m_Pos = p;}
|
||||
const wxString& GetPage() const ;
|
||||
const wxString& GetAnchor() const ;
|
||||
};
|
||||
|
||||
class wxHtmlWindow : public wxScrolledWindow
|
||||
{
|
||||
public:
|
||||
wxHtmlWindow(wxWindow *parent, wxWindowID id = -1,
|
||||
const wxPoint& pos = wxPyDefaultPosition,
|
||||
const wxSize& size = wxPyDefaultSize,
|
||||
int flags=wxHW_SCROLLBAR_AUTO,
|
||||
const char* name = "htmlWindow");
|
||||
%pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
|
||||
%pragma(python) addtomethod = "__init__:wx._StdOnScrollCallbacks(self)"
|
||||
|
||||
bool SetPage(const char* source);
|
||||
// Set HTML page and display it. !! source is HTML document itself,
|
||||
// it is NOT address/filename of HTML document. If you want to
|
||||
// specify document location, use LoadPage() istead
|
||||
// Return value : FALSE if an error occured, TRUE otherwise
|
||||
|
||||
bool LoadPage(const char* location);
|
||||
// Load HTML page from given location. Location can be either
|
||||
// a) /usr/wxGTK2/docs/html/wx.htm
|
||||
// b) http://www.somewhere.uk/document.htm
|
||||
// c) ftp://ftp.somesite.cz/pub/something.htm
|
||||
// In case there is no prefix (http:,ftp:), the method
|
||||
// will try to find it itself (1. local file, then http or ftp)
|
||||
// After the page is loaded, the method calls SetPage() to display it.
|
||||
// Note : you can also use path relative to previously loaded page
|
||||
// Return value : same as SetPage
|
||||
|
||||
wxString GetOpenedPage() const {return m_OpenedPage;}
|
||||
// Returns full location of opened page
|
||||
|
||||
void SetRelatedFrame(wxFrame* frame, const char* format);
|
||||
// sets frame in which page title will be displayed. Format is format of
|
||||
// frame title, e.g. "HtmlHelp : %s". It must contain exactly one %s
|
||||
wxFrame* GetRelatedFrame() const;
|
||||
|
||||
void SetRelatedStatusBar(int bar);
|
||||
// after(!) calling SetRelatedFrame, this sets statusbar slot where messages
|
||||
// will be displayed. Default is -1 = no messages.
|
||||
|
||||
void SetFonts(wxString normal_face, int normal_italic_mode, wxString fixed_face, int fixed_italic_mode, int *sizes);
|
||||
// sets fonts to be used when displaying HTML page.
|
||||
// *_italic_mode can be either wxSLANT or wxITALIC
|
||||
|
||||
void SetTitle(const char* title);
|
||||
// Sets the title of the window
|
||||
// (depending on the information passed to SetRelatedFrame() method)
|
||||
|
||||
void SetBorders(int b);
|
||||
// Sets space between text and window borders.
|
||||
|
||||
//virtual void ReadCustomization(wxConfigBase *cfg, wxString path = wxEmptyString);
|
||||
// saves custom settings into cfg config. it will use the path 'path'
|
||||
// if given, otherwise it will save info into currently selected path.
|
||||
// saved values : things set by SetFonts, SetBorders.
|
||||
//virtual void WriteCustomization(wxConfigBase *cfg, wxString path = wxEmptyString);
|
||||
// ...
|
||||
|
||||
bool HistoryBack();
|
||||
bool HistoryForward();
|
||||
// Goes to previous/next page (in browsing history)
|
||||
// Returns TRUE if successful, FALSE otherwise
|
||||
void HistoryClear();
|
||||
// Resets history
|
||||
|
||||
//wxHtmlContainerCell* GetInternalRepresentation() const;
|
||||
// Returns pointer to conteiners/cells structure.
|
||||
// It should be used ONLY when printing
|
||||
|
||||
//static void AddFilter(wxHtmlFilter *filter);
|
||||
// Adds input filter
|
||||
|
||||
/* This function needs to be eventified! */
|
||||
//virtual void OnLinkClicked(const char* link);
|
||||
// called when users clicked on hypertext link. Default behavior is to
|
||||
// call LoadPage(loc)
|
||||
|
||||
//static void CleanUpStatics();
|
||||
// cleans static variables
|
||||
|
||||
};
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
%init %{
|
||||
|
||||
/* This is a bit cheesy. SWIG happens to call the dictionary d...
|
||||
* I save it here, 'cause I don't know how to get it back later! */
|
||||
mod_dict = d;
|
||||
wxPyThreadState = PyThreadState_Get();
|
||||
wxClassInfo::CleanUpClasses();
|
||||
wxClassInfo::InitializeClasses();
|
||||
|
||||
/* specifically add our python tag handler; it doesn't seem to
|
||||
* happen by itself... */
|
||||
wxHtmlWinParser::AddModule(new HTML_ModulePythonTag());
|
||||
|
||||
// Until wxFileSystem is wrapped...
|
||||
#if wxUSE_FS_ZIP
|
||||
wxFileSystem::AddHandler(new wxZipFSHandler);
|
||||
#endif
|
||||
%}
|
||||
|
||||
//---------------------------------------------------------------------------
|
2
utils/wxPython/modules/html/htmlc.def
Normal file
2
utils/wxPython/modules/html/htmlc.def
Normal file
@ -0,0 +1,2 @@
|
||||
EXPORTS
|
||||
inithtmlc
|
59
utils/wxPython/modules/html/htmlhelper.py
Normal file
59
utils/wxPython/modules/html/htmlhelper.py
Normal file
@ -0,0 +1,59 @@
|
||||
#
|
||||
# htmlhelper.py
|
||||
#
|
||||
# A few helper functions for putting wxPython widgets in html pages
|
||||
#
|
||||
# Harm van der Heijden, 11 aug 1999.
|
||||
|
||||
import wx
|
||||
import string
|
||||
import htmlc
|
||||
|
||||
# Function to parse a param string (of the form 'item=value item2="value etc"'
|
||||
# and creates a dictionary
|
||||
def _param2dict(param):
|
||||
i = 0; j = 0; s = len(param); d = {}
|
||||
d['param_str'] = param
|
||||
while 1:
|
||||
while i<s and param[i] == " " : i = i+1
|
||||
if i>=s: break
|
||||
j = i
|
||||
while j<s and param[j] != "=": j=j+1
|
||||
if j+1>=s:
|
||||
break
|
||||
word = param[i:j]
|
||||
i=j+1
|
||||
if (param[i] == '"'):
|
||||
j=i+1
|
||||
while j<s and param[j] != '"' : j=j+1
|
||||
if j == s: break
|
||||
val = param[i+1:j]
|
||||
elif (param[i] != " "):
|
||||
j=i+1
|
||||
while j<s and param[j] != " " : j=j+1
|
||||
val = param[i:j]
|
||||
else:
|
||||
val = ""
|
||||
i=j+1
|
||||
d[string.lower(word)] = val
|
||||
return d
|
||||
|
||||
# This function gets called by the <python> tag handler.
|
||||
# Arguments are the parent (wxHtmlWindow) SWIG pointer (in python, a string)
|
||||
# and a string containing the parameters.
|
||||
# The return value must be the SWIG pointer of the created widget (the 'this'
|
||||
# attribute in python). The widget must be derived from a wxWindow or one
|
||||
# of its descendants.
|
||||
def _WidgetStarter(parentptr, param):
|
||||
# create a python instance of the parent
|
||||
parent = wx.wxWindowPtr(parentptr)
|
||||
# try to find the widget class in the htmlwinc (=htmlwidget) module
|
||||
dict = _param2dict(param)
|
||||
classname = dict['class']
|
||||
obj = htmlc.__dict__[classname]
|
||||
# now create the class with arguments parent, dictionary
|
||||
cls = apply(obj, (parent, dict))
|
||||
# return the class instance's pointer
|
||||
return cls.this
|
||||
|
||||
htmlc.WidgetStarter = _WidgetStarter
|
35
utils/wxPython/modules/html/makefile.vc
Normal file
35
utils/wxPython/modules/html/makefile.vc
Normal file
@ -0,0 +1,35 @@
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
TARGET = htmlc
|
||||
|
||||
OBJECTS = html.obj
|
||||
|
||||
PYMODULES = $(TARGETDIR)\html.py $(TARGETDIR)\htmlhelper.py
|
||||
|
||||
SOURCES = $(GENCODEDIR)\html.cpp
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
!include ..\makeinc.vc
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
default: $(TARGETDIR)\$(TARGET).pyd pycfiles
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
$(TARGETDIR)\$(TARGET).pyd : $(DUMMYOBJ) $(WXLIB) $(OBJECTS) # $(TARGET).res
|
||||
$(link) @<<
|
||||
/out:$@ /dll
|
||||
$(LFLAGS) /def:$(TARGET).def /implib:./$(TARGET).lib
|
||||
$(DUMMYOBJ) $(OBJECTS)
|
||||
$(LIBS)
|
||||
<<
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
77
utils/wxPython/modules/html/test/htmlview.py
Normal file
77
utils/wxPython/modules/html/test/htmlview.py
Normal file
@ -0,0 +1,77 @@
|
||||
from wxPython.wx import *
|
||||
from wxPython.html import *
|
||||
import sys
|
||||
|
||||
default_page = """
|
||||
<H1>HTML Viewer</H1>Please select <I>File->Open</I>
|
||||
to open a HTML file, or edit this page in the
|
||||
text control below and select <I>File->Update</I>
|
||||
<P>
|
||||
The python source can be seen
|
||||
<a href="%s">here</a>.
|
||||
""" % (sys.argv[0], )
|
||||
|
||||
class HtmlViewer(wxFrame):
|
||||
def __init__(self, parent, id, title, pos = wxDefaultPosition, size = wxSize(400,400)):
|
||||
wxFrame.__init__(self, parent, id, title, pos, size)
|
||||
self.CreateStatusBar(1)
|
||||
split = wxSplitterWindow(self, -1)
|
||||
self.html = wxHtmlWindow(split)
|
||||
self.html.SetRelatedFrame(self, "HTML Viewer: \%s")
|
||||
self.html.SetRelatedStatusBar(0)
|
||||
self.txt = wxTextCtrl(split, -1, default_page,
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
wxTE_MULTILINE)
|
||||
split.SplitHorizontally(self.html, self.txt, size.y/2)
|
||||
mbar = wxMenuBar()
|
||||
menu = wxMenu()
|
||||
menu.Append(1500, "Open")
|
||||
menu.Append(1501, "Reset")
|
||||
menu.Append(1502, "Update HTML")
|
||||
menu.AppendSeparator()
|
||||
menu.Append(1503, "Exit")
|
||||
mbar.Append(menu, "File")
|
||||
menu = wxMenu()
|
||||
menu.Append(1510, "Back")
|
||||
menu.Append(1511, "Forward")
|
||||
mbar.Append(menu, "Go")
|
||||
self.SetMenuBar(mbar)
|
||||
self.filename = ""
|
||||
EVT_MENU(self, 1500, self.OnFileOpen)
|
||||
EVT_MENU(self, 1501, self.OnFileReset)
|
||||
EVT_MENU(self, 1502, self.OnFileUpdate)
|
||||
EVT_MENU(self, 1503, self.OnClose)
|
||||
EVT_MENU(self, 1510, self.OnGoBack)
|
||||
EVT_MENU(self, 1511, self.OnGoForward)
|
||||
# A default opening text
|
||||
self.html.SetPage( default_page )
|
||||
def OnFileOpen(self, event):
|
||||
dlg = wxFileDialog(NULL, "Open file")
|
||||
if dlg.ShowModal() == wxID_OK:
|
||||
self.filename = dlg.GetPath()
|
||||
self.html.LoadPage(self.filename)
|
||||
def OnFileReset(self, event):
|
||||
self.html.SetPage( default_page )
|
||||
self.txt.SetValue( default_page )
|
||||
def OnFileUpdate(self, event):
|
||||
self.html.SetPage( self.txt.GetValue() )
|
||||
def OnGoBack(self, event):
|
||||
self.html.HistoryBack()
|
||||
def OnGoForward(self, event):
|
||||
self.html.HistoryForward()
|
||||
def OnClose(self,event):
|
||||
self.Destroy()
|
||||
|
||||
class MyApp(wxApp):
|
||||
def OnInit(self):
|
||||
frame = HtmlViewer(NULL, -1, "HTML Viewer")
|
||||
frame.Show(TRUE)
|
||||
self.SetTopWindow(frame)
|
||||
return TRUE
|
||||
|
||||
wxImage_AddHandler(wxPNGHandler())
|
||||
wxImage_AddHandler(wxGIFHandler())
|
||||
wxImage_AddHandler(wxJPEGHandler())
|
||||
|
||||
theApp = MyApp(0)
|
||||
theApp.MainLoop()
|
97
utils/wxPython/modules/html/test/htmlwidget.py
Normal file
97
utils/wxPython/modules/html/test/htmlwidget.py
Normal file
@ -0,0 +1,97 @@
|
||||
from wxPython.wx import *
|
||||
from wxPython.html import *
|
||||
import sys,string
|
||||
|
||||
# A bunch of simple widgets, all somehow derived from wxWindow
|
||||
class Widget1(wxWindow):
|
||||
def __init__(self, parent, param):
|
||||
wxWindow.__init__(self, parent, -1)
|
||||
self.text = wxTextCtrl(self, -1, param['param_str'], wxPoint(5,5),
|
||||
wxSize(200,150), wxTE_MULTILINE)
|
||||
but = wxButton(self, 1001, "Click me", wxPoint(50,160), wxSize(100,30))
|
||||
EVT_BUTTON(self, 1001, self.OnButton)
|
||||
self.SetSize(wxSize(210,200))
|
||||
def OnButton(self, event):
|
||||
self.text.AppendText( "Click!\n" )
|
||||
|
||||
class Widget2(wxButton):
|
||||
def __init__(self, parent, param):
|
||||
wxButton.__init__(self, parent, int(param['id']), param['title'])
|
||||
|
||||
class Widget3(wxTextCtrl):
|
||||
def __init__(self, parent, param):
|
||||
wxTextCtrl.__init__(self, parent, -1, "No clicks")
|
||||
self.clicked = 0;
|
||||
EVT_BUTTON(parent, int(param['button_id']), self.OnButton)
|
||||
def OnButton(self, event):
|
||||
self.clicked = self.clicked + 1
|
||||
self.SetValue("%d clicks" % (self.clicked,))
|
||||
|
||||
# make the widgets known in the widget module (aka htmlc)
|
||||
widget.Widget1 = Widget1
|
||||
widget.Widget2 = Widget2
|
||||
widget.Widget3 = Widget3
|
||||
|
||||
# our default page
|
||||
default_page = """
|
||||
<H2>wxPython widgets go HTML</H2>
|
||||
A bunch of wxPython widgets are scattered on this HTML page.
|
||||
Here's one:
|
||||
<center><python class="Widget1" greeting="Hello World"></center>
|
||||
<hr>
|
||||
Here's another:
|
||||
<center><python class="Widget2" float=70 id=1002 title="Button A"></center>
|
||||
It should always take up 70% of the page width.
|
||||
<p>And then there's this, listening to button A:
|
||||
<python class="Widget3" button_id=1002></p>
|
||||
"""
|
||||
|
||||
# our explanation
|
||||
apology = """
|
||||
For some bizarre reason, it takes forever and a day to display the
|
||||
widgets if they are constructed in the frame's constructor. This
|
||||
only happens in MSW, wxGTK works fine.
|
||||
<p>Select <I>File->Show it</I> to draw the widgets."""
|
||||
|
||||
default_page = default_page + "The HTML code for this page is\n <pre>" + default_page + "</pre>"
|
||||
|
||||
|
||||
class HtmlViewer(wxFrame):
|
||||
def __init__(self, parent, id, title, pos = wxDefaultPosition, size = wxSize(400,400)):
|
||||
wxFrame.__init__(self, parent, id, title, pos, size)
|
||||
self.CreateStatusBar(1)
|
||||
self.html = wxHtmlWindow(self)
|
||||
self.html.SetRelatedFrame(self, "HTML Viewer: \%s")
|
||||
self.html.SetRelatedStatusBar(0)
|
||||
mbar = wxMenuBar()
|
||||
menu = wxMenu()
|
||||
menu.Append(1500, "Show it")
|
||||
menu.Append(1503, "Exit")
|
||||
mbar.Append(menu, "File")
|
||||
EVT_MENU(self, 1500, self.OnShowIt)
|
||||
EVT_MENU(self, 1503, self.OnClose)
|
||||
self.SetMenuBar(mbar)
|
||||
# change apology below to default_page, if you dare!
|
||||
self.html.SetPage( default_page )
|
||||
def OnClose(self,event):
|
||||
self.Destroy()
|
||||
def OnShowIt(self,event):
|
||||
self.html.SetPage( default_page )
|
||||
# now quickly remove the menu option, to hide that
|
||||
# other bug; namely that widgets aren't removed when the
|
||||
# HTML page is.
|
||||
self.GetMenuBar().Enable(1500, FALSE)
|
||||
|
||||
class MyApp(wxApp):
|
||||
def OnInit(self):
|
||||
frame = HtmlViewer(NULL, -1, "HTML Viewer")
|
||||
frame.Show(TRUE)
|
||||
self.SetTopWindow(frame)
|
||||
return TRUE
|
||||
|
||||
wxImage_AddHandler(wxPNGHandler())
|
||||
wxImage_AddHandler(wxGIFHandler())
|
||||
wxImage_AddHandler(wxJPEGHandler())
|
||||
|
||||
theApp = MyApp(0)
|
||||
theApp.MainLoop()
|
28
utils/wxPython/modules/lseditor/BUGS
Normal file
28
utils/wxPython/modules/lseditor/BUGS
Normal file
@ -0,0 +1,28 @@
|
||||
Known bugs
|
||||
|
||||
html, all:
|
||||
- keys can move the vertical scrollbar, but the window moveth not.
|
||||
problem in wxHTML.
|
||||
|
||||
- widgets are not removed when the HTML contents is changed
|
||||
(this can be fixed by adding ~HtmlWidgetCell { wnd->Destroy(); } )
|
||||
|
||||
- potential problem with the use of ThreadState in html.i
|
||||
(mainly because I don't really know what I'm doing there)
|
||||
|
||||
html, msw:
|
||||
- vertical scrollbar behaves erratically when content smaller than
|
||||
window
|
||||
|
||||
- page with widgets takes forever to draw when constructed
|
||||
in frame constructor
|
||||
|
||||
html, gtk:
|
||||
- segfault on exit; sometimes warning about assert failure
|
||||
(m_Object->refcount > 0)
|
||||
|
||||
|
||||
editor, all:
|
||||
- (missing feature, really) syntax highlighting data is
|
||||
compile time.
|
||||
|
340
utils/wxPython/modules/lseditor/COPYING
Normal file
340
utils/wxPython/modules/lseditor/COPYING
Normal file
@ -0,0 +1,340 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Library General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) 19yy <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) 19yy name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Library General
|
||||
Public License instead of this License.
|
363
utils/wxPython/modules/lseditor/Makefile.pre.in
Normal file
363
utils/wxPython/modules/lseditor/Makefile.pre.in
Normal file
@ -0,0 +1,363 @@
|
||||
# Universal Unix Makefile for Python extensions
|
||||
# =============================================
|
||||
|
||||
# Short Instructions
|
||||
# ------------------
|
||||
|
||||
# 1. Build and install Python (1.5 or newer).
|
||||
# 2. "make -f Makefile.pre.in boot"
|
||||
# 3. "make"
|
||||
# You should now have a shared library.
|
||||
|
||||
# Long Instructions
|
||||
# -----------------
|
||||
|
||||
# Build *and install* the basic Python 1.5 distribution. See the
|
||||
# Python README for instructions. (This version of Makefile.pre.in
|
||||
# only withs with Python 1.5, alpha 3 or newer.)
|
||||
|
||||
# Create a file Setup.in for your extension. This file follows the
|
||||
# format of the Modules/Setup.in file; see the instructions there.
|
||||
# For a simple module called "spam" on file "spammodule.c", it can
|
||||
# contain a single line:
|
||||
# spam spammodule.c
|
||||
# You can build as many modules as you want in the same directory --
|
||||
# just have a separate line for each of them in the Setup.in file.
|
||||
|
||||
# If you want to build your extension as a shared library, insert a
|
||||
# line containing just the string
|
||||
# *shared*
|
||||
# at the top of your Setup.in file.
|
||||
|
||||
# Note that the build process copies Setup.in to Setup, and then works
|
||||
# with Setup. It doesn't overwrite Setup when Setup.in is changed, so
|
||||
# while you're in the process of debugging your Setup.in file, you may
|
||||
# want to edit Setup instead, and copy it back to Setup.in later.
|
||||
# (All this is done so you can distribute your extension easily and
|
||||
# someone else can select the modules they actually want to build by
|
||||
# commenting out lines in the Setup file, without editing the
|
||||
# original. Editing Setup is also used to specify nonstandard
|
||||
# locations for include or library files.)
|
||||
|
||||
# Copy this file (Misc/Makefile.pre.in) to the directory containing
|
||||
# your extension.
|
||||
|
||||
# Run "make -f Makefile.pre.in boot". This creates Makefile
|
||||
# (producing Makefile.pre and sedscript as intermediate files) and
|
||||
# config.c, incorporating the values for sys.prefix, sys.exec_prefix
|
||||
# and sys.version from the installed Python binary. For this to work,
|
||||
# the python binary must be on your path. If this fails, try
|
||||
# make -f Makefile.pre.in Makefile VERSION=1.5 installdir=<prefix>
|
||||
# where <prefix> is the prefix used to install Python for installdir
|
||||
# (and possibly similar for exec_installdir=<exec_prefix>).
|
||||
|
||||
# Note: "make boot" implies "make clobber" -- it assumes that when you
|
||||
# bootstrap you may have changed platforms so it removes all previous
|
||||
# output files.
|
||||
|
||||
# If you are building your extension as a shared library (your
|
||||
# Setup.in file starts with *shared*), run "make" or "make sharedmods"
|
||||
# to build the shared library files. If you are building a statically
|
||||
# linked Python binary (the only solution of your platform doesn't
|
||||
# support shared libraries, and sometimes handy if you want to
|
||||
# distribute or install the resulting Python binary), run "make
|
||||
# python".
|
||||
|
||||
# Note: Each time you edit Makefile.pre.in or Setup, you must run
|
||||
# "make Makefile" before running "make".
|
||||
|
||||
# Hint: if you want to use VPATH, you can start in an empty
|
||||
# subdirectory and say (e.g.):
|
||||
# make -f ../Makefile.pre.in boot srcdir=.. VPATH=..
|
||||
|
||||
|
||||
# === Bootstrap variables (edited through "make boot") ===
|
||||
|
||||
# The prefix used by "make inclinstall libainstall" of core python
|
||||
installdir= /usr/local
|
||||
|
||||
# The exec_prefix used by the same
|
||||
exec_installdir=$(installdir)
|
||||
|
||||
# Source directory and VPATH in case you want to use VPATH.
|
||||
# (You will have to edit these two lines yourself -- there is no
|
||||
# automatic support as the Makefile is not generated by
|
||||
# config.status.)
|
||||
srcdir= .
|
||||
VPATH= .
|
||||
|
||||
# === Variables that you may want to customize (rarely) ===
|
||||
|
||||
# (Static) build target
|
||||
TARGET= python
|
||||
|
||||
# Installed python binary (used only by boot target)
|
||||
PYTHON= python
|
||||
|
||||
# Add more -I and -D options here
|
||||
CFLAGS= $(OPT) -I$(INCLUDEPY) -I$(EXECINCLUDEPY) $(DEFS)
|
||||
|
||||
# These two variables can be set in Setup to merge extensions.
|
||||
# See example[23].
|
||||
BASELIB=
|
||||
BASESETUP=
|
||||
|
||||
# === Variables set by makesetup ===
|
||||
|
||||
MODOBJS= _MODOBJS_
|
||||
MODLIBS= _MODLIBS_
|
||||
|
||||
# === Definitions added by makesetup ===
|
||||
|
||||
# === Variables from configure (through sedscript) ===
|
||||
|
||||
VERSION= @VERSION@
|
||||
CC= @CC@
|
||||
LINKCC= @LINKCC@
|
||||
SGI_ABI= @SGI_ABI@
|
||||
OPT= @OPT@
|
||||
LDFLAGS= @LDFLAGS@
|
||||
LDLAST= @LDLAST@
|
||||
DEFS= @DEFS@
|
||||
LIBS= @LIBS@
|
||||
LIBM= @LIBM@
|
||||
LIBC= @LIBC@
|
||||
RANLIB= @RANLIB@
|
||||
MACHDEP= @MACHDEP@
|
||||
SO= @SO@
|
||||
LDSHARED= @LDSHARED@
|
||||
CCSHARED= @CCSHARED@
|
||||
LINKFORSHARED= @LINKFORSHARED@
|
||||
#@SET_CCC@
|
||||
|
||||
# Install prefix for architecture-independent files
|
||||
prefix= /usr/local
|
||||
|
||||
# Install prefix for architecture-dependent files
|
||||
exec_prefix= $(prefix)
|
||||
|
||||
# === Fixed definitions ===
|
||||
|
||||
# Shell used by make (some versions default to the login shell, which is bad)
|
||||
SHELL= /bin/sh
|
||||
|
||||
# Expanded directories
|
||||
BINDIR= $(exec_installdir)/bin
|
||||
LIBDIR= $(exec_prefix)/lib
|
||||
MANDIR= $(installdir)/man
|
||||
INCLUDEDIR= $(installdir)/include
|
||||
SCRIPTDIR= $(prefix)/lib
|
||||
|
||||
# Detailed destination directories
|
||||
BINLIBDEST= $(LIBDIR)/python$(VERSION)
|
||||
LIBDEST= $(SCRIPTDIR)/python$(VERSION)
|
||||
INCLUDEPY= $(INCLUDEDIR)/python$(VERSION)
|
||||
EXECINCLUDEPY= $(exec_installdir)/include/python$(VERSION)
|
||||
LIBP= $(exec_installdir)/lib/python$(VERSION)
|
||||
DESTSHARED= $(BINLIBDEST)/site-packages
|
||||
|
||||
LIBPL= $(LIBP)/config
|
||||
|
||||
PYTHONLIBS= $(LIBPL)/libpython$(VERSION).a
|
||||
|
||||
MAKESETUP= $(LIBPL)/makesetup
|
||||
MAKEFILE= $(LIBPL)/Makefile
|
||||
CONFIGC= $(LIBPL)/config.c
|
||||
CONFIGCIN= $(LIBPL)/config.c.in
|
||||
SETUP= $(LIBPL)/Setup
|
||||
|
||||
SYSLIBS= $(LIBM) $(LIBC)
|
||||
|
||||
ADDOBJS= $(LIBPL)/python.o config.o
|
||||
|
||||
# Portable install script (configure doesn't always guess right)
|
||||
INSTALL= $(LIBPL)/install-sh -c
|
||||
# Shared libraries must be installed with executable mode on some systems;
|
||||
# rather than figuring out exactly which, we always give them executable mode.
|
||||
# Also, making them read-only seems to be a good idea...
|
||||
INSTALL_SHARED= ${INSTALL} -m 555
|
||||
|
||||
#---------------------------------------------------
|
||||
# Possibly change some definintions for C++
|
||||
ifdef MY_LDSHARED
|
||||
LDSHARED=$(MY_LDSHARED)
|
||||
endif
|
||||
ifdef MY_LINKCC
|
||||
LINKCC=$(MY_LINKCC)
|
||||
endif
|
||||
|
||||
|
||||
# === Fixed rules ===
|
||||
|
||||
# Default target. This builds shared libraries only
|
||||
default: sharedmods
|
||||
|
||||
# Build everything
|
||||
all: static sharedmods
|
||||
|
||||
# Build shared libraries from our extension modules
|
||||
sharedmods: $(SHAREDMODS)
|
||||
|
||||
# Build a static Python binary containing our extension modules
|
||||
static: $(TARGET)
|
||||
$(TARGET): $(ADDOBJS) lib.a $(PYTHONLIBS) Makefile $(BASELIB)
|
||||
$(LINKCC) $(LDFLAGS) $(LINKFORSHARED) \
|
||||
$(ADDOBJS) lib.a $(PYTHONLIBS) \
|
||||
$(LINKPATH) $(BASELIB) $(MODLIBS) $(LIBS) $(SYSLIBS) \
|
||||
-o $(TARGET) $(LDLAST)
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#------------------------------------------------------------------------
|
||||
# This is a default version of the install target for wxPython. It just
|
||||
# redirects to wxInstall below...
|
||||
|
||||
install: wxInstall
|
||||
|
||||
#install: sharedmods
|
||||
# if test ! -d $(DESTSHARED) ; then \
|
||||
# mkdir $(DESTSHARED) ; else true ; fi
|
||||
# -for i in X $(SHAREDMODS); do \
|
||||
# if test $$i != X; \
|
||||
# then $(INSTALL_SHARED) $$i $(DESTSHARED)/$$i; \
|
||||
# fi; \
|
||||
# done
|
||||
|
||||
|
||||
# Build the library containing our extension modules
|
||||
lib.a: $(MODOBJS)
|
||||
-rm -f lib.a
|
||||
ar cr lib.a $(MODOBJS)
|
||||
-$(RANLIB) lib.a
|
||||
|
||||
# This runs makesetup *twice* to use the BASESETUP definition from Setup
|
||||
config.c Makefile: Makefile.pre Setup $(BASESETUP) $(MAKESETUP)
|
||||
$(MAKESETUP) \
|
||||
-m Makefile.pre -c $(CONFIGCIN) Setup -n $(BASESETUP) $(SETUP)
|
||||
$(MAKE) -f Makefile do-it-again
|
||||
|
||||
# Internal target to run makesetup for the second time
|
||||
do-it-again:
|
||||
$(MAKESETUP) \
|
||||
-m Makefile.pre -c $(CONFIGCIN) Setup -n $(BASESETUP) $(SETUP)
|
||||
|
||||
# Make config.o from the config.c created by makesetup
|
||||
config.o: config.c
|
||||
$(CC) $(CFLAGS) -c config.c
|
||||
|
||||
# Setup is copied from Setup.in *only* if it doesn't yet exist
|
||||
Setup:
|
||||
cp Setup.in Setup
|
||||
|
||||
# Make the intermediate Makefile.pre from Makefile.pre.in
|
||||
Makefile.pre: Makefile.pre.in sedscript
|
||||
sed -f sedscript Makefile.pre.in >Makefile.pre
|
||||
|
||||
# Shortcuts to make the sed arguments on one line
|
||||
P=prefix
|
||||
E=exec_prefix
|
||||
H=Generated automatically from Makefile.pre.in by sedscript.
|
||||
L=LINKFORSHARED
|
||||
|
||||
# Make the sed script used to create Makefile.pre from Makefile.pre.in
|
||||
sedscript: $(MAKEFILE)
|
||||
sed -n \
|
||||
-e '1s/.*/1i\\/p' \
|
||||
-e '2s%.*%# $H%p' \
|
||||
-e '/^VERSION=/s/^VERSION=[ ]*\(.*\)/s%@VERSION[@]%\1%/p' \
|
||||
-e '/^CC=/s/^CC=[ ]*\(.*\)/s%@CC[@]%\1%/p' \
|
||||
-e '/^CCC=/s/^CCC=[ ]*\(.*\)/s%#@SET_CCC[@]%CCC=\1%/p' \
|
||||
-e '/^LINKCC=/s/^LINKCC=[ ]*\(.*\)/s%@LINKCC[@]%\1%/p' \
|
||||
-e '/^OPT=/s/^OPT=[ ]*\(.*\)/s%@OPT[@]%\1%/p' \
|
||||
-e '/^LDFLAGS=/s/^LDFLAGS=[ ]*\(.*\)/s%@LDFLAGS[@]%\1%/p' \
|
||||
-e '/^DEFS=/s/^DEFS=[ ]*\(.*\)/s%@DEFS[@]%\1%/p' \
|
||||
-e '/^LIBS=/s/^LIBS=[ ]*\(.*\)/s%@LIBS[@]%\1%/p' \
|
||||
-e '/^LIBM=/s/^LIBM=[ ]*\(.*\)/s%@LIBM[@]%\1%/p' \
|
||||
-e '/^LIBC=/s/^LIBC=[ ]*\(.*\)/s%@LIBC[@]%\1%/p' \
|
||||
-e '/^RANLIB=/s/^RANLIB=[ ]*\(.*\)/s%@RANLIB[@]%\1%/p' \
|
||||
-e '/^MACHDEP=/s/^MACHDEP=[ ]*\(.*\)/s%@MACHDEP[@]%\1%/p' \
|
||||
-e '/^SO=/s/^SO=[ ]*\(.*\)/s%@SO[@]%\1%/p' \
|
||||
-e '/^LDSHARED=/s/^LDSHARED=[ ]*\(.*\)/s%@LDSHARED[@]%\1%/p' \
|
||||
-e '/^CCSHARED=/s/^CCSHARED=[ ]*\(.*\)/s%@CCSHARED[@]%\1%/p' \
|
||||
-e '/^$L=/s/^$L=[ ]*\(.*\)/s%@$L[@]%\1%/p' \
|
||||
-e '/^$P=/s/^$P=\(.*\)/s%^$P=.*%$P=\1%/p' \
|
||||
-e '/^$E=/s/^$E=\(.*\)/s%^$E=.*%$E=\1%/p' \
|
||||
$(MAKEFILE) >sedscript
|
||||
echo "/^#@SET_CCC@/d" >>sedscript
|
||||
echo "/^installdir=/s%=.*%= $(installdir)%" >>sedscript
|
||||
echo "/^exec_installdir=/s%=.*%=$(exec_installdir)%" >>sedscript
|
||||
echo "/^srcdir=/s%=.*%= $(srcdir)%" >>sedscript
|
||||
echo "/^VPATH=/s%=.*%= $(VPATH)%" >>sedscript
|
||||
echo "/^LINKPATH=/s%=.*%= $(LINKPATH)%" >>sedscript
|
||||
echo "/^BASELIB=/s%=.*%= $(BASELIB)%" >>sedscript
|
||||
echo "/^BASESETUP=/s%=.*%= $(BASESETUP)%" >>sedscript
|
||||
|
||||
# Bootstrap target
|
||||
boot: clobber
|
||||
VERSION=`$(PYTHON) -c "import sys; print sys.version[:3]"`; \
|
||||
installdir=`$(PYTHON) -c "import sys; print sys.prefix"`; \
|
||||
exec_installdir=`$(PYTHON) -c "import sys; print sys.exec_prefix"`; \
|
||||
$(MAKE) -f Makefile.pre.in VPATH=$(VPATH) srcdir=$(srcdir) \
|
||||
VERSION=$$VERSION \
|
||||
installdir=$$installdir \
|
||||
exec_installdir=$$exec_installdir \
|
||||
Makefile
|
||||
|
||||
# Handy target to remove intermediate files and backups
|
||||
clean:
|
||||
-rm -f *.o *~
|
||||
|
||||
# Handy target to remove everything that is easily regenerated
|
||||
clobber: clean
|
||||
-rm -f *.a tags TAGS config.c Makefile.pre $(TARGET) sedscript
|
||||
-rm -f *.so *.sl so_locations
|
||||
|
||||
|
||||
# Handy target to remove everything you don't want to distribute
|
||||
distclean: clobber
|
||||
-rm -f Makefile Setup
|
||||
|
||||
|
||||
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#------------------------------------------------------------------------
|
||||
# Custom rules and dependencies added for wxPython
|
||||
#
|
||||
|
||||
WXP_VERSION=2.1b2
|
||||
|
||||
# WXP_SRCDIR=../wxPython/src
|
||||
|
||||
SWIGFLAGS=-c++ -shadow -python -dnone -I$(WXP_SRCDIR) -D__WXGTK__ $(SEPARATE)
|
||||
|
||||
|
||||
# Implicit rules to run SWIG
|
||||
$(GENCODEDIR)/%.cpp : %.i
|
||||
swig $(SWIGFLAGS) -c -o $@ $<
|
||||
|
||||
$(GENCODEDIR)/%.py : %.i
|
||||
swig $(SWIGFLAGS) -c -o $@ $<
|
||||
$(GENCODEDIR)/%.py : %.i
|
||||
swig $(SWIGFLAGS) -c -o $(GENCODEDIR)/tmp_wrap.cpp $<
|
||||
rm $(GENCODEDIR)/tmp_wrap.cpp
|
||||
|
||||
|
||||
wxInstall : sharedmods $(PYMODULES)
|
||||
if test ! -d $(TARGETDIR) ; then \
|
||||
mkdir $(TARGETDIR) ; else true ; fi
|
||||
if [ "$(SHAREDMODS)" != "" ]; then \
|
||||
chmod 755 $(SHAREDMODS); \
|
||||
cp $(SHAREDMODS) $(TARGETDIR); fi
|
||||
-for i in $(PYMODULES); do \
|
||||
cp $$i $(TARGETDIR); \
|
||||
done
|
||||
if [ "$(TARGETDIR)" != ".." ]; then \
|
||||
python $(LIBDEST)/compileall.py $(TARGETDIR); \
|
||||
python -O $(LIBDEST)/compileall.py $(TARGETDIR); \
|
||||
else \
|
||||
python $(LIBDEST)/compileall.py -l $(TARGETDIR); \
|
||||
python -O $(LIBDEST)/compileall.py -l $(TARGETDIR);\
|
||||
fi
|
||||
|
||||
|
||||
|
13
utils/wxPython/modules/lseditor/README
Normal file
13
utils/wxPython/modules/lseditor/README
Normal file
@ -0,0 +1,13 @@
|
||||
Aug. 2 1999 Harm van der Heijden
|
||||
|
||||
What's in here:
|
||||
|
||||
lseditorplugin
|
||||
-- minimal wrap of Alexanders Gluchovas' editor plugin. The code was
|
||||
ransacked from the wxStudio (http://wxstudio.linuxbox.com) project.
|
||||
Since the editor is released under the Gnu Public License, this
|
||||
module, as a derivative work, is also released under this licence
|
||||
and NOT THE WXWINDOWS LICENSE. See the file COPYING for details.
|
||||
the file 'editor.py' contains a sample implementation using the
|
||||
editorplugin object.
|
||||
|
49
utils/wxPython/modules/lseditor/Setup.in
Normal file
49
utils/wxPython/modules/lseditor/Setup.in
Normal file
@ -0,0 +1,49 @@
|
||||
## This file gives the details of what is needed to build this extension
|
||||
## module so the Makefile can be created.
|
||||
|
||||
## If you have not done "make install" for wxWindows then see Setup.in.linux
|
||||
## for a more verbose version of this file.
|
||||
|
||||
*shared*
|
||||
|
||||
CCC=c++
|
||||
WXWIN=../../..
|
||||
GENCODEDIR=gtk
|
||||
# srcdir=$(GENCODEDIR)
|
||||
WX_CONFIG_CFLAGS=`wx-config --cflags`
|
||||
WX_CONFIG_LIBS=`wx-config --libs`
|
||||
|
||||
|
||||
## Depending on how your Python was built, you may have to set this
|
||||
## value to use the C++ driver to link with instead of the default
|
||||
## C driver. For example:
|
||||
MY_LDSHARED=$(CCC) -shared
|
||||
|
||||
## Same as above, but for statically linking Python and wxPython together,
|
||||
## in other words, if you comment out the *shared* above. If this is the
|
||||
## case then you should ensure that the main() function is Python's, not
|
||||
## wxWindows'. You can rebuild $(WXWIN)/src/gtk/app.cpp with NOMAIN defined
|
||||
## to force this...
|
||||
MY_LINKCC=$(CCC)
|
||||
|
||||
|
||||
## Pick one of these, or set your own. This is where the wxPython module
|
||||
## should be installed. It should be a subdirectory named wxPython.
|
||||
#TARGETDIR=..
|
||||
TARGETDIR=$(BINLIBDEST)/site-packages/wxPython
|
||||
|
||||
# The location of the wxPython source dir
|
||||
WXP_SRCDIR=../../src
|
||||
|
||||
## define SEPARATE so that the individual modules 'know' at compile time
|
||||
## they're not going to be part of a big wxcmodule.so
|
||||
C_DEFINES = -DSWIG_GLOBAL -DWXP_USE_THREAD -DSEPARATE
|
||||
C_FLAGS = -I. -I$(WXP_SRCDIR) $(WX_CONFIG_CFLAGS)
|
||||
C_LIBS = -lwxPyHelpers $(WX_CONFIG_LIBS)
|
||||
|
||||
PYMODULES = $(GENCODEDIR)/lseditor.py
|
||||
|
||||
lseditorc $(GENCODEDIR)/lseditor.cpp finddlg.cpp lseditorpl.cpp markup.cpp \
|
||||
plugin.cpp sourcepainter.cpp tdefs.cpp \
|
||||
$(C_DEFINES) $(C_FLAGS) -Xlinker $(C_LIBS)
|
||||
|
82
utils/wxPython/modules/lseditor/config.h
Normal file
82
utils/wxPython/modules/lseditor/config.h
Normal file
@ -0,0 +1,82 @@
|
||||
/* config.h. Generated automatically by configure. */
|
||||
/* config.h.in. Generated automatically from configure.in by autoheader. */
|
||||
|
||||
/* Define if using alloca.c. */
|
||||
/* #undef C_ALLOCA */
|
||||
|
||||
/* Define to empty if the keyword does not work. */
|
||||
/* #undef const */
|
||||
|
||||
/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems.
|
||||
This function is required for alloca.c support on those systems. */
|
||||
/* #undef CRAY_STACKSEG_END */
|
||||
|
||||
/* Define if you have alloca, as a function or macro. */
|
||||
#define HAVE_ALLOCA 1
|
||||
|
||||
/* Define if you have <alloca.h> and it should be used (not on Ultrix). */
|
||||
#define HAVE_ALLOCA_H 1
|
||||
|
||||
/* Define as __inline if that's what the C compiler calls it. */
|
||||
/* #undef inline */
|
||||
|
||||
/* Define as the return type of signal handlers (int or void). */
|
||||
#define RETSIGTYPE void
|
||||
|
||||
/* Define to `unsigned' if <sys/types.h> doesn't define. */
|
||||
/* #undef size_t */
|
||||
|
||||
/* If using the C implementation of alloca, define if you know the
|
||||
direction of stack growth for your system; otherwise it will be
|
||||
automatically deduced at run-time.
|
||||
STACK_DIRECTION > 0 => grows toward higher addresses
|
||||
STACK_DIRECTION < 0 => grows toward lower addresses
|
||||
STACK_DIRECTION = 0 => direction of growth unknown
|
||||
*/
|
||||
/* #undef STACK_DIRECTION */
|
||||
|
||||
/* Define if you have the ANSI C header files. */
|
||||
#define STDC_HEADERS 1
|
||||
|
||||
/* Define if your <sys/time.h> declares struct tm. */
|
||||
/* #undef TM_IN_SYS_TIME */
|
||||
|
||||
/* Define to use template STL (vs. wxSTL) */
|
||||
#define wxUSE_TEMPLATE_STL 1
|
||||
|
||||
/* Define to use framelayout library */
|
||||
/* #undef wxsUSE_FRAME_LAYOUT */
|
||||
|
||||
/* Define to use class-info plugin */
|
||||
#define wxsUSE_CLASS_INFO 1
|
||||
|
||||
/* Define to use window manager plugin */
|
||||
#define wxsUSE_WINDOWMANAGER 1
|
||||
|
||||
/* Define if you have the strdup function. */
|
||||
#define HAVE_STRDUP 1
|
||||
|
||||
/* Define if you have the <fcntl.h> header file. */
|
||||
#define HAVE_FCNTL_H 1
|
||||
|
||||
/* Define if you have the <limits.h> header file. */
|
||||
#define HAVE_LIMITS_H 1
|
||||
|
||||
/* Define if you have the <malloc.h> header file. */
|
||||
#define HAVE_MALLOC_H 1
|
||||
|
||||
/* Define if you have the <strings.h> header file. */
|
||||
#define HAVE_STRINGS_H 1
|
||||
|
||||
/* Define if you have the <sys/time.h> header file. */
|
||||
#define HAVE_SYS_TIME_H 1
|
||||
|
||||
/* Define if you have the <unistd.h> header file. */
|
||||
#define HAVE_UNISTD_H 1
|
||||
|
||||
/* Name of package */
|
||||
#define PACKAGE "wxStudio"
|
||||
|
||||
/* Version number of package */
|
||||
#define VERSION "0.0.2"
|
||||
|
262
utils/wxPython/modules/lseditor/controlarea.h
Normal file
262
utils/wxPython/modules/lseditor/controlarea.h
Normal file
@ -0,0 +1,262 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: No names yet.
|
||||
// Purpose: Contrib. demo
|
||||
// Author: Aleksandras Gluchovas
|
||||
// Modified by:
|
||||
// Created: 07/09/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Aleksandras Gluchovas
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __CONTROLAREA_G__
|
||||
#define __CONTROLAREA_G__
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface "controlarea.h"
|
||||
#endif
|
||||
|
||||
#include "wx/defs.h"
|
||||
#include "wx/window.h"
|
||||
#include "wx/string.h"
|
||||
|
||||
#define WXCONTROLAREA_VERSION 1.0
|
||||
|
||||
// layout types for title bars of the tabs
|
||||
// (are selected up by evaluating the available free space )
|
||||
|
||||
class twTabInfo; // forward decl.
|
||||
|
||||
#define wxTITLE_IMG_AND_TEXT 0
|
||||
#define wxTITLE_IMG_ONLY 1
|
||||
#define wxTITLE_BORDER_ONLY 2
|
||||
|
||||
/*
|
||||
* class manages and decorates contained "tab"-windows.
|
||||
* Draws decorations similar to those in "Project Workplace"
|
||||
* of Microsoft Developer Studio 4.xx
|
||||
*/
|
||||
|
||||
class wxTabbedWindow : public wxPanel
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS( wxTabbedWindow )
|
||||
|
||||
public:
|
||||
|
||||
friend class wxTabbedWindowSerializer;
|
||||
|
||||
wxList mTabs;
|
||||
int mActiveTab;
|
||||
int mTitleHeight;
|
||||
int mLayoutType;
|
||||
|
||||
void HideInactiveTabs( bool andRepaint );
|
||||
|
||||
// overrride,to provide different font for tab-labels
|
||||
|
||||
virtual wxFont GetLabelingFont();
|
||||
|
||||
// FOR NOW:: scrollbars are actually related to wxPaggedWindow
|
||||
|
||||
wxScrollBar* mpTabScroll;
|
||||
wxScrollBar* mpHorizScroll;
|
||||
wxScrollBar* mpVertScroll;
|
||||
|
||||
public:
|
||||
|
||||
// public properties (invoke ReclaclLayout(TRUE) to apply changes)
|
||||
|
||||
wxPen mWhitePen; // default: RGB(255,255,255)
|
||||
wxPen mLightPen; // wxSYS_COLOUR_3DHIGHLIGHT
|
||||
wxPen mGrayPen; // wxSYS_COLOUR_3DFACE
|
||||
wxPen mDarkPen; // wxSYS_COLOUR_3DSHADOW
|
||||
wxPen mBlackPen; // default: RGB( 0, 0, 0)
|
||||
|
||||
int mVertGap; // default: 3
|
||||
int mHorizGap; // default: 5
|
||||
int mTitleVertGap; // default: 3
|
||||
int mTitleHorizGap; // default: 4
|
||||
int mImageTextGap; // default: 2
|
||||
int mFirstTitleGap; // default: 11
|
||||
int mBorderOnlyWidth; // default: 8
|
||||
|
||||
// notifications (can be handled by derivatives)
|
||||
|
||||
virtual void OnTabAdded( twTabInfo* pInfo ) {}
|
||||
|
||||
virtual void SizeTabs(int x,int y, int width, int height, bool repant);
|
||||
|
||||
public:
|
||||
wxTabbedWindow();
|
||||
virtual ~wxTabbedWindow();
|
||||
|
||||
// tabs can be also added when the window is
|
||||
// already displayed - "on the fly"
|
||||
|
||||
virtual void AddTab( wxWindow* pContent, // contained window
|
||||
wxString tabText, // tab label
|
||||
wxString imageFileName = "", // if "", only text label is displayed
|
||||
long imageType = wxBITMAP_TYPE_BMP );
|
||||
|
||||
// NOTE:: if this AddTab(..) overload is called, the
|
||||
// image bitmap will not be serialized (if performed),
|
||||
// use the above method instead, so that images could
|
||||
// be restored using the given file names
|
||||
|
||||
virtual void AddTab( wxWindow* pContent,
|
||||
wxString tabText,
|
||||
wxBitmap* pImage = NULL );
|
||||
|
||||
|
||||
virtual void RemoveTab( int tabNo );
|
||||
|
||||
/* misc accessors */
|
||||
|
||||
virtual int GetTabCount();
|
||||
virtual wxWindow* GetTab( int tabNo );
|
||||
virtual wxWindow* GetActiveTab();
|
||||
virtual void SetActiveTab( int tabNo );
|
||||
|
||||
void DrawShadedRect( int x, int y, int width, int height,
|
||||
wxPen& upperPen, wxPen& lowerPen, wxDC& dc );
|
||||
|
||||
virtual void DrawDecorations( wxDC& dc );
|
||||
|
||||
// return -1, if non of the title bars was hitted,
|
||||
// otherwise the index of the hitted tab title bar
|
||||
|
||||
virtual int HitTest( const wxPoint& pos );
|
||||
|
||||
// should be invoked to redisplay window with changed properties
|
||||
|
||||
virtual void RecalcLayout( bool andRepaint = TRUE );
|
||||
|
||||
// event handlers
|
||||
|
||||
void OnPaint( wxPaintEvent& event );
|
||||
void OnSize ( wxSizeEvent& event );
|
||||
|
||||
void OnBkErase( wxEraseEvent& event );
|
||||
void OnLButtonDown( wxMouseEvent& event );
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
/*
|
||||
* class manages and decorates contained "sheets" (or pages).
|
||||
* Draws decorations similar to those in "Output window"
|
||||
* of Microsoft Developer Studio 4.xx
|
||||
*/
|
||||
|
||||
class wxPaggedWindow : public wxTabbedWindow
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS( wxPaggedWindow )
|
||||
protected:
|
||||
|
||||
bool mScrollEventInProgress;
|
||||
|
||||
// drag&drop state variables
|
||||
|
||||
bool mIsDragged;
|
||||
int mDagOrigin;
|
||||
wxCursor mResizeCursor;
|
||||
wxCursor mNormalCursor;
|
||||
bool mCursorChanged;
|
||||
int mOriginalTitleRowLen;
|
||||
|
||||
void DrawPaperBar( twTabInfo& tab, int x, int y,
|
||||
wxBrush& brush, wxPen& pen, wxDC& dc );
|
||||
|
||||
int GetWholeTabRowLen();
|
||||
|
||||
// adjusts scorllbars to fit around tabs
|
||||
|
||||
virtual void OnTabAdded( twTabInfo* pInfo );
|
||||
|
||||
// sets smaller font for page-labels
|
||||
|
||||
virtual wxFont GetLabelingFont();
|
||||
|
||||
public:
|
||||
int mTitleRowStart;
|
||||
int mResizeNailGap;
|
||||
int mTabTrianGap;
|
||||
int mTitleRowLen; // actual title row length
|
||||
int mAdjustableTitleRowLen; // setup by dragging mini-sash
|
||||
// with the mosue pointer
|
||||
int mCurentRowOfs;
|
||||
|
||||
wxBrush mGrayBrush;
|
||||
wxBrush mWhiteBrush;
|
||||
|
||||
public:
|
||||
wxPaggedWindow();
|
||||
~wxPaggedWindow();
|
||||
|
||||
// NOTE:: use public methods of the base class
|
||||
// to add "pages" to this window
|
||||
|
||||
/* misc accessors */
|
||||
|
||||
// below two methods should be called after
|
||||
// the tabs were added (AddTab(..)). Set up
|
||||
// these scrollbars to match the needs of the
|
||||
// tabs added into this area
|
||||
|
||||
wxScrollBar& GetVerticalScrollBar();
|
||||
wxScrollBar& GetHorizontalScrollBar();
|
||||
|
||||
virtual void DrawDecorations( wxDC& dc );
|
||||
|
||||
// return -1, if non of the title bars was hitted,
|
||||
// otherwise the index of the hitted tab title bar
|
||||
|
||||
virtual int HitTest( const wxPoint& pos );
|
||||
|
||||
virtual void RecalcLayout( bool andRepaint = TRUE );
|
||||
|
||||
// event handlers
|
||||
|
||||
void OnPaint( wxPaintEvent& event );
|
||||
void OnSize ( wxSizeEvent& event );
|
||||
void OnLButtonDown( wxMouseEvent& event );
|
||||
void OnLButtonUp ( wxMouseEvent& event );
|
||||
void OnMouseMove ( wxMouseEvent& event );
|
||||
void OnScroll ( wxScrollEvent& event );
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
// helper structure of wxTabbedWindow
|
||||
|
||||
class twTabInfo : public wxObject
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS( twTabInfo )
|
||||
public:
|
||||
twTabInfo();
|
||||
~twTabInfo();
|
||||
|
||||
int ImgWidth();
|
||||
int ImgHeight();
|
||||
int ImageToTxtGap( int prefGap );
|
||||
|
||||
bool HasImg();
|
||||
wxBitmap& GetImg();
|
||||
bool HasText();
|
||||
wxString& GetText();
|
||||
wxWindow& GetContent();
|
||||
|
||||
public:
|
||||
wxWindow* mpContent;
|
||||
wxBitmap mBitMap;
|
||||
|
||||
wxString mText;
|
||||
wxSize mDims;
|
||||
|
||||
// used for serialization
|
||||
wxString mImageFile;
|
||||
long mImageType;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
153
utils/wxPython/modules/lseditor/editorpl.h
Normal file
153
utils/wxPython/modules/lseditor/editorpl.h
Normal file
@ -0,0 +1,153 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: editorbase.h
|
||||
// Purpose: General interfaces for editor plug-ins.
|
||||
// Author: Aleksandras Gluchovas
|
||||
// Modified by:
|
||||
// Created: 11/04/1999
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Aleskandars Gluchovas
|
||||
// Licence: GNU General Public License wxWindows licence v2.0
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __EDITORBASE_G__
|
||||
#define __EDITORBASE_G__
|
||||
|
||||
#include "plugin.h"
|
||||
#include "wx/window.h"
|
||||
|
||||
class wxsSourceEditorPlugin : public wxsComponent
|
||||
{
|
||||
protected:
|
||||
string mFileName;
|
||||
|
||||
public:
|
||||
/*** overridables (with default implementations) ***/
|
||||
|
||||
// user-level commands
|
||||
|
||||
virtual void OnOpen( const string& fname ) = 0;
|
||||
virtual void OnSave( const string& fname ) = 0;
|
||||
|
||||
virtual void OnCopy() {}
|
||||
virtual void OnCut() {}
|
||||
virtual void OnPaste() {}
|
||||
virtual void OnDelete() {}
|
||||
|
||||
virtual void OnUndo() {}
|
||||
virtual void OnRedo() {}
|
||||
|
||||
virtual void SelectAll() {}
|
||||
|
||||
// NOTE:: column -1 should result cursor to appear
|
||||
// at the start of the first word in the line (if any)
|
||||
|
||||
virtual void OnGotoLine( int lineNo, int column = -1 ) {}
|
||||
|
||||
// should invoke editor's own "goto-line" dialog
|
||||
virtual void OnGotoLine() {}
|
||||
|
||||
virtual void OnProperties() {}
|
||||
|
||||
virtual void OnFind() {}
|
||||
virtual void OnFindNext() {}
|
||||
virtual void OnFindPrevious() {}
|
||||
virtual void OnReplace() {}
|
||||
|
||||
virtual void OnToggleBookmark() {}
|
||||
virtual void OnNextBookmark() {}
|
||||
virtual void OnPreviousBookmark() {}
|
||||
virtual void OnShowBookmarks() {}
|
||||
|
||||
virtual void SetCheckpoint() {}
|
||||
virtual bool CheckpointModified() { return TRUE; }
|
||||
|
||||
// UI-updates
|
||||
|
||||
virtual bool CanCopy() { return FALSE; }
|
||||
virtual bool CanCut() { return FALSE; }
|
||||
virtual bool CanPaste() { return FALSE; }
|
||||
virtual bool CanUndo() { return FALSE; }
|
||||
virtual bool CanRedo() { return FALSE; }
|
||||
|
||||
// accesed by framework
|
||||
|
||||
virtual bool IsModified() { return TRUE; }
|
||||
|
||||
// returned buffer is NULL, if operation is not supported
|
||||
// by this concrete editor
|
||||
|
||||
virtual void GetAllText( char** ppBuf, size_t* length )
|
||||
|
||||
{ *ppBuf = NULL; *length = 0; }
|
||||
|
||||
virtual string FindWordAtCursor() = 0;
|
||||
|
||||
// returned line and column are -1s, if operation
|
||||
// is not supported this concrete editor
|
||||
|
||||
virtual void GetCursorPos( int* line, int* column )
|
||||
|
||||
{ *line = -1; *column = -1; }
|
||||
|
||||
virtual void GetPagePos( int* line, int* column )
|
||||
|
||||
{ *line = -1; *column = -1; }
|
||||
|
||||
virtual void SetCursorPos( int line, int column ) {}
|
||||
|
||||
// returned buffer is NULL, if operation is not supported
|
||||
// by this concrete editor,
|
||||
// (NOTE: range is given from "fromLine", but not
|
||||
// including tillLine, [fomrLine,tillLine) )
|
||||
|
||||
virtual void GetText( int fromLine, int fromColumn,
|
||||
int tillLine, int tillColumn,
|
||||
char** ppBuf, size_t* length )
|
||||
{ ppBuf = NULL; }
|
||||
|
||||
virtual void InsertText( int line, int column,
|
||||
char* text, size_t lenght )
|
||||
{}
|
||||
|
||||
virtual void DeleteText( int fromLine, int fromColumn,
|
||||
int tillLine, int tillColumn )
|
||||
{}
|
||||
|
||||
virtual void PositionToXY( int line, int column, int* x, int* y )
|
||||
|
||||
{ *x = -1; *y = -1; }
|
||||
|
||||
virtual void GetSelectionRange( int* fromLine, int* fromColumn,
|
||||
int* tillLine, int* tillColumn )
|
||||
|
||||
{ *fromLine = -1; // not supported by default
|
||||
}
|
||||
|
||||
virtual wxSize GetCharacterSize() { return wxSize(-1,-1); }
|
||||
|
||||
virtual bool IsUnixText()
|
||||
|
||||
// default impl., actual implementation should use auto-detection
|
||||
|
||||
#ifdef __WINDOWS__
|
||||
{ return FALSE; }
|
||||
#else
|
||||
{ return TRUE; }
|
||||
#endif
|
||||
|
||||
// requests editor to keep cursor blinking, even when
|
||||
// the window has lost it's focus
|
||||
|
||||
virtual void HoldCursor( bool hold )
|
||||
{}
|
||||
|
||||
virtual string GetFileName() { return mFileName; }
|
||||
virtual void SetFileName( const string& fname ) { mFileName = fname; }
|
||||
|
||||
// overriden methods of wxStudioPluginBase
|
||||
virtual WXS_PLUGIN_TYPE GetType() {return WXS_EDITOR_PLUGIN;}
|
||||
virtual string GetCategory() { return "Editor";}
|
||||
};
|
||||
|
||||
#endif
|
||||
// __EDITORBASE_G__
|
146
utils/wxPython/modules/lseditor/finddlg.cpp
Normal file
146
utils/wxPython/modules/lseditor/finddlg.cpp
Normal file
@ -0,0 +1,146 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: No names yet.
|
||||
// Purpose: Contrib. demo
|
||||
// Author: Aleksandras Gluchovas
|
||||
// Modified by:
|
||||
// Created: 08/05/1999
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Aleksandars Gluchovas
|
||||
// Licence: GNU General Public License
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// For compilers that support precompilation, includes "wx/wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/wx.h"
|
||||
#endif
|
||||
|
||||
#include "finddlg.h"
|
||||
|
||||
/***** Implementation for class wxFindTextDialog *****/
|
||||
|
||||
//#define wxID_OK 3453453
|
||||
|
||||
BEGIN_EVENT_TABLE( wxFindTextDialog, wxDialog )
|
||||
|
||||
// FIXME:: why OnOk() is not called??
|
||||
//EVT_BUTTON( wxID_OK, wxFindTextDialog::OnOK )
|
||||
|
||||
EVT_CHAR_HOOK(wxFindTextDialog::OnKeyHook)
|
||||
|
||||
END_EVENT_TABLE()
|
||||
|
||||
wxString wxFindTextDialog::mLastExpr;
|
||||
bool wxFindTextDialog::mMatchCase = TRUE;
|
||||
bool wxFindTextDialog::mMatchWord = FALSE;
|
||||
StrListT wxFindTextDialog::mExprList;
|
||||
|
||||
// FIXME:: workaround for mystic. crashes wiht MSDev4.0
|
||||
|
||||
static wxComboBox* __gpCombo = NULL;
|
||||
|
||||
wxFindTextDialog::wxFindTextDialog( wxWindow* parent, const string& expr )
|
||||
|
||||
: wxDialog( parent, -1, "Find",
|
||||
wxDefaultPosition, wxSize( 335, 130 ),
|
||||
wxDIALOG_MODAL | wxCAPTION | wxTAB_TRAVERSAL |
|
||||
wxDEFAULT_DIALOG_STYLE
|
||||
)
|
||||
{
|
||||
mLastExpr = expr;
|
||||
|
||||
int leftMargin = 20;
|
||||
int inputY = 20;
|
||||
int inputWidth = 200;
|
||||
|
||||
wxStaticText* pStatic =
|
||||
new wxStaticText( this, -1, "Fi&nd what:",
|
||||
wxPoint( leftMargin, inputY ) );
|
||||
|
||||
int checkY = inputY + 25;
|
||||
|
||||
mpWordCheck = new wxCheckBox( this, -1, "Match &whole word only",
|
||||
wxPoint( leftMargin, checkY ) );
|
||||
|
||||
mpCaseCheck = new wxCheckBox( this, -1, "Match &case",
|
||||
wxPoint( leftMargin, checkY + 20 ) );
|
||||
|
||||
mpCaseCheck->SetValue( mMatchCase );
|
||||
mpWordCheck->SetValue( mMatchWord );
|
||||
|
||||
int btnX = inputWidth + leftMargin + 23;
|
||||
int btnY = inputY - 4;
|
||||
|
||||
wxSize btnSize( 70, 25 );
|
||||
|
||||
wxButton* pOkBtn = new wxButton( this, wxID_OK, "&Find",
|
||||
wxPoint( btnX, btnY ), btnSize );
|
||||
|
||||
wxButton* pCancelBtn = new wxButton( this, wxID_CANCEL, "&Cancel",
|
||||
wxPoint( btnX, btnY + 10 + btnSize.y ), btnSize );
|
||||
|
||||
__gpCombo = new wxComboBox( this, -1, mLastExpr,
|
||||
wxPoint( leftMargin + 60, inputY - 2 ),
|
||||
wxSize( inputWidth - 50, 20 ) );
|
||||
|
||||
for( size_t i = 0; i != mExprList.size(); ++i )
|
||||
|
||||
__gpCombo->Append( mExprList[i] );
|
||||
|
||||
pOkBtn->SetDefault();
|
||||
__gpCombo->SetFocus();
|
||||
|
||||
Center( wxBOTH );
|
||||
}
|
||||
|
||||
void wxFindTextDialog::SetExpr( const wxString& expr )
|
||||
{
|
||||
mLastExpr = expr;
|
||||
__gpCombo->SetValue( mLastExpr );
|
||||
|
||||
}
|
||||
|
||||
wxComboBox* wxFindTextDialog::GetCombo()
|
||||
{
|
||||
return __gpCombo;
|
||||
}
|
||||
|
||||
bool wxFindTextDialog::TransferDataFromWindow()
|
||||
{
|
||||
mLastExpr = GetCombo()->GetValue();
|
||||
mMatchCase = mpCaseCheck->GetValue();
|
||||
mMatchWord = mpWordCheck->GetValue();
|
||||
|
||||
if ( mLastExpr != "" )
|
||||
{
|
||||
for( size_t i = 0; i != mExprList.size(); ++i )
|
||||
|
||||
if ( mExprList[i] == mLastExpr )
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if ( mExprList.size() > 20 )
|
||||
|
||||
mExprList.pop_back();
|
||||
|
||||
mExprList.push_back( mLastExpr );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void wxFindTextDialog::OnKeyHook( wxKeyEvent& event )
|
||||
{
|
||||
if ( event.m_keyCode == WXK_RETURN )
|
||||
{
|
||||
TransferDataFromWindow();
|
||||
EndModal( wxID_OK );
|
||||
}
|
||||
else
|
||||
event.Skip();
|
||||
}
|
38
utils/wxPython/modules/lseditor/finddlg.h
Normal file
38
utils/wxPython/modules/lseditor/finddlg.h
Normal file
@ -0,0 +1,38 @@
|
||||
#ifndef __FINDDLG_G__
|
||||
#define __FINDDLG_G__
|
||||
|
||||
#include "wx/dialog.h"
|
||||
#include "wx/checkbox.h"
|
||||
#include "wx/combobox.h"
|
||||
|
||||
#include "wxstldefs.h"
|
||||
|
||||
class wxFindTextDialog : public wxDialog
|
||||
{
|
||||
public:
|
||||
static wxString mLastExpr;
|
||||
static bool mMatchCase;
|
||||
static bool mMatchWord;
|
||||
static StrListT mExprList;
|
||||
|
||||
wxCheckBox* mpCaseCheck;
|
||||
wxCheckBox* mpWordCheck;
|
||||
|
||||
public:
|
||||
wxFindTextDialog( wxWindow* parent, const string& expr = "" );
|
||||
|
||||
bool MatchWordOn() { return mMatchWord; }
|
||||
bool MatchCaseOn() { return mMatchCase; }
|
||||
wxString GetExpr() { return mLastExpr; }
|
||||
void SetExpr( const wxString& expr );
|
||||
|
||||
wxComboBox* GetCombo();
|
||||
|
||||
virtual bool TransferDataFromWindow();
|
||||
|
||||
void OnKeyHook( wxKeyEvent& event );
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
#endif
|
150
utils/wxPython/modules/lseditor/lseditor.i
Normal file
150
utils/wxPython/modules/lseditor/lseditor.i
Normal file
@ -0,0 +1,150 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: utils.i
|
||||
// Purpose: SWIG definitions of various utility classes
|
||||
//
|
||||
// Author: Robin Dunn
|
||||
//
|
||||
// Created: 25-nov-1998
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 1998 by Total Control Software
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
%module lseditor
|
||||
|
||||
%{
|
||||
#include "helpers.h"
|
||||
#include "lseditorpl.h"
|
||||
%}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
%include typemaps.i
|
||||
%include my_typemaps.i
|
||||
|
||||
%extern wx.i
|
||||
%extern windows.i
|
||||
%extern windows2.i
|
||||
%extern windows3.i
|
||||
%extern frames.i
|
||||
%extern _defs.i
|
||||
%extern misc.i
|
||||
%extern gdi.i
|
||||
%extern controls.i
|
||||
%extern events.i
|
||||
|
||||
|
||||
%{
|
||||
#ifdef SEPARATE
|
||||
wxString wxPyEmptyStr("");
|
||||
#endif
|
||||
%}
|
||||
|
||||
%pragma(python) code = "import wx"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
class wxsLSEditorPlugin
|
||||
{
|
||||
public:
|
||||
wxsLSEditorPlugin();
|
||||
~wxsLSEditorPlugin();
|
||||
|
||||
void Create( wxWindow* parent, wxWindowID id );
|
||||
|
||||
virtual void OnOpen( const char* fname );
|
||||
virtual void OnSave( const char* fname );
|
||||
|
||||
virtual void OnCopy();
|
||||
virtual void OnCut();
|
||||
virtual void OnPaste();
|
||||
virtual void OnDelete();
|
||||
|
||||
void OnUndo();
|
||||
void OnRedo();
|
||||
|
||||
void SelectAll();
|
||||
void OnGotoLine( int lineNo, int column = 0 );
|
||||
void OnGotoLine();
|
||||
void OnProperties();
|
||||
|
||||
void OnFind();
|
||||
void OnFindNext();
|
||||
void OnFindPrevious();
|
||||
void OnReplace();
|
||||
|
||||
virtual void OnToggleBookmark();
|
||||
virtual void OnNextBookmark();
|
||||
virtual void OnPreviousBookmark();
|
||||
virtual void OnShowBookmarks();
|
||||
|
||||
virtual void SetCheckpoint();
|
||||
virtual bool CheckpointModified();
|
||||
|
||||
// UI-updates
|
||||
|
||||
bool CanCopy();
|
||||
bool CanCut();
|
||||
bool CanPaste();
|
||||
bool CanUndo();
|
||||
bool CanRedo();
|
||||
|
||||
// accesed by framework
|
||||
|
||||
virtual string GetName(){ return "Alex's Language Sensitive Editor"; }
|
||||
|
||||
virtual bool IsModified();
|
||||
|
||||
virtual wxWindow* GetWindow();
|
||||
|
||||
//virtual void GetAllText( char** ppBuf, size_t* length );
|
||||
|
||||
virtual void SetFileName( const char* fname );
|
||||
|
||||
virtual void HoldCursor( bool hold );
|
||||
|
||||
//virtual wxsPluginBase* Clone() { return new wxsLSEditorPlugin(); };
|
||||
|
||||
virtual string FindWordAtCursor();
|
||||
|
||||
virtual void GetCursorPos( int* line, int* column );
|
||||
virtual void SetCursorPos( int line, int column );
|
||||
|
||||
virtual void GetPagePos( int* line, int* column );
|
||||
|
||||
virtual void GetText( int fromLine, int fromColumn,
|
||||
int tillLine, int tillColumn,
|
||||
char** ppBuf, size_t* length );
|
||||
|
||||
virtual void InsertText( int line, int column,
|
||||
char* text, size_t lenght );
|
||||
|
||||
virtual void DeleteText( int fromLine, int fromColumn,
|
||||
int tillLine, int tillColumn );
|
||||
|
||||
virtual void PositionToXY( int line, int column, int* x, int* y );
|
||||
|
||||
virtual void GetSelectionRange( int* fromLine, int* fromColumn,
|
||||
int* tillLine, int* tillColumn );
|
||||
|
||||
virtual wxSize GetCharacterSize();
|
||||
|
||||
virtual bool IsUnixText();
|
||||
|
||||
// some extras (just in case..)
|
||||
|
||||
//wxTextEditorModel& GetModel();
|
||||
//wxTextEditorView& GetView();
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
%init %{
|
||||
|
||||
wxClassInfo::CleanUpClasses();
|
||||
wxClassInfo::InitializeClasses();
|
||||
|
||||
%}
|
||||
|
||||
//---------------------------------------------------------------------------
|
2
utils/wxPython/modules/lseditor/lseditorc.def
Normal file
2
utils/wxPython/modules/lseditor/lseditorc.def
Normal file
@ -0,0 +1,2 @@
|
||||
EXPORTS
|
||||
initlseditorc
|
344
utils/wxPython/modules/lseditor/lseditorpl.cpp
Normal file
344
utils/wxPython/modules/lseditor/lseditorpl.cpp
Normal file
@ -0,0 +1,344 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: lseditorpl.cpp
|
||||
// Purpose: Language-sensative editor plugin for wxStudio
|
||||
// Copyright: (c) Aleksandars Gluchovas
|
||||
// Modified by:
|
||||
// Created: 11/04/1999
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Aleskandars Gluchovas
|
||||
// Licence: GNU General Public License
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
// For compilers that support precompilation, includes "wx/wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/wx.h"
|
||||
#endif
|
||||
|
||||
|
||||
#include "lseditorpl.h"
|
||||
#include "tdefs.h"
|
||||
|
||||
/***** Impelmentation for class wxsLSEditorPlugin *****/
|
||||
|
||||
wxsLSEditorPlugin::wxsLSEditorPlugin()
|
||||
|
||||
: mpModel( NULL ),
|
||||
mpView( NULL )
|
||||
{}
|
||||
|
||||
wxsLSEditorPlugin::~wxsLSEditorPlugin()
|
||||
{
|
||||
// view is destroyed by wxWindows along
|
||||
// with it's owned model
|
||||
}
|
||||
|
||||
void wxsLSEditorPlugin::Create( wxWindow* parent, wxWindowID id )
|
||||
{
|
||||
mpModel = new wxTextEditorModel();
|
||||
|
||||
mpView = new wxTextEditorView( parent, id, mpModel );
|
||||
|
||||
mpModel->AddView( mpView );
|
||||
mpView->Activate();
|
||||
|
||||
mpView->AddPinPainter( new TBreakpointPainter() );
|
||||
|
||||
mpView->SyncScrollbars();
|
||||
}
|
||||
|
||||
void wxsLSEditorPlugin::OnOpen( const string& fname )
|
||||
{
|
||||
mpModel->LoadTextFromFile( fname );
|
||||
|
||||
SetFileName( fname );
|
||||
}
|
||||
|
||||
void wxsLSEditorPlugin::OnSave( const string& fname )
|
||||
{
|
||||
mpModel->SaveTextToFile( fname );
|
||||
}
|
||||
|
||||
void wxsLSEditorPlugin::OnCopy()
|
||||
{
|
||||
mpModel->OnCopy();
|
||||
}
|
||||
|
||||
void wxsLSEditorPlugin::OnCut()
|
||||
{
|
||||
mpModel->OnCut();
|
||||
}
|
||||
|
||||
void wxsLSEditorPlugin::OnPaste()
|
||||
{
|
||||
mpModel->OnPaste();
|
||||
}
|
||||
|
||||
void wxsLSEditorPlugin::OnDelete()
|
||||
{
|
||||
mpModel->OnDelete();
|
||||
}
|
||||
|
||||
void wxsLSEditorPlugin::OnUndo()
|
||||
{
|
||||
mpModel->OnUndo();
|
||||
}
|
||||
|
||||
void wxsLSEditorPlugin::OnRedo()
|
||||
{
|
||||
mpModel->OnRedo();
|
||||
}
|
||||
|
||||
void wxsLSEditorPlugin::SelectAll()
|
||||
{
|
||||
mpModel->OnSelectAll();
|
||||
}
|
||||
|
||||
void wxsLSEditorPlugin::OnGotoLine()
|
||||
{
|
||||
mpModel->OnGotoLine();
|
||||
}
|
||||
|
||||
void wxsLSEditorPlugin::OnGotoLine( int lineNo, int column )
|
||||
{
|
||||
mpModel->ResetSelection();
|
||||
mpModel->OnGotoLine( lineNo, column );
|
||||
}
|
||||
|
||||
void wxsLSEditorPlugin::OnProperties()
|
||||
{
|
||||
// not impl.
|
||||
}
|
||||
|
||||
void wxsLSEditorPlugin::OnFind()
|
||||
{
|
||||
mpModel->OnFind();
|
||||
}
|
||||
|
||||
void wxsLSEditorPlugin::OnFindNext()
|
||||
{
|
||||
mpModel->OnFindNext();
|
||||
}
|
||||
|
||||
void wxsLSEditorPlugin::OnFindPrevious()
|
||||
{
|
||||
mpModel->OnFindPrevious();
|
||||
}
|
||||
|
||||
void wxsLSEditorPlugin::OnReplace()
|
||||
{
|
||||
// not impl.
|
||||
}
|
||||
|
||||
void wxsLSEditorPlugin::OnToggleBookmark()
|
||||
{
|
||||
mpModel->OnToggleBookmark();
|
||||
}
|
||||
|
||||
void wxsLSEditorPlugin::OnNextBookmark()
|
||||
{
|
||||
mpModel->OnNextBookmark();
|
||||
}
|
||||
|
||||
void wxsLSEditorPlugin::OnPreviousBookmark()
|
||||
{
|
||||
mpModel->OnPreviousBookmark();
|
||||
}
|
||||
|
||||
void wxsLSEditorPlugin::OnShowBookmarks()
|
||||
{
|
||||
// not impl.
|
||||
}
|
||||
|
||||
void wxsLSEditorPlugin::SetCheckpoint()
|
||||
{
|
||||
mpModel->SetCheckpoint();
|
||||
}
|
||||
|
||||
bool wxsLSEditorPlugin::CheckpointModified()
|
||||
{
|
||||
return mpModel->CheckpointModified();
|
||||
}
|
||||
|
||||
// UI-updates
|
||||
|
||||
bool wxsLSEditorPlugin::CanCopy()
|
||||
{
|
||||
return mpModel->CanCopy();
|
||||
}
|
||||
|
||||
bool wxsLSEditorPlugin::CanCut()
|
||||
{
|
||||
return mpModel->CanCopy();
|
||||
}
|
||||
|
||||
bool wxsLSEditorPlugin::CanPaste()
|
||||
{
|
||||
return mpModel->CanPaste();
|
||||
}
|
||||
|
||||
bool wxsLSEditorPlugin::CanUndo()
|
||||
{
|
||||
return mpModel->CanUndo();
|
||||
}
|
||||
|
||||
bool wxsLSEditorPlugin::CanRedo()
|
||||
{
|
||||
return mpModel->CanRedo();
|
||||
}
|
||||
|
||||
// accesed by framework
|
||||
|
||||
bool wxsLSEditorPlugin::IsModified()
|
||||
{
|
||||
return mpModel->IsModified();
|
||||
}
|
||||
|
||||
wxWindow* wxsLSEditorPlugin::GetWindow()
|
||||
{
|
||||
return mpView;
|
||||
}
|
||||
|
||||
void wxsLSEditorPlugin::GetAllText( char** ppBuf, size_t* length )
|
||||
{
|
||||
mpModel->GetAllText( ppBuf, *length );
|
||||
}
|
||||
|
||||
void wxsLSEditorPlugin::SetFileName( const string& fname )
|
||||
{
|
||||
mFileName = fname;
|
||||
|
||||
if ( mpView )
|
||||
|
||||
mpView->SetName( fname );
|
||||
}
|
||||
|
||||
void wxsLSEditorPlugin::HoldCursor( bool hold )
|
||||
{
|
||||
mpView->HoldCursor( hold );
|
||||
}
|
||||
|
||||
string wxsLSEditorPlugin::FindWordAtCursor()
|
||||
{
|
||||
mpModel->OnSelectWord();
|
||||
|
||||
char* buf = NULL; size_t len = 0;
|
||||
|
||||
mpModel->GetSelection( &buf, len );
|
||||
|
||||
if ( buf )
|
||||
{
|
||||
string word = string( buf, 0, len );
|
||||
delete [] buf;
|
||||
return word;
|
||||
}
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
void wxsLSEditorPlugin::GetCursorPos( int* line, int* column )
|
||||
{
|
||||
TPosition pos = mpModel->GetCursor();
|
||||
|
||||
*line = (int)pos.mRow;
|
||||
*column = (int)pos.mCol;
|
||||
}
|
||||
|
||||
void wxsLSEditorPlugin::SetCursorPos( int line, int column )
|
||||
{
|
||||
mpModel->OnGotoLine( line, column );
|
||||
}
|
||||
|
||||
void wxsLSEditorPlugin::GetPagePos( int* line, int* column )
|
||||
{
|
||||
TPosition pos = mpView->GetPagePos();
|
||||
|
||||
*line = pos.mRow;
|
||||
*column = pos.mCol;
|
||||
}
|
||||
|
||||
void wxsLSEditorPlugin::GetText( int fromLine, int fromColumn,
|
||||
int tillLine, int tillColumn,
|
||||
char** ppBuf, size_t* length )
|
||||
{
|
||||
mpModel->GetTextFromRange( TPosition( fromLine, fromColumn ),
|
||||
TPosition( tillLine, tillColumn ),
|
||||
ppBuf, *length );
|
||||
}
|
||||
|
||||
void wxsLSEditorPlugin::InsertText( int line, int column,
|
||||
char* text, size_t lenght )
|
||||
{
|
||||
mpModel->InsertText( TPosition( line, column ),
|
||||
text, lenght );
|
||||
}
|
||||
|
||||
void wxsLSEditorPlugin::DeleteText( int fromLine, int fromColumn,
|
||||
int tillLine, int tillColumn )
|
||||
{
|
||||
mpModel->DeleteRange( TPosition( fromLine, fromColumn ),
|
||||
TPosition( tillLine, tillColumn ) );
|
||||
}
|
||||
|
||||
void wxsLSEditorPlugin::PositionToXY( int line, int column, int* x, int* y )
|
||||
{
|
||||
TPosition scrPos;
|
||||
|
||||
mpView->TextPosToScreenPos( TPosition( line, column ), scrPos );
|
||||
mpView->ScreenPosToPixels( scrPos, *x, *y );
|
||||
|
||||
*y += mpView->mCharDim.y; // lower-right corner
|
||||
}
|
||||
|
||||
void wxsLSEditorPlugin::GetSelectionRange( int* fromLine, int* fromColumn,
|
||||
int* tillLine, int* tillColumn )
|
||||
{
|
||||
TPosition start = mpModel->GetStartOfSelection();
|
||||
TPosition end = mpModel->GetEndOfSelection();
|
||||
|
||||
*fromLine = (int)start.mRow;
|
||||
*fromColumn = (int)start.mCol;
|
||||
*tillLine = (int)end.mRow;
|
||||
*tillColumn = (int)end.mCol;
|
||||
}
|
||||
|
||||
wxSize wxsLSEditorPlugin::GetCharacterSize()
|
||||
{
|
||||
return mpView->GetCharacterSize();
|
||||
}
|
||||
|
||||
bool wxsLSEditorPlugin::IsUnixText()
|
||||
{
|
||||
return mpModel->IsUnixText();
|
||||
}
|
||||
|
||||
wxTextEditorModel& wxsLSEditorPlugin::GetModel()
|
||||
{
|
||||
return *mpModel;
|
||||
}
|
||||
|
||||
wxTextEditorView& wxsLSEditorPlugin::GetView()
|
||||
{
|
||||
return *mpView;
|
||||
}
|
133
utils/wxPython/modules/lseditor/lseditorpl.h
Normal file
133
utils/wxPython/modules/lseditor/lseditorpl.h
Normal file
@ -0,0 +1,133 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: nativeeditorpl.h
|
||||
// Purpose: Language-sensative editor plugin for wxStudio
|
||||
// Author: Aleksandras Gluchovas
|
||||
// Modified by:
|
||||
// Created: 11/04/1999
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Aleskandars Gluchovas
|
||||
// Licence: GNU General Public License
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __LSEDITORPL_G__
|
||||
#define __LSEDITORPL_G__
|
||||
|
||||
#include "editorpl.h"
|
||||
|
||||
class wxTextEditorModel;
|
||||
class wxTextEditorView;
|
||||
|
||||
class wxsLSEditorPlugin : public wxsSourceEditorPlugin
|
||||
{
|
||||
protected:
|
||||
wxTextEditorModel* mpModel;
|
||||
wxTextEditorView* mpView;
|
||||
|
||||
public:
|
||||
wxsLSEditorPlugin();
|
||||
~wxsLSEditorPlugin();
|
||||
|
||||
void Create( wxWindow* parent, wxWindowID id );
|
||||
|
||||
virtual void OnOpen( const string& fname );
|
||||
virtual void OnSave( const string& fname );
|
||||
|
||||
virtual void OnCopy();
|
||||
virtual void OnCut();
|
||||
virtual void OnPaste();
|
||||
virtual void OnDelete();
|
||||
|
||||
void OnUndo();
|
||||
void OnRedo();
|
||||
|
||||
void SelectAll();
|
||||
void OnGotoLine( int lineNo, int column = 0 );
|
||||
void OnGotoLine();
|
||||
void OnProperties();
|
||||
|
||||
void OnFind();
|
||||
void OnFindNext();
|
||||
void OnFindPrevious();
|
||||
void OnReplace();
|
||||
|
||||
virtual void OnToggleBookmark();
|
||||
virtual void OnNextBookmark();
|
||||
virtual void OnPreviousBookmark();
|
||||
virtual void OnShowBookmarks();
|
||||
|
||||
virtual void SetCheckpoint();
|
||||
virtual bool CheckpointModified();
|
||||
|
||||
// UI-updates
|
||||
|
||||
bool CanCopy();
|
||||
bool CanCut();
|
||||
bool CanPaste();
|
||||
bool CanUndo();
|
||||
bool CanRedo();
|
||||
|
||||
// accesed by framework
|
||||
|
||||
virtual string GetName(){ return "Alex's Language Sensitive Editor"; }
|
||||
|
||||
virtual bool IsModified();
|
||||
|
||||
virtual wxWindow* GetWindow();
|
||||
|
||||
virtual void GetAllText( char** ppBuf, size_t* length );
|
||||
|
||||
virtual void SetFileName( const string& fname );
|
||||
|
||||
virtual void HoldCursor( bool hold );
|
||||
|
||||
virtual wxsPluginBase* Clone() { return new wxsLSEditorPlugin(); };
|
||||
|
||||
virtual string FindWordAtCursor();
|
||||
|
||||
virtual void GetCursorPos( int* line, int* column );
|
||||
virtual void SetCursorPos( int line, int column );
|
||||
|
||||
virtual void GetPagePos( int* line, int* column );
|
||||
|
||||
virtual void GetText( int fromLine, int fromColumn,
|
||||
int tillLine, int tillColumn,
|
||||
char** ppBuf, size_t* length );
|
||||
|
||||
virtual void InsertText( int line, int column,
|
||||
char* text, size_t lenght );
|
||||
|
||||
virtual void DeleteText( int fromLine, int fromColumn,
|
||||
int tillLine, int tillColumn );
|
||||
|
||||
virtual void PositionToXY( int line, int column, int* x, int* y );
|
||||
|
||||
virtual void GetSelectionRange( int* fromLine, int* fromColumn,
|
||||
int* tillLine, int* tillColumn );
|
||||
|
||||
virtual wxSize GetCharacterSize();
|
||||
|
||||
virtual bool IsUnixText();
|
||||
|
||||
// some extras (just in case..)
|
||||
|
||||
wxTextEditorModel& GetModel();
|
||||
wxTextEditorView& GetView();
|
||||
};
|
||||
|
||||
#endif
|
||||
// __LSEDITORPL_G__
|
46
utils/wxPython/modules/lseditor/markup.cpp
Normal file
46
utils/wxPython/modules/lseditor/markup.cpp
Normal file
@ -0,0 +1,46 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: No names yet.
|
||||
// Purpose: Contrib. demo
|
||||
// Author: Aleksandras Gluchovas
|
||||
// Modified by:
|
||||
// Created: 22/09/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Aleskandars Gluchovas
|
||||
// Licence: GNU General Public License
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// For compilers that support precompilation, includes "wx/wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/wx.h"
|
||||
#endif
|
||||
|
||||
#include "markup.h"
|
||||
|
||||
static TagStructT htmlTags[] =
|
||||
{
|
||||
{ "<b>","</b>" }, // 0
|
||||
{ "<i>","</i>" }, // 1
|
||||
{ "<pre>","</pre>" }, // 2
|
||||
{ "<font color=\"#000000\">","</font>" }, // 3
|
||||
{ "<font color=\"#8F0000\">","</font>" }, // 4
|
||||
{ "<font color=\"#008F00\">","</font>" }, // 5
|
||||
{ "<font color=\"#0000CF\">","</font>" }, // 6
|
||||
{ "<p>","</p>" }, // 7
|
||||
{ "<br>","" }, // 8
|
||||
{ "<h1>","</h1>" }, // 9
|
||||
{ "<h2>","</h2>" }, // 10
|
||||
{ "<h3>","</h3>" }, // 11
|
||||
{ "<ul>","</ul>" }, // 12
|
||||
{ "<li>","</li>" }, // 13
|
||||
};
|
||||
|
||||
MarkupTagsT get_HTML_markup_tags()
|
||||
{
|
||||
return htmlTags;
|
||||
}
|
51
utils/wxPython/modules/lseditor/markup.h
Normal file
51
utils/wxPython/modules/lseditor/markup.h
Normal file
@ -0,0 +1,51 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: No names yet.
|
||||
// Purpose: Contrib. demo
|
||||
// Author: Aleksandras Gluchovas
|
||||
// Modified by:
|
||||
// Created: 22/09/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Aleskandars Gluchovas
|
||||
// Licence: GNU General Public License
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __MARKUP_G__
|
||||
#define __MARKUP_G__
|
||||
|
||||
// indicies for the MarkupTagsT array
|
||||
|
||||
#define TAG_BOLD 0
|
||||
#define TAG_ITALIC 1
|
||||
|
||||
#define TAG_FIXED_FONT 2
|
||||
#define TAG_BLACK_FONT 3
|
||||
#define TAG_RED_FONT 4
|
||||
#define TAG_GREEN_FONT 5
|
||||
#define TAG_BLUE_FONT 6
|
||||
|
||||
#define TAG_PARAGRAPH 7
|
||||
#define TAG_NEW_LINE 8
|
||||
#define TAG_HEADING_1 9
|
||||
#define TAG_HEADING_2 10
|
||||
#define TAG_HEADING_3 11
|
||||
|
||||
#define TAG_ITEM_LIST 12
|
||||
#define TAG_LIST_ITEM 13
|
||||
|
||||
struct TagStructT
|
||||
{
|
||||
char* start; // tag that starts style
|
||||
char* end; // tag that finishes style
|
||||
};
|
||||
|
||||
// tag array
|
||||
typedef TagStructT* MarkupTagsT;
|
||||
|
||||
// returns array of TagStructT with tag strings for HTML
|
||||
|
||||
MarkupTagsT get_HTML_markup_tags();
|
||||
|
||||
// MarkupTagsT get_PostScript_markup_tags();
|
||||
// MarkupTagsT get_Latex_markup_tags();
|
||||
|
||||
#endif
|
58
utils/wxPython/modules/lseditor/plugin.cpp
Normal file
58
utils/wxPython/modules/lseditor/plugin.cpp
Normal file
@ -0,0 +1,58 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wxsplbase.cpp
|
||||
// Purpose: General interfaces for all plug-ins in wxStudio
|
||||
// Author: Aleksandras Gluchovas
|
||||
// Modified by:
|
||||
// Created: 11/04/1999
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Aleksandars Gluchovas
|
||||
// Licence: GNU General Public License wxWindows licence v2.0
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// For compilers that support precompilation, includes "wx/wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/wx.h"
|
||||
#endif
|
||||
|
||||
#include "plugin.h"
|
||||
|
||||
/***** Implementation for class wxStudioPluginManager *****/
|
||||
|
||||
void wxsPluginManager::RegisterMenuCommand( const wxString& itemName,
|
||||
const wxString& menuName,
|
||||
int id,
|
||||
wxsPluginBase* forPlugin )
|
||||
{
|
||||
// TBD::
|
||||
}
|
||||
|
||||
void wxsPluginManager::UnregisterPlugin( wxsPluginBase* plugin )
|
||||
{
|
||||
// TBD::
|
||||
}
|
||||
|
||||
/***** Implementation for class wxStudioPluginBase *****/
|
||||
|
||||
wxsPluginBase::wxsPluginBase()
|
||||
{}
|
||||
|
||||
wxsPluginBase::~wxsPluginBase()
|
||||
{}
|
||||
|
||||
|
||||
wxsPluginManager& wxsPluginBase::GetPluginManager()
|
||||
{
|
||||
wxASSERT( mpPluginMgr );
|
||||
return *mpPluginMgr;
|
||||
}
|
||||
|
||||
void wxsPluginBase::SetPluginManager( wxsPluginManager* pMgr )
|
||||
{
|
||||
mpPluginMgr = pMgr;
|
||||
}
|
98
utils/wxPython/modules/lseditor/plugin.h
Normal file
98
utils/wxPython/modules/lseditor/plugin.h
Normal file
@ -0,0 +1,98 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wxsplbase.h
|
||||
// Purpose: General interfaces for all plug-ins in wxStudio
|
||||
// Author: Aleksandras Gluchovas
|
||||
// Modified by:
|
||||
// Created: 11/04/1999
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Aleskandars Gluchovas
|
||||
// Licence: GNU General Public License wxWindows licence v2.0
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __PLUGIN_G__
|
||||
#define __PLUGIN_G__
|
||||
|
||||
#include "wxstldefs.h"
|
||||
#include "wxsdefs.h"
|
||||
|
||||
class wxsPluginBase;
|
||||
typedef wxsPluginBase* wxsPluginBasePtrT;
|
||||
#ifdef wxUSE_TEMPLATE_STL
|
||||
typedef vector<wxsPluginBasePtrT> wxsPluginListT;
|
||||
#else
|
||||
typedef WXSTL_VECTOR_SHALLOW_COPY(wxsPluginBasePtrT) wxsPluginListT;
|
||||
#endif
|
||||
|
||||
|
||||
class wxsPluginManager : public wxObject
|
||||
{
|
||||
public:
|
||||
|
||||
wxsPluginListT& GetPlugins();
|
||||
|
||||
// allows to present plugin-specific features
|
||||
// as items in the menu-bar
|
||||
|
||||
void RegisterMenuCommand( const string& itemName,
|
||||
const string& menuName,
|
||||
int id,
|
||||
wxsPluginBase* forPlugin );
|
||||
|
||||
// should be called by plugin, when it's being destroyed
|
||||
|
||||
void UnregisterPlugin( wxsPluginBase* plugin );
|
||||
};
|
||||
|
||||
|
||||
|
||||
// Used by create settings panel:
|
||||
enum {
|
||||
WXS_SETTINGS_GLOBAL,
|
||||
WXS_SETTINGS_PROJECT
|
||||
};
|
||||
|
||||
|
||||
class wxsPluginBase : public wxObject
|
||||
{
|
||||
protected:
|
||||
wxsPluginManager* mpPluginMgr;
|
||||
|
||||
public:
|
||||
|
||||
wxsPluginBase();
|
||||
virtual ~wxsPluginBase();
|
||||
|
||||
virtual void InitPlugin() {}
|
||||
|
||||
// utilities
|
||||
|
||||
wxsPluginManager& GetPluginManager();
|
||||
void SetPluginManager( wxsPluginManager* mgr );
|
||||
|
||||
// overridables
|
||||
|
||||
// Current Types = UNKNOWN,EDITOR,CLASSBROWSER,FILEBROWSER,CLASSINFO,TOOL
|
||||
virtual WXS_PLUGIN_TYPE GetType() = 0;
|
||||
virtual string GetCategory() = 0;
|
||||
|
||||
virtual string GetName() = 0;
|
||||
// will return a help panel
|
||||
virtual wxWindow* CreateSettingsPanel(wxWindow *parent, int type) {return NULL;}
|
||||
virtual wxsPluginBase* Clone() = 0;
|
||||
|
||||
virtual string Command( const string& name, const string& args )
|
||||
|
||||
{ return "NO_SUPPORTED"; }
|
||||
};
|
||||
|
||||
// base clas for all plugins which are presented as windows
|
||||
|
||||
class wxsComponent : public wxsPluginBase
|
||||
{
|
||||
public:
|
||||
virtual void Create( wxWindow* parent, wxWindowID id ) = 0;
|
||||
virtual wxWindow* GetWindow() = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
// __PLUGIN_G__
|
696
utils/wxPython/modules/lseditor/sourcepainter.cpp
Normal file
696
utils/wxPython/modules/lseditor/sourcepainter.cpp
Normal file
@ -0,0 +1,696 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: No names yet.
|
||||
// Purpose: Contrib. demo
|
||||
// Author: Aleksandras Gluchovas
|
||||
// Modified by:
|
||||
// Created: 22/09/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Aleksandars Gluchovas
|
||||
// Licence: GNU General Public License
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
// For compilers that support precompilation, includes "wx/wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/wx.h"
|
||||
#endif
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#if defined( wxUSE_TEMPLATE_STL )
|
||||
|
||||
#include <map>
|
||||
using namespace std;
|
||||
#else
|
||||
|
||||
#include <wxstlac.h>
|
||||
|
||||
#endif
|
||||
|
||||
#include "sourcepainter.h"
|
||||
|
||||
const int MAX_KEYWORD_LEN = 16;
|
||||
|
||||
struct KeywordT
|
||||
{
|
||||
char keyWord[MAX_KEYWORD_LEN];
|
||||
int rank;
|
||||
};
|
||||
|
||||
// source fragment ranks :
|
||||
|
||||
// 0 - nomral text
|
||||
// 1 - basic types
|
||||
// 2 - reserved words
|
||||
|
||||
// multil-language keywords map
|
||||
|
||||
static KeywordT __gKeyWords[] =
|
||||
{
|
||||
{ "for", 1 },
|
||||
{ "FOR", 1 },
|
||||
{ "For", 1 },
|
||||
|
||||
{ "next", 1 },
|
||||
{ "Next", 1 },
|
||||
{ "NEXT", 1 },
|
||||
|
||||
{ "if", 1 },
|
||||
{ "If", 1 },
|
||||
{ "IF", 1 },
|
||||
|
||||
{ "then", 1 },
|
||||
{ "Then", 1 },
|
||||
{ "THEN", 1 },
|
||||
|
||||
{ "else", 1 },
|
||||
{ "Else", 1 },
|
||||
{ "ELSE", 1 },
|
||||
|
||||
{ "do", 1 },
|
||||
{ "Do", 1 },
|
||||
{ "DO", 1 },
|
||||
|
||||
|
||||
{ "break", 1 },
|
||||
{ "Break", 1 },
|
||||
{ "BREAK", 1 },
|
||||
|
||||
{ "continue", 1 },
|
||||
|
||||
{ "goto", 1 },
|
||||
{ "Goto", 1 },
|
||||
{ "GOTO", 1 },
|
||||
|
||||
{ "switch", 1 },
|
||||
{ "default", 1 },
|
||||
{ "case", 1 },
|
||||
|
||||
{ "repeat", 1 },
|
||||
{ "Repeat", 1 },
|
||||
{ "REPEAT", 1 },
|
||||
|
||||
{ "until", 1 },
|
||||
{ "Until", 1 },
|
||||
{ "UNTIL", 1 },
|
||||
|
||||
{ "return", 1 },
|
||||
{ "Return", 1 },
|
||||
{ "RETURN", 1 },
|
||||
|
||||
{ "unit", 1 },
|
||||
{ "Unit", 1 },
|
||||
{ "UNIT", 1 },
|
||||
|
||||
{ "procedure", 1 },
|
||||
{ "Procedure", 1 },
|
||||
{ "PROCEDURE", 1 },
|
||||
|
||||
{ "function", 1 },
|
||||
{ "Function", 1 },
|
||||
{ "FUNCTION", 1 },
|
||||
|
||||
{ "begin", 1 },
|
||||
{ "Begin", 1 },
|
||||
{ "BEGIN", 1 },
|
||||
|
||||
{ "End", 1 },
|
||||
{ "END", 1 },
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
|
||||
{ "enum", 1 },
|
||||
{ "static", 1 },
|
||||
{ "const", 1 },
|
||||
{ "mutable", 1 },
|
||||
{ "volatile", 1 },
|
||||
{ "__asm", 1 },
|
||||
{ "asm", 1 },
|
||||
|
||||
{ "typeid", 1 },
|
||||
{ "sizeof", 1 },
|
||||
{ "typeof", 1 },
|
||||
|
||||
|
||||
{ "native", 1 },
|
||||
|
||||
{ "#include", 1 },
|
||||
{ "#define", 1 },
|
||||
{ "#def", 1 },
|
||||
{ "#undef", 1 },
|
||||
{ "#ifdef", 1 },
|
||||
{ "#ifndef", 1 },
|
||||
{ "#if", 1 },
|
||||
{ "#endif", 1 },
|
||||
{ "#elif", 1 },
|
||||
{ "#else", 1 },
|
||||
{ "#pragma", 1 },
|
||||
{ "#line", 1 },
|
||||
|
||||
{ "package", 1 },
|
||||
{ "import", 1 },
|
||||
{ "export", 1 },
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
|
||||
{ "dynamic_cast", 1 },
|
||||
{ "const_cast", 1 },
|
||||
|
||||
//////// some hacks for VB /////////
|
||||
|
||||
{ "sub", 1 },
|
||||
{ "Sub", 1 },
|
||||
{ "SUB", 1 },
|
||||
{ "as", 1 },
|
||||
{ "As", 1 },
|
||||
{ "AS", 1 },
|
||||
|
||||
/////// data types ///////
|
||||
|
||||
{ "int" , 1 },
|
||||
{ "integer", 1 },
|
||||
{ "Integer", 1 },
|
||||
{ "INTEGER", 1 },
|
||||
|
||||
{ "real", 1 },
|
||||
{ "Real", 1 },
|
||||
{ "REAL", 1 },
|
||||
|
||||
{ "float", 1 },
|
||||
{ "Float", 1 },
|
||||
{ "FLOAT", 1 },
|
||||
|
||||
{ "char", 1 },
|
||||
{ "Char", 1 },
|
||||
{ "CHAR", 1 },
|
||||
|
||||
{ "register", 1 },
|
||||
|
||||
{ "string", 1 },
|
||||
{ "String", 1 },
|
||||
{ "STRING", 1 },
|
||||
|
||||
{ "array", 1 },
|
||||
{ "Array", 1 },
|
||||
{ "ARRAY", 1 },
|
||||
|
||||
{ "packed", 1 },
|
||||
{ "Packed", 1 },
|
||||
{ "PACKED", 1 },
|
||||
|
||||
{ "property", 1 },
|
||||
{ "Property", 1 },
|
||||
{ "PROPERTY", 1 },
|
||||
|
||||
{ "unsigned", 1 },
|
||||
|
||||
{ "long", 1 },
|
||||
{ "double", 1 },
|
||||
{ "short", 1 },
|
||||
{ "bool", 1 },
|
||||
|
||||
{ "longint", 1 },
|
||||
{ "Longint", 1 },
|
||||
{ "LONGINT", 1 },
|
||||
|
||||
{ "extended", 1 },
|
||||
{ "Extended", 1 },
|
||||
{ "EXTENTED", 1 },
|
||||
|
||||
{ "pointer", 1 },
|
||||
{ "Pointer", 1 },
|
||||
{ "POINTER", 1 },
|
||||
|
||||
{ "and", 1 },
|
||||
{ "And", 1 },
|
||||
{ "AND", 1 },
|
||||
{ "or", 1 },
|
||||
{ "Or", 1 },
|
||||
{ "OR", 1 },
|
||||
{ "xor", 1 },
|
||||
{ "Xor", 1 },
|
||||
{ "XOR", 1 },
|
||||
|
||||
{ "void", 1 },
|
||||
{ "__stdcall", 1 },
|
||||
{ "__declspec", 1 },
|
||||
{ "extern", 1 },
|
||||
{ "stdcall", 1 },
|
||||
{ "dllimport", 1 },
|
||||
{ "dllexport", 1 },
|
||||
{ "__cdecl", 1 },
|
||||
{ "cdecl", 1 },
|
||||
{ "template", 1 },
|
||||
{ "typedef", 1 },
|
||||
{ "naked", 1 },
|
||||
|
||||
{ "try", 1 },
|
||||
{ "catch", 1 },
|
||||
{ "throw", 2 }, // C++
|
||||
{ "throws", 1 }, // Java
|
||||
|
||||
|
||||
{ "finalize", 1 },
|
||||
|
||||
// "STL-suport"
|
||||
|
||||
{ "size_t", 1 },
|
||||
{ "NPOS", 1 },
|
||||
{ "vector", 1 },
|
||||
{ "list", 1 },
|
||||
{ "map", 1 },
|
||||
{ "multimap", 1 },
|
||||
|
||||
{ "external", 1 },
|
||||
{ "External", 1 },
|
||||
{ "EXTERNAL", 1 },
|
||||
|
||||
//////////// meta-information //////////////
|
||||
|
||||
{ "virtual", 2 },
|
||||
{ "Virtual", 2 },
|
||||
|
||||
{ "override", 2 },
|
||||
{ "Override", 2 },
|
||||
|
||||
{ "class", 2 },
|
||||
{ "Class", 2 },
|
||||
{ "CLASS", 2 },
|
||||
|
||||
{ "struct", 2 },
|
||||
{ "union", 2 },
|
||||
|
||||
{ "record", 2 },
|
||||
{ "Record", 2 },
|
||||
{ "RECORD", 2 },
|
||||
|
||||
{ "form", 1 },
|
||||
{ "Form", 1 },
|
||||
{ "FORM", 1 },
|
||||
|
||||
{ "namespace", 2 },
|
||||
|
||||
{ "interface" , 2 },
|
||||
{ "abstract", 2 },
|
||||
|
||||
{ "Interface" , 2 },
|
||||
{ "INTERFACE" , 2 },
|
||||
|
||||
{ "implementation", 2 },
|
||||
{ "Implementation", 2 },
|
||||
{ "IMPLEMENTATION", 2 },
|
||||
|
||||
{ "label", 2 },
|
||||
{ "Label", 2 },
|
||||
{ "LABEL", 2 },
|
||||
|
||||
{ "implements", 2 },
|
||||
{ "extends", 2 },
|
||||
|
||||
{ "public", 2 },
|
||||
{ "private", 2 },
|
||||
{ "protected", 2 },
|
||||
|
||||
{ "this", 1 },
|
||||
{ "This", 1 },
|
||||
{ "THIS", 1 },
|
||||
|
||||
{ "new", 1 },
|
||||
{ "New", 1 },
|
||||
{ "NEW", 1 },
|
||||
|
||||
{ "delete", 2 },
|
||||
{ "inline", 2 },
|
||||
|
||||
{ "operator", 1 },
|
||||
|
||||
{ "Inherited", 2 },
|
||||
{ "Inherited", 2 },
|
||||
|
||||
{ "final", 2 },
|
||||
{ "implements", 2 },
|
||||
{ "super", 2 },
|
||||
|
||||
// even more...
|
||||
{ "java", 2 },
|
||||
{ "Java", 2 },
|
||||
{ "JAVA", 2 },
|
||||
{ "delphi", 2 },
|
||||
{ "Delphi", 2 },
|
||||
{ "SmallTalk", 2 },
|
||||
{ "Smalltalk", 2 },
|
||||
{ "smalltalk", 2 },
|
||||
{ "assembler", 2 },
|
||||
{ "Assembler", 2 },
|
||||
{ "Basic", 2 },
|
||||
{ "BASIC", 2 },
|
||||
{ "basic", 2 },
|
||||
{ "CORBA", 2 },
|
||||
{ "COBOL", 2 },
|
||||
{ "ADA", 2 },
|
||||
{ "LISP", 2 },
|
||||
|
||||
// just for fun...
|
||||
{ "life", 2 },
|
||||
{ "sucks", 2 },
|
||||
{ "rules", 2 },
|
||||
{ "Quake", 2 },
|
||||
{ "QuakeWorld", 2 },
|
||||
{ "[ag_slammer]",2 },
|
||||
{ "Aleksandras", 2 },
|
||||
{ "Gluchovas" , 2 },
|
||||
{ "Alex", 2 },
|
||||
{ "alex", 2 },
|
||||
{ "aleks", 2 },
|
||||
{ "aleksas", 3 },
|
||||
{ "AlexSoft", 2 },
|
||||
{ "Alexsoft", 2 },
|
||||
{ "SpringSky", 2 },
|
||||
{ "SK_Team", 2 },
|
||||
{ "soften", 2 },
|
||||
{ "UB40", 2 },
|
||||
{ "U96", 2 }
|
||||
};
|
||||
|
||||
struct less_c_str
|
||||
{
|
||||
inline bool operator()( char* x, char* y) const
|
||||
{ return ( strcmp( x,y ) < 0 );
|
||||
}
|
||||
};
|
||||
|
||||
#if defined( wxUSE_TEMPLATE_STL )
|
||||
|
||||
typedef map< char*, char*, less_c_str > KeywordMapT;
|
||||
|
||||
#else
|
||||
|
||||
typedef char* CharPtrT;
|
||||
typedef WXSTL_MAP( CharPtrT, CharPtrT ,less_c_str) KeywordMapT;
|
||||
|
||||
#endif
|
||||
|
||||
static KeywordMapT __gMultiLangMap;
|
||||
static int __gMapReady = 0;
|
||||
|
||||
void check_keyword_map( int keywordMapNr )
|
||||
{
|
||||
if ( !__gMapReady )
|
||||
{
|
||||
__gMapReady = 1;
|
||||
|
||||
// "make sure" the address of the first member of non-polimorphic class
|
||||
// coinsides with the address of the instance
|
||||
|
||||
KeywordT dummy;
|
||||
|
||||
if ( (char*)& dummy != &dummy.keyWord[0] )
|
||||
throw;
|
||||
|
||||
int size = sizeof(__gKeyWords) / sizeof( KeywordT );
|
||||
|
||||
for( int i = 0; i != size; ++i )
|
||||
|
||||
__gMultiLangMap.insert(
|
||||
KeywordMapT::value_type( (char*)&__gKeyWords[i],
|
||||
(char*)&__gKeyWords[i]
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
int get_rank( char* start, char* end )
|
||||
{
|
||||
// FIXME:: what if end is no longer leagal adress?
|
||||
|
||||
char tmp = *end;
|
||||
*end = '\0'; // put temporary terminator
|
||||
|
||||
KeywordMapT::iterator i;
|
||||
|
||||
if ( (i = __gMultiLangMap.find( start ) ) != __gMultiLangMap.end() )
|
||||
{
|
||||
KeywordT* pKey = (KeywordT*)(*i).second;
|
||||
|
||||
*end = tmp;
|
||||
|
||||
return pKey->rank;
|
||||
}
|
||||
else
|
||||
{
|
||||
*end = tmp;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void store_range( IntListT& results, int rank, int range_len )
|
||||
{
|
||||
if ( !range_len ) return;
|
||||
|
||||
results.push_back ( ( rank << 16 ) | ( range_len ) );
|
||||
}
|
||||
|
||||
|
||||
#define STORE_RANGE store_range( results, cur_rank, cur_range_len );\
|
||||
cur_rank = cur_range_len = 0;
|
||||
|
||||
#define NEXT_CHAR cur_range_len++; \
|
||||
++cur; \
|
||||
continue;
|
||||
|
||||
static inline int is_alpha( char ch )
|
||||
{
|
||||
return ( (( ch >= '_' ) && ( ch <= 'z' )) ||
|
||||
(( ch >= 'A' ) && ( ch <= 'Z' ))
|
||||
);
|
||||
}
|
||||
|
||||
// _ . .
|
||||
// Ziema atEjo netikEtai
|
||||
|
||||
static void heighlight_syntax( char* str, int strLen,
|
||||
IntListT& results, bool& isComment )
|
||||
{
|
||||
bool isMultiline = 0;
|
||||
char* cur = str;
|
||||
char* end = str + strLen;
|
||||
|
||||
int cur_rank = ( isComment == 1 ) ? RANK_GREEN : RANK_BLACK;
|
||||
int cur_range_len = 0;
|
||||
|
||||
while ( cur != end )
|
||||
{
|
||||
int has_next = ( cur+1 != end );
|
||||
|
||||
if ( isComment )
|
||||
{
|
||||
if ( *cur == '*' )
|
||||
if ( has_next && *(cur+1) == '/' )
|
||||
{
|
||||
// turn off multiline comment mode
|
||||
cur += 2;
|
||||
cur_range_len += 2;
|
||||
isComment = 0;
|
||||
isMultiline = 0;
|
||||
STORE_RANGE;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
++cur_range_len;
|
||||
++cur;
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
if ( *cur == 10 )
|
||||
if ( isComment )
|
||||
if ( isMultiline )
|
||||
{
|
||||
cur_rank = RANK_GREEN;
|
||||
cur_range_len = end - cur;
|
||||
STORE_RANGE;
|
||||
isComment = 0;
|
||||
isMultiline = 0;
|
||||
continue;
|
||||
}*/
|
||||
|
||||
if ( *cur == '/' )
|
||||
{
|
||||
if ( has_next )
|
||||
{
|
||||
if ( *(cur+1) == '/' )
|
||||
{
|
||||
STORE_RANGE;
|
||||
|
||||
char* eol = cur;
|
||||
while ( eol < end && *eol != 10 )
|
||||
++eol;
|
||||
|
||||
cur_rank = RANK_GREEN;
|
||||
cur_range_len = eol - cur;
|
||||
cur = eol;
|
||||
STORE_RANGE;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( *(cur+1) == '*' )
|
||||
{
|
||||
STORE_RANGE;
|
||||
cur_rank = RANK_GREEN;
|
||||
cur_range_len = 2;
|
||||
isComment = 1;
|
||||
cur += 2;
|
||||
isMultiline = 1;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
NEXT_CHAR;
|
||||
}
|
||||
|
||||
if ( ( is_alpha( *cur ) || *(cur) == '#' )
|
||||
&& has_next
|
||||
)
|
||||
{
|
||||
if ( is_alpha( *(cur+1) ) )
|
||||
{
|
||||
char* start = cur;
|
||||
cur += 2;
|
||||
|
||||
while ( cur != end && is_alpha(*cur) ) ++cur;
|
||||
|
||||
int wordRank;
|
||||
|
||||
if ( (wordRank = get_rank( start, cur )) > 0 )
|
||||
{
|
||||
STORE_RANGE;
|
||||
|
||||
store_range( results, wordRank, int(cur-start) );
|
||||
cur_rank = cur_range_len = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
cur_range_len += ( cur-start );
|
||||
continue;
|
||||
}
|
||||
else
|
||||
NEXT_CHAR;
|
||||
}
|
||||
|
||||
NEXT_CHAR;
|
||||
}
|
||||
|
||||
if ( cur_range_len > 0 ) STORE_RANGE;
|
||||
}
|
||||
|
||||
/***** Implementation for class SourcePainter ******/
|
||||
|
||||
SourcePainter::SourcePainter( bool assembleResultString )
|
||||
: mCollectResultsOn( assembleResultString ),
|
||||
mIsInComment( FALSE ),
|
||||
mCommentIsMultiline( FALSE )
|
||||
{
|
||||
check_keyword_map(0);
|
||||
}
|
||||
|
||||
void SourcePainter::ProcessSource( char* src, int srcLen )
|
||||
{
|
||||
// TBD:: multilne state...
|
||||
|
||||
heighlight_syntax( src, srcLen, mBlocks, mIsInComment );
|
||||
|
||||
if ( mCollectResultsOn )
|
||||
|
||||
mResultStr += string( src, srcLen );
|
||||
}
|
||||
|
||||
void SourcePainter::SetState( bool isInComment,
|
||||
bool commentIsMultiline )
|
||||
{
|
||||
mIsInComment = isInComment;
|
||||
mCommentIsMultiline = commentIsMultiline;
|
||||
}
|
||||
|
||||
void SourcePainter::Init(bool assembleResultString)
|
||||
{
|
||||
mIsInComment = 0;
|
||||
mCommentIsMultiline = 0;
|
||||
mCollectResultsOn = assembleResultString;
|
||||
|
||||
mResultStr = "";
|
||||
|
||||
mBlocks.erase( mBlocks.begin(), mBlocks.end() );
|
||||
}
|
||||
|
||||
static int rank_tags_map[] =
|
||||
{
|
||||
TAG_BLACK_FONT,
|
||||
TAG_BLUE_FONT,
|
||||
TAG_RED_FONT,
|
||||
TAG_GREEN_FONT
|
||||
};
|
||||
|
||||
void SourcePainter::GetResultString(string& result, MarkupTagsT tags)
|
||||
{
|
||||
// this method works, only if results of processing
|
||||
// are collected
|
||||
ASSERT( mCollectResultsOn );
|
||||
result = "";
|
||||
|
||||
int pos = 0;
|
||||
|
||||
for( size_t i = 0; i != mBlocks.size(); ++i )
|
||||
{
|
||||
int desc = mBlocks[i];
|
||||
|
||||
int len = desc & 0xFFFF;
|
||||
int rank = (desc >> 16) & 0xFFFF;
|
||||
|
||||
result += tags[ rank_tags_map[rank] ].start;
|
||||
|
||||
for( int n = 0; n != len; ++n )
|
||||
|
||||
result += mResultStr[pos+n];
|
||||
|
||||
pos += len;
|
||||
|
||||
result += tags[ rank_tags_map[rank] ].end;
|
||||
}
|
||||
}
|
||||
|
||||
IntListT& SourcePainter::GetBlocks()
|
||||
{
|
||||
return mBlocks;
|
||||
}
|
||||
|
||||
bool SourcePainter::IsKeyword( char* word, int wordLen )
|
||||
{
|
||||
check_keyword_map(0);
|
||||
|
||||
int rank = get_rank( word, word + wordLen );
|
||||
|
||||
return ( rank == RANK_BLUE || rank == RANK_RED );
|
||||
}
|
109
utils/wxPython/modules/lseditor/sourcepainter.h
Normal file
109
utils/wxPython/modules/lseditor/sourcepainter.h
Normal file
@ -0,0 +1,109 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: No names yet.
|
||||
// Purpose: Contrib. demo
|
||||
// Author: Aleksandras Gluchovas
|
||||
// Modified by:
|
||||
// Created: 22/09/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Aleskandars Gluchovas
|
||||
// Licence: GNU General Public License
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef __SOURCEPAINTER_G__
|
||||
#define __SOURCEPAINTER_G__
|
||||
|
||||
#ifndef ASSERT
|
||||
#define ASSERT(x) if (!(x)) throw
|
||||
#endif
|
||||
|
||||
#include "wxstldefs.h"
|
||||
|
||||
#include "markup.h" // import MarkupTagsT definition
|
||||
|
||||
// "colored" codes for highlighted blocks
|
||||
|
||||
#define RANK_BLACK 0 // common source fragments
|
||||
#define RANK_BLUE 1 // basic types
|
||||
#define RANK_RED 2 // reserved words
|
||||
#define RANK_GREEN 3 // comments
|
||||
|
||||
// colored block description format :
|
||||
// int( ( rank << 16 ) | ( source_range_len ) )
|
||||
|
||||
inline int get_src_block_rank( int block )
|
||||
{
|
||||
return (block >> 16) & 0xFFFF;
|
||||
}
|
||||
|
||||
inline int get_src_block_len( int block )
|
||||
{
|
||||
return block & 0xFFFF;
|
||||
}
|
||||
|
||||
// FOR NOW:: no lagnguage-map selection
|
||||
|
||||
// source code syntax heighlighter (CPP+JAVA+VB+PASCAL)
|
||||
|
||||
class SourcePainter
|
||||
{
|
||||
protected:
|
||||
string mResultStr;
|
||||
IntListT mBlocks;
|
||||
bool mCollectResultsOn;
|
||||
|
||||
// state variables
|
||||
bool mIsInComment;
|
||||
bool mCommentIsMultiline;
|
||||
public:
|
||||
|
||||
// assembleResultString == TRUE - instructs painter
|
||||
// to collect each chunk of srouce passed to ProcessSource(),
|
||||
// so that results cann be futher obtained in a single string
|
||||
// instead of vector of block descriptions
|
||||
|
||||
SourcePainter( bool assembleResultString = TRUE );
|
||||
virtual ~SourcePainter() {}
|
||||
|
||||
// can be called multiple times (e.g. on each source line)
|
||||
virtual void ProcessSource( char* src, int srcLen );
|
||||
|
||||
// method, for manually adjusting state of source painter
|
||||
virtual void SetState( bool isInComment,
|
||||
bool commentIsMultiline );
|
||||
|
||||
// reinitializes object - clears results of previouse processing
|
||||
virtual void Init( bool assembleResultString = TRUE );
|
||||
|
||||
// generates string of highlighted source for the scipting
|
||||
// language given by "tags" argument
|
||||
|
||||
virtual void GetResultString(string& result, MarkupTagsT tags);
|
||||
|
||||
// returns vector of block descriptors, see IntListT definition
|
||||
// (block descriptors can be used for fast custom hightlighted text generation)
|
||||
|
||||
virtual IntListT& GetBlocks();
|
||||
|
||||
// NOTE:: static method
|
||||
// returns if the given word is a reserved word or basic type identifier
|
||||
static bool IsKeyword( char* word, int wordLen );
|
||||
};
|
||||
|
||||
#endif
|
4233
utils/wxPython/modules/lseditor/tdefs.cpp
Normal file
4233
utils/wxPython/modules/lseditor/tdefs.cpp
Normal file
File diff suppressed because it is too large
Load Diff
903
utils/wxPython/modules/lseditor/tdefs.h
Normal file
903
utils/wxPython/modules/lseditor/tdefs.h
Normal file
@ -0,0 +1,903 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: No names yet.
|
||||
// Purpose: Contrib. demo
|
||||
// Author: Aleksandras Gluchovas
|
||||
// Modified by:
|
||||
// Created: 03/04/1999
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Aleskandars Gluchovas
|
||||
// Licence: GNU General Public License
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef __TDEFS_G__
|
||||
#define __TDEFS_G__
|
||||
|
||||
// should be compiled with wxSTL-v.1.2 (or higher)
|
||||
|
||||
#include "wxstldefs.h"
|
||||
|
||||
#if defined( wxUSE_TEMPLATE_STL )
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#else
|
||||
#include "wxstlvec.h"
|
||||
#include "wxstllst.h"
|
||||
#endif
|
||||
|
||||
#include "wx/window.h"
|
||||
#include "wx/scrolbar.h"
|
||||
|
||||
#include "sourcepainter.h"
|
||||
|
||||
#define NPOS ((size_t)(-1))
|
||||
|
||||
class wxTextEditorModel;
|
||||
class wxTextEditorView;
|
||||
|
||||
/*
|
||||
* class represents column-row position in the source text,
|
||||
* may refere to the column past the end-of-line,
|
||||
* but should not point past the last-line in the text
|
||||
*/
|
||||
|
||||
class TPosition
|
||||
{
|
||||
public:
|
||||
size_t mRow;
|
||||
size_t mCol;
|
||||
|
||||
inline TPosition() : mRow(0), mCol(0) {}
|
||||
|
||||
inline TPosition( size_t row, size_t col )
|
||||
|
||||
: mRow( row ), mCol( col ) {}
|
||||
|
||||
inline bool operator>( const TPosition& rhs ) const
|
||||
{
|
||||
if ( mRow == rhs.mRow ) return mCol > rhs.mCol;
|
||||
else
|
||||
return mRow > rhs.mRow;
|
||||
}
|
||||
|
||||
inline bool operator<( const TPosition& rhs ) const
|
||||
{
|
||||
if ( mRow == rhs.mRow ) return mCol < rhs.mCol;
|
||||
else
|
||||
return mRow < rhs.mRow;
|
||||
}
|
||||
};
|
||||
|
||||
class TRange
|
||||
{
|
||||
public:
|
||||
TPosition mFrom;
|
||||
TPosition mTill;
|
||||
|
||||
TRange() {}
|
||||
TRange( const TPosition& from, const TPosition& till )
|
||||
: mFrom( from ), mTill( till )
|
||||
{}
|
||||
};
|
||||
|
||||
inline bool operator==( const TPosition& lhs, const TPosition& rhs )
|
||||
{
|
||||
return lhs.mRow == rhs.mRow && lhs.mCol == rhs.mCol;
|
||||
}
|
||||
|
||||
// FOR NOW:: bigger ones...
|
||||
|
||||
#define MAX_BLOCK_LEN (1024*164)
|
||||
#define BALANCED_BLOCK_LEN (1024*152)
|
||||
#define FILLED_BLOCK_LEN (1024*148)
|
||||
|
||||
// FOR NOW::
|
||||
#define T_ASSERT( x ) if ( !(x) ) throw;
|
||||
|
||||
// to speed up debug v. :
|
||||
|
||||
#define is_eol_char( ch ) ( ch == (char)10 )
|
||||
#define is_DOS_eol_char( ch ) ( ch == (char)13 )
|
||||
|
||||
// the target-platfrom eol-marking is selected when
|
||||
// new text document is created or auto-detection
|
||||
// failed to determine the text-format (e.g. no EOLs found at all)
|
||||
|
||||
#if defined(__WINDOWS__) || defined(__WXMSW__)
|
||||
|
||||
#define IS_UNIX_TEXT_BY_DEFAULT FALSE
|
||||
#else
|
||||
#define IS_UNIX_TEXT_BY_DEFAULT TRUE
|
||||
#endif
|
||||
|
||||
//inline bool is_eol_char( char ch ) { return ch == 10 && ch == 13 ; }
|
||||
|
||||
/*
|
||||
* Class contains single fragment of the source text, which
|
||||
* may grow or shrink in the process of editing. Blocks always
|
||||
* start at the begining of the line and end at eol, i.e. lines
|
||||
* are not broken among blocks
|
||||
*/
|
||||
|
||||
class TBlock
|
||||
{
|
||||
public:
|
||||
char mBuf[MAX_BLOCK_LEN];
|
||||
size_t mTextLen;
|
||||
size_t mRowCount;
|
||||
|
||||
TBlock() : mTextLen(0), mRowCount(0) { mBuf[0] = '\0'; }
|
||||
|
||||
void RecalcBlockProperties();
|
||||
|
||||
bool operator==( const TBlock& blk ) const { return this == &blk; }
|
||||
|
||||
bool operator!=( const TBlock& blk ) const { return this != &blk; }
|
||||
|
||||
bool operator<( const TBlock& blk ) const { return TRUE; }
|
||||
|
||||
bool operator>( const TBlock& blk ) const { return FALSE; }
|
||||
};
|
||||
|
||||
/*
|
||||
* captures info about mutable command
|
||||
*/
|
||||
|
||||
class TCommand
|
||||
{
|
||||
public:
|
||||
|
||||
TCommand() : mType(-1) {}
|
||||
TCommand( int type ) : mType( type ) {}
|
||||
~TCommand() {}
|
||||
|
||||
int mType;
|
||||
char* mData;
|
||||
size_t mDataLen;
|
||||
|
||||
TRange mRange;
|
||||
|
||||
// positions of cursor before and after executions of this command
|
||||
TPosition mPrePos;
|
||||
TPosition mPostPos;
|
||||
|
||||
};
|
||||
|
||||
enum TEXT_EDITOR_COMMAND
|
||||
{
|
||||
TCMD_INSERT,
|
||||
TCMD_DELETE
|
||||
};
|
||||
|
||||
enum TEXT_CHANGE_TYPE
|
||||
{
|
||||
CT_MODIFIED,
|
||||
CT_DELETED,
|
||||
CT_INSERTED
|
||||
};
|
||||
|
||||
class wxTextEditorView;
|
||||
|
||||
// STL-list is used for managing blocks, since it's alg. collects
|
||||
// removed elements into a free-list, from which they
|
||||
// can be reclaimed later, that way heap-fragmentation may be reduced
|
||||
|
||||
#if defined( wxUSE_TEMPLATE_STL )
|
||||
typedef list<TBlock> TBlockListT;
|
||||
typedef vector<TCommand*> TCommandListT;
|
||||
typedef vector<wxTextEditorView*> TextViewListT;
|
||||
#else
|
||||
typedef WXSTL_LIST( TBlock ) TBlockListT;
|
||||
|
||||
typedef TCommand* TCommandPtrT;
|
||||
typedef WXSTL_VECTOR_SHALLOW_COPY( TCommandPtrT ) TCommandListT;
|
||||
|
||||
typedef wxTextEditorView* TextViewPtrT;
|
||||
typedef WXSTL_VECTOR_SHALLOW_COPY( TextViewPtrT ) TextViewListT;
|
||||
#endif
|
||||
|
||||
typedef TBlockListT::iterator TBlockIteratorT;
|
||||
|
||||
|
||||
/*
|
||||
* class shields the higher-level operations from direct access
|
||||
* to blocks of fragmented in-memory buffers
|
||||
*/
|
||||
|
||||
class TTextIterator
|
||||
{
|
||||
public:
|
||||
TBlockIteratorT mBlockIter;
|
||||
TBlockIteratorT mEndOfListIter;
|
||||
TPosition mPos;
|
||||
|
||||
size_t mActualRow;
|
||||
size_t mFirstRowInBlock;
|
||||
|
||||
char* mpCurRowStart;
|
||||
bool mIsEof;
|
||||
|
||||
public:
|
||||
TTextIterator();
|
||||
|
||||
char GetChar();
|
||||
bool IsEol();
|
||||
bool IsEof();
|
||||
bool IsLastLine();
|
||||
int GetDistFromEol();
|
||||
|
||||
void NextChar();
|
||||
void PreviousChar();
|
||||
void NextWord();
|
||||
void PreviousWord();
|
||||
void ToEndOfLine();
|
||||
void ToStartOfLine();
|
||||
|
||||
bool IsInLastBlock();
|
||||
|
||||
// accesors
|
||||
|
||||
size_t GetLineLen();
|
||||
TPosition GetPosition();
|
||||
|
||||
char* GetClosestPos();
|
||||
char* GotoClosestPos();
|
||||
|
||||
inline char* GetBlockStart() { return (*mBlockIter).mBuf; }
|
||||
inline char* GetBlockEnd() { return (*mBlockIter).mBuf + (*mBlockIter).mTextLen; }
|
||||
|
||||
bool DetectUnixText();
|
||||
|
||||
// adjust this member to add specific separators,
|
||||
// the default value is : ",.()[]\t\\+-*/|=<>:;\t\n~?!%"
|
||||
|
||||
static string mSeparators;
|
||||
|
||||
static bool IsSeparator( char ch );
|
||||
};
|
||||
|
||||
class wxTextEditorModel;
|
||||
|
||||
class TTextChangeListenerBase
|
||||
{
|
||||
public:
|
||||
virtual void OnTextChanged( wxTextEditorModel* pModel, size_t atRow, size_t nRows, TEXT_CHANGE_TYPE ct ) = 0;
|
||||
};
|
||||
|
||||
class TCppJavaHighlightListener : public TTextChangeListenerBase
|
||||
{
|
||||
protected:
|
||||
wxTextEditorModel* mpModel; // is set up temporarely
|
||||
|
||||
enum { IN_COMMENT_STATE, OUT_OF_COMMENT_STATE };
|
||||
|
||||
public:
|
||||
virtual void OnTextChanged( wxTextEditorModel* pModel, size_t atRow, size_t nRows, TEXT_CHANGE_TYPE ct );
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Base class for user-defined "bookmarks" within the source-text, bookmarks
|
||||
* are automatically repositioned or deleted as the text is edited. Class
|
||||
* can be subclassed to add pin-specific data (e.g. breakpoint information)
|
||||
*/
|
||||
|
||||
class TPinBase
|
||||
{
|
||||
public:
|
||||
int mTypeCode;
|
||||
size_t mRow;
|
||||
|
||||
public:
|
||||
TPinBase()
|
||||
: mTypeCode(-1), mRow(NPOS) {}
|
||||
|
||||
TPinBase( int typeCode, size_t row )
|
||||
: mTypeCode( typeCode ), mRow( row ) {}
|
||||
|
||||
size_t GetRow() { return mRow; }
|
||||
int GetTypeCode() { return mTypeCode; }
|
||||
|
||||
virtual ~TPinBase() {}
|
||||
};
|
||||
|
||||
// "recommened" type-code ranges for custom pins
|
||||
|
||||
#define HIHGLIGHTING_PINS_TC_STARRT 50
|
||||
#define OTHER_PINS_TC_START 100
|
||||
|
||||
inline bool operator<( const TPinBase& lhs, TPinBase& rhs )
|
||||
|
||||
{ return lhs.mRow < rhs.mRow; }
|
||||
|
||||
#if defined( wxUSE_TEMPLATE_STL )
|
||||
|
||||
typedef vector<TPinBase*> PinListT;
|
||||
typedef vector<TTextChangeListenerBase*> ChangeListenerListT;
|
||||
#else
|
||||
typedef TPinBase* TPinBasePtrT;
|
||||
typedef WXSTL_VECTOR_SHALLOW_COPY( TPinBasePtrT ) PinListT;
|
||||
|
||||
typedef TTextChangeListenerBase* TTextChangeListenerBasePtrT;
|
||||
typedef WXSTL_VECTOR_SHALLOW_COPY( TTextChangeListenerBasePtrT ) ChangeListenerListT;
|
||||
#endif
|
||||
|
||||
/* OLD STUFF::
|
||||
|
||||
struct TPinBaseCompareFunctor
|
||||
{
|
||||
inline int operator()(const TPinBasePtrT* x, const TPinBasePtrT*& y ) const
|
||||
{
|
||||
return x->mLine < y->mLine;
|
||||
}
|
||||
};
|
||||
|
||||
typedef WXSTL_MULTIMAP( TPinBasePtrT, TPinBasePtrT, TPinBaseCompareFunctor ) PinMapT;
|
||||
typedef PinMapT::iterator PinIteratorT;
|
||||
*/
|
||||
|
||||
/*
|
||||
* Class manages access and manpulation of in-memory text. Can
|
||||
* be accessed by multiple views, only one of which can be active
|
||||
* at a time.
|
||||
*/
|
||||
|
||||
class wxTextEditorModel
|
||||
{
|
||||
protected:
|
||||
TBlockListT mBlocks;
|
||||
|
||||
TCommandListT mCommands;
|
||||
size_t mCurCommand;
|
||||
|
||||
TextViewListT mViews;
|
||||
wxTextEditorView* mpActiveView;
|
||||
|
||||
PinListT mPins;
|
||||
bool mIsUnixText;
|
||||
|
||||
ChangeListenerListT mChangeListeners;
|
||||
|
||||
public:
|
||||
/*** public properties ***/
|
||||
|
||||
bool mTextChanged;
|
||||
size_t mChangedFromRow;
|
||||
size_t mChangedTillRow;
|
||||
|
||||
bool mWasChanged; // TRUE, if any content has been changed
|
||||
|
||||
TPosition mCursorPos;
|
||||
|
||||
TPosition mPrevSelectionStart;
|
||||
TPosition mPrevSelectionEnd;
|
||||
TPosition mPrevCursorPos;
|
||||
|
||||
TPosition mSelectionStart;
|
||||
TPosition mSelectionEnd;
|
||||
size_t mRowsPerPage;
|
||||
|
||||
bool mIsReadOnly; // default: FALSE
|
||||
bool mIsModified;
|
||||
bool mInsertMode; // default: TRUE
|
||||
bool mAutoIndentMode; // default: TRUE
|
||||
bool mSmartIndentMode; // default: TRUE
|
||||
|
||||
bool mIsSelectionEditMode; // default: TRUE
|
||||
size_t mTabSize; // default: 4
|
||||
|
||||
StrListT mSearchExprList;
|
||||
string mLastFindExpr;
|
||||
|
||||
bool mCheckPointDestroyed;
|
||||
size_t mCheckPointCmdNo;
|
||||
|
||||
protected:
|
||||
|
||||
size_t GetLineCountInRange( char* from, char* till );
|
||||
|
||||
// two lowest-level operations
|
||||
void DoInsertText ( const TPosition& pos, char* text, size_t len, TRange& actualRange );
|
||||
void DoDeleteRange( const TPosition& from, const TPosition& till, TRange& actualRange );
|
||||
|
||||
void DoExecuteNewCommand( TCommand& cmd );
|
||||
|
||||
void DoReexecuteCommand( TCommand& cmd );
|
||||
void DoUnexecuteCommand( TCommand& cmd );
|
||||
|
||||
|
||||
void ExecuteCommand( TCommand* pCmd );
|
||||
|
||||
// to methods enabling grouping of undo-able commands
|
||||
bool CanPrependCommand( TCommand* pCmd );
|
||||
void PrependCommand( TCommand* pCmd );
|
||||
|
||||
void SetPostPos( const TPosition& pos );
|
||||
|
||||
void UndoImpl();
|
||||
void RedoImpl();
|
||||
|
||||
void StartBatch();
|
||||
void FinishBatch();
|
||||
|
||||
void CheckSelection();
|
||||
void TrackSelection();
|
||||
|
||||
void NotifyView();
|
||||
void NotifyAllViews();
|
||||
|
||||
void NotifyTextChanged( size_t atRow, size_t nRows, TEXT_CHANGE_TYPE ct );
|
||||
void NotifyTextChanged( TPosition from, TPosition till, TEXT_CHANGE_TYPE ct );
|
||||
|
||||
void ArrangePositions( TPosition& upper, TPosition& lower );
|
||||
void ArrangePositions( size_t& upper, size_t& lower );
|
||||
|
||||
void MergeChange( size_t fromRow, size_t nRows );
|
||||
|
||||
void PrepreForCommand();
|
||||
|
||||
size_t TextToScrColumn( const TPosition& pos );
|
||||
size_t ScrToTextColumn( TPosition pos );
|
||||
|
||||
void DoMoveCursor( int rows, int cols );
|
||||
|
||||
public:
|
||||
wxTextEditorModel();
|
||||
virtual ~wxTextEditorModel();
|
||||
|
||||
// utilities
|
||||
|
||||
char* AllocCharacters( size_t n );
|
||||
char* AllocCharacters( size_t n, const char* srcBuf );
|
||||
void FreeCharacters( char* buf );
|
||||
|
||||
void DeleteSelection();
|
||||
TTextIterator CreateIterator( const TPosition& pos );
|
||||
|
||||
void DeleteRange( const TPosition& from, const TPosition& till );
|
||||
void InsertText( const TPosition& pos, const char* text, size_t len );
|
||||
void GetTextFromRange( const TPosition& from, const TPosition& till, char** text, size_t& textLen );
|
||||
void LoadTextFromFile( const wxString& fname );
|
||||
void SaveTextToFile( const wxString& fname );
|
||||
void ResetSelection();
|
||||
void ClearUndoBuffer();
|
||||
|
||||
|
||||
void DeleteAllText();
|
||||
void GetAllText( char** text, size_t& textLen );
|
||||
|
||||
void SetSelectionEditMode( bool editIsOn );
|
||||
|
||||
/*** user-level commands ***/
|
||||
|
||||
// mutable (undoable) commands
|
||||
|
||||
void OnInsertChar( char ch );
|
||||
void OnDelete();
|
||||
void OnDeleteBack();
|
||||
void OnDeleteLine();
|
||||
|
||||
void OnShiftSelectionIndent( bool left );
|
||||
|
||||
// clipboard functions
|
||||
|
||||
void OnCopy();
|
||||
void OnPaste();
|
||||
void OnCut();
|
||||
bool CanCopy();
|
||||
bool CanPaste();
|
||||
|
||||
// undo-redo
|
||||
|
||||
bool CanUndo();
|
||||
bool CanRedo();
|
||||
void OnUndo();
|
||||
void OnRedo();
|
||||
|
||||
// imutable commands
|
||||
|
||||
void OnMoveLeft();
|
||||
void OnMoveRight();
|
||||
void OnMoveUp();
|
||||
void OnMoveDown();
|
||||
|
||||
void OnWordLeft();
|
||||
void OnWordRight();
|
||||
|
||||
void OnMoveToPosition( const TPosition& pos );
|
||||
|
||||
void OnEndOfLine();
|
||||
void OnStartOfLine();
|
||||
void OnPageUp();
|
||||
void OnPageDown();
|
||||
void OnSlideUp();
|
||||
void OnSlideDown();
|
||||
void OnStartOfText();
|
||||
void OnEndOfText();
|
||||
|
||||
void OnSelectWord();
|
||||
void OnSelectAll();
|
||||
|
||||
// bookmarks
|
||||
|
||||
void OnToggleBookmark();
|
||||
void OnNextBookmark();
|
||||
void OnPreviousBookmark();
|
||||
|
||||
// search
|
||||
|
||||
bool OnFind();
|
||||
bool OnFindNext();
|
||||
bool OnFindPrevious();
|
||||
void OnGotoLine( int line, int col );
|
||||
void OnGotoLine();
|
||||
|
||||
// status
|
||||
|
||||
bool IsReadOnly();
|
||||
bool IsModified();
|
||||
bool IsInsertMode();
|
||||
|
||||
// check-pointin
|
||||
|
||||
void SetCheckpoint();
|
||||
bool CheckpointModified();
|
||||
|
||||
// accessors
|
||||
|
||||
TPosition GetStartOfSelection();
|
||||
TPosition GetEndOfSelection();
|
||||
TPosition GetCursor();
|
||||
|
||||
size_t GetTotalRowCount();
|
||||
bool SelectionIsEmpty();
|
||||
bool IsLastLine( const TPosition& pos );
|
||||
|
||||
bool IsUnixText() { return mIsUnixText; }
|
||||
|
||||
void GetSelection( char** text, size_t& textLen );
|
||||
|
||||
void SetStartOfSelection( const TPosition& pos );
|
||||
void SetEndOfSelection( const TPosition& pos );
|
||||
void SetCursor( const TPosition& pos );
|
||||
|
||||
void AddView( wxTextEditorView* pView );
|
||||
void RemoveView( wxTextEditorView* pView );
|
||||
void SetActiveView( wxTextEditorView* pView );
|
||||
wxTextEditorView* GetActiveView();
|
||||
|
||||
void SetRowsPerPage( size_t n );
|
||||
|
||||
void AddPin( TPinBase* pPin );
|
||||
PinListT& GetPins();
|
||||
|
||||
// returns NPOS, if non
|
||||
size_t FindFirstPinInRange( size_t fromRow, size_t tillRow );
|
||||
size_t FindNextPinFrom( size_t fromRow );
|
||||
size_t FindPreviousPinFrom( size_t fromRow );
|
||||
|
||||
size_t GetPinNoAt( size_t row, int pinTypeCode );
|
||||
TPinBase* GetPinAt( size_t row, int pinTypeCode );
|
||||
void RemovePinAt( size_t row, int pinTypeCode );
|
||||
|
||||
void AddChangeListener( TTextChangeListenerBase* pListener );
|
||||
};
|
||||
|
||||
class TCursorTimer;
|
||||
class wxTextEditorView;
|
||||
|
||||
class TPinPainterBase : public wxObject
|
||||
{
|
||||
public:
|
||||
int mPinTypeCode;
|
||||
|
||||
public:
|
||||
TPinPainterBase( int pinTc ) : mPinTypeCode( pinTc ) {}
|
||||
TPinPainterBase() : mPinTypeCode( -1 ) {}
|
||||
|
||||
inline int GetPinTypeCode() { return mPinTypeCode; }
|
||||
|
||||
virtual void DrawPin( TPinBase* pPin, wxTextEditorView& view, wxDC& dc,
|
||||
const wxPoint& pos, const wxSize& dim ) = 0;
|
||||
};
|
||||
|
||||
/*
|
||||
* a couple very common ping objects/painters
|
||||
*/
|
||||
|
||||
#define BOOKMARK_PIN_TC (OTHER_PINS_TC_START)
|
||||
#define BRKPOINT_PIN_TC (BOOKMARK_PIN_TC + 1)
|
||||
|
||||
class TBookmarkPainter : public TPinPainterBase
|
||||
{
|
||||
protected:
|
||||
wxBrush mBkBrush;
|
||||
|
||||
public:
|
||||
TBookmarkPainter();
|
||||
|
||||
virtual void DrawPin( TPinBase* pPin, wxTextEditorView& view, wxDC& dc,
|
||||
const wxPoint& pos, const wxSize& dim );
|
||||
};
|
||||
|
||||
class TBookmarkPin : public TPinBase
|
||||
{
|
||||
public:
|
||||
TBookmarkPin( size_t row )
|
||||
: TPinBase( BOOKMARK_PIN_TC, row )
|
||||
{}
|
||||
|
||||
static int GetPinTypeCode() { return BOOKMARK_PIN_TC; }
|
||||
};
|
||||
|
||||
class TBreakpointPainter : public TPinPainterBase
|
||||
{
|
||||
protected:
|
||||
wxBrush mBkBrush;
|
||||
|
||||
public:
|
||||
TBreakpointPainter();
|
||||
|
||||
virtual void DrawPin( TPinBase* pPin, wxTextEditorView& view, wxDC& dc,
|
||||
const wxPoint& pos, const wxSize& dim );
|
||||
};
|
||||
|
||||
class TBreakpointPin : public TPinBase
|
||||
{
|
||||
public:
|
||||
TBreakpointPin( size_t row )
|
||||
: TPinBase( BRKPOINT_PIN_TC, row )
|
||||
{}
|
||||
|
||||
static int GetPinTypeCode() { return BRKPOINT_PIN_TC; }
|
||||
};
|
||||
|
||||
|
||||
#if defined( wxUSE_TEMPLATE_STL )
|
||||
typedef vector<TPinPainterBase*> PinPainterListT;
|
||||
#else
|
||||
typedef TPinPainterBase* TPinPainterBasePtrT;
|
||||
typedef WXSTL_VECTOR_SHALLOW_COPY( TPinPainterBasePtrT ) PinPainterListT;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Class displays graphical view of data contained in wxTextModel
|
||||
*/
|
||||
|
||||
class wxTextEditorView : public wxScrolledWindow
|
||||
{
|
||||
protected:
|
||||
|
||||
wxTextEditorModel* mpModel;
|
||||
TPosition mSelectionStart;
|
||||
TPosition mSelectionEnd;
|
||||
TPosition mCursorPos;
|
||||
|
||||
TPosition mLastViewStart;
|
||||
size_t mLastRowsTotal;
|
||||
|
||||
size_t mRowsPerPage;
|
||||
size_t mColsPerPage;
|
||||
|
||||
static char* mpLineBuffer;
|
||||
static size_t mpLineBufferLen;
|
||||
|
||||
bool mFullRefreshPending;
|
||||
bool mAdjustScrollPending;
|
||||
|
||||
wxFont mFont;
|
||||
|
||||
bool mScrollingOn; // default: TRUE
|
||||
bool mCursorOn; // default: TRUE;
|
||||
|
||||
bool mLTMode; // line-tracking mode
|
||||
// (when the whole line is coloured,
|
||||
// instead of showing blinking cursor position)
|
||||
|
||||
wxColour mLTColour; // fill-colour for LT-mode
|
||||
|
||||
bool mDragStarted;
|
||||
char* mpDraggedText;
|
||||
|
||||
bool mOwnsModel;
|
||||
|
||||
wxString mFragment; // reused heap-buffer
|
||||
// for coloured fragments
|
||||
SourcePainter* mpPainter;
|
||||
PinPainterListT mPinPainters;
|
||||
TTextIterator mCashedIter;
|
||||
|
||||
static TCursorTimer* mpTimer;
|
||||
|
||||
public: /*** public properties ***/
|
||||
|
||||
int mLeftMargin; // default: 20
|
||||
int mRightMargin; // default: 0
|
||||
int mTopMargin; // default: 0
|
||||
int mBottomMargin; // default: 0
|
||||
int mMaxColumns; // default: 500
|
||||
|
||||
TPosition mPagePos;
|
||||
|
||||
// color-scheme properties
|
||||
|
||||
wxColour mNormalTextCol;
|
||||
wxColour mIndentifierTextCol;
|
||||
wxColour mReservedWordTextCol;
|
||||
wxColour mCommentTextCol;
|
||||
|
||||
wxColour mNormalBkCol;
|
||||
wxColour mSelectionFgCol;
|
||||
wxColour mSelectionBkCol;
|
||||
|
||||
wxBrush mNormalBkBrush;
|
||||
wxBrush mSelectedBkBrush;
|
||||
|
||||
// accessed by timer
|
||||
|
||||
TPosition mCursorScrPos;
|
||||
wxSize mCharDim;
|
||||
|
||||
protected:
|
||||
|
||||
char* GetLineBuffer( size_t len );
|
||||
|
||||
virtual void PaintDecorations( size_t fromRow, size_t tillRow, wxDC& dc, TTextIterator& iter );
|
||||
virtual void PaintRows( size_t fromRow, size_t tillRow, wxDC& dc );
|
||||
|
||||
void ObtainFontProperties();
|
||||
|
||||
bool IsActiveView();
|
||||
void SetTextDefaults();
|
||||
void RecalcPagingInfo();
|
||||
|
||||
TPinPainterBase* FindPainterForPin( TPinBase& pin );
|
||||
|
||||
public:
|
||||
wxTextEditorView( wxWindow* parent, wxWindowID id = -1,
|
||||
wxTextEditorModel* pModel = NULL,
|
||||
int wndStyle = wxSUNKEN_BORDER,
|
||||
bool ownsModel = TRUE );
|
||||
~wxTextEditorView();
|
||||
|
||||
/*** setup methods ***/
|
||||
|
||||
void SetModel( wxTextEditorModel* pModel );
|
||||
|
||||
// sets custom syntax-higlighting implementation
|
||||
void SetSourcePainter( SourcePainter* pPainter );
|
||||
void AddPinPainter( TPinPainterBase* pPainter );
|
||||
|
||||
void SetDefaultFont( const wxFont& font );
|
||||
wxFont& GetDefaultFont();
|
||||
|
||||
wxSize GetCharacterSize() { return mCharDim; }
|
||||
|
||||
size_t GetRowsPerPage() { return mRowsPerPage; }
|
||||
void SetRowsPerPage( size_t n );
|
||||
void SetMaxColumns( size_t n );
|
||||
|
||||
void SetLineTrackingMode( bool on, const wxColour& col = wxColour(255,255,0) );
|
||||
|
||||
void EnableCursor( bool enable );
|
||||
void EnableScrollbars( bool enable );
|
||||
|
||||
void SetColours( const wxColour& normalBkCol,
|
||||
const wxColour& selectedBkCol,
|
||||
const wxColour& selectedTextCol );
|
||||
|
||||
void SetHeighlightingColours( const wxColour& normalTextCol,
|
||||
const wxColour& identifierTextCol,
|
||||
const wxColour& reservedWordTextCol,
|
||||
const wxColour& commentTextCol );
|
||||
|
||||
void SetMargins( int top, int left, int bottom, int right );
|
||||
|
||||
// notifications from editor-model:
|
||||
|
||||
void OnModelChanged();
|
||||
void ScrollView( int rows, int cols );
|
||||
|
||||
// accessors
|
||||
|
||||
void Activate();
|
||||
void Deactivate();
|
||||
|
||||
// event handlers
|
||||
|
||||
#if (( wxVERSION_NUMBER < 2100 ) || (( wxVERSION_NUMBER == 2100 ) && (wxBETA_NUMBER <= 4)))
|
||||
void OnScroll( wxScrollEvent& event );
|
||||
#else
|
||||
void OnScroll( wxScrollWinEvent& event );
|
||||
#endif
|
||||
void OnPaint ( wxPaintEvent& event );
|
||||
void OnSize ( wxSizeEvent& event );
|
||||
void OnEraseBackground( wxEraseEvent& event );
|
||||
|
||||
void OnLButtonDown( wxMouseEvent& event );
|
||||
void OnLButtonUp ( wxMouseEvent& event );
|
||||
void OnMotion ( wxMouseEvent& event );
|
||||
void OnDblClick ( wxMouseEvent& event );
|
||||
|
||||
void OnSetFocus( wxFocusEvent& event );
|
||||
void OnKillFocus( wxFocusEvent& event );
|
||||
|
||||
// requests editor to keep cursor blinking, even when
|
||||
// the window has lost it's focus
|
||||
|
||||
void HoldCursor( bool hold );
|
||||
|
||||
// FOR NOW:: hard-coded key-bindings
|
||||
|
||||
void OnChar( wxKeyEvent& event );
|
||||
void OnKeyDown( wxKeyEvent& event );
|
||||
|
||||
// utilities
|
||||
|
||||
virtual void SyncViewPortPosition();
|
||||
virtual void SyncScrollbars();
|
||||
virtual void PositionCursor();
|
||||
|
||||
void TextPosToScreenPos( const TPosition& txtPos, TPosition& scrPos );
|
||||
void ScreenPosToTextPos( const TPosition& scrPos, TPosition& txtPos );
|
||||
void ScreenPosToPixels ( const TPosition& scrPos, int& x, int& y );
|
||||
void PixelsToScrPos ( int x, int y, int& scrRow, int& scrCol );
|
||||
void PixelsToTextPos ( int x, int y, TPosition& textPos );
|
||||
|
||||
bool IsClipboardCmd( wxKeyEvent& key );
|
||||
|
||||
TPosition GetPagePos() { return mPagePos; }
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
// TODO:: mutex class should be used to avoid race on updates
|
||||
|
||||
class TCursorTimer : public wxTimer
|
||||
{
|
||||
protected:
|
||||
wxTextEditorView* mpView;
|
||||
volatile bool mIsLocked;
|
||||
volatile bool mIsShown;
|
||||
volatile bool mStarted;
|
||||
wxBrush mBrush;
|
||||
bool mMissOneTick;
|
||||
|
||||
int mBlinkInterval; // default: 500mills
|
||||
protected:
|
||||
|
||||
void DrawCursor();
|
||||
|
||||
public:
|
||||
|
||||
TCursorTimer();
|
||||
|
||||
virtual void Notify();
|
||||
|
||||
void SetView( wxTextEditorView* pView );
|
||||
wxTextEditorView* GetView();
|
||||
void HideCursor( bool forceHide = FALSE );
|
||||
void ShowCursor( bool forceShow = FALSE );
|
||||
|
||||
void SetIsShown( bool isShown );
|
||||
void Lock();
|
||||
void Unlock();
|
||||
};
|
||||
|
||||
#endif // __TDEFS_G__
|
118
utils/wxPython/modules/lseditor/test/editor.py
Normal file
118
utils/wxPython/modules/lseditor/test/editor.py
Normal file
@ -0,0 +1,118 @@
|
||||
from wxPython.wx import *
|
||||
from wxPython.lseditor import *
|
||||
|
||||
class LSEditorFrame(wxFrame):
|
||||
def __init__(self, parent, id, title, pos = wxDefaultPosition, size = wxSize(400,400)):
|
||||
wxFrame.__init__(self, parent, id, title, pos, size)
|
||||
self.editor = wxsLSEditorPlugin()
|
||||
self.editor.Create(self, -1)
|
||||
self.SetMenuBar(self.GetDefaultMenuBar())
|
||||
self.CreateStatusBar()
|
||||
self.SetDefaultEvents()
|
||||
self.filename = ""
|
||||
def GetDefaultMenuBar(self):
|
||||
mbar = wxMenuBar()
|
||||
menu = wxMenu()
|
||||
menu.Append(1500, "Open")
|
||||
menu.Append(1501, "Save")
|
||||
menu.Append(1502, "SaveAs")
|
||||
menu.AppendSeparator()
|
||||
menu.Append(1503, "Exit")
|
||||
mbar.Append(menu, "File")
|
||||
menu = wxMenu()
|
||||
menu.Append(1510, "Copy")
|
||||
menu.Append(1511, "Cut")
|
||||
menu.Append(1512, "Paste")
|
||||
menu.AppendSeparator()
|
||||
menu.Append(1513, "Delete")
|
||||
menu.AppendSeparator()
|
||||
menu.Append(1514, "Undo")
|
||||
menu.Append(1515, "Redo")
|
||||
menu.AppendSeparator()
|
||||
menu.Append(1516, "Find...")
|
||||
menu.Append(1517, "Find Next")
|
||||
menu.Append(1518, "Find Previous")
|
||||
menu.Append(1519, "Replace...")
|
||||
mbar.Append(menu, "Edit")
|
||||
menu = wxMenu()
|
||||
menu.Append(1520, "Toggle")
|
||||
menu.Append(1521, "Next")
|
||||
menu.Append(1522, "Prev")
|
||||
mbar.Append(menu, "Bookmarks")
|
||||
return mbar
|
||||
def SetDefaultEvents(self):
|
||||
EVT_MENU(self, 1500, self.evt_OnOpen)
|
||||
EVT_MENU(self, 1501, self.evt_OnSave)
|
||||
EVT_MENU(self, 1502, self.evt_OnSaveAs)
|
||||
EVT_MENU(self, 1503, self.OnClose)
|
||||
EVT_MENU(self, 1510, self.evt_OnCopy)
|
||||
EVT_MENU(self, 1511, self.evt_OnCut)
|
||||
EVT_MENU(self, 1512, self.evt_OnPaste)
|
||||
EVT_MENU(self, 1513, self.evt_OnDelete)
|
||||
EVT_MENU(self, 1514, self.evt_OnUndo)
|
||||
EVT_MENU(self, 1515, self.evt_OnRedo)
|
||||
EVT_MENU(self, 1516, self.evt_OnFind)
|
||||
EVT_MENU(self, 1517, self.evt_OnFindNext)
|
||||
EVT_MENU(self, 1518, self.evt_OnFindPrevious)
|
||||
EVT_MENU(self, 1519, self.evt_OnReplace)
|
||||
EVT_MENU(self, 1520, self.evt_OnToggle)
|
||||
EVT_MENU(self, 1521, self.evt_OnNext)
|
||||
EVT_MENU(self, 1522, self.evt_OnPrev)
|
||||
#EVT_MENU(self, 15, self.evt_)
|
||||
#EVT_MENU(self, 15, self.evt_)
|
||||
def evt_OnOpen(self, event):
|
||||
dlg = wxFileDialog(NULL, "Open file")
|
||||
if dlg.ShowModal() == wxID_OK:
|
||||
self.filename = dlg.GetPath()
|
||||
self.editor.OnOpen(self.filename)
|
||||
def evt_OnSaveAs(self, event):
|
||||
dlg = wxFileDialog(NULL, "Save As", self.filename)
|
||||
if dlg.ShowModal() == wxID_OK:
|
||||
self.filename = dlg.GetPath()
|
||||
self.editor.OnSave(self.filename)
|
||||
def evt_OnSave(self, event):
|
||||
if self.filename:
|
||||
self.editor.OnSave(self.filename)
|
||||
else:
|
||||
self.evt_OnSaveAs(None)
|
||||
def OnClose(self,event):
|
||||
self.Destroy()
|
||||
def evt_OnCopy(self,event):
|
||||
self.editor.OnCopy()
|
||||
def evt_OnCut(self,event):
|
||||
self.editor.OnCut()
|
||||
def evt_OnPaste(self,event):
|
||||
self.editor.OnPaste()
|
||||
def evt_OnDelete(self,event):
|
||||
self.editor.OnDelete()
|
||||
def evt_OnUndo(self,event):
|
||||
self.editor.OnUndo()
|
||||
def evt_OnRedo(self,event):
|
||||
self.editor.OnRedo()
|
||||
def evt_OnToggle(self,event):
|
||||
self.editor.OnToggleBookmark()
|
||||
def evt_OnNext(self,event):
|
||||
self.editor.OnNextBookmark()
|
||||
def evt_OnPrev(self,event):
|
||||
self.editor.OnPreviousBookmark()
|
||||
def evt_OnFind(self,event):
|
||||
self.editor.OnFind()
|
||||
def evt_OnFind(self,event):
|
||||
self.editor.OnFind()
|
||||
def evt_OnFindNext(self,event):
|
||||
self.editor.OnFindNext()
|
||||
def evt_OnFindPrevious(self,event):
|
||||
self.editor.OnFindPrevious()
|
||||
self.SetStatusText("OnFindPrevious: Not implemented")
|
||||
def evt_OnReplace(self,event):
|
||||
self.editor.OnReplace()
|
||||
self.SetStatusText("OnReplace: Not implemented")
|
||||
|
||||
class MyApp(wxApp):
|
||||
def OnInit(self):
|
||||
frame = LSEditorFrame(NULL, -1, "Editor")
|
||||
frame.Show(TRUE)
|
||||
return TRUE
|
||||
|
||||
App = MyApp(0)
|
||||
App.MainLoop()
|
374
utils/wxPython/modules/lseditor/wxsdefs.h
Normal file
374
utils/wxPython/modules/lseditor/wxsdefs.h
Normal file
@ -0,0 +1,374 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: No names yet.
|
||||
// Purpose: Contrib. demo
|
||||
// Author: Aleksandras Gluchovas
|
||||
// Modified by:
|
||||
// Created: 24/04/1999
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Aleskandars Gluchovas
|
||||
// Licence: GNU General Public License
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef __WXSDEFS_G__
|
||||
#define __WXSDEFS_G__
|
||||
|
||||
#include <config.h>
|
||||
|
||||
|
||||
#include "controlarea.h"
|
||||
|
||||
#ifdef wxUSE_TEMPLATE_STL
|
||||
#include <vector>
|
||||
#include <map>
|
||||
//using std::map;
|
||||
//using std::vector;
|
||||
using namespace std;
|
||||
#else
|
||||
#include "wxstldefs.h" // imports predefine StrListT, IntListT containers
|
||||
#include "wxstlac.h"
|
||||
#endif
|
||||
class wxsProject;
|
||||
class wxsComponent;
|
||||
class wxsWorkplace;
|
||||
class wxsOpenedFileInfo;
|
||||
class wxsWorkplaceListener;
|
||||
class wxsSourceEditorPlugin;
|
||||
class wxsSourceInfoPlugin;
|
||||
class wxsAppListener;
|
||||
class wxsAppInterface;
|
||||
|
||||
class wxFrame;
|
||||
|
||||
typedef wxsWorkplaceListener* wxsWorkplaceListenerPtrT;
|
||||
|
||||
#ifdef wxUSE_TEMPLATE_STL
|
||||
typedef vector<wxsWorkplaceListenerPtrT> wxsWorkplaceListenerListT;
|
||||
#else
|
||||
typedef WXSTL_VECTOR_SHALLOW_COPY( wxsWorkplaceListenerPtrT ) wxsWorkplaceListenerListT;
|
||||
#endif
|
||||
|
||||
// IDs for the controls and the menu commands
|
||||
enum
|
||||
{
|
||||
// menu items
|
||||
WXS_Quit = 3300, // FIXEM:: ids..
|
||||
WXS_About,
|
||||
WXS_Open,
|
||||
WXS_Close,
|
||||
WXS_OpenWorkplace,
|
||||
WXS_Save,
|
||||
WXS_SaveAs,
|
||||
WXS_SaveAll,
|
||||
WXS_CloseWorkplace,
|
||||
WXS_SaveWorkplace,
|
||||
WXS_NewProject,
|
||||
|
||||
WXS_ShowTips,
|
||||
|
||||
WXS_Undo = 9000,
|
||||
WXS_NextWindow,
|
||||
WXS_PreviousWindow,
|
||||
WXS_CloseWindow,
|
||||
WXS_ListWindows,
|
||||
WXS_UpdateBrowser,
|
||||
WXS_ToggleWorkplaceWindow,
|
||||
|
||||
WXS_InsertFiles,
|
||||
WXS_Test,
|
||||
WXS_Settings,
|
||||
|
||||
WXS_ClassView,
|
||||
WXS_FileView,
|
||||
WXS_GotoEditor,
|
||||
|
||||
WXS_Test1,
|
||||
WXS_Test2,
|
||||
|
||||
// controls start here (the numbers are, of course, arbitrary)
|
||||
WXS_Text = 1000,
|
||||
|
||||
ID_EDIT_UNDO,
|
||||
ID_EDIT_REDO,
|
||||
ID_EDIT_CUT,
|
||||
ID_EDIT_COPY,
|
||||
ID_EDIT_PASTE,
|
||||
ID_EDIT_DELETE,
|
||||
ID_EDIT_SELECT_ALL,
|
||||
ID_EDIT_FIND,
|
||||
ID_EDIT_FIND_NEXT,
|
||||
ID_EDIT_REPLACE,
|
||||
ID_EDIT_GOTO,
|
||||
ID_EDIT_TOGGLE_BM,
|
||||
ID_EDIT_NEXT_BM,
|
||||
ID_EDIT_PREV_BM,
|
||||
ID_EDIT_TOGGLE_BRKPNT,
|
||||
ID_EDIT_BOOKMARKS,
|
||||
ID_EDIT_SETFONT,
|
||||
ID_LEFT_SASH,
|
||||
ID_BOTTOM_SASH
|
||||
};
|
||||
|
||||
// bitmaps/icons
|
||||
enum WXS_ICON_ENUM{
|
||||
WXS_ICON_class = 1,
|
||||
WXS_ICON_priv_mtd,
|
||||
WXS_ICON_prot_mtd,
|
||||
WXS_ICON_pub_mtd,
|
||||
WXS_ICON_priv_mtd_def,
|
||||
WXS_ICON_prot_mtd_def,
|
||||
WXS_ICON_pub_mtd_def,
|
||||
WXS_ICON_priv_var,
|
||||
WXS_ICON_prot_var,
|
||||
WXS_ICON_pub_var,
|
||||
WXS_ICON_pub_pure_mtd,
|
||||
WXS_ICON_file,
|
||||
WXS_ICON_folder,
|
||||
WXS_ICON_mru_folder,
|
||||
WXS_ICON_class_gray,
|
||||
WXS_ICON_file_gray,
|
||||
};
|
||||
|
||||
|
||||
typedef char* CharPtrT;
|
||||
|
||||
struct UU_cmp
|
||||
{
|
||||
inline int operator()(const CharPtrT x, const CharPtrT y ) const { return 0; }
|
||||
};
|
||||
|
||||
typedef wxBitmap* wxBitmapPtrT;
|
||||
#ifdef wxUSE_TEMPLATE_STL
|
||||
typedef map<WXS_ICON_ENUM, wxBitmapPtrT> WXS_BitmapsMapT;
|
||||
#else
|
||||
typedef WXSTL_MAP( WXS_ICON_ENUM, wxBitmapPtrT,
|
||||
LESS_THEN_FUNCTOR(WXS_ICON_ENUM) ) WXS_BitmapsMapT;
|
||||
#endif
|
||||
|
||||
extern WXS_BitmapsMapT WXS_Bitmaps;
|
||||
#define WXS_ICON(name) (*WXS_Bitmaps[WXS_ICON_##name])
|
||||
|
||||
|
||||
// very general file categories
|
||||
|
||||
enum WXS_FILE_CATEGORY
|
||||
{
|
||||
WXS_UNKNOWN_FILE,
|
||||
WXS_SOURCE_FILE,
|
||||
WXS_RESOURCE_FILE,
|
||||
WXS_DOCUMENTATION_FILE,
|
||||
WXS_CONFIGURAITON_FILE
|
||||
};
|
||||
|
||||
enum WXS_PLUGIN_TYPE
|
||||
{
|
||||
WXS_UNKNOWN_PLUGIN,
|
||||
WXS_EDITOR_PLUGIN,
|
||||
WXS_CLASSINFO_PLUGIN,
|
||||
WXS_CLASSBROWSER_PLUGIN,
|
||||
WXS_FILEBROWSER_PLUGIN,
|
||||
WXS_TOOL_PLUGIN,
|
||||
WXS_OUTPUTTOOL_PLUGIN
|
||||
};
|
||||
|
||||
|
||||
|
||||
class wxsAppListener
|
||||
{
|
||||
public:
|
||||
virtual void OnWindowSwitched( wxWindow* fromWnd, wxWindow* toWnd ) {};
|
||||
virtual bool OnCloseWindow( wxWindow* wnd ) { return TRUE; }
|
||||
virtual void OnTabSwitched() {};
|
||||
virtual void OnPageSwitched() {};
|
||||
};
|
||||
|
||||
class wxsAppInterface
|
||||
{
|
||||
public:
|
||||
virtual void SetAppListener(wxsAppListener* pLsn) = 0;
|
||||
|
||||
virtual void AddEditor(wxsSourceEditorPlugin* editor,wxString title,wxBitmap* pImage = NULL) = 0;
|
||||
virtual void ActivateEditor( wxsSourceEditorPlugin* editor ) = 0;
|
||||
virtual void CloseEditor( wxsSourceEditorPlugin* editor ) = 0;
|
||||
|
||||
virtual void ShowNextWindow() = 0;
|
||||
virtual void ShowPreviousWindow() = 0;
|
||||
virtual void CloseActiveWindow() = 0;
|
||||
virtual void CloseWindow( wxWindow* wnd ) = 0;
|
||||
virtual void ShowWindowList() = 0;
|
||||
virtual wxWindow* GetActiveWindow() = 0;
|
||||
virtual wxTabbedWindow* GetTabbedWindow() = 0;
|
||||
virtual void AddTab(wxsComponent* pContent, wxString tabText, wxBitmap* pImage = NULL) = 0;
|
||||
virtual void ShowNextTab() = 0;
|
||||
virtual wxPaggedWindow* GetPaggedWindow() = 0;
|
||||
virtual void AddPage(wxsComponent* pContent, wxString tabText, wxBitmap* pImage = NULL) = 0;
|
||||
virtual void ShowNextPage() = 0;
|
||||
virtual wxFrame* GetMainFrame() = 0;
|
||||
virtual void SetStatusText( const string& text ) = 0;
|
||||
|
||||
static wxsAppInterface& GetInstance();
|
||||
|
||||
protected:
|
||||
static wxsAppInterface* mpInstance;
|
||||
friend wxsAppInterface& wxsGetApp();
|
||||
};
|
||||
|
||||
// short-cut for wxsAppInterface::GetInstance()
|
||||
|
||||
wxsAppInterface& wxsGetApp();
|
||||
|
||||
class wxsWorkplaceListener : public wxObject
|
||||
{
|
||||
public:
|
||||
virtual void OnSubprojectAdded( wxsProject& subPrj, wxsProject& toPrj ) {}
|
||||
virtual void OnSubprojectRemoved( wxsProject& subPrj, wxsProject& fromPrj ) {}
|
||||
virtual void OnProjectCreated( wxsProject& prj ) {}
|
||||
virtual void OnRootProjectLoaded() {}
|
||||
virtual void OnRootProjectClosed() {}
|
||||
virtual void OnFilesAddedToProject( wxsProject& prj, StrListT& files, WXS_FILE_CATEGORY cat ) {}
|
||||
virtual void OnFilesRemovedFromProject( wxsProject& prj, StrListT& files, WXS_FILE_CATEGORY cat ) {}
|
||||
|
||||
virtual void OnFileContentChanged( wxsProject& prj, const string& file, WXS_FILE_CATEGORY cat,
|
||||
char* newContent, size_t len ) {}
|
||||
|
||||
virtual void OnFileOpened( wxsOpenedFileInfo& file ) {}
|
||||
};
|
||||
|
||||
typedef wxsProject* wxsProjectPtrT;
|
||||
#ifdef wxUSE_TEMPLATE_STL
|
||||
typedef vector<wxsProjectPtrT> wxsProjectListT;
|
||||
#else
|
||||
typedef WXSTL_VECTOR_SHALLOW_COPY( wxsProjectPtrT ) wxsProjectListT;
|
||||
#endif
|
||||
|
||||
class wxsProject : public wxObject
|
||||
{
|
||||
public:
|
||||
// Basic project info
|
||||
virtual void SetName(const string& name) = 0;
|
||||
virtual void SetFileName(const string& fname) = 0;
|
||||
virtual void SetDescription(const string& desc) = 0;
|
||||
virtual void SetLanguage(const string& lang) = 0;
|
||||
virtual string GetName() = 0;
|
||||
virtual string GetFileName() = 0;
|
||||
virtual string GetDescription() = 0;
|
||||
virtual string GetLanguage() = 0;
|
||||
// File manipulation
|
||||
virtual bool AddFile( const string& file) = 0;
|
||||
virtual bool RemoveFile ( const string& file ) = 0;
|
||||
virtual StrListT GetFiles() = 0;
|
||||
// Sub-Project manipulation
|
||||
virtual void AddSubproject( wxsProject* subPrj) = 0;
|
||||
virtual void RemoveSubproject( wxsProject* subPrj) = 0;
|
||||
virtual wxsProjectListT& GetSubprojects() = 0;
|
||||
// Transient information (parent only exists when loaded
|
||||
virtual void SetParent( wxsProject* parentPrj) = 0;
|
||||
virtual wxsProject* GetParent() = 0;
|
||||
// configuration info storage
|
||||
virtual string CreateConfig ( const string& file = "" ) = 0;
|
||||
virtual bool SetCurrentConfig ( const string& configkey ) = 0;
|
||||
virtual bool AddConfigValue( const string& key, string& value) = 0;
|
||||
virtual bool SetConfigValue( const string& key, string& value) = 0;
|
||||
virtual bool RemoveConfigValue( const string& key ) = 0;
|
||||
virtual string GetConfigValue ( const string& key ) = 0;
|
||||
|
||||
|
||||
};
|
||||
|
||||
class wxsOpenedFileInfo : public wxObject
|
||||
{
|
||||
public:
|
||||
string mFullName;
|
||||
wxsProject* mpProject; // NULL, if file does not belong to any project
|
||||
wxsSourceEditorPlugin* mpEditor;
|
||||
WXS_FILE_CATEGORY mCategory;
|
||||
bool mIsSaved;
|
||||
|
||||
public:
|
||||
wxsOpenedFileInfo() : mIsSaved( TRUE ), mpProject( NULL ) {}
|
||||
|
||||
wxsProject* GetProject() { return mpProject; }
|
||||
const string& GetFullName() { return mFullName; }
|
||||
wxsSourceEditorPlugin& GetEditor() { return *mpEditor; }
|
||||
WXS_FILE_CATEGORY GetCategory() { return mCategory; }
|
||||
};
|
||||
|
||||
typedef wxsOpenedFileInfo* wxsOpenedFileInfoPtrT;
|
||||
#ifdef wxUSE_TEMPLATE_STL
|
||||
typedef vector<wxsOpenedFileInfoPtrT> wxsOpenedFileInfoListT;
|
||||
#else
|
||||
typedef WXSTL_VECTOR_SHALLOW_COPY( wxsOpenedFileInfoPtrT ) wxsOpenedFileInfoListT;
|
||||
#endif
|
||||
|
||||
// abstract interface
|
||||
|
||||
class wxsWorkplace : public wxObject
|
||||
{
|
||||
public:
|
||||
virtual void CreateProject( const string& name, const string& projectFile, const wxsProject* parent=NULL) = 0;
|
||||
|
||||
virtual void LoadRootProject( const string& projectFile ) = 0;
|
||||
virtual void SaveProject( wxsProject& prj ) = 0;
|
||||
virtual void CloseRootProject() = 0;
|
||||
|
||||
virtual wxsProject& GetRootProject() = 0;
|
||||
virtual wxsProject* FindProjectByName( const string& name ) = 0;
|
||||
virtual wxsOpenedFileInfo* FindFileByEditor( wxsSourceEditorPlugin& editor ) = 0;
|
||||
|
||||
virtual void AddWorkpalceListener( wxsWorkplaceListener* pListener ) = 0;
|
||||
|
||||
virtual void AddSubproject( wxsProject& intoPrj,const string& projectFile ) = 0;
|
||||
virtual void RemoveSubproject( wxsProject& prj ) = 0;
|
||||
|
||||
virtual void AddFilesToProject( wxsProject& prj, StrListT& files ) = 0;
|
||||
virtual void RemoveFilesFromProject( wxsProject& prj, StrListT& files ) = 0;
|
||||
|
||||
virtual void NotifyFileContentChanged( wxsProject& prj, const string& file,
|
||||
char* newContent, size_t len ) = 0;
|
||||
|
||||
virtual void NotifyFileContentChanged( wxsOpenedFileInfo& info ) = 0;
|
||||
virtual void NotifyEditorDeactivated( wxsSourceEditorPlugin& editor ) = 0;
|
||||
|
||||
// if pPrj is NULL, the specified file does not belong to any projects,
|
||||
// i.e. it blongs to the workplace
|
||||
|
||||
virtual wxsOpenedFileInfo*
|
||||
OpenFileInEditor( const string& file, wxsProject* pPrj = NULL,
|
||||
int line = -1, int column = -1) = 0;
|
||||
|
||||
virtual void GetCurrentFileContent( wxsProject& prj, const string& file,
|
||||
char** buf, size_t& len
|
||||
) = 0;
|
||||
|
||||
// returns FALSE, if source was already up-to-date
|
||||
virtual bool SyncSourceInfo() = 0;
|
||||
|
||||
virtual wxsProject* FindSubproject( wxsProject& parentPrj, const string& prjName ) = 0;
|
||||
virtual wxsOpenedFileInfo* FindOpenedFile( const string& name ) = 0;
|
||||
virtual bool FileIsOpened( wxsProject& prj, const string& file ) = 0;
|
||||
virtual wxsSourceEditorPlugin* GetSourceEditor( wxsProject& prj, const string& file ) = 0;
|
||||
virtual wxsSourceInfoPlugin* GetSourceInfoPlugin() = 0;
|
||||
|
||||
static wxsWorkplace& GetInstance() { return *wxsWorkplace::mpInstance; }
|
||||
|
||||
virtual wxsOpenedFileInfoListT& GetOpenedFiles() = 0;
|
||||
virtual wxsOpenedFileInfo* GetActiveFile() = 0;
|
||||
|
||||
virtual void SaveFile( wxsOpenedFileInfo& info ) = 0;
|
||||
virtual void SaveAllFiles() = 0;
|
||||
|
||||
virtual bool CloseFile( wxsOpenedFileInfo& info, bool closeWindow = TRUE ) = 0;
|
||||
virtual bool CloseAllFiles() = 0;
|
||||
|
||||
virtual bool CloseInProgress() = 0;
|
||||
|
||||
virtual WXS_FILE_CATEGORY GetFileCategory( const string& file ) = 0;
|
||||
|
||||
protected:
|
||||
static wxsWorkplace* mpInstance;
|
||||
friend wxsWorkplace& wxsGetWorkplace();
|
||||
};
|
||||
|
||||
// short-cut for wxsWorkplace::GetInstance()
|
||||
|
||||
wxsWorkplace& wxsGetWorkplace();
|
||||
|
||||
#endif
|
659
utils/wxPython/modules/lseditor/wxstlac.h
Normal file
659
utils/wxPython/modules/lseditor/wxstlac.h
Normal file
@ -0,0 +1,659 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: No names yet.
|
||||
// Purpose: Contrib. demo
|
||||
// Author: Aleksandras Gluchovas
|
||||
// Modified by:
|
||||
// Created: 27/09/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Aleskandars Gluchovas
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __WXSTLAC_G__
|
||||
#define __WXSTLAC_G__
|
||||
|
||||
#include <stddef.h>
|
||||
#include <sys/types.h>
|
||||
#include <memory.h>
|
||||
#include <limits.h>
|
||||
#include <new>
|
||||
|
||||
|
||||
// the below macro used internally (see actual interface after this macro)
|
||||
|
||||
// arguments:
|
||||
//
|
||||
// ARG_IS_UNIQUE
|
||||
// ASSOC_CONT_CLASS_NAME
|
||||
//
|
||||
// ARG_VALUE_TYPE
|
||||
// ARG_KEY_TYPE
|
||||
// ARG_ACTUAL_VALUE_TYPE
|
||||
//
|
||||
// _KEY_NAME
|
||||
// _VALUE_NAME
|
||||
//
|
||||
// _X_KEY_NAME
|
||||
// _X_VALUE_NAME
|
||||
//
|
||||
// _INSERT_METHOD_DEFINITION
|
||||
|
||||
#define __DEFINE_ASOC_CLASS( ARG_IS_UNIQUE, \
|
||||
FUNCTOR,\
|
||||
ASSOC_CONT_CLASS_NAME, \
|
||||
ARG_VALUE_TYPE, \
|
||||
ARG_KEY_TYPE, \
|
||||
ARG_ACTUAL_VALUE_TYPE, \
|
||||
_KEY_NAME, \
|
||||
_VALUE_NAME, \
|
||||
_X_KEY_NAME, \
|
||||
_X_VALUE_NAME, \
|
||||
_INSERT_METHOD_DEFINITION \
|
||||
) class \
|
||||
ASSOC_CONT_CLASS_NAME\
|
||||
{\
|
||||
protected:\
|
||||
\
|
||||
public:\
|
||||
typedef ARG_VALUE_TYPE value_type;\
|
||||
typedef ARG_KEY_TYPE key_type;\
|
||||
typedef ARG_ACTUAL_VALUE_TYPE actual_value_type;\
|
||||
\
|
||||
typedef value_type* pointer;\
|
||||
typedef value_type& reference;\
|
||||
\
|
||||
typedef const value_type& const_reference;\
|
||||
\
|
||||
typedef FUNCTOR key_compare;\
|
||||
typedef key_compare Compare;\
|
||||
\
|
||||
protected:\
|
||||
\
|
||||
struct tree_node \
|
||||
{\
|
||||
tree_node* mpParent;\
|
||||
tree_node* mpLeft;\
|
||||
tree_node* mpRight;\
|
||||
\
|
||||
value_type mData;\
|
||||
};\
|
||||
\
|
||||
typedef tree_node* node_ref_type;\
|
||||
\
|
||||
node_ref_type mpRoot;\
|
||||
node_ref_type mpLeftMost;\
|
||||
node_ref_type mpRightMost;\
|
||||
\
|
||||
node_ref_type mpFreeListHead;\
|
||||
int mKeyIsUnique;\
|
||||
\
|
||||
key_compare mCmpFunctorObj;\
|
||||
\
|
||||
public:\
|
||||
\
|
||||
static inline node_ref_type next( node_ref_type pNode )\
|
||||
{\
|
||||
if ( pNode->mpRight ) \
|
||||
{\
|
||||
pNode = pNode->mpRight;\
|
||||
\
|
||||
while ( pNode->mpLeft ) pNode = pNode->mpLeft;\
|
||||
\
|
||||
return pNode;\
|
||||
}\
|
||||
else\
|
||||
if ( pNode->mpParent )\
|
||||
{\
|
||||
if ( pNode == pNode->mpParent->mpLeft )\
|
||||
\
|
||||
return pNode->mpParent;\
|
||||
\
|
||||
pNode = pNode->mpParent;\
|
||||
\
|
||||
node_ref_type prevNode = pNode;\
|
||||
pNode = pNode->mpParent;\
|
||||
\
|
||||
while(pNode)\
|
||||
{\
|
||||
if ( pNode->mpRight &&\
|
||||
pNode->mpRight != prevNode\
|
||||
) return pNode;\
|
||||
\
|
||||
prevNode = pNode;\
|
||||
pNode= pNode->mpParent;\
|
||||
}\
|
||||
\
|
||||
return 0;\
|
||||
}\
|
||||
else\
|
||||
return 0;\
|
||||
}\
|
||||
\
|
||||
static inline node_ref_type prev( node_ref_type pNode )\
|
||||
{\
|
||||
if ( pNode->mpLeft ) \
|
||||
{\
|
||||
pNode = pNode->mpLeft;\
|
||||
\
|
||||
while ( pNode->mpRight ) pNode = pNode->mpRight;\
|
||||
\
|
||||
return pNode;\
|
||||
}\
|
||||
else\
|
||||
if ( pNode->mpParent )\
|
||||
{\
|
||||
if ( pNode == pNode->mpParent->mpRight )\
|
||||
return pNode->mpParent;\
|
||||
\
|
||||
pNode = pNode->mpParent;\
|
||||
\
|
||||
node_ref_type prevNode = pNode;\
|
||||
pNode = pNode->mpParent;\
|
||||
\
|
||||
while(pNode)\
|
||||
{\
|
||||
if ( pNode->mpLeft &&\
|
||||
pNode->mpLeft != prevNode\
|
||||
) return pNode;\
|
||||
\
|
||||
prevNode = pNode;\
|
||||
pNode= pNode->mpParent;\
|
||||
}\
|
||||
\
|
||||
return 0;\
|
||||
}\
|
||||
else \
|
||||
return 0;\
|
||||
}\
|
||||
\
|
||||
protected:\
|
||||
\
|
||||
inline int are_equel( const key_type& x, const key_type& y ) const\
|
||||
{\
|
||||
mCmpFunctorObj(x,y);\
|
||||
return ( !mCmpFunctorObj(x,y) && !mCmpFunctorObj(y,x) );\
|
||||
}\
|
||||
\
|
||||
inline int is_less( const key_type& x, const key_type& y ) const\
|
||||
{\
|
||||
return mCmpFunctorObj(x,y);\
|
||||
}\
|
||||
\
|
||||
static inline const actual_value_type& value( node_ref_type pNode )\
|
||||
{\
|
||||
return pNode->_VALUE_NAME;\
|
||||
}\
|
||||
\
|
||||
static inline const key_type& key( node_ref_type pNode )\
|
||||
{\
|
||||
return pNode->_KEY_NAME;\
|
||||
}\
|
||||
\
|
||||
inline node_ref_type AllocNode() \
|
||||
{ \
|
||||
if ( mpFreeListHead ) \
|
||||
{\
|
||||
node_ref_type pFreeNode = mpFreeListHead;\
|
||||
mpFreeListHead = mpFreeListHead->mpLeft;\
|
||||
\
|
||||
return pFreeNode;\
|
||||
}\
|
||||
else\
|
||||
{\
|
||||
char* pHeapBlock = new char[sizeof(tree_node)];\
|
||||
\
|
||||
return (node_ref_type)pHeapBlock;\
|
||||
}\
|
||||
}\
|
||||
\
|
||||
inline void DestroyFreeList()\
|
||||
{\
|
||||
while ( mpFreeListHead )\
|
||||
{\
|
||||
node_ref_type tmp = mpFreeListHead;\
|
||||
mpFreeListHead = mpFreeListHead->mpLeft;\
|
||||
\
|
||||
delete [](char*)tmp;\
|
||||
}\
|
||||
}\
|
||||
\
|
||||
inline void RecycleNode( node_ref_type pNode ) \
|
||||
{\
|
||||
pNode->mpLeft = mpFreeListHead;\
|
||||
mpFreeListHead = pNode;\
|
||||
}\
|
||||
\
|
||||
inline node_ref_type do_insert(const value_type& x = value_type() )\
|
||||
{\
|
||||
node_ref_type pNewNode = AllocNode();\
|
||||
\
|
||||
pNewNode->mpParent = \
|
||||
pNewNode->mpLeft =\
|
||||
pNewNode->mpRight = 0;\
|
||||
\
|
||||
node_ref_type pCurrent = mpRoot;\
|
||||
node_ref_type pParent = 0;\
|
||||
\
|
||||
while (pCurrent) \
|
||||
{\
|
||||
if ( mKeyIsUnique && are_equel( _X_KEY_NAME, key(pCurrent) ) )\
|
||||
{\
|
||||
RecycleNode(pNewNode);\
|
||||
return 0;\
|
||||
}\
|
||||
\
|
||||
pParent = pCurrent;\
|
||||
\
|
||||
pCurrent = is_less( _X_KEY_NAME, key(pCurrent) ) \
|
||||
? pCurrent->mpLeft \
|
||||
: pCurrent->mpRight;\
|
||||
}\
|
||||
\
|
||||
pNewNode->mpParent = pParent;\
|
||||
\
|
||||
if(pParent)\
|
||||
\
|
||||
if( is_less(_X_KEY_NAME, key(pParent) ) )\
|
||||
\
|
||||
pParent->mpLeft = pNewNode;\
|
||||
else\
|
||||
pParent->mpRight = pNewNode;\
|
||||
else\
|
||||
mpRoot = pNewNode;\
|
||||
\
|
||||
new ( &pNewNode->_KEY_NAME ) key_type(_X_KEY_NAME);\
|
||||
new ( &pNewNode->_VALUE_NAME ) actual_value_type(_X_VALUE_NAME);\
|
||||
\
|
||||
if ( prev(pNewNode) == 0 ) mpLeftMost = pNewNode;\
|
||||
if ( next(pNewNode) == 0 ) mpRightMost = pNewNode;\
|
||||
\
|
||||
return pNewNode;\
|
||||
}\
|
||||
\
|
||||
friend class iterator;\
|
||||
\
|
||||
public:\
|
||||
\
|
||||
class iterator;\
|
||||
class const_iterator;\
|
||||
\
|
||||
class iterator \
|
||||
{\
|
||||
public:\
|
||||
node_ref_type mpNode;\
|
||||
friend class CONT_CLASS_NAME;\
|
||||
friend class const_iterator;\
|
||||
friend class const_reverse_iterator;\
|
||||
\
|
||||
inline iterator( node_ref_type pNode )\
|
||||
{\
|
||||
mpNode = pNode;\
|
||||
}\
|
||||
\
|
||||
public:\
|
||||
inline iterator() {}\
|
||||
inline int operator==( const iterator& rhs ) const { return (mpNode == rhs.mpNode); }\
|
||||
inline int operator!=( const iterator& rhs ) const { return (mpNode != rhs.mpNode); }\
|
||||
\
|
||||
inline iterator( const iterator& other )\
|
||||
{\
|
||||
mpNode = other.mpNode;\
|
||||
}\
|
||||
\
|
||||
inline const iterator& operator=( const iterator& other )\
|
||||
{\
|
||||
mpNode = other.mpNode;\
|
||||
return *this;\
|
||||
}\
|
||||
\
|
||||
inline const iterator& operator--() \
|
||||
{\
|
||||
mpNode = ASSOC_CONT_CLASS_NAME::prev(mpNode);\
|
||||
return *this;\
|
||||
}\
|
||||
\
|
||||
inline iterator operator--(int)\
|
||||
{\
|
||||
iterator tmp = *this;\
|
||||
mpNode = ASSOC_CONT_CLASS_NAME::prev(mpNode);\
|
||||
return tmp;\
|
||||
}\
|
||||
\
|
||||
inline const iterator& operator++() \
|
||||
{\
|
||||
mpNode = ASSOC_CONT_CLASS_NAME::next(mpNode);\
|
||||
return *this;\
|
||||
}\
|
||||
\
|
||||
inline iterator operator++(int)\
|
||||
{\
|
||||
iterator tmp = *this;\
|
||||
mpNode = ASSOC_CONT_CLASS_NAME::next(mpNode);\
|
||||
return tmp;\
|
||||
}\
|
||||
\
|
||||
inline reference operator*() const { return mpNode->mData; }\
|
||||
};\
|
||||
\
|
||||
\
|
||||
class const_iterator \
|
||||
{\
|
||||
public:\
|
||||
node_ref_type mpNode;\
|
||||
friend class CONT_CLASS_NAME;\
|
||||
friend class const_reverse_iterator;\
|
||||
\
|
||||
inline const_iterator( node_ref_type pNode )\
|
||||
{\
|
||||
mpNode = pNode;\
|
||||
}\
|
||||
\
|
||||
public:\
|
||||
inline const_iterator() {}\
|
||||
\
|
||||
inline int operator==( const const_iterator& rhs ) const { return (mpNode == rhs.mpNode); }\
|
||||
inline int operator!=( const const_iterator& rhs ) const { return (mpNode != rhs.mpNode); }\
|
||||
\
|
||||
inline const_iterator( const iterator& other )\
|
||||
{\
|
||||
mpNode = other.mpNode;\
|
||||
}\
|
||||
\
|
||||
inline const_iterator( const const_iterator& other )\
|
||||
{\
|
||||
mpNode = other.mpNode;\
|
||||
}\
|
||||
\
|
||||
inline const const_iterator& operator=( const const_iterator& other )\
|
||||
{\
|
||||
mpNode = other.mpNode;\
|
||||
return *this;\
|
||||
}\
|
||||
\
|
||||
inline const const_iterator& operator--() \
|
||||
{\
|
||||
mpNode = ASSOC_CONT_CLASS_NAME::prev(mpNode);\
|
||||
return *this;\
|
||||
}\
|
||||
\
|
||||
inline const_iterator operator--(int)\
|
||||
{\
|
||||
const_iterator tmp = *this;\
|
||||
mpNode = ASSOC_CONT_CLASS_NAME::prev(mpNode);\
|
||||
return tmp;\
|
||||
}\
|
||||
\
|
||||
inline const const_iterator& operator++() \
|
||||
{\
|
||||
mpNode = ASSOC_CONT_CLASS_NAME::next(mpNode);\
|
||||
return *this;\
|
||||
}\
|
||||
\
|
||||
inline const_iterator operator++(int)\
|
||||
{\
|
||||
const_iterator tmp = *this;\
|
||||
mpNode = ASSOC_CONT_CLASS_NAME::next(mpNode);\
|
||||
return tmp;\
|
||||
}\
|
||||
\
|
||||
inline const_reference operator*() const { return mpNode->mData; }\
|
||||
};\
|
||||
\
|
||||
public:\
|
||||
\
|
||||
inline ASSOC_CONT_CLASS_NAME( key_compare cmpFunctorObj = key_compare(),\
|
||||
int keyIsUnique = ARG_IS_UNIQUE )\
|
||||
: mpFreeListHead( 0 ),\
|
||||
mKeyIsUnique( keyIsUnique ),\
|
||||
mCmpFunctorObj( cmpFunctorObj )\
|
||||
{\
|
||||
mpLeftMost = 0;\
|
||||
mpRightMost = 0;\
|
||||
mpRoot = 0;\
|
||||
}\
|
||||
\
|
||||
inline ~ASSOC_CONT_CLASS_NAME() \
|
||||
{ \
|
||||
erase( begin(), end() ); \
|
||||
\
|
||||
DestroyFreeList();\
|
||||
}\
|
||||
\
|
||||
inline iterator begin() { return mpLeftMost; }\
|
||||
inline iterator end() { return 0; }\
|
||||
\
|
||||
inline const_iterator begin() const { return mpLeftMost; }\
|
||||
inline const_iterator end() const { return 0; }\
|
||||
\
|
||||
inline iterator lower_bound( const key_type& x )\
|
||||
{ \
|
||||
node_ref_type pCurrent = mpRoot;\
|
||||
\
|
||||
while( pCurrent )\
|
||||
{\
|
||||
node_ref_type pParent = pCurrent;\
|
||||
\
|
||||
if( are_equel( x, key(pCurrent) ) )\
|
||||
\
|
||||
return (pCurrent);\
|
||||
else\
|
||||
pCurrent = is_less( x, key(pCurrent) ) \
|
||||
? pCurrent->mpLeft \
|
||||
: pCurrent->mpRight;\
|
||||
\
|
||||
if ( !pCurrent ) return (pParent);\
|
||||
}\
|
||||
\
|
||||
return begin();\
|
||||
}\
|
||||
\
|
||||
inline const_iterator lower_bound( const key_type& x ) const\
|
||||
\
|
||||
{ return const_iterator( lower_bound(x).mpNode ); }\
|
||||
\
|
||||
inline iterator upper_bound( const key_type& x )\
|
||||
{\
|
||||
node_ref_type pCurrent = mpRoot;\
|
||||
\
|
||||
while( pCurrent )\
|
||||
{\
|
||||
node_ref_type pParent = pCurrent;\
|
||||
\
|
||||
if( are_equel( x, key(pCurrent) ) )\
|
||||
\
|
||||
return (pCurrent);\
|
||||
else\
|
||||
pCurrent = is_less( x, key(pCurrent) ) \
|
||||
? pCurrent->mpLeft \
|
||||
: pCurrent->mpRight;\
|
||||
\
|
||||
if ( !pCurrent ) return next(pParent);\
|
||||
}\
|
||||
\
|
||||
return end();\
|
||||
}\
|
||||
\
|
||||
inline iterator find( const key_type& x ) const\
|
||||
{\
|
||||
node_ref_type pCurrent = mpRoot;\
|
||||
\
|
||||
while( pCurrent )\
|
||||
{\
|
||||
if( are_equel( x, key(pCurrent) ) )\
|
||||
\
|
||||
return (pCurrent);\
|
||||
else\
|
||||
pCurrent = is_less( x, key(pCurrent) ) \
|
||||
? pCurrent->mpLeft \
|
||||
: pCurrent->mpRight;\
|
||||
}\
|
||||
\
|
||||
return iterator(0);\
|
||||
}\
|
||||
\
|
||||
inline actual_value_type& operator[]( const key_type x ) const\
|
||||
\
|
||||
{ return find(x).mpNode->_VALUE_NAME; }\
|
||||
\
|
||||
inline void erase(iterator first, iterator last)\
|
||||
{\
|
||||
if ( first.mpNode == 0 ) return;\
|
||||
\
|
||||
while( first != last ) \
|
||||
{\
|
||||
iterator next = first;\
|
||||
++next;\
|
||||
erase( first );\
|
||||
first = next;\
|
||||
}\
|
||||
}\
|
||||
\
|
||||
inline void erase(iterator position)\
|
||||
{\
|
||||
if ( position.mpNode == 0 ) return;\
|
||||
\
|
||||
node_ref_type pZ = position.mpNode;\
|
||||
node_ref_type pX, pY;\
|
||||
\
|
||||
if ( pZ == mpLeftMost ) mpLeftMost = next(pZ);\
|
||||
if ( pZ == mpRightMost ) mpRightMost = prev( pZ );\
|
||||
\
|
||||
if ( !pZ->mpLeft || !pZ->mpRight )\
|
||||
\
|
||||
pY = pZ;\
|
||||
else \
|
||||
{\
|
||||
pY = pZ->mpRight;\
|
||||
\
|
||||
while (pY->mpLeft) \
|
||||
\
|
||||
pY = pY->mpLeft;\
|
||||
}\
|
||||
\
|
||||
if ( pY->mpLeft)\
|
||||
\
|
||||
pX = pY->mpLeft;\
|
||||
else\
|
||||
pX = pY->mpRight;\
|
||||
\
|
||||
if ( pX ) pX->mpParent = pY->mpParent;\
|
||||
\
|
||||
if (pY->mpParent)\
|
||||
\
|
||||
if (pY == pY->mpParent->mpLeft )\
|
||||
\
|
||||
pY->mpParent->mpLeft = pX;\
|
||||
else\
|
||||
pY->mpParent->mpRight = pX;\
|
||||
else\
|
||||
mpRoot = pX;\
|
||||
\
|
||||
node_ref_type toRemove = 0;\
|
||||
\
|
||||
if (pY != pZ) {\
|
||||
\
|
||||
pY->mpLeft = pZ->mpLeft;\
|
||||
\
|
||||
if (pY->mpLeft) pY->mpLeft->mpParent = pY;\
|
||||
\
|
||||
pY->mpRight = pZ->mpRight;\
|
||||
\
|
||||
if ( pY->mpRight ) \
|
||||
\
|
||||
pY->mpRight->mpParent = pY;\
|
||||
\
|
||||
pY->mpParent = pZ->mpParent;\
|
||||
\
|
||||
if (pZ->mpParent)\
|
||||
\
|
||||
if (pZ == pZ->mpParent->mpLeft)\
|
||||
\
|
||||
pZ->mpParent->mpLeft = pY;\
|
||||
else\
|
||||
pZ->mpParent->mpRight = pY;\
|
||||
else\
|
||||
mpRoot = pY;\
|
||||
\
|
||||
toRemove = pZ;\
|
||||
} \
|
||||
else \
|
||||
toRemove = pY;\
|
||||
\
|
||||
\
|
||||
RecycleNode( toRemove );\
|
||||
}\
|
||||
\
|
||||
_INSERT_METHOD_DEFINITION\
|
||||
}
|
||||
|
||||
// do not undefine ___WXSTL_COMMA, where associated containers are defined!
|
||||
// (it is used as workaround for constraints of C-Preprocessor's nested macros)
|
||||
|
||||
#define ___WXSTL_COMMA ,
|
||||
|
||||
#define __DEFINE_MAP(ARG_IS_UNIQUE, KEY_TYPE, VAL_TYPE, FUNCTOR ) __DEFINE_ASOC_CLASS( ARG_IS_UNIQUE,\
|
||||
FUNCTOR,\
|
||||
__WXSTLMAP_##KEY_TYPE##VAL_TYPE##ARG_IS_UNIQUE, \
|
||||
struct key_value_pair { KEY_TYPE first ; \
|
||||
VAL_TYPE second;\
|
||||
key_value_pair() {}\
|
||||
key_value_pair( const KEY_TYPE& key ___WXSTL_COMMA const VAL_TYPE& value ) \
|
||||
: first(key) ___WXSTL_COMMA second( value ) {} \
|
||||
} , \
|
||||
KEY_TYPE,\
|
||||
VAL_TYPE,\
|
||||
mData.first, mData.second, x.first, x.second, \
|
||||
struct insert_result_iterator\
|
||||
{\
|
||||
iterator first;\
|
||||
int second;\
|
||||
};\
|
||||
inline insert_result_iterator insert( const value_type& x )\
|
||||
{\
|
||||
insert_result_iterator result;\
|
||||
\
|
||||
result.first = do_insert(x);\
|
||||
result.second = ( result.first == end() ) ? 0 : 1;\
|
||||
\
|
||||
return result;\
|
||||
} )
|
||||
|
||||
#define __DEFINE_SET(ARG_IS_UNIQUE, KEY_TYPE, FUNCTOR ) __DEFINE_ASOC_CLASS( ARG_IS_UNIQUE,\
|
||||
FUNCTOR,\
|
||||
__WXSTLSET_##TYPE##ARG_IS_UNIQUE, \
|
||||
KEY_TYPE,\
|
||||
KEY_TYPE,\
|
||||
KEY_TYPE,\
|
||||
mData, mData, x, x, \
|
||||
struct insert_result_iterator\
|
||||
{\
|
||||
iterator first;\
|
||||
int second;\
|
||||
};\
|
||||
inline insert_result_iterator insert( const value_type& x )\
|
||||
{\
|
||||
insert_result_iterator result;\
|
||||
\
|
||||
result.first = do_insert(x);\
|
||||
result.second = ( result.first == end() ) ? 0 : 1;\
|
||||
\
|
||||
return result;\
|
||||
} )
|
||||
|
||||
// helper macros to create functor objects for associative containers of the given type
|
||||
|
||||
#define LESS_THEN_FUNCTOR(TYPE) struct \
|
||||
{ inline int operator()(const TYPE& x, const TYPE& y ) const { return x < y; } }
|
||||
|
||||
#define GREATER_THEN_FUNCTOR(TYPE) struct \
|
||||
{ inline int operator()(const TYPE& x, const TYPE& y ) const { return x > y; } }
|
||||
|
||||
// functor argument should be created using the two above macros
|
||||
// or passing own class with method "operator()(const TYPE&,cosnt TYPE&)" defined in it
|
||||
|
||||
#define WXSTL_MAP( KEY_TYPE, VALUE_TYPE, FUNCTOR ) __DEFINE_MAP( 1 ,KEY_TYPE, VALUE_TYPE, FUNCTOR)
|
||||
#define WXSTL_MULTIMAP( KEY_TYPE, VALUE_TYPE, FUNCTOR ) __DEFINE_MAP( 0 ,KEY_TYPE, VALUE_TYPE, FUNCTOR)
|
||||
#define WXSTL_SET( KEY_TYPE, FUNCTOR ) __DEFINE_SET( 1 ,KEY_TYPE, FUNCTOR )
|
||||
#define WXSTL_MULTISET( KEY_TYPE, FUNCTOR ) __DEFINE_SET( 0 ,KEY_TYPE, FUNCTOR )
|
||||
|
||||
#endif
|
49
utils/wxPython/modules/lseditor/wxstldefs.h
Normal file
49
utils/wxPython/modules/lseditor/wxstldefs.h
Normal file
@ -0,0 +1,49 @@
|
||||
#ifndef __WXSTLDEFS_G__
|
||||
#define __WXSTLDEFS_G__
|
||||
|
||||
|
||||
#include "config.h"
|
||||
|
||||
// defines some very commonly used container types
|
||||
// for both template and macro-based configurations
|
||||
|
||||
#if defined( wxUSE_TEMPLATE_STL )
|
||||
|
||||
#include <vector>
|
||||
using namespace std;
|
||||
#ifdef WIN32xxx
|
||||
#include <bstring.h>
|
||||
#else
|
||||
|
||||
//#include <strclass.h>
|
||||
//#include <string.h>
|
||||
// For now
|
||||
#include "wx/string.h"
|
||||
#define string wxString
|
||||
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#include "wx/string.h"
|
||||
#include "wxstlvec.h"
|
||||
|
||||
// FOR NOW:: quick n' dirty:
|
||||
|
||||
#define string wxString
|
||||
|
||||
#endif
|
||||
|
||||
#if defined( wxUSE_TEMPLATE_STL )
|
||||
|
||||
typedef vector<string> StrListT;
|
||||
typedef vector<int> IntListT;
|
||||
|
||||
#else
|
||||
|
||||
typedef WXSTL_VECTOR(string) StrListT;
|
||||
typedef WXSTL_VECTOR_SHALLOW_COPY(int) IntListT;
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
555
utils/wxPython/modules/lseditor/wxstllst.h
Normal file
555
utils/wxPython/modules/lseditor/wxstllst.h
Normal file
@ -0,0 +1,555 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: No names yet.
|
||||
// Purpose: Contrib. demo
|
||||
// Author: Aleksandras Gluchovas
|
||||
// Modified by:
|
||||
// Created: 27/09/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Aleskandars Gluchovas
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __WXSTLLST_G__
|
||||
#define __WXSTLLST_G__
|
||||
|
||||
#include <stddef.h>
|
||||
#include <sys/types.h>
|
||||
#include <memory.h>
|
||||
#include <limits.h>
|
||||
#include <new>
|
||||
|
||||
// VERSION:: 0.2 (copy-constructor/adign-op added)
|
||||
|
||||
// FOR NOW:: class-member operators "new" and "delete"
|
||||
// are ignored by list class, memory allocated
|
||||
// and freed using global operators
|
||||
|
||||
typedef int Type;
|
||||
|
||||
|
||||
// the below macro used internally (see actual interface after this macro)
|
||||
|
||||
#define __DEFINE_STL_LIST(listClass,Type) class \
|
||||
listClass \
|
||||
{\
|
||||
public:\
|
||||
\
|
||||
typedef Type value_type;\
|
||||
typedef value_type* pointer;\
|
||||
typedef const value_type* const_pointer;\
|
||||
typedef value_type& reference;\
|
||||
typedef const value_type& const_reference;\
|
||||
typedef size_t size_type;\
|
||||
typedef ptrdiff_t difference_type;\
|
||||
\
|
||||
protected:\
|
||||
struct list_node\
|
||||
{\
|
||||
list_node* mpNext;\
|
||||
list_node* mpPrev;\
|
||||
value_type mData;\
|
||||
};\
|
||||
\
|
||||
typedef list_node* node_ref_type;\
|
||||
\
|
||||
node_ref_type mpFreeListHead;\
|
||||
node_ref_type mpTerminator;\
|
||||
size_type mSize;\
|
||||
\
|
||||
inline node_ref_type AllocNode() \
|
||||
{ \
|
||||
if ( mpFreeListHead ) \
|
||||
{\
|
||||
node_ref_type pFreeNode = mpFreeListHead;\
|
||||
mpFreeListHead = mpFreeListHead->mpPrev;\
|
||||
\
|
||||
return pFreeNode;\
|
||||
}\
|
||||
else\
|
||||
{\
|
||||
char* pHeapBlock = new char[sizeof(list_node)];\
|
||||
\
|
||||
return (node_ref_type)pHeapBlock;\
|
||||
}\
|
||||
}\
|
||||
\
|
||||
inline void DestroyFreeList()\
|
||||
{\
|
||||
while ( mpFreeListHead )\
|
||||
{\
|
||||
node_ref_type tmp = mpFreeListHead;\
|
||||
mpFreeListHead = mpFreeListHead->mpPrev;\
|
||||
\
|
||||
delete [](char*)tmp;\
|
||||
}\
|
||||
}\
|
||||
\
|
||||
inline void RecycleNode( node_ref_type pNode ) \
|
||||
{\
|
||||
pNode->mpPrev = mpFreeListHead;\
|
||||
mpFreeListHead = pNode;\
|
||||
}\
|
||||
\
|
||||
public:\
|
||||
\
|
||||
class iterator \
|
||||
{\
|
||||
public:\
|
||||
node_ref_type mpNode;\
|
||||
friend class listClass;\
|
||||
friend class const_iterator;\
|
||||
friend class const_reverse_iterator;\
|
||||
\
|
||||
protected:\
|
||||
iterator( node_ref_type pNode )\
|
||||
{\
|
||||
mpNode = pNode;\
|
||||
}\
|
||||
\
|
||||
public:\
|
||||
iterator() {}\
|
||||
int operator==( const iterator& rhs ) const { return (mpNode == rhs.mpNode); }\
|
||||
int operator!=( const iterator& rhs ) const { return (mpNode != rhs.mpNode); }\
|
||||
\
|
||||
inline iterator( const iterator& other )\
|
||||
{\
|
||||
mpNode = other.mpNode;\
|
||||
}\
|
||||
\
|
||||
inline const iterator& operator--() \
|
||||
{\
|
||||
mpNode = mpNode->mpPrev;\
|
||||
return *this;\
|
||||
}\
|
||||
\
|
||||
inline iterator operator--(int)\
|
||||
{\
|
||||
iterator tmp = *this;\
|
||||
mpNode = mpNode->mpPrev;\
|
||||
return tmp;\
|
||||
}\
|
||||
\
|
||||
inline const iterator& operator++() \
|
||||
{\
|
||||
mpNode = mpNode->mpNext;\
|
||||
return *this;\
|
||||
}\
|
||||
\
|
||||
inline iterator operator++(int)\
|
||||
{\
|
||||
iterator tmp = *this;\
|
||||
mpNode = mpNode->mpNext;\
|
||||
return tmp;\
|
||||
}\
|
||||
\
|
||||
inline reference operator*() const { return mpNode->mData; }\
|
||||
};\
|
||||
\
|
||||
\
|
||||
class const_iterator \
|
||||
{\
|
||||
protected:\
|
||||
node_ref_type mpNode;\
|
||||
friend class listClass;\
|
||||
\
|
||||
protected:\
|
||||
const_iterator( node_ref_type pNode )\
|
||||
{\
|
||||
mpNode = pNode;\
|
||||
}\
|
||||
\
|
||||
public:\
|
||||
\
|
||||
const_iterator() {}\
|
||||
int operator==( const const_iterator& rhs ) const { return (mpNode == rhs.mpNode); }\
|
||||
int operator!=( const const_iterator& rhs ) const { return (mpNode != rhs.mpNode); }\
|
||||
\
|
||||
\
|
||||
inline const_iterator( const iterator& other )\
|
||||
{\
|
||||
mpNode = other.mpNode;\
|
||||
}\
|
||||
\
|
||||
inline const const_iterator& operator--() \
|
||||
{\
|
||||
mpNode = mpNode->mpPrev;\
|
||||
return *this;\
|
||||
}\
|
||||
\
|
||||
inline const_iterator operator--(int)\
|
||||
{\
|
||||
const_iterator tmp = *this;\
|
||||
mpNode = mpNode->mpPrev;\
|
||||
return tmp;\
|
||||
}\
|
||||
\
|
||||
inline const const_iterator& operator++() \
|
||||
{\
|
||||
mpNode = mpNode->mpNext;\
|
||||
return *this;\
|
||||
}\
|
||||
\
|
||||
inline const_iterator operator++(int)\
|
||||
{\
|
||||
const_iterator tmp = *this;\
|
||||
mpNode = mpNode->mpNext;\
|
||||
return tmp;\
|
||||
}\
|
||||
\
|
||||
inline const_reference operator*() const { return mpNode->mData; }\
|
||||
};\
|
||||
\
|
||||
typedef iterator OutputIterator;\
|
||||
typedef const_iterator InputIterator;\
|
||||
\
|
||||
class reverse_iterator \
|
||||
{\
|
||||
public:\
|
||||
node_ref_type mpNode;\
|
||||
friend class listClass;\
|
||||
friend class const_reverse_iterator;\
|
||||
\
|
||||
protected:\
|
||||
reverse_iterator ( node_ref_type pNode )\
|
||||
{\
|
||||
mpNode = pNode;\
|
||||
}\
|
||||
\
|
||||
public:\
|
||||
\
|
||||
reverse_iterator() {}\
|
||||
int operator==( const reverse_iterator& rhs ) const { return (mpNode == rhs.mpNode); }\
|
||||
int operator!=( const reverse_iterator& rhs ) const { return (mpNode != rhs.mpNode); }\
|
||||
\
|
||||
inline reverse_iterator( const reverse_iterator& other )\
|
||||
{\
|
||||
mpNode = other.mpNode;\
|
||||
}\
|
||||
\
|
||||
inline const reverse_iterator& operator--() \
|
||||
{\
|
||||
mpNode = mpNode->mpNext;\
|
||||
return *this;\
|
||||
}\
|
||||
\
|
||||
inline reverse_iterator operator--(int)\
|
||||
{\
|
||||
reverse_iterator tmp = *this;\
|
||||
mpNode = mpNode->mpPrev;\
|
||||
return tmp;\
|
||||
}\
|
||||
\
|
||||
inline const reverse_iterator & operator++() \
|
||||
{\
|
||||
mpNode = mpNode->mpNext;\
|
||||
return *this;\
|
||||
}\
|
||||
\
|
||||
inline reverse_iterator operator++(int)\
|
||||
{\
|
||||
reverse_iterator tmp = *this;\
|
||||
mpNode = mpNode->mpPrev;\
|
||||
return tmp;\
|
||||
}\
|
||||
\
|
||||
inline const_reference operator*() const { return mpNode->mData; }\
|
||||
};\
|
||||
\
|
||||
\
|
||||
class const_reverse_iterator \
|
||||
{\
|
||||
protected:\
|
||||
node_ref_type mpNode;\
|
||||
friend class listClass;\
|
||||
\
|
||||
protected:\
|
||||
const_reverse_iterator( node_ref_type pNode )\
|
||||
{\
|
||||
mpNode = pNode;\
|
||||
}\
|
||||
\
|
||||
public:\
|
||||
\
|
||||
const_reverse_iterator() {}\
|
||||
int operator==( const const_reverse_iterator& rhs ) const { return (mpNode == rhs.mpNode); }\
|
||||
int operator!=( const const_reverse_iterator& rhs ) const { return (mpNode != rhs.mpNode); }\
|
||||
\
|
||||
inline const_reverse_iterator( const reverse_iterator& other )\
|
||||
{\
|
||||
mpNode = other.mpNode;\
|
||||
}\
|
||||
\
|
||||
inline const const_reverse_iterator& operator--() \
|
||||
{\
|
||||
mpNode = mpNode->mpNext;\
|
||||
return *this;\
|
||||
}\
|
||||
\
|
||||
inline const_reverse_iterator operator--(int)\
|
||||
{\
|
||||
const_reverse_iterator tmp = *this;\
|
||||
mpNode = mpNode->mpNext;\
|
||||
return tmp;\
|
||||
}\
|
||||
\
|
||||
inline const const_reverse_iterator& operator++() \
|
||||
{\
|
||||
mpNode = mpNode->mpPrev;\
|
||||
return *this;\
|
||||
}\
|
||||
\
|
||||
inline const_reverse_iterator operator++(int)\
|
||||
{\
|
||||
const_reverse_iterator tmp = *this;\
|
||||
mpNode = mpNode->mpPrev;\
|
||||
return tmp;\
|
||||
}\
|
||||
\
|
||||
inline const_reference operator*() const { return mpNode->mData; }\
|
||||
};\
|
||||
\
|
||||
public:\
|
||||
\
|
||||
inline listClass()\
|
||||
: mpFreeListHead( 0 ),\
|
||||
mSize(0)\
|
||||
{\
|
||||
mpTerminator = AllocNode();\
|
||||
mpTerminator->mpPrev = mpTerminator->mpNext = mpTerminator;\
|
||||
}\
|
||||
\
|
||||
listClass( const listClass& other )\
|
||||
{\
|
||||
mpTerminator = AllocNode();\
|
||||
mpTerminator->mpPrev = mpTerminator->mpNext = mpTerminator;\
|
||||
\
|
||||
for( listClass::const_iterator i = other.begin(); i != other.end(); ++i )\
|
||||
\
|
||||
push_back( (*i) );\
|
||||
}\
|
||||
\
|
||||
inline const listClass& operator=( const listClass& rhs ) \
|
||||
{\
|
||||
erase( begin(), end() );\
|
||||
\
|
||||
for( listClass::const_iterator i = rhs.begin(); i != rhs.end(); ++i )\
|
||||
\
|
||||
push_back( (*i) );\
|
||||
\
|
||||
return *this;\
|
||||
}\
|
||||
\
|
||||
inline listClass(const_iterator first, const_iterator last)\
|
||||
: mpFreeListHead( 0 ),\
|
||||
mSize(0)\
|
||||
\
|
||||
{ while( first != last ) push_back( *first++ ); }\
|
||||
\
|
||||
inline listClass( size_type n, const value_type& value = value_type() )\
|
||||
\
|
||||
{ for( size_t i = 0; i != n; ++n ) push_back( value ); }\
|
||||
\
|
||||
inline ~listClass() \
|
||||
{ \
|
||||
erase( begin(), end() ); \
|
||||
\
|
||||
RecycleNode( mpTerminator );\
|
||||
DestroyFreeList();\
|
||||
}\
|
||||
\
|
||||
inline iterator begin() { return iterator(mpTerminator->mpNext); }\
|
||||
\
|
||||
inline const_iterator begin() const \
|
||||
{ return const_iterator(mpTerminator->mpNext); }\
|
||||
\
|
||||
inline iterator end() { return iterator(mpTerminator); }\
|
||||
\
|
||||
inline const_iterator end() const { return const_iterator(mpTerminator); }\
|
||||
\
|
||||
inline reverse_iterator rbegin() \
|
||||
{ return reverse_iterator(mpTerminator->mpPrev); }\
|
||||
\
|
||||
inline reverse_iterator rend() \
|
||||
{ return reverse_iterator(mpTerminator); }\
|
||||
\
|
||||
inline const_reverse_iterator rbegin() const\
|
||||
{ return const_reverse_iterator(mpTerminator->mpPrev); }\
|
||||
\
|
||||
inline const_reverse_iterator rend() const\
|
||||
{ return const_reverse_iterator(mpTerminator); }\
|
||||
\
|
||||
inline int empty() const { return (mSize == 0); }\
|
||||
\
|
||||
inline size_type size() const { return mSize; }\
|
||||
\
|
||||
inline size_type max_size() const { return UINT_MAX/sizeof(list_node); }\
|
||||
\
|
||||
inline reference front() { return mpTerminator->mData; }\
|
||||
\
|
||||
inline const_reference front() const { return mpTerminator->mData; }\
|
||||
\
|
||||
inline reference back() { return mpTerminator->mpPrev->mData; }\
|
||||
\
|
||||
inline const_reference back() const { return mpTerminator->mpPrev->mData; }\
|
||||
\
|
||||
inline void push_front(const value_type& x) { insert( begin(), x ); }\
|
||||
\
|
||||
inline void push_back(const value_type& x) { insert( end(), x ); }\
|
||||
\
|
||||
iterator insert(iterator position, const value_type& x = value_type())\
|
||||
{\
|
||||
node_ref_type pNew = AllocNode();\
|
||||
\
|
||||
node_ref_type pos = *((node_ref_type*)&position);\
|
||||
\
|
||||
pNew->mpNext = pos;\
|
||||
pNew->mpPrev = pos->mpPrev;\
|
||||
pos->mpPrev->mpNext = pNew;\
|
||||
pos->mpPrev = pNew;\
|
||||
\
|
||||
new (&pNew->mData) value_type(x);\
|
||||
\
|
||||
++mSize;\
|
||||
\
|
||||
return iterator(pNew);\
|
||||
}\
|
||||
\
|
||||
inline void insert(iterator position, const_iterator first, const_iterator last )\
|
||||
{\
|
||||
while( first != last ) insert( position, *first++ );\
|
||||
}\
|
||||
\
|
||||
inline void splice( iterator position, listClass& other )\
|
||||
{\
|
||||
if ( other.begin() == other.end() ) return;\
|
||||
\
|
||||
node_ref_type pTill = other.mpTerminator->mpPrev;\
|
||||
node_ref_type pFrom = other.begin().mpNode;\
|
||||
\
|
||||
mpTerminator->mpPrev->mpNext = pFrom;\
|
||||
pFrom->mpPrev = mpTerminator->mpPrev->mpNext;\
|
||||
\
|
||||
pTill->mpNext = mpTerminator;\
|
||||
mpTerminator->mpPrev = pTill;\
|
||||
\
|
||||
other.mpTerminator->mpNext = \
|
||||
other.mpTerminator->mpPrev = other.mpTerminator;\
|
||||
\
|
||||
mSize += other.mSize;\
|
||||
other.mSize = 0;\
|
||||
}\
|
||||
\
|
||||
inline void splice( iterator position, listClass& other, iterator first, iterator last )\
|
||||
{\
|
||||
if ( first == last ) return;\
|
||||
\
|
||||
size_type sz = 0;\
|
||||
iterator tmp = first;\
|
||||
while( tmp != last ) \
|
||||
{\
|
||||
++tmp;\
|
||||
++sz;\
|
||||
}\
|
||||
\
|
||||
mSize += sz;\
|
||||
other.mSize -= sz;\
|
||||
\
|
||||
node_ref_type pPos = position.mpNode;\
|
||||
node_ref_type pFirst = first.mpNode;\
|
||||
node_ref_type pLast = last.mpNode;\
|
||||
node_ref_type pTill = last.mpNode->mpPrev;\
|
||||
\
|
||||
pPos->mpPrev->mpNext = pFirst;\
|
||||
pPos->mpPrev = pTill;\
|
||||
\
|
||||
pFirst->mpPrev->mpNext = last.mpNode;\
|
||||
pLast->mpPrev = pTill;\
|
||||
\
|
||||
pFirst->mpPrev = pPos->mpPrev;\
|
||||
pTill->mpNext = pPos;\
|
||||
}\
|
||||
\
|
||||
inline void pop_front() { erase( begin() ); }\
|
||||
inline void pop_back() { erase( --end() ); }\
|
||||
\
|
||||
inline void erase(iterator position)\
|
||||
{\
|
||||
erase( position, ++position );\
|
||||
}\
|
||||
\
|
||||
inline void erase(iterator first, iterator last)\
|
||||
{\
|
||||
node_ref_type firstNode = *((node_ref_type*)&first);\
|
||||
node_ref_type lastNode = *((node_ref_type*)&last);\
|
||||
\
|
||||
firstNode->mpPrev->mpNext = lastNode;\
|
||||
lastNode->mpPrev = firstNode->mpPrev;\
|
||||
\
|
||||
while( firstNode != lastNode )\
|
||||
{\
|
||||
node_ref_type next = firstNode->mpNext;\
|
||||
\
|
||||
typedef value_type value_type_local;\
|
||||
firstNode->mData.value_type_local::~value_type_local();\
|
||||
\
|
||||
RecycleNode( firstNode );\
|
||||
\
|
||||
firstNode = next;\
|
||||
\
|
||||
--mSize;\
|
||||
}\
|
||||
}\
|
||||
\
|
||||
inline void remove(const value_type& value)\
|
||||
{\
|
||||
for( iterator i = begin(); i != end(); ++i )\
|
||||
\
|
||||
if ( (*i) == value ) \
|
||||
{\
|
||||
erase( i ); break;\
|
||||
}\
|
||||
}\
|
||||
\
|
||||
void sort()\
|
||||
{\
|
||||
if ( mSize < 2 ) return;\
|
||||
\
|
||||
iterator from = begin();\
|
||||
iterator other_end = end();\
|
||||
--other_end;\
|
||||
\
|
||||
for( size_type i = 0; i != mSize; ++i )\
|
||||
{\
|
||||
size_type nSwaps = 0;\
|
||||
\
|
||||
iterator next = begin();\
|
||||
++next;\
|
||||
\
|
||||
for( iterator j = begin(); j != other_end; ++j )\
|
||||
{\
|
||||
\
|
||||
if ( (*next) < (*j) )\
|
||||
{\
|
||||
value_type tmp = (*j);\
|
||||
(*j) = (*next);\
|
||||
(*next) = tmp;\
|
||||
\
|
||||
++nSwaps;\
|
||||
}\
|
||||
\
|
||||
++next;\
|
||||
}\
|
||||
\
|
||||
if ( !nSwaps) break;\
|
||||
\
|
||||
--other_end;\
|
||||
}\
|
||||
}\
|
||||
}
|
||||
|
||||
// defines list class with the given element type
|
||||
#define WXSTL_LIST(ELEMENT_CLASS) __DEFINE_STL_LIST(\
|
||||
\
|
||||
_WXSTL_LIST_##ELEMENT_CLASS, ELEMENT_CLASS )
|
||||
|
||||
#endif
|
857
utils/wxPython/modules/lseditor/wxstlvec.h
Normal file
857
utils/wxPython/modules/lseditor/wxstlvec.h
Normal file
@ -0,0 +1,857 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: No names yet.
|
||||
// Purpose: Contrib. demo
|
||||
// Author: Aleksandras Gluchovas
|
||||
// Modified by:
|
||||
// Created: 27/09/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Aleskandars Gluchovas
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __WXSTLVEC_G__
|
||||
#define __WXSTLVEC_G__
|
||||
|
||||
#include <memory.h>
|
||||
#include <string.h> // imports memmove()
|
||||
#include <stddef.h>
|
||||
#include <sys/types.h>
|
||||
#include <limits.h>
|
||||
#include <new>
|
||||
|
||||
// the below macro used internally (see actual interface after this macro)
|
||||
|
||||
#define __DEFINE_STL_VECTOR_DEEP( vectorClass, Type ) class vectorClass {\
|
||||
\
|
||||
public:\
|
||||
typedef Type value_type;\
|
||||
typedef value_type* iterator;\
|
||||
typedef const value_type* const_iterator;\
|
||||
typedef iterator pointer;\
|
||||
typedef const iterator const_pointer;\
|
||||
typedef value_type& reference;\
|
||||
typedef const value_type& const_reference;\
|
||||
typedef size_t size_type;\
|
||||
typedef ptrdiff_t difference_type;\
|
||||
\
|
||||
typedef iterator OutputIterator;\
|
||||
typedef const_iterator InputIterator;\
|
||||
\
|
||||
protected:\
|
||||
\
|
||||
inline void PlacementCopy( const_iterator first, const_iterator last, iterator result )\
|
||||
{\
|
||||
while ( first != last ) \
|
||||
new (result++) value_type(*first++);\
|
||||
}\
|
||||
\
|
||||
inline void ConstructObjects( iterator first, iterator last, const value_type& pattern )\
|
||||
{\
|
||||
while( first != last ) \
|
||||
new (first++) value_type(pattern);\
|
||||
}\
|
||||
\
|
||||
inline void CopyObjects( iterator first, iterator last, iterator result )\
|
||||
{\
|
||||
while( first != last ) \
|
||||
*result++ = *first++;\
|
||||
}\
|
||||
\
|
||||
inline void CopyObjectsBack( iterator first, iterator last, iterator result )\
|
||||
{\
|
||||
result += difference_type(last,first);\
|
||||
\
|
||||
while( first != last ) \
|
||||
*(--result) = *(--last);\
|
||||
}\
|
||||
\
|
||||
public:\
|
||||
\
|
||||
class reverse_iterator \
|
||||
{\
|
||||
friend class vectorClass;\
|
||||
friend class const_reverse_iterator;\
|
||||
\
|
||||
public:\
|
||||
iterator mpPos;\
|
||||
\
|
||||
public:\
|
||||
\
|
||||
reverse_iterator() {}\
|
||||
\
|
||||
reverse_iterator ( iterator pPos )\
|
||||
{\
|
||||
mpPos = pPos;\
|
||||
}\
|
||||
\
|
||||
int operator==( const reverse_iterator& rhs ) const { return (mpPos == rhs.mpPos); }\
|
||||
int operator!=( const reverse_iterator& rhs ) const { return (mpPos != rhs.mpPos); }\
|
||||
\
|
||||
inline reverse_iterator( const reverse_iterator& other )\
|
||||
{\
|
||||
mpPos = other.mpPos;\
|
||||
}\
|
||||
\
|
||||
inline const reverse_iterator& operator--() \
|
||||
{\
|
||||
--mpPos;\
|
||||
return *this;\
|
||||
}\
|
||||
\
|
||||
inline reverse_iterator operator--(int)\
|
||||
{\
|
||||
reverse_iterator tmp = *this;\
|
||||
--mpPos;\
|
||||
return tmp;\
|
||||
}\
|
||||
\
|
||||
inline const reverse_iterator & operator++() \
|
||||
{\
|
||||
++mpPos;\
|
||||
return *this;\
|
||||
}\
|
||||
\
|
||||
inline reverse_iterator operator++(int)\
|
||||
{\
|
||||
reverse_iterator tmp = *this;\
|
||||
++mpPos;\
|
||||
return tmp;\
|
||||
}\
|
||||
\
|
||||
inline const_reference operator*() const { return *mpPos; }\
|
||||
};\
|
||||
\
|
||||
\
|
||||
class const_reverse_iterator \
|
||||
{\
|
||||
protected:\
|
||||
iterator mpPos;\
|
||||
public:\
|
||||
\
|
||||
const_reverse_iterator() {}\
|
||||
\
|
||||
const_reverse_iterator( const iterator pPos )\
|
||||
{\
|
||||
mpPos = pPos;\
|
||||
}\
|
||||
\
|
||||
int operator==( const const_reverse_iterator& rhs ) const { return (mpPos == rhs.mpPos); }\
|
||||
int operator!=( const const_reverse_iterator& rhs ) const { return (mpPos != rhs.mpPos); }\
|
||||
\
|
||||
inline const_reverse_iterator( const reverse_iterator& other )\
|
||||
{\
|
||||
mpPos = other.mpPos;\
|
||||
}\
|
||||
\
|
||||
inline const const_reverse_iterator& operator--() \
|
||||
{\
|
||||
--mpPos;\
|
||||
return *this;\
|
||||
}\
|
||||
\
|
||||
inline const_reverse_iterator operator--(int)\
|
||||
{\
|
||||
const_reverse_iterator tmp = *this;\
|
||||
--mpPos;\
|
||||
return tmp;\
|
||||
}\
|
||||
\
|
||||
inline const const_reverse_iterator & operator++() \
|
||||
{\
|
||||
++mpPos;\
|
||||
return *this;\
|
||||
}\
|
||||
\
|
||||
inline const_reverse_iterator operator++(int)\
|
||||
{\
|
||||
const_reverse_iterator tmp = *this;\
|
||||
++mpPos;\
|
||||
return tmp;\
|
||||
}\
|
||||
\
|
||||
inline const_reference operator*() const { return *mpPos; }\
|
||||
};\
|
||||
\
|
||||
protected:\
|
||||
\
|
||||
pointer mpStart;\
|
||||
pointer mpEnd;\
|
||||
pointer mpEndOfBuf;\
|
||||
\
|
||||
protected:\
|
||||
\
|
||||
inline void quick_sort(int low, int hi) \
|
||||
{\
|
||||
int pivot_index;\
|
||||
int left, right;\
|
||||
\
|
||||
pivot_index = ( !(mpStart[low] < mpStart[low+1])) ? low : (low+1);\
|
||||
value_type pivot_value = mpStart[pivot_index];\
|
||||
\
|
||||
left = low; right = hi;\
|
||||
do \
|
||||
{\
|
||||
while ((left <= hi) && (mpStart[left] < pivot_value)) left++;\
|
||||
\
|
||||
while ((right >= low) && (pivot_value < mpStart[right])) right--;\
|
||||
\
|
||||
if (left <= right) \
|
||||
{\
|
||||
value_type tmp = mpStart[left];\
|
||||
mpStart[left] = mpStart[right];\
|
||||
mpStart[right] = tmp;\
|
||||
\
|
||||
left++;\
|
||||
right--;\
|
||||
}\
|
||||
\
|
||||
} while (left <= right);\
|
||||
if (low < right) quick_sort(low, right);\
|
||||
if (left < hi) quick_sort(left, hi);\
|
||||
}\
|
||||
\
|
||||
inline void DestructRange( iterator first, iterator last )\
|
||||
{\
|
||||
typedef value_type value_type_local;\
|
||||
\
|
||||
while ( first != last ) \
|
||||
{\
|
||||
first->value_type_local::~value_type_local();\
|
||||
++first;\
|
||||
}\
|
||||
}\
|
||||
\
|
||||
inline iterator DoInsert(iterator position, const value_type& x)\
|
||||
{\
|
||||
if ( mpEnd < mpEndOfBuf )\
|
||||
{\
|
||||
new (mpEnd) value_type(*(mpEnd-1) );\
|
||||
\
|
||||
CopyObjectsBack( position, mpEnd, position + 1 );\
|
||||
\
|
||||
*position = x;\
|
||||
\
|
||||
++mpEnd;\
|
||||
\
|
||||
return position;\
|
||||
}\
|
||||
\
|
||||
size_type minBufLen = WXSTL_VECTOR_MIN_BUF_SIZE/sizeof(value_type);\
|
||||
\
|
||||
size_type doubledSize = size()*2;\
|
||||
\
|
||||
size_type newLen = ( doubledSize < minBufLen ) ? minBufLen : doubledSize;\
|
||||
\
|
||||
iterator pNewStart = (iterator)( new char[newLen*sizeof(value_type)] );\
|
||||
\
|
||||
PlacementCopy( mpStart, position, pNewStart );\
|
||||
\
|
||||
iterator atPosition = pNewStart + difference_type( position - mpStart );\
|
||||
\
|
||||
new (atPosition) value_type(x);\
|
||||
\
|
||||
iterator newPos = atPosition;\
|
||||
\
|
||||
++atPosition;\
|
||||
\
|
||||
if ( mpStart ) \
|
||||
{\
|
||||
PlacementCopy( position, mpEnd, atPosition );\
|
||||
DestructRange( mpStart, mpEnd );\
|
||||
delete [](char*)mpStart;\
|
||||
}\
|
||||
\
|
||||
mpEnd = atPosition + difference_type( mpEnd - position );\
|
||||
\
|
||||
mpStart = pNewStart;\
|
||||
mpEndOfBuf = pNewStart + newLen;\
|
||||
\
|
||||
return newPos;\
|
||||
}\
|
||||
\
|
||||
public:\
|
||||
\
|
||||
inline vectorClass() : mpStart(0), \
|
||||
mpEnd(0),\
|
||||
mpEndOfBuf(0)\
|
||||
{}\
|
||||
\
|
||||
inline vectorClass( const_iterator first, const_iterator last )\
|
||||
: mpStart(0),\
|
||||
mpEnd(0),\
|
||||
mpEndOfBuf(0)\
|
||||
\
|
||||
{ while( first != last ) push_back( *first++ ); }\
|
||||
\
|
||||
inline vectorClass( size_type n, const value_type& value = value_type() )\
|
||||
: mpStart(0),\
|
||||
mpEnd(0),\
|
||||
mpEndOfBuf(0)\
|
||||
\
|
||||
{ for( size_type i = 0; i != n; ++i ) push_back( value ); }\
|
||||
\
|
||||
inline int operator==( const vectorClass& other )\
|
||||
{\
|
||||
size_type sz = size();\
|
||||
\
|
||||
if ( sz != other.size() ) return 0;\
|
||||
\
|
||||
for( size_type i = 0; i != sz; ++i )\
|
||||
\
|
||||
if ( !( (*this)[i] == other[i] ) ) return 0;\
|
||||
\
|
||||
return 1;\
|
||||
\
|
||||
}\
|
||||
\
|
||||
inline const vectorClass& operator=( const vectorClass& other )\
|
||||
{\
|
||||
if (mpStart) \
|
||||
{\
|
||||
DestructRange( begin(), end() );\
|
||||
delete [](char*)mpStart; \
|
||||
}\
|
||||
\
|
||||
size_t newLen = difference_type( other.mpEndOfBuf - other.mpStart );\
|
||||
\
|
||||
mpStart = (iterator)( new char[newLen*sizeof(value_type)] );\
|
||||
\
|
||||
PlacementCopy( other.begin(), other.end(), mpStart );\
|
||||
\
|
||||
mpEnd = mpStart + other.size();\
|
||||
\
|
||||
mpEndOfBuf = mpStart + newLen;\
|
||||
\
|
||||
return *this;\
|
||||
}\
|
||||
\
|
||||
inline vectorClass( const vectorClass& other )\
|
||||
: mpStart(0),\
|
||||
mpEnd(0),\
|
||||
mpEndOfBuf(0)\
|
||||
{\
|
||||
this->operator=( other );\
|
||||
}\
|
||||
\
|
||||
inline ~vectorClass() \
|
||||
{ \
|
||||
if (mpStart) \
|
||||
{\
|
||||
DestructRange( begin(), end() );\
|
||||
delete [](char*)mpStart; \
|
||||
}\
|
||||
}\
|
||||
\
|
||||
inline iterator begin() { return mpStart; }\
|
||||
\
|
||||
inline const_iterator begin() const { return mpStart; }\
|
||||
\
|
||||
inline iterator end() { return mpEnd; }\
|
||||
\
|
||||
inline const_iterator end() const { return mpEnd; }\
|
||||
\
|
||||
inline size_type size() const { return (size_type)difference_type(mpEnd-mpStart); }\
|
||||
\
|
||||
inline size_type max_size() const { return UINT_MAX/sizeof(value_type); }\
|
||||
\
|
||||
inline size_type capacity() const \
|
||||
{ return difference_type(mpEndOfBuf-mpStart)/sizeof(value_type); }\
|
||||
\
|
||||
inline int empty() const { return mpStart == mpEnd; }\
|
||||
\
|
||||
inline reference operator[](size_type n) { return *(mpStart+n); }\
|
||||
\
|
||||
inline const_reference operator[](size_type n) const { return *(mpStart+n); }\
|
||||
\
|
||||
inline reference front() { return (*mpStart); }\
|
||||
\
|
||||
inline const_reference front() const { return (*mpStart); }\
|
||||
\
|
||||
inline reference back() { return (*(mpEnd-1)); }\
|
||||
\
|
||||
inline const_reference back() const { return (*(mpEnd-1)); }\
|
||||
\
|
||||
inline void reserve(size_type n) {}\
|
||||
\
|
||||
inline void push_back(const value_type& x)\
|
||||
{\
|
||||
if ( mpEnd != mpEndOfBuf ) \
|
||||
{\
|
||||
new (mpEnd) value_type(x);\
|
||||
++mpEnd;\
|
||||
}\
|
||||
else\
|
||||
DoInsert( mpEnd, x );\
|
||||
}\
|
||||
\
|
||||
inline iterator insert(iterator position, const value_type& x = value_type())\
|
||||
{\
|
||||
if ( position == mpEnd && mpEnd != mpEndOfBuf )\
|
||||
{\
|
||||
new (mpEnd) value_type(x);\
|
||||
++mpEnd;\
|
||||
return (mpEnd-1);\
|
||||
}\
|
||||
else return DoInsert( position, x );\
|
||||
}\
|
||||
\
|
||||
inline void pop_back()\
|
||||
{\
|
||||
DestructRange( mpEnd-1, mpEnd );\
|
||||
\
|
||||
--mpEnd;\
|
||||
}\
|
||||
\
|
||||
inline void erase(iterator first, iterator last)\
|
||||
{\
|
||||
if ( last == mpEnd )\
|
||||
{\
|
||||
DestructRange( first, last );\
|
||||
mpEnd = first;\
|
||||
return;\
|
||||
}\
|
||||
\
|
||||
CopyObjects( last, last + difference_type( mpEnd - last ), first );\
|
||||
\
|
||||
iterator newEnd = mpEnd - difference_type( last - first );\
|
||||
DestructRange( newEnd, mpEnd );\
|
||||
\
|
||||
mpEnd = newEnd;\
|
||||
}\
|
||||
\
|
||||
inline void erase( iterator position )\
|
||||
{\
|
||||
erase( position, position + 1 );\
|
||||
}\
|
||||
\
|
||||
inline void sort()\
|
||||
{\
|
||||
if ( size() < 2 ) return;\
|
||||
quick_sort( 0, size()-1 );\
|
||||
}\
|
||||
}
|
||||
|
||||
/////////////////////////////// shallow-copy container ///////////////////////
|
||||
|
||||
#define __DEFINE_STL_VECTOR_SHALLOW( vectorClass, Type ) class vectorClass {\
|
||||
\
|
||||
public:\
|
||||
typedef Type value_type;\
|
||||
typedef value_type* iterator;\
|
||||
typedef const value_type* const_iterator;\
|
||||
typedef iterator pointer;\
|
||||
typedef const iterator const_pointer;\
|
||||
typedef value_type& reference;\
|
||||
typedef const value_type& const_reference;\
|
||||
typedef size_t size_type;\
|
||||
typedef ptrdiff_t difference_type;\
|
||||
\
|
||||
typedef iterator OutputIterator;\
|
||||
typedef const_iterator InputIterator;\
|
||||
\
|
||||
protected:\
|
||||
\
|
||||
inline void PlacementCopy( const_iterator first, const_iterator last, iterator result )\
|
||||
{\
|
||||
memcpy(result, first, int(difference_type(last-first)*sizeof(value_type)) );\
|
||||
}\
|
||||
\
|
||||
inline void ConstructObjects( iterator first, iterator last, const value_type& pattern )\
|
||||
{\
|
||||
if ( sizeof(pattern) == 1 )\
|
||||
\
|
||||
memset( first, int(difference_type(last-first)/sizeof(value_type)), \
|
||||
int(*((char*)&pattern)) );\
|
||||
else\
|
||||
while( first != last ) \
|
||||
*first++ = pattern;\
|
||||
}\
|
||||
\
|
||||
inline void CopyObjects( iterator first, iterator last, iterator result )\
|
||||
{\
|
||||
memcpy(result, first, int(difference_type(last-first)*sizeof(value_type)) );\
|
||||
}\
|
||||
\
|
||||
inline void CopyObjectsBack( iterator first, iterator last, iterator result )\
|
||||
{\
|
||||
memmove(result, first, int(difference_type(last-first)*sizeof(value_type)) );\
|
||||
}\
|
||||
\
|
||||
public:\
|
||||
\
|
||||
class reverse_iterator \
|
||||
{\
|
||||
friend class vectorClass;\
|
||||
friend class const_reverse_iterator;\
|
||||
\
|
||||
public:\
|
||||
iterator mpPos;\
|
||||
\
|
||||
public:\
|
||||
\
|
||||
reverse_iterator() {}\
|
||||
\
|
||||
reverse_iterator ( iterator pPos )\
|
||||
{\
|
||||
mpPos = pPos;\
|
||||
}\
|
||||
\
|
||||
int operator==( const reverse_iterator& rhs ) const { return (mpPos == rhs.mpPos); }\
|
||||
int operator!=( const reverse_iterator& rhs ) const { return (mpPos != rhs.mpPos); }\
|
||||
\
|
||||
inline reverse_iterator( const reverse_iterator& other )\
|
||||
{\
|
||||
mpPos = other.mpPos;\
|
||||
}\
|
||||
\
|
||||
inline const reverse_iterator& operator--() \
|
||||
{\
|
||||
--mpPos;\
|
||||
return *this;\
|
||||
}\
|
||||
\
|
||||
inline reverse_iterator operator--(int)\
|
||||
{\
|
||||
reverse_iterator tmp = *this;\
|
||||
--mpPos;\
|
||||
return tmp;\
|
||||
}\
|
||||
\
|
||||
inline const reverse_iterator & operator++() \
|
||||
{\
|
||||
++mpPos;\
|
||||
return *this;\
|
||||
}\
|
||||
\
|
||||
inline reverse_iterator operator++(int)\
|
||||
{\
|
||||
reverse_iterator tmp = *this;\
|
||||
++mpPos;\
|
||||
return tmp;\
|
||||
}\
|
||||
\
|
||||
inline const_reference operator*() const { return *mpPos; }\
|
||||
};\
|
||||
\
|
||||
\
|
||||
class const_reverse_iterator \
|
||||
{\
|
||||
protected:\
|
||||
iterator mpPos;\
|
||||
public:\
|
||||
\
|
||||
const_reverse_iterator() {}\
|
||||
\
|
||||
const_reverse_iterator( const iterator pPos )\
|
||||
{\
|
||||
mpPos = pPos;\
|
||||
}\
|
||||
\
|
||||
int operator==( const const_reverse_iterator& rhs ) const { return (mpPos == rhs.mpPos); }\
|
||||
int operator!=( const const_reverse_iterator& rhs ) const { return (mpPos != rhs.mpPos); }\
|
||||
\
|
||||
inline const_reverse_iterator( const reverse_iterator& other )\
|
||||
{\
|
||||
mpPos = other.mpPos;\
|
||||
}\
|
||||
\
|
||||
inline const const_reverse_iterator& operator--() \
|
||||
{\
|
||||
--mpPos;\
|
||||
return *this;\
|
||||
}\
|
||||
\
|
||||
inline const_reverse_iterator operator--(int)\
|
||||
{\
|
||||
const_reverse_iterator tmp = *this;\
|
||||
--mpPos;\
|
||||
return tmp;\
|
||||
}\
|
||||
\
|
||||
inline const const_reverse_iterator & operator++() \
|
||||
{\
|
||||
++mpPos;\
|
||||
return *this;\
|
||||
}\
|
||||
\
|
||||
inline const_reverse_iterator operator++(int)\
|
||||
{\
|
||||
const_reverse_iterator tmp = *this;\
|
||||
++mpPos;\
|
||||
return tmp;\
|
||||
}\
|
||||
\
|
||||
inline const_reference operator*() const { return *mpPos; }\
|
||||
};\
|
||||
\
|
||||
protected:\
|
||||
\
|
||||
pointer mpStart;\
|
||||
pointer mpEnd;\
|
||||
pointer mpEndOfBuf;\
|
||||
\
|
||||
protected:\
|
||||
\
|
||||
inline void quick_sort(int low, int hi) \
|
||||
{\
|
||||
int pivot_index;\
|
||||
int left, right;\
|
||||
\
|
||||
pivot_index = ( !(mpStart[low] < mpStart[low+1])) ? low : (low+1);\
|
||||
value_type pivot_value = mpStart[pivot_index];\
|
||||
\
|
||||
left = low; right = hi;\
|
||||
do \
|
||||
{\
|
||||
while ((left <= hi) && (mpStart[left] < pivot_value)) left++;\
|
||||
\
|
||||
while ((right >= low) && (pivot_value < mpStart[right])) right--;\
|
||||
\
|
||||
if (left <= right) \
|
||||
{\
|
||||
value_type tmp = mpStart[left];\
|
||||
mpStart[left] = mpStart[right];\
|
||||
mpStart[right] = tmp;\
|
||||
\
|
||||
left++;\
|
||||
right--;\
|
||||
}\
|
||||
\
|
||||
} while (left <= right);\
|
||||
if (low < right) quick_sort(low, right);\
|
||||
if (left < hi) quick_sort(left, hi);\
|
||||
}\
|
||||
\
|
||||
inline void DestructRange( iterator first, iterator last )\
|
||||
{\
|
||||
}\
|
||||
\
|
||||
inline iterator DoInsert(iterator position, const value_type& x)\
|
||||
{\
|
||||
if ( mpEnd < mpEndOfBuf )\
|
||||
{\
|
||||
new (mpEnd) value_type(*(mpEnd-1) );\
|
||||
\
|
||||
CopyObjectsBack( position, mpEnd, position + 1 );\
|
||||
\
|
||||
*position = x;\
|
||||
\
|
||||
++mpEnd;\
|
||||
\
|
||||
return position;\
|
||||
}\
|
||||
\
|
||||
size_type minBufLen = WXSTL_VECTOR_MIN_BUF_SIZE/sizeof(value_type);\
|
||||
\
|
||||
size_type doubledSize = size()*2;\
|
||||
\
|
||||
size_type newLen = ( doubledSize < minBufLen ) ? minBufLen : doubledSize;\
|
||||
\
|
||||
iterator pNewStart = (iterator)( new char[newLen*sizeof(value_type)] );\
|
||||
\
|
||||
PlacementCopy( mpStart, position, pNewStart );\
|
||||
\
|
||||
iterator atPosition = pNewStart + difference_type( position - mpStart );\
|
||||
\
|
||||
new (atPosition) value_type(x);\
|
||||
\
|
||||
iterator newPos = atPosition;\
|
||||
\
|
||||
++atPosition;\
|
||||
\
|
||||
if ( mpStart ) \
|
||||
{\
|
||||
PlacementCopy( position, mpEnd, atPosition );\
|
||||
DestructRange( mpStart, mpEnd );\
|
||||
delete [](char*)mpStart;\
|
||||
}\
|
||||
\
|
||||
mpEnd = atPosition + difference_type( mpEnd - position );\
|
||||
\
|
||||
mpStart = pNewStart;\
|
||||
mpEndOfBuf = pNewStart + newLen;\
|
||||
\
|
||||
return newPos;\
|
||||
}\
|
||||
\
|
||||
public:\
|
||||
\
|
||||
inline vectorClass() : mpStart(0), \
|
||||
mpEnd(0),\
|
||||
mpEndOfBuf(0)\
|
||||
{}\
|
||||
\
|
||||
inline vectorClass( const_iterator first, const_iterator last )\
|
||||
: mpStart(0),\
|
||||
mpEnd(0),\
|
||||
mpEndOfBuf(0)\
|
||||
\
|
||||
{ while( first != last ) push_back( *first++ ); }\
|
||||
\
|
||||
inline vectorClass( size_type n, const value_type& value = value_type() )\
|
||||
: mpStart(0),\
|
||||
mpEnd(0),\
|
||||
mpEndOfBuf(0)\
|
||||
\
|
||||
{ for( size_type i = 0; i != n; ++i ) push_back( value ); }\
|
||||
\
|
||||
inline int operator==( const vectorClass& other )\
|
||||
{\
|
||||
size_type sz = size();\
|
||||
\
|
||||
if ( sz != other.size() ) return 0;\
|
||||
\
|
||||
for( size_type i = 0; i != sz; ++i )\
|
||||
\
|
||||
if ( !( (*this)[i] == other[i] ) ) return 0;\
|
||||
\
|
||||
return 1;\
|
||||
\
|
||||
}\
|
||||
\
|
||||
inline const vectorClass& operator=( const vectorClass& other )\
|
||||
{\
|
||||
if (mpStart) \
|
||||
{\
|
||||
DestructRange( begin(), end() );\
|
||||
delete [](char*)mpStart; \
|
||||
}\
|
||||
\
|
||||
size_t newLen = difference_type( other.mpEndOfBuf - other.mpStart );\
|
||||
\
|
||||
mpStart = (iterator)( new char[newLen*sizeof(value_type)] );\
|
||||
\
|
||||
PlacementCopy( other.begin(), other.end(), mpStart );\
|
||||
\
|
||||
mpEnd = mpStart + other.size();\
|
||||
\
|
||||
mpEndOfBuf = mpStart + newLen;\
|
||||
\
|
||||
return *this;\
|
||||
}\
|
||||
\
|
||||
inline vectorClass( const vectorClass& other )\
|
||||
: mpStart(0),\
|
||||
mpEnd(0),\
|
||||
mpEndOfBuf(0)\
|
||||
{\
|
||||
this->operator=( other );\
|
||||
}\
|
||||
\
|
||||
inline ~vectorClass() \
|
||||
{ \
|
||||
if (mpStart) \
|
||||
{\
|
||||
DestructRange( begin(), end() );\
|
||||
delete [](char*)mpStart; \
|
||||
}\
|
||||
}\
|
||||
\
|
||||
inline iterator begin() { return mpStart; }\
|
||||
\
|
||||
inline const_iterator begin() const { return mpStart; }\
|
||||
\
|
||||
inline iterator end() { return mpEnd; }\
|
||||
\
|
||||
inline const_iterator end() const { return mpEnd; }\
|
||||
\
|
||||
inline size_type size() const { return (size_type)difference_type(mpEnd-mpStart); }\
|
||||
\
|
||||
inline size_type max_size() const { return UINT_MAX/sizeof(value_type); }\
|
||||
\
|
||||
inline size_type capacity() const \
|
||||
{ return difference_type(mpEndOfBuf-mpStart)/sizeof(value_type); }\
|
||||
\
|
||||
inline int empty() const { return mpStart == mpEnd; }\
|
||||
\
|
||||
inline reference operator[](size_type n) { return *(mpStart+n); }\
|
||||
\
|
||||
inline const_reference operator[](size_type n) const { return *(mpStart+n); }\
|
||||
\
|
||||
inline reference front() { return (*mpStart); }\
|
||||
\
|
||||
inline const_reference front() const { return (*mpStart); }\
|
||||
\
|
||||
inline reference back() { return (*(mpEnd-1)); }\
|
||||
\
|
||||
inline const_reference back() const { return (*(mpEnd-1)); }\
|
||||
\
|
||||
inline void reserve(size_type n) {}\
|
||||
\
|
||||
inline void push_back(const value_type& x)\
|
||||
{\
|
||||
if ( mpEnd != mpEndOfBuf ) \
|
||||
{\
|
||||
new (mpEnd) value_type(x);\
|
||||
++mpEnd;\
|
||||
}\
|
||||
else\
|
||||
DoInsert( mpEnd, x );\
|
||||
}\
|
||||
\
|
||||
inline iterator insert(iterator position, const value_type& x = value_type())\
|
||||
{\
|
||||
if ( position == mpEnd && mpEnd != mpEndOfBuf )\
|
||||
{\
|
||||
new (mpEnd) value_type(x);\
|
||||
++mpEnd;\
|
||||
return (mpEnd-1);\
|
||||
}\
|
||||
else return DoInsert( position, x );\
|
||||
}\
|
||||
\
|
||||
inline void pop_back()\
|
||||
{\
|
||||
DestructRange( mpEnd-1, mpEnd );\
|
||||
\
|
||||
--mpEnd;\
|
||||
}\
|
||||
\
|
||||
inline void erase(iterator first, iterator last)\
|
||||
{\
|
||||
if ( last == mpEnd )\
|
||||
{\
|
||||
DestructRange( first, last );\
|
||||
mpEnd = first;\
|
||||
return;\
|
||||
}\
|
||||
\
|
||||
CopyObjects( last, last + difference_type( mpEnd - last ), first );\
|
||||
\
|
||||
iterator newEnd = mpEnd - difference_type( last - first );\
|
||||
DestructRange( newEnd, mpEnd );\
|
||||
\
|
||||
mpEnd = newEnd;\
|
||||
}\
|
||||
\
|
||||
inline void erase( iterator position )\
|
||||
{\
|
||||
erase( position, position + 1 );\
|
||||
}\
|
||||
\
|
||||
inline void sort()\
|
||||
{\
|
||||
if ( size() < 2 ) return;\
|
||||
quick_sort( 0, size()-1 );\
|
||||
}\
|
||||
}
|
||||
|
||||
|
||||
|
||||
// redefine below symbol to change the default allocation unit of vector content buffer
|
||||
#define WXSTL_VECTOR_MIN_BUF_SIZE 64
|
||||
|
||||
// defines vector class, where objects are copied
|
||||
// using "deep-copy" sematics (i.e. by calling their copy constructors)
|
||||
|
||||
#define WXSTL_VECTOR(ELEMENT_CLASS) \
|
||||
__DEFINE_STL_VECTOR_DEEP(_WXSTL_VECTOR_##ELEMENT_CLASS, ELEMENT_CLASS)
|
||||
|
||||
// defines vector class, where objects are copied
|
||||
// using "shallow-copy" sematics (i.e. instead of calling
|
||||
// their constructors, memcpy() and memmove() are used to copy their raw data)
|
||||
|
||||
|
||||
#define WXSTL_VECTOR_SHALLOW_COPY(ELEMENT_CLASS) __DEFINE_STL_VECTOR_SHALLOW(_WXSTL_VECTORSC_##ELEMENT_CLASS, ELEMENT_CLASS)
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user