This commit is contained in:
Alexander Deynichenko
2013-02-25 07:23:44 +04:00
parent 35ff18a6a1
commit 03b62f3315
809 changed files with 211135 additions and 0 deletions
+3
View File
@@ -0,0 +1,3 @@
P-GUIDE was written by John F. Fay.
Significant improvements were made by James 'J.C.' Jones
+340
View 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) <year> <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) year 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.
+1
View File
@@ -0,0 +1 @@
July, 2002 -- P-Guide functionality increased dramatically -- James 'J.C.' Jones
+182
View File
@@ -0,0 +1,182 @@
Basic Installation
==================
These are generic installation instructions.
The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses
those values to create a `Makefile' in each directory of the package.
It may also create one or more `.h' files containing system-dependent
definitions. Finally, it creates a shell script `config.status' that
you can run in the future to recreate the current configuration, a file
`config.cache' that saves the results of its tests to speed up
reconfiguring, and a file `config.log' containing compiler output
(useful mainly for debugging `configure').
If you need to do unusual things to compile the package, please try
to figure out how `configure' could check whether to do them, and mail
diffs or instructions to the address given in the `README' so they can
be considered for the next release. If at some point `config.cache'
contains results you don't want to keep, you may remove or edit it.
The file `configure.in' is used to create `configure' by a program
called `autoconf'. You only need `configure.in' if you want to change
it or regenerate `configure' using a newer version of `autoconf'.
The simplest way to compile this package is:
1. `cd' to the directory containing the package's source code and type
`./configure' to configure the package for your system. If you're
using `csh' on an old version of System V, you might need to type
`sh ./configure' instead to prevent `csh' from trying to execute
`configure' itself.
Running `configure' takes awhile. While running, it prints some
messages telling which features it is checking for.
2. Type `make' to compile the package.
3. Optionally, type `make check' to run any self-tests that come with
the package.
4. Type `make install' to install the programs and any data files and
documentation.
5. You can remove the program binaries and object files from the
source code directory by typing `make clean'. To also remove the
files that `configure' created (so you can compile the package for
a different kind of computer), type `make distclean'. There is
also a `make maintainer-clean' target, but that is intended mainly
for the package's developers. If you use it, you may have to get
all sorts of other programs in order to regenerate files that came
with the distribution.
Compilers and Options
=====================
Some systems require unusual options for compilation or linking that
the `configure' script does not know about. You can give `configure'
initial values for variables by setting them in the environment. Using
a Bourne-compatible shell, you can do that on the command line like
this:
CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
Or on systems that have the `env' program, you can do it like this:
env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
Compiling For Multiple Architectures
====================================
You can compile the package for more than one kind of computer at the
same time, by placing the object files for each architecture in their
own directory. To do this, you must use a version of `make' that
supports the `VPATH' variable, such as GNU `make'. `cd' to the
directory where you want the object files and executables to go and run
the `configure' script. `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'.
If you have to use a `make' that does not supports the `VPATH'
variable, you have to compile the package for one architecture at a time
in the source code directory. After you have installed the package for
one architecture, use `make distclean' before reconfiguring for another
architecture.
Installation Names
==================
By default, `make install' will install the package's files in
`/usr/local/bin', `/usr/local/man', etc. You can specify an
installation prefix other than `/usr/local' by giving `configure' the
option `--prefix=PATH'.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you
give `configure' the option `--exec-prefix=PATH', the package will use
PATH as the prefix for installing programs and libraries.
Documentation and other data files will still use the regular prefix.
In addition, if you use an unusual directory layout you can give
options like `--bindir=PATH' to specify different values for particular
kinds of files. Run `configure --help' for a list of the directories
you can set and what kinds of files go in them.
If the package supports it, you can cause programs to be installed
with an extra prefix or suffix on their names by giving `configure' the
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
Optional Features
=================
Some packages pay attention to `--enable-FEATURE' options to
`configure', where FEATURE indicates an optional part of the package.
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
is something like `gnu-as' or `x' (for the X Window System). The
`README' should mention any `--enable-' and `--with-' options that the
package recognizes.
For packages that use the X Window System, `configure' can usually
find the X include and library files automatically, but if it doesn't,
you can use the `configure' options `--x-includes=DIR' and
`--x-libraries=DIR' to specify their locations.
Specifying the System Type
==========================
There may be some features `configure' can not figure out
automatically, but needs to determine by the type of host the package
will run on. Usually `configure' can figure that out, but if it prints
a message saying it can not guess the host type, give it the
`--host=TYPE' option. TYPE can either be a short name for the system
type, such as `sun4', or a canonical name with three fields:
CPU-COMPANY-SYSTEM
See the file `config.sub' for the possible values of each field. If
`config.sub' isn't included in this package, then this package doesn't
need to know the host type.
If you are building compiler tools for cross-compiling, you can also
use the `--target=TYPE' option to select the type of system they will
produce code for and the `--build=TYPE' option to select the type of
system on which you are compiling the package.
Sharing Defaults
================
If you want to set default values for `configure' scripts to share,
you can create a site shell script called `config.site' that gives
default values for variables like `CC', `cache_file', and `prefix'.
`configure' looks for `PREFIX/share/config.site' if it exists, then
`PREFIX/etc/config.site' if it exists. Or, you can set the
`CONFIG_SITE' environment variable to the location of the site script.
A warning: not all `configure' scripts look for a site script.
Operation Controls
==================
`configure' recognizes the following options to control how it
operates.
`--cache-file=FILE'
Use and save the results of the tests in FILE instead of
`./config.cache'. Set FILE to `/dev/null' to disable caching, for
debugging `configure'.
`--help'
Print a summary of the options to `configure', and exit.
`--quiet'
`--silent'
`-q'
Do not print messages saying which checks are being made. To
suppress all normal output, redirect it to `/dev/null' (any error
messages will still be shown).
`--srcdir=DIR'
Look for the package's source code in directory DIR. Usually
`configure' can determine that directory automatically.
`--version'
Print the version of Autoconf used to generate the `configure'
script, and exit.
`configure' also accepts some other, not widely useful, options.
+4
View File
@@ -0,0 +1,4 @@
SUBDIRS = src
EXTRA_DIRS = autogen.sh README TODO pGuide.dsw
View File
+34
View File
@@ -0,0 +1,34 @@
PUI-based Graphical User Interface Designer
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
by John F. Fay
REQUIREMENTS:
OpenGL (or Mesa)
GLUT (the GL Utility Toolkit)
PLIB
INSTALLATION:
Installation instructions are pretty basic:
./configure
make
make install
LICENSE:
This software is released under the provisions of
the GNU General Public License (GPL) which can be
found in the file 'COPYING' in the current directory.
DIRECTORY STRUCTURE:
src -- Where the source code lives.
doc -- Documentation - in HTML
+30
View File
@@ -0,0 +1,30 @@
Planned Bug Fixes or Upgrades to P-GUIDE:
Bug Fixes:
1. When the user has selected CTRL-widget, have the button value set back to zero when the selected_widget_type (or whatever it is) gets deselected or changed (eg when he presses on another widget button in the Widget window or presses another widget anywhere else), not just when he presses Escape.
2. Make the Active widget's black line go all the way around it.
3. puFileSelector needs options
4. puScrollBar needs to be added
5. Menus (Vert and normal) need a method to populate submenus.
Upgrades:
1. Improve layer support.
2. Make widgets added to window the real widgets, rather than Frames.
3. Multiple Window support
4. Makefile building?
5. Font viewing / selecting (a font browser and such)
6. Copy / Cut / Paste
7. Widget class changes
+19
View File
@@ -0,0 +1,19 @@
#!/bin/sh
OSTYPE=`uname -s`
AMFLAGS="--add-missing"
if test "$OSTYPE" = "IRIX" -o "$OSTYPE" = "IRIX64"; then
AMFLAGS=$AMFLAGS" --include-deps";
fi
echo "Running aclocal"
aclocal
echo "Running automake"
automake $AMFLAGS
echo "Running autoconf"
autoconf
echo "======================================"
echo "Now you are ready to run './configure'"
echo "======================================"
+162
View File
@@ -0,0 +1,162 @@
dnl Process this file with autoconf to produce a configure script.
AC_INIT(src/pGuide.cxx)
AM_INIT_AUTOMAKE(pguide, 0.0.1)
dnl Checks for programs.
AC_PROG_CC
AC_PROG_CPP
AC_PROG_CXX
AC_PROG_CXXCPP
AC_PROG_INSTALL
plib_suffix="-lplibpu -lplibfnt -lplibsg -lplibul"
AC_LANG_CPLUSPLUS
dnl Command line arguments.
dnl Don't use AC_HELP_STRING here as old versions of autoconf do not
dnl understand it.
AC_ARG_WITH(GL,
[ --with-GL=DIR set the prefix directory where GL resides],
GL_PREFIX=$withval, GL_PREFIX=auto)
if test "x$GL_PREFIX" != "xauto"; then
LDFLAGS="$LDFLAGS -L$GL_PREFIX/lib"
CPPFLAGS="$CPPFLAGS -I$GL_PREFIX/include"
fi
dnl Checks for library functions.
dnl check for OpenGL related libraries
AC_CANONICAL_HOST
case "${host}" in
*-*-cygwin* | *-*-mingw32*)
dnl CygWin under Windoze.
dnl OpenGL libraries
LIBS="$LIBS -lwinmm -lglut32 -lglu32 -lopengl32 -luser32 -lgdi32"
;;
*-apple-darwin*)
dnl Mac OS X
LIBS="$LIBS -framework GLUT -lobjc -framework OpenGL"
;;
*)
dnl Check for X11
AC_PATH_XTRA
LDFLAGS="$LDFLAGS $X_LIBS"
LIBS="$LIBS $X_PRE_LIBS -lXi -lXmu -lXext -lX11 $X_EXTRA_LIBS -lm"
dnl =========================================================
dnl if test "x$x_includes" != "x"; then
dnl CPPFLAGS="$CPPFLAGS -I$x_includes"
dnl fi
dnl =========================================================
dnl Reasonable stuff non-windoze variants ... :-)
AC_CHECK_LIB(GL, glNewList)
if test "x$ac_cv_lib_GL_glNewList" = "xno" ; then
dnl if no GL, check for MesaGL
AC_CHECK_LIB(MesaGL, glNewList,,
AC_MSG_ERROR([could not find working GL library]))
fi
AC_CHECK_LIB(GLU, gluLookAt)
if test "x$ac_cv_lib_GLU_gluLookAt" = "xno" ; then
dnl if no GLU, check for MesaGLU
AC_CHECK_LIB(MesaGLU, gluLookAt,,
AC_MSG_ERROR([could not find working GLU library]))
fi
dnl check for glut...or freeglut
AC_CHECK_LIB(freeglut, glutGetModifiers)
if test "x$ac_cv_lib_freeglut_glutGetModifiers" = "xno" ; then
dnl if no freeglut, check for Real GLUT
AC_CHECK_LIB(glut, glutGetModifiers,,
AC_MSG_ERROR([could not find working GLUT library]))
fi
AC_CHECK_LIB(dl, dlclose)
;;
esac
dnl Check PLIB library
AC_CHECK_LIB(plibul, ulInit, true,
AC_MSG_ERROR([there seems to be a problem with the PLIB libraries]))
LIBS="$plib_suffix $LIBS"
dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADER(windows.h, AC_DEFINE(WIN32))
case "${host}" in
*-*-cygwin* | *-*-mingw32*)
dnl CygWin under Windoze.
AC_CHECK_HEADERS(GL/gl.h GL/glu.h,,
AC_MSG_ERROR([OpenGL header files not found]))
AC_CHECK_HEADER(GL/glut.h, AC_DEFINE(GLUT_IS_PRESENT),
AC_MSG_ERROR([GLUT header file not found]))
;;
*-apple-darwin*)
dnl Mac OS X
AC_CHECK_HEADERS(OpenGL/gl.h OpenGL/glu.h,,
AC_MSG_ERROR([OpenGL header files not found]))
AC_CHECK_HEADER(GLUT/glut.h, AC_DEFINE(GLUT_IS_PRESENT),
AC_MSG_ERROR([GLUT header file not found]))
;;
*)
AC_CHECK_HEADERS(GL/gl.h GL/glu.h,,
AC_MSG_ERROR([OpenGL header files not found]))
if test "x$ac_cv_lib_freeglut_glutGetModifiers" = "xyes"; then
AC_CHECK_HEADER(GL/freeglut.h, AC_DEFINE(FREEGLUT_IS_PRESENT),
AC_MSG_ERROR([freeglut header file not found]))
else
AC_CHECK_HEADER(GL/glut.h, AC_DEFINE(GLUT_IS_PRESENT),
AC_MSG_ERROR([GLUT header file not found]))
fi
;;
esac
AC_CHECK_HEADER(plib/ul.h,, AC_MSG_ERROR([PLIB header files not found]))
dnl Warning flags
WFLAG="-Wall"
case "$host" in
mips-sgi-irix*)
if test "x$CXX" = "xCC"; then
WFLAG="-fullwarn";
fi
;;
*)
if test "x$CXX" = "xicpc" || test "x$CXX" = "xicc"; then
WFLAG="-w1"
fi
;;
esac
CFLAGS="$CFLAGS $WFLAG"
CXXFLAGS="$CXXFLAGS $WFLAG"
AC_OUTPUT( Makefile \
src/Makefile \
)
+146
View File
@@ -0,0 +1,146 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Author" content="John F. Fay">
<meta name="GENERATOR" content="Mozilla/4.75 [en] (Windows NT 5.0; U) [Netscape]">
<title>PUI-Based GUI Designer (P-GUIDE) Documentation</title>
</head>
<body>
<h1>
P-GUIDE Documentation</h1>
<h1>
PUI-Based Graphical User Interface Designer</h1>
P-GUIDE comes up in three OpenGL windows.&nbsp; The first window is the
Main window in which the user arranges the widgets of his graphical user
interface.&nbsp; The second window is the Widget window which contains
one button for each PUI widget class.&nbsp; The third window is the Status
window which allows the user to see and control various widget and window
parameters in the main window.
<br>The basic concept of P-GUIDE is that the user will click on a button
in the Widget window and then click in the Main window to create a widget
for his GUI.&nbsp; He will then use the Status window to modify the settings
of that widget.&nbsp; The Main window reflects the changes he makes in
real time.&nbsp; When the user has created as many widgets as he likes,
he clicks on the "Write Window Code" button in the Status window and P-GUIDE
will write a file of C++ code which implements the GUI using OpenGL, GLUT,
and PUI.
<br>P-GUIDE is offered to the PLIB community under a GNU Public License
(GPL).&nbsp; Users are free to modify the source code as they see fit but
must offer their changes back to the community.
<h2>
GUI Window Control</h2>
The user may size, position, color, and name his window by using the input
box widgets at the top of the Status window.&nbsp; All the changes except
the window position are reflected immediately in the Main window.
<br>The user may also change the size of his window by clicking on an edge
of the window and dragging on it.&nbsp; Any widgets which the user has
already defined and placed in the window will remain stationary while the
window is being resized; this means that if the user drags the left-hand
edge of the window to change its width, the x-coordinates of the widgets
will change.&nbsp; (The user is cautioned against moving his mouse off
one side of the window, dragging it around the outside of the window, and
clicking on the opposite side of the window from the outside.&nbsp; Due
to a limitation in the windowing system this will reposition the widgets
in the window incorrectly.)
<h2>
Placing Widgets</h2>
To place a widget in the GUI, the user clicks on that widget's button in
the Widget window and then clicks in the Main window.&nbsp; The new widget
will be placed in the Main window with its lower left-hand corner at the
mouse position.&nbsp; The widget will have an initial size of 90 pixels
wide by 20 pixels high.
<br>If the user wants to place more than one widget of the same type in
his GUI, he can press the Control key when he clicks on that widget's button
in the Widget window.&nbsp; He will then click in the Main window once
for each widget of the given type that he wants to create.&nbsp; Pressing
the Escape key or clicking on another widget's button in the Widget window
will deactivate the button.
<br>A widget which has just been placed or has just been clicked on by
the mouse is called the Active widget.&nbsp; It is surrounded by a black
line.
<h2>
Widget Settings</h2>
The user can control the following settings of his widget from controls
in the Status window:
<ul>
<li>
Name (the name of the variable which is the pointer to the widget in the
program)</li>
<li>
Position</li>
<li>
Size</li>
<li>
Legend text and position</li>
<li>
Label text and position</li>
<li>
Callbacks</li>
</ul>
The user may also modify the size and position of his widgets directly
in the Main window.&nbsp; To change the size, he clicks inside the widget
within five pixels of the edge and then drags the mouse to extend the widget.&nbsp;
To change the position he clicks inside the widget away from the edges
and drags the mouse.
<br>The user may also move the Active widget one pixel at a time by pressing
the four arrow keys.&nbsp; Holding the Control key while pressing the arrow
keys will move the Active widget ten pixels at a time.
<h2>
Widget Visibility</h2>
There are obviously times when the user will want to draw more than one
widget in the same place in the GUI and only show them one at a time.&nbsp;
To allow this capability the Status window has a button box which controls
whether the widget in the Main window is visible or not.&nbsp; To hide
a widget the user simply clicks on the "Visible" button box.&nbsp; If he
then clicks on the "Visible" button box again the Active widget will reappear.&nbsp;
If the user selects another Active widget, there is no simple and direct
way to make the single hidden widget reappear in the main window.
<br>To allow the user to make widgets reappear, the Status window has a
one-shot button labelled "Reveal All Widgets".&nbsp; This makes all the
widgets in the Main window visible again.&nbsp; The user can then select
the widgets he wishes to hide again and make them invisible.
<br>When the program writes the C++ code to create the GUI, the widgets
which are not visible in the Main window are hidden by default.
<h2>
Widget Layers</h2>
Many times the order in which widgets are drawn is of vital importance.&nbsp;
For example, the user may want to fill a window with a frame widget to
provide a pleasing background for the actual widgets of the GUI.&nbsp;
In order to allow this the program assigns each widget in the Main window
a layer number.&nbsp; These layer numbers start at zero and increase.&nbsp;
When the Main window is being drawn, the widgets in lower-numbered layers
are drawn first and the widgets with larger layer numbers are drawn after
(and therefore on top of) them.&nbsp; When the C++ code to create the GUI
is being written, the widgets in the lower-numbered layers are created
first.
<h2>
Program Controls</h2>
Basic program control is provided by the three buttons at the bottom of
the Status window.&nbsp; Clicking on the "Write Window Code" button will
cause a file selector widget to pop up for the user to enter a file name
into which the code is to be written.&nbsp; An entire file is written which
contains the necessary include, window data, a default font definition,
widget variable definitions, GLUT window callbacks, widget callbacks for
each widget, and a complete main program that creates and manages the GLUT
window, initializes PUI, creates the widgets, and calls the GLUT main loop.&nbsp;
(At the moment the widget definition calls are somewhat lacking and the
user will need to modify them before he can compile the code.)
<br>If the user clicks on the "Clear" button, all the widgets in the Main
window will be erased.&nbsp; If the user has changed the window at all
since the last time he wrote code or cleared the Main window, the program
will pop up a box asking if he is sure.
<br>If the user clicks on the "Quit" button, the program will stop.&nbsp;
Again, if there have been changes since the last code writing or clearing,
the program will ask if he is sure.
</body>
</html>
+29
View File
@@ -0,0 +1,29 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "pGuide"=.\src\pGuide.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################
+756
View File
@@ -0,0 +1,756 @@
/*
This file is part of P-GUIDE -
PUI-based Graphical User Interface Designer.
Copyright (C) 2002, 2006 John F. Fay
P-GUIDE 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.
P-GUIDE 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 P-GUIDE; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
$Id: LoadSave.cxx 2100 2006-11-03 22:31:54Z fayjf $
*/
#include <stdio.h>
#include "WidgetList.h"
#define TAG_SAVEFILE 0x00000001
#define TAG_WINDOW 0x00000002
#define TAG_OBJECT 0x00000004
#define TAG_WIDGET 0x00000008
#define TAG_SIZE 0x00000010
#define TAG_POSITION 0x00000020
#define TAG_COLOR 0x00000040
#define TAG_LEGEND 0x00000080
#define TAG_LABEL 0x00000100
#define TAG_DATA 0x00000120
#define CALLBACK_UP 0x00000001
#define CALLBACK_ACTIVE 0x00000002
#define CALLBACK_DOWN 0x00000004
#ifdef WIN32
#define PATH_SEPARATOR '\\'
#else
#define PATH_SEPARATOR '/'
#endif
// From the Main Window:
extern WidgetList *widgets ;
extern int max_layer ;
extern int main_window_width ;
extern int main_window_height ;
extern char main_window_name [ PUSTRING_MAX ] ;
extern int main_window_x ;
extern int main_window_y ;
extern int widget_number ;
extern bool main_window_changed ;
extern bool currently_loading ; /* Var for the Reshape function to not do its thing */
extern char pguide_current_directory [ PUSTRING_MAX ] ;
extern bool autolock ;
extern float main_window_color_r, main_window_color_g,
main_window_color_b, main_window_color_a ;
// From the Status Window
extern void setStatusWidgets ( WidgetList *wid );
extern int status_window ;
extern int main_window ;
extern puaFileSelector *file_selector ;
// Duplication checking
static void chk_dupname ( WidgetList *new_wid ) ;
static puInput *dup_newname = (puInput *)NULL ;
static puDialogBox *dup_dialog = (puDialogBox *)NULL ;
static WidgetList *nextwid ;
// Now our turn
void saveProject ( puObject *ob ) {
char* filename ;
file_selector -> getValue ( &filename ) ;
if (filename[0] == '\0')
{
puDeleteObject ( file_selector ) ;
file_selector = (puaFileSelector *)NULL ;
glutHideWindow () ;
glutSetWindow ( status_window ) ;
return ;
}
/* Save the new current directory */
strcpy(pguide_current_directory, filename) ;
int i = strlen(pguide_current_directory);
while (pguide_current_directory[i] != PATH_SEPARATOR) {
if (i>0) i-- ;
else break ;
}
pguide_current_directory[i+1] = '\0' ;
/* If they didn't give an extension, then tack ".xml" onto the end. */
if(!strstr(filename, "."))
sprintf(filename, "%s.xml", filename);
FILE *out = fopen ( filename, "wt" ) ;
if ( !out )
printf ( "ERROR opening file <%s> for writing\n", filename ) ;
puDeleteObject ( file_selector ) ;
file_selector = (puaFileSelector *)NULL ;
glutHideWindow () ;
glutSetWindow ( status_window ) ;
if ( !out ) return ;
/* Begin writing the XML */
const char *autolock_text;
if ( !autolock )
autolock_text="FALSE";
else
autolock_text="TRUE";
char projectname [] = "Test Project";
fprintf ( out, "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n<!DOCTYPE P-Guide>\n<savefile>\n\n" ) ;
fprintf ( out, "<version>VERSION</version>\n") ;
fprintf ( out, "<project>%s</project>\n", projectname) ;
fprintf ( out, "<autolock>%s</autolock>\n", autolock_text) ;
fprintf ( out, "<window>\n\t<name>%s</name>\n", main_window_name) ;
fprintf ( out, "\t<size>\n\t\t<width>%d</width>\n", main_window_width) ;
fprintf ( out, "\t\t<height>%d</height>\n\t</size>\n", main_window_height) ;
fprintf ( out, "\t<position>\n\t\t<x>%d</x>\n", main_window_x) ;
fprintf ( out, "\t\t<y>%d</y>\n\t</position>\n", main_window_y) ;
fprintf ( out, "\t<color>\n\t\t<r>%f</r>\n\t\t<g>%f</g>\n\t\t<b>%f</b>\n", main_window_color_r, main_window_color_g, main_window_color_b) ;
fprintf ( out, "\t\t<a>%f</a>\n\t</color>\n</window>\n\n", main_window_color_a) ;
fprintf ( out, "<objects>\n") ;
/* Now begin spitting out the actual widget data. */
WidgetList *wid = widgets ;
const char *place_name [] = { "PUPLACE_TOP_LEFT", "PUPLACE_TOP_CENTERED", "PUPLACE_TOP_RIGHT",
"PUPLACE_CENTERED_LEFT", "PUPLACE_CENTERED_RIGHT",
"PUPLACE_BOTTOM_LEFT", "PUPLACE_BOTTOM_CENTERED", "PUPLACE_BOTTOM_RIGHT",
"PUPLACE_CENTERED_CENTERED",
"PUPLACE_ABOVE_LEFT", "PUPLACE_ABOVE_RIGHT",
"PUPLACE_BELOW_LEFT", "PUPLACE_BELOW_RIGHT",
"PUPLACE_UPPER_LEFT", "PUPLACE_UPPER_RIGHT",
"PUPLACE_LOWER_LEFT", "PUPLACE_LOWER_RIGHT" } ;
while ( wid )
{
puObject *obj = wid->obj ;
int x, y, w, h ;
const char *hidden ;
const char *locked ;
const char *bool_one ;
const char *bool_two ;
const char *bool_three ;
obj->getPosition ( &x, &y ) ;
obj->getSize ( &w, &h ) ;
fprintf ( out, "\t<widget>\n\t\t<name>%s</name>\n", wid->object_name) ;
if (wid->legend_text != NULL)
fprintf ( out, "\t\t<legend>\n\t\t\t<text>%s</text>\n\t\t\t<pos>%s</pos>\n\t\t</legend>\n", wid->legend_text, place_name [ obj->getLegendPlace () ] ) ;
if (wid->label_text != NULL)
fprintf ( out, "\t\t<label>\n\t\t\t<text>%s</text>\n\t\t\t<pos>%s</pos>\n\t\t</label>\n", wid->label_text, place_name [ obj->getLabelPlace () ] ) ;
fprintf ( out, "\t\t<type>%s</type>\n", wid->object_type_name) ;
if ( !wid->visible )
hidden="FALSE";
else
hidden="TRUE";
if ( !wid->locked )
locked="FALSE";
else
locked="TRUE";
if ( wid->callbacks & CALLBACK_UP ) // Up-callback defined
fprintf ( out, "\t\t<callbacks>Up</callbacks>\n") ;
if ( wid->callbacks & CALLBACK_ACTIVE ) // Active callback defined
fprintf ( out, "\t\t<callbacks>Active</callbacks>\n") ;
if ( wid->callbacks & CALLBACK_DOWN ) // Down-callback defined
fprintf ( out, "\t\t<callbacks>Down</callbacks>\n") ;
if ( wid->callbacks == 0 )
fprintf ( out, "\t\t<callbacks></callbacks>\n") ;
fprintf ( out, "\t\t<layer>%d</layer>\n", wid->layer) ;
fprintf ( out, "\t\t<visible>%s</visible>\n", hidden) ;
fprintf ( out, "\t\t<locked>%s</locked>\n", locked) ;
fprintf ( out, "\t\t<size>\n\t\t\t<width>%d</width>\n\t\t\t<height>%d</height>\n\t\t</size>\n", w, h) ;
fprintf ( out, "\t\t<position>\n\t\t\t<x>%d</x>\n\t\t\t<y>%d</y>\n\t\t</position>\n", x, y) ;
fprintf ( out, "\t\t<data>\n\t\t\t<int1>%d</int1>\n\t\t\t<int2>%d</int2>\n", wid->intval1, wid->intval2) ;
if ( wid->boolval1 )
bool_one = "TRUE";
else
bool_one = "FALSE";
if ( wid->boolval2 )
bool_two = "TRUE";
else
bool_two = "FALSE";
if ( wid->boolval3 )
bool_three = "TRUE";
else
bool_three = "FALSE";
fprintf ( out, "\t\t\t<bool1>%s</bool1>\n\t\t\t<bool2>%s</bool2>\n\t\t\t<bool3>%s</bool3>\n", bool_one, bool_two, bool_three) ;
fprintf ( out, "\t\t\t<float1>%f</float1>\n\t\t\t<float2>%f</float2>\n", wid->floatval1, wid->floatval2) ;
fprintf ( out, "\t\t\t<float3>%f</float3>\n\t\t\t<float4>%f</float4>\n", wid->floatval3, wid->floatval4) ;
fprintf ( out, "\t\t\t<float5>%f</float5>\n\t\t\t<float6>%f</float6>\n", wid->floatval5, wid->floatval6) ;
if (wid->allowed)
fprintf ( out, "\t\t\t<allowed>%s</allowed>\n", wid->allowed) ;
/* Walk through the list of items, and make a seperate <items> entry for each line in the string */
if (wid->items)
{
char *temp_items = wid->items ;
char *cr = strchr(temp_items, '\n');
while ( cr != '\0' )
{
*cr = '\0';
fprintf ( out, "\t\t\t<item>%s</item>\n", temp_items);
*cr = '\n';
temp_items = cr + 1;
cr = strchr(temp_items, '\n');
}
if (wid->object_type == PUCLASS_ARROW)
{
fprintf ( out, "\t\t\t<item>%s</item>\n", temp_items);
}
}
fprintf ( out, "\t\t</data>\n\t</widget>\n") ;
wid = wid->next ;
}
fprintf ( out, "</objects>\n</savefile>\n") ; /* XML output done */
fclose (out) ;
}
/*static void gotoNextLine( char* buffer )
{
while (buffer != "\n")
buffer++ ;
}*/
void loadProject ( puObject *ob ) {
extern puInput *window_name ;
extern puInput *window_size_x ;
extern puInput *window_size_y ;
extern puInput *window_position_x ;
extern puInput *window_position_y ;
extern puaSpinBox *window_color_r ;
extern puaSpinBox *window_color_g ;
extern puaSpinBox *window_color_b ;
extern puaSpinBox *window_color_a ;
char* filename ;
file_selector -> getValue ( &filename ) ;
if (filename[0] == '\0')
{
puDeleteObject ( file_selector ) ;
file_selector = (puaFileSelector *)NULL ;
glutHideWindow () ;
glutSetWindow ( status_window ) ;
return ;
}
/* Save the new current directory */
strcpy(pguide_current_directory, filename) ;
int i = strlen(pguide_current_directory);
while (pguide_current_directory[i] != PATH_SEPARATOR) {
if (i>0) i-- ;
else break ;
}
pguide_current_directory[i+1] = '\0' ;
FILE *in = fopen ( filename, "rt" ) ;
if ( !in )
printf ( "ERROR opening file <%s> for reading\n", filename ) ;
puDeleteObject ( file_selector ) ;
file_selector = (puaFileSelector *)NULL ;
glutHideWindow () ;
glutSetWindow ( status_window ) ;
if ( !in ) return ;
char rawbuffer[2048];
// Verify file is XML
float tver = 0.0f ;
char encversion[PUSTRING_MAX];
fgets( rawbuffer, sizeof(rawbuffer), in) ;
sscanf(rawbuffer,"<?xml version=\"%f\" encoding=\"%s\" ?>", &tver, encversion) ;
if (!tver) {
printf ("File does not contain proper XML headings.\n");
return ;
}
// Verify file is P-Guide
char tag[PUSTRING_MAX] ;
char tagvalue[PUSTRING_MAX] ;
fgets( rawbuffer, sizeof(rawbuffer), in) ;
if (!sscanf(rawbuffer,"<!DOCTYPE %s>", tag)) {
printf ("File, though XML, does not contain P-Guide information (or has damaged header information).\n");
return ;
}
// Start reading XML
main_window_changed = true ;
currently_loading = true ;
int groupid = 0 ;
puObject *new_obj = NULL;
WidgetList *new_wid = NULL ;
/* Dandy little variables */
int wid_val_y = 0, wid_val_x = 0, val_object_width = 20, val_object_height = 20, val_label_place = 4, val_legend_place = 8;
int intval1 = 0, intval2 = 0 ;
bool boolval1 = false, boolval2 = false, boolval3 = false ;
float floatval1 = 0.0f, floatval2 = 0.0f, floatval3 = 0.0f, floatval4 = 0.0f, floatval5 = 0.0f, floatval6 = 0.0f;
while(fgets( rawbuffer, sizeof(rawbuffer), in))
{
/**************************************************************/
/* Key for Groups in our XML file located at top of this file */
/**************************************************************/
*tag = '\0';
*tagvalue = '\0';
char *buffer = rawbuffer;
/* From here on we walk, line by line, through the XML and parse any tags we come to. */
while (*buffer == '\t' || *buffer == ' ') /* Ignore the tabs and spaces */
buffer++ ;
sscanf(buffer,"<%[^>]>", tag); /* Get the tag */
while (*buffer !='>') buffer++;
sscanf(buffer,">%[a-zA-Z_!@#$^&*0123456789-+/\\{}()=~`,. ]</", tagvalue) ; /* Get the tag's value. */
/* Classify the tag, so we know where the next will fit. */
if ( strstr(tag,"savefile") ) groupid |= TAG_SAVEFILE ;
if ( strstr(tag,"window") ) groupid |= TAG_WINDOW ;
if ( strstr(tag,"size") ) groupid |= TAG_SIZE ;
if ( strstr(tag,"position") ) groupid |= TAG_POSITION ;
if ( strstr(tag,"color") ) groupid |= TAG_COLOR ;
if ( strstr(tag,"object") ) groupid |= TAG_OBJECT ;
if ( strstr(tag,"widget") ) groupid |= TAG_WIDGET ;
if ( strstr(tag,"legend") ) groupid |= TAG_LEGEND ;
if ( strstr(tag,"label") ) groupid |= TAG_LABEL ;
if ( strstr(tag,"data") ) groupid |= TAG_DATA ;
/* Note: Order here matters, since the strstrs above WILL match closing tags. This */
/* doesn't hurt anything, as long as we remove the bitset when we realize they are */
/* close tags, not open ones. */
/* De-classify the tag, so we know where it doesn't fit. */
if ( strstr(tag,"/savefile") ) groupid ^= TAG_SAVEFILE ;
if ( strstr(tag,"/window") ) groupid ^= TAG_WINDOW ;
if ( strstr(tag,"/size") ) groupid ^= TAG_SIZE ;
if ( strstr(tag,"/position") ) groupid ^= TAG_POSITION ;
if ( strstr(tag,"/color") ) groupid ^= TAG_COLOR ;
if ( strstr(tag,"/object") ) groupid ^= TAG_OBJECT ;
if ( strstr(tag,"/widget") ) groupid ^= TAG_WIDGET ;
if ( strstr(tag,"/legend") ) groupid ^= TAG_LEGEND ;
if ( strstr(tag,"/label") ) groupid ^= TAG_LABEL ;
if ( strstr(tag,"/data") ) groupid ^= TAG_DATA ;
/* Now that the tag's classifcation has been determined, rip the data */
/* viciously from its' hold and throw it onto the memory stack. */
if (groupid & TAG_SAVEFILE )
{
/* NULLCHECK! */
if (tagvalue[0] == '\0') { sprintf(tagvalue, " "); }
if ( strstr(tag,"autolock") )
{
if (strstr(tagvalue, "TRUE"))
autolock = true ;
else
autolock = false ;
}
if (groupid & TAG_WINDOW)
{
if ( strstr(tag,"name") )
{
window_name->setValue(tagvalue) ;
strcpy(main_window_name, tagvalue);
}
if (groupid & TAG_SIZE)
{
if ( strstr(tag,"width") )
window_size_x->setValue(tagvalue) ;
if ( strstr(tag,"height") )
window_size_y->setValue(tagvalue) ;
}
if (groupid & TAG_POSITION)
{
if ( strstr(tag,"x") )
window_position_x->setValue(tagvalue) ;
if ( strstr(tag,"y") )
window_position_y->setValue(tagvalue) ;
}
if (groupid & TAG_COLOR)
{
if ( strstr(tag,"r") )
window_color_r->setValue(tagvalue) ;
if ( strstr(tag,"g") )
window_color_g->setValue(tagvalue) ;
if ( strstr(tag,"b") )
window_color_b->setValue(tagvalue) ;
if ( strstr(tag,"a") )
window_color_a->setValue(tagvalue) ;
}
}
if (groupid & TAG_OBJECT)
{
if ( strstr(tag,"/widget") )
{
extern WidgetList *widgets ;
/* Create a new frame in the viewing window (for manipulation). */
new_obj = new puFrame ( 0, 0, val_object_width, val_object_height ) ;
new_obj->setWindow( main_window ) ;
/* Set the representative widget's position */
new_obj->setPosition ( wid_val_x, wid_val_y ) ;
new_obj->setLegend ( new_wid->object_type_name ) ;
new_obj->setLegendPlace ( val_legend_place ) ;
if (new_wid->label_text)
{
new_obj->setLabel ( new_wid->label_text ) ;
new_obj->setLabelPlace ( val_label_place ) ; /**/
}
new_wid->boolval1 = boolval1;
new_wid->boolval2 = boolval2;
new_wid->boolval3 = boolval3;
new_wid->intval1 = intval1;
new_wid->intval2 = intval2;
new_wid->floatval1 = floatval1;
new_wid->floatval2 = floatval2;
new_wid->floatval3 = floatval3;
new_wid->floatval4 = floatval4;
new_wid->floatval5 = floatval5;
new_wid->floatval6 = floatval6;
intval1 = intval2 = 0 ;
boolval1 = boolval2 = boolval3 = false ;
floatval1 = floatval2 = floatval3 = floatval4 = floatval5 = floatval6 = 0.0f;
new_wid->obj = new_obj ;
new_wid->next = widgets ;
widgets = new_wid ;
} else if ( strstr(tag,"widget") ) {
/* Add the new object to the list of widgets (for the builder itself) */
new_wid = new WidgetList ;
/* Set those dandy variables */
wid_val_y = 0; wid_val_x = 0;
val_object_width = 20; val_object_height = 20;
val_label_place = 4; val_legend_place = 8;
new_wid->callbacks = 0;
new_wid->allowed = (char *)NULL ;
new_wid->items = (char *)NULL ;
new_wid->locked = false;
new_wid->legend_text = NULL ;
new_wid->label_text = NULL ;
}
if (groupid & TAG_WIDGET)
{
if ( strstr(tag,"name") )
{
strcpy(new_wid->object_name, tagvalue) ;
/* As names are copied, look for defaults (widget0..9999), */
/* and if it's higher than the current widget_number, set */
/* widget_number to it. */
int tmp_wid_num = 0;
sscanf(tagvalue, "widget%d", &tmp_wid_num) ;
if (tmp_wid_num >= widget_number) widget_number = tmp_wid_num + 1;
}
if ( strstr(tag,"type") )
{
new_wid->object_type = 0 ;
new_wid->object_type_name = new char [strlen(tagvalue)+1] ;
strcpy(new_wid->object_type_name, tagvalue) ;
/* BEWARE: Popup[menu], BiSlider[WithEnds], and Button[box] want to be each other! Don't let them! */
if ( strstr(new_wid->object_type_name, "puaList")) new_wid->object_type |= PUCLASS_LIST ;
if ( strstr(new_wid->object_type_name, "puaChooser")) new_wid->object_type |= PUCLASS_CHOOSER ;
if ( strstr(new_wid->object_type_name, "puaSliderWithInput")) new_wid->object_type |= PUCLASS_SLIDERWITHINPUT ;
if ( strstr(new_wid->object_type_name, "puaBiSliderWithEnds")) new_wid->object_type |= PUCLASS_BISLIDERWITHENDS ;
else if ( strstr(new_wid->object_type_name, "puaBiSlider")) new_wid->object_type |= PUCLASS_BISLIDER ;
if ( strstr(new_wid->object_type_name, "puaScrollBar")) new_wid->object_type |= PUCLASS_SCROLLBAR ;
if ( strstr(new_wid->object_type_name, "puaSpinBox")) new_wid->object_type |= PUCLASS_SPINBOX ; /**/
if ( strstr(new_wid->object_type_name, "puaSelectBox")) new_wid->object_type |= PUCLASS_SELECTBOX ;
if ( strstr(new_wid->object_type_name, "puaComboBox")) new_wid->object_type |= PUCLASS_COMBOBOX ;
if ( strstr(new_wid->object_type_name, "puaLargeInput")) new_wid->object_type |= PUCLASS_LARGEINPUT ;
if ( strstr(new_wid->object_type_name, "puaVerticalMenu")) new_wid->object_type |= PUCLASS_VERTMENU ;
if ( strstr(new_wid->object_type_name, "puaTriSlider")) new_wid->object_type |= PUCLASS_TRISLIDER ;
if ( strstr(new_wid->object_type_name, "puaFileSelector")) new_wid->object_type |= PUCLASS_FILESELECTOR ;
if ( strstr(new_wid->object_type_name, "puDial")) new_wid->object_type |= PUCLASS_DIAL ;
if ( strstr(new_wid->object_type_name, "puListBox")) new_wid->object_type |= PUCLASS_LISTBOX ;
if ( strstr(new_wid->object_type_name, "puArrowButton")) new_wid->object_type |= PUCLASS_ARROW ;
if ( strstr(new_wid->object_type_name, "puDialogBox")) new_wid->object_type |= PUCLASS_DIALOGBOX ; /**/
if ( strstr(new_wid->object_type_name, "puSlider")) new_wid->object_type |= PUCLASS_SLIDER ;
if ( strstr(new_wid->object_type_name, "puButtonBox")) new_wid->object_type |= PUCLASS_BUTTONBOX ;
else if ( strstr(new_wid->object_type_name, "puButton")) new_wid->object_type |= PUCLASS_BUTTON ; /* See above for why the elses' */
if ( strstr(new_wid->object_type_name, "puInput")) new_wid->object_type |= PUCLASS_INPUT ;
if ( strstr(new_wid->object_type_name, "puMenuBar")) new_wid->object_type |= PUCLASS_MENUBAR ;
if ( strstr(new_wid->object_type_name, "puPopupMenu")) new_wid->object_type |= PUCLASS_POPUPMENU ; /**/
else if ( strstr(new_wid->object_type_name, "puPopup")) new_wid->object_type |= PUCLASS_POPUP ; /**/
if ( strstr(new_wid->object_type_name, "puOneShot")) new_wid->object_type |= PUCLASS_ONESHOT ;
if ( strstr(new_wid->object_type_name, "puText")) new_wid->object_type |= PUCLASS_TEXT ;
if ( strstr(new_wid->object_type_name, "puFrame")) new_wid->object_type |= PUCLASS_FRAME ;
}
if ( strstr(tag,"callbacks") )
{
/* Update callback's bit set */
if (strstr(tagvalue, "Up")) new_wid->callbacks |= CALLBACK_UP ;
if (strstr(tagvalue, "Down")) new_wid->callbacks |= CALLBACK_DOWN ;
if (strstr(tagvalue, "Active")) new_wid->callbacks |= CALLBACK_ACTIVE ;
}
if ( strstr(tag,"layer") )
{
new_wid->layer = atoi(tagvalue) ;
if ( max_layer <= new_wid->layer ) max_layer = new_wid->layer + 1 ;
}
if ( strstr(tag,"visible") )
{
if (strstr(tagvalue, "TRUE"))
new_wid->visible = true ;
else
new_wid->visible = false ;
}
if ( strstr(tag,"locked") )
{
if (strstr(tagvalue, "TRUE"))
new_wid->locked = true ;
else
new_wid->locked = false ;
}
if (groupid & TAG_LEGEND)
{
if ( strstr(tag,"text") )
{
delete new_wid->legend_text;
new_wid->legend_text = new char [strlen(tagvalue)+1] ;
strcpy(new_wid->legend_text, tagvalue) ;
}
if ( strstr(tag,"pos") )
{
if (strstr(tagvalue, "PUPLACE_TOP_LEFT")) val_legend_place = PUPLACE_TOP_LEFT ;
if (strstr(tagvalue, "PUPLACE_TOP_CENTERED")) val_legend_place = PUPLACE_TOP_CENTERED ;
if (strstr(tagvalue, "PUPLACE_TOP_RIGHT")) val_legend_place = PUPLACE_TOP_RIGHT ;
if (strstr(tagvalue, "PUPLACE_CENTERED_LEFT")) val_legend_place = PUPLACE_CENTERED_LEFT ;
if (strstr(tagvalue, "PUPLACE_CENTERED_RIGHT")) val_legend_place = PUPLACE_CENTERED_RIGHT ;
if (strstr(tagvalue, "PUPLACE_BOTTOM_LEFT")) val_legend_place = PUPLACE_BOTTOM_LEFT ;
if (strstr(tagvalue, "PUPLACE_BOTTOM_CENTERED")) val_legend_place = PUPLACE_BOTTOM_CENTERED ;
if (strstr(tagvalue, "PUPLACE_BOTTOM_RIGHT")) val_legend_place = PUPLACE_BOTTOM_RIGHT ;
if (strstr(tagvalue, "PUPLACE_CENTERED_CENTERED")) val_legend_place = PUPLACE_CENTERED_CENTERED ;
}
}
if (groupid & TAG_LABEL)
{
if ( strstr(tag,"text") )
{
delete new_wid->label_text;
new_wid->label_text = new char [strlen(tagvalue)+1] ;
strcpy(new_wid->label_text, tagvalue) ;
}
if ( strstr(tag,"pos") )
{
if (strstr(tagvalue, "PUPLACE_TOP_LEFT")) val_label_place = PUPLACE_TOP_LEFT ;
if (strstr(tagvalue, "PUPLACE_TOP_CENTERED")) val_label_place = PUPLACE_TOP_CENTERED ;
if (strstr(tagvalue, "PUPLACE_TOP_RIGHT")) val_label_place = PUPLACE_TOP_RIGHT ;
if (strstr(tagvalue, "PUPLACE_CENTERED_LEFT")) val_label_place = PUPLACE_CENTERED_LEFT ;
if (strstr(tagvalue, "PUPLACE_CENTERED_RIGHT")) val_label_place = PUPLACE_CENTERED_RIGHT ;
if (strstr(tagvalue, "PUPLACE_BOTTOM_LEFT")) val_label_place = PUPLACE_BOTTOM_LEFT ;
if (strstr(tagvalue, "PUPLACE_BOTTOM_CENTERED")) val_label_place = PUPLACE_BOTTOM_CENTERED ;
if (strstr(tagvalue, "PUPLACE_BOTTOM_RIGHT")) val_label_place = PUPLACE_BOTTOM_RIGHT ;
if (strstr(tagvalue, "PUPLACE_ABOVE_LEFT")) val_label_place = PUPLACE_ABOVE_LEFT ;
if (strstr(tagvalue, "PUPLACE_ABOVE_RIGHT")) val_label_place = PUPLACE_ABOVE_RIGHT ;
if (strstr(tagvalue, "PUPLACE_BELOW_LEFT")) val_label_place = PUPLACE_BELOW_LEFT ;
if (strstr(tagvalue, "PUPLACE_BELOW_RIGHT")) val_label_place = PUPLACE_BELOW_RIGHT ;
if (strstr(tagvalue, "PUPLACE_UPPER_LEFT")) val_label_place = PUPLACE_UPPER_LEFT ;
if (strstr(tagvalue, "PUPLACE_UPPER_RIGHT")) val_label_place = PUPLACE_UPPER_RIGHT ;
if (strstr(tagvalue, "PUPLACE_LOWER_LEFT")) val_label_place = PUPLACE_LOWER_LEFT ;
if (strstr(tagvalue, "PUPLACE_LOWER_RIGHT")) val_label_place = PUPLACE_LOWER_RIGHT ;
}
}
if (groupid & TAG_SIZE)
{
if ( strstr(tag,"width") )
val_object_width = atoi(tagvalue) ;
if ( strstr(tag,"height") )
val_object_height = atoi(tagvalue) ;
}
if (groupid & TAG_POSITION)
{
if ( strstr(tag,"x") )
wid_val_x = atoi(tagvalue) ;
if ( strstr(tag,"y") )
wid_val_y = atoi(tagvalue) ;
}
if (groupid & TAG_DATA)
{
if ( strstr(tag,"int1") )
intval1 = atoi (tagvalue) ;
if ( strstr(tag,"int2") )
intval2 = atoi (tagvalue) ;
if ( strstr(tag,"bool1") )
{
if (strstr(tagvalue, "TRUE"))
boolval1 = true ;
else
boolval1 = false ;
}
if ( strstr(tag,"bool2") )
{
if (strstr(tagvalue, "TRUE"))
boolval2 = true ;
else
boolval2 = false ;
}
if ( strstr(tag,"bool3") )
{
if (strstr(tagvalue, "TRUE"))
boolval3 = true ;
else
boolval3 = false ;
}
if ( strstr(tag,"float1") )
floatval1 = (float)atof (tagvalue) ;
if ( strstr(tag,"float2") )
floatval2 = (float)atof (tagvalue) ;
if ( strstr(tag,"float3") )
floatval3 = (float)atof (tagvalue) ;
if ( strstr(tag,"float4") )
floatval4 = (float)atof (tagvalue) ;
if ( strstr(tag,"float5") )
floatval5 = (float)atof (tagvalue) ;
if ( strstr(tag,"float6") )
floatval6 = (float)atof (tagvalue) ;
if ( strstr(tag,"allowed") )
{
new_wid->allowed = new char [strlen(tagvalue)+1] ;
strcpy(new_wid->allowed, tagvalue) ;
}
if ( strstr(tag,"item") )
{
strcat(tagvalue, "\n");
if (!new_wid->items)
{
new_wid->items = new char [1024] ;
strcpy(new_wid->items, tagvalue) ;
}
else
strcat(new_wid->items, tagvalue) ;
}
}
}
}
}
if (strstr(tag, "/savefile"))
{
static int mouse_x ;
static int mouse_y ;
setStatusWidgets( new_wid );
glutSetWindow ( main_window ) ;
glutSetWindowTitle ( window_name->getStringValue() ) ;
/* Fake out the Reshape parts that determine whether to move widgets around or not. */
mouse_x = 999 ;
mouse_y = 999 ;
glutReshapeWindow ( window_size_x->getValue(), window_size_y->getValue() ) ;
glutSetWindow ( status_window ) ;
}
buffer[0] = '\0';
}
fclose (in);
WidgetList *wid = widgets;
/* Check name for duplication */
nextwid = wid; /* Note: Yes, this is inelegant, but if we loop here, we end up making many copies of the same dialog box in the same memory space. This is a Bad Thing. */
chk_dupname(nextwid);
/* Done checking name for duplication */
}
static void chk_dupname_ok_cb ( puObject *ob )
{
/* The user's new name from the dialog has already been set to the object_name*/
/* Close dialogbox and update main window ...*/
puDeleteObject ( dup_dialog ) ;
dup_dialog = (puDialogBox *)NULL ;
dup_newname = (puInput *)NULL ;
/*but force a recheck afterwards to ensure it's an okay substitution. */
nextwid = nextwid->next ;
chk_dupname(nextwid);
}
static void chk_dupname ( WidgetList *new_wid )
{
if (!new_wid)
return;
WidgetList *wid = widgets ;
while ( wid )
{
if ( (strcmp(new_wid->object_name,wid->object_name) == 0) && (new_wid != wid) )
{
/* Popup a dialog telling user something's bad! */
dup_dialog = new puDialogBox ( 20, 20 ) ;
new puFrame ( 0, 0, 460, 120 ) ;
puText *text = new puText ( 80, 85 ) ;
text->setLabel ( "ERROR: Name already used." ) ;
text->setLabelFont(PUFONT_TIMES_ROMAN_24);
puText *directions = new puText ( 90, 65 ) ;
directions->setLabel ( "Please type in a new, unique name to continue." ) ;
directions->setLabelFont(PUFONT_HELVETICA_12);
dup_newname = new puInput (20,40,440,60) ;
dup_newname->setValuator(new_wid->object_name);
dup_newname->setValidData("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_012345679");
puOneShot *ok = new puOneShot ( 200, 10, "Accept" ) ;
ok->setCallback ( chk_dupname_ok_cb ) ;
dup_dialog->close () ;
dup_dialog->reveal () ;
break ;
}
wid = wid->next ;
}
}
+9
View File
@@ -0,0 +1,9 @@
bin_PROGRAMS = pguide
pguide_SOURCES = pGuide.cxx StatusWindow.cxx WidgetList.h \
WidgetWindow.cxx WriteCode.cxx LoadSave.cxx PropertiesWindow.cxx
pguide_LDADD = -lplibpuaux
EXTRA_DIST = pGuide.dsp
+610
View File
@@ -0,0 +1,610 @@
/*
This file is part of P-GUIDE -
PUI-based Graphical User Interface Designer.
Copyright (C) 2002, 2006 John F. Fay
P-GUIDE 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.
P-GUIDE 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 P-GUIDE; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
$Id: PropertiesWindow.cxx 2100 2006-11-03 22:31:54Z fayjf $
*/
// Status Window
#include <plib/pu.h>
#include "WidgetList.h"
// From the Main Window:
extern int max_layer ;
extern WidgetList *active_widget ;
extern puObject *active_object ;
extern char pguide_current_directory [ PUSTRING_MAX ] ;
extern bool main_window_changed ;
// Status window parameters
int properties_window = 0 ; // Window handle
extern int main_window ;
// Status window widgets
puGroup *properties_group ;
// Function to set the widgets from the active object
// GLUT Status Window Callbacks
static void properties_window_specialfn ( int key, int, int )
{
puKeyboard ( key + PU_KEY_GLUT_SPECIAL_OFFSET, PU_DOWN ) ;
glutPostRedisplay () ;
}
static void properties_window_keyfn ( unsigned char key, int, int )
{
puKeyboard ( key, PU_DOWN ) ;
glutPostRedisplay () ;
}
static void properties_window_motionfn ( int x, int y )
{
puMouse ( x, y ) ;
glutPostRedisplay () ;
}
static void properties_window_mousefn ( int button, int updown, int x, int y )
{
puMouse ( button, updown, x, y ) ;
glutPostRedisplay () ;
}
static void properties_window_displayfn ( void )
{
glutSetWindow ( properties_window ) ;
/* Clear the screen */
glClearColor ( 0.1f, 0.1f, 0.1f, 1.0f ) ;
glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) ;
puDisplay () ;
/* Update GLUT */
glutSwapBuffers () ;
glutPostRedisplay () ;
}
// PUI Callback Functions:
static void cb_properties_close (puObject *obj)
{
/* Save the changes ... Needed? */
if ( puActiveWidget() )
puActiveWidget() -> invokeDownCallback () ; /* Just make sure the last widget saves ... */
/* Delete the widgets */
puDeleteObject( properties_group );
/* Destroy the window */
glutDestroyWindow( properties_window );
properties_window = 0;
glutSetWindow( main_window );
}
// Data setting standard callbacks
static void cb_items (puObject *obj)
{
/*Set the Items*/
if (active_widget)
{
delete active_widget->items;
active_widget->items = new char [strlen(obj->getStringValue())+1] ;
strcpy(active_widget->items, obj->getStringValue());
}
}
static void cb_allowed (puObject *obj)
{
/*Set the Allowed string*/
if (active_widget)
{
delete active_widget->allowed;
active_widget->allowed = new char [strlen(obj->getStringValue())+1] ;
strcpy(active_widget->allowed, obj->getStringValue());
}
}
static void cb_int1 (puObject *obj)
{
/*Set the first integer storage value */
if (active_widget)
active_widget->intval1 = obj->getIntegerValue();
}
static void cb_int2 (puObject *obj)
{
/*Set the second integer storage value */
if (active_widget)
active_widget->intval2 = obj->getIntegerValue();
}
static void cb_bool1 (puObject *obj)
{
/*Set the first boolean storage value */
if (active_widget)
{
if (obj->getIntegerValue() == 1)
active_widget->boolval1 = true ;
else
active_widget->boolval1 = false ;
}
}
static void cb_bool2 (puObject *obj)
{
/*Set the second boolean storage value */
if (active_widget)
{
if (obj->getIntegerValue() == 1)
active_widget->boolval2 = true ;
else
active_widget->boolval2 = false ;
}
}
static void cb_bool3 (puObject *obj)
{
/*Set the second boolean storage value */
if (active_widget)
{
if (obj->getIntegerValue() == 1)
active_widget->boolval3 = true ;
else
active_widget->boolval3 = false ;
}
}
static void cb_float1 (puObject *obj)
{
/*Set the first floating storage value */
if (active_widget)
active_widget->floatval1 = obj->getFloatValue();
}
static void cb_float2 (puObject *obj)
{
/*Set the first floating storage value */
if (active_widget)
active_widget->floatval2 = obj->getFloatValue();
}
static void cb_float3 (puObject *obj)
{
/*Set the first floating storage value */
if (active_widget)
active_widget->floatval3 = obj->getFloatValue();
}
static void cb_float4 (puObject *obj)
{
/*Set the first floating storage value */
if (active_widget)
active_widget->floatval4 = obj->getFloatValue();
}
static void cb_float5 (puObject *obj)
{
/*Set the first floating storage value */
if (active_widget)
active_widget->floatval5 = obj->getFloatValue();
}
static void cb_float6 (puObject *obj)
{
/*Set the first floating storage value */
if (active_widget)
active_widget->floatval6 = obj->getFloatValue();
}
// Function to define the window
int define_properties_window ()
{
properties_window = glutCreateWindow ( "Properties" ) ;
glutPositionWindow ( 400, 200 ) ;
glutReshapeWindow ( 500, 250 ) ;
glutDisplayFunc ( properties_window_displayfn ) ;
glutKeyboardFunc ( properties_window_keyfn ) ;
glutSpecialFunc ( properties_window_specialfn ) ;
glutMotionFunc ( properties_window_motionfn ) ;
glutMouseFunc ( properties_window_mousefn ) ;
// Set up the widgets
properties_group = new puGroup ( 0, 0 ) ;
new puFrame ( 0, 0, 500, 250 ) ;
puText *properties_instructions = new puText ( 250, 230 );
properties_instructions->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_instructions->setLabel("Here are the extended options for your");
puText *properties_typelabel = new puText ( 250, 215 );
properties_typelabel->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_typelabel->setLabel(active_widget->object_type_name);
puOneShot *properties_close = new puOneShot ( 370, 10, 490, 30 ) ;
properties_close->setLegend("Accept");
properties_close->setCallback(cb_properties_close);
/* puStyle stuff here*/
/* Now customize the display based on the widget currently selected */
if (active_widget->object_type == PUCLASS_FRAME)
{
puText *properties_nooptions = new puText (25, 100 );
properties_nooptions->setLabelPlace(PUPLACE_CENTERED_RIGHT);
properties_nooptions->setLabel("There are no options for a puFrame.");
} if (active_widget->object_type == PUCLASS_TEXT)
{
/* Add in font properties? */
puText *properties_nooptions = new puText (25, 100 );
properties_nooptions->setLabelPlace(PUPLACE_CENTERED_RIGHT);
properties_nooptions->setLabel("There are no options for puText.");
} if (active_widget->object_type == PUCLASS_BUTTON)
{
puText *properties_nooptions = new puText (25, 100 );
properties_nooptions->setLabelPlace(PUPLACE_CENTERED_RIGHT);
properties_nooptions->setLabel("There are no options for puButton.");
} if (active_widget->object_type == PUCLASS_ONESHOT)
{
puText *properties_nooptions = new puText (25, 100 );
properties_nooptions->setLabelPlace(PUPLACE_CENTERED_RIGHT);
properties_nooptions->setLabel("There are no options for puOneShot.");
} if ( (active_widget->object_type == PUCLASS_POPUPMENU) ||
(active_widget->object_type == PUCLASS_MENUBAR) ||
(active_widget->object_type == PUCLASS_VERTMENU) ||
(active_widget->object_type == PUCLASS_LISTBOX) ||
(active_widget->object_type == PUCLASS_COMBOBOX) ||
(active_widget->object_type == PUCLASS_SELECTBOX) ||
(active_widget->object_type == PUCLASS_BUTTONBOX) ||
(active_widget->object_type == PUCLASS_LIST) )
{
/* List */
puaLargeInput *properties_list_items = new puaLargeInput(10,10,300,195,0,5);
properties_list_items->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_list_items->setLabel("Enter items, each on a new line.");
properties_list_items->setValidData("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_012345679 :;.,\n");
properties_list_items->setCallback(cb_items);
properties_list_items->setDownCallback(cb_items);
properties_list_items->setValue(active_widget->items);
puText *properties_list_note = new puText(400,190);
properties_list_note->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_list_note->setLabel("Each line will become");
puText *properties_list_note2 = new puText(400,175);
properties_list_note2->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_list_note2->setLabel("a selection option.");
} if (active_widget->object_type == PUCLASS_POPUPMENU)
{
/* Allow a list of menu items, and remember to point out these are hidden when created, and must be reveal()ed. */
/* NOT CURRENTLY IMPLEMENTED */
puText *properties_popupmenu_warning = new puText(400,150);
properties_popupmenu_warning->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_popupmenu_warning->setLabel("WARNING: Popup Menus are hidden by \
default when created. You must use \
reveal() to make them appear.");
} if (active_widget->object_type == PUCLASS_MENUBAR)
{
/* Allow a list of menu items */
} if (active_widget->object_type == PUCLASS_VERTMENU)
{
/* Allow a list of menu items */
} if (active_widget->object_type == PUCLASS_LISTBOX)
{
/* Allow a list of items */
} if (active_widget->object_type == PUCLASS_COMBOBOX)
{
/* List and a setCurrentItem, and if editable */
puaSpinBox *properties_combobox_currentitem = new puaSpinBox(320,135,480,155);
properties_combobox_currentitem->setLabel("Initial Selection:");
properties_combobox_currentitem->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_combobox_currentitem->setMinValue(0.0f);
properties_combobox_currentitem->setMaxValue(30.0f);
properties_combobox_currentitem->setCallback(cb_int1);
properties_combobox_currentitem->setValue(active_widget->intval1);
static char *properties_combobox_editable_callback_entries [] = { "No", "Yes", NULL } ;
puButtonBox *properties_combobox_editable = new puButtonBox(320, 50, 480, 120, properties_combobox_editable_callback_entries, TRUE);
properties_combobox_editable->setLabel("Editable?");
properties_combobox_editable->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_combobox_editable->setCallback(cb_bool1);
properties_combobox_editable->setValue(active_widget->boolval1);
} if (active_widget->object_type == PUCLASS_SELECTBOX)
{
/* List and a setCurrentItem */
puaSpinBox *properties_selectbox_currentitem = new puaSpinBox(320,135,480,155);
properties_selectbox_currentitem->setLabel("Initial Selection:");
properties_selectbox_currentitem->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_selectbox_currentitem->setMinValue(0.0f);
properties_selectbox_currentitem->setMaxValue(30.0f);
properties_selectbox_currentitem->setCallback(cb_int1);
properties_selectbox_currentitem->setValue(active_widget->intval1);
} if (active_widget->object_type == PUCLASS_BUTTONBOX)
{
/* Allow a list of menu items, and if multiple can be selected at once */
puText *properties_buttonbox_label = new puText(400,135);
properties_buttonbox_label->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_buttonbox_label->setLabel("Allow multiple");
static char *properties_buttonbox_multiselect_callback_entries [] = { "No", "Yes", NULL } ;
puButtonBox *properties_buttonbox_multiselect = new puButtonBox(320, 50, 480, 120, properties_buttonbox_multiselect_callback_entries, TRUE);
properties_buttonbox_multiselect->setLabel("selections?");
properties_buttonbox_multiselect->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_buttonbox_multiselect->setCallback(cb_bool1);
properties_buttonbox_multiselect->setValue(active_widget->boolval1);
} if ( (active_widget->object_type == PUCLASS_SLIDER ) ||
(active_widget->object_type == PUCLASS_BISLIDER ) ||
(active_widget->object_type == PUCLASS_TRISLIDER ) ||
(active_widget->object_type == PUCLASS_DIAL ) ||
(active_widget->object_type == PUCLASS_SPINBOX ) ||
(active_widget->object_type == PUCLASS_SCROLLBAR ) ||
(active_widget->object_type == PUCLASS_SLIDERWITHINPUT ) ||
(active_widget->object_type == PUCLASS_BISLIDERWITHENDS ))
{
/* int minx, int miny, int sz, {TRUE|FALSE}, int width */
puaSpinBox *properties_range_setmaxvalue = new puaSpinBox(30,150,110,170);
properties_range_setmaxvalue->setLabel("Maximum Value:");
properties_range_setmaxvalue->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_range_setmaxvalue->setMinValue(-5000.0f);
properties_range_setmaxvalue->setMaxValue(5000.0f);
properties_range_setmaxvalue->setCallback(cb_float1);
properties_range_setmaxvalue->setValue(active_widget->floatval1);
puaSpinBox *properties_range_setminvalue = new puaSpinBox(230,150,310,170);
properties_range_setminvalue->setLabel("Minimum Value:");
properties_range_setminvalue->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_range_setminvalue->setMinValue(-5000.0f);
properties_range_setminvalue->setMaxValue(5000.0f);
properties_range_setminvalue->setCallback(cb_float2);
properties_range_setminvalue->setValue(active_widget->floatval2);
puaSpinBox *properties_range_setstepvalue = new puaSpinBox(400,150,480,170);
properties_range_setstepvalue->setLabel("Step Size:");
properties_range_setstepvalue->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_range_setstepvalue->setMinValue(0.0f);
properties_range_setstepvalue->setMaxValue(5000.0f);
properties_range_setstepvalue->setCallback(cb_float3);
properties_range_setstepvalue->setValue(active_widget->floatval3);
static char *properties_range_cbmode_callback_entries [] = { "On Click", "Always", NULL } ;
puButtonBox *properties_range_cbmode = new puButtonBox(20, 80, 170, 130, properties_range_cbmode_callback_entries, TRUE);
properties_range_cbmode->setLabel("Callback Mode:");
properties_range_cbmode->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_range_cbmode->setCallback(cb_bool1);
properties_range_cbmode->setValue(active_widget->boolval1);
} if ( (active_widget->object_type == PUCLASS_SLIDER ) ||
(active_widget->object_type == PUCLASS_BISLIDER ) ||
(active_widget->object_type == PUCLASS_TRISLIDER ) ||
(active_widget->object_type == PUCLASS_SCROLLBAR ) )
{
static char *properties_range_vertical_callback_entries [] = { "Horizontal", "Vertical", NULL } ;
puButtonBox *properties_range_vertical = new puButtonBox(20, 10, 170, 60, properties_range_vertical_callback_entries, TRUE);
properties_range_vertical->setLabel("Orientation:");
properties_range_vertical->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_range_vertical->setValue(active_widget->boolval2);
properties_range_vertical->setCallback(cb_bool2);
} if (active_widget->object_type == PUCLASS_SLIDER)
{
puaSpinBox *properties_slider_value = new puaSpinBox(230,110,310,130);
properties_slider_value->setLabel("Starting Value:");
properties_slider_value->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_slider_value->setMinValue(-5000.0f);
properties_slider_value->setMaxValue(5000.0f);
properties_slider_value->setValue(active_widget->floatval4);
properties_slider_value->setStepSize(0.1f);
properties_slider_value->setCallback(cb_float4);
} if ((active_widget->object_type == PUCLASS_BISLIDER) ||
(active_widget->object_type == PUCLASS_BISLIDERWITHENDS))
{
puaSpinBox *properties_bislider_topvalue = new puaSpinBox(230,110,310,130);
properties_bislider_topvalue->setLabel("Top Slider Value:");
properties_bislider_topvalue->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_bislider_topvalue->setMinValue(-5000.0f);
properties_bislider_topvalue->setMaxValue(5000.0f);
properties_bislider_topvalue->setValue(active_widget->floatval4);
properties_bislider_topvalue->setStepSize(0.1f);
properties_bislider_topvalue->setCallback(cb_float4);
puaSpinBox *properties_bislider_botvalue = new puaSpinBox(230,40,310,60);
properties_bislider_botvalue->setLabel("Bottom Slider Value:");
properties_bislider_botvalue->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_bislider_botvalue->setMinValue(-5000.0f);
properties_bislider_botvalue->setMaxValue(5000.0f);
properties_bislider_botvalue->setValue(active_widget->floatval5);
properties_bislider_botvalue->setStepSize(0.1f);
properties_bislider_botvalue->setCallback(cb_float5);
} if (active_widget->object_type == PUCLASS_TRISLIDER)
{
puaSpinBox *properties_trislider_topvalue = new puaSpinBox(230,110,310,130);
properties_trislider_topvalue->setLabel("Top Slider Value:");
properties_trislider_topvalue->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_trislider_topvalue->setMinValue(-5000.0f);
properties_trislider_topvalue->setMaxValue(5000.0f);
properties_trislider_topvalue->setValue(active_widget->floatval4);
properties_trislider_topvalue->setStepSize(0.1f);
properties_trislider_topvalue->setCallback(cb_float4);
puaSpinBox *properties_trislider_centvalue = new puaSpinBox(230,60,310,80);
properties_trislider_centvalue->setLabel("Center Slider Value:");
properties_trislider_centvalue->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_trislider_centvalue->setMinValue(-5000.0f);
properties_trislider_centvalue->setMaxValue(5000.0f);
properties_trislider_centvalue->setValue(active_widget->floatval6);
properties_trislider_centvalue->setStepSize(0.1f);
properties_trislider_centvalue->setCallback(cb_float6);
puaSpinBox *properties_trislider_botvalue = new puaSpinBox(230,10,310,30);
properties_trislider_botvalue->setLabel("Bottom Slider Value:");
properties_trislider_botvalue->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_trislider_botvalue->setMinValue(-5000.0f);
properties_trislider_botvalue->setMaxValue(5000.0f);
properties_trislider_botvalue->setValue(active_widget->floatval5);
properties_trislider_botvalue->setStepSize(0.1f);
properties_trislider_botvalue->setCallback(cb_float5);
static char *properties_trislider_lock_callback_entries [] = { "No", "Yes", NULL } ;
puButtonBox *properties_trislider_lock = new puButtonBox(380, 80, 480, 130, properties_trislider_lock_callback_entries, TRUE);
properties_trislider_lock->setLabel("Lock End Sliders:");
properties_trislider_lock->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_trislider_lock->setValue(active_widget->boolval3);
properties_trislider_lock->setCallback(cb_bool3);
} if (active_widget->object_type == PUCLASS_DIAL)
{
/* Wrap Mode */
static char *properties_dial_wrap_callback_entries [] = { "No", "Yes", NULL } ;
puButtonBox *properties_dial_wrap = new puButtonBox(20, 10, 170, 60, properties_dial_wrap_callback_entries, TRUE);
properties_dial_wrap->setLabel("Allow Dial Wrapping:");
properties_dial_wrap->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_dial_wrap->setValue(active_widget->boolval2);
properties_dial_wrap->setCallback(cb_bool2);
} if (active_widget->object_type == PUCLASS_SPINBOX)
{
/* Arrow position and height */
static char *properties_spinbox_arrow_callback_entries [] = { "Left", "Right", NULL } ;
puButtonBox *properties_spinbox_arrow = new puButtonBox(20, 10, 170, 60, properties_spinbox_arrow_callback_entries, TRUE);
properties_spinbox_arrow->setLabel("Arrow Position");
properties_spinbox_arrow->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_spinbox_arrow->setValue(active_widget->boolval2);
properties_spinbox_arrow->setCallback(cb_bool2);
puaSpinBox *properties_spinbox_arrowheight = new puaSpinBox(230,110,310,130);
properties_spinbox_arrowheight->setLabel("Arrow Height:");
properties_spinbox_arrowheight->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_spinbox_arrowheight->setMinValue(0.0f);
properties_spinbox_arrowheight->setMaxValue(20.0f);
properties_spinbox_arrowheight->setValue(active_widget->floatval4);
properties_spinbox_arrowheight->setStepSize(0.05f);
properties_spinbox_arrowheight->setCallback(cb_float4);
puText *properties_spinbox_arrowextra = new puText ( 310, 90 );
properties_spinbox_arrowextra->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_spinbox_arrowextra->setLabel("(as porportion of spinbox height)");
} if (active_widget->object_type == PUCLASS_DIALOGBOX)
{
/* Not yet implemented as a class */
} if (active_widget->object_type == PUCLASS_ARROW)
{
static char *properties_arrow_arrowtype_options [] = { "Up", "Down", "Left", "Right",
"Double-Up", "Double-Down", "Double-Left",
"Double-Right", NULL } ;
puaComboBox *properties_arrow_arrowtype = new puaComboBox ( 120,10,310,30, properties_arrow_arrowtype_options, FALSE ) ;
properties_arrow_arrowtype->setLabel ( "Arrow Type:" ) ;
properties_arrow_arrowtype->setLabelPlace ( PUPLACE_LOWER_LEFT ) ;
properties_arrow_arrowtype->setCallback(cb_items);
int num = 0;
if (active_widget->items)
{
if (strstr(active_widget->items,"Double-Up"))
num = 4;
else if (strstr(active_widget->items,"Double-Down"))
num = 5;
else if (strstr(active_widget->items,"Double-Left"))
num = 6;
else if (strstr(active_widget->items,"Double-Right"))
num = 7;
else if (strstr(active_widget->items,"Up"))
num = 0;
else if (strstr(active_widget->items,"Down"))
num = 1;
else if (strstr(active_widget->items,"Left"))
num = 2;
else if (strstr(active_widget->items,"Right"))
num = 3;
}
properties_arrow_arrowtype->setCurrentItem(num);
} if ( (active_widget->object_type == PUCLASS_INPUT ) ||
(active_widget->object_type == PUCLASS_LARGEINPUT ) )
{
/*int minx, int miny, int maxx, int maxy */
/* Disabled, and Valid Data list */
puInput *properties_input_validdata = new puInput(20, 150, 260, 170);
properties_input_validdata->setLabel("Allowed Characters for Input:");
properties_input_validdata->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_input_validdata->setCallback(cb_allowed);
properties_input_validdata->setDownCallback(cb_allowed);
properties_input_validdata->setValue(active_widget->allowed);
static char *properties_input_enabled_callback_entries [] = { "Yes", NULL } ;
puButtonBox *properties_input_enabled = new puButtonBox(300, 140, 450, 170, properties_input_enabled_callback_entries, FALSE);
properties_input_enabled->setLabel("Input Allowed? (enabled)");
properties_input_enabled->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_input_enabled->setValue(active_widget->boolval1);
properties_input_enabled->setCallback(cb_bool1);
} if ((active_widget->object_type == PUCLASS_LARGEINPUT) ||
(active_widget->object_type == PUCLASS_SCROLLBAR) )
{
/*Arrows*/
static char *properties_largeinput_arrows_callback_entries [] = { "None", "Normal", "Normal and Fast", NULL } ;
puButtonBox *properties_largeinput_arrows = new puButtonBox(20, 10, 200, 130, properties_largeinput_arrows_callback_entries, TRUE);
properties_largeinput_arrows->setLabel("Which Arrow Buttons:");
properties_largeinput_arrows->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_largeinput_arrows->setValue(active_widget->intval1);
properties_largeinput_arrows->setCallback(cb_int1);
} if (active_widget->object_type == PUCLASS_LARGEINPUT)
{
/*Slider Size*/
puaSpinBox *properties_largeinput_sliderwidth = new puaSpinBox(300,90,400,110);
properties_largeinput_sliderwidth->setLabel("Slider Width:");
properties_largeinput_sliderwidth->setLabelPlace(PUPLACE_TOP_CENTERED);
properties_largeinput_sliderwidth->setMinValue(0.0f);
properties_largeinput_sliderwidth->setMaxValue(150.0f);
properties_largeinput_sliderwidth->setValue(active_widget->intval2);
properties_largeinput_sliderwidth->setStepSize(1.0f);
properties_largeinput_sliderwidth->setCallback(cb_int2);
}
/* TODO:
* puaSliderWithInput: is input above or below slider?
* puaList: can we add the transparency field?
*/
properties_group->close () ;
return 0 ;
}
File diff suppressed because it is too large Load Diff
+75
View File
@@ -0,0 +1,75 @@
/*
This file is part of P-GUIDE -
PUI-based Graphical User Interface Designer.
Copyright (C) 2002, 2006 John F. Fay
P-GUIDE 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.
P-GUIDE 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 P-GUIDE; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
$Id: WidgetList.h 2083 2006-05-01 13:14:50Z bram $
*/
// Data Structure Definition
#ifndef WIDGET_LIST_H
#define WIDGET_LIST_H
#include <plib/pu.h>
#include <plib/puAux.h>
#ifdef FREEGLUT_IS_PRESENT
# include <GL/freeglut.h>
#else
# ifdef __APPLE__
# include <GLUT/glut.h>
# else
# include <GL/glut.h>
# endif
#endif
// PUI Widget List for Main Window
struct WidgetList
{
puObject *obj ;
char *object_type_name ;
int object_type ;
char *label_text ;
char *legend_text ;
short callbacks ;
char object_name [ PUSTRING_MAX ] ;
bool visible ;
bool locked ;
int layer ; // GUI layer: 0 - in back, positive nubmers - greater in front of lesser
WidgetList *next ;
/* Additional data for the extended properties of widgets */
char *items ;
char *allowed ;
int intval1 ;
int intval2 ;
bool boolval1 ;
bool boolval2 ;
bool boolval3 ;
float floatval1 ;
float floatval2 ;
float floatval3 ;
float floatval4 ;
float floatval5 ;
float floatval6 ;
} ;
#endif // WIDGET_LIST_H
+460
View File
@@ -0,0 +1,460 @@
/*
This file is part of P-GUIDE -
PUI-based Graphical User Interface Designer.
Copyright (C) 2002, 2006 John F. Fay
P-GUIDE 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.
P-GUIDE 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 P-GUIDE; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
$Id: WidgetWindow.cxx 2100 2006-11-03 22:31:54Z fayjf $
*/
// Widget Window
#include <stdio.h>
#include <plib/pu.h>
#include <plib/puAux.h>
#ifdef FREEGLUT_IS_PRESENT
# include <GL/freeglut.h>
#else
# ifdef __APPLE__
# include <GLUT/glut.h>
# else
# include <GL/glut.h>
# endif
#endif
// Widget Window Data
bool selected_object_sticky = false ;
int selected_object_type ;
char *selected_type_string ;
puButton *active_button = (puButton *)NULL ;
// Widget window parameters
static int widget_window = 0 ; // Window handle
// GLUT Widget Window Callbacks
static void widget_window_specialfn ( int key, int, int )
{
glutPostRedisplay () ;
}
static void widget_window_keyfn ( unsigned char key, int, int )
{
if ( selected_object_type )
{
if ( key == 27 ) // Escape key, deactivate the selected button
{
selected_object_type = 0 ;
active_button->setValue ( 0 ) ;
}
}
glutPostRedisplay () ;
}
static void widget_window_motionfn ( int x, int y )
{
puMouse ( x, y ) ;
glutPostRedisplay () ;
}
static void widget_window_mousefn ( int button, int updown, int x, int y )
{
if ( ! puMouse ( button, updown, x, y ) )
{
// PUI didn't absorb the mouse click; deactivate the selected object type
if ( selected_object_type )
{
selected_object_type = 0 ;
active_button->setValue ( 0 ) ;
}
}
glutPostRedisplay () ;
}
static void widget_window_displayfn ( void )
{
glutSetWindow ( widget_window ) ;
/* Clear the screen */
glClearColor ( 0.1f, 0.1f, 0.1f, 1.0f ) ;
glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) ;
puDisplay () ;
/* Update GLUT */
glutSwapBuffers () ;
glutPostRedisplay () ;
}
// PUI Callback Functions:
static void frame_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_FRAME ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void text_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_TEXT ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void menu_bar_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_MENUBAR ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void vertical_menu_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_VERTMENU ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void spin_box_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_SPINBOX ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void list_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_LIST ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void input_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_INPUT ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void large_input_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_LARGEINPUT ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void select_box_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_SELECTBOX ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void file_selector_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_FILESELECTOR ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void list_box_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_LISTBOX ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void scroll_bar_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_SCROLLBAR ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void button_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_BUTTON ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void one_shot_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_ONESHOT ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void arrow_button_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_ARROW ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void button_box_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_BUTTONBOX ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void combo_box_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_COMBOBOX ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void chooser_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_CHOOSER ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void dial_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_DIAL ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void slider_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_SLIDER ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void bislider_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_BISLIDER ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void trislider_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_TRISLIDER ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void slider_with_input_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_SLIDERWITHINPUT ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
static void bislider_with_ends_cb ( puObject *ob )
{
selected_object_sticky = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ? 1 : 0 ;
selected_object_type = PUCLASS_BISLIDERWITHENDS ;
strcpy ( selected_type_string, ob->getLegend () ) ;
active_button = (puButton *)ob ;
}
// Function to define the window
// The widgets are arranged in a rectangle:
// Frame Input Button Dial
// Text Large Input One Shot Slider
// Menu Bar Select Box Arrow Button Bi-Slider
// Vertical Menu File Selector Button Box Tri-Slider
// Spin Box List Box Combo Box Slider with Input
// List Scroll Bar Chooser Bi-Slider with Ends
//
// The following widgets are not offered:
// Group Interface Popup Popup Menu
// Dialog Box
int define_widget_window ()
{
widget_window = glutCreateWindow ( "Widget List" ) ;
int ln = 120 ; // Button length
int ht = 20 ; // Button height
int sp = 10 ; // Button spacing
int total_screen_width = glutGet( GLUT_SCREEN_WIDTH ) ;
glutReshapeWindow ( 4 * ln + 5 * sp, 6 * ht + 7 * sp ) ;
glutPositionWindow ( total_screen_width - (4 * ln + 5 * sp) - 20, 20 ) ;
glutDisplayFunc ( widget_window_displayfn ) ;
glutKeyboardFunc ( widget_window_keyfn ) ;
glutSpecialFunc ( widget_window_specialfn ) ;
glutMotionFunc ( widget_window_motionfn ) ;
glutMouseFunc ( widget_window_mousefn ) ;
// Global variable initialization (type string)
selected_type_string = new char [ PUSTRING_MAX ] ;
// Set up the widgets
puGroup *widget_group = new puGroup ( 0, 0 ) ;
new puFrame ( 0, 0, 4 * ln + 5 * sp, 6 * ht + 7 * sp ) ;
puButton *button = (puButton *)NULL ;
button = new puButton ( sp, 6*sp+5*ht, sp+ln, 6*sp+6*ht ) ;
button->setLegend ( "puFrame" ) ;
button->setCallback ( frame_cb ) ;
button = new puButton ( sp, 5*sp+4*ht, sp+ln, 5*sp+5*ht ) ;
button->setLegend ( "puText" ) ;
button->setCallback ( text_cb ) ;
button = new puButton ( sp, 4*sp+3*ht, sp+ln, 4*sp+4*ht ) ;
button->setLegend ( "puMenuBar" ) ;
button->setCallback ( menu_bar_cb ) ;
button = new puButton ( sp, 3*sp+2*ht, sp+ln, 3*sp+3*ht ) ;
button->setLegend ( "puaVerticalMenu" ) ;
button->setCallback ( vertical_menu_cb ) ;
button = new puButton ( sp, 2*sp+ht, sp+ln, 2*sp+2*ht ) ;
button->setLegend ( "puaSpinBox" ) ;
button->setCallback ( spin_box_cb ) ;
button = new puButton ( sp, sp, sp+ln, sp+ht ) ;
button->setLegend ( "puaList" ) ;
button->setCallback ( list_cb ) ;
button = new puButton ( 2*sp+ln, 6*sp+5*ht, 2*sp+2*ln, 6*sp+6*ht ) ;
button->setLegend ( "puInput" ) ;
button->setCallback ( input_cb ) ;
button = new puButton ( 2*sp+ln, 5*sp+4*ht, 2*sp+2*ln, 5*sp+5*ht ) ;
button->setLegend ( "puaLargeInput" ) ;
button->setCallback ( large_input_cb ) ;
button = new puButton ( 2*sp+ln, 4*sp+3*ht, 2*sp+2*ln, 4*sp+4*ht ) ;
button->setLegend ( "puaSelectBox" ) ;
button->setCallback ( select_box_cb ) ;
button = new puButton ( 2*sp+ln, 3*sp+2*ht, 2*sp+2*ln, 3*sp+3*ht ) ;
button->setLegend ( "puaFileSelector" ) ;
button->setCallback ( file_selector_cb ) ;
button = new puButton ( 2*sp+ln, 2*sp+ht, 2*sp+2*ln, 2*sp+2*ht ) ;
button->setLegend ( "puListBox" ) ;
button->setCallback ( list_box_cb ) ;
button = new puButton ( 2*sp+ln, sp, 2*sp+2*ln, sp+ht ) ;
button->setLegend ( "puaScrollBar" ) ;
button->setCallback ( scroll_bar_cb ) ;
button = new puButton ( 3*sp+2*ln, 6*sp+5*ht, 3*sp+3*ln, 6*sp+6*ht ) ;
button->setLegend ( "puButton" ) ;
button->setCallback ( button_cb ) ;
button = new puButton ( 3*sp+2*ln, 5*sp+4*ht, 3*sp+3*ln, 5*sp+5*ht ) ;
button->setLegend ( "puOneShot" ) ;
button->setCallback ( one_shot_cb ) ;
button = new puButton ( 3*sp+2*ln, 4*sp+3*ht, 3*sp+3*ln, 4*sp+4*ht ) ;
button->setLegend ( "puArrowButton" ) ;
button->setCallback ( arrow_button_cb ) ;
button = new puButton ( 3*sp+2*ln, 3*sp+2*ht, 3*sp+3*ln, 3*sp+3*ht ) ;
button->setLegend ( "puButtonBox" ) ;
button->setCallback ( button_box_cb ) ;
button = new puButton ( 3*sp+2*ln, 2*sp+ht, 3*sp+3*ln, 2*sp+2*ht ) ;
button->setLegend ( "puaComboBox" ) ;
button->setCallback ( combo_box_cb ) ;
button = new puButton ( 3*sp+2*ln, sp, 3*sp+3*ln, sp+ht ) ;
button->setLegend ( "puaChooser" ) ;
button->setCallback ( chooser_cb ) ;
// TODO: It appears that the "puaChooser" file is not in the puAux library yet.
button->hide ();
button = new puButton ( 4*sp+3*ln, 6*sp+5*ht, 4*sp+4*ln, 6*sp+6*ht ) ;
button->setLegend ( "puDial" ) ;
button->setCallback ( dial_cb ) ;
button = new puButton ( 4*sp+3*ln, 5*sp+4*ht, 4*sp+4*ln, 5*sp+5*ht ) ;
button->setLegend ( "puSlider" ) ;
button->setCallback ( slider_cb ) ;
button = new puButton ( 4*sp+3*ln, 4*sp+3*ht, 4*sp+4*ln, 4*sp+4*ht ) ;
button->setLegend ( "puaBiSlider" ) ;
button->setCallback ( bislider_cb ) ;
button = new puButton ( 4*sp+3*ln, 3*sp+2*ht, 4*sp+4*ln, 3*sp+3*ht ) ;
button->setLegend ( "puaTriSlider" ) ;
button->setCallback ( trislider_cb ) ;
button = new puButton ( 4*sp+3*ln, 2*sp+ht, 4*sp+4*ln, 2*sp+2*ht ) ;
button->setLegend ( "puaSliderWithInput" ) ;
button->setCallback ( slider_with_input_cb ) ;
button = new puButton ( 4*sp+3*ln, sp, 4*sp+4*ln, sp+ht ) ;
button->setLegend ( "puaBiSliderWithEnds" ) ;
button->setCallback ( bislider_with_ends_cb ) ;
widget_group->close () ;
return 0 ;
}
+616
View File
@@ -0,0 +1,616 @@
/*
This file is part of P-GUIDE -
PUI-based Graphical User Interface Designer.
Copyright (C) 2002, 2006 John F. Fay
P-GUIDE 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.
P-GUIDE 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 P-GUIDE; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
$Id: WriteCode.cxx 2100 2006-11-03 22:31:54Z fayjf $
*/
// Function to write the actual code
#include <stdio.h>
#include "WidgetList.h"
#ifdef WIN32
#define PATH_SEPARATOR '\\'
#else
#define PATH_SEPARATOR '/'
#endif
// From the Main Window:
extern WidgetList *widgets ;
extern int max_layer ;
extern int main_window_width ;
extern int main_window_height ;
extern char main_window_name [ PUSTRING_MAX ] ;
extern char pguide_current_directory [ PUSTRING_MAX ] ;
extern int main_window_x ;
extern int main_window_y ;
extern bool main_window_changed ;
extern float main_window_color_r, main_window_color_g,
main_window_color_b, main_window_color_a ;
// From the Status Window
extern int status_window ;
extern puaFileSelector *file_selector ;
const char* trueOrFalse(bool tf)
{
if (tf) return "TRUE";
else return "FALSE";
}
// The function itself
void write_code ( puObject *ob )
{
// Get the file name and open the file
char* filename ;
file_selector -> getValue ( &filename ) ;
if (filename[0] == '\0')
{
puDeleteObject ( file_selector ) ;
file_selector = (puaFileSelector *)NULL ;
glutHideWindow () ;
glutSetWindow ( status_window ) ;
return ;
}
/* Save the new current directory */
strcpy(pguide_current_directory, filename) ;
int i = strlen(pguide_current_directory);
while (pguide_current_directory[i] != PATH_SEPARATOR) {
if (i>0) i-- ;
else break ;
}
pguide_current_directory[i+1] = '\0' ;
/* If they didn't give an extension, then tack ".cxx" onto the end. */
if(!strstr(filename, "."))
sprintf(filename, "%s.cxx", filename);
FILE *out = fopen ( filename, "wt" ) ;
if ( !out )
printf ( "ERROR opening file <%s> for writing\n", filename ) ;
puDeleteObject ( file_selector ) ;
file_selector = (puaFileSelector *)NULL ;
glutHideWindow () ;
glutSetWindow ( status_window ) ;
if ( !out ) return ;
// Start writing code:
fprintf ( out, "// TODO: Initial documentation\n" ) ;
fprintf ( out, "// TODO: Configuration Management system flags\n\n" ) ;
fprintf ( out, "// TODO: Any additional includes you may need\n\n" ) ;
fprintf ( out, "#include <GL/freeglut.h>\n\n" ) ;
fprintf ( out, "#include <plib/pu.h>\n\n" ) ;
fprintf ( out, "#include <plib/puAux.h> // TODO: Decide if you really need this\n\n" ) ;
fprintf ( out, "// GLUT Window Handle\n" ) ;
fprintf ( out, "int window_handle ;\n\n" ) ;
WidgetList *wid = widgets ;
fprintf ( out, "// PUI Widget Handles:\n" ) ;
while ( wid )
{
fprintf ( out, "%s *%s = (%s *)NULL ;\n", wid->object_type_name, wid->object_name,
wid->object_type_name ) ;
wid = wid->next ;
}
fprintf ( out, "\n" ) ;
// GLUT Callbacks:
fprintf ( out, "// GLUT Callbacks:\n" ) ;
fprintf ( out, "static void specialfn ( int key, int x, int y )\n" ) ;
fprintf ( out, "{\n" ) ;
fprintf ( out, " // TODO: Put any of your own special-key functionality in here\n" ) ;
fprintf ( out, " puKeyboard ( key + PU_KEY_GLUT_SPECIAL_OFFSET, PU_DOWN ) ;\n" ) ;
fprintf ( out, " glutPostRedisplay () ;\n" ) ;
fprintf ( out, "}\n\n" ) ;
fprintf ( out, "static void keyfn ( unsigned char key, int x, int y )\n" ) ;
fprintf ( out, "{\n" ) ;
fprintf ( out, " // TODO: Put any of your own keyboard functionality in here\n" ) ;
fprintf ( out, " puKeyboard ( key, PU_DOWN ) ;\n" ) ;
fprintf ( out, " glutPostRedisplay () ;\n" ) ;
fprintf ( out, "}\n\n" ) ;
fprintf ( out, "static void motionfn ( int x, int y )\n" ) ;
fprintf ( out, "{\n" ) ;
fprintf ( out, " // TODO: Put any of your own mouse motion functionality in here\n" ) ;
fprintf ( out, " puMouse ( x, y ) ;\n" ) ;
fprintf ( out, " glutPostRedisplay () ;\n" ) ;
fprintf ( out, "}\n\n" ) ;
fprintf ( out, "static void mousefn ( int button, int updown, int x, int y )\n" ) ;
fprintf ( out, "{\n" ) ;
fprintf ( out, " // TODO: Put any of your own mouse click functionality in here\n" ) ;
fprintf ( out, " puMouse ( button, updown, x, y ) ;\n" ) ;
fprintf ( out, " glutPostRedisplay () ;\n" ) ;
fprintf ( out, "}\n\n" ) ;
fprintf ( out, "static void displayfn ( void )\n" ) ;
fprintf ( out, "{\n" ) ;
fprintf ( out, " // Clear the screen\n\n" ) ;
fprintf ( out, " glClearColor ( %f, %f, %f, %f ) ;\n", main_window_color_r, main_window_color_g,
main_window_color_b, main_window_color_a ) ;
fprintf ( out, " glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) ;\n\n" ) ;
fprintf ( out, " // TODO: Put any of your own window display in here\n\n" ) ;
fprintf ( out, " // Make PUI display\n" ) ;
fprintf ( out, " puDisplay () ;\n\n" ) ;
fprintf ( out, " glutSwapBuffers () ;\n" ) ;
fprintf ( out, " glutPostRedisplay () ;\n" ) ;
fprintf ( out, "}\n\n" ) ;
fprintf ( out, "// TODO: Put any of your own additional GLUT callbacks in here\n\n" ) ;
// PUI Callbacks
fprintf ( out, "// PUI Callbacks:\n\n" ) ;
wid = widgets ;
while ( wid )
{
if ( wid->callbacks & 0x01 ) // Up-callback defined
{
fprintf ( out, "void %s_cb ( puObject *ob )\n", wid->object_name ) ;
fprintf ( out, "{\n" ) ;
fprintf ( out, " // TODO: Put your up-callback functionality in here\n" ) ;
fprintf ( out, "}\n\n" ) ;
}
if ( wid->callbacks & 0x02 ) // Active callback defined
{
fprintf ( out, "void %s_active_cb ( puObject *ob )\n", wid->object_name ) ;
fprintf ( out, "{\n" ) ;
fprintf ( out, " // TODO: Put your active callback functionality in here\n" ) ;
fprintf ( out, "}\n\n" ) ;
}
if ( wid->callbacks & 0x04 ) // Down-callback defined
{
fprintf ( out, "void %s_down_cb ( puObject *ob )\n", wid->object_name ) ;
fprintf ( out, "{\n" ) ;
fprintf ( out, " // TODO: Put your down-callback functionality in here\n" ) ;
fprintf ( out, "}\n\n" ) ;
}
wid = wid->next ;
}
fprintf ( out, "\n\n" ) ;
// The Main Program
fprintf ( out, "//**********************************************************\n" ) ;
fprintf ( out, "//* The Main Program *\n" ) ;
fprintf ( out, "//**********************************************************\n\n" ) ;
fprintf ( out, "int main ( int argc, char *argv[] )\n" ) ;
fprintf ( out, "{\n" ) ;
fprintf ( out, " // TODO: Add any non-GLUT functionality you want to\n\n" ) ;
fprintf ( out, " // Create the GLUT window:\n" ) ;
fprintf ( out, " glutInitWindowPosition( %d, %d ) ;\n", main_window_x, main_window_y ) ;
fprintf ( out, " glutInitWindowSize ( %d, %d ) ;\n", main_window_width, main_window_height ) ;
fprintf ( out, " glutInit ( &argc, argv ) ;\n" ) ;
fprintf ( out, " glutInitDisplayMode ( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ) ;\n" ) ;
fprintf ( out, " window_handle = glutCreateWindow ( \"%s\" ) ;\n\n", main_window_name ) ;
fprintf ( out, " // GLUT Windowing Callbacks:\n" ) ;
fprintf ( out, " glutDisplayFunc ( displayfn ) ;\n" ) ;
fprintf ( out, " glutKeyboardFunc ( keyfn ) ;\n" ) ;
fprintf ( out, " glutSpecialFunc ( specialfn ) ;\n" ) ;
fprintf ( out, " glutMouseFunc ( mousefn ) ;\n" ) ;
fprintf ( out, " glutMotionFunc ( motionfn ) ;\n" ) ;
fprintf ( out, " glutPassiveMotionFunc ( motionfn ) ;\n" ) ;
fprintf ( out, " glutIdleFunc ( displayfn ) ;\n" ) ;
fprintf ( out, " // TODO: Add any additional GLUT callbacks that you defined earlier\n\n" ) ;
fprintf ( out, " // Initialize PUI:\n" ) ;
fprintf ( out, " puInit () ;\n\n" ) ;
// TO DO: Allow the user to select his own default fonts, style, and colour scheme
fprintf ( out, " // PUI Default Style, and Colors:\n" ) ;
fprintf ( out, " puSetDefaultStyle ( PUSTYLE_SMALL_SHADED ) ;\n" ) ;
fprintf ( out, " puSetDefaultColourScheme ( 0.3f, 0.4f, 0.6f, 1.0f ) ;\n" ) ;
fprintf ( out, " // TODO: Customize this as you like\n\n" ) ;
fprintf ( out, " // Define the widgets:\n\n" ) ;
fprintf ( out, " puGroup *window_group = new puGroup ( 0, 0 ) ;\n\n" ) ;
int layer ;
for ( layer = 0; layer < max_layer; layer++ )
{
wid = widgets ;
while ( wid )
{
if ( layer == wid->layer )
{
puObject *ob = wid->obj ;
int x, y, w, h ;
ob->getPosition ( &x, &y ) ;
ob->getSize ( &w, &h ) ;
/* Customize widget's constructor and extra details */
/* fprintf ( out, " %s = new %s ( %d, %d, %d, %d ) ;\n", wid->object_name,
wid->object_type_name, x, y, x+w, y+h ) ; */
/* General minx, miny, maxx, maxy constructor */
if ( (wid->object_type == PUCLASS_FRAME ) ||
(wid->object_type == PUCLASS_BUTTON ) ||
(wid->object_type == PUCLASS_INPUT ) ||
(wid->object_type == PUCLASS_BISLIDERWITHENDS))
{
fprintf ( out, " %s = new %s (%d, %d, %d, %d ) ;\n", wid->object_name, wid->object_type_name, x, y, x+w, y+h) ;
}
/* General minx, miny constructor */
if (wid->object_type == PUCLASS_TEXT)
{
/* Add in font properties? */
fprintf ( out, " %s = new %s (%d, %d ) ;\n", wid->object_name, wid->object_type_name, x, y) ;
}
if (wid->object_type == PUCLASS_ONESHOT)
{
/*
Add support for both constructors!
puButton::puButton ( int minx, int miny, const char *legend ) ;
puButton::puButton ( int minx, int miny, int maxx, int maxy ) ;
*/
fprintf ( out, " %s = new %s (%d, %d, %d, %d ) ;\n", wid->object_name, wid->object_type_name, x, y, x+w, y+h) ;
}
if ( (wid->object_type == PUCLASS_MENUBAR) ||
(wid->object_type == PUCLASS_VERTMENU) ) {
if (wid->items)
{
char *temp_items = wid->items ;
char *cr = strchr(temp_items, '\n');
while ( cr != '\0' )
{
char *spc = strchr ( temp_items, ' ' ) ;
while ( spc )
{
*spc = '_' ;
spc = strchr ( temp_items, ' ' ) ;
}
spc = strchr ( temp_items, ':' ) ;
while ( spc )
{
*spc = '_' ;
spc = strchr ( temp_items, ':' ) ;
}
spc = strchr ( temp_items, ';' ) ;
while ( spc )
{
*spc = '_' ;
spc = strchr ( temp_items, ';' ) ;
}
spc = strchr ( temp_items, ',' ) ;
while ( spc )
{
*spc = '_' ;
spc = strchr ( temp_items, ',' ) ;
}
spc = strchr ( temp_items, '.' ) ;
while ( spc )
{
*spc = '_' ;
spc = strchr ( temp_items, '.' ) ;
}
*cr = '\0';
fprintf ( out, " static char *%s_%s_submenu [] = { \"Filler\", NULL } ;\n", wid->object_name, temp_items) ;
fprintf ( out, " /* TODO: You need to create your own callbacks here, such as { \"exit_cb\",\"delete_cb\",NULL } */ \n") ;
fprintf ( out, " puCallback %s_%s_submenu_cb [] = { NULL, NULL } ;\n\n", wid->object_name, temp_items) ;
*cr = '\n';
temp_items = cr + 1;
cr = strchr(temp_items, '\n');
}
}
if (wid->object_type == PUCLASS_MENUBAR) {
/* TODO: add in "height" support */
fprintf ( out, " %s = new %s ( ) ;\n", wid->object_name, wid->object_type_name) ;
}
if (wid->object_type == PUCLASS_VERTMENU) {
/* TODO: add in "lock to corner" support */
fprintf ( out, " %s = new %s (%d, %d ) ;\n", wid->object_name, wid->object_type_name, x, y) ;
}
if (wid->items)
{
char *temp_items = wid->items ;
char unspaced_items[PUSTRING_MAX];
char *cr = strchr(temp_items, '\n');
fprintf ( out, " {\n") ;
while ( cr != '\0' )
{
*cr = '\0';
strcpy(unspaced_items, temp_items);
/* Put back the space */
char *spc = strchr ( temp_items, '_' ) ;
while ( spc )
{
*spc = ' ' ;
spc = strchr ( temp_items, '_' ) ;
}
/* Now "unspaced_items" writes "I_have_no_spaces" while temp_items writes "I have no spaces" (AND LIES!) */
fprintf ( out, " %s->add_submenu (\"%s\", %s_%s_submenu, %s_%s_submenu_cb ) ;\n", wid->object_name, temp_items, wid->object_name, unspaced_items, wid->object_name, unspaced_items ) ;
*cr = '\n';
temp_items = cr + 1;
cr = strchr(temp_items, '\n');
}
fprintf ( out, " }\n") ;
}
fprintf ( out, " %s->close() ;\n", wid->object_name) ;
}
if ( (wid->object_type == PUCLASS_LISTBOX) ||
(wid->object_type == PUCLASS_COMBOBOX) ||
(wid->object_type == PUCLASS_SELECTBOX) ||
(wid->object_type == PUCLASS_BUTTONBOX) ||
(wid->object_type == PUCLASS_LIST))
{
char data[1024];
char onedata[PUSTRING_MAX];
if (wid->items)
{
char *temp_items = wid->items ;
char *cr = strchr(temp_items, '\n');
sprintf ( data, " ");
while ( cr != '\0' )
{
*cr = '\0';
sprintf ( onedata, "\"%s\",", temp_items);
*cr = '\n';
temp_items = cr + 1;
cr = strchr(temp_items, '\n');
strcat(data, onedata);
}
}
fprintf ( out, " static char *%s_entries [] = { %s NULL } ;\n", wid->object_name, data) ;
if ( (wid->object_type == PUCLASS_LISTBOX) ||
(wid->object_type == PUCLASS_LIST) )
fprintf ( out, " %s = new %s (%d, %d, %d, %d, %s_entries ) ;\n", wid->object_name, wid->object_type_name, x, y, x+w, y+h, wid->object_name) ;
if (wid->object_type == PUCLASS_BUTTONBOX)
fprintf ( out, " %s = new %s (%d, %d, %d, %d, %s_entries, %s ) ;\n", wid->object_name, wid->object_type_name, x, y, x+w, y+h, wid->object_name, trueOrFalse(wid->boolval1)) ;
if (wid->object_type == PUCLASS_COMBOBOX)
{
fprintf ( out, " %s = new %s (%d, %d, %d, %d, %s_entries, %s ) ;\n", wid->object_name, wid->object_type_name, x, y, x+w, y+h, wid->object_name, trueOrFalse(wid->boolval1)) ;
fprintf ( out, " %s->setCurrentItem(%d) ;\n", wid->object_name, wid->intval1) ;
}
if (wid->object_type == PUCLASS_SELECTBOX)
{
fprintf ( out, " %s = new %s (%d, %d, %d, %d, %s_entries ) ;\n", wid->object_name, wid->object_type_name, x, y, x+w, y+h, wid->object_name) ;
fprintf ( out, " %s->setCurrentItem(%d) ;\n", wid->object_name, wid->intval1) ;
}
}
if (wid->object_type == PUCLASS_POPUPMENU)
{
/* Allow a list of menu items, and remember to point out these are hidden when created, and must be reveal()ed. */
/* NOT CURRENTLY IMPLEMENTED */
}
/* puRange */
if ( (wid->object_type == PUCLASS_SLIDER ) ||
(wid->object_type == PUCLASS_BISLIDER ) ||
(wid->object_type == PUCLASS_TRISLIDER ) ||
(wid->object_type == PUCLASS_DIAL ) ||
(wid->object_type == PUCLASS_SPINBOX ) ||
(wid->object_type == PUCLASS_SCROLLBAR ) )
{
/* Constructors */
if ( (wid->object_type == PUCLASS_SLIDER ) ||
(wid->object_type == PUCLASS_BISLIDER ) ||
(wid->object_type == PUCLASS_TRISLIDER ))
{
/* Sliders */
fprintf ( out, " %s = new %s (%d, %d, %d, %s, %d ) ;\n", wid->object_name, wid->object_type_name, x, y, (wid->boolval2==1)?h:w, trueOrFalse(wid->boolval2), (wid->boolval2==1)?w:h) ;
/* Slider value options */
if (wid->object_type == PUCLASS_SLIDER )
fprintf ( out, " %s->setValue(%ff) ;\n", wid->object_name, wid->floatval4) ;
if ( (wid->object_type == PUCLASS_BISLIDER ) || (wid->object_type == PUCLASS_TRISLIDER ) )
{
fprintf ( out, " %s->setCurrentMax(%ff) ;\n", wid->object_name, wid->floatval4) ;
fprintf ( out, " %s->setCurrentMin(%ff) ;\n", wid->object_name, wid->floatval5) ;
if (wid->object_type == PUCLASS_TRISLIDER )
{
if (!wid->boolval3)
fprintf ( out, " %s->setFreezeEnds(FALSE) ;\n", wid->object_name ) ;
fprintf ( out, " %s->setValue(%ff) ;\n", wid->object_name, wid->floatval6) ;
fprintf ( out, " %s->setSliderFraction(0.1f) ;\n", wid->object_name) ;
/*Allow setting the slider fraction?*/
}
}
} else if (wid->object_type == PUCLASS_DIAL )
{
fprintf ( out, " %s = new %s (%d, %d, %d ) ;\n", wid->object_name, wid->object_type_name, x, y, (h+w)/2) ;
fprintf ( out, " %s->setWrap(%s) ;\n", wid->object_name, trueOrFalse(wid->boolval2)) ;
} else if (wid->object_type == PUCLASS_SPINBOX )
{
fprintf ( out, " %s = new %s (%d, %d, %d, %d, %s ) ;\n", wid->object_name, wid->object_type_name, x, y, x+w, y+h, trueOrFalse(wid->boolval2) ) ;
fprintf ( out, " %s->setArrowHeight(%ff) ;\n", wid->object_name, wid->floatval4 ) ;
} else if (wid->object_type == PUCLASS_SCROLLBAR )
{
fprintf ( out, " %s = new %s (%d, %d, %d, %d, %d, %s ) ;\n", wid->object_name, wid->object_type_name, x, y, x+w, y+h, wid->intval1, trueOrFalse(wid->boolval2) ) ;
fprintf ( out, " %s->setArrowHeight(%ff) ;\n", wid->object_name, wid->floatval4 ) ;
}
/* All puRange options */
fprintf ( out, " %s->setMaxValue (%ff) ;\n", wid->object_name, wid->floatval1 ) ;
fprintf ( out, " %s->setMinValue (%ff) ;\n", wid->object_name, wid->floatval2 ) ;
fprintf ( out, " %s->setStepSize (%ff) ;\n", wid->object_name, wid->floatval3 ) ;
char cbmodetext[20] = "PUSLIDER_ALWAYS";
if (wid->boolval1)
strcpy(cbmodetext,"PUSLIDER_ALWAYS");
else
strcpy(cbmodetext,"PUSLIDER_CLICK");
fprintf ( out, " %s->setCBMode (%s) ;\n", wid->object_name, cbmodetext) ;
}
if (wid->object_type == PUCLASS_DIALOGBOX)
{
/* Not yet implemented as a class */
}
if (wid->object_type == PUCLASS_ARROW)
{
char arr_name[20] = "PUARROW_UP";
if (wid->items)
{
if (strstr(wid->items,"Double-Up"))
strcpy(arr_name, "PUARROW_FASTUP");
else if (strstr(wid->items,"Double-Down"))
strcpy(arr_name, "PUARROW_FASTDOWN");
else if (strstr(wid->items,"Double-Left"))
strcpy(arr_name, "PUARROW_FASTLEFT");
else if (strstr(wid->items,"Double-Right"))
strcpy(arr_name, "PUARROW_FASTRIGHT");
else if (strstr(wid->items,"Up"))
strcpy(arr_name, "PUARROW_UP");
else if (strstr(wid->items,"Down"))
strcpy(arr_name, "PUARROW_DOWN");
else if (strstr(wid->items,"Left"))
strcpy(arr_name, "PUARROW_LEFT");
else if (strstr(wid->items,"Right"))
strcpy(arr_name, "PUARROW_RIGHT");
}
fprintf ( out, " %s = new puArrowButton (%d, %d, %d, %d, %s ) ;\n", wid->object_name, x, y, x+w, y+h, arr_name) ;
}
if (wid->object_type == PUCLASS_CHOOSER)
{
// Just give it a dummy legend; set the legend later on
fprintf ( out, " %s = new %s (%d, %d, %d, %d, "" ) ;\n", wid->object_name, wid->object_type_name, x, y, x+w, y+h) ;
}
if (wid->object_type == PUCLASS_SLIDERWITHINPUT)
{
// Extra argument for input box being on the bottom of the slider
fprintf ( out, " %s = new %s (%d, %d, %d, %d, 0 ) ;\n", wid->object_name, wid->object_type_name, x, y, x+w, y+h) ;
}
if (wid->object_type == PUCLASS_INPUT )
{
/*Already had its constructor defined by the general -- look up*/
if (wid->boolval1 == false)
fprintf ( out, " %s->rejectInput() ;\n", wid->object_name ) ;
if ( wid->allowed)
fprintf ( out, " %s->setValidData(\"%s\") ;\n", wid->object_name, wid->allowed ) ;
}
if ( wid->object_type == PUCLASS_LARGEINPUT )
{
fprintf ( out, " %s = new %s (%d, %d, %d, %d, %d, %d ) ;\n", wid->object_name, wid->object_type_name, x, y, w, h, wid->intval1, wid->intval2 ) ;
if (wid->boolval1 == false)
fprintf ( out, " %s->rejectInput() ;\n", wid->object_name ) ;
if ( wid->allowed)
fprintf ( out, " %s->setValidData(\"%s\") ;\n", wid->object_name, wid->allowed ) ;
}
/* Done custom constructor and extra details */
if ( wid->callbacks & 0x01 ) // Up-callback defined
fprintf ( out, " %s->setCallback ( %s_cb ) ;\n", wid->object_name, wid->object_name ) ;
if ( wid->callbacks & 0x02 ) // Active callback defined
fprintf ( out, " %s->setActiveCallback ( %s_active_cb ) ;\n", wid->object_name, wid->object_name ) ;
if ( wid->callbacks & 0x04 ) // Down-callback defined
fprintf ( out, " %s->setDownCallback ( %s_down_cb ) ;\n", wid->object_name, wid->object_name ) ;
// TO DO: Allow the user to customize colour and style
const char *place_name [] = { "PUPLACE_TOP_LEFT", "PUPLACE_TOP_CENTERED", "PUPLACE_TOP_RIGHT",
"PUPLACE_CENTERED_LEFT", "PUPLACE_CENTERED_RIGHT",
"PUPLACE_BOTTOM_LEFT", "PUPLACE_BOTTOM_CENTERED", "PUPLACE_BOTTOM_RIGHT",
"PUPLACE_CENTERED_CENTERED",
"PUPLACE_ABOVE_LEFT", "PUPLACE_ABOVE_RIGHT",
"PUPLACE_BELOW_LEFT", "PUPLACE_BELOW_RIGHT",
"PUPLACE_UPPER_LEFT", "PUPLACE_UPPER_RIGHT",
"PUPLACE_LOWER_LEFT", "PUPLACE_LOWER_RIGHT" } ;
if ( wid->label_text )
{
fprintf ( out, " %s->setLabel ( \"%s\" ) ;\n", wid->object_name, wid->label_text ) ;
fprintf ( out, " %s->setLabelPlace ( %s ) ;\n", wid->object_name, place_name [ ob->getLabelPlace () ] ) ;
// TO DO: Check for label font and print it
}
if ( wid->legend_text )
{
fprintf ( out, " %s->setLegend ( \"%s\" ) ;\n", wid->object_name, wid->legend_text ) ;
fprintf ( out, " %s->setLegendPlace ( %s ) ;\n", wid->object_name, place_name [ ob->getLegendPlace () ] ) ;
// TO DO: Check for legend font and print it
}
if( !wid->visible )
fprintf ( out, " %s->hide () ;\n", wid->object_name ) ;
fprintf ( out, " \n" ) ;
}
wid = wid->next ;
}
}
fprintf ( out, "\n\n" ) ;
fprintf ( out, " window_group->close () ;\n\n\n" ) ;
fprintf ( out, " // GLUT Main Loop\n" ) ;
fprintf ( out, " glutMainLoop () ;\n" ) ;
fprintf ( out, " return 0;\n" ) ;
fprintf ( out, "}\n\n" ) ;
// Close up shop
fclose ( out ) ;
main_window_changed = false ;
}
+504
View File
@@ -0,0 +1,504 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE P-Guide>
<savefile>
<version>VERSION</version>
<project>Test Project</project>
<autolock>TRUE</autolock>
<window>
<name>Sample P-Guide File</name>
<size>
<width>600</width>
<height>400</height>
</size>
<position>
<x>0</x>
<y>0</y>
</position>
<color>
<r>0.750000</r>
<g>0.550000</g>
<b>0.650000</b>
<a>1.000000</a>
</color>
</window>
<objects>
<widget>
<name>left_arrow</name>
<type>puArrowButton</type>
<callbacks>Up</callbacks>
<layer>1</layer>
<visible>TRUE</visible>
<locked>TRUE</locked>
<size>
<width>24</width>
<height>101</height>
</size>
<position>
<x>93</x>
<y>96</y>
</position>
<data>
<int1>0</int1>
<int2>0</int2>
<bool1>FALSE</bool1>
<bool2>FALSE</bool2>
<bool3>FALSE</bool3>
<float1>0.000000</float1>
<float2>0.000000</float2>
<float3>0.000000</float3>
<float4>0.000000</float4>
<float5>0.000000</float5>
<float6>0.000000</float6>
<item>Double-Left</item>
</data>
</widget>
<widget>
<name>right_arrow</name>
<type>puArrowButton</type>
<callbacks>Up</callbacks>
<layer>1</layer>
<visible>TRUE</visible>
<locked>TRUE</locked>
<size>
<width>25</width>
<height>101</height>
</size>
<position>
<x>127</x>
<y>96</y>
</position>
<data>
<int1>0</int1>
<int2>0</int2>
<bool1>FALSE</bool1>
<bool2>FALSE</bool2>
<bool3>FALSE</bool3>
<float1>0.000000</float1>
<float2>0.000000</float2>
<float3>0.000000</float3>
<float4>0.000000</float4>
<float5>0.000000</float5>
<float6>0.000000</float6>
<item>Double-Right</item>
</data>
</widget>
<widget>
<name>combo</name>
<type>puComboBox</type>
<callbacks>Up</callbacks>
<layer>1</layer>
<visible>TRUE</visible>
<locked>TRUE</locked>
<size>
<width>166</width>
<height>70</height>
</size>
<position>
<x>89</x>
<y>20</y>
</position>
<data>
<int1>2</int1>
<int2>0</int2>
<bool1>FALSE</bool1>
<bool2>FALSE</bool2>
<bool3>FALSE</bool3>
<float1>0.000000</float1>
<float2>0.000000</float2>
<float3>0.000000</float3>
<float4>0.000000</float4>
<float5>0.000000</float5>
<float6>0.000000</float6>
<item>Option 1</item>
<item>Option 2</item>
<item>Option 3</item>
<item>Final</item>
</data>
</widget>
<widget>
<name>oneshot3</name>
<legend>
<text>Run Away</text>
<pos>PUPLACE_CENTERED_CENTERED</pos>
</legend>
<type>puOneShot</type>
<callbacks>Up</callbacks>
<layer>1</layer>
<visible>TRUE</visible>
<locked>TRUE</locked>
<size>
<width>90</width>
<height>20</height>
</size>
<position>
<x>154</x>
<y>127</y>
</position>
<data>
<int1>0</int1>
<int2>0</int2>
<bool1>FALSE</bool1>
<bool2>FALSE</bool2>
<bool3>FALSE</bool3>
<float1>0.000000</float1>
<float2>0.000000</float2>
<float3>0.000000</float3>
<float4>0.000000</float4>
<float5>0.000000</float5>
<float6>0.000000</float6>
</data>
</widget>
<widget>
<name>oneshot2</name>
<legend>
<text>Shoot</text>
<pos>PUPLACE_CENTERED_CENTERED</pos>
</legend>
<type>puOneShot</type>
<callbacks>Up</callbacks>
<layer>1</layer>
<visible>TRUE</visible>
<locked>TRUE</locked>
<size>
<width>90</width>
<height>20</height>
</size>
<position>
<x>154</x>
<y>152</y>
</position>
<data>
<int1>0</int1>
<int2>0</int2>
<bool1>FALSE</bool1>
<bool2>FALSE</bool2>
<bool3>FALSE</bool3>
<float1>0.000000</float1>
<float2>0.000000</float2>
<float3>0.000000</float3>
<float4>0.000000</float4>
<float5>0.000000</float5>
<float6>0.000000</float6>
</data>
</widget>
<widget>
<name>oneshot1</name>
<legend>
<text>Execute</text>
<pos>PUPLACE_CENTERED_CENTERED</pos>
</legend>
<type>puOneShot</type>
<callbacks>Up</callbacks>
<layer>1</layer>
<visible>TRUE</visible>
<locked>TRUE</locked>
<size>
<width>90</width>
<height>20</height>
</size>
<position>
<x>154</x>
<y>177</y>
</position>
<data>
<int1>0</int1>
<int2>0</int2>
<bool1>FALSE</bool1>
<bool2>FALSE</bool2>
<bool3>FALSE</bool3>
<float1>0.000000</float1>
<float2>0.000000</float2>
<float3>0.000000</float3>
<float4>0.000000</float4>
<float5>0.000000</float5>
<float6>0.000000</float6>
</data>
</widget>
<widget>
<name>dizzy</name>
<type>puSpinBox</type>
<callbacks>Up</callbacks>
<layer>1</layer>
<visible>TRUE</visible>
<locked>TRUE</locked>
<size>
<width>166</width>
<height>40</height>
</size>
<position>
<x>89</x>
<y>205</y>
</position>
<data>
<int1>0</int1>
<int2>0</int2>
<bool1>TRUE</bool1>
<bool2>TRUE</bool2>
<bool3>FALSE</bool3>
<float1>20.000000</float1>
<float2>0.000000</float2>
<float3>1.000000</float3>
<float4>0.500000</float4>
<float5>0.000000</float5>
<float6>0.000000</float6>
</data>
</widget>
<widget>
<name>libris</name>
<label>
<text>Input</text>
<pos>PUPLACE_TOP_LEFT</pos>
</label>
<type>puLargeInput</type>
<callbacks>Up</callbacks>
<layer>1</layer>
<visible>TRUE</visible>
<locked>TRUE</locked>
<size>
<width>334</width>
<height>232</height>
</size>
<position>
<x>258</x>
<y>13</y>
</position>
<data>
<int1>2</int1>
<int2>5</int2>
<bool1>TRUE</bool1>
<bool2>FALSE</bool2>
<bool3>FALSE</bool3>
<float1>0.000000</float1>
<float2>0.000000</float2>
<float3>0.000000</float3>
<float4>0.000000</float4>
<float5>0.000000</float5>
<float6>0.000000</float6>
<allowed> </allowed>
</data>
</widget>
<widget>
<name>dial2</name>
<type>puDial</type>
<callbacks>Up</callbacks>
<layer>0</layer>
<visible>TRUE</visible>
<locked>TRUE</locked>
<size>
<width>50</width>
<height>50</height>
</size>
<position>
<x>88</x>
<y>255</y>
</position>
<data>
<int1>0</int1>
<int2>0</int2>
<bool1>TRUE</bool1>
<bool2>TRUE</bool2>
<bool3>FALSE</bool3>
<float1>5.000000</float1>
<float2>0.000000</float2>
<float3>1.000000</float3>
<float4>0.000000</float4>
<float5>0.000000</float5>
<float6>0.000000</float6>
</data>
</widget>
<widget>
<name>dial1</name>
<type>puDial</type>
<callbacks>Up</callbacks>
<layer>0</layer>
<visible>TRUE</visible>
<locked>FALSE</locked>
<size>
<width>50</width>
<height>50</height>
</size>
<position>
<x>87</x>
<y>309</y>
</position>
<data>
<int1>0</int1>
<int2>0</int2>
<bool1>TRUE</bool1>
<bool2>TRUE</bool2>
<bool3>FALSE</bool3>
<float1>1.000000</float1>
<float2>0.000000</float2>
<float3>0.000000</float3>
<float4>0.000000</float4>
<float5>0.000000</float5>
<float6>0.000000</float6>
</data>
</widget>
<widget>
<name>slider</name>
<type>puSlider</type>
<callbacks>Up</callbacks>
<layer>0</layer>
<visible>TRUE</visible>
<locked>TRUE</locked>
<size>
<width>35</width>
<height>356</height>
</size>
<position>
<x>50</x>
<y>7</y>
</position>
<data>
<int1>0</int1>
<int2>0</int2>
<bool1>TRUE</bool1>
<bool2>TRUE</bool2>
<bool3>FALSE</bool3>
<float1>10.000000</float1>
<float2>0.000000</float2>
<float3>0.000000</float3>
<float4>0.500000</float4>
<float5>0.000000</float5>
<float6>0.000000</float6>
</data>
</widget>
<widget>
<name>trislider</name>
<type>puTriSlider</type>
<callbacks>Up</callbacks>
<layer>0</layer>
<visible>TRUE</visible>
<locked>FALSE</locked>
<size>
<width>47</width>
<height>356</height>
</size>
<position>
<x>1</x>
<y>7</y>
</position>
<data>
<int1>0</int1>
<int2>0</int2>
<bool1>TRUE</bool1>
<bool2>TRUE</bool2>
<bool3>FALSE</bool3>
<float1>17.000000</float1>
<float2>-5.000000</float2>
<float3>2.000000</float3>
<float4>16.000000</float4>
<float5>-0.500000</float5>
<float6>0.500000</float6>
</data>
</widget>
<widget>
<name>menu_bar</name>
<type>puMenuBar</type>
<callbacks>Up</callbacks>
<layer>0</layer>
<visible>TRUE</visible>
<locked>TRUE</locked>
<size>
<width>120</width>
<height>30</height>
</size>
<position>
<x>0</x>
<y>367</y>
</position>
<data>
<int1>0</int1>
<int2>0</int2>
<bool1>FALSE</bool1>
<bool2>FALSE</bool2>
<bool3>FALSE</bool3>
<float1>0.000000</float1>
<float2>0.000000</float2>
<float3>0.000000</float3>
<float4>0.000000</float4>
<float5>0.000000</float5>
<float6>0.000000</float6>
<item>File</item>
<item>Edit</item>
<item>View</item>
<item>Project</item>
<item>Build</item>
<item>Debug</item>
<item>Tools</item>
<item>Options</item>
<item>Window</item>
<item>Bookmarks</item>
<item>Help</item>
</data>
</widget>
<widget>
<name>buttonbox</name>
<type>puButtonBox</type>
<callbacks>Up</callbacks>
<layer>1</layer>
<visible>TRUE</visible>
<locked>TRUE</locked>
<size>
<width>163</width>
<height>134</height>
</size>
<position>
<x>428</x>
<y>249</y>
</position>
<data>
<int1>0</int1>
<int2>0</int2>
<bool1>FALSE</bool1>
<bool2>FALSE</bool2>
<bool3>FALSE</bool3>
<float1>0.000000</float1>
<float2>0.000000</float2>
<float3>0.000000</float3>
<float4>0.000000</float4>
<float5>0.000000</float5>
<float6>0.000000</float6>
<item>On</item>
<item>Off</item>
<item>Automatic</item>
</data>
</widget>
<widget>
<name>widget1</name>
<label>
<text>This is a test application</text>
<pos>PUPLACE_LOWER_RIGHT</pos>
</label>
<type>puText</type>
<callbacks>Up</callbacks>
<layer>1</layer>
<visible>TRUE</visible>
<locked>TRUE</locked>
<size>
<width>5</width>
<height>20</height>
</size>
<position>
<x>173</x>
<y>360</y>
</position>
<data>
<int1>0</int1>
<int2>0</int2>
<bool1>FALSE</bool1>
<bool2>FALSE</bool2>
<bool3>FALSE</bool3>
<float1>0.000000</float1>
<float2>0.000000</float2>
<float3>0.000000</float3>
<float4>0.000000</float4>
<float5>0.000000</float5>
<float6>0.000000</float6>
</data>
</widget>
</objects>
</savefile>
+916
View File
@@ -0,0 +1,916 @@
/*
This file is part of P-GUIDE -
PUI-based Graphical User Interface Designer.
Copyright (C) 2002, 2006 John F. Fay
P-GUIDE 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.
P-GUIDE 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 P-GUIDE; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
$Id: pGuide.cxx 2083 2006-05-01 13:14:50Z bram $
*/
#ifdef VERSION
#undef VERSION
#endif
#define VERSION = "0.1a"
// Program to allow the user to build a PUI Graphical User Interface
#include "WidgetList.h"
WidgetList *widgets = (WidgetList *)NULL ;
int max_layer = 1 ;
puObject *active_object = (puObject *)NULL ;
WidgetList *active_widget = (WidgetList *)NULL ;
static short activity_flag = 0 ; // 0 - inactive; 1 - moving; 2 - resizing xmin, 3 - resizing ymin, 4 - resizing xmax, 5 - resizing ymax
static int resize_symmetric = 1 ;
static int resize_corner = 0 ;
static int mouse_x_position_in_object = 0 ;
static int mouse_y_position_in_object = 0 ;
static int pguide_last_buttons = 0 ; // Because puMouse isn't called, we have to do our own last_buttons checking
// Main window parameters
int main_window = 0 ; // Main window handle
int main_window_width = 600 ;
int main_window_height = 600 ;
char main_window_name [ PUSTRING_MAX ] ;
int main_window_x = 0, main_window_y = 0 ;
float main_window_color_r = 1.0, main_window_color_g = 1.0,
main_window_color_b = 1.0, main_window_color_a = 1.0 ;
bool main_window_changed = false ;
static bool done_first_setup = false ;
bool currently_loading = false ;
static int ctrl_key_down = 0 ;
static int mouse_x = 0 ;
static int mouse_y = 0 ;
char pguide_current_directory [ PUSTRING_MAX ] ;
// Widget count
int widget_number = 0 ;
// Upon creation of new widgets, should they automatically be made "locked"?
bool autolock = false ;
// Properties popup
static puPopupMenu *context_menu;
// From the status window:
extern void setStatusWidgets ( WidgetList *wid ) ;
// From the properties window:
extern int properties_window;
// Definitions
#define RESIZING_BORDER_WIDTH 5
#define RESIZING_CORNER_BORDER_WIDTH 4
/** 4 seems to be the best number for this define... this makes sure *
* that the default widget size allows you to still resize along the *
* X axis without difficulty - 23 Jan 03 JCJ **/
// Properties Callback
static void cb_edit_properties ( puObject *ob )
{
if (properties_window)
{
extern puGroup *properties_group;
/* Delete the widgets */
puDeleteObject( properties_group );
glutDestroyWindow( properties_window );
properties_window = 0;
glutSetWindow( main_window );
}
extern int define_properties_window () ;
// Open the properties menu
define_properties_window();
}
static void cb_lock_toggle ( puObject *ob )
{
WidgetList *wid = widgets ;
while ( wid )
{
if ( wid->obj == active_object )
{
if (wid->locked == false)
wid->locked = true ;
else
wid->locked = false ;
}
wid = wid->next ;
}
}
static void cb_popup_delete ( puObject *ob )
{
WidgetList *wid = widgets ;
WidgetList *prv = (WidgetList *)NULL ;
while ( wid )
{
if ( wid->obj == active_object )
{
if ( prv ) // Remove the widget from the linked list
prv->next = wid->next ;
else
widgets = wid->next ;
delete wid->object_type_name ; // Delete the widget
delete wid->legend_text ;
delete wid->label_text ;
delete wid->obj ;
delete wid->allowed ;
delete wid->items ;
delete wid ;
active_widget = (WidgetList *)NULL ;
active_object = (puObject *)NULL ;
wid = (WidgetList *)NULL ;
if (properties_window)
{
extern puGroup *properties_group;
/* Delete the widgets */
puDeleteObject( properties_group );
glutDestroyWindow( properties_window );
properties_window = 0;
glutSetWindow( main_window );
}
}
else
{
prv = wid ;
wid = wid->next ;
}
}
}
// GLUT Main Window Callbacks
static void process_key ( int key )
{
extern int selected_object_type ;
extern puButton *active_button ;
ctrl_key_down = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ;
#define NUDGE_DISTANCE 1
#define LARGE_NUDGE_DISTANCE 10
if ( active_object ) // Active object; check the keys
{
main_window_changed = true ;
int xo, yo ;
active_object->getPosition ( &xo, &yo ) ;
int dist = ctrl_key_down ? LARGE_NUDGE_DISTANCE : NUDGE_DISTANCE ;
if ( key == GLUT_KEY_LEFT )
active_object->setPosition ( xo-dist, yo ) ;
else if ( key == GLUT_KEY_RIGHT )
active_object->setPosition ( xo+dist, yo ) ;
else if ( key == GLUT_KEY_UP )
active_object->setPosition ( xo, yo+dist ) ;
else if ( key == GLUT_KEY_DOWN )
active_object->setPosition ( xo, yo-dist ) ;
else if ( ( key == 127 ) || ( key == 8 ) ) // Delete or Backspace
{
WidgetList *wid = widgets ;
WidgetList *prv = (WidgetList *)NULL ;
while ( wid )
{
if ( wid->obj == active_object )
{
if ( prv ) // Remove the widget from the linked list
prv->next = wid->next ;
else
widgets = wid->next ;
delete wid->object_type_name ; // Delete the widget
delete wid->legend_text ;
delete wid->label_text ;
delete wid->obj ;
delete wid->allowed ;
delete wid->items ;
delete wid ;
active_widget = (WidgetList *)NULL ;
active_object = (puObject *)NULL ;
wid = (WidgetList *)NULL ;
}
else
{
prv = wid ;
wid = wid->next ;
}
}
}
else if ( key == 27 ) // Escape key, deactivate the object
{
active_widget = (WidgetList *)NULL ;
active_object = (puObject *)NULL ;
}
setStatusWidgets ( active_widget ) ;
}
if ( selected_object_type )
{
if ( key == 27 ) // Escape key, deactivate the selected button
{
selected_object_type = 0 ;
active_button->setValue ( 0 ) ;
}
}
glutPostRedisplay () ;
}
static void main_window_specialfn ( int key, int, int )
{
process_key ( key ) ;
}
static void main_window_keyfn ( unsigned char key, int, int )
{
process_key ( key ) ;
}
static void main_window_motionfn ( int x, int yy )
{
int y = main_window_height - yy ;
mouse_x = x ;
mouse_y = y ;
// Dragging the mouse: If there is an active object, slide it around
if ( ( active_object ) && ( pguide_last_buttons != 4 ) )
{
WidgetList *wid = widgets ;
while ( wid )
{
if ( wid->obj == active_object )
{
if (wid->locked == false)
{
extern puInput *object_position_x ;
extern puInput *object_position_y ;
extern puInput *object_size_x ;
extern puInput *object_size_y ;
main_window_changed = true ;
int dist ;
int xo, yo ;
active_object->getPosition ( &xo, &yo ) ;
int w, h ;
active_object->getSize ( &w, &h ) ;
if (resize_corner == 1)
{
switch ( activity_flag )
{
case 2 : // Resize top-right
case 3 :
activity_flag = 6;
break ;
case 4 : // Resize bottom_left
case 5 :
activity_flag = 7;
break ;
}
}
switch ( activity_flag )
{
case 1 : // Moving the object
active_object->setPosition ( x - mouse_x_position_in_object,
y - mouse_y_position_in_object ) ;
break ;
case 2 : // Resizing on x-min
dist = x - xo ;
if (w - dist < 5) break ;
if ( resize_symmetric * dist > w ) dist = w / resize_symmetric - 1 ;
active_object->setPosition ( x, yo ) ;
active_object->setSize ( w - resize_symmetric * dist, h ) ;
break ;
case 3 : // Resizing on y-min
dist = y - yo ;
if (h - dist < 5) break ;
if ( resize_symmetric * dist > h ) dist = h / resize_symmetric - 1 ;
active_object->setPosition ( xo, y ) ;
active_object->setSize ( w, h - resize_symmetric * dist ) ;
break ;
case 4 : // Resizing on x-max
dist = x - xo - w ;
if (w + dist < 5) break ;
if ( resize_symmetric * dist < -w ) dist = 1 - w / resize_symmetric ;
active_object->setSize ( w + resize_symmetric * dist, h ) ;
if ( resize_symmetric == 2 ) active_object->setPosition ( xo - dist, yo ) ;
break ;
case 5 : // Resizing on y-max
dist = y - yo - h ;
if (h + dist < 5) break ;
if ( resize_symmetric * dist < -h ) dist = 1 - h / resize_symmetric ;
active_object->setSize ( w, h + resize_symmetric * dist ) ;
if ( resize_symmetric == 2 ) active_object->setPosition ( xo, yo - dist ) ;
break ;
case 6 : // Resizing bottom-left
if ( yo - y > xo - x )
dist = yo - y;
else
dist = xo - x;
if ( (w + dist < 5) || (h + dist < 5) ) break ;
active_object->setPosition ( xo - dist, yo - dist ) ;
active_object->setSize ( w + dist, h + dist ) ;
break ;
case 7 : // Resizing top-right
if (y-yo-h>x-xo-w)
dist = y - yo - h ;
else
dist = x - xo - w ;
if ( (w + dist < 5) || (h + dist < 5) ) break ;
active_object->setSize ( w + dist, h + dist ) ;
break ;
case 8 : // Resizing top-left
if (y-yo-h>x-xo-w)
dist = y - yo - h ;
else
dist = xo - x ;
if ( (w + dist < 5) || (h + dist < 5) ) break ;
active_object->setPosition ( xo - dist, yo ) ;
active_object->setSize ( w + dist, h + dist ) ;
break ;
case 9 : // Resizing bottom-right
if (y-yo-h>x-xo-w)
dist = yo - y ;
else
dist = x - xo - w ;
if ( (w + dist < 5) || (h + dist < 5) ) break ;
active_object->setPosition ( xo , yo - dist ) ;
active_object->setSize ( w + dist, h + dist ) ;
break ;
}
int a, b ;
active_object->getPosition ( &a, &b ) ;
object_position_x->setValue ( a ) ;
object_position_y->setValue ( b ) ;
active_object->getSize ( &a, &b ) ;
object_size_x->setValue ( a ) ;
object_size_y->setValue ( b ) ;
}
}
wid = wid->next ;
}
}
glutPostRedisplay () ;
}
static void main_window_passivefn ( int x, int yy )
{
int y = main_window_height - yy ;
// Dragging the mouse without a button down: save the mouse coordinates
mouse_x = x ;
mouse_y = y ;
/*if (context_menu->isVisible() == 1)
{
puBox *cont_box = context_menu->getABox();
if ( ( x >= cont_box->min[0] ) && ( x <= cont_box->max[0] ) &&
( y >= cont_box->min[1] ) && ( y <= cont_box->max[1] ) )
{
context_menu->checkHit(-1, 0, mouse_x, mouse_y);
}
}*/
}
static void main_window_mousefn ( int button, int updown, int x, int yy )
{
int y = main_window_height - yy ;
mouse_x = x ;
mouse_y = y ;
if ( updown == PU_DOWN )
pguide_last_buttons |= ( 1 << button ) ;
else
pguide_last_buttons &= ~( 1 << button ) ;
if ( button == PU_RIGHT_BUTTON )
{
/* Pressed the right mouse button -- popup the manipulation window. */
WidgetList *wid = widgets ;
while ( wid )
{
puBox *box = wid->obj->getABox () ;
if ( wid->visible && ( x >= box->min[0] ) && ( x <= box->max[0] ) &&
( y >= box->min[1] ) && ( y <= box->max[1] ) )
{
active_widget = wid ;
active_object = wid->obj ;
/* We can modify mouse_x and mouse_y, because theyre not used again if we're in the right mouse function */
/* If we're real close to the right of the screen, modify the X position ...*/
if (mouse_x > main_window_width - 110 ) mouse_x = main_window_width - 110 ;
/* If we're real close to the top of the screen, modify the Y position...*/
if (mouse_y > main_window_height - 140) mouse_y = main_window_height - 140 ;
context_menu->setPosition(mouse_x, mouse_y) ;
context_menu->reveal() ;
//puSetActiveWidget(context_menu, mouse_x, mouse_y) ;
break ;
}
wid = wid->next ;
}
} else {
if ( puActiveWidget() && ( active_object != puActiveWidget() ) )
{
puActiveWidget() -> invokeDownCallback () ;
puDeactivateWidget () ;
}
ctrl_key_down = ( glutGetModifiers () & GLUT_ACTIVE_CTRL ) ;
if ( ( context_menu->isVisible() == 1) && ( active_widget ) )
{
puBox *cont_box = context_menu->getABox();
if ( ( x >= cont_box->min[0] ) && ( x <= cont_box->max[0] ) &&
( y >= cont_box->min[1] ) && ( y <= cont_box->max[1] ) )
{
context_menu->checkHit(button, updown, mouse_x, mouse_y);
} else {
context_menu->hide();
}
} else /*if ( context_menu->isVisible() == 1) { context_menu->hide(); } * The user did something funny, so hide the menu since they've been naughty */
{
// Downclick: Place a new widget, activate an existing widget, deactivate widget, or select from menu.
if ( updown == GLUT_DOWN )
{
// If there is a selected object, create a new one of that type.
// extern puObject *createWidget ( int type ) ;
extern int selected_object_type ;
if ( selected_object_type )
{
extern bool selected_object_sticky ;
extern char *selected_type_string ;
extern puButton *active_button ;
main_window_changed = true ;
// puObject *new_obj = createWidget ( selected_object->getType () ) ;
puObject *new_obj = new puFrame ( 0, 0, 90, 20 ) ;
char *object_type_name = new char [ PUSTRING_MAX ] ;
strcpy ( object_type_name, selected_type_string ) ;
new_obj->setLegend ( object_type_name ) ;
// Add the new object to the list of widgets
WidgetList *new_wid = new WidgetList ;
new_wid->obj = new_obj ;
new_wid->label_text = (char *)NULL ;
new_wid->legend_text = (char *)NULL ;
new_wid->allowed = (char *)NULL ;
new_wid->items = (char *)NULL ;
new_wid->object_type_name = object_type_name ;
new_wid->object_type = selected_object_type ;
new_wid->callbacks = 1 ; // Default: up callback enabled, others disabled
sprintf ( new_wid->object_name, "widget%d", widget_number++ ) ;
new_wid->visible = true ;
new_wid->locked = autolock ; /* Set it to the autolock var (true or false ) */
new_wid->layer = max_layer - 1 ;
new_wid->next = widgets ;
widgets = new_wid ;
// Set the new widget's position
new_obj->setPosition ( x, y ) ;
mouse_x_position_in_object = 0 ;
mouse_y_position_in_object = 0 ;
/* Set up the widget's default data values */
new_wid->intval1 = 0;
new_wid->intval2 = 0;
new_wid->boolval1 = false;
new_wid->boolval2 = false;
new_wid->boolval3 = false;
new_wid->floatval1 = 0.0f;
new_wid->floatval2 = 0.0f;
new_wid->floatval3 = 0.0f;
new_wid->floatval4 = 0.0f;
new_wid->floatval5 = 0.0f;
new_wid->floatval6 = 0.0f;
if (new_wid->object_type == PUCLASS_TEXT)
{
new_obj->setSize(5,20);
}
if (new_wid->object_type == PUCLASS_COMBOBOX)
{
new_wid->intval1 = 1;
new_wid->boolval1 = true;
}
if (new_wid->object_type == PUCLASS_SELECTBOX)
{
new_wid->intval1 = 1;
}
if (new_wid->object_type == PUCLASS_BUTTONBOX)
{
new_wid->boolval1 = true;
}
if (new_wid->object_type == PUCLASS_COMBOBOX)
{
new_wid->intval1 = 1;
new_wid->boolval1 = true;
}
if ( (new_wid->object_type == PUCLASS_SLIDER ) ||
(new_wid->object_type == PUCLASS_BISLIDER ) ||
(new_wid->object_type == PUCLASS_TRISLIDER ) ||
(new_wid->object_type == PUCLASS_DIAL ) ||
(new_wid->object_type == PUCLASS_SPINBOX ) ||
(new_wid->object_type == PUCLASS_SCROLLBAR ) )
{
new_wid->floatval1 = 1.0f;
new_wid->floatval2 = 0.0f;
new_wid->floatval3 = 0.0f;
new_wid->boolval1 = true;
}
if ( (new_wid->object_type == PUCLASS_SLIDER ) ||
(new_wid->object_type == PUCLASS_BISLIDER ) ||
(new_wid->object_type == PUCLASS_TRISLIDER ) )
{
new_wid->boolval2 = true;
}
if (new_wid->object_type == PUCLASS_SLIDER)
{
new_wid->floatval4 = 0.5f;
}
if (new_wid->object_type == PUCLASS_BISLIDER)
{
new_wid->floatval4 = 1.0f;
new_wid->floatval5 = 0.0f;
}
if (new_wid->object_type == PUCLASS_TRISLIDER)
{
new_wid->floatval4 = 1.0f;
new_wid->floatval5 = 0.0f;
new_wid->floatval6 = 0.5f;
new_wid->boolval3 = false;
}
if (new_wid->object_type == PUCLASS_DIAL)
{
new_obj->setSize(50,50);
new_wid->boolval2 = true;
}
if (new_wid->object_type == PUCLASS_SPINBOX)
{
new_wid->boolval2 = true;
new_wid->floatval4 = 0.5f;
}
if (new_wid->object_type == PUCLASS_SCROLLBAR)
{
/* Not Yet Implemented */
}
if (new_wid->object_type == PUCLASS_SPINBOX)
{
new_wid->boolval2 = true;
new_wid->floatval4 = 0.5f;
}
if (new_wid->object_type == PUCLASS_INPUT)
{
new_wid->boolval1 = true;
}
if (new_wid->object_type == PUCLASS_LARGEINPUT)
{
new_wid->boolval1 = true;
new_wid->intval1 = 1;
new_wid->intval2 = 5;
}
if (new_wid->object_type == PUCLASS_MENUBAR)
{
new_obj->setSize( 120, 30) ;
new_obj->setPosition( 0, puGetWindowHeight()-30) ;
new_wid->locked = true ;
}
if (new_wid->object_type == PUCLASS_VERTMENU)
{
new_obj->setSize( 45, 120) ;
new_obj->setPosition( 0, puGetWindowHeight()-120) ;
new_obj->setLegend("");
new_obj->setLabelPlace(PUPLACE_BOTTOM_LEFT);
new_obj->setLabel("puVerticalMenu");
new_wid->locked = true ;
}
// Make the new widget the active widget
active_object = new_obj ;
active_widget = new_wid ;
// If the "sticky" flag is not set, reset the selected object
if ( !selected_object_sticky )
{
selected_object_type = 0 ;
active_button->setValue ( 0 ) ;
}
}
else
{
// Clicking on a widget in the main widget list activates it
WidgetList *wid = widgets ;
while ( wid )
{
puBox *box = wid->obj->getABox () ;
if ( wid->visible && ( x >= box->min[0] ) && ( x <= box->max[0] ) &&
( y >= box->min[1] ) && ( y <= box->max[1] ) )
{
active_widget = wid ;
active_object = wid->obj ;
if ( abs ( x - box->min[0] ) < RESIZING_BORDER_WIDTH )
activity_flag = 2 ; // Resizing on x-min
else if ( abs ( x - box->max[0] ) < RESIZING_BORDER_WIDTH )
activity_flag = 4 ; // Resizing on x-max
else if ( abs ( y - box->min[1] ) < RESIZING_BORDER_WIDTH )
activity_flag = 3 ; // Resizing on y-min
else if ( abs ( y - box->max[1] ) < RESIZING_BORDER_WIDTH )
activity_flag = 5 ; // Resizing on y-max
else
activity_flag = 1 ; // Away from edges, we're moving it
/* Now we check and see if we're clicking on a corner - the sensitivity for
the determiniation of whether we're clicking a corner or not is held by the
definition of "RESIZING_CORNER_BORDER_WIDTH" which is at the top of this file */
int corner_resize_width = RESIZING_CORNER_BORDER_WIDTH + (((box->max[0] - box->min[0]) + (box->max[1] - box->min[1]) / 2 ) / 50 ) * 2 ;
if ( activity_flag != 1 )
{
// Bottom Right Corner
if ( ( abs( y - box->min[1] ) < corner_resize_width ) && (abs ( x - box->max[0] ) < corner_resize_width ) )
activity_flag = 9;
// Bottom Left Corner
if ( ( abs( y - box->min[1] ) < corner_resize_width ) && (abs ( x - box->min[0] ) < corner_resize_width ) )
activity_flag = 6;
// Top Right Corner
if ( ( abs( y - box->max[1] ) < corner_resize_width ) && (abs ( x - box->max[0] ) < corner_resize_width ) )
activity_flag = 7;
// Top Left Corner
if ( ( abs( y - box->max[1] ) < corner_resize_width ) && (abs ( x - box->min[0] ) < corner_resize_width ) )
activity_flag = 8;
}
/* If CTRL is held down, symmetric resize is forced. */
resize_symmetric = ctrl_key_down ? 2 : 1 ;
if (active_widget->object_type == PUCLASS_DIAL)
resize_corner = 1 ;
else
resize_corner = 0;
int object_x, object_y ;
active_object->getPosition ( &object_x, &object_y ) ;
mouse_x_position_in_object = x - object_x ;
mouse_y_position_in_object = y - object_y ;
break ;
}
wid = wid->next ;
}
if ( ( !wid ) && ( context_menu->isVisible()==0 ) ) // Ran through the entire list, deactivate any active widget
{
active_widget = (WidgetList *)NULL ;
active_object = (puObject *)NULL ;
}
}
}
setStatusWidgets ( active_widget ) ;
}
}
glutPostRedisplay () ;
}
static void main_window_reshapefn ( int w, int h )
{
extern puInput *window_size_x ;
extern puInput *window_size_y ;
if (done_first_setup)
main_window_changed = true ;
else
done_first_setup = true ;
if ( ( !currently_loading ) && (
( mouse_x < main_window_width/2 ) || // Grabbed the left edge ...
( mouse_y < main_window_height/2 ) ) ) // or the bottom edge, move the widgets
{
WidgetList *wid = widgets ;
int deltax = 0 ;
int deltay = 0 ;
if ( mouse_x < main_window_width/2 ) deltax = w - main_window_width ;
if ( mouse_y < main_window_height/2 ) deltay = h - main_window_height ;
while ( wid )
{
int x, y ;
wid->obj->getPosition ( &x, &y ) ;
wid->obj->setPosition ( x + deltax, y + deltay ) ;
wid = wid->next ;
}
}
main_window_width = w ;
main_window_height = h ;
window_size_x->setValue ( w ) ;
window_size_y->setValue ( h ) ;
currently_loading = false ;
}
static void main_window_displayfn ( void )
{
/* Clear the screen */
glutSetWindow ( main_window ) ;
glClearColor ( main_window_color_r, main_window_color_g, main_window_color_b, main_window_color_a ) ;
glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) ;
// Set the OpenGL to draw PUI widgets
int w = puGetWindowWidth () ;
int h = puGetWindowHeight () ;
glPushAttrib ( GL_ENABLE_BIT | GL_TRANSFORM_BIT | GL_LIGHTING_BIT ) ;
glDisable ( GL_LIGHTING ) ;
glDisable ( GL_FOG ) ;
glDisable ( GL_TEXTURE_2D ) ;
glDisable ( GL_DEPTH_TEST ) ;
glDisable ( GL_CULL_FACE ) ;
glViewport ( 0, 0, w, h ) ;
glMatrixMode ( GL_PROJECTION ) ;
glPushMatrix () ;
glLoadIdentity () ;
gluOrtho2D ( 0, w, 0, h ) ;
glMatrixMode ( GL_MODELVIEW ) ;
glPushMatrix () ;
glLoadIdentity () ;
// Draw the widgets
int layer ;
for ( layer = 0; layer < max_layer; layer++ )
{
WidgetList *wid = widgets ;
while ( wid )
{
if ( wid->visible && ( wid->layer == layer ) ) wid->obj->draw ( 0, 0 ) ;
wid = wid->next ;
}
}
if ( active_object )
{
puBox *box = active_object->getBBox () ;
glColor4f ( 0.0f, 0.0f, 0.0f, 1.0f ) ;
glLineWidth ( 3.0f ) ;
glBegin ( GL_LINES ) ;
glVertex2i ( box->min[0]-1, box->min[1]-1 ) ;
glVertex2i ( box->max[0]+1, box->min[1]-1 ) ;
glVertex2i ( box->max[0]+1, box->max[1]+1 ) ;
glVertex2i ( box->min[0]-1, box->max[1]+1 ) ;
glVertex2i ( box->min[0]-1, box->min[1]-1 ) ;
glEnd () ;
}
context_menu->draw(0,0);
/* Update GLUT */
glutSwapBuffers () ;
glutPostRedisplay () ;
}
int main ( int argc, char **argv )
{
extern int define_widget_window () ;
extern int define_status_window () ;
int i = 0;
strcpy ( main_window_name, "PUI GUI Builder" ) ;
glutInitWindowPosition( 100, 0 ) ;
glutInitWindowSize ( main_window_width, main_window_height ) ;
glutInit ( &argc, argv ) ;
glutInitDisplayMode ( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ) ;
main_window = glutCreateWindow ( main_window_name ) ;
glutDisplayFunc ( main_window_displayfn ) ;
glutKeyboardFunc ( main_window_keyfn ) ;
glutSpecialFunc ( main_window_specialfn ) ;
glutMouseFunc ( main_window_mousefn ) ;
glutMotionFunc ( main_window_motionfn ) ;
glutPassiveMotionFunc ( main_window_passivefn ) ;
glutReshapeFunc ( main_window_reshapefn ) ;
glutIdleFunc ( main_window_displayfn ) ;
// If we're using windows, ignore the C: or whatnot
#ifdef WIN32
#define PATH_SEPARATOR '\\'
strcpy (pguide_current_directory, argv[0]+2);
#else
#define PATH_SEPARATOR '/'
strcpy (pguide_current_directory, argv[0]);
#endif
i = strlen(pguide_current_directory);
while (pguide_current_directory[i] != PATH_SEPARATOR) {
if (i>0) i-- ;
else break ;
}
pguide_current_directory[i+1] = '\0';
puInit () ;
#ifdef VOODOO
puShowCursor () ;
#endif
puSetDefaultStyle ( PUSTYLE_SMALL_SHADED ) ;
puSetDefaultColourScheme ( 0.8f, 0.8f, 0.8f, 1.0f ) ;
// Add the properties context menu
context_menu = new puPopupMenu( 0, 0 ) ;
context_menu->add_item("Properties", cb_edit_properties) ;
context_menu->add_item("Lock/Unlock", cb_lock_toggle) ;
context_menu->add_item("Delete", cb_popup_delete) ;
context_menu->add_item("Cut", NULL) ;
context_menu->add_item("Copy", NULL) ;
context_menu->add_item("Change Class", NULL) ;
context_menu->close() ;
// Set up the other windows
define_widget_window () ;
define_status_window () ;
glutMainLoop () ;
return 0 ;
}
+128
View File
@@ -0,0 +1,128 @@
# Microsoft Developer Studio Project File - Name="pGuide" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
CFG=pGuide - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "pGuide.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "pGuide.mak" CFG="pGuide - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "pGuide - Win32 Release" (based on "Win32 (x86) Console Application")
!MESSAGE "pGuide - Win32 Debug" (based on "Win32 (x86) Console Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
F90=df.exe
RSC=rc.exe
!IF "$(CFG)" == "pGuide - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /W3 /GX /O2 /I "..\..\..\..\\" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "FREEGLUT_STATIC" /YX /FD /c
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 pui.lib puAux.lib sg.lib fnt.lib ul.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib opengl32.lib glu32.lib /nologo /subsystem:console /machine:I386 /libpath:"..\..\..\..\plib"
!ELSEIF "$(CFG)" == "pGuide - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "pGuide___Win32_Debug"
# PROP BASE Intermediate_Dir "pGuide___Win32_Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "pGuide___Win32_Debug"
# PROP Intermediate_Dir "pGuide___Win32_Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\..\..\..\\" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "FREEGLUT_STATIC" /FR /YX /FD /GZ /c
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 pui_d.lib puAux_d.lib sg_d.lib fnt_d.lib ul_d.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib opengl32.lib glu32.lib /nologo /subsystem:console /debug /machine:I386 /nodefaultlib:"LIBCMTD" /pdbtype:sept /libpath:"..\..\..\..\plib"
# SUBTRACT LINK32 /pdb:none
!ENDIF
# Begin Target
# Name "pGuide - Win32 Release"
# Name "pGuide - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\LoadSave.cxx
# End Source File
# Begin Source File
SOURCE=.\pGuide.cxx
# End Source File
# Begin Source File
SOURCE=.\PropertiesWindow.cxx
# End Source File
# Begin Source File
SOURCE=.\StatusWindow.cxx
# End Source File
# Begin Source File
SOURCE=.\WidgetWindow.cxx
# End Source File
# Begin Source File
SOURCE=.\WriteCode.cxx
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=.\WidgetList.h
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project