Moved OGL to new locations.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6327 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
@@ -1,68 +1,68 @@
|
||||
utils/ogl/Makefile.in
|
||||
src/ogl/*.cpp
|
||||
src/ogl/*.h
|
||||
src/ogl/*.rc
|
||||
src/ogl/*.def
|
||||
src/ogl/*.xbm
|
||||
src/ogl/*.xpm
|
||||
src/ogl/make*.*
|
||||
src/ogl/*.txt
|
||||
src/ogl/*.ico
|
||||
src/ogl/*.bmp
|
||||
|
||||
utils/ogl/src/*.cpp
|
||||
utils/ogl/src/*.h
|
||||
utils/ogl/src/*.rc
|
||||
utils/ogl/src/*.def
|
||||
utils/ogl/src/*.xbm
|
||||
utils/ogl/src/*.xpm
|
||||
utils/ogl/src/make*.*
|
||||
utils/ogl/src/*.txt
|
||||
utils/ogl/src/*.ico
|
||||
utils/ogl/src/*.bmp
|
||||
include/wx/ogl/*.h
|
||||
|
||||
utils/ogl/samples/ogledit/*.cpp
|
||||
utils/ogl/samples/ogledit/*.h
|
||||
utils/ogl/samples/ogledit/*.rc
|
||||
utils/ogl/samples/ogledit/*.def
|
||||
utils/ogl/samples/ogledit/*.xbm
|
||||
utils/ogl/samples/ogledit/make*.*
|
||||
utils/ogl/samples/ogledit/Makefile
|
||||
utils/ogl/samples/ogledit/*.txt
|
||||
utils/ogl/samples/ogledit/*.ico
|
||||
utils/ogl/samples/ogledit/*.bmp
|
||||
utils/ogl/samples/ogledit/*.xpm
|
||||
utils/ogl/samples/ogledit/bitmaps/*.bmp
|
||||
utils/ogl/samples/ogledit/bitmaps/*.gif
|
||||
utils/ogl/samples/ogledit/bitmaps/*.xbm
|
||||
utils/ogl/samples/ogledit/bitmaps/*.xpm
|
||||
samples/ogl/ogledit/*.cpp
|
||||
samples/ogl/ogledit/*.h
|
||||
samples/ogl/ogledit/*.rc
|
||||
samples/ogl/ogledit/*.def
|
||||
samples/ogl/ogledit/*.xbm
|
||||
samples/ogl/ogledit/make*.*
|
||||
samples/ogl/ogledit/Makefile
|
||||
samples/ogl/ogledit/*.txt
|
||||
samples/ogl/ogledit/*.ico
|
||||
samples/ogl/ogledit/*.bmp
|
||||
samples/ogl/ogledit/*.xpm
|
||||
samples/ogl/ogledit/bitmaps/*.bmp
|
||||
samples/ogl/ogledit/bitmaps/*.gif
|
||||
samples/ogl/ogledit/bitmaps/*.xbm
|
||||
samples/ogl/ogledit/bitmaps/*.xpm
|
||||
|
||||
utils/ogl/samples/studio/*.cpp
|
||||
utils/ogl/samples/studio/*.h
|
||||
utils/ogl/samples/studio/*.rc
|
||||
utils/ogl/samples/studio/*.def
|
||||
utils/ogl/samples/studio/*.xbm
|
||||
utils/ogl/samples/studio/make*.*
|
||||
utils/ogl/samples/studio/Makefile
|
||||
utils/ogl/samples/studio/*.txt
|
||||
utils/ogl/samples/studio/*.ico
|
||||
utils/ogl/samples/studio/*.bmp
|
||||
utils/ogl/samples/studio/*.xpm
|
||||
utils/ogl/samples/studio/*.wxr
|
||||
utils/ogl/samples/studio/bitmaps/*.bmp
|
||||
utils/ogl/samples/studio/bitmaps/*.gif
|
||||
utils/ogl/samples/studio/bitmaps/*.xbm
|
||||
utils/ogl/samples/studio/bitmaps/*.xpm
|
||||
utils/ogl/samples/studio/manual/*.tex
|
||||
utils/ogl/samples/studio/manual/*.ini
|
||||
utils/ogl/samples/studio/manual/*.gif
|
||||
utils/ogl/samples/studio/manual/*.bmp
|
||||
utils/ogl/samples/studio/manual/*.htm
|
||||
utils/ogl/samples/studio/manual/*.hlp
|
||||
utils/ogl/samples/studio/manual/*.cnt
|
||||
utils/ogl/samples/studio/manual/Makefile
|
||||
samples/ogl/studio/*.cpp
|
||||
samples/ogl/studio/*.h
|
||||
samples/ogl/studio/*.rc
|
||||
samples/ogl/studio/*.def
|
||||
samples/ogl/studio/*.xbm
|
||||
samples/ogl/studio/make*.*
|
||||
samples/ogl/studio/Makefile
|
||||
samples/ogl/studio/*.txt
|
||||
samples/ogl/studio/*.ico
|
||||
samples/ogl/studio/*.bmp
|
||||
samples/ogl/studio/*.xpm
|
||||
samples/ogl/studio/*.wxr
|
||||
samples/ogl/studio/bitmaps/*.bmp
|
||||
samples/ogl/studio/bitmaps/*.gif
|
||||
samples/ogl/studio/bitmaps/*.xbm
|
||||
samples/ogl/studio/bitmaps/*.xpm
|
||||
samples/ogl/studio/manual/*.tex
|
||||
samples/ogl/studio/manual/*.ini
|
||||
samples/ogl/studio/manual/*.gif
|
||||
samples/ogl/studio/manual/*.bmp
|
||||
samples/ogl/studio/manual/*.htm
|
||||
samples/ogl/studio/manual/*.hlp
|
||||
samples/ogl/studio/manual/*.cnt
|
||||
samples/ogl/studio/manual/Makefile
|
||||
|
||||
utils/ogl/distrib/*.rsp
|
||||
utils/ogl/distrib/*.bat
|
||||
distrib/msw/ogl.rsp
|
||||
distrib/msw/zipogl.bat
|
||||
|
||||
utils/ogl/docs/*.txt
|
||||
utils/ogl/docs/*.tex
|
||||
utils/ogl/docs/*.ini
|
||||
utils/ogl/docs/*.hpj
|
||||
utils/ogl/docs/*.ps
|
||||
utils/ogl/docs/*.eps
|
||||
utils/ogl/docs/*.bmp
|
||||
utils/ogl/docs/*.gif
|
||||
docs/latex/ogl/*.txt
|
||||
docs/latex/ogl/*.tex
|
||||
docs/latex/ogl/*.ini
|
||||
docs/latex/ogl/*.hpj
|
||||
docs/latex/ogl/*.ps
|
||||
docs/latex/ogl/*.eps
|
||||
docs/latex/ogl/*.bmp
|
||||
docs/latex/ogl/*.gif
|
||||
|
||||
docs/html/ogl/*.*
|
||||
docs/winhelp/ogl.hlp
|
||||
|
BIN
docs/latex/ogl/back.gif
Normal file
After Width: | Height: | Size: 225 B |
BIN
docs/latex/ogl/books.bmp
Normal file
After Width: | Height: | Size: 1.2 KiB |
11
docs/latex/ogl/bugs.tex
Normal file
@@ -0,0 +1,11 @@
|
||||
\chapter{Bugs}\label{bugs}%
|
||||
\setheader{{\it CHAPTER \thechapter}}{}{}{}{}{{\it CHAPTER \thechapter}}%
|
||||
\setfooter{\thepage}{}{}{}{}{\thepage}
|
||||
|
||||
These are the known bugs.
|
||||
|
||||
\begin{itemize}\itemsep=0pt
|
||||
\item In the OGLEdit sample, .dia files are output double-spaced
|
||||
due to an unidentified bug in the way a stream is converted to a file.
|
||||
\end{itemize}
|
||||
|
BIN
docs/latex/ogl/bullet.bmp
Normal file
After Width: | Height: | Size: 138 B |
19
docs/latex/ogl/changes.tex
Normal file
@@ -0,0 +1,19 @@
|
||||
\chapter{Change log}
|
||||
\setheader{{\it CHAPTER \thechapter}}{}{}{}{}{{\it CHAPTER \thechapter}}%
|
||||
\setfooter{\thepage}{}{}{}{}{\thepage}
|
||||
|
||||
Version 3.0, September 8th 1998
|
||||
|
||||
\begin{itemize}\itemsep=0pt
|
||||
\item Version for wxWindows 2.0.
|
||||
\item Various enhancements especially to wxDrawnShape
|
||||
(multiple metafiles, for different orientations).
|
||||
\item More ability to override functions e.g. OnSizeDragLeft, so events can be
|
||||
intercepted for Do/Undo.
|
||||
\end{itemize}
|
||||
|
||||
Version 2.0, June 1st 1996
|
||||
|
||||
\begin{itemize}\itemsep=0pt
|
||||
\item First publicly released version.
|
||||
\end{itemize}
|
2861
docs/latex/ogl/classes.tex
Normal file
BIN
docs/latex/ogl/contents.gif
Normal file
After Width: | Height: | Size: 231 B |
BIN
docs/latex/ogl/forward.gif
Normal file
After Width: | Height: | Size: 164 B |
47
docs/latex/ogl/intro.tex
Normal file
@@ -0,0 +1,47 @@
|
||||
\chapter{Introduction}
|
||||
\pagenumbering{arabic}%
|
||||
\setheader{{\it CHAPTER \thechapter}}{}{}{}{}{{\it CHAPTER \thechapter}}%
|
||||
\setfooter{\thepage}{}{}{}{}{\thepage}
|
||||
|
||||
Object Graphics Library (\ogl) is a C++ library supporting the creation and
|
||||
manipulation of simple and complex graphic images on a canvas.
|
||||
|
||||
It can be found in the directory {\tt utils/ogl/src} in the
|
||||
wxWindows distribution. The file {\tt ogl.h} must be included to make use
|
||||
of the library.
|
||||
|
||||
Please see \helpref{OGL overview}{ogloverview} for a general description how the object library works. For details,
|
||||
please see the \helpref{class reference}{classref}.
|
||||
|
||||
\section{File structure}
|
||||
|
||||
These are the files that comprise the \ogl\ library.
|
||||
|
||||
\begin{description}\itemsep=0pt
|
||||
\item[basic.h] Header for basic objects such as wxShape and wxRectangleShape.
|
||||
\item[basic.cpp] Basic objects implementation (1).
|
||||
\item[basic2.cpp] Basic objects implementation (2).
|
||||
\item[bmpshape.h] wxBitmapShape class header.
|
||||
\item[bmpshape.cpp] wxBitmapShape implementation.
|
||||
\item[canvas.h] wxShapeCanvas class header.
|
||||
\item[canvas.cpp] wxShapeCanvas class implementation.
|
||||
\item[composit.h] Composite object class header.
|
||||
\item[composit.cpp] Composite object class implementation.
|
||||
\item[constrnt.h] Constraint classes header.
|
||||
\item[constrnt.cpp] Constraint classes implementation.
|
||||
\item[divided.h] Divided object class header.
|
||||
\item[divided.cpp] Divided object class implementation.
|
||||
\item[drawn.h] Drawn (metafile) object class header.
|
||||
\item[drawn.cpp] Drawn (metafile) object class implementation.
|
||||
\item[graphics.h] Main include file.
|
||||
\item[lines.h] wxLineShape class header.
|
||||
\item[lines.cpp] wxLineShape class implementation.
|
||||
\item[misc.h] Miscellaneous graphics functions header.
|
||||
\item[misc.cpp] Miscellaneous graphics functions implementation.
|
||||
\item[ogldiag.h] wxDiagram class header.
|
||||
\item[ogldiag.cpp] wxDiagram implementation.
|
||||
\item[mfutils.h] Metafile utilities header.
|
||||
\item[mfutils.cpp] Metafile utilities implementation.
|
||||
\end{description}
|
||||
|
||||
|
17
docs/latex/ogl/ogl.hpj
Normal file
@@ -0,0 +1,17 @@
|
||||
[OPTIONS]
|
||||
BMROOT=d:\wx2\wxwind~1\docs\latex\ogl ; Assume that bitmaps are where the source is
|
||||
TITLE=OGL Manual
|
||||
CONTENTS=Contents
|
||||
COMPRESS=HIGH
|
||||
|
||||
[FILES]
|
||||
ogl.rtf
|
||||
|
||||
[CONFIG]
|
||||
CreateButton("Up", "&Up", "JumpId(`ogl.hlp', `Contents')")
|
||||
BrowseButtons()
|
||||
|
||||
[MAP]
|
||||
|
||||
[BITMAPS]
|
||||
|
46
docs/latex/ogl/ogl.tex
Normal file
@@ -0,0 +1,46 @@
|
||||
\documentstyle[a4,makeidx,verbatim,texhelp,fancyhea,mysober,mytitle]{report}
|
||||
\newcommand{\ogl}[0]{{OGL}}%
|
||||
\definecolour{black}{0}{0}{0}%
|
||||
\definecolour{cyan}{0}{255}{255}%
|
||||
\definecolour{green}{0}{255}{0}%
|
||||
\definecolour{magenta}{255}{0}{255}%
|
||||
\definecolour{red}{255}{0}{0}%
|
||||
\definecolour{blue}{0}{0}{200}%
|
||||
\definecolour{yellow}{255}{255}{0}%
|
||||
\definecolour{white}{255}{255}{255}%
|
||||
\input psbox.tex
|
||||
\parindent 0pt
|
||||
\parskip 11pt
|
||||
\title{Object Graphics Library 3.0}
|
||||
\author{Julian Smart}
|
||||
\date{September 1998}
|
||||
|
||||
\makeindex
|
||||
\begin{document}
|
||||
\maketitle
|
||||
|
||||
\pagestyle{fancyplain}
|
||||
\bibliographystyle{plain}
|
||||
\pagenumbering{roman}
|
||||
\setheader{{\it CONTENTS}}{}{}{}{}{{\it CONTENTS}}
|
||||
\setfooter{\thepage}{}{}{}{}{\thepage}
|
||||
\tableofcontents%
|
||||
|
||||
\input{intro.tex}
|
||||
%
|
||||
\input{sample.tex}
|
||||
%
|
||||
\input{classes.tex}
|
||||
%
|
||||
\input{topics.tex}
|
||||
%
|
||||
\input{bugs.tex}
|
||||
%
|
||||
\input{changes.tex}
|
||||
|
||||
%
|
||||
\addcontentsline{toc}{chapter}{Index}
|
||||
\setheader{{\it INDEX}}{}{}{}{}{{\it INDEX}}
|
||||
\setfooter{\thepage}{}{}{}{}{\thepage}%
|
||||
\printindex
|
||||
\end{document}
|
BIN
docs/latex/ogl/ogledit.bmp
Normal file
After Width: | Height: | Size: 86 KiB |
BIN
docs/latex/ogl/ogledit.gif
Normal file
After Width: | Height: | Size: 7.0 KiB |
87
docs/latex/ogl/sample.tex
Normal file
@@ -0,0 +1,87 @@
|
||||
\chapter{OGLEdit: a sample OGL application}\label{ogledit}%
|
||||
\setheader{{\it CHAPTER \thechapter}}{}{}{}{}{{\it CHAPTER \thechapter}}%
|
||||
\setfooter{\thepage}{}{}{}{}{\thepage}
|
||||
|
||||
OGLEdit is a sample OGL application that allows the user to draw, edit,
|
||||
save and load a few shapes. It should clarify aspects of OGL usage, and
|
||||
can act as a template for similar applications. OGLEdit can be found in\rtfsp
|
||||
{\tt samples/ogledit} in the OGL distribution.
|
||||
|
||||
$$\image{10cm;0cm}{ogledit.eps}$$\par
|
||||
|
||||
The wxWindows document/view model has been used in OGL, to reduce the amount of
|
||||
housekeeping logic required to get it up and running. OGLEdit also provides
|
||||
a demonstration of the Undo/Redo capability supported by the document/view classes,
|
||||
and how a typical application might implement this feature.
|
||||
|
||||
\section{OGLEdit files}
|
||||
|
||||
OGLEdit comprises the following source files.
|
||||
|
||||
\begin{itemize}\itemsep=0pt
|
||||
\item doc.h, doc.cpp: MyDiagram, DiagramDocument, DiagramCommand, MyEvtHandler
|
||||
classes related to diagram functionality and documents.
|
||||
\item view.h, view.cpp: MyCanvas, DiagramView classes related to visualisation of
|
||||
the diagram.
|
||||
\item ogledit.h, ogledit.cpp: MyFrame, MyApp classes related to the overall application.
|
||||
\item palette.h, palette.cpp: EditorToolPalette implementing the shape palette.
|
||||
\end{itemize}
|
||||
|
||||
\section{How OGLEdit works}
|
||||
|
||||
OGLEdit defines a DiagramDocument class, each of instance of which holds a MyDiagram
|
||||
member which itself contains the shapes.
|
||||
|
||||
In order to implement specific mouse behaviour for shapes, a class MyEvtHandler is
|
||||
defined which is `plugged into' each shape when it is created, instead of overriding each shape class
|
||||
individually. This event handler class also holds a label string.
|
||||
|
||||
The DiagramCommand class is the key to implementing Undo/Redo. Each instance of DiagramCommand
|
||||
stores enough information about an operation (create, delete, change colour etc.) to allow
|
||||
it to carry out (or undo) its command. In DiagramView::OnMenuCommand, when the user initiates the
|
||||
command, a new DiagramCommand instance is created which is then sent to the document's
|
||||
command processor (see wxWindows manual for more information about doc/view and command
|
||||
processing).
|
||||
|
||||
Apart from menu commands, another way commands are initiated is by the user left-clicking on
|
||||
the canvas or right-dragging on a node. MyCanvas::OnLeftClick in view.cpp shows how
|
||||
the appropriate wxClassInfo is passed to a DiagramCommand, to allow DiagramCommand::Do
|
||||
to create a new shape given the wxClassInfo.
|
||||
|
||||
The MyEvtHandler right-drag methods in doc.cpp implement drawing a line between
|
||||
two shapes, detecting where the right mouse button was released and looking for a second
|
||||
shape. Again, a new DiagramCommand instance is created and passed to the command
|
||||
processor to carry out the command.
|
||||
|
||||
DiagramCommand::Do and DiagramCommand::Undo embody much of the
|
||||
interesting interaction with the OGL library. A complication of note
|
||||
when implementing undo is the problem of deleting a node shape which has
|
||||
one or more arcs attached to it. If you delete the node, the arc(s)
|
||||
should be deleted too. But multiple arc deletion represents more information
|
||||
that can be incorporated in the existing DiagramCommand scheme. OGLEdit
|
||||
copes with this by treating each arc deletion as a separate command, and
|
||||
sending Cut commands recursively, providing an undo path. Undoing such a
|
||||
Cut will only undo one command at a time - not a one to one
|
||||
correspondence with the original command - but it's a reasonable
|
||||
compromise and preserves Do/Undo whilst keeping our DiagramCommand class
|
||||
simple.
|
||||
|
||||
\section{Possible enhancements}
|
||||
|
||||
OGLEdit is very simplistic and does not employ the more advanced features
|
||||
of OGL, such as:
|
||||
|
||||
\begin{itemize}\itemsep=0pt
|
||||
\item attachment points (arcs are drawn to particular points on a shape)
|
||||
\item metafile and bitmaps shapes
|
||||
\item divided rectangles
|
||||
\item composite shapes, and constraints
|
||||
\item creating labels in shape regions
|
||||
\item arc labels (OGL has support for three movable labels per arc)
|
||||
\item spline and multiple-segment line arcs
|
||||
\item adding annotations to node and arc shapes
|
||||
\item line-straightening (supported by OGL) and alignment (not supported directly by OGL)
|
||||
\end{itemize}
|
||||
|
||||
These could be added to OGLEdit, at the risk of making it a less
|
||||
useful example for beginners.
|
35
docs/latex/ogl/tex2rtf.ini
Normal file
@@ -0,0 +1,35 @@
|
||||
; Last change: JS 8 Sep 98 2:54 pm
|
||||
runTwice = yes
|
||||
titleFontSize = 12
|
||||
authorFontSize = 10
|
||||
chapterFontSize = 12
|
||||
sectionFontSize = 12
|
||||
subsectionFontSize = 12
|
||||
headerRule = yes
|
||||
footerRule = yes
|
||||
useHeadingStyles = yes
|
||||
listItemIndent=40
|
||||
generateHPJ = no
|
||||
htmlBrowseButtons = bitmap
|
||||
winHelpVersion = 3
|
||||
winHelpContents = yes
|
||||
winHelpTitle = "OGL Manual"
|
||||
truncateFilenames = yes
|
||||
combineSubSections = yes
|
||||
\overview [2] {\rtfonly{See also }\settransparency{on}\sethotspotcolour{off}\sethotspotunderline{on}\winhelponly{\image{}{books.bmp}\settransparency{off}}
|
||||
\htmlonly{\image{}{books.gif}}\helpref{#1}{#2}
|
||||
\sethotspotcolour{on}\sethotspotunderline{on}}
|
||||
\docparam [2]{\parskip{0}{\it #1}\htmlignore{\par}\parskip{10}\indented{1cm}{#2}}
|
||||
\wxheading [1]{{\bf \htmlignore{\fcol{blue}{#1}}\htmlonly{\fcol{red}{#1}}}}
|
||||
\const [0] {{\bf const}}
|
||||
\constfunc [3] {{\bf #1} {\bf #2}(#3) {\bf const}\index{#2}}
|
||||
\windowstyle [1] {{\bf #1}\index{#1}}
|
||||
|
||||
;;
|
||||
;; These two are for generating MS HTML Help project, contents and index files.
|
||||
;;
|
||||
htmlWorkshopFiles = true
|
||||
htmlIndex = true
|
||||
\pythonnote [1] {{\bf \fcol{blue}{wxPython note:}} #1}
|
||||
%\pythonnote [1] {}
|
||||
|
298
docs/latex/ogl/texhelp.sty
Normal file
@@ -0,0 +1,298 @@
|
||||
% LaTeX style file
|
||||
% Name: texhelp.sty
|
||||
% Author: Julian Smart
|
||||
%
|
||||
% Purpose
|
||||
% -------
|
||||
% Style file to enable the simultaneous preparation of printed LaTeX and on-line
|
||||
% hypertext manuals.
|
||||
% Use in conjunction with Tex2RTF (see Tex2RTF documentation).
|
||||
%
|
||||
% Note that if a non-ASCII character starts a newline and there should be a space
|
||||
% between the last word on the previous line and the first word on this line,
|
||||
% you need to use \rtfsp to generate a space in Windows Help. \rtfsp is ignored
|
||||
% in all other formats.
|
||||
%
|
||||
% Julian Smart
|
||||
% Artificial Intelligence Applications Institute
|
||||
%
|
||||
%
|
||||
% ============== C++/CLIPS Documentation Facilities ==============
|
||||
%
|
||||
% Each class definition should be typeset with e.g.
|
||||
%
|
||||
% \section{\class{Name}: Parent}
|
||||
%
|
||||
% followed by a description of the class.
|
||||
% Each member should follow:
|
||||
%
|
||||
% \membersection{wxName::Member}
|
||||
%
|
||||
% with a description of what this member does.
|
||||
% Then, one (or more if overloaded) member (function) in detail:
|
||||
%
|
||||
% \func{return type}{name}{args}
|
||||
% or
|
||||
% \member{type}{name}
|
||||
%
|
||||
% where args is a list of \param{type}{name}, ...
|
||||
|
||||
% Function, e.g.
|
||||
% e.g. to typeset
|
||||
%
|
||||
% void DoIt(char *string);
|
||||
%
|
||||
% write:
|
||||
%
|
||||
% \func{void}{DoIt}{\param{char *}{string}}
|
||||
%
|
||||
|
||||
\newcommand{\func}[3]{\hangafter=1\noindent\hangindent=10mm
|
||||
{{\it #1} {\bf #2}\index{#2}}(#3)}
|
||||
|
||||
% For function/type definition where the name is a pointer,
|
||||
% e.g. to typeset
|
||||
%
|
||||
% typedef void (*wxFunction)(wxObject&)
|
||||
%
|
||||
% write:
|
||||
%
|
||||
% \pfunc{typedef void}{wxFunction}{param{wxObject&}}
|
||||
|
||||
\newcommand{\pfunc}[3]{\hangafter=1\noindent\hangindent=10mm
|
||||
{{\it #1} ({\bf *#2})\index{#2}}(#3)}
|
||||
|
||||
% Use an ordinary \section command for class name definitions.
|
||||
|
||||
% This is used for a member, such as wxBitmap: GetDepth
|
||||
\newcommand{\membersection}[1]{\subsection*{#1}\index{#1}}
|
||||
|
||||
% CLIPS function
|
||||
\newcommand{\clipsfunc}[3]{\hangafter=1\noindent\hangindent=10mm
|
||||
{{\bf #1} ({\bf #2}\index{#2}}#3)}
|
||||
|
||||
\newcommand{\clipssection}[1]{\chapter{#1}}
|
||||
|
||||
% This is used for a CLIPS function name
|
||||
\newcommand{\functionsection}[1]{\subsection*{#1}}
|
||||
|
||||
% Member: a type and a name
|
||||
\newcommand{\member}[2]{{\bf #1 \it #2}}
|
||||
|
||||
% C++ Parameter: a type and a name (no intervening space)
|
||||
\newcommand{\param}[2]{{\it #1}{\bf #2}}
|
||||
|
||||
% CLIPS Parameter: a type and a name (one intervening space)
|
||||
\newcommand{\cparam}[2]{{\bf #1} {\it #2}}
|
||||
|
||||
% Class: puts in index
|
||||
\newcommand{\class}[1]{#1\index{#1}}
|
||||
|
||||
%\newcommand{\docparam}[2]{\parskip=0pt {\it #1}\par\parskip=10pt\begin{indented}{1cm}{#2}\end{indented}}
|
||||
|
||||
% Void type
|
||||
\newcommand{\void}{{\it void}}
|
||||
|
||||
% Typeset destructor
|
||||
\newcommand{\destruct}[1]{{$\sim$}#1}
|
||||
|
||||
% Typeset insert/extract operators
|
||||
\newcommand{\cinsert}{$<<$}
|
||||
\newcommand{\cextract}{$>>$}
|
||||
|
||||
|
||||
% =================== Hypertext facilities ===================
|
||||
%
|
||||
% To insert hyperlinks (or references, in Latex), \label the sections
|
||||
% or membersections \label{ref-label} immediately after the section, on the same line,
|
||||
% and use \helpref{text-to-show}{ref-label} to make a reference.
|
||||
%
|
||||
|
||||
% Type text with section reference
|
||||
\newcommand{\helpref}[2]{{\it #1} (p.\ \pageref{#2}) }
|
||||
|
||||
% Type text with URL in verbatim mode
|
||||
\newcommand{\urlref}[2]{#1 (\verb$#2$)}
|
||||
|
||||
% Don't typeset section number in LaTeX
|
||||
\newcommand{\helprefn}[2]{{\it #1}}
|
||||
|
||||
% Like helpref, but popup text in WinHelp instead of hyperlinked
|
||||
\newcommand{\popref}[2]{{\it #1}}
|
||||
|
||||
% Like footnote, but popup text.
|
||||
\newcommand{\footnotepopup}[2]{{\it #1}\footnote{#2}}
|
||||
|
||||
% =================== On-line help specific macros ===================
|
||||
%
|
||||
|
||||
% Global document font size/family, help only.
|
||||
\newcommand{\helpfontsize}[1]{}
|
||||
\newcommand{\helpfontfamily}[1]{}
|
||||
|
||||
% Ignore in all on-line help
|
||||
\newcommand{\helpignore}[1]{#1}
|
||||
% Only print in all on-line help
|
||||
\newcommand{\helponly}[1]{}
|
||||
|
||||
% Ignore in LaTeX
|
||||
\newcommand{\latexignore}[1]{}
|
||||
% Only print in LaTeX
|
||||
\newcommand{\latexonly}[1]{#1}
|
||||
|
||||
% Ignore in linear RTF
|
||||
\newcommand{\rtfignore}[1]{#1}
|
||||
% Only print in linear RTF
|
||||
\newcommand{\rtfonly}[1]{}
|
||||
|
||||
% Ignore in WinHelp RTF
|
||||
\newcommand{\winhelpignore}[1]{#1}
|
||||
% Only print in WinHelp RTF
|
||||
\newcommand{\winhelponly}[1]{}
|
||||
|
||||
% Ignore in wxHelp
|
||||
\newcommand{\xlpignore}[1]{#1}
|
||||
% Only print in wxHelp
|
||||
\newcommand{\xlponly}[1]{}
|
||||
|
||||
% Ignore in HTML
|
||||
\newcommand{\htmlignore}[1]{#1}
|
||||
% Only print in HTML
|
||||
\newcommand{\htmlonly}[1]{}
|
||||
|
||||
% Input a file only for help system (binder thickness is not a limitation
|
||||
% in help systems!)
|
||||
\newcommand{\helpinput}[1]{}
|
||||
|
||||
\newcommand{\rtfsp}{ } % Force a space in RTF, ignore in Latex
|
||||
|
||||
% =================== Miscellaneous macros ===================
|
||||
%
|
||||
% Headings consistent with generated ones
|
||||
\newcommand{\myheading}[1]{\vspace*{25pt}
|
||||
\begin{flushleft}
|
||||
{\LARGE \bf #1}
|
||||
\end{flushleft}
|
||||
\vskip 20pt
|
||||
}
|
||||
|
||||
% Heading with entry in contents page.
|
||||
\newcommand{\chapterheading}[1]{\myheading{#1}
|
||||
\addcontentsline{toc}{chapter}{#1}}
|
||||
|
||||
\newcommand{\sectionheading}[1]{\myheading{#1}
|
||||
\addcontentsline{toc}{section}{#1}}
|
||||
|
||||
% Glossary environment
|
||||
\newenvironment{helpglossary}{\newpage\chapterheading{Glossary}\begin{description}}{\end{description}}
|
||||
|
||||
% Glossary entry
|
||||
\newcommand{\gloss}[1]{\item[#1]\index{#1}}
|
||||
|
||||
% Image: EPS in Latex, BMP or MF (whatever's available) in RTF. Requires psbox.
|
||||
\newcommand{\image}[2]{\psboxto(#1){#2}}
|
||||
|
||||
% Image, left aligned (HTML)
|
||||
\newcommand{\imager}[2]{\psboxto(#1){#2}}
|
||||
|
||||
% Image, right aligned (HTML)
|
||||
\newcommand{\imagel}[2]{\psboxto(#1){#2}}
|
||||
|
||||
% Imagemap: principally for HTML only. In Latex,
|
||||
% acts like \image.
|
||||
\newcommand{\imagemap}[3]{\psboxto(#1){#2}}
|
||||
|
||||
% Headers and footers
|
||||
% \setheader{EvenPageLeft}{EvenPageCentre}{EvenPageRight}
|
||||
% {OddPageLeft}{OddPageCentre}{OddPageRight}
|
||||
\newcommand{\setheader}[6]{
|
||||
\lhead[\fancyplain{}{#1}]{\fancyplain{}{#4}}
|
||||
\chead[\fancyplain{}{#2}]{\fancyplain{}{#5}}
|
||||
\rhead[\fancyplain{}{#3}]{\fancyplain{}{#6}}
|
||||
}
|
||||
|
||||
% \setfooter{EvenPageLeft}{EvenPageCentre}{EvenPageRight}
|
||||
% {OddPageLeft}{OddPageCentre}{OddPageRight}
|
||||
\newcommand{\setfooter}[6]{
|
||||
\lfoot[\fancyplain{#1}{#1}]{\fancyplain{#4}{#4}}
|
||||
\cfoot[\fancyplain{#2}{#2}]{\fancyplain{#5}{#5}}
|
||||
\rfoot[\fancyplain{#3}{#3}]{\fancyplain{#6}{#6}}
|
||||
}
|
||||
|
||||
% Needed for telling RTF where margin paragraph should go
|
||||
% in mirrored margins mode.
|
||||
\newcommand{\marginpareven}[1]{\hspace*{0pt}\marginpar{#1}}
|
||||
\newcommand{\marginparodd}[1]{\hspace*{0pt}\marginpar{#1}}
|
||||
|
||||
% Environment for two-column table popular in WinHelp and manuals.
|
||||
\newcommand{\twocolwidtha}[1]{\def\twocolwidthaval{#1}}
|
||||
\newcommand{\twocolwidthb}[1]{\def\twocolwidthbval{#1}}
|
||||
\newcommand{\twocolspacing}[1]{\def\twocolspacingval{#1}}
|
||||
|
||||
\twocolwidtha{3cm}
|
||||
\twocolwidthb{8.5cm}
|
||||
\twocolspacing{2}
|
||||
|
||||
\newcommand{\twocolitem}[2]{#1 & #2\\}
|
||||
\newcommand{\twocolitemruled}[2]{#1 & #2\\\hline}
|
||||
|
||||
\newenvironment{twocollist}{\renewcommand{\arraystretch}{\twocolspacingval}\begin{tabular}{lp{\twocolwidthbval}}}%
|
||||
{\end{tabular}\renewcommand{\arraystretch}{1}}
|
||||
|
||||
% Specifying table rows for RTF compatibility
|
||||
\newcommand{\row}[1]{#1\\}
|
||||
|
||||
% Use for the last ruled row for correct RTF generation.
|
||||
\newcommand{\ruledrow}[1]{#1\\\hline}
|
||||
|
||||
% Indentation environment. Arg1 is left margin size
|
||||
\newenvironment{indented}[1]{\begin{list}{}{\leftmargin=#1}\item[]}%
|
||||
{\end{list}}
|
||||
|
||||
% Framed box of text, normal formatting.
|
||||
\newcommand{\normalbox}[1]{\fbox{\vbox{#1}}}
|
||||
% Double-framed box of text.
|
||||
\newcommand{\normalboxd}[1]{\fbox{\fbox{\vbox{#1}}}}
|
||||
|
||||
% WITHDRAWN -- can't do in RTF, easily.
|
||||
% Framed box of text, horizontally centred. Ragged right within box.
|
||||
% \newcommand{\centeredbox}[2]{\begin{center}\fbox{\parbox{#1}{\raggedright#2}}\end{center}}
|
||||
% Double-framed box of text, horizontally centred. Ragged right within box.
|
||||
% \newcommand{\centeredboxd}[2]{\begin{center}\fbox{\fbox{\parbox{#1}{\raggedright#2}}}\end{center}}
|
||||
|
||||
% toocomplex environment: simply prints the argument in LaTeX,
|
||||
% comes out verbatim in all generated formats.
|
||||
\newenvironment{toocomplex}{}{}
|
||||
|
||||
% Colour: dummy commands since LaTeX doesn't support colour.
|
||||
% \definecolour{name}{red}{blue}{green}
|
||||
% \fcol{name}{text} ; Foreground
|
||||
% \bcol{name}{text} ; Background
|
||||
\newcommand{\definecolour}[4]{}
|
||||
\newcommand{\definecolor}[4]{}
|
||||
\newcommand{\fcol}[2]{#2}
|
||||
\newcommand{\bcol}[2]{#2}
|
||||
\newcommand{\sethotspotcolour}[1]{}
|
||||
\newcommand{\sethotspotunderline}[1]{}
|
||||
\newcommand{\settransparency}[1]{}
|
||||
\newcommand{\backslashraw}[0]{}
|
||||
\newcommand{\lbraceraw}[0]{}
|
||||
\newcommand{\rbraceraw}[0]{}
|
||||
\newcommand{\registered}[0]{(r)}
|
||||
\newcommand{\background}[1]{}
|
||||
\newcommand{\textcolour}[1]{}
|
||||
\newcommand{\overview}[2]{See \helpref{#1}{#2}.}
|
||||
\newcommand{\docparam}[2]{{\it #1}\begin{list}{}{\leftmargin=1cm}\item[]
|
||||
#2%
|
||||
\end{list}}
|
||||
\newcommand{\wxheading}[1]{{\bf #1}}
|
||||
\newcommand{\const}[0]{{\bf const}}
|
||||
\newcommand{\constfunc}[3]{{\bf #1} {\bf #2}(#3) {\bf const}\index{#2}}
|
||||
\newcommand{\windowstyle}[1]{{\bf #1}\index{#1}}
|
||||
|
||||
\addtolength{\textwidth}{1in}
|
||||
\addtolength{\oddsidemargin}{-0.5in}
|
||||
\addtolength{\topmargin}{-0.5in}
|
||||
\addtolength{\textheight}{1in}
|
||||
\sloppy
|
||||
|
161
docs/latex/ogl/topics.tex
Normal file
@@ -0,0 +1,161 @@
|
||||
\chapter{Topic overviews}
|
||||
\setheader{{\it CHAPTER \thechapter}}{}{}{}{}{{\it CHAPTER \thechapter}}%
|
||||
\setfooter{\thepage}{}{}{}{}{\thepage}
|
||||
|
||||
The following sections describe particular topics.
|
||||
|
||||
\section{OGL overview}\label{ogloverview}
|
||||
|
||||
\helpref{wxShapeCanvas}{wxshapecanvas}, derived from {\bf wxCanvas}, is the drawing area
|
||||
for a number of \helpref{wxShape}{wxshape} instances. Everything drawn on a
|
||||
wxShapeCanvas is derived from wxShape, which provides virtual
|
||||
member functions for redrawing, creating and destroying
|
||||
resize/selection `handles', movement and erasing behaviour, mouse
|
||||
click behaviour, calculating the bounding box of the shape, linking
|
||||
nodes with arcs, and so on.
|
||||
|
||||
The way a client application copes with `damage' to the canvas is to
|
||||
erase (white out) anything should no longer be displayed, redraw the shape,
|
||||
and then redraw everything on the canvas to repair any damage. If quick edit
|
||||
mode is on for the canvas, the complete should be omitted by OGL and the
|
||||
application.
|
||||
|
||||
Selection handles (called control points in the code) are implemented as
|
||||
wxRectangleShapes.
|
||||
|
||||
Events are passed to shapes by the canvas in a high-level form, for example {\bf OnLeftClick},
|
||||
{\bf OnBeginDragLeft}, {\bf OnDragLeft}, {\bf OnEndDragLeft}. The canvas decides
|
||||
what is a click and what is a drag, whether it is on a shape or the canvas itself,
|
||||
and (by interrogating the shape) which attachment point the click is associated with.
|
||||
|
||||
In order to provide event-handling flexibility, each shapes has an `event handler' associated with it,
|
||||
which by default is the shape itself (all shapes derive from wxShapeEvtHandler).
|
||||
An application can modify the event-handling behaviour simply by plugging a new
|
||||
event handler into the shape. This can avoid the need for multiple inheritance when
|
||||
new properties and behaviour are required for a number of different shape classes: instead
|
||||
of overriding each class, one new event handler class can be defined and used for all
|
||||
existing shape classes.
|
||||
|
||||
A range of shapes have been predefined in the library, including rectangles, ellipses,
|
||||
polygons. A client application can derive from these shapes and/or derive entirely
|
||||
new shapes from wxShape.
|
||||
|
||||
Instances of a class called \helpref{wxDiagram}{wxdiagram} organise collections of
|
||||
shapes, providing default file input and output behaviour.
|
||||
|
||||
\section{wxDividedShape overview}\label{dividedshapeoverview}
|
||||
|
||||
Classes: \helpref{wxDividedShape}{wxdividedshape}
|
||||
|
||||
A wxDividedShape is a rectangle with a number of vertical divisions. Each
|
||||
division may have its text formatted with independent characteristics, and
|
||||
the size of each division relative to the whole image may be specified.
|
||||
|
||||
Once a wxDividedShape has been created, the user may move the divisions with the
|
||||
mouse. By pressing Ctrl while right-clicking, the region attributes can be edited.
|
||||
|
||||
Here are examples of creating wxDividedShape objects:
|
||||
|
||||
{\small
|
||||
\begin{verbatim}
|
||||
/*
|
||||
* Divided rectangle with 3 regions
|
||||
*
|
||||
*/
|
||||
|
||||
wxDividedShape *dividedRect = new wxDividedShape(50, 60);
|
||||
|
||||
wxShapeRegion *region = new wxShapeRegion;
|
||||
region->SetProportions(0.0, 0.25);
|
||||
dividedRect->AddRegion(region);
|
||||
|
||||
region = new wxShapeRegion;
|
||||
region->SetProportions(0.0, 0.5);
|
||||
dividedRect->AddRegion(region);
|
||||
|
||||
region = new wxShapeRegion;
|
||||
region->SetProportions(0.0, 0.25);
|
||||
dividedRect->AddRegion(region);
|
||||
|
||||
dividedRect->SetSize(50, 60); // Allow it to calculate region sizes
|
||||
dividedRect->SetPen(wxBLACK_PEN);
|
||||
dividedRect->SetBrush(wxWHITE_BRUSH);
|
||||
dividedRect->Show(TRUE);
|
||||
dividedRect->NameRegions();
|
||||
|
||||
/*
|
||||
* Divided rectangle with 3 regions, rounded
|
||||
*
|
||||
*/
|
||||
|
||||
wxDividedShape *dividedRect3 = new wxDividedShape(50, 60);
|
||||
dividedRect3->SetCornerRadius(-0.4);
|
||||
|
||||
region = new wxShapeRegion;
|
||||
region->SetProportions(0.0, 0.25);
|
||||
dividedRect3->AddRegion(region);
|
||||
|
||||
region = new wxShapeRegion;
|
||||
region->SetProportions(0.0, 0.5);
|
||||
dividedRect3->AddRegion(region);
|
||||
|
||||
region = new wxShapeRegion;
|
||||
region->SetProportions(0.0, 0.25);
|
||||
dividedRect3->AddRegion(region);
|
||||
|
||||
dividedRect3->SetSize(50, 60); // Allow it to calculate region sizes
|
||||
dividedRect3->SetPen(wxBLACK_PEN);
|
||||
dividedRect3->SetBrush(wxWHITE_BRUSH);
|
||||
dividedRect3->Show(TRUE);
|
||||
dividedRect3->NameRegions();
|
||||
\end{verbatim}
|
||||
}
|
||||
|
||||
\section{wxCompositeShape overview}\label{compositeshapeoverview}
|
||||
|
||||
Classes: \helpref{wxCompositeShape}{wxcompositeshape}, \helpref{wxOGLConstraint}{wxoglconstraint}
|
||||
|
||||
The wxCompositeShape allows fairly complex shapes to be created, and maintains
|
||||
a set of constraints which specify the layout and proportions of child shapes.
|
||||
|
||||
Add child shapes to a wxCompositeShape using \helpref{AddChild}{wxcompositeshapeaddchild}, and
|
||||
add constraints using \helpref{AddConstraint}{wxcompositeshapeaddconstraint}.
|
||||
|
||||
After children and shapes have been added, call \helpref{Recompute}{wxcompositeshaperecompute} which
|
||||
will return TRUE is the constraints could be satisfied, FALSE otherwise. If
|
||||
constraints have been correctly and consistently specified, this call will succeed.
|
||||
|
||||
If there is more than one child, constraints must be specified: OGL cannot calculate
|
||||
the size and position of children otherwise. Don't assume that children will simply
|
||||
move relative to the parent without the use of constraints.
|
||||
|
||||
To specify a constraint, you need three things:
|
||||
|
||||
\begin{enumerate}\itemsep=0pt
|
||||
\item a constraint type, such as gyCONSTRAINT\_CENTRED\_VERTICALLY;
|
||||
\item a reference shape, with respect to which other shapes are going to be positioned - the\rtfsp
|
||||
{\it constraining} shape;
|
||||
\item a list of one or more shapes to be constrained: the {\it constrained} shapes.
|
||||
\end{enumerate}
|
||||
|
||||
The constraining shape can be either the parent of the constrained shapes, or a sibling. The
|
||||
constrained shapes must all be siblings of each other.
|
||||
|
||||
For an exhaustive list and description of the available constraint types, see the \helpref{wxOGLConstraint constructor}{wxoglconstraintconstr}.
|
||||
Note that most constraints operate in one dimension only (vertically or horizontally), so you will
|
||||
usually need to specify constraints in pairs.
|
||||
|
||||
You can set the spacing between constraining and constrained shapes by
|
||||
calling \helpref{wxOGLConstraint::SetSpacing}{wxoglconstraintsetspacing}.
|
||||
|
||||
Finally, a wxCompositeShape can have {\it divisions}, which are special child shapes of class
|
||||
wxDivisionShape (not to be confused with wxDividedShape). The purpose of this is to allow
|
||||
the composite to be divided into user-adjustable regions (divisions) into which other shapes
|
||||
can be dropped dynamically, given suitable application code. Divisons allow the child
|
||||
shapes to have an identity of their own - they can be manipulated independently of their container -
|
||||
but to behave as if they are contained with the division, moving with the parent shape.
|
||||
Divisions boundaries can themselves be moved using the mouse.
|
||||
|
||||
To create an initial division, call \helpref{wxCompositeShape::MakeContainer}{wxcompositeshapemakecontainer}.
|
||||
Make further divisions by calling \helpref{wxDivisionShape::Divide}{wxdivisionshapedivide}.
|
||||
|
BIN
docs/latex/ogl/up.gif
Normal file
After Width: | Height: | Size: 137 B |
744
include/wx/ogl/basic.h
Normal file
@@ -0,0 +1,744 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: basic.h
|
||||
// Purpose: Basic OGL classes and definitions
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 12/07/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _OGL_BASIC_H_
|
||||
#define _OGL_BASIC_H_
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface "basic.h"
|
||||
#endif
|
||||
|
||||
#define OGL_VERSION 2.0
|
||||
|
||||
#ifndef DEFAULT_MOUSE_TOLERANCE
|
||||
#define DEFAULT_MOUSE_TOLERANCE 3
|
||||
#endif
|
||||
|
||||
// Edit these lines if you positively don't want PROLOGIO support
|
||||
#ifndef PROLOGIO
|
||||
#define PROLOGIO
|
||||
#endif
|
||||
|
||||
// Key identifiers
|
||||
#define KEY_SHIFT 1
|
||||
#define KEY_CTRL 2
|
||||
|
||||
// Arrow styles
|
||||
|
||||
#define ARROW_NONE 0
|
||||
#define ARROW_END 1
|
||||
#define ARROW_BOTH 2
|
||||
#define ARROW_MIDDLE 3
|
||||
#define ARROW_START 4
|
||||
|
||||
// Control point types
|
||||
// Rectangle and most other shapes
|
||||
#define CONTROL_POINT_VERTICAL 1
|
||||
#define CONTROL_POINT_HORIZONTAL 2
|
||||
#define CONTROL_POINT_DIAGONAL 3
|
||||
|
||||
// Line
|
||||
#define CONTROL_POINT_ENDPOINT_TO 4
|
||||
#define CONTROL_POINT_ENDPOINT_FROM 5
|
||||
#define CONTROL_POINT_LINE 6
|
||||
|
||||
// Types of formatting: can be combined in a bit list
|
||||
#define FORMAT_NONE 0
|
||||
// Left justification
|
||||
#define FORMAT_CENTRE_HORIZ 1
|
||||
// Centre horizontally
|
||||
#define FORMAT_CENTRE_VERT 2
|
||||
// Centre vertically
|
||||
#define FORMAT_SIZE_TO_CONTENTS 4
|
||||
// Resize shape to contents
|
||||
|
||||
// Shadow mode
|
||||
#define SHADOW_NONE 0
|
||||
#define SHADOW_LEFT 1
|
||||
#define SHADOW_RIGHT 2
|
||||
|
||||
/*
|
||||
* Declare types
|
||||
*
|
||||
*/
|
||||
|
||||
#define SHAPE_BASIC wxTYPE_USER + 1
|
||||
#define SHAPE_RECTANGLE wxTYPE_USER + 2
|
||||
#define SHAPE_ELLIPSE wxTYPE_USER + 3
|
||||
#define SHAPE_POLYGON wxTYPE_USER + 4
|
||||
#define SHAPE_CIRCLE wxTYPE_USER + 5
|
||||
#define SHAPE_LINE wxTYPE_USER + 6
|
||||
#define SHAPE_DIVIDED_RECTANGLE wxTYPE_USER + 8
|
||||
#define SHAPE_COMPOSITE wxTYPE_USER + 9
|
||||
#define SHAPE_CONTROL_POINT wxTYPE_USER + 10
|
||||
#define SHAPE_DRAWN wxTYPE_USER + 11
|
||||
#define SHAPE_DIVISION wxTYPE_USER + 12
|
||||
#define SHAPE_LABEL_OBJECT wxTYPE_USER + 13
|
||||
#define SHAPE_BITMAP wxTYPE_USER + 14
|
||||
#define SHAPE_DIVIDED_OBJECT_CONTROL_POINT wxTYPE_USER + 15
|
||||
|
||||
#define OBJECT_REGION wxTYPE_USER + 20
|
||||
|
||||
#define OP_CLICK_LEFT 1
|
||||
#define OP_CLICK_RIGHT 2
|
||||
#define OP_DRAG_LEFT 4
|
||||
#define OP_DRAG_RIGHT 8
|
||||
|
||||
#define OP_ALL (OP_CLICK_LEFT | OP_CLICK_RIGHT | OP_DRAG_LEFT | OP_DRAG_RIGHT)
|
||||
|
||||
// Attachment modes
|
||||
#define ATTACHMENT_MODE_NONE 0
|
||||
#define ATTACHMENT_MODE_EDGE 1
|
||||
#define ATTACHMENT_MODE_BRANCHING 2
|
||||
|
||||
// Sub-modes for branching attachment mode
|
||||
#define BRANCHING_ATTACHMENT_NORMAL 1
|
||||
#define BRANCHING_ATTACHMENT_BLOB 2
|
||||
|
||||
class wxShapeTextLine;
|
||||
class wxShapeCanvas;
|
||||
class wxLineShape;
|
||||
class wxControlPoint;
|
||||
class wxShapeRegion;
|
||||
class wxShape;
|
||||
|
||||
#ifdef PROLOGIO
|
||||
class WXDLLEXPORT wxExpr;
|
||||
class WXDLLEXPORT wxExprDatabase;
|
||||
#endif
|
||||
|
||||
// Round up
|
||||
#define WXROUND(x) ( (long) (x + 0.5) )
|
||||
|
||||
|
||||
// logical function to use when drawing rubberband boxes, etc.
|
||||
#define OGLRBLF wxINVERT
|
||||
|
||||
|
||||
|
||||
class wxShapeEvtHandler: public wxObject
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxShapeEvtHandler)
|
||||
|
||||
public:
|
||||
wxShapeEvtHandler(wxShapeEvtHandler *prev = NULL, wxShape *shape = NULL);
|
||||
virtual ~wxShapeEvtHandler();
|
||||
|
||||
inline void SetShape(wxShape *sh) { m_handlerShape = sh; }
|
||||
inline wxShape *GetShape() const { return m_handlerShape; }
|
||||
|
||||
inline void SetPreviousHandler(wxShapeEvtHandler* handler) { m_previousHandler = handler; }
|
||||
inline wxShapeEvtHandler* GetPreviousHandler() const { return m_previousHandler; }
|
||||
|
||||
// This is called when the _shape_ is deleted.
|
||||
virtual void OnDelete();
|
||||
virtual void OnDraw(wxDC& dc);
|
||||
virtual void OnDrawContents(wxDC& dc);
|
||||
virtual void OnDrawBranches(wxDC& dc, bool erase = FALSE);
|
||||
virtual void OnMoveLinks(wxDC& dc);
|
||||
virtual void OnErase(wxDC& dc);
|
||||
virtual void OnEraseContents(wxDC& dc);
|
||||
virtual void OnHighlight(wxDC& dc);
|
||||
virtual void OnLeftClick(double x, double y, int keys = 0, int attachment = 0);
|
||||
virtual void OnLeftDoubleClick(double x, double y, int keys = 0, int attachment = 0);
|
||||
virtual void OnRightClick(double x, double y, int keys = 0, int attachment = 0);
|
||||
virtual void OnSize(double x, double y);
|
||||
virtual bool OnMovePre(wxDC& dc, double x, double y, double old_x, double old_y, bool display = TRUE);
|
||||
virtual void OnMovePost(wxDC& dc, double x, double y, double old_x, double old_y, bool display = TRUE);
|
||||
|
||||
virtual void OnDragLeft(bool draw, double x, double y, int keys=0, int attachment = 0); // Erase if draw false
|
||||
virtual void OnBeginDragLeft(double x, double y, int keys=0, int attachment = 0);
|
||||
virtual void OnEndDragLeft(double x, double y, int keys=0, int attachment = 0);
|
||||
virtual void OnDragRight(bool draw, double x, double y, int keys=0, int attachment = 0); // Erase if draw false
|
||||
virtual void OnBeginDragRight(double x, double y, int keys=0, int attachment = 0);
|
||||
virtual void OnEndDragRight(double x, double y, int keys=0, int attachment = 0);
|
||||
virtual void OnDrawOutline(wxDC& dc, double x, double y, double w, double h);
|
||||
virtual void OnDrawControlPoints(wxDC& dc);
|
||||
virtual void OnEraseControlPoints(wxDC& dc);
|
||||
virtual void OnMoveLink(wxDC& dc, bool moveControlPoints = TRUE);
|
||||
|
||||
// Control points ('handles') redirect control to the actual shape, to make it easier
|
||||
// to override sizing behaviour.
|
||||
virtual void OnSizingDragLeft(wxControlPoint* pt, bool draw, double x, double y, int keys=0, int attachment = 0); // Erase if draw false
|
||||
virtual void OnSizingBeginDragLeft(wxControlPoint* pt, double x, double y, int keys=0, int attachment = 0);
|
||||
virtual void OnSizingEndDragLeft(wxControlPoint* pt, double x, double y, int keys=0, int attachment = 0);
|
||||
|
||||
virtual void OnBeginSize(double WXUNUSED(w), double WXUNUSED(h)) { }
|
||||
virtual void OnEndSize(double WXUNUSED(w), double WXUNUSED(h)) { }
|
||||
|
||||
// Can override this to prevent or intercept line reordering.
|
||||
virtual void OnChangeAttachment(int attachment, wxLineShape* line, wxList& ordering);
|
||||
|
||||
// Creates a copy of this event handler.
|
||||
wxShapeEvtHandler *CreateNewCopy();
|
||||
|
||||
// Does the copy - override for new event handlers which might store
|
||||
// app-specific data.
|
||||
virtual void CopyData(wxShapeEvtHandler& copy) {};
|
||||
|
||||
private:
|
||||
wxShapeEvtHandler* m_previousHandler;
|
||||
wxShape* m_handlerShape;
|
||||
};
|
||||
|
||||
class wxShape: public wxShapeEvtHandler
|
||||
{
|
||||
DECLARE_ABSTRACT_CLASS(wxShape)
|
||||
|
||||
public:
|
||||
|
||||
wxShape(wxShapeCanvas *can = NULL);
|
||||
virtual ~wxShape();
|
||||
virtual void GetBoundingBoxMax(double *width, double *height);
|
||||
virtual void GetBoundingBoxMin(double *width, double *height) = 0;
|
||||
virtual bool GetPerimeterPoint(double x1, double y1,
|
||||
double x2, double y2,
|
||||
double *x3, double *y3);
|
||||
inline wxShapeCanvas *GetCanvas() { return m_canvas; }
|
||||
void SetCanvas(wxShapeCanvas *the_canvas);
|
||||
virtual void AddToCanvas(wxShapeCanvas *the_canvas, wxShape *addAfter = NULL);
|
||||
virtual void InsertInCanvas(wxShapeCanvas *the_canvas);
|
||||
|
||||
virtual void RemoveFromCanvas(wxShapeCanvas *the_canvas);
|
||||
inline double GetX() const { return m_xpos; }
|
||||
inline double GetY() const { return m_ypos; }
|
||||
inline void SetX(double x) { m_xpos = x; }
|
||||
inline void SetY(double y) { m_ypos = y; }
|
||||
|
||||
inline wxShape *GetParent() const { return m_parent; }
|
||||
inline void SetParent(wxShape *p) { m_parent = p; }
|
||||
wxShape *GetTopAncestor();
|
||||
inline wxList& GetChildren() { return m_children; }
|
||||
|
||||
virtual void OnDraw(wxDC& dc);
|
||||
virtual void OnDrawContents(wxDC& dc);
|
||||
virtual void OnMoveLinks(wxDC& dc);
|
||||
virtual void Unlink() { };
|
||||
void SetDrawHandles(bool drawH);
|
||||
inline bool GetDrawHandles() { return m_drawHandles; }
|
||||
virtual void OnErase(wxDC& dc);
|
||||
virtual void OnEraseContents(wxDC& dc);
|
||||
virtual void OnHighlight(wxDC& dc);
|
||||
virtual void OnLeftClick(double x, double y, int keys = 0, int attachment = 0);
|
||||
virtual void OnLeftDoubleClick(double x, double y, int keys = 0, int attachment = 0) {}
|
||||
virtual void OnRightClick(double x, double y, int keys = 0, int attachment = 0);
|
||||
virtual void OnSize(double x, double y);
|
||||
virtual bool OnMovePre(wxDC& dc, double x, double y, double old_x, double old_y, bool display = TRUE);
|
||||
virtual void OnMovePost(wxDC& dc, double x, double y, double old_x, double old_y, bool display = TRUE);
|
||||
|
||||
virtual void OnDragLeft(bool draw, double x, double y, int keys=0, int attachment = 0); // Erase if draw false
|
||||
virtual void OnBeginDragLeft(double x, double y, int keys=0, int attachment = 0);
|
||||
virtual void OnEndDragLeft(double x, double y, int keys=0, int attachment = 0);
|
||||
virtual void OnDragRight(bool draw, double x, double y, int keys=0, int attachment = 0); // Erase if draw false
|
||||
virtual void OnBeginDragRight(double x, double y, int keys=0, int attachment = 0);
|
||||
virtual void OnEndDragRight(double x, double y, int keys=0, int attachment = 0);
|
||||
virtual void OnDrawOutline(wxDC& dc, double x, double y, double w, double h);
|
||||
virtual void OnDrawControlPoints(wxDC& dc);
|
||||
virtual void OnEraseControlPoints(wxDC& dc);
|
||||
|
||||
virtual void OnBeginSize(double WXUNUSED(w), double WXUNUSED(h)) { }
|
||||
virtual void OnEndSize(double WXUNUSED(w), double WXUNUSED(h)) { }
|
||||
|
||||
// Control points ('handles') redirect control to the actual shape, to make it easier
|
||||
// to override sizing behaviour.
|
||||
virtual void OnSizingDragLeft(wxControlPoint* pt, bool draw, double x, double y, int keys=0, int attachment = 0); // Erase if draw false
|
||||
virtual void OnSizingBeginDragLeft(wxControlPoint* pt, double x, double y, int keys=0, int attachment = 0);
|
||||
virtual void OnSizingEndDragLeft(wxControlPoint* pt, double x, double y, int keys=0, int attachment = 0);
|
||||
|
||||
virtual void MakeControlPoints();
|
||||
virtual void DeleteControlPoints(wxDC *dc = NULL);
|
||||
virtual void ResetControlPoints();
|
||||
|
||||
inline wxShapeEvtHandler *GetEventHandler() { return m_eventHandler; }
|
||||
inline void SetEventHandler(wxShapeEvtHandler *handler) { m_eventHandler = handler; }
|
||||
|
||||
// Mandatory control points, e.g. the divided line moving handles
|
||||
// should appear even if a child of the 'selected' image
|
||||
virtual void MakeMandatoryControlPoints();
|
||||
virtual void ResetMandatoryControlPoints();
|
||||
|
||||
inline virtual bool Recompute() { return TRUE; };
|
||||
// Calculate size recursively, if size changes. Size might depend on children.
|
||||
inline virtual void CalculateSize() { };
|
||||
virtual void Select(bool select = TRUE, wxDC* dc = NULL);
|
||||
virtual void SetHighlight(bool hi = TRUE, bool recurse = FALSE);
|
||||
inline virtual bool IsHighlighted() const { return m_highlighted; };
|
||||
virtual bool Selected() const;
|
||||
virtual bool AncestorSelected() const;
|
||||
void SetSensitivityFilter(int sens = OP_ALL, bool recursive = FALSE);
|
||||
int GetSensitivityFilter() const { return m_sensitivity; }
|
||||
void SetDraggable(bool drag, bool recursive = FALSE);
|
||||
inline void SetFixedSize(bool x, bool y) { m_fixedWidth = x; m_fixedHeight = y; };
|
||||
inline void GetFixedSize(bool *x, bool *y) const { *x = m_fixedWidth; *y = m_fixedHeight; };
|
||||
inline bool GetFixedWidth() const { return m_fixedWidth; }
|
||||
inline bool GetFixedHeight() const { return m_fixedHeight; }
|
||||
inline void SetSpaceAttachments(bool sp) { m_spaceAttachments = sp; };
|
||||
inline bool GetSpaceAttachments() const { return m_spaceAttachments; };
|
||||
void SetShadowMode(int mode, bool redraw = FALSE);
|
||||
inline int GetShadowMode() const { return m_shadowMode; }
|
||||
virtual bool HitTest(double x, double y, int *attachment, double *distance);
|
||||
inline void SetCentreResize(bool cr) { m_centreResize = cr; }
|
||||
inline bool GetCentreResize() const { return m_centreResize; }
|
||||
inline void SetMaintainAspectRatio(bool ar) { m_maintainAspectRatio = ar; }
|
||||
inline bool GetMaintainAspectRatio() const { return m_maintainAspectRatio; }
|
||||
inline wxList& GetLines() const { return (wxList&) m_lines; }
|
||||
inline void SetDisableLabel(bool flag) { m_disableLabel = flag; }
|
||||
inline bool GetDisableLabel() const { return m_disableLabel; }
|
||||
inline void SetAttachmentMode(int mode) { m_attachmentMode = mode; }
|
||||
inline int GetAttachmentMode() const { return m_attachmentMode; }
|
||||
inline void SetId(long i) { m_id = i; }
|
||||
inline long GetId() const { return m_id; }
|
||||
|
||||
void SetPen(wxPen *pen);
|
||||
void SetBrush(wxBrush *brush);
|
||||
inline void SetClientData(wxObject *client_data) { m_clientData = client_data; };
|
||||
inline wxObject *GetClientData() const { return m_clientData; };
|
||||
|
||||
virtual void Show(bool show);
|
||||
virtual bool IsShown() const { return m_visible; }
|
||||
virtual void Move(wxDC& dc, double x1, double y1, bool display = TRUE);
|
||||
virtual void Erase(wxDC& dc);
|
||||
virtual void EraseContents(wxDC& dc);
|
||||
virtual void Draw(wxDC& dc);
|
||||
virtual void Flash();
|
||||
virtual void MoveLinks(wxDC& dc);
|
||||
virtual void DrawContents(wxDC& dc); // E.g. for drawing text label
|
||||
virtual void SetSize(double x, double y, bool recursive = TRUE);
|
||||
virtual void SetAttachmentSize(double x, double y);
|
||||
void Attach(wxShapeCanvas *can);
|
||||
void Detach();
|
||||
|
||||
inline virtual bool Constrain() { return FALSE; } ;
|
||||
|
||||
void AddLine(wxLineShape *line, wxShape *other,
|
||||
int attachFrom = 0, int attachTo = 0,
|
||||
// The line ordering
|
||||
int positionFrom = -1, int positionTo = -1);
|
||||
|
||||
// Return the zero-based position in m_lines of line.
|
||||
int GetLinePosition(wxLineShape* line);
|
||||
|
||||
void AddText(const wxString& string);
|
||||
|
||||
inline wxPen *GetPen() const { return m_pen; }
|
||||
inline wxBrush *GetBrush() const { return m_brush; }
|
||||
|
||||
/*
|
||||
* Region-specific functions (defaults to the default region
|
||||
* for simple objects
|
||||
*/
|
||||
|
||||
// Set the default, single region size to be consistent
|
||||
// with the object size
|
||||
void SetDefaultRegionSize();
|
||||
virtual void FormatText(wxDC& dc, const wxString& s, int regionId = 0);
|
||||
virtual void SetFormatMode(int mode, int regionId = 0);
|
||||
virtual int GetFormatMode(int regionId = 0) const;
|
||||
virtual void SetFont(wxFont *font, int regionId = 0);
|
||||
virtual wxFont *GetFont(int regionId = 0) const;
|
||||
virtual void SetTextColour(const wxString& colour, int regionId = 0);
|
||||
virtual wxString GetTextColour(int regionId = 0) const;
|
||||
virtual inline int GetNumberOfTextRegions() const { return m_regions.Number(); }
|
||||
virtual void SetRegionName(const wxString& name, int regionId = 0);
|
||||
|
||||
// Get the name representing the region for this image alone.
|
||||
// I.e. this image's region ids go from 0 to N-1.
|
||||
// But the names might be "0.2.0", "0.2.1" etc. depending on position in composite.
|
||||
// So the last digit represents the region Id, the others represent positions
|
||||
// in composites.
|
||||
virtual wxString GetRegionName(int regionId);
|
||||
|
||||
// Gets the region corresponding to the name, or -1 if not found.
|
||||
virtual int GetRegionId(const wxString& name);
|
||||
|
||||
// Construct names for regions, unique even for children of a composite.
|
||||
virtual void NameRegions(const wxString& parentName = "");
|
||||
|
||||
// Get list of regions
|
||||
inline wxList& GetRegions() const { return (wxList&) m_regions; }
|
||||
|
||||
virtual void AddRegion(wxShapeRegion *region);
|
||||
|
||||
virtual void ClearRegions();
|
||||
|
||||
// Assign new ids to this image and children (if composite)
|
||||
void AssignNewIds();
|
||||
|
||||
// Returns actual image (same as 'this' if non-composite) and region id
|
||||
// for given region name.
|
||||
virtual wxShape *FindRegion(const wxString& regionName, int *regionId);
|
||||
|
||||
// Finds all region names for this image (composite or simple).
|
||||
// Supply empty string list.
|
||||
virtual void FindRegionNames(wxStringList& list);
|
||||
|
||||
virtual void ClearText(int regionId = 0);
|
||||
void RemoveLine(wxLineShape *line);
|
||||
|
||||
#ifdef PROLOGIO
|
||||
// I/O
|
||||
virtual void WriteAttributes(wxExpr *clause);
|
||||
virtual void ReadAttributes(wxExpr *clause);
|
||||
|
||||
// In case the object has constraints it needs to read in in a different pass
|
||||
inline virtual void ReadConstraints(wxExpr *WXUNUSED(clause), wxExprDatabase *WXUNUSED(database)) { };
|
||||
virtual void WriteRegions(wxExpr *clause);
|
||||
virtual void ReadRegions(wxExpr *clause);
|
||||
#endif
|
||||
|
||||
// Attachment code
|
||||
virtual bool GetAttachmentPosition(int attachment, double *x, double *y,
|
||||
int nth = 0, int no_arcs = 1, wxLineShape *line = NULL);
|
||||
virtual int GetNumberOfAttachments() const;
|
||||
virtual bool AttachmentIsValid(int attachment) const;
|
||||
|
||||
// Only get the attachment position at the _edge_ of the shape, ignoring
|
||||
// branching mode. This is used e.g. to indicate the edge of interest, not the point
|
||||
// on the attachment branch.
|
||||
virtual bool GetAttachmentPositionEdge(int attachment, double *x, double *y,
|
||||
int nth = 0, int no_arcs = 1, wxLineShape *line = NULL);
|
||||
|
||||
// Assuming the attachment lies along a vertical or horizontal line,
|
||||
// calculate the position on that point.
|
||||
virtual wxRealPoint CalcSimpleAttachment(const wxRealPoint& pt1, const wxRealPoint& pt2,
|
||||
int nth, int noArcs, wxLineShape* line);
|
||||
|
||||
// Returns TRUE if pt1 <= pt2 in the sense that one point comes before another on an
|
||||
// edge of the shape.
|
||||
// attachmentPoint is the attachment point (= side) in question.
|
||||
virtual bool AttachmentSortTest(int attachmentPoint, const wxRealPoint& pt1, const wxRealPoint& pt2);
|
||||
|
||||
virtual void EraseLinks(wxDC& dc, int attachment = -1, bool recurse = FALSE);
|
||||
virtual void DrawLinks(wxDC& dc, int attachment = -1, bool recurse = FALSE);
|
||||
|
||||
virtual bool MoveLineToNewAttachment(wxDC& dc, wxLineShape *to_move,
|
||||
double x, double y);
|
||||
|
||||
// Reorders the lines coming into the node image at this attachment
|
||||
// position, in the order in which they appear in linesToSort.
|
||||
virtual void SortLines(int attachment, wxList& linesToSort);
|
||||
|
||||
// Apply an attachment ordering change
|
||||
void ApplyAttachmentOrdering(wxList& ordering);
|
||||
|
||||
// Can override this to prevent or intercept line reordering.
|
||||
virtual void OnChangeAttachment(int attachment, wxLineShape* line, wxList& ordering);
|
||||
|
||||
//// New banching attachment code, 24/9/98
|
||||
|
||||
//
|
||||
// |________|
|
||||
// | <- root
|
||||
// | <- neck
|
||||
// shoulder1 ->---------<- shoulder2
|
||||
// | | | | |<- stem
|
||||
// <- branching attachment point N-1
|
||||
|
||||
// This function gets the root point at the given attachment.
|
||||
virtual wxRealPoint GetBranchingAttachmentRoot(int attachment);
|
||||
|
||||
// This function gets information about where branching connections go (calls GetBranchingAttachmentRoot)
|
||||
virtual bool GetBranchingAttachmentInfo(int attachment, wxRealPoint& root, wxRealPoint& neck,
|
||||
wxRealPoint& shoulder1, wxRealPoint& shoulder2);
|
||||
|
||||
// n is the number of the adjoining line, from 0 to N-1 where N is the number of lines
|
||||
// at this attachment point.
|
||||
// attachmentPoint is where the arc meets the stem, and stemPoint is where the stem meets the
|
||||
// shoulder.
|
||||
virtual bool GetBranchingAttachmentPoint(int attachment, int n, wxRealPoint& attachmentPoint,
|
||||
wxRealPoint& stemPoint);
|
||||
|
||||
// Get the number of lines at this attachment position.
|
||||
virtual int GetAttachmentLineCount(int attachment) const;
|
||||
|
||||
// Draw the branches (not the actual arcs though)
|
||||
virtual void OnDrawBranches(wxDC& dc, int attachment, bool erase = FALSE);
|
||||
virtual void OnDrawBranches(wxDC& dc, bool erase = FALSE);
|
||||
|
||||
// Branching attachment settings
|
||||
inline void SetBranchNeckLength(int len) { m_branchNeckLength = len; }
|
||||
inline int GetBranchNeckLength() const { return m_branchNeckLength; }
|
||||
|
||||
inline void SetBranchStemLength(int len) { m_branchStemLength = len; }
|
||||
inline int GetBranchStemLength() const { return m_branchStemLength; }
|
||||
|
||||
inline void SetBranchSpacing(int len) { m_branchSpacing = len; }
|
||||
inline int GetBranchSpacing() const { return m_branchSpacing; }
|
||||
|
||||
// Further detail on branching style, e.g. blobs on interconnections
|
||||
inline void SetBranchStyle(long style) { m_branchStyle = style; }
|
||||
inline long GetBranchStyle() const { return m_branchStyle; }
|
||||
|
||||
// Rotate the standard attachment point from physical (0 is always North)
|
||||
// to logical (0 -> 1 if rotated by 90 degrees)
|
||||
virtual int PhysicalToLogicalAttachment(int physicalAttachment) const;
|
||||
|
||||
// Rotate the standard attachment point from logical
|
||||
// to physical (0 is always North)
|
||||
virtual int LogicalToPhysicalAttachment(int logicalAttachment) const;
|
||||
|
||||
// This is really to distinguish between lines and other images.
|
||||
// For lines, want to pass drag to canvas, since lines tend to prevent
|
||||
// dragging on a canvas (they get in the way.)
|
||||
virtual bool Draggable() const { return TRUE; }
|
||||
|
||||
// Returns TRUE if image is a descendant of this image
|
||||
bool HasDescendant(wxShape *image);
|
||||
|
||||
// Creates a copy of this shape.
|
||||
wxShape *CreateNewCopy(bool resetMapping = TRUE, bool recompute = TRUE);
|
||||
|
||||
// Does the copying for this object
|
||||
virtual void Copy(wxShape& copy);
|
||||
|
||||
// Does the copying for this object, including copying event
|
||||
// handler data if any. Calls the virtual Copy function.
|
||||
void CopyWithHandler(wxShape& copy);
|
||||
|
||||
// Rotate about the given axis by the given amount in radians.
|
||||
virtual void Rotate(double x, double y, double theta);
|
||||
virtual inline double GetRotation() const { return m_rotation; }
|
||||
|
||||
void ClearAttachments();
|
||||
|
||||
// Recentres all the text regions for this object
|
||||
void Recentre(wxDC& dc);
|
||||
|
||||
// Clears points from a list of wxRealPoints
|
||||
void ClearPointList(wxList& list);
|
||||
|
||||
private:
|
||||
wxObject* m_clientData;
|
||||
|
||||
protected:
|
||||
wxShapeEvtHandler* m_eventHandler;
|
||||
bool m_formatted;
|
||||
double m_xpos, m_ypos;
|
||||
wxPen* m_pen;
|
||||
wxBrush* m_brush;
|
||||
wxFont* m_font;
|
||||
wxColour* m_textColour;
|
||||
wxString m_textColourName;
|
||||
wxShapeCanvas* m_canvas;
|
||||
wxList m_lines;
|
||||
wxList m_text;
|
||||
wxList m_controlPoints;
|
||||
wxList m_regions;
|
||||
wxList m_attachmentPoints;
|
||||
bool m_visible;
|
||||
bool m_disableLabel;
|
||||
long m_id;
|
||||
bool m_selected;
|
||||
bool m_highlighted; // Different from selected: user-defined highlighting,
|
||||
// e.g. thick border.
|
||||
double m_rotation;
|
||||
int m_sensitivity;
|
||||
bool m_draggable;
|
||||
int m_attachmentMode; // 0 for no attachments, 1 if using normal attachments,
|
||||
// 2 for branching attachments
|
||||
bool m_spaceAttachments; // TRUE if lines at one side should be spaced
|
||||
bool m_fixedWidth;
|
||||
bool m_fixedHeight;
|
||||
bool m_centreResize; // Default is to resize keeping the centre constant (TRUE)
|
||||
bool m_drawHandles; // Don't draw handles if FALSE, usually TRUE
|
||||
wxList m_children; // In case it's composite
|
||||
wxShape* m_parent; // In case it's a child
|
||||
int m_formatMode;
|
||||
int m_shadowMode;
|
||||
wxBrush* m_shadowBrush;
|
||||
int m_shadowOffsetX;
|
||||
int m_shadowOffsetY;
|
||||
int m_textMarginX; // Gap between text and border
|
||||
int m_textMarginY;
|
||||
wxString m_regionName;
|
||||
bool m_maintainAspectRatio;
|
||||
int m_branchNeckLength;
|
||||
int m_branchStemLength;
|
||||
int m_branchSpacing;
|
||||
long m_branchStyle;
|
||||
};
|
||||
|
||||
class wxPolygonShape: public wxShape
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxPolygonShape)
|
||||
public:
|
||||
wxPolygonShape();
|
||||
~wxPolygonShape();
|
||||
|
||||
// Takes a list of wxRealPoints; each point is an OFFSET from the centre.
|
||||
// Deletes user's points in destructor.
|
||||
virtual void Create(wxList *points);
|
||||
virtual void ClearPoints();
|
||||
|
||||
void GetBoundingBoxMin(double *w, double *h);
|
||||
void CalculateBoundingBox();
|
||||
bool GetPerimeterPoint(double x1, double y1,
|
||||
double x2, double y2,
|
||||
double *x3, double *y3);
|
||||
bool HitTest(double x, double y, int *attachment, double *distance);
|
||||
void SetSize(double x, double y, bool recursive = TRUE);
|
||||
void OnDraw(wxDC& dc);
|
||||
void OnDrawOutline(wxDC& dc, double x, double y, double w, double h);
|
||||
|
||||
// Control points ('handles') redirect control to the actual shape, to make it easier
|
||||
// to override sizing behaviour.
|
||||
virtual void OnSizingDragLeft(wxControlPoint* pt, bool draw, double x, double y, int keys=0, int attachment = 0);
|
||||
virtual void OnSizingBeginDragLeft(wxControlPoint* pt, double x, double y, int keys=0, int attachment = 0);
|
||||
virtual void OnSizingEndDragLeft(wxControlPoint* pt, double x, double y, int keys=0, int attachment = 0);
|
||||
|
||||
// A polygon should have a control point at each vertex,
|
||||
// with the option of moving the control points individually
|
||||
// to change the shape.
|
||||
void MakeControlPoints();
|
||||
void ResetControlPoints();
|
||||
|
||||
// If we've changed the shape, must make the original
|
||||
// points match the working points
|
||||
void UpdateOriginalPoints();
|
||||
|
||||
// Add a control point after the given point
|
||||
virtual void AddPolygonPoint(int pos = 0);
|
||||
|
||||
// Delete a control point
|
||||
virtual void DeletePolygonPoint(int pos = 0);
|
||||
|
||||
// Recalculates the centre of the polygon
|
||||
virtual void CalculatePolygonCentre();
|
||||
|
||||
#ifdef PROLOGIO
|
||||
void WriteAttributes(wxExpr *clause);
|
||||
void ReadAttributes(wxExpr *clause);
|
||||
#endif
|
||||
|
||||
int GetNumberOfAttachments() const;
|
||||
bool GetAttachmentPosition(int attachment, double *x, double *y,
|
||||
int nth = 0, int no_arcs = 1, wxLineShape *line = NULL);
|
||||
bool AttachmentIsValid(int attachment);
|
||||
// Does the copying for this object
|
||||
void Copy(wxShape& copy);
|
||||
|
||||
inline wxList *GetPoints() { return m_points; }
|
||||
|
||||
// Rotate about the given axis by the given amount in radians
|
||||
virtual void Rotate(double x, double y, double theta);
|
||||
|
||||
private:
|
||||
wxList* m_points;
|
||||
wxList* m_originalPoints;
|
||||
double m_boundWidth;
|
||||
double m_boundHeight;
|
||||
double m_originalWidth;
|
||||
double m_originalHeight;
|
||||
};
|
||||
|
||||
class wxRectangleShape: public wxShape
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxRectangleShape)
|
||||
public:
|
||||
wxRectangleShape(double w = 0.0, double h = 0.0);
|
||||
void GetBoundingBoxMin(double *w, double *h);
|
||||
bool GetPerimeterPoint(double x1, double y1,
|
||||
double x2, double y2,
|
||||
double *x3, double *y3);
|
||||
void OnDraw(wxDC& dc);
|
||||
void SetSize(double x, double y, bool recursive = TRUE);
|
||||
void SetCornerRadius(double rad); // If > 0, rounded corners
|
||||
|
||||
#ifdef PROLOGIO
|
||||
void WriteAttributes(wxExpr *clause);
|
||||
void ReadAttributes(wxExpr *clause);
|
||||
#endif
|
||||
|
||||
int GetNumberOfAttachments() const;
|
||||
bool GetAttachmentPosition(int attachment, double *x, double *y,
|
||||
int nth = 0, int no_arcs = 1, wxLineShape *line = NULL);
|
||||
// Does the copying for this object
|
||||
void Copy(wxShape& copy);
|
||||
|
||||
inline double GetWidth() const { return m_width; }
|
||||
inline double GetHeight() const { return m_height; }
|
||||
inline void SetWidth(double w) { m_width = w; }
|
||||
inline void SetHeight(double h) { m_height = h; }
|
||||
|
||||
protected:
|
||||
double m_width;
|
||||
double m_height;
|
||||
double m_cornerRadius;
|
||||
};
|
||||
|
||||
class wxTextShape: public wxRectangleShape
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxTextShape)
|
||||
public:
|
||||
wxTextShape(double width = 0.0, double height = 0.0);
|
||||
|
||||
void OnDraw(wxDC& dc);
|
||||
|
||||
#ifdef PROLOGIO
|
||||
void WriteAttributes(wxExpr *clause);
|
||||
#endif
|
||||
|
||||
// Does the copying for this object
|
||||
void Copy(wxShape& copy);
|
||||
};
|
||||
|
||||
class wxEllipseShape: public wxShape
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxEllipseShape)
|
||||
public:
|
||||
wxEllipseShape(double w = 0.0, double h = 0.0);
|
||||
|
||||
void GetBoundingBoxMin(double *w, double *h);
|
||||
bool GetPerimeterPoint(double x1, double y1,
|
||||
double x2, double y2,
|
||||
double *x3, double *y3);
|
||||
|
||||
void OnDraw(wxDC& dc);
|
||||
void SetSize(double x, double y, bool recursive = TRUE);
|
||||
|
||||
#ifdef PROLOGIO
|
||||
void WriteAttributes(wxExpr *clause);
|
||||
void ReadAttributes(wxExpr *clause);
|
||||
#endif
|
||||
|
||||
int GetNumberOfAttachments() const;
|
||||
bool GetAttachmentPosition(int attachment, double *x, double *y,
|
||||
int nth = 0, int no_arcs = 1, wxLineShape *line = NULL);
|
||||
|
||||
// Does the copying for this object
|
||||
void Copy(wxShape& copy);
|
||||
|
||||
inline double GetWidth() const { return m_width; }
|
||||
inline double GetHeight() const { return m_height; }
|
||||
|
||||
inline void SetWidth(double w) { m_width = w; }
|
||||
inline void SetHeight(double h) { m_height = h; }
|
||||
|
||||
protected:
|
||||
double m_width;
|
||||
double m_height;
|
||||
};
|
||||
|
||||
class wxCircleShape: public wxEllipseShape
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxCircleShape)
|
||||
public:
|
||||
wxCircleShape(double w = 0.0);
|
||||
|
||||
bool GetPerimeterPoint(double x1, double y1,
|
||||
double x2, double y2,
|
||||
double *x3, double *y3);
|
||||
// Does the copying for this object
|
||||
void Copy(wxShape& copy);
|
||||
};
|
||||
|
||||
#endif
|
||||
// _OGL_BASIC_H_
|
223
include/wx/ogl/basicp.h
Normal file
@@ -0,0 +1,223 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: basicp.h
|
||||
// Purpose: Private OGL classes and definitions
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 12/07/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _OGL_BASICP_H_
|
||||
#define _OGL_BASICP_H_
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface "basicp.h"
|
||||
#endif
|
||||
|
||||
#define CONTROL_POINT_SIZE 6
|
||||
|
||||
class wxShapeTextLine: public wxObject
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxShapeTextLine)
|
||||
public:
|
||||
wxShapeTextLine(double the_x = 0.0, double the_y = 0.0, const wxString& the_line = "");
|
||||
~wxShapeTextLine();
|
||||
|
||||
inline double GetX() const { return m_x; }
|
||||
inline double GetY() const { return m_y; }
|
||||
|
||||
inline void SetX(double x) { m_x = x; }
|
||||
inline void SetY(double y) { m_y = y; }
|
||||
|
||||
inline void SetText(const wxString& text) { m_line = text; }
|
||||
inline wxString GetText() const { return m_line; }
|
||||
|
||||
protected:
|
||||
wxString m_line;
|
||||
double m_x;
|
||||
double m_y;
|
||||
};
|
||||
|
||||
class wxShape;
|
||||
class wxControlPoint: public wxRectangleShape
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxControlPoint)
|
||||
|
||||
friend class wxShapeEvtHandler;
|
||||
friend class wxShape;
|
||||
|
||||
public:
|
||||
wxControlPoint(wxShapeCanvas *the_canvas = NULL, wxShape *object = NULL, double size = 0.0, double the_xoffset = 0.0,
|
||||
double the_yoffset = 0.0, int the_type = 0);
|
||||
~wxControlPoint();
|
||||
|
||||
void OnDraw(wxDC& dc);
|
||||
void OnErase(wxDC& dc);
|
||||
void OnDrawContents(wxDC& dc);
|
||||
void OnDragLeft(bool draw, double x, double y, int keys=0, int attachment = 0);
|
||||
void OnBeginDragLeft(double x, double y, int keys=0, int attachment = 0);
|
||||
void OnEndDragLeft(double x, double y, int keys=0, int attachment = 0);
|
||||
|
||||
bool GetAttachmentPosition(int attachment, double *x, double *y,
|
||||
int nth = 0, int no_arcs = 1, wxLineShape *line = NULL);
|
||||
int GetNumberOfAttachments() const;
|
||||
|
||||
inline void SetEraseObject(bool er) { m_eraseObject = er; }
|
||||
|
||||
public:
|
||||
int m_type;
|
||||
double m_xoffset;
|
||||
double m_yoffset;
|
||||
wxShape* m_shape;
|
||||
wxCursor* m_oldCursor;
|
||||
bool m_eraseObject; // If TRUE, erases object before dragging handle.
|
||||
|
||||
/*
|
||||
* Store original top-left, bottom-right coordinates
|
||||
* in case we're doing non-vertical resizing.
|
||||
*/
|
||||
static double sm_controlPointDragStartX;
|
||||
static double sm_controlPointDragStartY;
|
||||
static double sm_controlPointDragStartWidth;
|
||||
static double sm_controlPointDragStartHeight;
|
||||
static double sm_controlPointDragEndWidth;
|
||||
static double sm_controlPointDragEndHeight;
|
||||
static double sm_controlPointDragPosX;
|
||||
static double sm_controlPointDragPosY;
|
||||
};
|
||||
|
||||
class wxPolygonShape;
|
||||
class wxPolygonControlPoint: public wxControlPoint
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxPolygonControlPoint)
|
||||
friend class wxPolygonShape;
|
||||
public:
|
||||
wxPolygonControlPoint(wxShapeCanvas *the_canvas = NULL, wxShape *object = NULL, double size = 0.0, wxRealPoint *vertex = NULL,
|
||||
double the_xoffset = 0.0, double the_yoffset = 0.0);
|
||||
~wxPolygonControlPoint();
|
||||
|
||||
void OnDragLeft(bool draw, double x, double y, int keys=0, int attachment = 0);
|
||||
void OnBeginDragLeft(double x, double y, int keys=0, int attachment = 0);
|
||||
void OnEndDragLeft(double x, double y, int keys=0, int attachment = 0);
|
||||
|
||||
// Calculate what new size would be, at end of resize
|
||||
virtual void CalculateNewSize(double x, double y);
|
||||
|
||||
// Get new size
|
||||
inline wxRealPoint GetNewSize() const { return m_newSize; };
|
||||
|
||||
public:
|
||||
wxRealPoint* m_polygonVertex;
|
||||
wxRealPoint m_originalSize;
|
||||
double m_originalDistance;
|
||||
wxRealPoint m_newSize;
|
||||
};
|
||||
|
||||
/*
|
||||
* Object regions.
|
||||
* Every shape has one or more text regions with various
|
||||
* properties. Not all of a region's properties will be used
|
||||
* by a shape.
|
||||
*
|
||||
*/
|
||||
|
||||
class wxShapeRegion: public wxObject
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxShapeRegion)
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
wxShapeRegion();
|
||||
// Copy constructor
|
||||
wxShapeRegion(wxShapeRegion& region);
|
||||
// Destructor
|
||||
~wxShapeRegion();
|
||||
|
||||
// Accessors
|
||||
inline void SetText(const wxString& s) { m_regionText = s; }
|
||||
void SetFont(wxFont *f);
|
||||
void SetMinSize(double w, double h);
|
||||
void SetSize(double w, double h);
|
||||
void SetPosition(double x, double y);
|
||||
void SetProportions(double x, double y);
|
||||
void SetFormatMode(int mode);
|
||||
inline void SetName(const wxString& s) { m_regionName = s; };
|
||||
void SetColour(const wxString& col); // Text colour
|
||||
|
||||
inline wxString GetText() const { return m_regionText; }
|
||||
inline wxFont *GetFont() const { return m_font; }
|
||||
inline void GetMinSize(double *x, double *y) const { *x = m_minWidth; *y = m_minHeight; }
|
||||
inline void GetProportion(double *x, double *y) const { *x = m_regionProportionX; *y = m_regionProportionY; }
|
||||
inline void GetSize(double *x, double *y) const { *x = m_width; *y = m_height; }
|
||||
inline void GetPosition(double *xp, double *yp) const { *xp = m_x; *yp = m_y; }
|
||||
inline int GetFormatMode() const { return m_formatMode; }
|
||||
inline wxString GetName() const { return m_regionName; }
|
||||
inline wxString GetColour() const { return m_textColour; }
|
||||
wxColour *GetActualColourObject();
|
||||
inline wxList& GetFormattedText() { return m_formattedText; }
|
||||
inline wxString GetPenColour() const { return m_penColour; }
|
||||
inline int GetPenStyle() const { return m_penStyle; }
|
||||
inline void SetPenStyle(int style) { m_penStyle = style; m_actualPenObject = NULL; }
|
||||
void SetPenColour(const wxString& col);
|
||||
wxPen *GetActualPen();
|
||||
inline double GetWidth() const { return m_width; }
|
||||
inline double GetHeight() const { return m_height; }
|
||||
|
||||
void ClearText();
|
||||
|
||||
public:
|
||||
wxString m_regionText;
|
||||
wxList m_formattedText; // List of wxShapeTextLines
|
||||
wxFont* m_font;
|
||||
double m_minHeight; // If zero, hide region.
|
||||
double m_minWidth; // If zero, hide region.
|
||||
double m_width;
|
||||
double m_height;
|
||||
double m_x;
|
||||
double m_y;
|
||||
|
||||
double m_regionProportionX; // Proportion of total object size;
|
||||
// -1.0 indicates equal proportion
|
||||
double m_regionProportionY; // Proportion of total object size;
|
||||
// -1.0 indicates equal proportion
|
||||
|
||||
int m_formatMode; // FORMAT_CENTRE_HORIZ | FORMAT_CENTRE_VERT | FORMAT_NONE
|
||||
wxString m_regionName;
|
||||
wxString m_textColour;
|
||||
wxColour* m_actualColourObject; // For speed purposes
|
||||
|
||||
// New members for specifying divided rectangle division colour/style 30/6/94
|
||||
wxString m_penColour;
|
||||
int m_penStyle;
|
||||
wxPen* m_actualPenObject;
|
||||
|
||||
};
|
||||
|
||||
/*
|
||||
* User-defined attachment point
|
||||
*/
|
||||
|
||||
class wxAttachmentPoint: public wxObject
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxAttachmentPoint)
|
||||
|
||||
public:
|
||||
inline wxAttachmentPoint()
|
||||
{
|
||||
m_id = 0; m_x = 0.0; m_y = 0.0;
|
||||
}
|
||||
inline wxAttachmentPoint(int id, double x, double y)
|
||||
{
|
||||
m_id = id; m_x = x; m_y = y;
|
||||
}
|
||||
|
||||
public:
|
||||
int m_id; // Identifier
|
||||
double m_x; // x offset from centre of object
|
||||
double m_y; // y offset from centre of object
|
||||
};
|
||||
|
||||
#endif
|
||||
// _OGL_BASICP_H_
|
53
include/wx/ogl/bmpshape.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: bmpshape.h
|
||||
// Purpose: wxBitmapShape
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 12/07/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _OGL_BITMAP_H_
|
||||
#define _OGL_BITMAP_H_
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface "bmpshape.h"
|
||||
#endif
|
||||
|
||||
#include <wx/ogl/basic.h>
|
||||
|
||||
class wxBitmapShape: public wxRectangleShape
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxBitmapShape)
|
||||
public:
|
||||
wxBitmapShape();
|
||||
~wxBitmapShape();
|
||||
|
||||
void OnDraw(wxDC& dc);
|
||||
|
||||
#ifdef PROLOGIO
|
||||
// I/O
|
||||
void WriteAttributes(wxExpr *clause);
|
||||
void ReadAttributes(wxExpr *clause);
|
||||
#endif
|
||||
|
||||
// Does the copying for this object
|
||||
void Copy(wxShape& copy);
|
||||
|
||||
void SetSize(double w, double h, bool recursive = TRUE);
|
||||
inline wxBitmap& GetBitmap() const { return (wxBitmap&) m_bitmap; }
|
||||
void SetBitmap(const wxBitmap& bm);
|
||||
inline void SetFilename(const wxString& f) { m_filename = f; };
|
||||
inline wxString GetFilename() const { return m_filename; }
|
||||
|
||||
private:
|
||||
wxBitmap m_bitmap;
|
||||
wxString m_filename;
|
||||
};
|
||||
|
||||
#endif
|
||||
// _OGL_BITMAP_H_
|
||||
|
||||
|
83
include/wx/ogl/canvas.h
Normal file
@@ -0,0 +1,83 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: canvas.h
|
||||
// Purpose: wxShapeCanvas
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 12/07/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _OGL_CANVAS_H_
|
||||
#define _OGL_CANVAS_H_
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface "canvas.h"
|
||||
#endif
|
||||
|
||||
// Drag states
|
||||
#define NoDragging 0
|
||||
#define StartDraggingLeft 1
|
||||
#define ContinueDraggingLeft 2
|
||||
#define StartDraggingRight 3
|
||||
#define ContinueDraggingRight 4
|
||||
|
||||
// When drag_count reaches 0, process drag message
|
||||
|
||||
class wxDiagram;
|
||||
|
||||
class wxShapeCanvas: public wxScrolledWindow
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxShapeCanvas)
|
||||
public:
|
||||
wxShapeCanvas(wxWindow *parent = NULL, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
|
||||
long style = wxBORDER | wxRETAINED);
|
||||
~wxShapeCanvas();
|
||||
|
||||
inline void SetDiagram(wxDiagram *diag) { m_shapeDiagram = diag; }
|
||||
inline wxDiagram *GetDiagram() const { return m_shapeDiagram; }
|
||||
|
||||
virtual void OnLeftClick(double x, double y, int keys = 0);
|
||||
virtual void OnRightClick(double x, double y, int keys = 0);
|
||||
|
||||
virtual void OnDragLeft(bool draw, double x, double y, int keys=0); // Erase if draw false
|
||||
virtual void OnBeginDragLeft(double x, double y, int keys=0);
|
||||
virtual void OnEndDragLeft(double x, double y, int keys=0);
|
||||
|
||||
virtual void OnDragRight(bool draw, double x, double y, int keys=0); // Erase if draw false
|
||||
virtual void OnBeginDragRight(double x, double y, int keys=0);
|
||||
virtual void OnEndDragRight(double x, double y, int keys=0);
|
||||
|
||||
// Find object for mouse click, of given wxClassInfo (NULL for any type).
|
||||
// If notImage is non-NULL, don't find an object that is equal to or a descendant of notImage
|
||||
virtual wxShape *FindShape(double x, double y, int *attachment, wxClassInfo *info = NULL, wxShape *notImage = NULL);
|
||||
wxShape *FindFirstSensitiveShape(double x, double y, int *new_attachment, int op);
|
||||
wxShape *FindFirstSensitiveShape1(wxShape *image, int op);
|
||||
|
||||
// Redirect to wxDiagram object
|
||||
virtual void AddShape(wxShape *object, wxShape *addAfter = NULL);
|
||||
virtual void InsertShape(wxShape *object);
|
||||
virtual void RemoveShape(wxShape *object);
|
||||
virtual bool GetQuickEditMode();
|
||||
virtual void Redraw(wxDC& dc);
|
||||
void Snap(double *x, double *y);
|
||||
|
||||
// Events
|
||||
void OnPaint(wxPaintEvent& event);
|
||||
void OnMouseEvent(wxMouseEvent& event);
|
||||
|
||||
protected:
|
||||
wxDiagram* m_shapeDiagram;
|
||||
int m_dragState;
|
||||
double m_oldDragX, m_oldDragY; // Previous drag coordinates
|
||||
double m_firstDragX, m_firstDragY; // INITIAL drag coordinates
|
||||
bool m_checkTolerance; // Whether to check drag tolerance
|
||||
wxShape* m_draggedShape;
|
||||
int m_draggedAttachment;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
#endif
|
||||
// _OGL_CANVAS_H_
|
238
include/wx/ogl/composit.h
Normal file
@@ -0,0 +1,238 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: composit.h
|
||||
// Purpose: wxCompositeShape
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 12/07/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _OGL_COMPOSIT_H_
|
||||
#define _OGL_COMPOSIT_H_
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface "composit.h"
|
||||
#endif
|
||||
|
||||
class wxDivisionShape;
|
||||
class wxOGLConstraint;
|
||||
|
||||
/*
|
||||
* A composite object is an invisible rectangle surrounding all children
|
||||
*
|
||||
*/
|
||||
|
||||
class wxCompositeShape: public wxRectangleShape
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxCompositeShape)
|
||||
public:
|
||||
|
||||
wxCompositeShape();
|
||||
~wxCompositeShape();
|
||||
|
||||
void OnDraw(wxDC& dc);
|
||||
void OnDrawContents(wxDC& dc);
|
||||
void OnErase(wxDC& dc);
|
||||
bool OnMovePre(wxDC& dc, double x, double y, double oldX, double oldY, bool display = TRUE);
|
||||
void OnDragLeft(bool draw, double x, double y, int keys, int attachment = 0);
|
||||
void OnBeginDragLeft(double x, double y, int keys, int attachment = 0);
|
||||
void OnEndDragLeft(double x, double y, int keys, int attachment = 0);
|
||||
|
||||
void OnRightClick(double x, double y, int keys, int attachment = 0);
|
||||
|
||||
void SetSize(double w, double h, bool recursive = TRUE);
|
||||
|
||||
// Returns TRUE if it settled down
|
||||
bool Recompute();
|
||||
|
||||
// New members
|
||||
void AddChild(wxShape *child, wxShape *addAfter = NULL);
|
||||
void RemoveChild(wxShape *child);
|
||||
|
||||
wxOGLConstraint *AddConstraint(wxOGLConstraint *constraint);
|
||||
wxOGLConstraint *AddConstraint(int type, wxShape *constraining, wxList& constrained);
|
||||
wxOGLConstraint *AddConstraint(int type, wxShape *constraining, wxShape *constrained);
|
||||
|
||||
void DeleteConstraint(wxOGLConstraint *constraint);
|
||||
|
||||
// Delete constraints that involve this child.
|
||||
void DeleteConstraintsInvolvingChild(wxShape *child);
|
||||
|
||||
// Remove the image from any constraints involving it, but DON'T
|
||||
// remove any constraints.
|
||||
void RemoveChildFromConstraints(wxShape *child);
|
||||
|
||||
// Find constraint, also returning actual composite the constraint was in,
|
||||
// in case it had to find it recursively.
|
||||
wxOGLConstraint *FindConstraint(long id, wxCompositeShape **actualComposite = NULL);
|
||||
|
||||
// Returns TRUE if something changed
|
||||
bool Constrain();
|
||||
|
||||
// Make this composite into a container by creating one wxDivisionShape
|
||||
void MakeContainer();
|
||||
|
||||
// Calculates size and position of composite object based on children
|
||||
void CalculateSize();
|
||||
|
||||
#ifdef PROLOGIO
|
||||
void WriteAttributes(wxExpr *clause);
|
||||
void ReadAttributes(wxExpr *clause);
|
||||
// In case the object has constraints it needs to read in in a different pass
|
||||
void ReadConstraints(wxExpr *clause, wxExprDatabase *database);
|
||||
#endif
|
||||
// Does the copying for this object
|
||||
void Copy(wxShape& copy);
|
||||
|
||||
virtual wxDivisionShape *OnCreateDivision();
|
||||
|
||||
// Finds the image used to visualize a container. This is any child
|
||||
// of the composite that is not in the divisions list.
|
||||
wxShape *FindContainerImage();
|
||||
|
||||
// Returns TRUE if division is a descendant of this container
|
||||
bool ContainsDivision(wxDivisionShape *division);
|
||||
|
||||
inline wxList& GetDivisions() const { return (wxList&) m_divisions; }
|
||||
inline wxList& GetConstraints() const { return (wxList&) m_constraints; }
|
||||
|
||||
protected:
|
||||
double m_oldX;
|
||||
double m_oldY;
|
||||
wxList m_constraints;
|
||||
wxList m_divisions; // In case it's a container
|
||||
};
|
||||
|
||||
/*
|
||||
* A division object is a composite with special properties,
|
||||
* to be used for containment. It's a subdivision of a container.
|
||||
* A containing node image consists of a composite with a main child shape
|
||||
* such as rounded rectangle, plus a list of division objects.
|
||||
* It needs to be a composite because a division contains pieces
|
||||
* of diagram.
|
||||
* NOTE a container has at least one wxDivisionShape for consistency.
|
||||
* This can be subdivided, so it turns into two objects, then each of
|
||||
* these can be subdivided, etc.
|
||||
*/
|
||||
#define DIVISION_SIDE_NONE 0
|
||||
#define DIVISION_SIDE_LEFT 1
|
||||
#define DIVISION_SIDE_TOP 2
|
||||
#define DIVISION_SIDE_RIGHT 3
|
||||
#define DIVISION_SIDE_BOTTOM 4
|
||||
|
||||
class wxDivisionShape: public wxCompositeShape
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxDivisionShape)
|
||||
public:
|
||||
|
||||
wxDivisionShape();
|
||||
~wxDivisionShape();
|
||||
|
||||
void OnDraw(wxDC& dc);
|
||||
void OnDrawContents(wxDC& dc);
|
||||
bool OnMovePre(wxDC& dc, double x, double y, double oldX, double oldY, bool display = TRUE);
|
||||
void OnDragLeft(bool draw, double x, double y, int keys, int attachment = 0);
|
||||
void OnBeginDragLeft(double x, double y, int keys, int attachment = 0);
|
||||
void OnEndDragLeft(double x, double y, int keys, int attachment = 0);
|
||||
|
||||
void OnRightClick(double x, double y, int keys = 0, int attachment = 0);
|
||||
|
||||
// Don't want this kind of composite to resize its subdiagrams, so
|
||||
// override composite's SetSize.
|
||||
void SetSize(double w, double h, bool recursive = TRUE);
|
||||
|
||||
// Similarly for calculating size: it's fixed at whatever SetSize
|
||||
// set it to, not in terms of children.
|
||||
void CalculateSize();
|
||||
|
||||
void MakeControlPoints();
|
||||
void ResetControlPoints();
|
||||
void MakeMandatoryControlPoints();
|
||||
void ResetMandatoryControlPoints();
|
||||
|
||||
#ifdef PROLOGIO
|
||||
void WriteAttributes(wxExpr *clause);
|
||||
void ReadAttributes(wxExpr *clause);
|
||||
#endif
|
||||
// Does the copying for this object
|
||||
void Copy(wxShape& copy);
|
||||
|
||||
// Divide horizontally (wxHORIZONTAL) or vertically (wxVERTICAL)
|
||||
bool Divide(int direction);
|
||||
|
||||
// Resize adjoining divisions at the given side. If test is TRUE,
|
||||
// just see whether it's possible for each adjoining region,
|
||||
// returning FALSE if it's not.
|
||||
bool ResizeAdjoining(int side, double newPos, bool test);
|
||||
|
||||
// Adjust a side, returning FALSE if it's not physically possible.
|
||||
bool AdjustLeft(double left, bool test);
|
||||
bool AdjustTop(double top, bool test);
|
||||
bool AdjustRight(double right, bool test);
|
||||
bool AdjustBottom(double bottom, bool test);
|
||||
|
||||
// Edit style of left or top side
|
||||
void EditEdge(int side);
|
||||
|
||||
// Popup menu
|
||||
void PopupMenu(double x, double y);
|
||||
|
||||
inline void SetLeftSide(wxDivisionShape *shape) { m_leftSide = shape; }
|
||||
inline void SetTopSide(wxDivisionShape *shape) { m_topSide = shape; }
|
||||
inline void SetRightSide(wxDivisionShape *shape) { m_rightSide = shape; }
|
||||
inline void SetBottomSide(wxDivisionShape *shape) { m_bottomSide = shape; }
|
||||
inline wxDivisionShape *GetLeftSide() const { return m_leftSide; }
|
||||
inline wxDivisionShape *GetTopSide() const { return m_topSide; }
|
||||
inline wxDivisionShape *GetRightSide() const { return m_rightSide; }
|
||||
inline wxDivisionShape *GetBottomSide() const { return m_bottomSide; }
|
||||
|
||||
inline void SetHandleSide(int side) { m_handleSide = side; }
|
||||
inline int GetHandleSide() const { return m_handleSide; }
|
||||
|
||||
inline void SetLeftSidePen(wxPen *pen) { m_leftSidePen = pen; }
|
||||
inline wxPen *GetLeftSidePen() const { return m_leftSidePen; }
|
||||
inline void SetTopSidePen(wxPen *pen) { m_topSidePen = pen; }
|
||||
inline wxPen *GetTopSidePen() const { return m_topSidePen; }
|
||||
|
||||
void SetLeftSideColour(const wxString& colour);
|
||||
void SetTopSideColour(const wxString& colour);
|
||||
void SetLeftSideStyle(const wxString& style);
|
||||
void SetTopSideStyle(const wxString& style);
|
||||
|
||||
inline wxString GetLeftSideColour() const { return m_leftSideColour; }
|
||||
inline wxString GetTopSideColour() const { return m_topSideColour; }
|
||||
inline wxString GetLeftSideStyle() const { return m_leftSideStyle; }
|
||||
inline wxString GetTopSideStyle() const { return m_topSideStyle; }
|
||||
|
||||
protected:
|
||||
// Adjoining divisions. NULL indicates edge
|
||||
// of container, and that side shouldn't be
|
||||
// drawn.
|
||||
wxDivisionShape* m_leftSide;
|
||||
wxDivisionShape* m_rightSide;
|
||||
wxDivisionShape* m_topSide;
|
||||
wxDivisionShape* m_bottomSide;
|
||||
|
||||
int m_handleSide; // Side at which handle is legal
|
||||
|
||||
wxPen* m_leftSidePen;
|
||||
wxPen* m_topSidePen;
|
||||
wxString m_leftSideColour;
|
||||
wxString m_topSideColour;
|
||||
wxString m_leftSideStyle;
|
||||
wxString m_topSideStyle;
|
||||
};
|
||||
|
||||
|
||||
#define DIVISION_MENU_SPLIT_HORIZONTALLY 1
|
||||
#define DIVISION_MENU_SPLIT_VERTICALLY 2
|
||||
#define DIVISION_MENU_EDIT_LEFT_EDGE 3
|
||||
#define DIVISION_MENU_EDIT_TOP_EDGE 4
|
||||
#define DIVISION_MENU_EDIT_RIGHT_EDGE 5
|
||||
#define DIVISION_MENU_EDIT_BOTTOM_EDGE 6
|
||||
#define DIVISION_MENU_DELETE_ALL 7
|
||||
|
||||
#endif
|
||||
// _OGL_COMPOSIT_H_
|
87
include/wx/ogl/constrnt.h
Normal file
@@ -0,0 +1,87 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: constrnt.h
|
||||
// Purpose: OGL constraint definitions
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 12/07/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _OGL_CONSTRNT_H_
|
||||
#define _OGL_CONSTRNT_H_
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface "constrnt.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* OGL Constraints
|
||||
*
|
||||
*/
|
||||
|
||||
class wxOGLConstraintType: public wxObject
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxOGLConstraintType)
|
||||
public:
|
||||
wxOGLConstraintType(int type = 0, const wxString& name = "", const wxString& phrase = "");
|
||||
~wxOGLConstraintType();
|
||||
|
||||
public:
|
||||
int m_type; // E.g. gyCONSTRAINT_CENTRED_VERTICALLY
|
||||
wxString m_name; // E.g. "Centre vertically"
|
||||
wxString m_phrase; // E.g. "centred vertically with respect to", "left of"
|
||||
|
||||
};
|
||||
|
||||
extern wxList* wxOGLConstraintTypes;
|
||||
|
||||
#define gyCONSTRAINT_CENTRED_VERTICALLY 1
|
||||
#define gyCONSTRAINT_CENTRED_HORIZONTALLY 2
|
||||
#define gyCONSTRAINT_CENTRED_BOTH 3
|
||||
#define gyCONSTRAINT_LEFT_OF 4
|
||||
#define gyCONSTRAINT_RIGHT_OF 5
|
||||
#define gyCONSTRAINT_ABOVE 6
|
||||
#define gyCONSTRAINT_BELOW 7
|
||||
#define gyCONSTRAINT_ALIGNED_TOP 8
|
||||
#define gyCONSTRAINT_ALIGNED_BOTTOM 9
|
||||
#define gyCONSTRAINT_ALIGNED_LEFT 10
|
||||
#define gyCONSTRAINT_ALIGNED_RIGHT 11
|
||||
|
||||
// Like aligned, but with the objects centred on the respective edge
|
||||
// of the reference object.
|
||||
#define gyCONSTRAINT_MIDALIGNED_TOP 12
|
||||
#define gyCONSTRAINT_MIDALIGNED_BOTTOM 13
|
||||
#define gyCONSTRAINT_MIDALIGNED_LEFT 14
|
||||
#define gyCONSTRAINT_MIDALIGNED_RIGHT 15
|
||||
|
||||
class wxOGLConstraint: public wxObject
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxOGLConstraint)
|
||||
public:
|
||||
wxOGLConstraint() { m_xSpacing = 0.0; m_ySpacing = 0.0; m_constraintType = 0; m_constraintName = ""; m_constraintId = 0;
|
||||
m_constrainingObject = NULL; }
|
||||
wxOGLConstraint(int type, wxShape *constraining, wxList& constrained);
|
||||
~wxOGLConstraint();
|
||||
|
||||
// Returns TRUE if anything changed
|
||||
bool Evaluate();
|
||||
inline void SetSpacing(double x, double y) { m_xSpacing = x; m_ySpacing = y; };
|
||||
bool Equals(double a, double b);
|
||||
|
||||
double m_xSpacing;
|
||||
double m_ySpacing;
|
||||
int m_constraintType;
|
||||
wxString m_constraintName;
|
||||
long m_constraintId;
|
||||
wxShape* m_constrainingObject;
|
||||
wxList m_constrainedObjects;
|
||||
|
||||
};
|
||||
|
||||
void OGLInitializeConstraintTypes();
|
||||
void OGLCleanUpConstraintTypes();
|
||||
|
||||
#endif
|
||||
// _OGL_CONSTRNT_H_
|
75
include/wx/ogl/divided.h
Normal file
@@ -0,0 +1,75 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: divided.h
|
||||
// Purpose: wxDividedShape
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 12/07/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _OGL_DIVIDED_H_
|
||||
#define _OGL_DIVIDED_H_
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface "basic.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Definition of a region
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Box divided into horizontal regions
|
||||
*
|
||||
*/
|
||||
|
||||
extern wxFont *g_oglNormalFont;
|
||||
class wxDividedShape: public wxRectangleShape
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxDividedShape)
|
||||
|
||||
public:
|
||||
wxDividedShape(double w = 0.0, double h = 0.0);
|
||||
~wxDividedShape();
|
||||
|
||||
void OnDraw(wxDC& dc);
|
||||
void OnDrawContents(wxDC& dc);
|
||||
|
||||
void SetSize(double w, double h, bool recursive = TRUE);
|
||||
|
||||
void MakeControlPoints();
|
||||
void ResetControlPoints();
|
||||
|
||||
void MakeMandatoryControlPoints();
|
||||
void ResetMandatoryControlPoints();
|
||||
|
||||
#ifdef PROLOGIO
|
||||
void WriteAttributes(wxExpr *clause);
|
||||
void ReadAttributes(wxExpr *clause);
|
||||
#endif
|
||||
|
||||
void Copy(wxShape ©);
|
||||
|
||||
// Set all region sizes according to proportions and
|
||||
// this object total size
|
||||
void SetRegionSizes();
|
||||
|
||||
// Edit region colours/styles
|
||||
void EditRegions();
|
||||
|
||||
// Attachment points correspond to regions in the divided box
|
||||
bool GetAttachmentPosition(int attachment, double *x, double *y,
|
||||
int nth = 0, int no_arcs = 1, wxLineShape *line = NULL);
|
||||
bool AttachmentIsValid(int attachment);
|
||||
int GetNumberOfAttachments() const;
|
||||
|
||||
// Invoke editor on CTRL-right click
|
||||
void OnRightClick(double x, double y, int keys = 0, int attachment = 0);
|
||||
};
|
||||
|
||||
#endif
|
||||
// _OGL_DIVIDED_H_
|
||||
|
227
include/wx/ogl/drawn.h
Normal file
@@ -0,0 +1,227 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: drawn.h
|
||||
// Purpose: wxDrawnShape
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 12/07/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _OGL_DRAWN_H_
|
||||
#define _OGL_DRAWN_H_
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface "drawn.h"
|
||||
#endif
|
||||
|
||||
#include <wx/ogl/basic.h>
|
||||
|
||||
#define oglMETAFLAGS_OUTLINE 1
|
||||
#define oglMETAFLAGS_ATTACHMENTS 2
|
||||
|
||||
class wxDrawnShape;
|
||||
class wxPseudoMetaFile: public wxObject
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxPseudoMetaFile)
|
||||
public:
|
||||
wxPseudoMetaFile();
|
||||
wxPseudoMetaFile(wxPseudoMetaFile& mf);
|
||||
~wxPseudoMetaFile();
|
||||
|
||||
void Draw(wxDC& dc, double xoffset, double yoffset);
|
||||
|
||||
#ifdef PROLOGIO
|
||||
void WriteAttributes(wxExpr *clause, int whichAngle);
|
||||
void ReadAttributes(wxExpr *clause, int whichAngle);
|
||||
#endif
|
||||
|
||||
void Clear();
|
||||
|
||||
void Copy(wxPseudoMetaFile& copy);
|
||||
|
||||
void Scale(double sx, double sy);
|
||||
void ScaleTo(double w, double h); // Scale to fit size
|
||||
void Translate(double x, double y);
|
||||
|
||||
// Rotate about the given axis by theta radians from the x axis.
|
||||
void Rotate(double x, double y, double theta);
|
||||
|
||||
bool LoadFromMetaFile(char *filename, double *width, double *height);
|
||||
|
||||
void GetBounds(double *minX, double *minY, double *maxX, double *maxY);
|
||||
|
||||
// Calculate size from current operations
|
||||
void CalculateSize(wxDrawnShape* shape);
|
||||
|
||||
inline wxList& GetOutlineColours() const { return (wxList&) m_outlineColours; }
|
||||
inline wxList& GetFillColours() const { return (wxList&) m_fillColours; }
|
||||
inline void SetRotateable(bool rot) { m_rotateable = rot; }
|
||||
inline bool GetRotateable() const { return m_rotateable; }
|
||||
|
||||
inline void SetSize(double w, double h) { m_width = w; m_height = h; }
|
||||
|
||||
inline void SetFillBrush(wxBrush* brush) { m_fillBrush = brush; }
|
||||
inline wxBrush* GetFillBrush() const { return m_fillBrush; }
|
||||
|
||||
inline void SetOutlinePen(wxPen* pen) { m_outlinePen = pen; }
|
||||
inline wxPen* GetOutlinePen() const { return m_outlinePen; }
|
||||
|
||||
inline void SetOutlineOp(int op) { m_outlineOp = op; }
|
||||
inline int GetOutlineOp() const { return m_outlineOp; }
|
||||
|
||||
inline wxList& GetOps() const { return (wxList&) m_ops; }
|
||||
|
||||
// Is this a valid (non-empty) metafile?
|
||||
inline bool IsValid() const { return (m_ops.Number() > 0); }
|
||||
|
||||
public:
|
||||
/// Set of functions for drawing into a pseudo metafile.
|
||||
/// They use integers, but doubles are used internally for accuracy
|
||||
/// when scaling.
|
||||
|
||||
virtual void DrawLine(const wxPoint& pt1, const wxPoint& pt2);
|
||||
virtual void DrawRectangle(const wxRect& rect);
|
||||
virtual void DrawRoundedRectangle(const wxRect& rect, double radius);
|
||||
virtual void DrawArc(const wxPoint& centrePt, const wxPoint& startPt, const wxPoint& endPt);
|
||||
virtual void DrawEllipticArc(const wxRect& rect, double startAngle, double endAngle);
|
||||
virtual void DrawEllipse(const wxRect& rect);
|
||||
virtual void DrawPoint(const wxPoint& pt);
|
||||
virtual void DrawText(const wxString& text, const wxPoint& pt);
|
||||
virtual void DrawLines(int n, wxPoint pts[]);
|
||||
// flags:
|
||||
// oglMETAFLAGS_OUTLINE: will be used for drawing the outline and
|
||||
// also drawing lines/arrows at the circumference.
|
||||
// oglMETAFLAGS_ATTACHMENTS: will be used for initialising attachment points at
|
||||
// the vertices (perhaps a rare case...)
|
||||
virtual void DrawPolygon(int n, wxPoint pts[], int flags = 0);
|
||||
virtual void DrawSpline(int n, wxPoint pts[]);
|
||||
|
||||
virtual void SetClippingRect(const wxRect& rect);
|
||||
virtual void DestroyClippingRect();
|
||||
|
||||
virtual void SetPen(wxPen* pen, bool isOutline = FALSE); // TODO: eventually, just store GDI object attributes, not actual
|
||||
virtual void SetBrush(wxBrush* brush, bool isFill = FALSE); // pens/brushes etc.
|
||||
virtual void SetFont(wxFont* font);
|
||||
virtual void SetTextColour(const wxColour& colour);
|
||||
virtual void SetBackgroundColour(const wxColour& colour);
|
||||
virtual void SetBackgroundMode(int mode);
|
||||
|
||||
public:
|
||||
bool m_rotateable;
|
||||
double m_width;
|
||||
double m_height;
|
||||
wxList m_ops; // List of drawing operations (see drawnp.h)
|
||||
wxList m_gdiObjects; // List of pens, brushes and fonts for this object.
|
||||
int m_outlineOp; // The op representing the outline, if any
|
||||
|
||||
// Pen/brush specifying outline/fill colours
|
||||
// to override operations.
|
||||
wxPen* m_outlinePen;
|
||||
wxBrush* m_fillBrush;
|
||||
wxList m_outlineColours; // List of the GDI operations that comprise the outline
|
||||
wxList m_fillColours; // List of the GDI operations that fill the shape
|
||||
double m_currentRotation;
|
||||
};
|
||||
|
||||
#define oglDRAWN_ANGLE_0 0
|
||||
#define oglDRAWN_ANGLE_90 1
|
||||
#define oglDRAWN_ANGLE_180 2
|
||||
#define oglDRAWN_ANGLE_270 3
|
||||
|
||||
class wxDrawnShape: public wxRectangleShape
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxDrawnShape)
|
||||
public:
|
||||
wxDrawnShape();
|
||||
~wxDrawnShape();
|
||||
|
||||
void OnDraw(wxDC& dc);
|
||||
|
||||
#ifdef PROLOGIO
|
||||
// I/O
|
||||
void WriteAttributes(wxExpr *clause);
|
||||
void ReadAttributes(wxExpr *clause);
|
||||
#endif
|
||||
|
||||
// Does the copying for this object
|
||||
void Copy(wxShape& copy);
|
||||
|
||||
void Scale(double sx, double sy);
|
||||
void Translate(double x, double y);
|
||||
// Rotate about the given axis by theta radians from the x axis.
|
||||
void Rotate(double x, double y, double theta);
|
||||
|
||||
// Get current rotation
|
||||
inline double GetRotation() const { return m_rotation; }
|
||||
|
||||
void SetSize(double w, double h, bool recursive = TRUE);
|
||||
bool LoadFromMetaFile(char *filename);
|
||||
|
||||
inline void SetSaveToFile(bool save) { m_saveToFile = save; }
|
||||
inline wxPseudoMetaFile& GetMetaFile(int which = 0) const { return (wxPseudoMetaFile&) m_metafiles[which]; }
|
||||
|
||||
void OnDrawOutline(wxDC& dc, double x, double y, double w, double h);
|
||||
|
||||
// Get the perimeter point using the special outline op, if there is one,
|
||||
// otherwise use default wxRectangleShape scheme
|
||||
bool GetPerimeterPoint(double x1, double y1,
|
||||
double x2, double y2,
|
||||
double *x3, double *y3);
|
||||
|
||||
/// Set of functions for drawing into a pseudo metafile.
|
||||
/// They use integers, but doubles are used internally for accuracy
|
||||
/// when scaling.
|
||||
|
||||
virtual void DrawLine(const wxPoint& pt1, const wxPoint& pt2);
|
||||
virtual void DrawRectangle(const wxRect& rect);
|
||||
virtual void DrawRoundedRectangle(const wxRect& rect, double radius);
|
||||
virtual void DrawArc(const wxPoint& centrePt, const wxPoint& startPt, const wxPoint& endPt);
|
||||
virtual void DrawEllipticArc(const wxRect& rect, double startAngle, double endAngle);
|
||||
virtual void DrawEllipse(const wxRect& rect);
|
||||
virtual void DrawPoint(const wxPoint& pt);
|
||||
virtual void DrawText(const wxString& text, const wxPoint& pt);
|
||||
virtual void DrawLines(int n, wxPoint pts[]);
|
||||
virtual void DrawPolygon(int n, wxPoint pts[], int flags = 0);
|
||||
virtual void DrawSpline(int n, wxPoint pts[]);
|
||||
|
||||
virtual void SetClippingRect(const wxRect& rect);
|
||||
virtual void DestroyClippingRect();
|
||||
|
||||
virtual void SetDrawnPen(wxPen* pen, bool isOutline = FALSE); // TODO: eventually, just store GDI object attributes, not actual
|
||||
virtual void SetDrawnBrush(wxBrush* brush, bool isFill = FALSE); // pens/brushes etc.
|
||||
virtual void SetDrawnFont(wxFont* font);
|
||||
virtual void SetDrawnTextColour(const wxColour& colour);
|
||||
virtual void SetDrawnBackgroundColour(const wxColour& colour);
|
||||
virtual void SetDrawnBackgroundMode(int mode);
|
||||
|
||||
// Set the width/height according to the shapes in the metafile.
|
||||
// Call this after drawing into the shape.
|
||||
inline void CalculateSize() { m_metafiles[m_currentAngle].CalculateSize(this); }
|
||||
|
||||
inline void DrawAtAngle(int angle) { m_currentAngle = angle; };
|
||||
|
||||
inline int GetAngle() const { return m_currentAngle; }
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
// Which metafile do we use now? Based on current rotation and validity
|
||||
// of metafiles.
|
||||
int DetermineMetaFile(double rotation);
|
||||
|
||||
private:
|
||||
// One metafile for each 90 degree rotation (or just a single one).
|
||||
wxPseudoMetaFile m_metafiles[4];
|
||||
|
||||
// Don't save all wxDrawnShape metafiles to file: sometimes
|
||||
// we take the metafile data from a symbol library.
|
||||
bool m_saveToFile;
|
||||
|
||||
// Which angle are we using/drawing into?
|
||||
int m_currentAngle;
|
||||
};
|
||||
|
||||
#endif
|
||||
// _DRAWN_H_
|
||||
|
205
include/wx/ogl/drawnp.h
Normal file
@@ -0,0 +1,205 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: drawnp.h
|
||||
// Purpose: Private header for wxDrawnShape
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 12/07/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _OGL_DRAWNP_H_
|
||||
#define _OGL_DRAWNP_H_
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface "drawnp.h"
|
||||
#endif
|
||||
|
||||
#include <wx/ogl/drawn.h>
|
||||
|
||||
/*
|
||||
* Drawing operations
|
||||
*
|
||||
*/
|
||||
|
||||
#define DRAWOP_SET_PEN 1
|
||||
#define DRAWOP_SET_BRUSH 2
|
||||
#define DRAWOP_SET_FONT 3
|
||||
#define DRAWOP_SET_TEXT_COLOUR 4
|
||||
#define DRAWOP_SET_BK_COLOUR 5
|
||||
#define DRAWOP_SET_BK_MODE 6
|
||||
#define DRAWOP_SET_CLIPPING_RECT 7
|
||||
#define DRAWOP_DESTROY_CLIPPING_RECT 8
|
||||
|
||||
/*
|
||||
#define DRAWOP_CREATE_PEN 10
|
||||
#define DRAWOP_CREATE_BRUSH 11
|
||||
#define DRAWOP_CREATE_FONT 12
|
||||
*/
|
||||
|
||||
#define DRAWOP_DRAW_LINE 20
|
||||
#define DRAWOP_DRAW_POLYLINE 21
|
||||
#define DRAWOP_DRAW_POLYGON 22
|
||||
#define DRAWOP_DRAW_RECT 23
|
||||
#define DRAWOP_DRAW_ROUNDED_RECT 24
|
||||
#define DRAWOP_DRAW_ELLIPSE 25
|
||||
#define DRAWOP_DRAW_POINT 26
|
||||
#define DRAWOP_DRAW_ARC 27
|
||||
#define DRAWOP_DRAW_TEXT 28
|
||||
#define DRAWOP_DRAW_SPLINE 29
|
||||
#define DRAWOP_DRAW_ELLIPTIC_ARC 30
|
||||
|
||||
/*
|
||||
* Base, virtual class
|
||||
*
|
||||
*/
|
||||
|
||||
class wxDrawOp: public wxObject
|
||||
{
|
||||
public:
|
||||
inline wxDrawOp(int theOp) { m_op = theOp; }
|
||||
inline ~wxDrawOp() {}
|
||||
inline virtual void Scale(double xScale, double yScale) {};
|
||||
inline virtual void Translate(double x, double y) {};
|
||||
inline virtual void Rotate(double x, double y, double theta, double sinTheta, double cosTheta) {};
|
||||
virtual void Do(wxDC& dc, double xoffset, double yoffset) = 0;
|
||||
virtual wxDrawOp *Copy(wxPseudoMetaFile *newImage) = 0;
|
||||
virtual wxExpr *WriteExpr(wxPseudoMetaFile *image) = 0;
|
||||
virtual void ReadExpr(wxPseudoMetaFile *image, wxExpr *expr) = 0;
|
||||
|
||||
inline int GetOp() const { return m_op; }
|
||||
|
||||
// Draw an outline using the current operation. By default, return FALSE (not drawn)
|
||||
virtual bool OnDrawOutline(wxDC& dc, double x, double y, double w, double h,
|
||||
double oldW, double oldH) { return FALSE; }
|
||||
|
||||
// Get the perimeter point using this data
|
||||
virtual bool GetPerimeterPoint(double x1, double y1,
|
||||
double x2, double y2,
|
||||
double *x3, double *y3,
|
||||
double xOffset, double yOffset,
|
||||
int attachmentMode)
|
||||
{ return FALSE; }
|
||||
|
||||
protected:
|
||||
int m_op;
|
||||
|
||||
};
|
||||
|
||||
/*
|
||||
* Set font, brush, text colour
|
||||
*
|
||||
*/
|
||||
|
||||
class wxOpSetGDI: public wxDrawOp
|
||||
{
|
||||
public:
|
||||
wxOpSetGDI(int theOp, wxPseudoMetaFile *theImage, int theGdiIndex, int theMode = 0);
|
||||
void Do(wxDC& dc, double xoffset, double yoffset);
|
||||
wxDrawOp *Copy(wxPseudoMetaFile *newImage);
|
||||
wxExpr *WriteExpr(wxPseudoMetaFile *image);
|
||||
void ReadExpr(wxPseudoMetaFile *image, wxExpr *expr);
|
||||
|
||||
public:
|
||||
int m_mode;
|
||||
int m_gdiIndex;
|
||||
wxPseudoMetaFile* m_image;
|
||||
unsigned char m_r;
|
||||
unsigned char m_g;
|
||||
unsigned char m_b;
|
||||
};
|
||||
|
||||
/*
|
||||
* Set/destroy clipping
|
||||
*
|
||||
*/
|
||||
|
||||
class wxOpSetClipping: public wxDrawOp
|
||||
{
|
||||
public:
|
||||
wxOpSetClipping(int theOp, double theX1, double theY1, double theX2, double theY2);
|
||||
void Do(wxDC& dc, double xoffset, double yoffset);
|
||||
void Scale(double xScale, double yScale);
|
||||
void Translate(double x, double y);
|
||||
wxDrawOp *Copy(wxPseudoMetaFile *newImage);
|
||||
wxExpr *WriteExpr(wxPseudoMetaFile *image);
|
||||
void ReadExpr(wxPseudoMetaFile *image, wxExpr *expr);
|
||||
|
||||
public:
|
||||
double m_x1;
|
||||
double m_y1;
|
||||
double m_x2;
|
||||
double m_y2;
|
||||
};
|
||||
|
||||
/*
|
||||
* Draw line, rectangle, rounded rectangle, ellipse, point, arc, text
|
||||
*
|
||||
*/
|
||||
|
||||
class wxOpDraw: public wxDrawOp
|
||||
{
|
||||
public:
|
||||
wxOpDraw(int theOp, double theX1, double theY1, double theX2, double theY2,
|
||||
double radius = 0.0, char *s = NULL);
|
||||
~wxOpDraw();
|
||||
void Do(wxDC& dc, double xoffset, double yoffset);
|
||||
void Scale(double scaleX, double scaleY);
|
||||
void Translate(double x, double y);
|
||||
void Rotate(double x, double y, double theta, double sinTheta, double cosTheta);
|
||||
wxDrawOp *Copy(wxPseudoMetaFile *newImage);
|
||||
wxExpr *WriteExpr(wxPseudoMetaFile *image);
|
||||
void ReadExpr(wxPseudoMetaFile *image, wxExpr *expr);
|
||||
|
||||
public:
|
||||
double m_x1;
|
||||
double m_y1;
|
||||
double m_x2;
|
||||
double m_y2;
|
||||
double m_x3;
|
||||
double m_y3;
|
||||
double m_radius;
|
||||
char* m_textString;
|
||||
|
||||
};
|
||||
|
||||
/*
|
||||
* Draw polyline, spline, polygon
|
||||
*
|
||||
*/
|
||||
|
||||
class wxOpPolyDraw: public wxDrawOp
|
||||
{
|
||||
public:
|
||||
wxOpPolyDraw(int theOp, int n, wxRealPoint *thePoints);
|
||||
~wxOpPolyDraw();
|
||||
void Do(wxDC& dc, double xoffset, double yoffset);
|
||||
void Scale(double scaleX, double scaleY);
|
||||
void Translate(double x, double y);
|
||||
void Rotate(double x, double y, double theta, double sinTheta, double cosTheta);
|
||||
wxDrawOp *Copy(wxPseudoMetaFile *newImage);
|
||||
wxExpr *WriteExpr(wxPseudoMetaFile *image);
|
||||
void ReadExpr(wxPseudoMetaFile *image, wxExpr *expr);
|
||||
|
||||
// Draw an outline using the current operation.
|
||||
virtual bool OnDrawOutline(wxDC& dc, double x, double y, double w, double h,
|
||||
double oldW, double oldH);
|
||||
|
||||
// Get the perimeter point using this data
|
||||
bool GetPerimeterPoint(double x1, double y1,
|
||||
double x2, double y2,
|
||||
double *x3, double *y3,
|
||||
double xOffset, double yOffset,
|
||||
int attachmentMode);
|
||||
|
||||
public:
|
||||
wxRealPoint* m_points;
|
||||
int m_noPoints;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
// _OGL_DRAWNP_H_
|
||||
|
||||
|
296
include/wx/ogl/lines.h
Normal file
@@ -0,0 +1,296 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: lines.h
|
||||
// Purpose: wxLineShape
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 12/07/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _OGL_LINES_H_
|
||||
#define _OGL_LINES_H_
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface "lines.h"
|
||||
#endif
|
||||
|
||||
class wxLabelShape;
|
||||
class wxPseudoMetaFile;
|
||||
class wxLineControlPoint;
|
||||
/*
|
||||
* Arcs with multiple arrowheads
|
||||
*
|
||||
*/
|
||||
|
||||
// Types of arrowhead
|
||||
// (i) Built-in
|
||||
#define ARROW_HOLLOW_CIRCLE 1
|
||||
#define ARROW_FILLED_CIRCLE 2
|
||||
#define ARROW_ARROW 3
|
||||
#define ARROW_SINGLE_OBLIQUE 4
|
||||
#define ARROW_DOUBLE_OBLIQUE 5
|
||||
// (ii) Custom
|
||||
#define ARROW_METAFILE 20
|
||||
|
||||
// Position of arrow on line
|
||||
#define ARROW_POSITION_START 0
|
||||
#define ARROW_POSITION_END 1
|
||||
#define ARROW_POSITION_MIDDLE 2
|
||||
|
||||
// Line alignment flags
|
||||
// Vertical by default
|
||||
#define LINE_ALIGNMENT_HORIZ 1
|
||||
#define LINE_ALIGNMENT_VERT 0
|
||||
#define LINE_ALIGNMENT_TO_NEXT_HANDLE 2
|
||||
#define LINE_ALIGNMENT_NONE 0
|
||||
|
||||
class wxArrowHead: public wxObject
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxArrowHead)
|
||||
|
||||
public:
|
||||
wxArrowHead(WXTYPE type = 0, int end = 0, double size = 0.0, double dist = 0.0, const wxString& name = "", wxPseudoMetaFile *mf = NULL,
|
||||
long arrowId = -1);
|
||||
~wxArrowHead();
|
||||
wxArrowHead(wxArrowHead& toCopy);
|
||||
|
||||
inline WXTYPE _GetType() const { return m_arrowType; }
|
||||
inline int GetPosition() const { return m_arrowEnd; }
|
||||
inline void SetPosition(int pos) { m_arrowEnd = pos; }
|
||||
inline double GetXOffset() const { return m_xOffset; }
|
||||
inline double GetYOffset() const { return m_yOffset; }
|
||||
inline double GetSpacing() const { return m_spacing; }
|
||||
inline double GetSize() const { return m_arrowSize; }
|
||||
inline wxString GetName() const { return m_arrowName; }
|
||||
inline void SetXOffset(double x) { m_xOffset = x; }
|
||||
inline void SetYOffset(double y) { m_yOffset = y; }
|
||||
inline wxPseudoMetaFile *GetMetaFile() const { return m_metaFile; }
|
||||
inline long GetId() const { return m_id; }
|
||||
inline int GetArrowEnd() const { return m_arrowEnd; }
|
||||
inline double GetArrowSize() const { return m_arrowSize; }
|
||||
void SetSize(double size);
|
||||
inline void SetSpacing(double sp) { m_spacing = sp; }
|
||||
|
||||
protected:
|
||||
WXTYPE m_arrowType;
|
||||
int m_arrowEnd; // Position on line
|
||||
double m_xOffset; // Distance from arc start or end, w.r.t. point on arrowhead
|
||||
// nearest start or end. If zero, use default spacing.
|
||||
double m_yOffset; // vertical offset (w.r.t. a horizontal line). Normally zero.
|
||||
double m_spacing; // Spacing from the last arrowhead
|
||||
double m_arrowSize; // Length of arrowhead
|
||||
wxString m_arrowName; // Name of arrow
|
||||
bool m_saveToFile; // TRUE if we want to save custom arrowheads to file.
|
||||
wxPseudoMetaFile* m_metaFile; // Pseudo metafile if this is a custom arrowhead
|
||||
long m_id; // identifier
|
||||
};
|
||||
|
||||
// Line object
|
||||
class wxLabelShape;
|
||||
class wxLineShape: public wxShape
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxLineShape)
|
||||
|
||||
public:
|
||||
wxLineShape();
|
||||
~wxLineShape();
|
||||
|
||||
// Called when a connected object has moved, to move the link to
|
||||
// correct position
|
||||
// moveControlPoints must be disabled when a control point is being
|
||||
// dragged.
|
||||
void OnMoveLink(wxDC& dc, bool moveControlPoints = TRUE);
|
||||
bool OnMovePre(wxDC& dc, double x, double y, double old_x, double old_y, bool display = TRUE);
|
||||
void OnDraw(wxDC& dc);
|
||||
void OnDrawContents(wxDC& dc);
|
||||
void OnDrawControlPoints(wxDC& dc);
|
||||
void OnEraseControlPoints(wxDC& dc);
|
||||
void OnErase(wxDC& dc);
|
||||
virtual bool OnMoveControlPoint(int WXUNUSED(which), double WXUNUSED(x), double WXUNUSED(y)) { return FALSE; }
|
||||
virtual bool OnMoveMiddleControlPoint(wxDC& dc, wxLineControlPoint* lpt, const wxRealPoint& pt);
|
||||
virtual bool OnLabelMovePre(wxDC& dc, wxLabelShape* labelShape, double x, double y, double old_x, double old_y, bool display);
|
||||
void OnDrawOutline(wxDC& dc, double x, double y, double w, double h);
|
||||
void GetBoundingBoxMin(double *w, double *h);
|
||||
void FormatText(wxDC& dc, const wxString& s, int regionId = 0);
|
||||
virtual void SetEnds(double x1, double y1, double x2, double y2);
|
||||
virtual void GetEnds(double *x1, double *y1, double *x2, double *y2);
|
||||
inline virtual wxShape *GetFrom() { return m_from; }
|
||||
inline virtual wxShape *GetTo() { return m_to; }
|
||||
inline virtual int GetAttachmentFrom() { return m_attachmentFrom; }
|
||||
inline virtual int GetAttachmentTo() { return m_attachmentTo; }
|
||||
|
||||
virtual void SetFrom(wxShape *object);
|
||||
virtual void SetTo(wxShape *object);
|
||||
virtual void DrawArrows(wxDC& dc);
|
||||
|
||||
// Finds the x, y points at the two ends of the line.
|
||||
// This function can be used by e.g. line-routing routines to
|
||||
// get the actual points on the two node images where the lines will be drawn
|
||||
// to/from.
|
||||
void FindLineEndPoints(double *fromX, double *fromY, double *toX, double *toY);
|
||||
|
||||
// Format one region at this position
|
||||
void DrawRegion(wxDC& dc, wxShapeRegion *region, double x, double y);
|
||||
|
||||
// Erase one region at this position
|
||||
void EraseRegion(wxDC& dc, wxShapeRegion *region, double x, double y);
|
||||
|
||||
// Get the reference point for a label. Region x and y
|
||||
// are offsets from this.
|
||||
// position is 0 (middle), 1 (start), 2 (end)
|
||||
void GetLabelPosition(int position, double *x, double *y);
|
||||
|
||||
// Can override this to create a different class of label shape
|
||||
virtual wxLabelShape* OnCreateLabelShape(wxLineShape *parent = NULL, wxShapeRegion *region = NULL, double w = 0.0, double h = 0.0);
|
||||
|
||||
// Straighten verticals and horizontals
|
||||
virtual void Straighten(wxDC* dc = NULL);
|
||||
|
||||
// Not implemented
|
||||
inline void SetMaintainStraightLines(bool flag) { m_maintainStraightLines = flag; }
|
||||
inline bool GetMaintainStraightLines() const { return m_maintainStraightLines; }
|
||||
|
||||
// Make handle control points
|
||||
void MakeControlPoints();
|
||||
void ResetControlPoints();
|
||||
|
||||
// Make a given number of control points
|
||||
virtual void MakeLineControlPoints(int n);
|
||||
virtual wxNode *InsertLineControlPoint(wxDC* dc);
|
||||
virtual bool DeleteLineControlPoint();
|
||||
virtual void Initialise();
|
||||
inline wxList *GetLineControlPoints() { return m_lineControlPoints; }
|
||||
|
||||
// Override dragging behaviour - don't want to be able to drag lines!
|
||||
void OnDragLeft(bool draw, double x, double y, int keys=0, int attachment = 0);
|
||||
void OnBeginDragLeft(double x, double y, int keys=0, int attachment = 0);
|
||||
void OnEndDragLeft(double x, double y, int keys=0, int attachment = 0);
|
||||
|
||||
// Control points ('handles') redirect control to the actual shape, to make it easier
|
||||
// to override sizing behaviour.
|
||||
virtual void OnSizingDragLeft(wxControlPoint* pt, bool draw, double x, double y, int keys=0, int attachment = 0);
|
||||
virtual void OnSizingBeginDragLeft(wxControlPoint* pt, double x, double y, int keys=0, int attachment = 0);
|
||||
virtual void OnSizingEndDragLeft(wxControlPoint* pt, double x, double y, int keys=0, int attachment = 0);
|
||||
|
||||
// Override select, to create/delete temporary label-moving objects
|
||||
void Select(bool select = TRUE, wxDC* dc = NULL);
|
||||
|
||||
// Set to spline (TRUE) or line (FALSE)
|
||||
inline void SetSpline(bool spl) { m_isSpline = spl; }
|
||||
inline bool IsSpline() const { return m_isSpline; }
|
||||
|
||||
void Unlink();
|
||||
void SetAttachments(int from_attach, int to_attach);
|
||||
inline void SetAttachmentFrom(int attach) { m_attachmentFrom = attach; }
|
||||
inline void SetAttachmentTo(int attach) { m_attachmentTo = attach; }
|
||||
|
||||
bool HitTest(double x, double y, int *attachment, double *distance);
|
||||
|
||||
#ifdef PROLOGIO
|
||||
// I/O
|
||||
virtual void WriteAttributes(wxExpr *clause);
|
||||
virtual void ReadAttributes(wxExpr *clause);
|
||||
#endif
|
||||
|
||||
virtual void FindNth(wxShape *image, int *nth, int *no_arcs, bool incoming);
|
||||
|
||||
// Find which position we're talking about at this (x, y).
|
||||
// Returns ARROW_POSITION_START, ARROW_POSITION_MIDDLE, ARROW_POSITION_END
|
||||
int FindLinePosition(double x, double y);
|
||||
|
||||
// This is really to distinguish between lines and other images.
|
||||
// For lines, want to pass drag to canvas, since lines tend to prevent
|
||||
// dragging on a canvas (they get in the way.)
|
||||
virtual bool Draggable() const { return FALSE; }
|
||||
|
||||
// Does the copying for this object
|
||||
void Copy(wxShape& copy);
|
||||
|
||||
// Add an arrowhead.
|
||||
wxArrowHead *AddArrow(WXTYPE type, int end = ARROW_POSITION_END,
|
||||
double arrowSize = 10.0, double xOffset = 0.0, const wxString& name = "",
|
||||
wxPseudoMetaFile *mf = NULL, long arrowId = -1);
|
||||
|
||||
// Add an arrowhead in the position indicated by the reference
|
||||
// list of arrowheads, which contains all legal arrowheads for this
|
||||
// line, in the correct order.
|
||||
// E.g. reference list: a b c d e
|
||||
// Current line list: a d
|
||||
// Add c, then line list is: a c d
|
||||
// If no legal arrowhead position, return FALSE.
|
||||
// Assume reference list is for one end only, since it potentially defines
|
||||
// the ordering for any one of the 3 positions. So we don't check
|
||||
// the reference list for arrowhead position.
|
||||
bool AddArrowOrdered(wxArrowHead *arrow, wxList& referenceList, int end);
|
||||
|
||||
// Delete arrowhead(s)
|
||||
void ClearArrowsAtPosition(int end = -1);
|
||||
bool ClearArrow(const wxString& name);
|
||||
wxArrowHead *FindArrowHead(int position, const wxString& name);
|
||||
wxArrowHead *FindArrowHead(long arrowId);
|
||||
bool DeleteArrowHead(int position, const wxString& name);
|
||||
bool DeleteArrowHead(long arrowId);
|
||||
void DrawArrow(wxDC& dc, wxArrowHead *arrow, double xOffset, bool proportionalOffset);
|
||||
inline void SetIgnoreOffsets(bool ignore) { m_ignoreArrowOffsets = ignore; }
|
||||
inline wxList& GetArrows() const { return (wxList&) m_arcArrows; }
|
||||
|
||||
// Find horizontal width for drawing a line with
|
||||
// arrows in minimum space. Assume arrows at
|
||||
// END only
|
||||
double FindMinimumWidth();
|
||||
|
||||
// Set alignment flags. ALIGNMENT NOT IMPLEMENTED.
|
||||
void SetAlignmentOrientation(bool isEnd, bool isHoriz);
|
||||
void SetAlignmentType(bool isEnd, int alignType);
|
||||
bool GetAlignmentOrientation(bool isEnd);
|
||||
int GetAlignmentType(bool isEnd);
|
||||
|
||||
// Find next control point in line after the start/end point
|
||||
// (depending on whether the node object is at start or end)
|
||||
wxRealPoint *GetNextControlPoint(wxShape *nodeObject);
|
||||
inline bool IsEnd(wxShape *nodeObject) const { return (m_to == nodeObject); }
|
||||
|
||||
private:
|
||||
bool m_erasing; // flag to say whether we're erasing or drawing
|
||||
// this line (really so metafiles can draw a
|
||||
// blank rectangle)
|
||||
bool m_ignoreArrowOffsets; // Don't always want to draw arrowhead offsets
|
||||
// because they may not work on tool palettes (for example)
|
||||
bool m_isSpline;
|
||||
bool m_maintainStraightLines;
|
||||
|
||||
protected:
|
||||
// Temporary list of line segment orientations
|
||||
// so we know what direction the line is supposed to be dog-legging
|
||||
// in. The values are integer: 0 for vertical, 1 for horizontal.
|
||||
wxList m_lineOrientations;
|
||||
|
||||
// Temporary pointers for start, middle and end label editing objects
|
||||
// (active only when the line is selected)
|
||||
wxLabelShape* m_labelObjects[3];
|
||||
|
||||
// These define the segmented line - not to be confused with temporary control
|
||||
// points which appear when object is selected (although in this case they'll
|
||||
// probably be the same)
|
||||
wxList* m_lineControlPoints;
|
||||
|
||||
double m_arrowSpacing; // Separation between adjacent arrows
|
||||
|
||||
wxShape* m_to;
|
||||
wxShape* m_from;
|
||||
|
||||
int m_attachmentTo; // Attachment point at one end
|
||||
int m_attachmentFrom; // Attachment point at other end
|
||||
|
||||
// Alignment flags
|
||||
int m_alignmentStart;
|
||||
int m_alignmentEnd;
|
||||
|
||||
wxList m_arcArrows;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
// _OGL_LINES_H_
|
89
include/wx/ogl/linesp.h
Normal file
@@ -0,0 +1,89 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: linesp.h
|
||||
// Purpose: Lines private header file
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 12/07/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _OGL_LINESP_H_
|
||||
#define _OGL_LINESP_H_
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface "linesp.h"
|
||||
#endif
|
||||
|
||||
class wxLineShape;
|
||||
class wxLineControlPoint: public wxControlPoint
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxLineControlPoint)
|
||||
friend class wxLineShape;
|
||||
public:
|
||||
|
||||
wxLineControlPoint(wxShapeCanvas *the_canvas = NULL, wxShape *object = NULL, double size = 0.0,
|
||||
double x = 0.0, double y = 0.0, int the_type = 0);
|
||||
~wxLineControlPoint();
|
||||
|
||||
void OnDraw(wxDC& dc);
|
||||
void OnDragLeft(bool draw, double x, double y, int keys=0, int attachment = 0);
|
||||
void OnBeginDragLeft(double x, double y, int keys=0, int attachment = 0);
|
||||
void OnEndDragLeft(double x, double y, int keys=0, int attachment = 0);
|
||||
|
||||
// Obsolete (left-dragging now moves attachment point to new relative position OR new
|
||||
// attachment id)
|
||||
#if 0
|
||||
void OnDragRight(bool draw, double x, double y, int keys=0, int attachment = 0);
|
||||
void OnBeginDragRight(double x, double y, int keys=0, int attachment = 0);
|
||||
void OnEndDragRight(double x, double y, int keys=0, int attachment = 0);
|
||||
#endif
|
||||
|
||||
public:
|
||||
|
||||
int m_type;
|
||||
wxRealPoint* m_point; // Line point
|
||||
wxRealPoint m_originalPos;
|
||||
|
||||
};
|
||||
|
||||
/*
|
||||
* Temporary arc label object
|
||||
*/
|
||||
|
||||
class wxLabelShape: public wxRectangleShape
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxLabelShape)
|
||||
|
||||
public:
|
||||
wxLabelShape(wxLineShape *parent = NULL, wxShapeRegion *region = NULL, double w = 0.0, double h = 0.0);
|
||||
~wxLabelShape();
|
||||
|
||||
void OnDraw(wxDC& dc);
|
||||
void OnDrawContents(wxDC& dc);
|
||||
void OnLeftClick(double x, double y, int keys = 0, int attachment = 0);
|
||||
void OnRightClick(double x, double y, int keys = 0, int attachment = 0);
|
||||
void OnDragLeft(bool draw, double x, double y, int keys=0, int attachment = 0);
|
||||
void OnBeginDragLeft(double x, double y, int keys=0, int attachment = 0);
|
||||
void OnEndDragLeft(double x, double y, int keys=0, int attachment = 0);
|
||||
bool OnMovePre(wxDC& dc, double x, double y, double old_x, double old_y, bool display = TRUE);
|
||||
|
||||
public:
|
||||
wxLineShape* m_lineShape;
|
||||
wxShapeRegion* m_shapeRegion;
|
||||
|
||||
};
|
||||
|
||||
/*
|
||||
* Get the point on the given line (x1, y1) (x2, y2)
|
||||
* distance 'length' along from the end,
|
||||
* returned values in x and y
|
||||
*/
|
||||
|
||||
void GetPointOnLine(double x1, double y1, double x2, double y2,
|
||||
double length, double *x, double *y);
|
||||
|
||||
#endif
|
||||
// _OGL_LINESP_H_
|
||||
|
211
include/wx/ogl/mfutils.h
Normal file
@@ -0,0 +1,211 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: mfutils.h
|
||||
// Purpose: Metafile utilities: reading a placeable metafile independently
|
||||
// of Windows.
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 12/07/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _MFUTILS_H_
|
||||
#define _MFUTILS_H_
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface "mfutils.h"
|
||||
#endif
|
||||
|
||||
#include <wx/metafile.h>
|
||||
|
||||
#ifndef GetRValue
|
||||
#define GetRValue(rgb) ((unsigned char)(rgb))
|
||||
#define GetGValue(rgb) ((unsigned char)(((int)(rgb)) >> 8))
|
||||
#define GetBValue(rgb) ((unsigned char)((rgb)>>16))
|
||||
#endif
|
||||
|
||||
/* Metafile Functions */
|
||||
/* Win32s/Borland need these macros, although META_SETBKCOLOR is defined */
|
||||
#if 1 // !defined(META_SETBKCOLOR) // || defined(WIN32)
|
||||
|
||||
#define META_SETBKCOLOR 0x0201
|
||||
#define META_SETBKMODE 0x0102
|
||||
#define META_SETMAPMODE 0x0103
|
||||
#define META_SETROP2 0x0104
|
||||
#define META_SETRELABS 0x0105
|
||||
#define META_SETPOLYFILLMODE 0x0106
|
||||
#define META_SETSTRETCHBLTMODE 0x0107
|
||||
#define META_SETTEXTCHAREXTRA 0x0108
|
||||
#define META_SETTEXTCOLOR 0x0209
|
||||
#define META_SETTEXTJUSTIFICATION 0x020A
|
||||
#define META_SETWINDOWORG 0x020B
|
||||
#define META_SETWINDOWEXT 0x020C
|
||||
#define META_SETVIEWPORTORG 0x020D
|
||||
#define META_SETVIEWPORTEXT 0x020E
|
||||
#define META_OFFSETWINDOWORG 0x020F
|
||||
#define META_SCALEWINDOWEXT 0x0410
|
||||
#define META_OFFSETVIEWPORTORG 0x0211
|
||||
#define META_SCALEVIEWPORTEXT 0x0412
|
||||
#define META_LINETO 0x0213
|
||||
#define META_MOVETO 0x0214
|
||||
#define META_EXCLUDECLIPRECT 0x0415
|
||||
#define META_INTERSECTCLIPRECT 0x0416
|
||||
#define META_ARC 0x0817
|
||||
#define META_ELLIPSE 0x0418
|
||||
#define META_FLOODFILL 0x0419
|
||||
#define META_PIE 0x081A
|
||||
#define META_RECTANGLE 0x041B
|
||||
#define META_ROUNDRECT 0x061C
|
||||
#define META_PATBLT 0x061D
|
||||
#define META_SAVEDC 0x001E
|
||||
#define META_SETPIXEL 0x041F
|
||||
#define META_OFFSETCLIPRGN 0x0220
|
||||
#define META_TEXTOUT 0x0521
|
||||
#define META_BITBLT 0x0922
|
||||
#define META_STRETCHBLT 0x0B23
|
||||
#define META_POLYGON 0x0324
|
||||
#define META_POLYLINE 0x0325
|
||||
#define META_ESCAPE 0x0626
|
||||
#define META_RESTOREDC 0x0127
|
||||
#define META_FILLREGION 0x0228
|
||||
#define META_FRAMEREGION 0x0429
|
||||
#define META_INVERTREGION 0x012A
|
||||
#define META_PAINTREGION 0x012B
|
||||
#define META_SELECTCLIPREGION 0x012C
|
||||
#define META_SELECTOBJECT 0x012D
|
||||
#define META_SETTEXTALIGN 0x012E
|
||||
#define META_DRAWTEXT 0x062F
|
||||
|
||||
#define META_CHORD 0x0830
|
||||
#define META_SETMAPPERFLAGS 0x0231
|
||||
#define META_EXTTEXTOUT 0x0a32
|
||||
#define META_SETDIBTODEV 0x0d33
|
||||
#define META_SELECTPALETTE 0x0234
|
||||
#define META_REALIZEPALETTE 0x0035
|
||||
#define META_ANIMATEPALETTE 0x0436
|
||||
#define META_SETPALENTRIES 0x0037
|
||||
#define META_POLYPOLYGON 0x0538
|
||||
#define META_RESIZEPALETTE 0x0139
|
||||
|
||||
#define META_DIBBITBLT 0x0940
|
||||
#define META_DIBSTRETCHBLT 0x0b41
|
||||
#define META_DIBCREATEPATTERNBRUSH 0x0142
|
||||
#define META_STRETCHDIB 0x0f43
|
||||
|
||||
#define META_EXTFLOODFILL 0x0548
|
||||
|
||||
#define META_RESETDC 0x014C
|
||||
#define META_STARTDOC 0x014D
|
||||
#define META_STARTPAGE 0x004F
|
||||
#define META_ENDPAGE 0x0050
|
||||
#define META_ABORTDOC 0x0052
|
||||
#define META_ENDDOC 0x005E
|
||||
|
||||
#define META_DELETEOBJECT 0x01f0
|
||||
|
||||
#define META_CREATEPALETTE 0x00f7
|
||||
#define META_CREATEBRUSH 0x00F8
|
||||
#define META_CREATEPATTERNBRUSH 0x01F9
|
||||
#define META_CREATEPENINDIRECT 0x02FA
|
||||
#define META_CREATEFONTINDIRECT 0x02FB
|
||||
#define META_CREATEBRUSHINDIRECT 0x02FC
|
||||
#define META_CREATEBITMAPINDIRECT 0x02FD
|
||||
#define META_CREATEBITMAP 0x06FE
|
||||
#define META_CREATEREGION 0x06FF
|
||||
|
||||
/* Background Modes */
|
||||
#define TRANSPARENT 1
|
||||
#define OPAQUE 2
|
||||
|
||||
/* Pen Styles */
|
||||
#define PS_SOLID 0
|
||||
#define PS_DASH 1
|
||||
#define PS_DOT 2
|
||||
#define PS_DASHDOT 3
|
||||
#define PS_DASHDOTDOT 4
|
||||
#define PS_NULL 5
|
||||
#define PS_INSIDEFRAME 6
|
||||
|
||||
/* PitchAndFamily family values (high 4 bits) */
|
||||
/* Win32s/Borland don't need this */
|
||||
#ifndef FF_DONTCARE // !defined(__BORLANDC__) && !defined(WIN32)
|
||||
#define FF_DONTCARE 0x00
|
||||
#define FF_ROMAN 0x10
|
||||
#define FF_SWISS 0x20
|
||||
#define FF_MODERN 0x30
|
||||
#define FF_SCRIPT 0x40
|
||||
#define FF_DECORATIVE 0x50
|
||||
#endif
|
||||
|
||||
/* Brush Styles */
|
||||
#define BS_SOLID 0
|
||||
#define BS_NULL 1
|
||||
#define BS_HOLLOW BS_NULL
|
||||
#define BS_HATCHED 2
|
||||
#define BS_PATTERN 3
|
||||
#define BS_INDEXED 4
|
||||
#define BS_DIBPATTERN 5
|
||||
|
||||
/* Hatch Styles */
|
||||
#define HS_HORIZONTAL 0
|
||||
#define HS_VERTICAL 1
|
||||
#define HS_FDIAGONAL 2
|
||||
#define HS_BDIAGONAL 3
|
||||
#define HS_CROSS 4
|
||||
#define HS_DIAGCROSS 5
|
||||
|
||||
#endif // metafile functions
|
||||
|
||||
class wxMetaRecord: public wxObject
|
||||
{
|
||||
public:
|
||||
int metaFunction;
|
||||
long param1;
|
||||
long param2;
|
||||
long param3;
|
||||
long param4;
|
||||
long param5;
|
||||
long param6;
|
||||
long param7;
|
||||
long param8;
|
||||
char *stringParam;
|
||||
wxRealPoint *points;
|
||||
|
||||
wxMetaRecord(int fun)
|
||||
{
|
||||
metaFunction = fun; points = NULL; stringParam = NULL;
|
||||
param1 = 0;
|
||||
}
|
||||
~wxMetaRecord(void);
|
||||
};
|
||||
|
||||
class wxXMetaFile: public wxObject
|
||||
{
|
||||
public:
|
||||
double lastX;
|
||||
double lastY;
|
||||
bool ok;
|
||||
|
||||
double left;
|
||||
double top;
|
||||
double right;
|
||||
double bottom;
|
||||
|
||||
wxList metaRecords;
|
||||
wxList gdiObjects; // List of wxMetaRecord objects created with Create...,
|
||||
// referenced by position in list by SelectObject
|
||||
wxXMetaFile(char *file = NULL);
|
||||
~wxXMetaFile(void);
|
||||
|
||||
// After this is called, the metafile cannot be used for anything
|
||||
// since it is now owned by the clipboard.
|
||||
bool SetClipboard(int width = 0, int height = 0);
|
||||
|
||||
bool Play(wxDC *dc);
|
||||
inline bool Ok(void) const { return ok; }
|
||||
bool ReadFile(char *file);
|
||||
};
|
||||
|
||||
#endif
|
||||
// _MFUTILS_H_
|
113
include/wx/ogl/misc.h
Normal file
@@ -0,0 +1,113 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: misc.h
|
||||
// Purpose: Miscellaneous utilities for OGL
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 12/07/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _OGL_MISC_H_
|
||||
#define _OGL_MISC_H_
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface "misc.h"
|
||||
#endif
|
||||
|
||||
// List to use when copying objects; may need to associate elements of new objects
|
||||
// with elements of old objects, e.g. when copying constraint.s
|
||||
extern wxList oglObjectCopyMapping;
|
||||
|
||||
/*
|
||||
* TEXT FORMATTING FUNCTIONS
|
||||
*
|
||||
*/
|
||||
|
||||
// Centres the given list of wxShapeTextLine strings in the given box
|
||||
// (changing the positions in situ). Doesn't actually draw into the DC.
|
||||
void oglCentreText(wxDC& dc, wxList *text, double m_xpos, double m_ypos,
|
||||
double width, double height,
|
||||
int formatMode = FORMAT_CENTRE_HORIZ | FORMAT_CENTRE_VERT);
|
||||
|
||||
// Given a string, returns a list of strings that fit within the given
|
||||
// width of box. Height is ignored.
|
||||
wxStringList *oglFormatText(wxDC& dc, const wxString& text, double width, double height, int formatMode = 0);
|
||||
|
||||
// Centres the list of wxShapeTextLine strings, doesn't clip.
|
||||
// Doesn't actually draw into the DC.
|
||||
void oglCentreTextNoClipping(wxDC& dc, wxList *text_list,
|
||||
double m_xpos, double m_ypos, double width, double height);
|
||||
|
||||
// Gets the maximum width and height of the given list of wxShapeTextLines.
|
||||
void oglGetCentredTextExtent(wxDC& dc, wxList *text_list,
|
||||
double m_xpos, double m_ypos, double width, double height,
|
||||
double *actual_width, double *actual_height);
|
||||
|
||||
// Actually draw the preformatted list of wxShapeTextLines.
|
||||
void oglDrawFormattedText(wxDC& context, wxList *text_list,
|
||||
double m_xpos, double m_ypos, double width, double height,
|
||||
int formatMode = FORMAT_CENTRE_HORIZ | FORMAT_CENTRE_VERT);
|
||||
|
||||
// Give it a list of points, finds the centre.
|
||||
void oglFindPolylineCentroid(wxList *points, double *x, double *y);
|
||||
|
||||
void oglCheckLineIntersection(double x1, double y1, double x2, double y2,
|
||||
double x3, double y3, double x4, double y4,
|
||||
double *ratio1, double *ratio2);
|
||||
|
||||
void oglFindEndForPolyline(double n, double xvec[], double yvec[],
|
||||
double x1, double y1, double x2, double y2, double *x3, double *y3);
|
||||
|
||||
|
||||
void oglFindEndForBox(double width, double height,
|
||||
double x1, double y1, // Centre of box (possibly)
|
||||
double x2, double y2, // other end of line
|
||||
double *x3, double *y3); // End on box edge
|
||||
|
||||
void oglFindEndForCircle(double radius,
|
||||
double x1, double y1, // Centre of circle
|
||||
double x2, double y2, // Other end of line
|
||||
double *x3, double *y3);
|
||||
|
||||
void oglGetArrowPoints(double x1, double y1, double x2, double y2,
|
||||
double length, double width,
|
||||
double *tip_x, double *tip_y,
|
||||
double *side1_x, double *side1_y,
|
||||
double *side2_x, double *side2_y);
|
||||
|
||||
/*
|
||||
* Given an ellipse and endpoints of a line, returns the point at which
|
||||
* the line touches the ellipse in values x4, y4.
|
||||
* This function assumes that the centre of the ellipse is at x1, y1, and the
|
||||
* ellipse has a width of a1 and a height of b1. It also assumes you are
|
||||
* wanting to draw an arc FROM point x2, y2 TOWARDS point x3, y3.
|
||||
* This function calculates the x,y coordinates of the intersection point of
|
||||
* the arc with the ellipse.
|
||||
* Author: Ian Harrison
|
||||
*/
|
||||
|
||||
void oglDrawArcToEllipse(double x1, double y1, double a1, double b1, double x2, double y2, double x3, double y3,
|
||||
double *x4, double *y4);
|
||||
|
||||
bool oglRoughlyEqual(double val1, double val2, double tol = 0.00001);
|
||||
|
||||
extern wxFont* g_oglNormalFont;
|
||||
extern wxPen* g_oglBlackPen;
|
||||
extern wxPen* g_oglWhiteBackgroundPen;
|
||||
extern wxPen* g_oglTransparentPen;
|
||||
extern wxBrush* g_oglWhiteBackgroundBrush;
|
||||
extern wxPen* g_oglBlackForegroundPen;
|
||||
extern wxCursor* g_oglBullseyeCursor;
|
||||
|
||||
extern wxFont* oglMatchFont(int point_size);
|
||||
|
||||
extern wxString oglColourToHex(const wxColour& colour);
|
||||
extern wxColour oglHexToColour(const wxString& hex);
|
||||
extern void oglDecToHex(unsigned int dec, char *buf);
|
||||
extern unsigned int oglHexToDec(char* buf);
|
||||
|
||||
|
||||
#endif
|
||||
// _OGL_MISC_H_
|
27
include/wx/ogl/ogl.h
Normal file
@@ -0,0 +1,27 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: ogl.h
|
||||
// Purpose: OGL main include
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 12/07/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _OGL_OGL_H_
|
||||
#define _OGL_OGL_H_
|
||||
|
||||
#include <wx/ogl/basic.h> // Basic shapes
|
||||
#include <wx/ogl/lines.h> // Lines and splines
|
||||
#include <wx/ogl/divided.h> // Vertically-divided rectangle
|
||||
#include <wx/ogl/composit.h> // Composite images
|
||||
#include <wx/ogl/canvas.h> // wxShapeCanvas for displaying objects
|
||||
#include <wx/ogl/ogldiag.h> // wxDiagram
|
||||
|
||||
// TODO: replace with wxModule implementation
|
||||
extern void wxOGLInitialize();
|
||||
extern void wxOGLCleanUp();
|
||||
|
||||
#endif
|
||||
// _OGL_OGL_H_
|
124
include/wx/ogl/ogldiag.h
Normal file
@@ -0,0 +1,124 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: ogldiag.h
|
||||
// Purpose: OGL - wxDiagram class
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 12/07/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _OGL_OGLDIAG_H_
|
||||
#define _OGL_OGLDIAG_H_
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface "ogldiag.h"
|
||||
#endif
|
||||
|
||||
#include "basic.h"
|
||||
|
||||
class wxDiagram: public wxObject
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxDiagram)
|
||||
|
||||
public:
|
||||
|
||||
wxDiagram();
|
||||
virtual ~wxDiagram();
|
||||
|
||||
void SetCanvas(wxShapeCanvas *can);
|
||||
|
||||
inline wxShapeCanvas *GetCanvas() const { return m_diagramCanvas; }
|
||||
|
||||
virtual void Redraw(wxDC& dc);
|
||||
virtual void Clear(wxDC& dc);
|
||||
virtual void DrawOutline(wxDC& dc, double x1, double y1, double x2, double y2);
|
||||
|
||||
// Add object to end of object list (if addAfter is NULL)
|
||||
// or just after addAfter.
|
||||
virtual void AddShape(wxShape *object, wxShape *addAfter = NULL);
|
||||
|
||||
// Add object to front of object list
|
||||
virtual void InsertShape(wxShape *object);
|
||||
|
||||
void SetSnapToGrid(bool snap);
|
||||
void SetGridSpacing(double spacing);
|
||||
inline double GetGridSpacing() const { return m_gridSpacing; }
|
||||
inline bool GetSnapToGrid() const { return m_snapToGrid; }
|
||||
void Snap(double *x, double *y);
|
||||
|
||||
inline void SetQuickEditMode(bool qem) { m_quickEditMode = qem; }
|
||||
inline bool GetQuickEditMode() const { return m_quickEditMode; }
|
||||
|
||||
virtual void RemoveShape(wxShape *object);
|
||||
virtual void RemoveAllShapes();
|
||||
virtual void DeleteAllShapes();
|
||||
virtual void ShowAll(bool show);
|
||||
|
||||
// Find a shape by its id
|
||||
wxShape* FindShape(long id) const;
|
||||
|
||||
inline void SetMouseTolerance(int tol) { m_mouseTolerance = tol; }
|
||||
inline int GetMouseTolerance() const { return m_mouseTolerance; }
|
||||
inline wxList *GetShapeList() const { return m_shapeList; }
|
||||
inline int GetCount() const { return m_shapeList->Number(); }
|
||||
|
||||
// Make sure all text that should be centred, is centred.
|
||||
void RecentreAll(wxDC& dc);
|
||||
|
||||
#ifdef PROLOGIO
|
||||
virtual bool SaveFile(const wxString& filename);
|
||||
virtual bool LoadFile(const wxString& filename);
|
||||
|
||||
virtual void ReadNodes(wxExprDatabase& database);
|
||||
virtual void ReadLines(wxExprDatabase& database);
|
||||
virtual void ReadContainerGeometry(wxExprDatabase& database);
|
||||
|
||||
// Allow for modifying file
|
||||
virtual bool OnDatabaseLoad(wxExprDatabase& db);
|
||||
virtual bool OnDatabaseSave(wxExprDatabase& db);
|
||||
virtual bool OnShapeSave(wxExprDatabase& db, wxShape& shape, wxExpr& expr);
|
||||
virtual bool OnShapeLoad(wxExprDatabase& db, wxShape& shape, wxExpr& expr);
|
||||
virtual bool OnHeaderSave(wxExprDatabase& db, wxExpr& expr);
|
||||
virtual bool OnHeaderLoad(wxExprDatabase& db, wxExpr& expr);
|
||||
#endif
|
||||
|
||||
protected:
|
||||
wxShapeCanvas* m_diagramCanvas;
|
||||
bool m_quickEditMode;
|
||||
bool m_snapToGrid;
|
||||
double m_gridSpacing;
|
||||
int m_mouseTolerance;
|
||||
wxList* m_shapeList;
|
||||
};
|
||||
|
||||
class wxLineCrossing: public wxObject
|
||||
{
|
||||
public:
|
||||
wxLineCrossing() { m_lineShape1 = NULL; m_lineShape2 = NULL; }
|
||||
wxRealPoint m_pt1; // First line
|
||||
wxRealPoint m_pt2;
|
||||
wxRealPoint m_pt3; // Second line
|
||||
wxRealPoint m_pt4;
|
||||
wxRealPoint m_intersect;
|
||||
wxLineShape* m_lineShape1;
|
||||
wxLineShape* m_lineShape2;
|
||||
};
|
||||
|
||||
class wxLineCrossings: public wxObject
|
||||
{
|
||||
public:
|
||||
wxLineCrossings();
|
||||
~wxLineCrossings();
|
||||
|
||||
void FindCrossings(wxDiagram& diagram);
|
||||
void DrawCrossings(wxDiagram& diagram, wxDC& dc);
|
||||
void ClearCrossings();
|
||||
|
||||
public:
|
||||
wxList m_crossings;
|
||||
};
|
||||
|
||||
#endif
|
||||
// _OGL_OGLDIAG_H_
|
39
samples/ogl/ogledit/Makefile
Normal file
@@ -0,0 +1,39 @@
|
||||
#
|
||||
# File: Makefile
|
||||
# Author: Julian Smart
|
||||
# Created: 1999
|
||||
# Updated:
|
||||
# Copyright: (c) 2000 Julian Smart
|
||||
#
|
||||
# Makefile for OGL demo (GTK version)
|
||||
#
|
||||
# This makefile requires wxWindows/GTK to be
|
||||
# installed (possibly using "make install")
|
||||
# on your system.
|
||||
#
|
||||
|
||||
CPP = gcc
|
||||
CC = gcc
|
||||
WXCONFIG=../../../../wx-config
|
||||
WXINCLUDE=-I../../../../include
|
||||
WXLIB=-L../../../../lib
|
||||
|
||||
OBJECTS=ogledit.o palette.o doc.o view.o
|
||||
|
||||
ogledit: $(OBJECTS)
|
||||
$(CPP) -o ogledit $(OBJECTS) `$(WXCONFIG) --libs` $(WXLIB) -logl
|
||||
|
||||
ogledit.o: ogledit.cpp
|
||||
$(CPP) `$(WXCONFIG) --cflags` -I../../src $(WXINCLUDE) -c ogledit.cpp
|
||||
|
||||
palette.o: palette.cpp
|
||||
$(CPP) `$(WXCONFIG) --cflags` -I../../src $(WXINCLUDE) -c palette.cpp
|
||||
|
||||
doc.o: doc.cpp
|
||||
$(CPP) `$(WXCONFIG) --cflags` -I../../src $(WXINCLUDE) -c doc.cpp
|
||||
|
||||
view.o: view.cpp
|
||||
$(CPP) `$(WXCONFIG) --cflags` -I../../src $(WXINCLUDE) -c view.cpp
|
||||
|
||||
clean:
|
||||
rm -f *.o ogledit
|
BIN
samples/ogl/ogledit/bitmaps/arrow.bmp
Normal file
After Width: | Height: | Size: 382 B |
44
samples/ogl/ogledit/bitmaps/arrow.xpm
Normal file
@@ -0,0 +1,44 @@
|
||||
/* XPM */
|
||||
static char *arrow_xpm[] = {
|
||||
/* columns rows colors chars-per-pixel */
|
||||
"22 22 16 1",
|
||||
" c Gray0",
|
||||
". c #bf0000",
|
||||
"X c #00bf00",
|
||||
"o c #bfbf00",
|
||||
"O c #0000bf",
|
||||
"+ c #bf00bf",
|
||||
"@ c #00bfbf",
|
||||
"# c #c0c0c0",
|
||||
"$ c #808080",
|
||||
"% c Red",
|
||||
"& c Green",
|
||||
"* c Yellow",
|
||||
"= c Blue",
|
||||
"- c Magenta",
|
||||
"; c Cyan",
|
||||
": c Gray100",
|
||||
/* pixels */
|
||||
"######################",
|
||||
"######################",
|
||||
"######################",
|
||||
"######################",
|
||||
"######################",
|
||||
"####### ##############",
|
||||
"####### #############",
|
||||
"####### ############",
|
||||
"####### ###########",
|
||||
"####### ##########",
|
||||
"####### #########",
|
||||
"####### ########",
|
||||
"####### #######",
|
||||
"####### ##########",
|
||||
"####### # ##########",
|
||||
"####### ### #########",
|
||||
"########### #########",
|
||||
"############ ########",
|
||||
"############ ########",
|
||||
"######################",
|
||||
"######################",
|
||||
"######################"
|
||||
};
|
BIN
samples/ogl/ogledit/bitmaps/tool1.bmp
Normal file
After Width: | Height: | Size: 382 B |
44
samples/ogl/ogledit/bitmaps/tool1.xpm
Normal file
@@ -0,0 +1,44 @@
|
||||
/* XPM */
|
||||
static char *tool1_xpm[] = {
|
||||
/* columns rows colors chars-per-pixel */
|
||||
"22 22 16 1",
|
||||
" c Gray0",
|
||||
". c #bf0000",
|
||||
"X c #00bf00",
|
||||
"o c #bfbf00",
|
||||
"O c #0000bf",
|
||||
"+ c #bf00bf",
|
||||
"@ c #00bfbf",
|
||||
"# c #c0c0c0",
|
||||
"$ c #808080",
|
||||
"% c Red",
|
||||
"& c Green",
|
||||
"* c Yellow",
|
||||
"= c Blue",
|
||||
"- c Magenta",
|
||||
"; c Cyan",
|
||||
": c Gray100",
|
||||
/* pixels */
|
||||
"######################",
|
||||
"######################",
|
||||
"# ##",
|
||||
"# ::::::::::::::::: ##",
|
||||
"# ::::::::::::::::: ##",
|
||||
"# ::::::::::::::::: ##",
|
||||
"# ::::::::::::::::: ##",
|
||||
"# ::::::::::::::::: ##",
|
||||
"# ::::::::::::::::: ##",
|
||||
"# ::::::::::::::::: ##",
|
||||
"# ::::::::::::::::: ##",
|
||||
"# ::::::::::::::::: ##",
|
||||
"# ::::::::::::::::: ##",
|
||||
"# ::::::::::::::::: ##",
|
||||
"# ::::::::::::::::: ##",
|
||||
"# ::::::::::::::::: ##",
|
||||
"# ::::::::::::::::: ##",
|
||||
"# ::::::::::::::::: ##",
|
||||
"# ##",
|
||||
"######################",
|
||||
"######################",
|
||||
"######################"
|
||||
};
|
BIN
samples/ogl/ogledit/bitmaps/tool2.bmp
Normal file
After Width: | Height: | Size: 382 B |
44
samples/ogl/ogledit/bitmaps/tool2.xpm
Normal file
@@ -0,0 +1,44 @@
|
||||
/* XPM */
|
||||
static char *tool2_xpm[] = {
|
||||
/* columns rows colors chars-per-pixel */
|
||||
"22 22 16 1",
|
||||
" c Gray0",
|
||||
". c #bf0000",
|
||||
"X c #00bf00",
|
||||
"o c #bfbf00",
|
||||
"O c #0000bf",
|
||||
"+ c #bf00bf",
|
||||
"@ c #00bfbf",
|
||||
"# c #c0c0c0",
|
||||
"$ c #808080",
|
||||
"% c Red",
|
||||
"& c Green",
|
||||
"* c Yellow",
|
||||
"= c Blue",
|
||||
"- c Magenta",
|
||||
"; c Cyan",
|
||||
": c Gray100",
|
||||
/* pixels */
|
||||
"######################",
|
||||
"######################",
|
||||
"#### #####",
|
||||
"### ::::::::::::: ####",
|
||||
"## ::::::::::::::: ###",
|
||||
"# ::::::::::::::::: ##",
|
||||
"# ::::::::::::::::: ##",
|
||||
"# ::::::::::::::::: ##",
|
||||
"# ::::::::::::::::: ##",
|
||||
"# ::::::::::::::::: ##",
|
||||
"# ::::::::::::::::: ##",
|
||||
"# ::::::::::::::::: ##",
|
||||
"# ::::::::::::::::: ##",
|
||||
"# ::::::::::::::::: ##",
|
||||
"# ::::::::::::::::: ##",
|
||||
"# ::::::::::::::::: ##",
|
||||
"## ::::::::::::::: ###",
|
||||
"### ::::::::::::: ####",
|
||||
"#### #####",
|
||||
"######################",
|
||||
"######################",
|
||||
"######################"
|
||||
};
|
BIN
samples/ogl/ogledit/bitmaps/tool3.bmp
Normal file
After Width: | Height: | Size: 382 B |
44
samples/ogl/ogledit/bitmaps/tool3.xpm
Normal file
@@ -0,0 +1,44 @@
|
||||
/* XPM */
|
||||
static char *tool3_xpm[] = {
|
||||
/* columns rows colors chars-per-pixel */
|
||||
"22 22 16 1",
|
||||
" c Gray0",
|
||||
". c #bf0000",
|
||||
"X c #00bf00",
|
||||
"o c #bfbf00",
|
||||
"O c #0000bf",
|
||||
"+ c #bf00bf",
|
||||
"@ c #00bfbf",
|
||||
"# c #c0c0c0",
|
||||
"$ c #808080",
|
||||
"% c Red",
|
||||
"& c Green",
|
||||
"* c Yellow",
|
||||
"= c Blue",
|
||||
"- c Magenta",
|
||||
"; c Cyan",
|
||||
": c Gray100",
|
||||
/* pixels */
|
||||
"######################",
|
||||
"######################",
|
||||
"######################",
|
||||
"######################",
|
||||
"####### ########",
|
||||
"#### ::::::: #####",
|
||||
"### ::::::::::::: ####",
|
||||
"## ::::::::::::::: ###",
|
||||
"# ::::::::::::::::: ##",
|
||||
"# ::::::::::::::::: ##",
|
||||
"# ::::::::::::::::: ##",
|
||||
"# ::::::::::::::::: ##",
|
||||
"## ::::::::::::::: ###",
|
||||
"### ::::::::::::: ####",
|
||||
"#### ::::::: #####",
|
||||
"###### ########",
|
||||
"######################",
|
||||
"######################",
|
||||
"######################",
|
||||
"######################",
|
||||
"######################",
|
||||
"######################"
|
||||
};
|
BIN
samples/ogl/ogledit/bitmaps/tool4.bmp
Normal file
After Width: | Height: | Size: 382 B |
44
samples/ogl/ogledit/bitmaps/tool4.xpm
Normal file
@@ -0,0 +1,44 @@
|
||||
/* XPM */
|
||||
static char *tool4_xpm[] = {
|
||||
/* columns rows colors chars-per-pixel */
|
||||
"22 22 16 1",
|
||||
" c Gray0",
|
||||
". c #bf0000",
|
||||
"X c #00bf00",
|
||||
"o c #bfbf00",
|
||||
"O c #0000bf",
|
||||
"+ c #bf00bf",
|
||||
"@ c #00bfbf",
|
||||
"# c #c0c0c0",
|
||||
"$ c #808080",
|
||||
"% c Red",
|
||||
"& c Green",
|
||||
"* c Yellow",
|
||||
"= c Blue",
|
||||
"- c Magenta",
|
||||
"; c Cyan",
|
||||
": c Gray100",
|
||||
/* pixels */
|
||||
"######################",
|
||||
"######################",
|
||||
"######################",
|
||||
"########## ##########",
|
||||
"######### :: #########",
|
||||
"######## :::: ########",
|
||||
"####### :::::: #######",
|
||||
"###### :::::::: ######",
|
||||
"##### :::::::::: #####",
|
||||
"#### :::::::::::: ####",
|
||||
"### :::::::::::::: ###",
|
||||
"### :::::::::::::: ###",
|
||||
"#### :::::::::::: ####",
|
||||
"##### :::::::::: #####",
|
||||
"###### :::::::: ######",
|
||||
"####### :::::: #######",
|
||||
"######## :::: ########",
|
||||
"######### :: #########",
|
||||
"########## ##########",
|
||||
"######################",
|
||||
"######################",
|
||||
"######################"
|
||||
};
|
611
samples/ogl/ogledit/doc.cpp
Normal file
@@ -0,0 +1,611 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: doc.cpp
|
||||
// Purpose: Implements document functionality in OGLEdit
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 12/07/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
// #pragma implementation
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include <wx/wxprec.h>
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include <wx/wx.h>
|
||||
#endif
|
||||
|
||||
#if !wxUSE_DOC_VIEW_ARCHITECTURE
|
||||
#error You must set wxUSE_DOC_VIEW_ARCHITECTURE to 1 in wx_setup.h!
|
||||
#endif
|
||||
|
||||
#include <wx/wxexpr.h>
|
||||
#include "ogledit.h"
|
||||
#include "doc.h"
|
||||
#include "view.h"
|
||||
|
||||
#if wxUSE_STD_IOSTREAM
|
||||
#include <iostream.h>
|
||||
#endif
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(DiagramDocument, wxDocument)
|
||||
|
||||
DiagramDocument::DiagramDocument(void)
|
||||
{
|
||||
}
|
||||
|
||||
DiagramDocument::~DiagramDocument(void)
|
||||
{
|
||||
}
|
||||
|
||||
bool DiagramDocument::OnCloseDocument(void)
|
||||
{
|
||||
diagram.DeleteAllShapes();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#if wxUSE_STD_IOSTREAM
|
||||
ostream& DiagramDocument::SaveObject(ostream& stream)
|
||||
{
|
||||
wxDocument::SaveObject(stream);
|
||||
|
||||
char buf[400];
|
||||
(void) wxGetTempFileName("diag", buf);
|
||||
|
||||
diagram.SaveFile(buf);
|
||||
wxTransferFileToStream(buf, stream);
|
||||
|
||||
wxRemoveFile(buf);
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
istream& DiagramDocument::LoadObject(istream& stream)
|
||||
{
|
||||
wxDocument::LoadObject(stream);
|
||||
|
||||
char buf[400];
|
||||
(void) wxGetTempFileName("diag", buf);
|
||||
|
||||
wxTransferStreamToFile(stream, buf);
|
||||
|
||||
diagram.DeleteAllShapes();
|
||||
diagram.LoadFile(buf);
|
||||
wxRemoveFile(buf);
|
||||
|
||||
return stream;
|
||||
}
|
||||
#else
|
||||
|
||||
wxOutputStream& DiagramDocument::SaveObject(wxOutputStream& stream)
|
||||
{
|
||||
wxDocument::SaveObject(stream);
|
||||
char buf[400];
|
||||
(void) wxGetTempFileName("diag", buf);
|
||||
|
||||
diagram.SaveFile(buf);
|
||||
|
||||
wxTransferFileToStream(buf, stream);
|
||||
|
||||
wxRemoveFile(buf);
|
||||
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
wxInputStream& DiagramDocument::LoadObject(wxInputStream& stream)
|
||||
{
|
||||
wxDocument::LoadObject(stream);
|
||||
|
||||
|
||||
char buf[400];
|
||||
(void) wxGetTempFileName("diag", buf);
|
||||
|
||||
wxTransferStreamToFile(stream, buf);
|
||||
|
||||
diagram.DeleteAllShapes();
|
||||
diagram.LoadFile(buf);
|
||||
wxRemoveFile(buf);
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Implementation of drawing command
|
||||
*/
|
||||
|
||||
DiagramCommand::DiagramCommand(char *name, int command, DiagramDocument *ddoc, wxClassInfo *info, double xx, double yy,
|
||||
bool sel, wxShape *theShape, wxShape *fs, wxShape *ts):
|
||||
wxCommand(TRUE, name)
|
||||
{
|
||||
doc = ddoc;
|
||||
cmd = command;
|
||||
shape = theShape;
|
||||
fromShape = fs;
|
||||
toShape = ts;
|
||||
shapeInfo = info;
|
||||
shapeBrush = NULL;
|
||||
shapePen = NULL;
|
||||
x = xx;
|
||||
y = yy;
|
||||
selected = sel;
|
||||
deleteShape = FALSE;
|
||||
}
|
||||
|
||||
DiagramCommand::DiagramCommand(char *name, int command, DiagramDocument *ddoc, wxBrush *backgroundColour, wxShape *theShape):
|
||||
wxCommand(TRUE, name)
|
||||
{
|
||||
doc = ddoc;
|
||||
cmd = command;
|
||||
shape = theShape;
|
||||
fromShape = NULL;
|
||||
toShape = NULL;
|
||||
shapeInfo = NULL;
|
||||
x = 0.0;
|
||||
y = 0.0;
|
||||
selected = FALSE;
|
||||
deleteShape = FALSE;
|
||||
shapeBrush = backgroundColour;
|
||||
shapePen = NULL;
|
||||
}
|
||||
|
||||
DiagramCommand::DiagramCommand(char *name, int command, DiagramDocument *ddoc, const wxString& lab, wxShape *theShape):
|
||||
wxCommand(TRUE, name)
|
||||
{
|
||||
doc = ddoc;
|
||||
cmd = command;
|
||||
shape = theShape;
|
||||
fromShape = NULL;
|
||||
toShape = NULL;
|
||||
shapeInfo = NULL;
|
||||
x = 0.0;
|
||||
y = 0.0;
|
||||
selected = FALSE;
|
||||
deleteShape = FALSE;
|
||||
shapeBrush = NULL;
|
||||
shapePen = NULL;
|
||||
shapeLabel = lab;
|
||||
}
|
||||
|
||||
DiagramCommand::~DiagramCommand(void)
|
||||
{
|
||||
if (shape && deleteShape)
|
||||
{
|
||||
shape->SetCanvas(NULL);
|
||||
delete shape;
|
||||
}
|
||||
}
|
||||
|
||||
bool DiagramCommand::Do(void)
|
||||
{
|
||||
switch (cmd)
|
||||
{
|
||||
case OGLEDIT_CUT:
|
||||
{
|
||||
if (shape)
|
||||
{
|
||||
deleteShape = TRUE;
|
||||
|
||||
shape->Select(FALSE);
|
||||
|
||||
// Generate commands to explicitly remove each connected line.
|
||||
RemoveLines(shape);
|
||||
|
||||
doc->GetDiagram()->RemoveShape(shape);
|
||||
if (shape->IsKindOf(CLASSINFO(wxLineShape)))
|
||||
{
|
||||
wxLineShape *lineShape = (wxLineShape *)shape;
|
||||
fromShape = lineShape->GetFrom();
|
||||
toShape = lineShape->GetTo();
|
||||
}
|
||||
shape->Unlink();
|
||||
|
||||
doc->Modify(TRUE);
|
||||
doc->UpdateAllViews();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case OGLEDIT_ADD_SHAPE:
|
||||
{
|
||||
wxShape *theShape = NULL;
|
||||
if (shape)
|
||||
theShape = shape; // Saved from undoing the shape
|
||||
else
|
||||
{
|
||||
theShape = (wxShape *)shapeInfo->CreateObject();
|
||||
theShape->AssignNewIds();
|
||||
theShape->SetEventHandler(new MyEvtHandler(theShape, theShape, wxString("")));
|
||||
theShape->SetCentreResize(FALSE);
|
||||
theShape->SetPen(wxBLACK_PEN);
|
||||
theShape->SetBrush(wxCYAN_BRUSH);
|
||||
|
||||
theShape->SetSize(60, 60);
|
||||
}
|
||||
doc->GetDiagram()->AddShape(theShape);
|
||||
theShape->Show(TRUE);
|
||||
|
||||
wxClientDC dc(theShape->GetCanvas());
|
||||
theShape->GetCanvas()->PrepareDC(dc);
|
||||
|
||||
theShape->Move(dc, x, y);
|
||||
|
||||
shape = theShape;
|
||||
deleteShape = FALSE;
|
||||
|
||||
doc->Modify(TRUE);
|
||||
doc->UpdateAllViews();
|
||||
break;
|
||||
}
|
||||
case OGLEDIT_ADD_LINE:
|
||||
{
|
||||
wxShape *theShape = NULL;
|
||||
if (shape)
|
||||
theShape = shape; // Saved from undoing the line
|
||||
else
|
||||
{
|
||||
theShape = (wxShape *)shapeInfo->CreateObject();
|
||||
theShape->AssignNewIds();
|
||||
theShape->SetEventHandler(new MyEvtHandler(theShape, theShape, wxString("")));
|
||||
theShape->SetPen(wxBLACK_PEN);
|
||||
theShape->SetBrush(wxRED_BRUSH);
|
||||
|
||||
wxLineShape *lineShape = (wxLineShape *)theShape;
|
||||
|
||||
// Yes, you can have more than 2 control points, in which case
|
||||
// it becomes a multi-segment line.
|
||||
lineShape->MakeLineControlPoints(2);
|
||||
lineShape->AddArrow(ARROW_ARROW, ARROW_POSITION_END, 10.0, 0.0, "Normal arrowhead");
|
||||
}
|
||||
|
||||
doc->GetDiagram()->AddShape(theShape);
|
||||
|
||||
fromShape->AddLine((wxLineShape *)theShape, toShape);
|
||||
|
||||
theShape->Show(TRUE);
|
||||
|
||||
wxClientDC dc(theShape->GetCanvas());
|
||||
theShape->GetCanvas()->PrepareDC(dc);
|
||||
|
||||
// It won't get drawn properly unless you move both
|
||||
// connected images
|
||||
fromShape->Move(dc, fromShape->GetX(), fromShape->GetY());
|
||||
toShape->Move(dc, toShape->GetX(), toShape->GetY());
|
||||
|
||||
shape = theShape;
|
||||
deleteShape = FALSE;
|
||||
|
||||
doc->Modify(TRUE);
|
||||
doc->UpdateAllViews();
|
||||
break;
|
||||
}
|
||||
case OGLEDIT_CHANGE_BACKGROUND_COLOUR:
|
||||
{
|
||||
if (shape)
|
||||
{
|
||||
wxClientDC dc(shape->GetCanvas());
|
||||
shape->GetCanvas()->PrepareDC(dc);
|
||||
|
||||
wxBrush *oldBrush = shape->GetBrush();
|
||||
shape->SetBrush(shapeBrush);
|
||||
shapeBrush = oldBrush;
|
||||
shape->Draw(dc);
|
||||
|
||||
doc->Modify(TRUE);
|
||||
doc->UpdateAllViews();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case OGLEDIT_EDIT_LABEL:
|
||||
{
|
||||
if (shape)
|
||||
{
|
||||
MyEvtHandler *myHandler = (MyEvtHandler *)shape->GetEventHandler();
|
||||
wxString oldLabel(myHandler->label);
|
||||
myHandler->label = shapeLabel;
|
||||
shapeLabel = oldLabel;
|
||||
|
||||
wxClientDC dc(shape->GetCanvas());
|
||||
shape->GetCanvas()->PrepareDC(dc);
|
||||
|
||||
shape->FormatText(dc, (char*) (const char*) myHandler->label);
|
||||
shape->Draw(dc);
|
||||
|
||||
doc->Modify(TRUE);
|
||||
doc->UpdateAllViews();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool DiagramCommand::Undo(void)
|
||||
{
|
||||
switch (cmd)
|
||||
{
|
||||
case OGLEDIT_CUT:
|
||||
{
|
||||
if (shape)
|
||||
{
|
||||
doc->GetDiagram()->AddShape(shape);
|
||||
shape->Show(TRUE);
|
||||
|
||||
if (shape->IsKindOf(CLASSINFO(wxLineShape)))
|
||||
{
|
||||
wxLineShape *lineShape = (wxLineShape *)shape;
|
||||
|
||||
fromShape->AddLine(lineShape, toShape);
|
||||
}
|
||||
if (selected)
|
||||
shape->Select(TRUE);
|
||||
|
||||
deleteShape = FALSE;
|
||||
}
|
||||
doc->Modify(TRUE);
|
||||
doc->UpdateAllViews();
|
||||
break;
|
||||
}
|
||||
case OGLEDIT_ADD_SHAPE:
|
||||
case OGLEDIT_ADD_LINE:
|
||||
{
|
||||
if (shape)
|
||||
{
|
||||
wxClientDC dc(shape->GetCanvas());
|
||||
shape->GetCanvas()->PrepareDC(dc);
|
||||
|
||||
shape->Select(FALSE, &dc);
|
||||
doc->GetDiagram()->RemoveShape(shape);
|
||||
shape->Unlink();
|
||||
deleteShape = TRUE;
|
||||
}
|
||||
doc->Modify(TRUE);
|
||||
doc->UpdateAllViews();
|
||||
break;
|
||||
}
|
||||
case OGLEDIT_CHANGE_BACKGROUND_COLOUR:
|
||||
{
|
||||
if (shape)
|
||||
{
|
||||
wxClientDC dc(shape->GetCanvas());
|
||||
shape->GetCanvas()->PrepareDC(dc);
|
||||
|
||||
wxBrush *oldBrush = shape->GetBrush();
|
||||
shape->SetBrush(shapeBrush);
|
||||
shapeBrush = oldBrush;
|
||||
shape->Draw(dc);
|
||||
|
||||
doc->Modify(TRUE);
|
||||
doc->UpdateAllViews();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case OGLEDIT_EDIT_LABEL:
|
||||
{
|
||||
if (shape)
|
||||
{
|
||||
MyEvtHandler *myHandler = (MyEvtHandler *)shape->GetEventHandler();
|
||||
wxString oldLabel(myHandler->label);
|
||||
myHandler->label = shapeLabel;
|
||||
shapeLabel = oldLabel;
|
||||
|
||||
wxClientDC dc(shape->GetCanvas());
|
||||
shape->GetCanvas()->PrepareDC(dc);
|
||||
|
||||
shape->FormatText(dc, (char*) (const char*) myHandler->label);
|
||||
shape->Draw(dc);
|
||||
|
||||
doc->Modify(TRUE);
|
||||
doc->UpdateAllViews();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Remove each individual line connected to a shape by sending a command.
|
||||
void DiagramCommand::RemoveLines(wxShape *shape)
|
||||
{
|
||||
wxNode *node = shape->GetLines().First();
|
||||
while (node)
|
||||
{
|
||||
wxLineShape *line = (wxLineShape *)node->Data();
|
||||
doc->GetCommandProcessor()->Submit(new DiagramCommand("Cut", OGLEDIT_CUT, doc, NULL, 0.0, 0.0, line->Selected(), line));
|
||||
|
||||
node = shape->GetLines().First();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* MyEvtHandler: an event handler class for all shapes
|
||||
*/
|
||||
|
||||
void MyEvtHandler::OnLeftClick(double x, double y, int keys, int attachment)
|
||||
{
|
||||
wxClientDC dc(GetShape()->GetCanvas());
|
||||
GetShape()->GetCanvas()->PrepareDC(dc);
|
||||
|
||||
if (keys == 0)
|
||||
{
|
||||
// Selection is a concept the library knows about
|
||||
if (GetShape()->Selected())
|
||||
{
|
||||
GetShape()->Select(FALSE, &dc);
|
||||
GetShape()->GetCanvas()->Redraw(dc); // Redraw because bits of objects will be are missing
|
||||
}
|
||||
else
|
||||
{
|
||||
// Ensure no other shape is selected, to simplify Undo/Redo code
|
||||
bool redraw = FALSE;
|
||||
wxNode *node = GetShape()->GetCanvas()->GetDiagram()->GetShapeList()->First();
|
||||
while (node)
|
||||
{
|
||||
wxShape *eachShape = (wxShape *)node->Data();
|
||||
if (eachShape->GetParent() == NULL)
|
||||
{
|
||||
if (eachShape->Selected())
|
||||
{
|
||||
eachShape->Select(FALSE, &dc);
|
||||
redraw = TRUE;
|
||||
}
|
||||
}
|
||||
node = node->Next();
|
||||
}
|
||||
GetShape()->Select(TRUE, &dc);
|
||||
if (redraw)
|
||||
GetShape()->GetCanvas()->Redraw(dc);
|
||||
}
|
||||
}
|
||||
else if (keys & KEY_CTRL)
|
||||
{
|
||||
// Do something for CONTROL
|
||||
}
|
||||
else
|
||||
{
|
||||
wxGetApp().frame->SetStatusText(label);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Implement connection of two shapes by right-dragging between them.
|
||||
*/
|
||||
|
||||
void MyEvtHandler::OnBeginDragRight(double x, double y, int keys, int attachment)
|
||||
{
|
||||
// Force attachment to be zero for now. Eventually we can deal with
|
||||
// the actual attachment point, e.g. a rectangle side if attachment mode is on.
|
||||
attachment = 0;
|
||||
|
||||
wxClientDC dc(GetShape()->GetCanvas());
|
||||
GetShape()->GetCanvas()->PrepareDC(dc);
|
||||
|
||||
wxPen dottedPen(wxColour(0, 0, 0), 1, wxDOT);
|
||||
dc.SetLogicalFunction(OGLRBLF);
|
||||
dc.SetPen(dottedPen);
|
||||
double xp, yp;
|
||||
GetShape()->GetAttachmentPosition(attachment, &xp, &yp);
|
||||
dc.DrawLine((long) xp, (long) yp, (long) x, (long) y);
|
||||
GetShape()->GetCanvas()->CaptureMouse();
|
||||
}
|
||||
|
||||
void MyEvtHandler::OnDragRight(bool draw, double x, double y, int keys, int attachment)
|
||||
{
|
||||
// Force attachment to be zero for now
|
||||
attachment = 0;
|
||||
|
||||
wxClientDC dc(GetShape()->GetCanvas());
|
||||
GetShape()->GetCanvas()->PrepareDC(dc);
|
||||
|
||||
wxPen dottedPen(wxColour(0, 0, 0), 1, wxDOT);
|
||||
dc.SetLogicalFunction(OGLRBLF);
|
||||
dc.SetPen(dottedPen);
|
||||
double xp, yp;
|
||||
GetShape()->GetAttachmentPosition(attachment, &xp, &yp);
|
||||
dc.DrawLine((long) xp, (long) yp, (long) x, (long) y);
|
||||
}
|
||||
|
||||
void MyEvtHandler::OnEndDragRight(double x, double y, int keys, int attachment)
|
||||
{
|
||||
GetShape()->GetCanvas()->ReleaseMouse();
|
||||
MyCanvas *canvas = (MyCanvas *)GetShape()->GetCanvas();
|
||||
|
||||
// Check if we're on an object
|
||||
int new_attachment;
|
||||
wxShape *otherShape = canvas->FindFirstSensitiveShape(x, y, &new_attachment, OP_DRAG_RIGHT);
|
||||
|
||||
if (otherShape && !otherShape->IsKindOf(CLASSINFO(wxLineShape)))
|
||||
{
|
||||
canvas->view->GetDocument()->GetCommandProcessor()->Submit(
|
||||
new DiagramCommand("wxLineShape", OGLEDIT_ADD_LINE, (DiagramDocument *)canvas->view->GetDocument(), CLASSINFO(wxLineShape),
|
||||
0.0, 0.0, FALSE, NULL, GetShape(), otherShape));
|
||||
}
|
||||
}
|
||||
|
||||
void MyEvtHandler::OnEndSize(double x, double y)
|
||||
{
|
||||
wxClientDC dc(GetShape()->GetCanvas());
|
||||
GetShape()->GetCanvas()->PrepareDC(dc);
|
||||
|
||||
GetShape()->FormatText(dc, (char*) (const char*) label);
|
||||
}
|
||||
|
||||
/*
|
||||
* Diagram
|
||||
*/
|
||||
|
||||
bool MyDiagram::OnShapeSave(wxExprDatabase& db, wxShape& shape, wxExpr& expr)
|
||||
{
|
||||
wxDiagram::OnShapeSave(db, shape, expr);
|
||||
MyEvtHandler *handler = (MyEvtHandler *)shape.GetEventHandler();
|
||||
expr.AddAttributeValueString("label", handler->label);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool MyDiagram::OnShapeLoad(wxExprDatabase& db, wxShape& shape, wxExpr& expr)
|
||||
{
|
||||
wxDiagram::OnShapeLoad(db, shape, expr);
|
||||
char *label = NULL;
|
||||
expr.AssignAttributeValue("label", &label);
|
||||
MyEvtHandler *handler = new MyEvtHandler(&shape, &shape, wxString(label));
|
||||
shape.SetEventHandler(handler);
|
||||
|
||||
if (label)
|
||||
delete[] label;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* New shapes
|
||||
*/
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxRoundedRectangleShape, wxRectangleShape)
|
||||
|
||||
wxRoundedRectangleShape::wxRoundedRectangleShape(double w, double h):
|
||||
wxRectangleShape(w, h)
|
||||
{
|
||||
// 0.3 of the smaller rectangle dimension
|
||||
SetCornerRadius((double) -0.3);
|
||||
}
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxDiamondShape, wxPolygonShape)
|
||||
|
||||
wxDiamondShape::wxDiamondShape(double w, double h):
|
||||
wxPolygonShape()
|
||||
{
|
||||
// wxPolygonShape::SetSize relies on the shape having non-zero
|
||||
// size initially.
|
||||
if (w == 0.0)
|
||||
w = 60.0;
|
||||
if (h == 0.0)
|
||||
h = 60.0;
|
||||
|
||||
wxList *thePoints = new wxList;
|
||||
wxRealPoint *point = new wxRealPoint(0.0, (-h/2.0));
|
||||
thePoints->Append((wxObject*) point);
|
||||
|
||||
point = new wxRealPoint((w/2.0), 0.0);
|
||||
thePoints->Append((wxObject*) point);
|
||||
|
||||
point = new wxRealPoint(0.0, (h/2.0));
|
||||
thePoints->Append((wxObject*) point);
|
||||
|
||||
point = new wxRealPoint((-w/2.0), 0.0);
|
||||
thePoints->Append((wxObject*) point);
|
||||
|
||||
Create(thePoints);
|
||||
}
|
182
samples/ogl/ogledit/doc.h
Normal file
@@ -0,0 +1,182 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: doc.h
|
||||
// Purpose: Document classes
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 12/07/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _OGLSAMPLE_DOC_H_
|
||||
#define _OGLSAMPLE_DOC_H_
|
||||
|
||||
#ifdef __GNUG__
|
||||
// #pragma interface
|
||||
#endif
|
||||
|
||||
#include <wx/docview.h>
|
||||
#include <wx/string.h>
|
||||
#include <wx/wxexpr.h>
|
||||
|
||||
#include <wx/ogl/ogl.h>
|
||||
|
||||
#if wxUSE_STD_IOSTREAM
|
||||
class ostream;
|
||||
class istream;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Override a few members for this application
|
||||
*/
|
||||
|
||||
class MyDiagram: public wxDiagram
|
||||
{
|
||||
public:
|
||||
MyDiagram(void) {}
|
||||
bool OnShapeSave(wxExprDatabase& db, wxShape& shape, wxExpr& expr);
|
||||
bool OnShapeLoad(wxExprDatabase& db, wxShape& shape, wxExpr& expr);
|
||||
};
|
||||
|
||||
/*
|
||||
* A few new shape classes so we have a 1:1 mapping
|
||||
* between palette symbol and unique class
|
||||
*/
|
||||
|
||||
class wxRoundedRectangleShape: public wxRectangleShape
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxRoundedRectangleShape)
|
||||
private:
|
||||
public:
|
||||
wxRoundedRectangleShape(double w = 0.0, double h = 0.0);
|
||||
};
|
||||
|
||||
class wxDiamondShape: public wxPolygonShape
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxDiamondShape)
|
||||
private:
|
||||
public:
|
||||
wxDiamondShape(double w = 0.0, double h = 0.0);
|
||||
};
|
||||
|
||||
/*
|
||||
* All shape event behaviour is routed through this handler, so we don't
|
||||
* have to derive from each shape class. We plug this in to each shape.
|
||||
*/
|
||||
|
||||
class MyEvtHandler: public wxShapeEvtHandler
|
||||
{
|
||||
public:
|
||||
wxString label;
|
||||
MyEvtHandler(wxShapeEvtHandler *prev = NULL, wxShape *shape = NULL, const wxString& lab = ""):wxShapeEvtHandler(prev, shape)
|
||||
{
|
||||
label = lab;
|
||||
}
|
||||
~MyEvtHandler(void)
|
||||
{
|
||||
}
|
||||
void OnLeftClick(double x, double y, int keys = 0, int attachment = 0);
|
||||
void OnBeginDragRight(double x, double y, int keys = 0, int attachment = 0);
|
||||
void OnDragRight(bool draw, double x, double y, int keys = 0, int attachment = 0);
|
||||
void OnEndDragRight(double x, double y, int keys = 0, int attachment = 0);
|
||||
void OnEndSize(double x, double y);
|
||||
};
|
||||
|
||||
/*
|
||||
* A diagram document, which contains a diagram.
|
||||
*/
|
||||
|
||||
class DiagramDocument: public wxDocument
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(DiagramDocument)
|
||||
private:
|
||||
public:
|
||||
MyDiagram diagram;
|
||||
|
||||
DiagramDocument(void);
|
||||
~DiagramDocument(void);
|
||||
|
||||
#if wxUSE_STD_IOSTREAM
|
||||
virtual ostream& SaveObject(ostream& stream);
|
||||
virtual istream& LoadObject(istream& stream);
|
||||
#else
|
||||
virtual wxOutputStream& SaveObject(wxOutputStream& stream);
|
||||
virtual wxInputStream& LoadObject(wxInputStream& stream);
|
||||
#endif
|
||||
|
||||
inline wxDiagram *GetDiagram() { return &diagram; }
|
||||
|
||||
bool OnCloseDocument(void);
|
||||
};
|
||||
|
||||
/*
|
||||
* Most user interface commands are routed through this, to give us the
|
||||
* Undo/Redo mechanism. If you add more commands, such as changing the shape colour,
|
||||
* you will need to add members to 'remember' what the user applied (for 'Do') and what the
|
||||
* previous state was (for 'Undo').
|
||||
* You can have one member for each property to be changed. Assume we also have
|
||||
* a pointer member wxShape *shape, which is set to the shape being changed.
|
||||
* Let's assume we're changing the shape colour. Our member for this is shapeColour.
|
||||
*
|
||||
* - In 'Do':
|
||||
* o Set a temporary variable 'temp' to the current colour for 'shape'.
|
||||
* o Change the colour to the new colour.
|
||||
* o Set shapeColour to the _old_ colour, 'temp'.
|
||||
* - In 'Undo':
|
||||
* o Set a temporary variable 'temp' to the current colour for 'shape'.
|
||||
* o Change the colour to shapeColour (the old colour).
|
||||
* o Set shapeColour to 'temp'.
|
||||
*
|
||||
* So, as long as we have a pointer to the shape being changed,
|
||||
* we only need one member variable for each property.
|
||||
*
|
||||
* PROBLEM: when an Add shape command is redone, the 'shape' pointer changes.
|
||||
* Assume, as here, that we keep a pointer to the old shape so we reuse it
|
||||
* when we recreate.
|
||||
*/
|
||||
|
||||
class DiagramCommand: public wxCommand
|
||||
{
|
||||
protected:
|
||||
DiagramDocument *doc;
|
||||
int cmd;
|
||||
wxShape *shape; // Pointer to the shape we're acting on
|
||||
wxShape *fromShape;
|
||||
wxShape *toShape;
|
||||
wxClassInfo *shapeInfo;
|
||||
double x;
|
||||
double y;
|
||||
bool selected;
|
||||
bool deleteShape;
|
||||
|
||||
// Storage for property commands
|
||||
wxBrush *shapeBrush;
|
||||
wxPen *shapePen;
|
||||
wxString shapeLabel;
|
||||
public:
|
||||
// Multi-purpose constructor for creating, deleting shapes
|
||||
DiagramCommand(char *name, int cmd, DiagramDocument *ddoc, wxClassInfo *shapeInfo = NULL,
|
||||
double x = 0.0, double y = 0.0, bool sel = FALSE, wxShape *theShape = NULL, wxShape *fs = NULL, wxShape *ts = NULL);
|
||||
|
||||
// Property-changing command constructors
|
||||
DiagramCommand(char *name, int cmd, DiagramDocument *ddoc, wxBrush *backgroundColour, wxShape *theShape);
|
||||
DiagramCommand(char *name, int cmd, DiagramDocument *ddoc, const wxString& lab, wxShape *theShape);
|
||||
|
||||
~DiagramCommand(void);
|
||||
|
||||
bool Do(void);
|
||||
bool Undo(void);
|
||||
|
||||
inline void SetShape(wxShape *s) { shape = s; }
|
||||
inline wxShape *GetShape(void) { return shape; }
|
||||
inline wxShape *GetFromShape(void) { return fromShape; }
|
||||
inline wxShape *GetToShape(void) { return toShape; }
|
||||
inline wxClassInfo *GetShapeInfo(void) { return shapeInfo; }
|
||||
inline bool GetSelected(void) { return selected; }
|
||||
|
||||
void RemoveLines(wxShape *shape);
|
||||
};
|
||||
|
||||
#endif
|
||||
// _OGLSAMPLE_DOC_H_
|
18
samples/ogl/ogledit/makefile.b32
Normal file
@@ -0,0 +1,18 @@
|
||||
#
|
||||
# File: makefile.b32
|
||||
# Author: Julian Smart
|
||||
# Created: 1999
|
||||
# Updated:
|
||||
# Copyright:
|
||||
#
|
||||
# Makefile : Builds sample for 32-bit BC++
|
||||
|
||||
WXDIR = $(WXWIN)
|
||||
|
||||
TARGET=ogledit
|
||||
EXTRALIBS=$(WXDIR)\lib\ogl.lib
|
||||
EXTRACPPFLAGS=-I$(WXDIR)\utils\ogl\src
|
||||
OBJECTS = $(TARGET).obj doc.obj view.obj palette.obj
|
||||
|
||||
!include $(WXDIR)\src\makeprog.b32
|
||||
|
21
samples/ogl/ogledit/makefile.bcc
Normal file
@@ -0,0 +1,21 @@
|
||||
#
|
||||
# File: makefile.bcc
|
||||
# Author: Julian Smart
|
||||
# Created: 1998
|
||||
# Updated:
|
||||
#
|
||||
# Builds a BC++ 16-bit sample
|
||||
|
||||
!if "$(WXWIN)" == ""
|
||||
!error You must define the WXWIN variable in autoexec.bat, e.g. WXWIN=c:\wx
|
||||
!endif
|
||||
|
||||
WXDIR = $(WXWIN)
|
||||
|
||||
TARGET=ogledit
|
||||
EXTRALIBS=$(WXDIR)\lib\ogl.lib
|
||||
EXTRACPPFLAGS=-I$(WXDIR)\utils\ogl\src
|
||||
OBJECTS = $(TARGET).obj doc.obj view.obj palette.obj
|
||||
|
||||
!include $(WXDIR)\src\makeprog.b32
|
||||
|
103
samples/ogl/ogledit/makefile.dos
Normal file
@@ -0,0 +1,103 @@
|
||||
#
|
||||
# File: makefile.dos
|
||||
# Author: Julian Smart
|
||||
# Created: 1995
|
||||
# Updated:
|
||||
# Copyright: (c) 1995, AIAI, University of Edinburgh
|
||||
#
|
||||
# "%W% %G%"
|
||||
#
|
||||
# Makefile : Builds OGLEdit example (MSVC++ 1.5).
|
||||
# Use FINAL=1 argument to nmake to build final version with no debugging
|
||||
# info
|
||||
|
||||
WXDIR = $(WXWIN)
|
||||
|
||||
!include $(WXDIR)\src\makemsc.env
|
||||
|
||||
THISDIR = $(WXDIR)\utils\ogl\samples\ogledit
|
||||
WXLIB = $(WXDIR)\lib\wx.lib
|
||||
|
||||
OGLDIR = $(WXDIR)\utils\ogl
|
||||
OGLINC = $(OGLDIR)\src
|
||||
OGLLIB = $(OGLDIR)\lib\ogl.lib
|
||||
|
||||
LIBS=$(WXLIB) $(OGLLIB) oldnames libw llibcew commdlg shell ddeml
|
||||
|
||||
EXTRAFLAGS=/I$(OGLINC)
|
||||
|
||||
OBJECTS = ogledit.obj doc.obj view.obj palette.obj
|
||||
|
||||
all: ogledit.exe
|
||||
|
||||
wx:
|
||||
cd $(WXDIR)\src\msw
|
||||
nmake -f makefile.dos
|
||||
cd $(THISDIR)
|
||||
|
||||
wxclean:
|
||||
cd $(WXDIR)\src\msw
|
||||
nmake -f makefile.dos clean
|
||||
cd $(THISDIR)
|
||||
|
||||
ogl:
|
||||
cd $(OGLDIR)\src
|
||||
nmake -f makefile.dos FINAL=$(FINAL)
|
||||
cd $(THISDIR)
|
||||
|
||||
prologio:
|
||||
cd $(PROLOGDIR)\src
|
||||
nmake -f makefile.dos FINAL=$(FINAL)
|
||||
cd $(THISDIR)
|
||||
|
||||
ogledit.exe: $(WXDIR)\src\msw\dummy.obj $(WXLIB) $(OBJECTS) $(OGLLIB) ogledit.def ogledit.res
|
||||
link $(LINKFLAGS) @<<
|
||||
$(WXDIR)\src\msw\dummy.obj $(OBJECTS),
|
||||
ogledit,
|
||||
NUL,
|
||||
$(LIBS),
|
||||
ogledit.def
|
||||
;
|
||||
<<
|
||||
rc -30 -K ogledit.res
|
||||
|
||||
ogledit.obj: ogledit.h ogledit.$(SRCSUFF)
|
||||
cl @<<
|
||||
$(CPPFLAGS) /c /Tp $*.$(SRCSUFF)
|
||||
<<
|
||||
|
||||
view.obj: view.h view.$(SRCSUFF)
|
||||
cl @<<
|
||||
$(CPPFLAGS) /c /Tp $*.$(SRCSUFF)
|
||||
<<
|
||||
|
||||
doc.obj: doc.h doc.$(SRCSUFF)
|
||||
cl @<<
|
||||
$(CPPFLAGS) /c /Tp $*.$(SRCSUFF)
|
||||
<<
|
||||
|
||||
palette.obj: view.h doc.h ogledit.h palette.$(SRCSUFF) $(DUMMYOBJ)
|
||||
cl @<<
|
||||
$(CPPFLAGS) /c /Tp $*.$(SRCSUFF)
|
||||
<<
|
||||
|
||||
ogledit.res : ogledit.rc $(WXDIR)\include\msw\wx.rc
|
||||
rc -r /dFAFA_LIB /i$(WXDIR)\contrib\fafa /i$(WXDIR)\include\msw ogledit
|
||||
|
||||
clean:
|
||||
-erase *.obj
|
||||
-erase *.exe
|
||||
-erase *.res
|
||||
-erase *.map
|
||||
-erase *.sbr
|
||||
-erase *.pdb
|
||||
|
||||
cleanogl:
|
||||
cd $(OGLDIR)\src
|
||||
nmake -f makefile.dos clean
|
||||
cd $(THISDIR)
|
||||
|
||||
cleanall:
|
||||
cd $(OGLDIR)\src
|
||||
nmake -f makefile.dos clean
|
||||
cd $(THISDIR)
|
18
samples/ogl/ogledit/makefile.g95
Normal file
@@ -0,0 +1,18 @@
|
||||
#
|
||||
# File: makefile.g95
|
||||
# Author: Julian Smart
|
||||
# Created: 1999
|
||||
# Updated:
|
||||
# Copyright: (c) Julian Smart, 1999
|
||||
#
|
||||
# Makefile for wxWindows sample (Cygwin/Mingw32).
|
||||
|
||||
WXDIR = ../../../..
|
||||
|
||||
TARGET=ogledit
|
||||
EXTRACPPFLAGS=-I../../src
|
||||
EXTRALIBS=-logl
|
||||
OBJECTS = $(TARGET).o doc.o view.o palette.o
|
||||
|
||||
include $(WXDIR)/src/makeprog.g95
|
||||
|
33
samples/ogl/ogledit/makefile.sc
Normal file
@@ -0,0 +1,33 @@
|
||||
# Symantec C++ makefile for docview example
|
||||
# NOTE that peripheral libraries are now dealt in main wxWindows makefile.
|
||||
|
||||
WXDIR = $(WXWIN)
|
||||
include $(WXDIR)\src\makesc.env
|
||||
|
||||
WXLIB = $(WXDIR)\lib\wx.lib
|
||||
INCDIR = $(WXDIR)\include
|
||||
MSWINC = $(INCDIR)\msw
|
||||
BASEINC = $(INCDIR)\base
|
||||
|
||||
INCLUDE=$(BASEINC);$(MSWINC)
|
||||
|
||||
LIBS=$(WXLIB) libw.lib commdlg.lib shell.lib
|
||||
|
||||
OBJECTS=docview.obj view.obj doc.obj
|
||||
|
||||
.$(SRCSUFF).obj:
|
||||
*$(CC) -c $(CFLAGS) -I$(INCLUDE) $<
|
||||
|
||||
.rc.res:
|
||||
*$(RC) -r -I$(INCLUDE) $<
|
||||
|
||||
docview.exe: $(OBJECTS) docview.def docview.res
|
||||
*$(CC) $(LDFLAGS) -o$@ $(OBJECTS) docview.def $(LIBS)
|
||||
*$(RC) -k docview.res
|
||||
|
||||
clean:
|
||||
-del *.obj
|
||||
-del *.exe
|
||||
-del *.res
|
||||
-del *.map
|
||||
-del *.rws
|
20
samples/ogl/ogledit/makefile.unx
Normal file
@@ -0,0 +1,20 @@
|
||||
#
|
||||
# File: makefile.unx
|
||||
# Author: Julian Smart
|
||||
# Created: 1998
|
||||
# Updated:
|
||||
# Copyright: (c) 1998 Julian Smart
|
||||
#
|
||||
# "%W% %G%"
|
||||
#
|
||||
# Makefile for OGLEdit example (UNIX).
|
||||
|
||||
PROGRAM=ogledit
|
||||
|
||||
OBJECTS=$(PROGRAM).o doc.o view.o palette.o
|
||||
|
||||
EXTRACPPFLAGS=-I$(WXDIR)/utils/ogl/src
|
||||
EXTRALDLIBS=-logl$(GUISUFFIX)
|
||||
|
||||
include ../../../../src/makeprog.env
|
||||
|
95
samples/ogl/ogledit/makefile.vc
Normal file
@@ -0,0 +1,95 @@
|
||||
#
|
||||
# File: makefile.vc
|
||||
# Author: Julian Smart
|
||||
# Created: 1993
|
||||
# Updated:
|
||||
# Copyright: (c) 1993, AIAI, University of Edinburgh
|
||||
#
|
||||
# "%W% %G%"
|
||||
#
|
||||
# Makefile : Builds docview example (MS VC++).
|
||||
# Use FINAL=1 argument to nmake to build final version with no debugging
|
||||
# info
|
||||
|
||||
# Set WXDIR for your system
|
||||
WXDIR = $(WXWIN)
|
||||
|
||||
!include $(WXDIR)\src\makevc.env
|
||||
|
||||
THISDIR = $(WXDIR)\utils\ogl\samples\ogledit
|
||||
|
||||
OGLDIR = $(WXDIR)\utils\ogl
|
||||
OGLINC = $(OGLDIR)\src
|
||||
OGLLIB = $(WXDIR)\lib\ogl$(LIBEXT).lib
|
||||
|
||||
PROGRAM=ogledit
|
||||
|
||||
EXTRALIBS=$(OGLLIB)
|
||||
EXTRAINC=/I$(OGLINC)
|
||||
|
||||
OBJECTS = $(PROGRAM).obj doc.obj view.obj palette.obj
|
||||
|
||||
$(PROGRAM): $(PROGRAM).exe
|
||||
|
||||
all: $(PROGRAM).exe
|
||||
|
||||
wx:
|
||||
cd $(WXDIR)\src\msw
|
||||
nmake -f makefile.vc FINAL=$(FINAL)
|
||||
cd $(THISDIR)
|
||||
|
||||
wxclean:
|
||||
cd $(WXDIR)\src\msw
|
||||
nmake -f makefile.vc clean
|
||||
cd $(THISDIR)
|
||||
|
||||
ogl:
|
||||
cd $(OGLDIR)\src
|
||||
nmake -f makefile.vc FINAL=$(FINAL)
|
||||
cd $(THISDIR)
|
||||
|
||||
$(PROGRAM).exe: $(DUMMYOBJ) $(WXLIB) $(OBJECTS) $(OGLLIB) $(PROGRAM).res
|
||||
$(link) @<<
|
||||
-out:$(PROGRAM).exe
|
||||
$(LINKFLAGS)
|
||||
$(DUMMYOBJ) $(OBJECTS) $(PROGRAM).res
|
||||
$(LIBS)
|
||||
<<
|
||||
|
||||
$(PROGRAM).obj: $(PROGRAM).h doc.h view.h palette.h $(PROGRAM).$(SRCSUFF) $(DUMMYOBJ)
|
||||
$(cc) @<<
|
||||
$(CPPFLAGS) /c /Tp $*.$(SRCSUFF)
|
||||
<<
|
||||
|
||||
doc.obj: view.h doc.h doc.$(SRCSUFF) ogledit.h $(DUMMYOBJ)
|
||||
$(cc) @<<
|
||||
$(CPPFLAGS) /c /Tp $*.$(SRCSUFF)
|
||||
<<
|
||||
|
||||
view.obj: view.h doc.h view.$(SRCSUFF) ogledit.h $(DUMMYOBJ)
|
||||
$(cc) @<<
|
||||
$(CPPFLAGS) /c /Tp $*.$(SRCSUFF)
|
||||
<<
|
||||
|
||||
palette.obj: view.h doc.h ogledit.h palette.$(SRCSUFF) $(DUMMYOBJ)
|
||||
$(cc) @<<
|
||||
$(CPPFLAGS) /c /Tp $*.$(SRCSUFF)
|
||||
<<
|
||||
|
||||
$(PROGRAM).res : $(PROGRAM).rc $(WXDIR)\include\wx\msw\wx.rc ogl.ico
|
||||
$(rc) -r /i$(WXDIR)\include -fo$@ $(PROGRAM).rc
|
||||
|
||||
|
||||
cleanogl:
|
||||
cd $(OGLDIR)\src
|
||||
nmake -f makefile.vc clean
|
||||
cd $(THISDIR)
|
||||
|
||||
clean:
|
||||
-erase *.obj
|
||||
-erase *.sbr
|
||||
-erase *.exe
|
||||
-erase *.res
|
||||
-erase *.map
|
||||
-erase *.pdb
|
||||
|
44
samples/ogl/ogledit/makefile.vms
Normal file
@@ -0,0 +1,44 @@
|
||||
#************************************************************************
|
||||
# Makefile for DOCVIEW under VMS
|
||||
# by Stefan Hammes
|
||||
# (incomplete) update history:
|
||||
# 09.06.95
|
||||
#************************************************************************
|
||||
|
||||
#************************************************************************
|
||||
# Definition section
|
||||
# (cave: definitions and includes must begin with ',')
|
||||
#************************************************************************
|
||||
|
||||
APPOPTS =
|
||||
APPDEFS =
|
||||
APPINCS =
|
||||
|
||||
#************************************************************************
|
||||
# Module section
|
||||
#************************************************************************
|
||||
|
||||
# Name of main module
|
||||
MAIN = docview
|
||||
|
||||
# Object modules of the application.
|
||||
OBJS = docview.obj view.obj doc.obj
|
||||
OBJLIST =docview.obj,view.obj,doc.obj
|
||||
|
||||
.include [--.src]makevms.env
|
||||
|
||||
# main dependency
|
||||
$(MAIN).exe : $(OBJS)
|
||||
$(LINK) $(LINKFLAGS) /exec=$(MAIN).exe $(OBJLIST),$(WXLIB)/lib,$(OPTSFILE)/option
|
||||
- purge *.exe
|
||||
|
||||
#************************************************************************
|
||||
# Header file depedencies following
|
||||
#************************************************************************
|
||||
|
||||
docview.$(OBJSUFF) : docview.$(SRCSUFF) docview.h doc.h view.h
|
||||
|
||||
doc.$(OBJSUFF) : doc.$(SRCSUFF) doc.h
|
||||
|
||||
view.$(OBJSUFF) : view.$(SRCSUFF) view.h
|
||||
|
43
samples/ogl/ogledit/makefile.wat
Normal file
@@ -0,0 +1,43 @@
|
||||
#
|
||||
# Makefile for WATCOM
|
||||
#
|
||||
# Created by D.Chubraev, chubraev@iem.ee.ethz.ch
|
||||
# 8 Nov 1994
|
||||
#
|
||||
|
||||
WXDIR = ..\..
|
||||
|
||||
!include $(WXDIR)\src\makewat.env
|
||||
|
||||
WXLIB = $(WXDIR)\lib
|
||||
NAME = docview
|
||||
LNK = $(name).lnk
|
||||
OBJS = $(name).obj doc.obj view.obj
|
||||
|
||||
all: $(name).exe
|
||||
|
||||
$(name).exe : $(OBJS) $(name).res $(LNK) $(WXLIB)\wx$(LEVEL).lib
|
||||
wlink @$(LNK)
|
||||
$(BINDCOMMAND) $(name).res
|
||||
|
||||
$(name).res : $(name).rc $(WXDIR)\include\msw\wx.rc
|
||||
$(RC) $(RESFLAGS1) $(name).rc
|
||||
|
||||
$(LNK) : makefile.wat
|
||||
%create $(LNK)
|
||||
@%append $(LNK) debug all
|
||||
@%append $(LNK) system $(LINKOPTION)
|
||||
@%append $(LNK) $(MINDATA)
|
||||
@%append $(LNK) $(MAXDATA)
|
||||
@%append $(LNK) $(STACK)
|
||||
@%append $(LNK) name $(name)
|
||||
@%append $(LNK) file $(WXLIB)\wx$(LEVEL).lib
|
||||
@for %i in ($(EXTRALIBS)) do @%append $(LNK) file %i
|
||||
@for %i in ($(OBJS)) do @%append $(LNK) file %i
|
||||
|
||||
thing: .SYMBOLIC
|
||||
echo $(WATLIBDIR)
|
||||
|
||||
clean: .SYMBOLIC
|
||||
-erase *.obj *.bak *.err *.pch *.lib *.lnk *.res *.exe *.rex
|
||||
|
BIN
samples/ogl/ogledit/ogl.ico
Normal file
After Width: | Height: | Size: 766 B |
45
samples/ogl/ogledit/ogl.xpm
Normal file
@@ -0,0 +1,45 @@
|
||||
/* XPM */
|
||||
static char * ogl_xpm[] = {
|
||||
/* width height ncolors chars_per_pixel */
|
||||
"32 32 7 1",
|
||||
/* colors */
|
||||
" s None c None",
|
||||
". c #000000",
|
||||
"+ c #000080",
|
||||
"@ c #ff0000",
|
||||
"# c #00ff00",
|
||||
"$ c #00ffff",
|
||||
"% c #ffffff",
|
||||
/* pixels */
|
||||
"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
|
||||
"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
|
||||
"%............%%%%%%........%%%%%",
|
||||
"%.@@@@@@@@@@.%%%%..$$$$$$$$..%%%",
|
||||
"%.@@@@@@@@@@.%%%.$$$$$$$$$$$$.%%",
|
||||
"%.@@@@@@@@@@.+++.$$$$$$$$$$$$.%%",
|
||||
"%.@@@@@@@@@@.+++.$$$$$$$$$$$$.%%",
|
||||
"%.@@@@@@@@@@.%%%.$$$$$$$$$$$$.%%",
|
||||
"%.@@@@@@@@@@.%%%%..$$$$$$$$..%%%",
|
||||
"%............%%%%%.........%%%%%",
|
||||
"%%%%%%++%%%%%%%%%%%%%%++%%%%%%%%",
|
||||
"%%%%%%++%%%%%%%%%%%%%%++%%%%%%%%",
|
||||
"%%%%%%++%%%%%%%%%%%%%%++%%%%%%%%",
|
||||
"%%%%%%++%%%%%%%%%%%%%%++%%%%%%%%",
|
||||
"%%%%%%++%%%%%%%%%%%%%%++%%%%%%%%",
|
||||
"%%%%%%++%%%%%%%%%%%%%%++%%%%%%%%",
|
||||
"%%%%%%+.%%%%%%%%%%%%%%++%%%%%%%%",
|
||||
"%%%%%%.+.%%%%%%%%%%%%.++..%%%%%%",
|
||||
"%%%%%.+++.%%%%%%%%%..#####..%%%%",
|
||||
"%%%%.+++++.%%%%%%%.#########.%%%",
|
||||
"%%%.+++++++.%%%%%%.#########.%%%",
|
||||
"%%.+++++++++.%%%%.###########.%%",
|
||||
"%.+++++++++++.++++###########.%%",
|
||||
"%%.+++++++++.+++++###########.%%",
|
||||
"%%%.+++++++.%%%%%%.#########.%%%",
|
||||
"%%%%.+++++.%%%%%%%.#########.%%%",
|
||||
"%%%%%.+++.%%%%%%%%%..#####..%%%%",
|
||||
"%%%%%%.+.%%%%%%%%%%%%.....%%%%%%",
|
||||
"%%%%%%%.%%%%%%%%%%%%%%%%%%%%%%%%",
|
||||
"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
|
||||
"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
|
||||
"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"};
|
213
samples/ogl/ogledit/ogledit.cpp
Normal file
@@ -0,0 +1,213 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: ogledit.cpp
|
||||
// Purpose: OGLEdit sample app
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 12/07/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
// #pragma implementation
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include <wx/wxprec.h>
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include <wx/wx.h>
|
||||
#endif
|
||||
|
||||
#if !wxUSE_DOC_VIEW_ARCHITECTURE
|
||||
#error You must set wxUSE_DOC_VIEW_ARCHITECTURE to 1 in wx_setup.h!
|
||||
#endif
|
||||
|
||||
#include "ogledit.h"
|
||||
#include "palette.h"
|
||||
#include "doc.h"
|
||||
#include "view.h"
|
||||
|
||||
#if defined(__WXGTK__) || defined(__WXMOTIF__)
|
||||
#include "ogl.xpm"
|
||||
#endif
|
||||
|
||||
// A macro needed for some compilers (AIX) that need 'main' to be defined
|
||||
// in the application itself.
|
||||
IMPLEMENT_APP(MyApp)
|
||||
|
||||
MyApp::MyApp(void)
|
||||
{
|
||||
frame = NULL;
|
||||
myDocManager= NULL;
|
||||
}
|
||||
|
||||
// The `main program' equivalent, creating the windows and returning the
|
||||
// main frame
|
||||
bool MyApp::OnInit(void)
|
||||
{
|
||||
wxOGLInitialize();
|
||||
|
||||
//// Create a document manager
|
||||
myDocManager = new wxDocManager;
|
||||
|
||||
//// Create a template relating drawing documents to their views
|
||||
(void) new wxDocTemplate(myDocManager, "Diagram", "*.dia", "", "dia", "Diagram Doc", "Diagram View",
|
||||
CLASSINFO(DiagramDocument), CLASSINFO(DiagramView));
|
||||
|
||||
// If we've only got one window, we only get to edit
|
||||
// one document at a time.
|
||||
myDocManager->SetMaxDocsOpen(1);
|
||||
|
||||
//// Create the main frame window
|
||||
frame = new MyFrame(myDocManager, NULL, "OGLEdit Demo", wxPoint(0, 0), wxSize(500, 400), wxDEFAULT_FRAME_STYLE);
|
||||
|
||||
//// Give it an icon
|
||||
frame->SetIcon(wxICON(ogl));
|
||||
|
||||
//// Make a menubar
|
||||
wxMenu *file_menu = new wxMenu;
|
||||
wxMenu *edit_menu = NULL;
|
||||
|
||||
file_menu->Append(wxID_NEW, "&New...");
|
||||
file_menu->Append(wxID_OPEN, "&Open...");
|
||||
|
||||
file_menu->Append(wxID_CLOSE, "&Close");
|
||||
file_menu->Append(wxID_SAVE, "&Save");
|
||||
file_menu->Append(wxID_SAVEAS, "Save &As...");
|
||||
file_menu->AppendSeparator();
|
||||
file_menu->Append(wxID_PRINT, "&Print...");
|
||||
file_menu->Append(wxID_PRINT_SETUP, "Print &Setup...");
|
||||
file_menu->Append(wxID_PREVIEW, "Print Pre&view");
|
||||
|
||||
edit_menu = new wxMenu;
|
||||
edit_menu->Append(wxID_UNDO, "&Undo");
|
||||
edit_menu->Append(wxID_REDO, "&Redo");
|
||||
edit_menu->AppendSeparator();
|
||||
edit_menu->Append(OGLEDIT_CUT, "&Cut");
|
||||
edit_menu->AppendSeparator();
|
||||
edit_menu->Append(OGLEDIT_CHANGE_BACKGROUND_COLOUR, "Change &background colour");
|
||||
edit_menu->Append(OGLEDIT_EDIT_LABEL, "Edit &label");
|
||||
|
||||
frame->editMenu = edit_menu;
|
||||
|
||||
file_menu->AppendSeparator();
|
||||
file_menu->Append(wxID_EXIT, "E&xit");
|
||||
|
||||
// A nice touch: a history of files visited. Use this menu.
|
||||
myDocManager->FileHistoryUseMenu(file_menu);
|
||||
|
||||
wxMenu *help_menu = new wxMenu;
|
||||
help_menu->Append(OGLEDIT_ABOUT, "&About");
|
||||
|
||||
wxMenuBar *menu_bar = new wxMenuBar;
|
||||
|
||||
menu_bar->Append(file_menu, "&File");
|
||||
if (edit_menu)
|
||||
menu_bar->Append(edit_menu, "&Edit");
|
||||
menu_bar->Append(help_menu, "&Help");
|
||||
|
||||
frame->canvas = frame->CreateCanvas(NULL, frame);
|
||||
frame->palette = wxGetApp().CreatePalette(frame);
|
||||
myDocManager->CreateDocument("", wxDOC_NEW);
|
||||
|
||||
//// Associate the menu bar with the frame
|
||||
frame->SetMenuBar(menu_bar);
|
||||
|
||||
frame->CreateStatusBar(1);
|
||||
|
||||
frame->Centre(wxBOTH);
|
||||
frame->Show(TRUE);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int MyApp::OnExit(void)
|
||||
{
|
||||
wxOGLCleanUp();
|
||||
delete myDocManager;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* This is the top-level window of the application.
|
||||
*/
|
||||
|
||||
IMPLEMENT_CLASS(MyFrame, wxDocParentFrame)
|
||||
|
||||
BEGIN_EVENT_TABLE(MyFrame, wxDocParentFrame)
|
||||
EVT_MENU(OGLEDIT_ABOUT, MyFrame::OnAbout)
|
||||
EVT_SIZE(MyFrame::OnSize)
|
||||
EVT_CLOSE(MyFrame::OnCloseWindow)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
MyFrame::MyFrame(wxDocManager *manager, wxFrame *frame, const wxString& title,
|
||||
const wxPoint& pos, const wxSize& size, long type):
|
||||
wxDocParentFrame(manager, frame, -1, title, pos, size, type)
|
||||
{
|
||||
canvas = NULL;
|
||||
palette = NULL;
|
||||
editMenu = NULL;
|
||||
}
|
||||
|
||||
void MyFrame::OnSize(wxSizeEvent& event)
|
||||
{
|
||||
if (canvas && palette)
|
||||
{
|
||||
int cw, ch;
|
||||
GetClientSize(&cw, &ch);
|
||||
int paletteX = 0;
|
||||
int paletteY = 0;
|
||||
int paletteW = 30;
|
||||
int paletteH = ch;
|
||||
int canvasX = paletteX + paletteW;
|
||||
int canvasY = 0;
|
||||
int canvasW = cw - paletteW;
|
||||
int canvasH = ch;
|
||||
|
||||
palette->SetSize(paletteX, paletteY, paletteW, paletteH);
|
||||
canvas->SetSize(canvasX, canvasY, canvasW, canvasH);
|
||||
}
|
||||
}
|
||||
|
||||
void MyFrame::OnCloseWindow(wxCloseEvent& event)
|
||||
{
|
||||
wxDocParentFrame::OnCloseWindow(event);
|
||||
if (!event.GetVeto())
|
||||
{
|
||||
wxOGLCleanUp();
|
||||
}
|
||||
}
|
||||
|
||||
// Intercept menu commands
|
||||
void MyFrame::OnAbout(wxCommandEvent& event)
|
||||
{
|
||||
(void)wxMessageBox("OGLEdit Demo\nTo draw a shape, select a shape on the toolbar and left-click on the canvas.\nTo draw a line, right-drag between shapes.\nFor further details, see the OGL manual.\n (c) Julian Smart 1996", "About OGLEdit");
|
||||
}
|
||||
|
||||
// Creates a canvas. Called by OnInit as a child of the main window
|
||||
MyCanvas *MyFrame::CreateCanvas(wxView *view, wxFrame *parent)
|
||||
{
|
||||
int width, height;
|
||||
parent->GetClientSize(&width, &height);
|
||||
|
||||
// Non-retained canvas
|
||||
MyCanvas *canvas = new MyCanvas(view, parent, -1, wxPoint(0, 0), wxSize(width, height), 0);
|
||||
canvas->SetCursor(wxCursor(wxCURSOR_HAND));
|
||||
|
||||
// Give it scrollbars
|
||||
canvas->SetScrollbars(20, 20, 50, 50);
|
||||
|
||||
return canvas;
|
||||
}
|
||||
|
||||
MyFrame *GetMainFrame(void)
|
||||
{
|
||||
return wxGetApp().frame;
|
||||
}
|
||||
|
8
samples/ogl/ogledit/ogledit.def
Normal file
@@ -0,0 +1,8 @@
|
||||
NAME OGLEdit
|
||||
DESCRIPTION 'OGL Editor Sample'
|
||||
EXETYPE WINDOWS
|
||||
STUB 'WINSTUB.EXE'
|
||||
CODE PRELOAD MOVEABLE DISCARDABLE
|
||||
DATA PRELOAD MOVEABLE MULTIPLE
|
||||
HEAPSIZE 1024
|
||||
STACKSIZE 8192
|
77
samples/ogl/ogledit/ogledit.h
Normal file
@@ -0,0 +1,77 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: ogledit.h
|
||||
// Purpose: OGL sample
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 12/07/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
// #pragma interface
|
||||
#endif
|
||||
|
||||
#ifndef _OGLSAMPLE_OGLEDIT_H_
|
||||
#define _OGLSAMPLE_OGLEDIT_H_
|
||||
|
||||
#include <wx/docview.h>
|
||||
|
||||
// Define a new application
|
||||
class MyFrame;
|
||||
class EditorToolPalette;
|
||||
class MyApp: public wxApp
|
||||
{
|
||||
public:
|
||||
MyFrame *frame;
|
||||
wxDocManager* myDocManager;
|
||||
|
||||
MyApp(void);
|
||||
bool OnInit(void);
|
||||
int OnExit(void);
|
||||
|
||||
// Palette stuff
|
||||
EditorToolPalette *CreatePalette(wxFrame *parent);
|
||||
};
|
||||
|
||||
DECLARE_APP(MyApp)
|
||||
|
||||
// Define a new frame
|
||||
class MyCanvas;
|
||||
class MyFrame: public wxDocParentFrame
|
||||
{
|
||||
DECLARE_CLASS(MyFrame)
|
||||
public:
|
||||
wxMenu *editMenu;
|
||||
|
||||
MyCanvas *canvas;
|
||||
EditorToolPalette *palette;
|
||||
|
||||
MyFrame(wxDocManager *manager, wxFrame *parent, const wxString& title,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxDEFAULT_FRAME_STYLE);
|
||||
|
||||
MyCanvas *CreateCanvas(wxView *view, wxFrame *parent);
|
||||
void OnSize(wxSizeEvent& event);
|
||||
void OnCloseWindow(wxCloseEvent& event);
|
||||
void OnAbout(wxCommandEvent& event);
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
extern MyFrame *GetMainFrame(void);
|
||||
|
||||
// Menu/undo/redo commands
|
||||
|
||||
#define OGLEDIT_CUT 1
|
||||
#define OGLEDIT_ADD_SHAPE 2
|
||||
#define OGLEDIT_ADD_LINE 3
|
||||
#define OGLEDIT_EDIT_LABEL 4
|
||||
#define OGLEDIT_CHANGE_BACKGROUND_COLOUR 5
|
||||
|
||||
#define OGLEDIT_ABOUT 100
|
||||
|
||||
#endif
|
||||
// _OGLSAMPLE_OGLEDIT_H_
|
10
samples/ogl/ogledit/ogledit.rc
Normal file
@@ -0,0 +1,10 @@
|
||||
ogl ICON ogl.ico
|
||||
|
||||
TOOL1 BITMAP "bitmaps/tool1.bmp"
|
||||
TOOL2 BITMAP "bitmaps/tool2.bmp"
|
||||
TOOL3 BITMAP "bitmaps/tool3.bmp"
|
||||
TOOL4 BITMAP "bitmaps/tool4.bmp"
|
||||
ARROWTOOL BITMAP "bitmaps/arrow.bmp"
|
||||
|
||||
#include "wx/msw/wx.rc"
|
||||
|
121
samples/ogl/ogledit/palette.cpp
Normal file
@@ -0,0 +1,121 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: palette.cpp
|
||||
// Purpose: OGLEdit palette
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 12/07/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
// #pragma implementation
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include <wx/wxprec.h>
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include <wx/wx.h>
|
||||
#endif
|
||||
|
||||
#include <wx/toolbar.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "doc.h"
|
||||
#include "view.h"
|
||||
#include "ogledit.h"
|
||||
#include "palette.h"
|
||||
|
||||
// Include pixmaps
|
||||
#if defined(__WXGTK__) || defined(__WXMOTIF__)
|
||||
#include "bitmaps/arrow.xpm"
|
||||
#include "bitmaps/tool1.xpm"
|
||||
#include "bitmaps/tool2.xpm"
|
||||
#include "bitmaps/tool3.xpm"
|
||||
#include "bitmaps/tool4.xpm"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Object editor tool palette
|
||||
*
|
||||
*/
|
||||
|
||||
EditorToolPalette::EditorToolPalette(wxWindow* parent, const wxPoint& pos, const wxSize& size,
|
||||
long style):
|
||||
TOOLPALETTECLASS(parent, -1, pos, size, style)
|
||||
{
|
||||
currentlySelected = -1;
|
||||
|
||||
#if 1 // ndef __WXGTK__
|
||||
SetMaxRowsCols(1000, 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool EditorToolPalette::OnLeftClick(int toolIndex, bool toggled)
|
||||
{
|
||||
// BEGIN mutual exclusivity code
|
||||
if (toggled && (currentlySelected != -1) && (toolIndex != currentlySelected))
|
||||
ToggleTool(currentlySelected, FALSE);
|
||||
|
||||
if (toggled)
|
||||
currentlySelected = toolIndex;
|
||||
else if (currentlySelected == toolIndex)
|
||||
currentlySelected = -1;
|
||||
// END mutual exclusivity code
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void EditorToolPalette::OnMouseEnter(int toolIndex)
|
||||
{
|
||||
}
|
||||
|
||||
void EditorToolPalette::SetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
{
|
||||
TOOLPALETTECLASS::SetSize(x, y, width, height, sizeFlags);
|
||||
}
|
||||
|
||||
EditorToolPalette *MyApp::CreatePalette(wxFrame *parent)
|
||||
{
|
||||
// Load palette bitmaps
|
||||
#ifdef __WXMSW__
|
||||
wxBitmap PaletteTool1("TOOL1");
|
||||
wxBitmap PaletteTool2("TOOL2");
|
||||
wxBitmap PaletteTool3("TOOL3");
|
||||
wxBitmap PaletteTool4("TOOL4");
|
||||
wxBitmap PaletteArrow("ARROWTOOL");
|
||||
#elif defined(__WXGTK__) || defined(__WXMOTIF__)
|
||||
wxBitmap PaletteTool1(tool1_xpm);
|
||||
wxBitmap PaletteTool2(tool2_xpm);
|
||||
wxBitmap PaletteTool3(tool3_xpm);
|
||||
wxBitmap PaletteTool4(tool4_xpm);
|
||||
wxBitmap PaletteArrow(arrow_xpm);
|
||||
#endif
|
||||
|
||||
EditorToolPalette *palette = new EditorToolPalette(parent, wxPoint(0, 0), wxSize(-1, -1), wxTB_HORIZONTAL);
|
||||
|
||||
palette->SetMargins(2, 2);
|
||||
palette->SetToolBitmapSize(wxSize(22, 22));
|
||||
|
||||
palette->AddTool(PALETTE_ARROW, PaletteArrow, wxNullBitmap, TRUE, 0, -1, NULL, "Pointer");
|
||||
palette->AddTool(PALETTE_TOOL1, PaletteTool1, wxNullBitmap, TRUE, 0, -1, NULL, "Tool 1");
|
||||
palette->AddTool(PALETTE_TOOL2, PaletteTool2, wxNullBitmap, TRUE, 0, -1, NULL, "Tool 2");
|
||||
palette->AddTool(PALETTE_TOOL3, PaletteTool3, wxNullBitmap, TRUE, 0, -1, NULL, "Tool 3");
|
||||
palette->AddTool(PALETTE_TOOL4, PaletteTool4, wxNullBitmap, TRUE, 0, -1, NULL, "Tool 4");
|
||||
|
||||
palette->Realize();
|
||||
|
||||
palette->ToggleTool(PALETTE_ARROW, TRUE);
|
||||
palette->currentlySelected = PALETTE_ARROW;
|
||||
return palette;
|
||||
}
|
||||
|
66
samples/ogl/ogledit/palette.h
Normal file
@@ -0,0 +1,66 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: palette.h
|
||||
// Purpose: OGL sample palette
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 12/07/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _OGLSAMPLE_PALETTE_H_
|
||||
#define _OGLSAMPLE_PALETTE_H_
|
||||
|
||||
#ifdef __GNUG__
|
||||
// #pragma interface
|
||||
#endif
|
||||
|
||||
#include <wx/wx.h>
|
||||
#include <wx/string.h>
|
||||
#if 0 // def __WXGTK__
|
||||
#include <wx/toolbar.h>
|
||||
#else
|
||||
#include <wx/tbarsmpl.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Object editor tool palette
|
||||
*
|
||||
*/
|
||||
|
||||
// TODO for wxWin: wxToolBar95 cannot be moved to a non-0,0 position!
|
||||
// Needs to have a parent window...
|
||||
// So use a simple toolbar at present.
|
||||
#if 0 // def __WXGTK__
|
||||
#define TOOLPALETTECLASS wxToolBar
|
||||
#else
|
||||
#define TOOLPALETTECLASS wxToolBarSimple
|
||||
#endif
|
||||
|
||||
class EditorToolPalette: public TOOLPALETTECLASS
|
||||
{
|
||||
public:
|
||||
int currentlySelected;
|
||||
|
||||
EditorToolPalette(wxWindow *parent, const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxTB_VERTICAL);
|
||||
bool OnLeftClick(int toolIndex, bool toggled);
|
||||
void OnMouseEnter(int toolIndex);
|
||||
void SetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO);
|
||||
};
|
||||
|
||||
#define PALETTE_TOOL1 1
|
||||
#define PALETTE_TOOL2 2
|
||||
#define PALETTE_TOOL3 3
|
||||
#define PALETTE_TOOL4 4
|
||||
#define PALETTE_TOOL5 5
|
||||
#define PALETTE_TOOL6 6
|
||||
#define PALETTE_TOOL7 7
|
||||
#define PALETTE_TOOL8 8
|
||||
#define PALETTE_TOOL9 9
|
||||
#define PALETTE_ARROW 10
|
||||
|
||||
#endif
|
||||
// _OGLSAMPLE_PALETTE_H_
|
337
samples/ogl/ogledit/view.cpp
Normal file
@@ -0,0 +1,337 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: view.cpp
|
||||
// Purpose: Implements view functionality in OGLEdit
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 12/07/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
// #pragma implementation
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include <wx/wxprec.h>
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include <wx/wx.h>
|
||||
#endif
|
||||
|
||||
#include <wx/colordlg.h>
|
||||
|
||||
#if !wxUSE_DOC_VIEW_ARCHITECTURE
|
||||
#error You must set wxUSE_DOC_VIEW_ARCHITECTURE to 1 in wx_setup.h!
|
||||
#endif
|
||||
|
||||
#include "ogledit.h"
|
||||
#include "doc.h"
|
||||
#include "view.h"
|
||||
#include "palette.h"
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(DiagramView, wxView)
|
||||
|
||||
BEGIN_EVENT_TABLE(DiagramView, wxView)
|
||||
EVT_MENU(OGLEDIT_CUT, DiagramView::OnCut)
|
||||
EVT_MENU(OGLEDIT_CHANGE_BACKGROUND_COLOUR, DiagramView::OnChangeBackgroundColour)
|
||||
EVT_MENU(OGLEDIT_EDIT_LABEL, DiagramView::OnEditLabel)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
// What to do when a view is created. Creates actual
|
||||
// windows for displaying the view.
|
||||
bool DiagramView::OnCreate(wxDocument *doc, long flags)
|
||||
{
|
||||
frame = GetMainFrame();
|
||||
canvas = GetMainFrame()->canvas;
|
||||
canvas->view = this;
|
||||
|
||||
SetFrame(frame);
|
||||
Activate(TRUE);
|
||||
|
||||
// Initialize the edit menu Undo and Redo items
|
||||
doc->GetCommandProcessor()->SetEditMenu(((MyFrame *)frame)->editMenu);
|
||||
doc->GetCommandProcessor()->Initialize();
|
||||
|
||||
wxShapeCanvas *shapeCanvas = (wxShapeCanvas *)canvas;
|
||||
DiagramDocument *diagramDoc = (DiagramDocument *)doc;
|
||||
shapeCanvas->SetDiagram(diagramDoc->GetDiagram());
|
||||
diagramDoc->GetDiagram()->SetCanvas(shapeCanvas);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#define CENTER FALSE // Place the drawing to the center of the page
|
||||
|
||||
|
||||
// Sneakily gets used for default print/preview
|
||||
// as well as drawing on the screen.
|
||||
void DiagramView::OnDraw(wxDC *dc)
|
||||
{
|
||||
|
||||
/* You might use THIS code if you were scaling
|
||||
* graphics of known size to fit on the page.
|
||||
*/
|
||||
int w, h;
|
||||
|
||||
// We need to adjust for the graphic size, a formula will be added
|
||||
float maxX = 900;
|
||||
float maxY = 700;
|
||||
// A better way of find the maxium values would be to search through
|
||||
// the linked list
|
||||
|
||||
// Let's have at least 10 device units margin
|
||||
float marginX = 10;
|
||||
float marginY = 10;
|
||||
|
||||
// Add the margin to the graphic size
|
||||
maxX += (2 * marginX);
|
||||
maxY += (2 * marginY);
|
||||
|
||||
// Get the size of the DC in pixels
|
||||
dc->GetSize (&w, &h);
|
||||
|
||||
// Calculate a suitable scaling factor
|
||||
float scaleX = (float) (w / maxX);
|
||||
float scaleY = (float) (h / maxY);
|
||||
|
||||
// Use x or y scaling factor, whichever fits on the DC
|
||||
float actualScale = wxMin (scaleX, scaleY);
|
||||
|
||||
float posX, posY;
|
||||
// Calculate the position on the DC for centring the graphic
|
||||
if (CENTER == TRUE) // center the drawing
|
||||
{
|
||||
posX = (float) ((w - (200 * actualScale)) / 2.0);
|
||||
posY = (float) ((h - (200 * actualScale)) / 2.0);
|
||||
}
|
||||
else // Use defined presets
|
||||
{
|
||||
posX = 10;
|
||||
posY = 35;
|
||||
}
|
||||
|
||||
|
||||
// Set the scale and origin
|
||||
dc->SetUserScale (actualScale, actualScale);
|
||||
dc->SetDeviceOrigin ((long) posX, (long) posY);
|
||||
|
||||
// This part was added to preform the print preview and printing functions
|
||||
|
||||
dc->BeginDrawing(); // Allows optimization of drawing code under MS Windows.
|
||||
wxDiagram *diagram_p=((DiagramDocument*)GetDocument())->GetDiagram(); // Get the current diagram
|
||||
if (diagram_p->GetShapeList())
|
||||
{
|
||||
wxCursor *old_cursor = NULL;
|
||||
wxNode *current = diagram_p->GetShapeList()->First();
|
||||
|
||||
while (current) // Loop through the entire list of shapes
|
||||
{
|
||||
wxShape *object = (wxShape *)current->Data();
|
||||
if (!object->GetParent())
|
||||
{
|
||||
object->Draw(* dc); // Draw the shape onto our printing dc
|
||||
}
|
||||
current = current->Next(); // Procede to the next shape in the list
|
||||
}
|
||||
}
|
||||
dc->EndDrawing(); // Allows optimization of drawing code under MS Windows.
|
||||
}
|
||||
|
||||
void DiagramView::OnUpdate(wxView *sender, wxObject *hint)
|
||||
{
|
||||
if (canvas)
|
||||
canvas->Refresh();
|
||||
}
|
||||
|
||||
// Clean up windows used for displaying the view.
|
||||
bool DiagramView::OnClose(bool deleteWindow)
|
||||
{
|
||||
if (!GetDocument()->Close())
|
||||
return FALSE;
|
||||
|
||||
DiagramDocument *diagramDoc = (DiagramDocument *)GetDocument();
|
||||
diagramDoc->GetDiagram()->SetCanvas(NULL);
|
||||
|
||||
canvas->Clear();
|
||||
canvas->SetDiagram(NULL);
|
||||
canvas->view = NULL;
|
||||
canvas = NULL;
|
||||
|
||||
wxString s = wxTheApp->GetAppName();
|
||||
if (frame)
|
||||
frame->SetTitle(s);
|
||||
|
||||
SetFrame(NULL);
|
||||
|
||||
Activate(FALSE);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
wxShape *DiagramView::FindSelectedShape(void)
|
||||
{
|
||||
DiagramDocument *doc = (DiagramDocument *)GetDocument();
|
||||
wxShape *theShape = NULL;
|
||||
wxNode *node = doc->GetDiagram()->GetShapeList()->First();
|
||||
while (node)
|
||||
{
|
||||
wxShape *eachShape = (wxShape *)node->Data();
|
||||
if ((eachShape->GetParent() == NULL) && eachShape->Selected())
|
||||
{
|
||||
theShape = eachShape;
|
||||
node = NULL;
|
||||
}
|
||||
else node = node->Next();
|
||||
}
|
||||
return theShape;
|
||||
}
|
||||
|
||||
void DiagramView::OnCut(wxCommandEvent& event)
|
||||
{
|
||||
DiagramDocument *doc = (DiagramDocument *)GetDocument();
|
||||
|
||||
wxShape *theShape = FindSelectedShape();
|
||||
if (theShape)
|
||||
doc->GetCommandProcessor()->Submit(new DiagramCommand("Cut", OGLEDIT_CUT, doc, NULL, 0.0, 0.0, TRUE, theShape));
|
||||
}
|
||||
|
||||
void DiagramView::OnChangeBackgroundColour(wxCommandEvent& event)
|
||||
{
|
||||
DiagramDocument *doc = (DiagramDocument *)GetDocument();
|
||||
|
||||
wxShape *theShape = FindSelectedShape();
|
||||
if (theShape)
|
||||
{
|
||||
wxColourData data;
|
||||
data.SetChooseFull(TRUE);
|
||||
data.SetColour(theShape->GetBrush()->GetColour());
|
||||
|
||||
wxColourDialog *dialog = new wxColourDialog(frame, &data);
|
||||
wxBrush *theBrush = NULL;
|
||||
if (dialog->ShowModal() == wxID_OK)
|
||||
{
|
||||
wxColourData retData = dialog->GetColourData();
|
||||
wxColour col = retData.GetColour();
|
||||
theBrush = wxTheBrushList->FindOrCreateBrush(col, wxSOLID);
|
||||
}
|
||||
dialog->Close();
|
||||
|
||||
if (theBrush)
|
||||
doc->GetCommandProcessor()->Submit(new DiagramCommand("Change colour", OGLEDIT_CHANGE_BACKGROUND_COLOUR, doc,
|
||||
theBrush, theShape));
|
||||
}
|
||||
}
|
||||
|
||||
void DiagramView::OnEditLabel(wxCommandEvent& event)
|
||||
{
|
||||
wxShape *theShape = FindSelectedShape();
|
||||
if (theShape)
|
||||
{
|
||||
wxString newLabel = wxGetTextFromUser("Enter new label", "Shape Label", ((MyEvtHandler *)theShape->GetEventHandler())->label);
|
||||
GetDocument()->GetCommandProcessor()->Submit(new DiagramCommand("Edit label", OGLEDIT_EDIT_LABEL, (DiagramDocument*) GetDocument(), newLabel, theShape));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Window implementations
|
||||
*/
|
||||
|
||||
BEGIN_EVENT_TABLE(MyCanvas, wxShapeCanvas)
|
||||
EVT_MOUSE_EVENTS(MyCanvas::OnMouseEvent)
|
||||
EVT_PAINT(MyCanvas::OnPaint)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
// Define a constructor for my canvas
|
||||
MyCanvas::MyCanvas(wxView *v, wxWindow *parent, wxWindowID id, const wxPoint& pos,
|
||||
const wxSize& size, long style):
|
||||
wxShapeCanvas(parent, id, pos, size, style)
|
||||
{
|
||||
SetBackgroundColour(*wxWHITE);
|
||||
view = v;
|
||||
}
|
||||
|
||||
MyCanvas::~MyCanvas(void)
|
||||
{
|
||||
}
|
||||
|
||||
void MyCanvas::OnLeftClick(double x, double y, int keys)
|
||||
{
|
||||
EditorToolPalette *palette = wxGetApp().frame->palette;
|
||||
wxClassInfo *info = NULL;
|
||||
switch (palette->currentlySelected)
|
||||
{
|
||||
case PALETTE_TOOL1:
|
||||
{
|
||||
info = CLASSINFO(wxRectangleShape);
|
||||
break;
|
||||
}
|
||||
case PALETTE_TOOL2:
|
||||
{
|
||||
info = CLASSINFO(wxRoundedRectangleShape);
|
||||
break;
|
||||
}
|
||||
case PALETTE_TOOL3:
|
||||
{
|
||||
info = CLASSINFO(wxEllipseShape);
|
||||
break;
|
||||
}
|
||||
case PALETTE_TOOL4:
|
||||
{
|
||||
info = CLASSINFO(wxDiamondShape);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (info)
|
||||
{
|
||||
view->GetDocument()->GetCommandProcessor()->Submit(new DiagramCommand(info->GetClassName(), OGLEDIT_ADD_SHAPE, (DiagramDocument *)view->GetDocument(), info,
|
||||
x, y));
|
||||
}
|
||||
}
|
||||
|
||||
void MyCanvas::OnRightClick(double x, double y, int keys)
|
||||
{
|
||||
}
|
||||
|
||||
void MyCanvas::OnDragLeft(bool draw, double x, double y, int keys)
|
||||
{
|
||||
}
|
||||
|
||||
void MyCanvas::OnBeginDragLeft(double x, double y, int keys)
|
||||
{
|
||||
}
|
||||
|
||||
void MyCanvas::OnEndDragLeft(double x, double y, int keys)
|
||||
{
|
||||
}
|
||||
|
||||
void MyCanvas::OnDragRight(bool draw, double x, double y, int keys)
|
||||
{
|
||||
}
|
||||
|
||||
void MyCanvas::OnBeginDragRight(double x, double y, int keys)
|
||||
{
|
||||
}
|
||||
|
||||
void MyCanvas::OnEndDragRight(double x, double y, int keys)
|
||||
{
|
||||
}
|
||||
|
||||
void MyCanvas::OnMouseEvent(wxMouseEvent& event)
|
||||
{
|
||||
wxShapeCanvas::OnMouseEvent(event);
|
||||
}
|
||||
|
||||
void MyCanvas::OnPaint(wxPaintEvent& event)
|
||||
{
|
||||
// if (GetDiagram())
|
||||
wxShapeCanvas::OnPaint(event);
|
||||
}
|
79
samples/ogl/ogledit/view.h
Normal file
@@ -0,0 +1,79 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: view.h
|
||||
// Purpose: View-related classes
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 12/07/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _OGLSAMPLE_VIEW_H_
|
||||
#define _OGLSAMPLE_VIEW_H_
|
||||
|
||||
#ifdef __GNUG__
|
||||
// #pragma interface "view.h"
|
||||
#endif
|
||||
|
||||
#include "doc.h"
|
||||
#include <wx/ogl/ogl.h>
|
||||
|
||||
class MyCanvas: public wxShapeCanvas
|
||||
{
|
||||
// DECLARE_DYNAMIC_CLASS(wxShapeCanvas)
|
||||
protected:
|
||||
public:
|
||||
wxView *view;
|
||||
|
||||
MyCanvas(wxView *view, wxWindow *parent = NULL, wxWindowID id = -1,
|
||||
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
|
||||
long style = wxRETAINED);
|
||||
~MyCanvas(void);
|
||||
|
||||
void OnMouseEvent(wxMouseEvent& event);
|
||||
void OnPaint(wxPaintEvent& event);
|
||||
|
||||
virtual void OnLeftClick(double x, double y, int keys = 0);
|
||||
virtual void OnRightClick(double x, double y, int keys = 0);
|
||||
|
||||
virtual void OnDragLeft(bool draw, double x, double y, int keys=0); // Erase if draw false
|
||||
virtual void OnBeginDragLeft(double x, double y, int keys=0);
|
||||
virtual void OnEndDragLeft(double x, double y, int keys=0);
|
||||
|
||||
virtual void OnDragRight(bool draw, double x, double y, int keys=0); // Erase if draw false
|
||||
virtual void OnBeginDragRight(double x, double y, int keys=0);
|
||||
virtual void OnEndDragRight(double x, double y, int keys=0);
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
class DiagramView: public wxView
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(DiagramView)
|
||||
private:
|
||||
public:
|
||||
wxFrame *frame;
|
||||
MyCanvas *canvas;
|
||||
|
||||
DiagramView(void) { canvas = NULL; frame = NULL; };
|
||||
~DiagramView(void) {};
|
||||
|
||||
bool OnCreate(wxDocument *doc, long flags);
|
||||
void OnDraw(wxDC *dc);
|
||||
void OnUpdate(wxView *sender, wxObject *hint = NULL);
|
||||
bool OnClose(bool deleteWindow = TRUE);
|
||||
|
||||
wxShape *FindSelectedShape(void);
|
||||
|
||||
// void OnMenuCommand(int cmd);
|
||||
|
||||
void OnCut(wxCommandEvent& event);
|
||||
void OnChangeBackgroundColour(wxCommandEvent& event);
|
||||
void OnEditLabel(wxCommandEvent& event);
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
#endif
|
||||
// _OGLSAMPLE_VIEW_H_
|
57
samples/ogl/studio/Makefile
Normal file
@@ -0,0 +1,57 @@
|
||||
#
|
||||
# File: Makefile
|
||||
# Author: Julian Smart
|
||||
# Created: 1999
|
||||
# Updated:
|
||||
# Copyright: (c) 2000 Julian Smart
|
||||
#
|
||||
# Makefile for OGL demo (GTK version)
|
||||
#
|
||||
# This makefile requires wxWindows/GTK to be
|
||||
# installed (possibly using "make install")
|
||||
# on your system.
|
||||
#
|
||||
|
||||
CPP = gcc
|
||||
CC = gcc
|
||||
WXCONFIG=../../../../wx-config
|
||||
WXINCLUDE=-I../../../../include
|
||||
WXLIB=-L../../../../lib
|
||||
|
||||
OBJECTS=studio.o cspalette.o csprint.o dialogs.o doc.o mainfrm.o project.o shapes.o symbols.o view.o
|
||||
|
||||
studio: $(OBJECTS)
|
||||
$(CPP) -o studio $(OBJECTS) `$(WXCONFIG) --libs` $(WXLIB) -logl
|
||||
|
||||
studio.o: studio.cpp
|
||||
$(CPP) `$(WXCONFIG) --cflags` -I../../src $(WXINCLUDE) -c studio.cpp
|
||||
|
||||
cspalette.o: cspalette.cpp
|
||||
$(CPP) `$(WXCONFIG) --cflags` -I../../src $(WXINCLUDE) -c cspalette.cpp
|
||||
|
||||
doc.o: doc.cpp
|
||||
$(CPP) `$(WXCONFIG) --cflags` -I../../src $(WXINCLUDE) -c doc.cpp
|
||||
|
||||
view.o: view.cpp
|
||||
$(CPP) `$(WXCONFIG) --cflags` -I../../src $(WXINCLUDE) -c view.cpp
|
||||
|
||||
dialogs.o: dialogs.cpp
|
||||
$(CPP) `$(WXCONFIG) --cflags` -I../../src $(WXINCLUDE) -c dialogs.cpp
|
||||
|
||||
mainfrm.o: mainfrm.cpp
|
||||
$(CPP) `$(WXCONFIG) --cflags` -I../../src $(WXINCLUDE) -c mainfrm.cpp
|
||||
|
||||
project.o: project.cpp
|
||||
$(CPP) `$(WXCONFIG) --cflags` -I../../src $(WXINCLUDE) -c project.cpp
|
||||
|
||||
shapes.o: shapes.cpp
|
||||
$(CPP) `$(WXCONFIG) --cflags` -I../../src $(WXINCLUDE) -c shapes.cpp
|
||||
|
||||
symbols.o: symbols.cpp
|
||||
$(CPP) `$(WXCONFIG) --cflags` -I../../src $(WXINCLUDE) -c symbols.cpp
|
||||
|
||||
csprint.o: csprint.cpp
|
||||
$(CPP) `$(WXCONFIG) --cflags` -I../../src $(WXINCLUDE) -c csprint.cpp
|
||||
|
||||
clean:
|
||||
rm -f *.o studio
|
153
samples/ogl/studio/cspalette.cpp
Normal file
@@ -0,0 +1,153 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: cspalette.cpp
|
||||
// Purpose: OGLEdit palette
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 12/07/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
// #pragma implementation
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include <wx/wxprec.h>
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include <wx/wx.h>
|
||||
#endif
|
||||
|
||||
#include <wx/laywin.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "doc.h"
|
||||
#include "view.h"
|
||||
#include "studio.h"
|
||||
#include "cspalette.h"
|
||||
#include "symbols.h"
|
||||
|
||||
#if defined(__WXGTK__) || defined(__WXMOTIF__)
|
||||
#include "bitmaps/arrow.xpm"
|
||||
#include "bitmaps/texttool.xpm"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Object editor tool palette
|
||||
*
|
||||
*/
|
||||
|
||||
csEditorToolPalette::csEditorToolPalette(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
|
||||
long style):
|
||||
TOOLPALETTECLASS(parent, id, pos, size, style)
|
||||
{
|
||||
m_currentlySelected = -1;
|
||||
|
||||
SetMaxRowsCols(1, 1000);
|
||||
}
|
||||
|
||||
bool csEditorToolPalette::OnLeftClick(int toolIndex, bool toggled)
|
||||
{
|
||||
// BEGIN mutual exclusivity code
|
||||
if (toggled && (m_currentlySelected != -1) && (toolIndex != m_currentlySelected))
|
||||
ToggleTool(m_currentlySelected, FALSE);
|
||||
|
||||
if (toggled)
|
||||
m_currentlySelected = toolIndex;
|
||||
else if (m_currentlySelected == toolIndex)
|
||||
m_currentlySelected = -1;
|
||||
// END mutual exclusivity code
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void csEditorToolPalette::OnMouseEnter(int toolIndex)
|
||||
{
|
||||
wxString msg("");
|
||||
if (toolIndex == PALETTE_ARROW)
|
||||
msg = "Pointer";
|
||||
else if (toolIndex != -1)
|
||||
{
|
||||
csSymbol* symbol = wxGetApp().GetSymbolDatabase()->FindSymbol(toolIndex);
|
||||
if (symbol)
|
||||
msg = symbol->GetName();
|
||||
}
|
||||
((wxFrame*) wxGetApp().GetTopWindow())->SetStatusText(msg);
|
||||
}
|
||||
|
||||
void csEditorToolPalette::SetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
{
|
||||
TOOLPALETTECLASS::SetSize(x, y, width, height, sizeFlags);
|
||||
}
|
||||
|
||||
void csEditorToolPalette::SetSelection(int sel)
|
||||
{
|
||||
if ((sel != m_currentlySelected) && (m_currentlySelected != -1))
|
||||
{
|
||||
ToggleTool(m_currentlySelected, FALSE);
|
||||
}
|
||||
m_currentlySelected = sel;
|
||||
ToggleTool(m_currentlySelected, TRUE);
|
||||
}
|
||||
|
||||
bool csApp::CreatePalette(wxFrame *parent)
|
||||
{
|
||||
// First create a layout window
|
||||
wxSashLayoutWindow* win = new wxSashLayoutWindow(parent, ID_LAYOUT_WINDOW_PALETTE, wxDefaultPosition, wxSize(200, 30), wxNO_BORDER|wxSW_3D|wxCLIP_CHILDREN);
|
||||
win->SetDefaultSize(wxSize(10000, 40));
|
||||
win->SetOrientation(wxLAYOUT_HORIZONTAL);
|
||||
win->SetAlignment(wxLAYOUT_TOP);
|
||||
win->SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
|
||||
win->SetSashVisible(wxSASH_BOTTOM, TRUE);
|
||||
|
||||
m_diagramPaletteSashWindow = win;
|
||||
|
||||
m_diagramPaletteSashWindow->Show(FALSE);
|
||||
|
||||
// Load palette bitmaps
|
||||
#ifdef __WXMSW__
|
||||
wxBitmap PaletteArrow("arrowtool");
|
||||
wxBitmap TextTool("texttool");
|
||||
#elif defined(__WXGTK__) || defined(__WXMOTIF__)
|
||||
wxBitmap PaletteArrow(arrow_xpm);
|
||||
wxBitmap TextTool(texttool_xpm);
|
||||
#endif
|
||||
|
||||
csEditorToolPalette *palette = new csEditorToolPalette(m_diagramPaletteSashWindow, ID_DIAGRAM_PALETTE, wxPoint(0, 0), wxSize(-1, -1), wxTB_HORIZONTAL|wxNO_BORDER);
|
||||
|
||||
palette->SetMargins(2, 2);
|
||||
|
||||
palette->SetToolBitmapSize(wxSize(32, 32));
|
||||
|
||||
palette->AddTool(PALETTE_ARROW, PaletteArrow, wxNullBitmap, TRUE, 0, -1, NULL, "Pointer");
|
||||
palette->AddTool(PALETTE_TEXT_TOOL, TextTool, wxNullBitmap, TRUE, 0, -1, NULL, "Text");
|
||||
|
||||
wxNode* node = GetSymbolDatabase()->GetSymbols().First();
|
||||
while (node)
|
||||
{
|
||||
csSymbol* symbol = (csSymbol*) node->Data();
|
||||
wxBitmap* bitmap = GetSymbolDatabase()->CreateToolBitmap(symbol);
|
||||
palette->AddTool(symbol->GetToolId(), *bitmap, wxNullBitmap, TRUE, 0, -1, NULL, symbol->GetName());
|
||||
|
||||
delete bitmap;
|
||||
|
||||
node = node->Next();
|
||||
}
|
||||
|
||||
palette->Realize();
|
||||
|
||||
palette->SetSelection(PALETTE_ARROW);
|
||||
m_diagramPalette = palette;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
57
samples/ogl/studio/cspalette.h
Normal file
@@ -0,0 +1,57 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: cspalette.h
|
||||
// Purpose: OGL sample palette
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 12/07/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _STUDIO_CSPALETTE_H_
|
||||
#define _STUDIO_CSPALETTE_H_
|
||||
|
||||
#ifdef __GNUG__
|
||||
// #pragma interface
|
||||
#endif
|
||||
|
||||
#include <wx/wx.h>
|
||||
#include <wx/string.h>
|
||||
#include <wx/tbarsmpl.h>
|
||||
|
||||
/*
|
||||
* Object editor tool palette
|
||||
*
|
||||
*/
|
||||
|
||||
// TODO for wxWin: wxToolBar95 cannot be moved to a non-0,0 position!
|
||||
// Needs to have a parent window...
|
||||
// So use a simple toolbar at present.
|
||||
#define TOOLPALETTECLASS wxToolBarSimple
|
||||
|
||||
class csEditorToolPalette: public TOOLPALETTECLASS
|
||||
{
|
||||
public:
|
||||
|
||||
csEditorToolPalette(wxWindow *parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxTB_VERTICAL);
|
||||
|
||||
bool OnLeftClick(int toolIndex, bool toggled);
|
||||
void OnMouseEnter(int toolIndex);
|
||||
|
||||
inline int GetSelection() const { return m_currentlySelected; }
|
||||
void SetSelection(int sel);
|
||||
|
||||
void SetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO);
|
||||
|
||||
protected:
|
||||
int m_currentlySelected;
|
||||
};
|
||||
|
||||
#define PALETTE_ARROW 200
|
||||
#define PALETTE_TEXT_TOOL 201
|
||||
|
||||
#endif
|
||||
// _STUDIO_CSPALETTE_H_
|
320
samples/ogl/studio/csprint.cpp
Normal file
@@ -0,0 +1,320 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: csprint.cpp
|
||||
// Purpose: Printing and clipboard functionality
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 12/07/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
// #pragma implementation
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include <wx/wxprec.h>
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include <wx/wx.h>
|
||||
#endif
|
||||
|
||||
#include <wx/wxexpr.h>
|
||||
#include <wx/clipbrd.h>
|
||||
|
||||
#ifdef __WXMSW__
|
||||
#include <wx/metafile.h>
|
||||
#endif
|
||||
|
||||
#include "studio.h"
|
||||
#include "doc.h"
|
||||
#include "shapes.h"
|
||||
#include "view.h"
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxDiagramClipboard, wxDiagram)
|
||||
|
||||
// Copy selection
|
||||
bool wxDiagramClipboard::Copy(wxDiagram* diagram)
|
||||
{
|
||||
DeleteAllShapes();
|
||||
|
||||
return DoCopy(diagram, this, FALSE, NULL);
|
||||
}
|
||||
|
||||
// Copy contents to the diagram, with new ids.
|
||||
|
||||
bool wxDiagramClipboard::Paste(wxDiagram* diagram, wxDC* dc, int offsetX, int offsetY)
|
||||
{
|
||||
return DoCopy(this, diagram, TRUE, dc, offsetX, offsetY);
|
||||
}
|
||||
|
||||
// Universal copy function (to or from clipboard).
|
||||
// TODO:
|
||||
// Note that this only works for non-composites so far (nested shapes
|
||||
// don't have their old-to-new object mappings stored).
|
||||
// Also, lines don't yet get their attachment points moved to the new offset position
|
||||
// if they have more than 2 points.
|
||||
bool wxDiagramClipboard::DoCopy(wxDiagram* diagramFrom, wxDiagram* diagramTo, bool newIds,
|
||||
wxDC* dc, int offsetX, int offsetY)
|
||||
{
|
||||
OnStartCopy(diagramTo);
|
||||
|
||||
wxHashTable mapping(wxKEY_INTEGER);
|
||||
|
||||
// First copy all node shapes.
|
||||
wxList* shapeList = diagramFrom->GetShapeList();
|
||||
wxNode* node = shapeList->First();
|
||||
while (node)
|
||||
{
|
||||
wxShape* shape = (wxShape*) node->Data();
|
||||
if (((diagramFrom == this) || shape->Selected()) && !shape->IsKindOf(CLASSINFO(wxLineShape)))
|
||||
{
|
||||
wxShape* newShape = shape->CreateNewCopy();
|
||||
newShape->GetLines().Clear();
|
||||
if (newIds)
|
||||
{
|
||||
newShape->AssignNewIds();
|
||||
}
|
||||
mapping.Put((long) shape, (wxObject*) newShape);
|
||||
|
||||
newShape->SetX(newShape->GetX() + offsetX);
|
||||
newShape->SetY(newShape->GetY() + offsetY);
|
||||
|
||||
OnAddShape(diagramTo, newShape, dc);
|
||||
|
||||
}
|
||||
node = node->Next();
|
||||
}
|
||||
|
||||
node = shapeList->First();
|
||||
while (node)
|
||||
{
|
||||
wxShape* shape = (wxShape*) node->Data();
|
||||
if (((diagramFrom == this) || shape->Selected()) && shape->IsKindOf(CLASSINFO(wxLineShape)))
|
||||
{
|
||||
wxLineShape* lineShape = (wxLineShape*) shape;
|
||||
// Only copy a line if its ends are selected too.
|
||||
if ((diagramFrom == this) || (lineShape->GetTo()->Selected() && lineShape->GetFrom()->Selected()))
|
||||
{
|
||||
wxLineShape* newShape = (wxLineShape*) shape->CreateNewCopy();
|
||||
mapping.Put((long) shape, (wxObject*) newShape);
|
||||
|
||||
if (newIds)
|
||||
newShape->AssignNewIds();
|
||||
|
||||
wxShape* fromShape = (wxShape*) mapping.Get((long) lineShape->GetFrom());
|
||||
wxShape* toShape = (wxShape*) mapping.Get((long) lineShape->GetTo());
|
||||
|
||||
wxASSERT_MSG( (fromShape != NULL), "Could not find 'from' shape");
|
||||
wxASSERT_MSG( (toShape != NULL), "Could not find 'to' shape");
|
||||
|
||||
fromShape->AddLine(newShape, toShape, newShape->GetAttachmentFrom(),
|
||||
newShape->GetAttachmentTo());
|
||||
|
||||
OnAddShape(diagramTo, newShape, dc);
|
||||
|
||||
}
|
||||
}
|
||||
node = node->Next();
|
||||
}
|
||||
|
||||
// Now make sure line ordering is correct
|
||||
node = shapeList->First();
|
||||
while (node)
|
||||
{
|
||||
wxShape* shape = (wxShape*) node->Data();
|
||||
if (((diagramFrom == this) || shape->Selected()) && !shape->IsKindOf(CLASSINFO(wxLineShape)))
|
||||
{
|
||||
wxShape* newShape = (wxShape*) mapping.Get((long) shape);
|
||||
|
||||
// Make a list of all the new lines, in the same order as the old lines.
|
||||
// Then apply the list of new lines to the shape.
|
||||
wxList newLines;
|
||||
wxNode* lineNode = shape->GetLines().First();
|
||||
while (lineNode)
|
||||
{
|
||||
wxLineShape* lineShape = (wxLineShape*) lineNode->Data();
|
||||
if ((diagramFrom == this) || (lineShape->GetTo()->Selected() && lineShape->GetFrom()->Selected()))
|
||||
{
|
||||
wxLineShape* newLineShape = (wxLineShape*) mapping.Get((long) lineShape);
|
||||
|
||||
wxASSERT_MSG( (newLineShape != NULL), "Could not find new line shape");
|
||||
|
||||
newLines.Append(newLineShape);
|
||||
}
|
||||
|
||||
lineNode = lineNode->Next();
|
||||
}
|
||||
|
||||
if (newLines.Number() > 0)
|
||||
newShape->ApplyAttachmentOrdering(newLines);
|
||||
}
|
||||
node = node->Next();
|
||||
}
|
||||
|
||||
OnEndCopy(diagramTo);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#ifdef __WXMSW__
|
||||
// Draw contents to a Windows metafile device context and a bitmap, and copy
|
||||
// these to the Windows clipboard
|
||||
bool wxDiagramClipboard::CopyToClipboard(double scale)
|
||||
{
|
||||
// Make a metafile DC
|
||||
wxMetaFileDC mfDC;
|
||||
if (mfDC.Ok())
|
||||
{
|
||||
mfDC.SetUserScale(scale, scale);
|
||||
|
||||
// Draw on metafile DC
|
||||
Redraw(mfDC);
|
||||
|
||||
int printWidth = mfDC.MaxX() - mfDC.MinX();
|
||||
int printHeight = mfDC.MaxY() - mfDC.MinY();
|
||||
int maxX = (int)mfDC.MaxX();
|
||||
int maxY = (int)mfDC.MaxY();
|
||||
wxMetaFile *mf = mfDC.Close();
|
||||
|
||||
// Set to a bitmap memory DC
|
||||
wxBitmap *newBitmap = new wxBitmap((int)(maxX + 10), (int)(maxY + 10));
|
||||
if (!newBitmap->Ok())
|
||||
{
|
||||
delete newBitmap;
|
||||
|
||||
char buf[200];
|
||||
sprintf(buf, "Sorry, could not allocate clipboard bitmap (%dx%d)", (maxX+10), (maxY+10));
|
||||
wxMessageBox(buf, "Clipboard copy problem");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
wxMemoryDC memDC;
|
||||
memDC.SelectObject(*newBitmap);
|
||||
memDC.Clear();
|
||||
|
||||
// Now draw on memory bitmap DC
|
||||
Redraw(memDC);
|
||||
|
||||
memDC.SelectObject(wxNullBitmap);
|
||||
|
||||
// Open clipboard and set the data
|
||||
if (wxOpenClipboard())
|
||||
{
|
||||
wxEmptyClipboard();
|
||||
|
||||
// Copy the bitmap to the clipboard
|
||||
wxSetClipboardData(wxDF_BITMAP, newBitmap, 0, 0);
|
||||
|
||||
#if 0 // TODO: replace this code (wxEnhMetaFile doesn't have SetClipboard)
|
||||
if (mf)
|
||||
{
|
||||
// Copy the metafile to the clipboard
|
||||
// Allow a small margin
|
||||
bool success = mf->SetClipboard((int)(mfDC.MaxX() + 15), (int)(mfDC.MaxY() + 15));
|
||||
}
|
||||
#endif
|
||||
|
||||
// Close clipboard
|
||||
wxCloseClipboard();
|
||||
}
|
||||
|
||||
delete newBitmap;
|
||||
delete mf;
|
||||
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
// __WXMSW__
|
||||
|
||||
// Override this to e.g. have the shape added through a Do/Undo command system.
|
||||
// By default, we'll just add it directly to the destination diagram.
|
||||
bool wxDiagramClipboard::OnAddShape(wxDiagram* diagramTo, wxShape* newShape, wxDC* dc)
|
||||
{
|
||||
diagramTo->AddShape(newShape);
|
||||
|
||||
if (dc && (diagramTo != this))
|
||||
{
|
||||
newShape->Select(TRUE, dc);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* csDiagramClipboard
|
||||
*/
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(csDiagramClipboard, wxDiagramClipboard)
|
||||
|
||||
// Start/end copying
|
||||
bool csDiagramClipboard::OnStartCopy(wxDiagram* diagramTo)
|
||||
{
|
||||
// Do nothing if copying to the clipboard
|
||||
if (diagramTo == this)
|
||||
return TRUE;
|
||||
|
||||
// Deselect all objects initially.
|
||||
|
||||
csDiagram* diagram = (csDiagram*) diagramTo;
|
||||
csDiagramDocument* doc = diagram->GetDocument();
|
||||
((csDiagramView*)doc->GetFirstView())->SelectAll(FALSE);
|
||||
|
||||
m_currentCmd = new csDiagramCommand("Paste", doc);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool csDiagramClipboard::OnEndCopy(wxDiagram* diagramTo)
|
||||
{
|
||||
// Do nothing if copying to the clipboard
|
||||
if (diagramTo == this)
|
||||
return TRUE;
|
||||
|
||||
csDiagram* diagram = (csDiagram*) diagramTo;
|
||||
csDiagramDocument* doc = diagram->GetDocument();
|
||||
|
||||
if (m_currentCmd)
|
||||
{
|
||||
if (m_currentCmd->GetStates().Number() == 0)
|
||||
{
|
||||
delete m_currentCmd;
|
||||
}
|
||||
else
|
||||
{
|
||||
doc->GetCommandProcessor()->Submit(m_currentCmd);
|
||||
m_currentCmd = NULL;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Use the command framework to add the shapes, if we're copying to a diagram and
|
||||
// not the clipboard.
|
||||
bool csDiagramClipboard::OnAddShape(wxDiagram* diagramTo, wxShape* newShape, wxDC* dc)
|
||||
{
|
||||
if (diagramTo == this)
|
||||
{
|
||||
diagramTo->AddShape(newShape);
|
||||
}
|
||||
else
|
||||
{
|
||||
csDiagram* diagram = (csDiagram*) diagramTo;
|
||||
csDiagramDocument* doc = diagram->GetDocument();
|
||||
|
||||
if (newShape->IsKindOf(CLASSINFO(wxLineShape)))
|
||||
m_currentCmd->AddState(new csCommandState(ID_CS_ADD_LINE_SELECT, newShape, NULL));
|
||||
else
|
||||
m_currentCmd->AddState(new csCommandState(ID_CS_ADD_SHAPE_SELECT, newShape, NULL));
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
525
samples/ogl/studio/dialogs.cpp
Normal file
@@ -0,0 +1,525 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: dialogs.cpp
|
||||
// Purpose: Implements Studio dialogs
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 12/07/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence:
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
// #pragma implementation
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include <wx/wxprec.h>
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include <wx/wx.h>
|
||||
#endif
|
||||
|
||||
#include <wx/resource.h>
|
||||
#include "dialogs.h"
|
||||
#include "doc.h"
|
||||
#include "view.h"
|
||||
#include "studio.h"
|
||||
#include "studio_resources.h"
|
||||
|
||||
IMPLEMENT_CLASS(csLabelEditingDialog, wxDialog)
|
||||
|
||||
BEGIN_EVENT_TABLE(csLabelEditingDialog, wxDialog)
|
||||
EVT_BUTTON(wxID_OK, csLabelEditingDialog::OnOK)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
csLabelEditingDialog::csLabelEditingDialog(wxWindow* parent)
|
||||
{
|
||||
LoadFromResource(parent, "shape_label_dialog");
|
||||
|
||||
// Accelerators
|
||||
wxAcceleratorEntry entries[1];
|
||||
entries[0].Set(wxACCEL_CTRL, WXK_RETURN, wxID_OK);
|
||||
wxAcceleratorTable accel(1, entries);
|
||||
SetAcceleratorTable(accel);
|
||||
|
||||
Centre();
|
||||
|
||||
wxTextCtrl* textCtrl = (wxTextCtrl*) FindWindow(ID_LABELTEXT);
|
||||
wxASSERT( (textCtrl != NULL) );
|
||||
|
||||
// textCtrl->SetAcceleratorTable(accel);
|
||||
|
||||
textCtrl->SetFocus();
|
||||
}
|
||||
|
||||
void csLabelEditingDialog::OnOK(wxCommandEvent& event)
|
||||
{
|
||||
wxTextCtrl* textCtrl = (wxTextCtrl*) FindWindow(ID_LABELTEXT);
|
||||
wxASSERT( (textCtrl != NULL) );
|
||||
|
||||
SetShapeLabel(textCtrl->GetValue());
|
||||
|
||||
wxDialog::OnOK(event);
|
||||
}
|
||||
|
||||
void csLabelEditingDialog::SetShapeLabel(const wxString& label)
|
||||
{
|
||||
wxTextCtrl* textCtrl = (wxTextCtrl*) FindWindow(ID_LABELTEXT);
|
||||
wxASSERT( (textCtrl != NULL) );
|
||||
|
||||
m_label = label;
|
||||
|
||||
textCtrl->SetValue(label);
|
||||
}
|
||||
|
||||
IMPLEMENT_CLASS(csSettingsDialog, wxDialog)
|
||||
|
||||
BEGIN_EVENT_TABLE(csSettingsDialog, wxDialog)
|
||||
EVT_BUTTON(wxID_OK, csSettingsDialog::OnOK)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
#define PROPERTY_DIALOG_WIDTH 400
|
||||
#define PROPERTY_DIALOG_HEIGHT 400
|
||||
|
||||
// For 400x400 settings dialog, size your panels to about 375x325 in dialog editor
|
||||
|
||||
csSettingsDialog::csSettingsDialog(wxWindow* parent):
|
||||
wxDialog(parent, -1, "Settings", wxPoint(0, 0), wxSize(PROPERTY_DIALOG_WIDTH, PROPERTY_DIALOG_HEIGHT))
|
||||
{
|
||||
m_generalSettings = NULL;
|
||||
m_diagramSettings = NULL;
|
||||
|
||||
m_notebook = new wxNotebook(this, ID_PROPERTY_NOTEBOOK,
|
||||
wxPoint(2, 2), wxSize(PROPERTY_DIALOG_WIDTH - 4, PROPERTY_DIALOG_HEIGHT - 4));
|
||||
|
||||
m_generalSettings = new wxPanel;
|
||||
|
||||
bool success = m_generalSettings->LoadFromResource(m_notebook, "general_settings_dialog");
|
||||
wxASSERT_MSG( (success), "Could not load general settings panel.");
|
||||
m_notebook->AddPage(m_generalSettings, "General", TRUE);
|
||||
|
||||
m_diagramSettings = new wxPanel;
|
||||
|
||||
success = m_diagramSettings->LoadFromResource(m_notebook, "diagram_settings_dialog");
|
||||
wxASSERT_MSG( (success), "Could not load diagram settings panel.");
|
||||
m_notebook->AddPage(m_diagramSettings, "Diagram");
|
||||
|
||||
int largeButtonWidth = 70;
|
||||
int largeButtonHeight = 22;
|
||||
|
||||
wxButton* okButton = new wxButton(this, wxID_OK, "OK", wxPoint(0, 0), wxSize(largeButtonWidth, largeButtonHeight));
|
||||
wxButton* cancelButton = new wxButton(this, wxID_CANCEL, "Cancel", wxPoint(0, 0), wxSize(largeButtonWidth, largeButtonHeight));
|
||||
wxButton* helpButton = new wxButton(this, wxID_HELP, "Help", wxPoint(0, 0), wxSize(largeButtonWidth, largeButtonHeight));
|
||||
|
||||
// Constraints for the notebook
|
||||
wxLayoutConstraints *c = new wxLayoutConstraints;
|
||||
c->top.SameAs (this, wxTop, 5);
|
||||
c->left.SameAs (this, wxLeft, 5);
|
||||
c->right.SameAs (this, wxRight, 5);
|
||||
c->bottom.SameAs (cancelButton, wxTop, 5);
|
||||
m_notebook->SetConstraints(c);
|
||||
|
||||
// Constraints for the Help button
|
||||
c = new wxLayoutConstraints;
|
||||
c->width.AsIs();
|
||||
c->height.AsIs();
|
||||
c->right.SameAs (this, wxRight, 5);
|
||||
c->bottom.SameAs (this, wxBottom, 5);
|
||||
helpButton->SetConstraints(c);
|
||||
|
||||
// Constraints for the Cancel button
|
||||
c = new wxLayoutConstraints;
|
||||
c->width.AsIs();
|
||||
c->height.AsIs();
|
||||
c->right.SameAs (helpButton, wxLeft, 5);
|
||||
c->bottom.SameAs (this, wxBottom, 5);
|
||||
cancelButton->SetConstraints(c);
|
||||
|
||||
// Constraints for the OK button
|
||||
c = new wxLayoutConstraints;
|
||||
c->width.AsIs();
|
||||
c->height.AsIs();
|
||||
c->right.SameAs (cancelButton, wxLeft, 5);
|
||||
c->bottom.SameAs (this, wxBottom, 5);
|
||||
okButton->SetConstraints(c);
|
||||
|
||||
okButton->SetDefault();
|
||||
okButton->SetFocus();
|
||||
|
||||
Layout();
|
||||
Centre(wxBOTH);
|
||||
}
|
||||
|
||||
void csSettingsDialog::OnOK(wxCommandEvent& event)
|
||||
{
|
||||
wxDialog::OnOK(event);
|
||||
}
|
||||
|
||||
bool csSettingsDialog::TransferDataToWindow()
|
||||
{
|
||||
wxTextCtrl* gridSpacing = (wxTextCtrl*) m_diagramSettings->FindWindow(ID_GRID_SPACING);
|
||||
wxASSERT_MSG( (gridSpacing != (wxTextCtrl*) NULL), "Could not find grid spacing control.");
|
||||
|
||||
wxChoice* gridStyle = (wxChoice*) m_diagramSettings->FindWindow(ID_GRID_STYLE);
|
||||
wxASSERT_MSG( (gridStyle != (wxChoice*) NULL), "Could not find grid style control.");
|
||||
|
||||
gridStyle->SetSelection(wxGetApp().GetGridStyle());
|
||||
|
||||
wxString str;
|
||||
str.Printf("%d", wxGetApp().GetGridSpacing());
|
||||
gridSpacing->SetValue(str);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool csSettingsDialog::TransferDataFromWindow()
|
||||
{
|
||||
wxTextCtrl* gridSpacing = (wxTextCtrl*) m_diagramSettings->FindWindow(ID_GRID_SPACING);
|
||||
wxASSERT_MSG( (gridSpacing != (wxTextCtrl*) NULL), "Could not find grid spacing control.");
|
||||
|
||||
wxChoice* gridStyle = (wxChoice*) m_diagramSettings->FindWindow(ID_GRID_STYLE);
|
||||
wxASSERT_MSG( (gridStyle != (wxChoice*) NULL), "Could not find grid style control.");
|
||||
|
||||
wxGetApp().SetGridStyle(gridStyle->GetSelection());
|
||||
wxGetApp().SetGridSpacing(atoi(gridSpacing->GetValue()));
|
||||
|
||||
if (wxGetApp().GetGridStyle() == csGRID_STYLE_DOTTED)
|
||||
{
|
||||
wxMessageBox("Dotted grid style not yet implemented.", "Studio", wxICON_EXCLAMATION);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Apply settings to all open diagram documents
|
||||
wxNode* node = wxGetApp().GetDocManager()->GetDocuments().First();
|
||||
while (node)
|
||||
{
|
||||
wxDocument* doc = (wxDocument*) node->Data();
|
||||
if (doc->IsKindOf(CLASSINFO(csDiagramDocument)))
|
||||
{
|
||||
csDiagramDocument* diagramDoc = (csDiagramDocument*) doc;
|
||||
wxDiagram* diagram = (wxDiagram*) diagramDoc->GetDiagram();
|
||||
|
||||
diagram->SetGridSpacing((double) wxGetApp().GetGridSpacing());
|
||||
switch (wxGetApp().GetGridStyle())
|
||||
{
|
||||
case csGRID_STYLE_NONE:
|
||||
{
|
||||
diagram->SetSnapToGrid(FALSE);
|
||||
break;
|
||||
}
|
||||
case csGRID_STYLE_INVISIBLE:
|
||||
{
|
||||
diagram->SetSnapToGrid(TRUE);
|
||||
break;
|
||||
}
|
||||
case csGRID_STYLE_DOTTED:
|
||||
{
|
||||
// TODO (not implemented in OGL)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
node = node->Next();
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Shape properties dialog (tabbed)
|
||||
*/
|
||||
|
||||
|
||||
IMPLEMENT_CLASS(csShapePropertiesDialog, wxDialog)
|
||||
|
||||
BEGIN_EVENT_TABLE(csShapePropertiesDialog, wxDialog)
|
||||
EVT_BUTTON(wxID_OK, csShapePropertiesDialog::OnOK)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
#define SHAPE_PROPERTY_DIALOG_WIDTH 400
|
||||
#define SHAPE_PROPERTY_DIALOG_HEIGHT 400
|
||||
|
||||
// For 400x400 settings dialog, size your panels to about 375x325 in dialog editor
|
||||
|
||||
csShapePropertiesDialog::csShapePropertiesDialog(wxWindow* parent, const wxString& title,
|
||||
wxPanel* attributeDialog, const wxString& attributeDialogName):
|
||||
wxDialog(parent, -1, title, wxPoint(0, 0), wxSize(SHAPE_PROPERTY_DIALOG_WIDTH, SHAPE_PROPERTY_DIALOG_HEIGHT))
|
||||
{
|
||||
m_attributeDialog = attributeDialog;
|
||||
m_alternativeAttributeDialog = NULL;
|
||||
m_generalPropertiesDialog = NULL;
|
||||
|
||||
m_notebook = new wxNotebook(this, ID_SHAPE_PROPERTY_NOTEBOOK,
|
||||
wxPoint(2, 2), wxSize(SHAPE_PROPERTY_DIALOG_WIDTH - 4, SHAPE_PROPERTY_DIALOG_HEIGHT - 4));
|
||||
|
||||
m_generalPropertiesDialog = new csGeneralShapePropertiesDialog;
|
||||
bool success = m_generalPropertiesDialog->LoadFromResource(m_notebook, "general_shape_properties_dialog");
|
||||
wxASSERT_MSG( (success), "Could not load general properties panel.");
|
||||
m_notebook->AddPage(m_generalPropertiesDialog, "General");
|
||||
|
||||
success = m_attributeDialog->LoadFromResource(m_notebook, attributeDialogName);
|
||||
if (!success)
|
||||
{
|
||||
wxMessageBox("Could not load the attribute dialog for this shape.", "Studio", wxICON_EXCLAMATION);
|
||||
delete m_attributeDialog;
|
||||
m_attributeDialog = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_notebook->AddPage(m_attributeDialog, "Attributes");
|
||||
}
|
||||
|
||||
// Try the alternative dialog (test code)
|
||||
wxString str(attributeDialogName);
|
||||
str += "1";
|
||||
m_alternativeAttributeDialog = new wxPanel;
|
||||
success = m_alternativeAttributeDialog->LoadFromResource(m_notebook, str);
|
||||
if (success)
|
||||
{
|
||||
m_notebook->AddPage(m_alternativeAttributeDialog, "Attributes (alternative)");
|
||||
}
|
||||
else
|
||||
{
|
||||
delete m_alternativeAttributeDialog;
|
||||
m_alternativeAttributeDialog = NULL;
|
||||
}
|
||||
|
||||
int largeButtonWidth = 70;
|
||||
int largeButtonHeight = 22;
|
||||
|
||||
wxButton* okButton = new wxButton(this, wxID_OK, "OK", wxPoint(0, 0), wxSize(largeButtonWidth, largeButtonHeight));
|
||||
wxButton* cancelButton = new wxButton(this, wxID_CANCEL, "Cancel", wxPoint(0, 0), wxSize(largeButtonWidth, largeButtonHeight));
|
||||
wxButton* helpButton = new wxButton(this, wxID_HELP, "Help", wxPoint(0, 0), wxSize(largeButtonWidth, largeButtonHeight));
|
||||
|
||||
// Constraints for the notebook
|
||||
wxLayoutConstraints *c = new wxLayoutConstraints;
|
||||
c->top.SameAs (this, wxTop, 5);
|
||||
c->left.SameAs (this, wxLeft, 5);
|
||||
c->right.SameAs (this, wxRight, 5);
|
||||
c->bottom.SameAs (helpButton, wxTop, 5);
|
||||
m_notebook->SetConstraints(c);
|
||||
|
||||
// Constraints for the Help button
|
||||
c = new wxLayoutConstraints;
|
||||
c->width.AsIs();
|
||||
c->height.AsIs();
|
||||
c->right.SameAs (this, wxRight, 5);
|
||||
c->bottom.SameAs (this, wxBottom, 5);
|
||||
helpButton->SetConstraints(c);
|
||||
|
||||
// Constraints for the Cancel button
|
||||
c = new wxLayoutConstraints;
|
||||
c->width.AsIs();
|
||||
c->height.AsIs();
|
||||
c->right.SameAs (helpButton, wxLeft, 5);
|
||||
c->bottom.SameAs (this, wxBottom, 5);
|
||||
cancelButton->SetConstraints(c);
|
||||
|
||||
// Constraints for the OK button
|
||||
c = new wxLayoutConstraints;
|
||||
c->width.AsIs();
|
||||
c->height.AsIs();
|
||||
c->right.SameAs (cancelButton, wxLeft, 5);
|
||||
c->bottom.SameAs (this, wxBottom, 5);
|
||||
okButton->SetConstraints(c);
|
||||
|
||||
okButton->SetDefault();
|
||||
okButton->SetFocus();
|
||||
|
||||
SetDefaults();
|
||||
|
||||
Layout();
|
||||
Centre(wxBOTH);
|
||||
}
|
||||
|
||||
void csShapePropertiesDialog::OnOK(wxCommandEvent& event)
|
||||
{
|
||||
wxTextCtrl* textCtrl = (wxTextCtrl*) m_generalPropertiesDialog->FindWindow(ID_LABELTEXT);
|
||||
wxASSERT( (textCtrl != NULL) );
|
||||
|
||||
m_generalPropertiesDialog->SetShapeLabel(textCtrl->GetValue());
|
||||
|
||||
wxDialog::OnOK(event);
|
||||
}
|
||||
|
||||
// Set some suitable defaults in the attribute dialogs (in the first instance,
|
||||
// just set all wxChoices to the first element)
|
||||
void csShapePropertiesDialog::SetDefaults()
|
||||
{
|
||||
if (!m_attributeDialog)
|
||||
return;
|
||||
|
||||
wxNode* node = m_attributeDialog->GetChildren().First();
|
||||
while (node)
|
||||
{
|
||||
wxWindow* child = (wxWindow*) node->Data();
|
||||
if (child->IsKindOf(CLASSINFO(wxChoice)))
|
||||
{
|
||||
wxChoice* choice = (wxChoice*) child;
|
||||
choice->SetSelection(0);
|
||||
}
|
||||
node = node->Next();
|
||||
}
|
||||
|
||||
if (!m_alternativeAttributeDialog)
|
||||
return;
|
||||
|
||||
node = m_alternativeAttributeDialog->GetChildren().First();
|
||||
while (node)
|
||||
{
|
||||
wxWindow* child = (wxWindow*) node->Data();
|
||||
if (child->IsKindOf(CLASSINFO(wxChoice)))
|
||||
{
|
||||
wxChoice* choice = (wxChoice*) child;
|
||||
choice->SetSelection(0);
|
||||
}
|
||||
node = node->Next();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* csGeneralShapePropertiesDialog
|
||||
*/
|
||||
|
||||
IMPLEMENT_CLASS(csGeneralShapePropertiesDialog, wxPanel)
|
||||
|
||||
BEGIN_EVENT_TABLE(csGeneralShapePropertiesDialog, wxPanel)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
csGeneralShapePropertiesDialog::csGeneralShapePropertiesDialog()
|
||||
{
|
||||
}
|
||||
|
||||
void csGeneralShapePropertiesDialog::SetShapeLabel(const wxString& label)
|
||||
{
|
||||
wxTextCtrl* textCtrl = (wxTextCtrl*) FindWindow(ID_LABELTEXT);
|
||||
wxASSERT( (textCtrl != NULL) );
|
||||
|
||||
m_label = label;
|
||||
|
||||
textCtrl->SetValue(label);
|
||||
}
|
||||
|
||||
/*
|
||||
* csThinRectangleDialog
|
||||
*/
|
||||
|
||||
IMPLEMENT_CLASS(csThinRectangleDialog, wxPanel)
|
||||
|
||||
BEGIN_EVENT_TABLE(csThinRectangleDialog, wxPanel)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
csThinRectangleDialog::csThinRectangleDialog()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* csWideRectangleDialog
|
||||
*/
|
||||
|
||||
IMPLEMENT_CLASS(csWideRectangleDialog, wxPanel)
|
||||
|
||||
BEGIN_EVENT_TABLE(csWideRectangleDialog, wxPanel)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
csWideRectangleDialog::csWideRectangleDialog()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* csTriangleDialog
|
||||
*/
|
||||
|
||||
IMPLEMENT_CLASS(csTriangleDialog, wxPanel)
|
||||
|
||||
BEGIN_EVENT_TABLE(csTriangleDialog, wxPanel)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
csTriangleDialog::csTriangleDialog()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* csSemiCircleDialog
|
||||
*/
|
||||
|
||||
IMPLEMENT_CLASS(csSemiCircleDialog, wxPanel)
|
||||
|
||||
BEGIN_EVENT_TABLE(csSemiCircleDialog, wxPanel)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
csSemiCircleDialog::csSemiCircleDialog()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* csCircleDialog
|
||||
*/
|
||||
|
||||
IMPLEMENT_CLASS(csCircleDialog, wxPanel)
|
||||
|
||||
BEGIN_EVENT_TABLE(csCircleDialog, wxPanel)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
csCircleDialog::csCircleDialog()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* csCircleShadowDialog
|
||||
*/
|
||||
|
||||
IMPLEMENT_CLASS(csCircleShadowDialog, wxPanel)
|
||||
|
||||
BEGIN_EVENT_TABLE(csCircleShadowDialog, wxPanel)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
csCircleShadowDialog::csCircleShadowDialog()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* csOctagonDialog
|
||||
*/
|
||||
|
||||
IMPLEMENT_CLASS(csOctagonDialog, wxPanel)
|
||||
|
||||
BEGIN_EVENT_TABLE(csOctagonDialog, wxPanel)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
csOctagonDialog::csOctagonDialog()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* csGroupDialog
|
||||
*/
|
||||
|
||||
IMPLEMENT_CLASS(csGroupDialog, wxPanel)
|
||||
|
||||
BEGIN_EVENT_TABLE(csGroupDialog, wxPanel)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
csGroupDialog::csGroupDialog()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* csTextBoxDialog
|
||||
*/
|
||||
|
||||
IMPLEMENT_CLASS(csTextBoxDialog, wxPanel)
|
||||
|
||||
BEGIN_EVENT_TABLE(csTextBoxDialog, wxPanel)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
csTextBoxDialog::csTextBoxDialog()
|
||||
{
|
||||
}
|
||||
|
||||
|
248
samples/ogl/studio/dialogs.h
Normal file
@@ -0,0 +1,248 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: dialogs.h
|
||||
// Purpose: Miscellaneous dialogs
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 12/07/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence:
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _STUDIO_DIALOGS_H_
|
||||
#define _STUDIO_DIALOGS_H_
|
||||
|
||||
#ifdef __GNUG__
|
||||
// #pragma interface
|
||||
#endif
|
||||
|
||||
#include <wx/wx.h>
|
||||
#include <wx/notebook.h>
|
||||
|
||||
/*
|
||||
* Label editing dialog (about to become obsolete)
|
||||
*/
|
||||
|
||||
class csLabelEditingDialog: public wxDialog
|
||||
{
|
||||
DECLARE_CLASS(csLabelEditingDialog)
|
||||
public:
|
||||
csLabelEditingDialog(wxWindow* parent);
|
||||
|
||||
void SetShapeLabel(const wxString& label);
|
||||
inline wxString GetShapeLabel() const { return m_label; }
|
||||
|
||||
void OnOK(wxCommandEvent& event);
|
||||
|
||||
protected:
|
||||
wxString m_label;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
/*
|
||||
* Settings dialog (tabbed)
|
||||
*/
|
||||
|
||||
class csSettingsDialog: public wxDialog
|
||||
{
|
||||
DECLARE_CLASS(csSettingsDialog)
|
||||
public:
|
||||
csSettingsDialog(wxWindow* parent);
|
||||
|
||||
void OnOK(wxCommandEvent& event);
|
||||
|
||||
virtual bool TransferDataToWindow();
|
||||
virtual bool TransferDataFromWindow();
|
||||
|
||||
protected:
|
||||
|
||||
wxPanel* m_generalSettings;
|
||||
wxPanel* m_diagramSettings;
|
||||
wxNotebook* m_notebook;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
#define ID_PROPERTY_NOTEBOOK 1000
|
||||
#define ID_GENERAL_SETTINGS 1002
|
||||
#define ID_DIAGRAM_SETTINGS 1003
|
||||
|
||||
/*
|
||||
* csGeneralShapePropertiesDialog
|
||||
* Name, description etc.
|
||||
*/
|
||||
|
||||
class csGeneralShapePropertiesDialog: public wxPanel
|
||||
{
|
||||
DECLARE_CLASS(csGeneralShapePropertiesDialog)
|
||||
public:
|
||||
csGeneralShapePropertiesDialog();
|
||||
|
||||
void SetShapeLabel(const wxString& label);
|
||||
inline wxString GetShapeLabel() const { return m_label; }
|
||||
|
||||
protected:
|
||||
wxString m_label;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
/*
|
||||
* Shape properties dialog (tabbed)
|
||||
*/
|
||||
|
||||
class csShapePropertiesDialog: public wxDialog
|
||||
{
|
||||
DECLARE_CLASS(csShapePropertiesDialog)
|
||||
public:
|
||||
csShapePropertiesDialog(wxWindow* parent, const wxString& title, wxPanel* attributeDialog, const wxString& attributeDialogName);
|
||||
|
||||
void OnOK(wxCommandEvent& event);
|
||||
|
||||
// Set some suitable defaults in the attribute dialogs (in the first instance,
|
||||
// just set all wxChoices to the first element)
|
||||
void SetDefaults();
|
||||
|
||||
// Accessors
|
||||
csGeneralShapePropertiesDialog* GetGeneralPropertiesDialog() const { return m_generalPropertiesDialog; }
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Attributes, specific to each shape
|
||||
wxPanel* m_attributeDialog;
|
||||
wxPanel* m_alternativeAttributeDialog;
|
||||
|
||||
// General properties, same for each shape, e.g. name/description
|
||||
csGeneralShapePropertiesDialog* m_generalPropertiesDialog;
|
||||
|
||||
wxNotebook* m_notebook;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
#define ID_SHAPE_PROPERTY_NOTEBOOK 1000
|
||||
|
||||
//// Specific attribute-editing panel classes below here
|
||||
|
||||
/*
|
||||
* csThinRectangleDialog
|
||||
*/
|
||||
|
||||
class csThinRectangleDialog: public wxPanel
|
||||
{
|
||||
DECLARE_CLASS(csThinRectangleDialog)
|
||||
public:
|
||||
csThinRectangleDialog();
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
/*
|
||||
* csWideRectangleDialog
|
||||
*/
|
||||
|
||||
class csWideRectangleDialog: public wxPanel
|
||||
{
|
||||
DECLARE_CLASS(csWideRectangleDialog)
|
||||
public:
|
||||
csWideRectangleDialog();
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
/*
|
||||
* csTriangleDialog
|
||||
*/
|
||||
|
||||
class csTriangleDialog: public wxPanel
|
||||
{
|
||||
DECLARE_CLASS(csTriangleDialog)
|
||||
public:
|
||||
csTriangleDialog();
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
/*
|
||||
* csSemiCircleDialog
|
||||
*/
|
||||
|
||||
class csSemiCircleDialog: public wxPanel
|
||||
{
|
||||
DECLARE_CLASS(csSemiCircleDialog)
|
||||
public:
|
||||
csSemiCircleDialog();
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
/*
|
||||
* csCircleDialog
|
||||
*/
|
||||
|
||||
class csCircleDialog: public wxPanel
|
||||
{
|
||||
DECLARE_CLASS(csCircleDialog)
|
||||
public:
|
||||
csCircleDialog();
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
/*
|
||||
* csCircleShadowDialog
|
||||
*/
|
||||
|
||||
class csCircleShadowDialog: public wxPanel
|
||||
{
|
||||
DECLARE_CLASS(csCircleShadowDialog)
|
||||
public:
|
||||
csCircleShadowDialog();
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
/*
|
||||
* csOctagonDialog
|
||||
*/
|
||||
|
||||
class csOctagonDialog: public wxPanel
|
||||
{
|
||||
DECLARE_CLASS(csOctagonDialog)
|
||||
public:
|
||||
csOctagonDialog();
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
/*
|
||||
* csGroupDialog
|
||||
*/
|
||||
|
||||
class csGroupDialog: public wxPanel
|
||||
{
|
||||
DECLARE_CLASS(csGroupDialog)
|
||||
public:
|
||||
csGroupDialog();
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
/*
|
||||
* csTextBoxDialog
|
||||
*/
|
||||
|
||||
class csTextBoxDialog: public wxPanel
|
||||
{
|
||||
DECLARE_CLASS(csTextBoxDialog)
|
||||
public:
|
||||
csTextBoxDialog();
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
// _STUDIO_DIALOGS_H_
|
598
samples/ogl/studio/doc.cpp
Normal file
@@ -0,0 +1,598 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: doc.cpp
|
||||
// Purpose: Implements document functionality
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 12/07/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
// #pragma implementation
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include <wx/wxprec.h>
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include <wx/wx.h>
|
||||
#endif
|
||||
|
||||
#include <wx/wxexpr.h>
|
||||
|
||||
#include "studio.h"
|
||||
#include "doc.h"
|
||||
#include "view.h"
|
||||
#include <wx/ogl/basicp.h>
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(csDiagramDocument, wxDocument)
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable:4355)
|
||||
#endif
|
||||
|
||||
csDiagramDocument::csDiagramDocument():m_diagram(this)
|
||||
{
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(default:4355)
|
||||
#endif
|
||||
|
||||
csDiagramDocument::~csDiagramDocument()
|
||||
{
|
||||
}
|
||||
|
||||
bool csDiagramDocument::OnCloseDocument()
|
||||
{
|
||||
m_diagram.DeleteAllShapes();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool csDiagramDocument::OnSaveDocument(const wxString& file)
|
||||
{
|
||||
if (file == "")
|
||||
return FALSE;
|
||||
|
||||
if (!m_diagram.SaveFile(file))
|
||||
{
|
||||
wxString msgTitle;
|
||||
if (wxTheApp->GetAppName() != "")
|
||||
msgTitle = wxTheApp->GetAppName();
|
||||
else
|
||||
msgTitle = wxString("File error");
|
||||
|
||||
(void)wxMessageBox("Sorry, could not open this file for saving.", msgTitle, wxOK | wxICON_EXCLAMATION,
|
||||
GetDocumentWindow());
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Modify(FALSE);
|
||||
SetFilename(file);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool csDiagramDocument::OnOpenDocument(const wxString& file)
|
||||
{
|
||||
if (!OnSaveModified())
|
||||
return FALSE;
|
||||
|
||||
wxString msgTitle;
|
||||
if (wxTheApp->GetAppName() != "")
|
||||
msgTitle = wxTheApp->GetAppName();
|
||||
else
|
||||
msgTitle = wxString("File error");
|
||||
|
||||
m_diagram.DeleteAllShapes();
|
||||
if (!m_diagram.LoadFile(file))
|
||||
{
|
||||
(void)wxMessageBox("Sorry, could not open this file.", msgTitle, wxOK|wxICON_EXCLAMATION,
|
||||
GetDocumentWindow());
|
||||
return FALSE;
|
||||
}
|
||||
SetFilename(file, TRUE);
|
||||
Modify(FALSE);
|
||||
UpdateAllViews();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Implementation of drawing command
|
||||
*/
|
||||
|
||||
csDiagramCommand::csDiagramCommand(const wxString& name, csDiagramDocument *doc,
|
||||
csCommandState* onlyState):
|
||||
wxCommand(TRUE, name)
|
||||
{
|
||||
m_doc = doc;
|
||||
|
||||
if (onlyState)
|
||||
{
|
||||
AddState(onlyState);
|
||||
}
|
||||
}
|
||||
|
||||
csDiagramCommand::~csDiagramCommand()
|
||||
{
|
||||
wxNode* node = m_states.First();
|
||||
while (node)
|
||||
{
|
||||
csCommandState* state = (csCommandState*) node->Data();
|
||||
delete state;
|
||||
node = node->Next();
|
||||
}
|
||||
}
|
||||
|
||||
void csDiagramCommand::AddState(csCommandState* state)
|
||||
{
|
||||
state->m_doc = m_doc;
|
||||
// state->m_cmd = m_cmd;
|
||||
m_states.Append(state);
|
||||
}
|
||||
|
||||
// Insert a state at the beginning of the list
|
||||
void csDiagramCommand::InsertState(csCommandState* state)
|
||||
{
|
||||
state->m_doc = m_doc;
|
||||
// state->m_cmd = m_cmd;
|
||||
m_states.Insert(state);
|
||||
}
|
||||
|
||||
// Schedule all lines connected to the states to be cut.
|
||||
void csDiagramCommand::RemoveLines()
|
||||
{
|
||||
wxNode* node = m_states.First();
|
||||
while (node)
|
||||
{
|
||||
csCommandState* state = (csCommandState*) node->Data();
|
||||
wxShape* shape = state->GetShapeOnCanvas();
|
||||
wxASSERT( (shape != NULL) );
|
||||
|
||||
wxNode *node1 = shape->GetLines().First();
|
||||
while (node1)
|
||||
{
|
||||
wxLineShape *line = (wxLineShape *)node1->Data();
|
||||
if (!FindStateByShape(line))
|
||||
{
|
||||
csCommandState* newState = new csCommandState(ID_CS_CUT, NULL, line);
|
||||
InsertState(newState);
|
||||
}
|
||||
|
||||
node1 = node1->Next();
|
||||
}
|
||||
node = node->Next();
|
||||
}
|
||||
}
|
||||
|
||||
csCommandState* csDiagramCommand::FindStateByShape(wxShape* shape)
|
||||
{
|
||||
wxNode* node = m_states.First();
|
||||
while (node)
|
||||
{
|
||||
csCommandState* state = (csCommandState*) node->Data();
|
||||
if (shape == state->GetShapeOnCanvas() || shape == state->GetSavedState())
|
||||
return state;
|
||||
node = node->Next();
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool csDiagramCommand::Do()
|
||||
{
|
||||
wxNode* node = m_states.First();
|
||||
while (node)
|
||||
{
|
||||
csCommandState* state = (csCommandState*) node->Data();
|
||||
if (!state->Do())
|
||||
return FALSE;
|
||||
node = node->Next();
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool csDiagramCommand::Undo()
|
||||
{
|
||||
// Undo in reverse order, so e.g. shapes get added
|
||||
// back before the lines do.
|
||||
wxNode* node = m_states.Last();
|
||||
while (node)
|
||||
{
|
||||
csCommandState* state = (csCommandState*) node->Data();
|
||||
if (!state->Undo())
|
||||
return FALSE;
|
||||
node = node->Previous();
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
csCommandState::csCommandState(int cmd, wxShape* savedState, wxShape* shapeOnCanvas)
|
||||
{
|
||||
m_cmd = cmd;
|
||||
m_doc = NULL;
|
||||
m_savedState = savedState;
|
||||
m_shapeOnCanvas = shapeOnCanvas;
|
||||
m_linePositionFrom = 0;
|
||||
m_linePositionTo = 0;
|
||||
}
|
||||
|
||||
csCommandState::~csCommandState()
|
||||
{
|
||||
if (m_savedState)
|
||||
{
|
||||
m_savedState->SetCanvas(NULL);
|
||||
delete m_savedState;
|
||||
}
|
||||
}
|
||||
|
||||
bool csCommandState::Do()
|
||||
{
|
||||
switch (m_cmd)
|
||||
{
|
||||
case ID_CS_CUT:
|
||||
{
|
||||
// New state is 'nothing' - maybe pass shape ID to state so we know what
|
||||
// we're talking about.
|
||||
// Then save old shape in m_savedState (actually swap pointers)
|
||||
|
||||
wxASSERT( (m_shapeOnCanvas != NULL) );
|
||||
wxASSERT( (m_savedState == NULL) ); // new state will be 'nothing'
|
||||
wxASSERT( (m_doc != NULL) );
|
||||
|
||||
wxShapeCanvas* canvas = m_shapeOnCanvas->GetCanvas();
|
||||
|
||||
// In case this is a line
|
||||
wxShape* lineFrom = NULL;
|
||||
wxShape* lineTo = NULL;
|
||||
int attachmentFrom = 0, attachmentTo = 0;
|
||||
|
||||
if (m_shapeOnCanvas->IsKindOf(CLASSINFO(wxLineShape)))
|
||||
{
|
||||
// Store the from/to info to save in the line shape
|
||||
wxLineShape* lineShape = (wxLineShape*) m_shapeOnCanvas;
|
||||
lineFrom = lineShape->GetFrom();
|
||||
lineTo = lineShape->GetTo();
|
||||
attachmentFrom = lineShape->GetAttachmentFrom();
|
||||
attachmentTo = lineShape->GetAttachmentTo();
|
||||
|
||||
m_linePositionFrom = lineFrom->GetLinePosition(lineShape);
|
||||
m_linePositionTo = lineTo->GetLinePosition(lineShape);
|
||||
}
|
||||
|
||||
m_shapeOnCanvas->Select(FALSE);
|
||||
((csDiagramView*) m_doc->GetFirstView())->SelectShape(m_shapeOnCanvas, FALSE);
|
||||
|
||||
m_shapeOnCanvas->Unlink();
|
||||
|
||||
m_doc->GetDiagram()->RemoveShape(m_shapeOnCanvas);
|
||||
|
||||
m_savedState = m_shapeOnCanvas;
|
||||
|
||||
if (m_savedState->IsKindOf(CLASSINFO(wxLineShape)))
|
||||
{
|
||||
// Restore the from/to info for future reference
|
||||
wxLineShape* lineShape = (wxLineShape*) m_savedState;
|
||||
lineShape->SetFrom(lineFrom);
|
||||
lineShape->SetTo(lineTo);
|
||||
lineShape->SetAttachments(attachmentFrom, attachmentTo);
|
||||
|
||||
wxClientDC dc(canvas);
|
||||
canvas->PrepareDC(dc);
|
||||
|
||||
lineFrom->MoveLinks(dc);
|
||||
lineTo->MoveLinks(dc);
|
||||
}
|
||||
|
||||
m_doc->Modify(TRUE);
|
||||
m_doc->UpdateAllViews();
|
||||
break;
|
||||
}
|
||||
case ID_CS_ADD_SHAPE:
|
||||
case ID_CS_ADD_SHAPE_SELECT:
|
||||
{
|
||||
// The app has given the command state a new m_savedState
|
||||
// shape, which is the new shape to add to the canvas (but
|
||||
// not actually added until this point).
|
||||
// The new 'saved state' is therefore 'nothing' since there
|
||||
// was nothing there before.
|
||||
|
||||
wxASSERT( (m_shapeOnCanvas == NULL) );
|
||||
wxASSERT( (m_savedState != NULL) );
|
||||
wxASSERT( (m_doc != NULL) );
|
||||
|
||||
m_shapeOnCanvas = m_savedState;
|
||||
m_savedState = NULL;
|
||||
|
||||
m_doc->GetDiagram()->AddShape(m_shapeOnCanvas);
|
||||
m_shapeOnCanvas->Show(TRUE);
|
||||
|
||||
wxClientDC dc(m_shapeOnCanvas->GetCanvas());
|
||||
m_shapeOnCanvas->GetCanvas()->PrepareDC(dc);
|
||||
|
||||
csEvtHandler *handler = (csEvtHandler *)m_shapeOnCanvas->GetEventHandler();
|
||||
m_shapeOnCanvas->FormatText(dc, handler->m_label);
|
||||
|
||||
m_shapeOnCanvas->Move(dc, m_shapeOnCanvas->GetX(), m_shapeOnCanvas->GetY());
|
||||
|
||||
if (m_cmd == ID_CS_ADD_SHAPE_SELECT)
|
||||
{
|
||||
m_shapeOnCanvas->Select(TRUE, &dc);
|
||||
((csDiagramView*) m_doc->GetFirstView())->SelectShape(m_shapeOnCanvas, TRUE);
|
||||
}
|
||||
|
||||
m_doc->Modify(TRUE);
|
||||
m_doc->UpdateAllViews();
|
||||
break;
|
||||
}
|
||||
case ID_CS_ADD_LINE:
|
||||
case ID_CS_ADD_LINE_SELECT:
|
||||
{
|
||||
wxASSERT( (m_shapeOnCanvas == NULL) );
|
||||
wxASSERT( (m_savedState != NULL) );
|
||||
wxASSERT( (m_doc != NULL) );
|
||||
|
||||
wxLineShape *lineShape = (wxLineShape *)m_savedState;
|
||||
wxASSERT( (lineShape->GetFrom() != NULL) );
|
||||
wxASSERT( (lineShape->GetTo() != NULL) );
|
||||
|
||||
m_shapeOnCanvas = m_savedState;
|
||||
m_savedState = NULL;
|
||||
|
||||
m_doc->GetDiagram()->AddShape(lineShape);
|
||||
|
||||
lineShape->GetFrom()->AddLine(lineShape, lineShape->GetTo(),
|
||||
lineShape->GetAttachmentFrom(), lineShape->GetAttachmentTo());
|
||||
|
||||
lineShape->Show(TRUE);
|
||||
|
||||
wxClientDC dc(lineShape->GetCanvas());
|
||||
lineShape->GetCanvas()->PrepareDC(dc);
|
||||
|
||||
// It won't get drawn properly unless you move both
|
||||
// connected images
|
||||
lineShape->GetFrom()->Move(dc, lineShape->GetFrom()->GetX(), lineShape->GetFrom()->GetY());
|
||||
lineShape->GetTo()->Move(dc, lineShape->GetTo()->GetX(), lineShape->GetTo()->GetY());
|
||||
|
||||
if (m_cmd == ID_CS_ADD_LINE_SELECT)
|
||||
{
|
||||
lineShape->Select(TRUE, &dc);
|
||||
((csDiagramView*) m_doc->GetFirstView())->SelectShape(m_shapeOnCanvas, TRUE);
|
||||
}
|
||||
|
||||
m_doc->Modify(TRUE);
|
||||
m_doc->UpdateAllViews();
|
||||
break;
|
||||
}
|
||||
case ID_CS_CHANGE_BACKGROUND_COLOUR:
|
||||
case ID_CS_MOVE:
|
||||
case ID_CS_SIZE:
|
||||
case ID_CS_EDIT_PROPERTIES:
|
||||
case ID_CS_FONT_CHANGE:
|
||||
case ID_CS_ARROW_CHANGE:
|
||||
case ID_CS_ROTATE_CLOCKWISE:
|
||||
case ID_CS_ROTATE_ANTICLOCKWISE:
|
||||
case ID_CS_CHANGE_LINE_ORDERING:
|
||||
case ID_CS_CHANGE_LINE_ATTACHMENT:
|
||||
case ID_CS_ALIGN:
|
||||
case ID_CS_NEW_POINT:
|
||||
case ID_CS_CUT_POINT:
|
||||
case ID_CS_MOVE_LINE_POINT:
|
||||
case ID_CS_STRAIGHTEN:
|
||||
case ID_CS_MOVE_LABEL:
|
||||
{
|
||||
// At this point we have been given a new shape
|
||||
// just like the old one but with a changed colour.
|
||||
// It's now time to apply that change to the
|
||||
// shape on the canvas, saving the old state.
|
||||
// NOTE: this is general enough to work with MOST attribute
|
||||
// changes!
|
||||
|
||||
wxASSERT( (m_shapeOnCanvas != NULL) );
|
||||
wxASSERT( (m_savedState != NULL) ); // This is the new shape with changed colour
|
||||
wxASSERT( (m_doc != NULL) );
|
||||
|
||||
wxClientDC dc(m_shapeOnCanvas->GetCanvas());
|
||||
m_shapeOnCanvas->GetCanvas()->PrepareDC(dc);
|
||||
|
||||
bool isSelected = m_shapeOnCanvas->Selected();
|
||||
if (isSelected)
|
||||
m_shapeOnCanvas->Select(FALSE, & dc);
|
||||
|
||||
if (m_cmd == ID_CS_SIZE || m_cmd == ID_CS_ROTATE_CLOCKWISE || m_cmd == ID_CS_ROTATE_ANTICLOCKWISE ||
|
||||
m_cmd == ID_CS_CHANGE_LINE_ORDERING || m_cmd == ID_CS_CHANGE_LINE_ATTACHMENT)
|
||||
{
|
||||
m_shapeOnCanvas->Erase(dc);
|
||||
}
|
||||
|
||||
// TODO: make sure the ID is the same. Or, when applying the new state,
|
||||
// don't change the original ID.
|
||||
wxShape* tempShape = m_shapeOnCanvas->CreateNewCopy();
|
||||
|
||||
// Apply the saved state to the shape on the canvas, by copying.
|
||||
m_savedState->CopyWithHandler(*m_shapeOnCanvas);
|
||||
|
||||
// Delete this state now it's been used (m_shapeOnCanvas currently holds this state)
|
||||
delete m_savedState;
|
||||
|
||||
// Remember the previous state
|
||||
m_savedState = tempShape;
|
||||
|
||||
// Redraw the shape
|
||||
|
||||
if (m_cmd == ID_CS_MOVE || m_cmd == ID_CS_ROTATE_CLOCKWISE || m_cmd == ID_CS_ROTATE_ANTICLOCKWISE ||
|
||||
m_cmd == ID_CS_ALIGN)
|
||||
{
|
||||
m_shapeOnCanvas->Move(dc, m_shapeOnCanvas->GetX(), m_shapeOnCanvas->GetY());
|
||||
|
||||
csEvtHandler *handler = (csEvtHandler *)m_shapeOnCanvas->GetEventHandler();
|
||||
m_shapeOnCanvas->FormatText(dc, handler->m_label);
|
||||
m_shapeOnCanvas->Draw(dc);
|
||||
}
|
||||
else if (m_cmd == ID_CS_CHANGE_LINE_ORDERING)
|
||||
{
|
||||
m_shapeOnCanvas->MoveLinks(dc);
|
||||
}
|
||||
else if (m_cmd == ID_CS_CHANGE_LINE_ATTACHMENT)
|
||||
{
|
||||
wxLineShape *lineShape = (wxLineShape *)m_shapeOnCanvas;
|
||||
|
||||
// Have to move both sets of links since we don't know which links
|
||||
// have been affected (unless we compared before and after states).
|
||||
lineShape->GetFrom()->MoveLinks(dc);
|
||||
lineShape->GetTo()->MoveLinks(dc);
|
||||
}
|
||||
else if (m_cmd == ID_CS_SIZE)
|
||||
{
|
||||
double width, height;
|
||||
m_shapeOnCanvas->GetBoundingBoxMax(&width, &height);
|
||||
|
||||
m_shapeOnCanvas->SetSize(width, height);
|
||||
m_shapeOnCanvas->Move(dc, m_shapeOnCanvas->GetX(), m_shapeOnCanvas->GetY());
|
||||
|
||||
m_shapeOnCanvas->Show(TRUE);
|
||||
|
||||
// Recursively redraw links if we have a composite.
|
||||
if (m_shapeOnCanvas->GetChildren().Number() > 0)
|
||||
m_shapeOnCanvas->DrawLinks(dc, -1, TRUE);
|
||||
|
||||
m_shapeOnCanvas->GetEventHandler()->OnEndSize(width, height);
|
||||
}
|
||||
else if (m_cmd == ID_CS_EDIT_PROPERTIES || m_cmd == ID_CS_FONT_CHANGE)
|
||||
{
|
||||
csEvtHandler *handler = (csEvtHandler *)m_shapeOnCanvas->GetEventHandler();
|
||||
m_shapeOnCanvas->FormatText(dc, handler->m_label);
|
||||
m_shapeOnCanvas->Draw(dc);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_shapeOnCanvas->Draw(dc);
|
||||
}
|
||||
|
||||
if (isSelected)
|
||||
m_shapeOnCanvas->Select(TRUE, & dc);
|
||||
|
||||
m_doc->Modify(TRUE);
|
||||
m_doc->UpdateAllViews();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool csCommandState::Undo()
|
||||
{
|
||||
switch (m_cmd)
|
||||
{
|
||||
case ID_CS_CUT:
|
||||
{
|
||||
wxASSERT( (m_savedState != NULL) );
|
||||
wxASSERT( (m_doc != NULL) );
|
||||
|
||||
m_doc->GetDiagram()->AddShape(m_savedState);
|
||||
m_shapeOnCanvas = m_savedState;
|
||||
m_savedState = NULL;
|
||||
|
||||
if (m_shapeOnCanvas->IsKindOf(CLASSINFO(wxLineShape)))
|
||||
{
|
||||
wxLineShape* lineShape = (wxLineShape*) m_shapeOnCanvas;
|
||||
lineShape->GetFrom()->AddLine(lineShape, lineShape->GetTo(),
|
||||
lineShape->GetAttachmentFrom(), lineShape->GetAttachmentTo(),
|
||||
m_linePositionFrom, m_linePositionTo);
|
||||
|
||||
wxShapeCanvas* canvas = lineShape->GetFrom()->GetCanvas();
|
||||
|
||||
wxClientDC dc(canvas);
|
||||
canvas->PrepareDC(dc);
|
||||
|
||||
lineShape->GetFrom()->MoveLinks(dc);
|
||||
lineShape->GetTo()->MoveLinks(dc);
|
||||
|
||||
}
|
||||
m_shapeOnCanvas->Show(TRUE);
|
||||
|
||||
m_doc->Modify(TRUE);
|
||||
m_doc->UpdateAllViews();
|
||||
break;
|
||||
}
|
||||
case ID_CS_ADD_SHAPE:
|
||||
case ID_CS_ADD_LINE:
|
||||
case ID_CS_ADD_SHAPE_SELECT:
|
||||
case ID_CS_ADD_LINE_SELECT:
|
||||
{
|
||||
wxASSERT( (m_shapeOnCanvas != NULL) );
|
||||
wxASSERT( (m_savedState == NULL) );
|
||||
wxASSERT( (m_doc != NULL) );
|
||||
|
||||
// In case this is a line
|
||||
wxShape* lineFrom = NULL;
|
||||
wxShape* lineTo = NULL;
|
||||
int attachmentFrom = 0, attachmentTo = 0;
|
||||
|
||||
if (m_shapeOnCanvas->IsKindOf(CLASSINFO(wxLineShape)))
|
||||
{
|
||||
// Store the from/to info to save in the line shape
|
||||
wxLineShape* lineShape = (wxLineShape*) m_shapeOnCanvas;
|
||||
lineFrom = lineShape->GetFrom();
|
||||
lineTo = lineShape->GetTo();
|
||||
attachmentFrom = lineShape->GetAttachmentFrom();
|
||||
attachmentTo = lineShape->GetAttachmentTo();
|
||||
}
|
||||
|
||||
wxClientDC dc(m_shapeOnCanvas->GetCanvas());
|
||||
m_shapeOnCanvas->GetCanvas()->PrepareDC(dc);
|
||||
|
||||
m_shapeOnCanvas->Select(FALSE, &dc);
|
||||
((csDiagramView*) m_doc->GetFirstView())->SelectShape(m_shapeOnCanvas, FALSE);
|
||||
m_doc->GetDiagram()->RemoveShape(m_shapeOnCanvas);
|
||||
m_shapeOnCanvas->Unlink(); // Unlinks the line, if it is a line
|
||||
|
||||
if (m_shapeOnCanvas->IsKindOf(CLASSINFO(wxLineShape)))
|
||||
{
|
||||
// Restore the from/to info for future reference
|
||||
wxLineShape* lineShape = (wxLineShape*) m_shapeOnCanvas;
|
||||
lineShape->SetFrom(lineFrom);
|
||||
lineShape->SetTo(lineTo);
|
||||
lineShape->SetAttachments(attachmentFrom, attachmentTo);
|
||||
}
|
||||
|
||||
m_savedState = m_shapeOnCanvas;
|
||||
m_shapeOnCanvas = NULL;
|
||||
|
||||
m_doc->Modify(TRUE);
|
||||
m_doc->UpdateAllViews();
|
||||
break;
|
||||
}
|
||||
case ID_CS_CHANGE_BACKGROUND_COLOUR:
|
||||
case ID_CS_MOVE:
|
||||
case ID_CS_SIZE:
|
||||
case ID_CS_EDIT_PROPERTIES:
|
||||
case ID_CS_FONT_CHANGE:
|
||||
case ID_CS_ARROW_CHANGE:
|
||||
case ID_CS_ROTATE_CLOCKWISE:
|
||||
case ID_CS_ROTATE_ANTICLOCKWISE:
|
||||
case ID_CS_CHANGE_LINE_ORDERING:
|
||||
case ID_CS_CHANGE_LINE_ATTACHMENT:
|
||||
case ID_CS_ALIGN:
|
||||
case ID_CS_NEW_POINT:
|
||||
case ID_CS_CUT_POINT:
|
||||
case ID_CS_MOVE_LINE_POINT:
|
||||
case ID_CS_STRAIGHTEN:
|
||||
case ID_CS_MOVE_LABEL:
|
||||
{
|
||||
// Exactly like the Do case; we're just swapping states.
|
||||
Do();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
134
samples/ogl/studio/doc.h
Normal file
@@ -0,0 +1,134 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: doc.h
|
||||
// Purpose: Document classes
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 12/07/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _STUDIO_DOC_H_
|
||||
#define _STUDIO_DOC_H_
|
||||
|
||||
#ifdef __GNUG__
|
||||
// #pragma interface
|
||||
#endif
|
||||
|
||||
#include <wx/docview.h>
|
||||
#include <wx/string.h>
|
||||
#include <wx/wxexpr.h>
|
||||
|
||||
#include <wx/ogl/ogl.h>
|
||||
#include "shapes.h"
|
||||
|
||||
/*
|
||||
* A diagram document, which contains a diagram.
|
||||
*/
|
||||
|
||||
class csDiagramDocument: public wxDocument
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(csDiagramDocument)
|
||||
public:
|
||||
csDiagramDocument();
|
||||
~csDiagramDocument();
|
||||
|
||||
bool OnSaveDocument(const wxString& file);
|
||||
bool OnOpenDocument(const wxString& file);
|
||||
|
||||
inline wxDiagram *GetDiagram() { return &m_diagram; }
|
||||
|
||||
bool OnCloseDocument();
|
||||
|
||||
protected:
|
||||
csDiagram m_diagram;
|
||||
};
|
||||
|
||||
/*
|
||||
Do/Undo 30/7/98
|
||||
|
||||
1) We have a csCommandState, and in csDiagramCommand you have a list of
|
||||
these. This allows undo to work with several shapes at once.
|
||||
|
||||
2) Instead of storing info about each operation, e.g. separate pens, colours,
|
||||
etc., we simply use a copy of the shape.
|
||||
In csCommandState, we have a pointer to the actual shape in the canvas, m_currentShape.
|
||||
We also have wxShape* m_shapeState which stores the requested or previous state
|
||||
(depending on whether it's before the Do or after the Do.
|
||||
|
||||
- In Do: save a temp copy of the old m_currentShape (i.e. the state just before it's changed).
|
||||
Change the data pointed to by m_currentShape to the new attributes stored in m_shapeState.
|
||||
Now assign the temp copy to m_shapeState, for use in Undo.
|
||||
|
||||
wxShape* temp = m_currentShape->Copy(); // Take a copy of the current state
|
||||
m_currentShape->Set(m_shapeState); // Apply the new state (e.g. moving, changing colour etc.)
|
||||
delete m_shapeState; // Delete the previous 'old state'.
|
||||
m_shapeState = temp; // Remember the new 'old state'.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
class csCommandState;
|
||||
class csDiagramCommand: public wxCommand
|
||||
{
|
||||
friend class csCommandState;
|
||||
public:
|
||||
// Multi-purpose constructor for creating, deleting shapes
|
||||
csDiagramCommand(const wxString& name, csDiagramDocument *doc,
|
||||
csCommandState* onlyState = NULL); // Allow for the common case of just one state to change
|
||||
|
||||
~csDiagramCommand();
|
||||
|
||||
bool Do();
|
||||
bool Undo();
|
||||
|
||||
// Add a state to the end of the list
|
||||
void AddState(csCommandState* state);
|
||||
|
||||
// Insert a state at the beginning of the list
|
||||
void InsertState(csCommandState* state);
|
||||
|
||||
// Schedule all lines connected to the states to be cut.
|
||||
void RemoveLines();
|
||||
|
||||
// Find the state that refers to this shape
|
||||
csCommandState* FindStateByShape(wxShape* shape);
|
||||
|
||||
wxList& GetStates() const { return (wxList&) m_states; }
|
||||
|
||||
protected:
|
||||
csDiagramDocument* m_doc;
|
||||
wxList m_states;
|
||||
};
|
||||
|
||||
class csCommandState: public wxObject
|
||||
{
|
||||
friend class csDiagramCommand;
|
||||
public:
|
||||
csCommandState(int cmd, wxShape* savedState, wxShape* shapeOnCanvas);
|
||||
~csCommandState();
|
||||
|
||||
bool Do();
|
||||
bool Undo();
|
||||
|
||||
inline void SetSavedState(wxShape *s) { m_savedState = s; }
|
||||
inline wxShape *GetSavedState() const { return m_savedState; }
|
||||
|
||||
inline void SetShapeOnCanvas(wxShape *s) { m_shapeOnCanvas = s; }
|
||||
inline wxShape *GetShapeOnCanvas() const { return m_shapeOnCanvas; }
|
||||
protected:
|
||||
wxShape* m_savedState; // Previous state, for restoring on Undo
|
||||
wxShape* m_shapeOnCanvas; // The actual shape on the canvas
|
||||
csDiagramDocument* m_doc;
|
||||
int m_cmd;
|
||||
|
||||
// These store the line ordering for the shapes at either end,
|
||||
// so an un-cut line can restore the ordering properly. Otherwise
|
||||
// it just adds the line at an arbitrary position.
|
||||
int m_linePositionFrom;
|
||||
int m_linePositionTo;
|
||||
};
|
||||
|
||||
#endif
|
||||
// _STUDIO_DOC_H_
|
276
samples/ogl/studio/mainfrm.cpp
Normal file
@@ -0,0 +1,276 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: mainfrm.cpp
|
||||
// Purpose: Studio main frame
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 27/7/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence:
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// For compilers that support precompilation, includes "wx/wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/wx.h"
|
||||
#include "wx/mdi.h"
|
||||
#endif
|
||||
|
||||
#include "wx/laywin.h"
|
||||
|
||||
#include "studio.h"
|
||||
#include "view.h"
|
||||
#include "doc.h"
|
||||
#include "cspalette.h"
|
||||
#include "mainfrm.h"
|
||||
#include "dialogs.h"
|
||||
|
||||
BEGIN_EVENT_TABLE(csFrame, wxDocMDIParentFrame)
|
||||
EVT_MENU(ID_CS_ABOUT, csFrame::OnAbout)
|
||||
EVT_MENU(wxID_EXIT, csFrame::OnQuit)
|
||||
EVT_MENU(wxID_HELP, csFrame::OnHelp)
|
||||
EVT_MENU(ID_CS_SETTINGS, csFrame::OnSettings)
|
||||
EVT_SIZE(csFrame::OnSize)
|
||||
EVT_SASH_DRAGGED(ID_LAYOUT_WINDOW_PALETTE, csFrame::OnSashDragPaletteWindow)
|
||||
EVT_SASH_DRAGGED(ID_LAYOUT_WINDOW_PROJECT, csFrame::OnSashDragProjectWindow)
|
||||
EVT_IDLE(csFrame::OnIdle)
|
||||
EVT_UPDATE_UI(wxID_PRINT, csFrame::OnUpdateDisable)
|
||||
EVT_UPDATE_UI(wxID_PREVIEW, csFrame::OnUpdateDisable)
|
||||
EVT_UPDATE_UI(wxID_SAVE, csFrame::OnSaveUpdate)
|
||||
EVT_UPDATE_UI(wxID_SAVEAS, csFrame::OnSaveUpdate)
|
||||
EVT_UPDATE_UI(wxID_UNDO, csFrame::OnUpdateDisable)
|
||||
EVT_UPDATE_UI(wxID_REDO, csFrame::OnUpdateDisable)
|
||||
EVT_UPDATE_UI(wxID_CUT, csFrame::OnUpdateDisable)
|
||||
EVT_UPDATE_UI(wxID_COPY, csFrame::OnUpdateDisable)
|
||||
EVT_UPDATE_UI(wxID_PASTE, csFrame::OnUpdateDisable)
|
||||
EVT_CLOSE(csFrame::OnCloseWindow)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
// Define my frame constructor
|
||||
csFrame::csFrame(wxDocManager* manager, wxFrame *parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size,
|
||||
long style):
|
||||
wxDocMDIParentFrame(manager, parent, id, title, pos, size, style, "frame")
|
||||
{
|
||||
CreateToolBar(wxNO_BORDER|wxTB_FLAT|wxTB_HORIZONTAL);
|
||||
wxGetApp().InitToolBar(GetToolBar());
|
||||
|
||||
// Accelerators
|
||||
wxAcceleratorEntry entries[4];
|
||||
|
||||
entries[0].Set(wxACCEL_NORMAL, WXK_F1, wxID_HELP);
|
||||
entries[1].Set(wxACCEL_CTRL, 'O', wxID_OPEN);
|
||||
entries[2].Set(wxACCEL_CTRL, 'N', wxID_NEW);
|
||||
entries[3].Set(wxACCEL_CTRL, 'P', wxID_PRINT);
|
||||
|
||||
wxAcceleratorTable accel(4, entries);
|
||||
SetAcceleratorTable(accel);
|
||||
}
|
||||
|
||||
void csFrame::OnHelp(wxCommandEvent& event)
|
||||
{
|
||||
wxGetApp().GetHelpController().DisplayContents();
|
||||
}
|
||||
|
||||
void csFrame::OnSettings(wxCommandEvent& event)
|
||||
{
|
||||
csSettingsDialog* dialog = new csSettingsDialog(this);
|
||||
int ret = dialog->ShowModal();
|
||||
dialog->Destroy();
|
||||
}
|
||||
|
||||
void csFrame::OnQuit(wxCommandEvent& event)
|
||||
{
|
||||
Close(TRUE);
|
||||
}
|
||||
|
||||
void csFrame::OnAbout(wxCommandEvent& event)
|
||||
{
|
||||
(void)wxMessageBox("OGL Studio\n(c) 1999, Julian Smart", "About OGL Studio", wxICON_INFORMATION);
|
||||
}
|
||||
|
||||
void csFrame::OnSashDragPaletteWindow(wxSashEvent& event)
|
||||
{
|
||||
if (event.GetDragStatus() == wxSASH_STATUS_OUT_OF_RANGE)
|
||||
return;
|
||||
|
||||
switch (event.GetId())
|
||||
{
|
||||
case ID_LAYOUT_WINDOW_PALETTE:
|
||||
{
|
||||
wxGetApp().GetDiagramPaletteSashWindow()->SetDefaultSize(wxSize(10000, event.GetDragRect().height));
|
||||
break;
|
||||
}
|
||||
}
|
||||
wxLayoutAlgorithm layout;
|
||||
layout.LayoutMDIFrame(this);
|
||||
}
|
||||
|
||||
void csFrame::OnSashDragProjectWindow(wxSashEvent& event)
|
||||
{
|
||||
if (event.GetDragStatus() == wxSASH_STATUS_OUT_OF_RANGE)
|
||||
return;
|
||||
|
||||
switch (event.GetId())
|
||||
{
|
||||
case ID_LAYOUT_WINDOW_PROJECT:
|
||||
{
|
||||
wxGetApp().GetProjectSashWindow()->SetDefaultSize(wxSize(event.GetDragRect().width, 10000));
|
||||
break;
|
||||
}
|
||||
}
|
||||
wxLayoutAlgorithm layout;
|
||||
layout.LayoutMDIFrame(this);
|
||||
}
|
||||
|
||||
// Define the behaviour for the frame closing
|
||||
// - must delete all frames except for the main one.
|
||||
void csFrame::OnCloseWindow(wxCloseEvent& event)
|
||||
{
|
||||
int x, y;
|
||||
GetPosition(& x, & y);
|
||||
wxGetApp().m_mainFramePos = wxPoint(x, y);
|
||||
|
||||
GetSize(& x, & y);
|
||||
wxGetApp().m_mainFrameSize = wxSize(x, y);
|
||||
|
||||
wxDocMDIParentFrame::OnCloseWindow(event);
|
||||
}
|
||||
|
||||
void csFrame::OnSize(wxSizeEvent& event)
|
||||
{
|
||||
wxLayoutAlgorithm layout;
|
||||
layout.LayoutMDIFrame(this);
|
||||
}
|
||||
|
||||
// Make sure the correct toolbars are showing for the active view
|
||||
void csFrame::OnIdle(wxIdleEvent& event)
|
||||
{
|
||||
wxDocMDIParentFrame::OnIdle(event);
|
||||
|
||||
wxSashLayoutWindow* paletteWin = wxGetApp().GetDiagramPaletteSashWindow();
|
||||
wxSashLayoutWindow* diagramToolBarWin = wxGetApp().GetDiagramToolBarSashWindow();
|
||||
if (!paletteWin || !diagramToolBarWin)
|
||||
return;
|
||||
bool doLayout = FALSE;
|
||||
if (GetActiveChild())
|
||||
{
|
||||
if (!paletteWin->IsShown() || !diagramToolBarWin->IsShown())
|
||||
{
|
||||
paletteWin->Show(TRUE);
|
||||
diagramToolBarWin->Show(TRUE);
|
||||
|
||||
doLayout = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (paletteWin->IsShown() || diagramToolBarWin->IsShown())
|
||||
{
|
||||
paletteWin->Show(FALSE);
|
||||
diagramToolBarWin->Show(FALSE);
|
||||
doLayout = TRUE;
|
||||
}
|
||||
}
|
||||
if (doLayout)
|
||||
{
|
||||
wxLayoutAlgorithm layout;
|
||||
layout.LayoutMDIFrame(this);
|
||||
|
||||
#if defined(__WXMSW__) && defined(__WIN95__)
|
||||
// Need to do something else to get it to refresh properly
|
||||
// when a client frame is first displayed; moving the client
|
||||
// window doesn't cause the proper refresh. Just refreshing the
|
||||
// client doesn't work (presumably because it's clipping the
|
||||
// children).
|
||||
// FIXED in wxWindows, by intercepting wxMDIClientWindow::DoSetSize
|
||||
// and checking if the position has changed, before redrawing the
|
||||
// child windows.
|
||||
#if 0
|
||||
wxMDIChildFrame* childFrame = GetActiveChild();
|
||||
if (childFrame)
|
||||
{
|
||||
HWND hWnd = (HWND) childFrame->GetHWND();
|
||||
::RedrawWindow(hWnd, NULL, NULL, RDW_FRAME|RDW_ALLCHILDREN|RDW_INVALIDATE );
|
||||
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// General handler for disabling items
|
||||
void csFrame::OnUpdateDisable(wxUpdateUIEvent& event)
|
||||
{
|
||||
event.Enable(FALSE);
|
||||
}
|
||||
|
||||
void csFrame::OnSaveUpdate(wxUpdateUIEvent& event)
|
||||
{
|
||||
event.Enable( (GetActiveChild() != NULL) );
|
||||
}
|
||||
|
||||
/*
|
||||
* Child frame
|
||||
*/
|
||||
|
||||
BEGIN_EVENT_TABLE(csMDIChildFrame, wxDocMDIChildFrame)
|
||||
EVT_ACTIVATE(csMDIChildFrame::OnActivate)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
csMDIChildFrame::csMDIChildFrame(wxDocument* doc, wxView* view, wxMDIParentFrame *parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style):
|
||||
wxDocMDIChildFrame(doc, view, parent, id, title, pos, size, style)
|
||||
{
|
||||
// Accelerators
|
||||
wxAcceleratorEntry entries[18];
|
||||
|
||||
// Usual editing functions
|
||||
entries[0].Set(wxACCEL_NORMAL, WXK_DELETE, wxID_CLEAR);
|
||||
entries[1].Set(wxACCEL_CTRL, 'X', wxID_CUT);
|
||||
entries[2].Set(wxACCEL_CTRL, 'C', wxID_COPY);
|
||||
entries[3].Set(wxACCEL_SHIFT, WXK_INSERT, wxID_PASTE);
|
||||
entries[4].Set(wxACCEL_CTRL, 'V', wxID_PASTE);
|
||||
entries[5].Set(wxACCEL_CTRL, 'A', ID_CS_SELECT_ALL);
|
||||
|
||||
// Undo/redo
|
||||
entries[6].Set(wxACCEL_CTRL, 'Z', wxID_UNDO);
|
||||
entries[7].Set(wxACCEL_CTRL, 'Y', wxID_REDO);
|
||||
|
||||
// Other
|
||||
entries[8].Set(wxACCEL_NORMAL, WXK_RETURN, ID_CS_EDIT_PROPERTIES);
|
||||
entries[9].Set(wxACCEL_ALT, WXK_RETURN, ID_CS_EDIT_PROPERTIES);
|
||||
entries[10].Set(wxACCEL_CTRL, 'D', wxID_DUPLICATE);
|
||||
entries[11].Set(wxACCEL_NORMAL, WXK_F1, wxID_HELP);
|
||||
|
||||
// File handling
|
||||
entries[12].Set(wxACCEL_CTRL, 'S', wxID_SAVE);
|
||||
entries[13].Set(wxACCEL_NORMAL, WXK_F12, wxID_SAVEAS);
|
||||
entries[14].Set(wxACCEL_CTRL, 'O', wxID_OPEN);
|
||||
entries[15].Set(wxACCEL_CTRL, 'N', wxID_NEW);
|
||||
entries[16].Set(wxACCEL_CTRL, 'P', wxID_PRINT);
|
||||
entries[17].Set(wxACCEL_CTRL, 'W', wxID_CLOSE);
|
||||
|
||||
|
||||
wxAcceleratorTable accel(18, entries);
|
||||
SetAcceleratorTable(accel);
|
||||
}
|
||||
|
||||
void csMDIChildFrame::OnActivate(wxActivateEvent& event)
|
||||
{
|
||||
wxDocMDIChildFrame::OnActivate(event);
|
||||
/*
|
||||
wxSashLayoutWindow* win = wxGetApp().GetDiagramPaletteSashWindow();
|
||||
if (!win)
|
||||
return;
|
||||
|
||||
win->Show(event.GetActive());
|
||||
|
||||
wxLayoutAlgorithm layout;
|
||||
layout.LayoutMDIFrame((wxMDIParentFrame*) GetParent());
|
||||
*/
|
||||
}
|
||||
|
55
samples/ogl/studio/mainfrm.h
Normal file
@@ -0,0 +1,55 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: mainfrm.h
|
||||
// Purpose: Studio main window class
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 27/7/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence:
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _STUDIO_MAINFRM_H_
|
||||
#define _STUDIO_MAINFRM_H_
|
||||
|
||||
#include <wx/docmdi.h>
|
||||
|
||||
class wxSashLayoutWindow;
|
||||
class wxSashEvent;
|
||||
|
||||
class csFrame: public wxDocMDIParentFrame
|
||||
{
|
||||
public:
|
||||
csFrame(wxDocManager *manager, wxFrame *parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style);
|
||||
|
||||
void OnCloseWindow(wxCloseEvent& event);
|
||||
void OnSize(wxSizeEvent& event);
|
||||
void OnAbout(wxCommandEvent& event);
|
||||
void OnNewWindow(wxCommandEvent& event);
|
||||
void OnQuit(wxCommandEvent& event);
|
||||
void OnSashDragPaletteWindow(wxSashEvent& event);
|
||||
void OnSashDragProjectWindow(wxSashEvent& event);
|
||||
void OnIdle(wxIdleEvent& event);
|
||||
void OnHelp(wxCommandEvent& event);
|
||||
void OnSettings(wxCommandEvent& event);
|
||||
|
||||
// General handler for disabling items
|
||||
void OnUpdateDisable(wxUpdateUIEvent& event);
|
||||
void OnSaveUpdate(wxUpdateUIEvent& event);
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
class csMDIChildFrame: public wxDocMDIChildFrame
|
||||
{
|
||||
public:
|
||||
csMDIChildFrame(wxDocument* doc, wxView* view, wxMDIParentFrame *parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style);
|
||||
|
||||
void OnActivate(wxActivateEvent& event);
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
#endif
|
||||
// _STUDIO_MAINFRM_H_
|
||||
|
19
samples/ogl/studio/makefile.b32
Normal file
@@ -0,0 +1,19 @@
|
||||
#
|
||||
# File: makefile.b32
|
||||
# Author: Julian Smart
|
||||
# Created: 1999
|
||||
# Updated:
|
||||
# Copyright:
|
||||
#
|
||||
# Makefile : Builds sample for 32-bit BC++
|
||||
|
||||
WXDIR = $(WXWIN)
|
||||
|
||||
TARGET=studio
|
||||
EXTRALIBS=$(WXDIR)\lib\ogl.lib
|
||||
EXTRACPPFLAGS=-I$(WXDIR)\utils\ogl\src
|
||||
OBJECTS = $(TARGET).obj doc.obj shapes.obj symbols.obj view.obj cspalette.obj\
|
||||
mainfrm.obj project.obj dialogs.obj csprint.obj
|
||||
|
||||
!include $(WXDIR)\src\makeprog.b32
|
||||
|
22
samples/ogl/studio/makefile.bcc
Normal file
@@ -0,0 +1,22 @@
|
||||
#
|
||||
# File: makefile.bcc
|
||||
# Author: Julian Smart
|
||||
# Created: 1998
|
||||
# Updated:
|
||||
#
|
||||
# Builds a BC++ 16-bit sample
|
||||
|
||||
!if "$(WXWIN)" == ""
|
||||
!error You must define the WXWIN variable in autoexec.bat, e.g. WXWIN=c:\wx
|
||||
!endif
|
||||
|
||||
WXDIR = $(WXWIN)
|
||||
|
||||
TARGET=studio
|
||||
EXTRALIBS=$(WXDIR)\lib\ogl.lib
|
||||
EXTRACPPFLAGS=-I$(WXDIR)\utils\ogl\src
|
||||
OBJECTS = $(TARGET).obj doc.obj shapes.obj symbols.obj view.obj cspalette.obj\
|
||||
mainfrm.obj project.obj dialogs.obj csprint.obj
|
||||
|
||||
!include $(WXDIR)\src\makeprog.b32
|
||||
|
19
samples/ogl/studio/makefile.g95
Normal file
@@ -0,0 +1,19 @@
|
||||
#
|
||||
# File: makefile.g95
|
||||
# Author: Julian Smart
|
||||
# Created: 1999
|
||||
# Updated:
|
||||
# Copyright: (c) Julian Smart, 1999
|
||||
#
|
||||
# Makefile for wxWindows sample (Cygwin/Mingw32).
|
||||
|
||||
WXDIR = ../../../..
|
||||
|
||||
TARGET=studio
|
||||
EXTRACPPFLAGS=-I../../src
|
||||
EXTRALIBS=-logl
|
||||
OBJECTS = $(TARGET).o doc.o shapes.o symbols.o view.o cspalette.o\
|
||||
mainfrm.o project.o dialogs.o csprint.o
|
||||
|
||||
include $(WXDIR)/src/makeprog.g95
|
||||
|
39
samples/ogl/studio/makefile.unx
Normal file
@@ -0,0 +1,39 @@
|
||||
#
|
||||
# File: makefile.unx
|
||||
# Author: Julian Smart
|
||||
# Created: 1998
|
||||
# Updated:
|
||||
# Copyright: (c) 1998 Julian Smart
|
||||
#
|
||||
# "%W% %G%"
|
||||
#
|
||||
# Makefile for OGL Studio (UNIX).
|
||||
|
||||
PROGRAM=studio
|
||||
|
||||
OBJECTS=$(PROGRAM).o doc.o shapes.o symbols.o view.o cspalette.o\
|
||||
mainfrm.o project.o dialogs.o csprint.o
|
||||
|
||||
EXTRACPPFLAGS=-I$(WXDIR)/utils/ogl/src -I./bitmaps
|
||||
EXTRALDLIBS=-logl$(GUISUFFIX)
|
||||
|
||||
#WXDIR=/home/jacs/wx2
|
||||
|
||||
include $(WXDIR)/src/makeprog.env
|
||||
|
||||
cleanogl:
|
||||
cd $(WXDIR)/utils/ogl/src; make -f makefile.unx cleanmotif
|
||||
|
||||
ogl:
|
||||
cd $(WXDIR)/utils/ogl/src; make -f makefile.unx motif
|
||||
|
||||
wx:
|
||||
cd $(WXDIR)/src/motif; make -f makefile.unx motif
|
||||
|
||||
cleanwx:
|
||||
cd $(WXDIR)/src/motif; make -f makefile.unx cleanmotif
|
||||
|
||||
cleanall: cleanmotif cleanogl cleanwx
|
||||
|
||||
makeall: wx ogl motif
|
||||
|
143
samples/ogl/studio/makefile.vc
Normal file
@@ -0,0 +1,143 @@
|
||||
#
|
||||
# File: makefile.vc
|
||||
# Author: Julian Smart
|
||||
# Created: 1999
|
||||
# Updated:
|
||||
# Copyright: (c) Julian Smart
|
||||
#
|
||||
# "%W% %G%"
|
||||
#
|
||||
# Makefile : Builds OGL studio example (MS VC++).
|
||||
# Use FINAL=1 argument to nmake to build final version with no debugging
|
||||
# info
|
||||
|
||||
# Set WXDIR for your system
|
||||
WXDIR = $(WXWIN)
|
||||
WXUSINGDLL=0
|
||||
|
||||
STUDIODIR = $(WXDIR)\utils\ogl\samples\studio
|
||||
THISDIR = $(STUDIODIR)
|
||||
|
||||
OGLDIR = $(WXDIR)\utils\ogl
|
||||
OGLINC = $(OGLDIR)\src
|
||||
OGLLIB = $(WXDIR)\lib\ogl$(LIBEXT).lib
|
||||
|
||||
!include $(WXDIR)\src\makevc.env
|
||||
|
||||
EXTRALIBS=$(OGLLIB)
|
||||
EXTRAINC = /I$(OGLINC)
|
||||
|
||||
PROGRAM=studio
|
||||
|
||||
OBJECTS = $(PROGRAM).obj doc.obj shapes.obj symbols.obj view.obj cspalette.obj\
|
||||
mainfrm.obj project.obj dialogs.obj csprint.obj
|
||||
|
||||
all: ogl $(PROGRAM).exe
|
||||
|
||||
$(PROGRAM): $(PROGRAM).exe
|
||||
|
||||
cleanall: clean cleanogl # cleanidelib
|
||||
cleanutils: cleanall
|
||||
|
||||
wx:
|
||||
cd $(WXDIR)\src\msw
|
||||
nmake -f makefile.vc FINAL=$(FINAL)
|
||||
cd $(THISDIR)
|
||||
|
||||
cleanwx:
|
||||
cd $(WXDIR)\src\msw
|
||||
nmake -f makefile.vc clean
|
||||
cd $(THISDIR)
|
||||
|
||||
idelib:
|
||||
cd $(CLIPDIR)\IDELib\src
|
||||
nmake -f makefile.vc FINAL=$(FINAL)
|
||||
cd $(THISDIR)
|
||||
|
||||
cleanidelib:
|
||||
cd $(CLIPDIR)\IDELib\src
|
||||
nmake -f makefile.vc clean
|
||||
cd $(THISDIR)
|
||||
|
||||
ogl:
|
||||
cd $(OGLDIR)\src
|
||||
nmake -f makefile.vc FINAL=$(FINAL)
|
||||
cd $(THISDIR)
|
||||
|
||||
cleanogl:
|
||||
cd $(OGLDIR)\src
|
||||
nmake -f makefile.vc clean
|
||||
cd $(THISDIR)
|
||||
|
||||
$(PROGRAM).exe: $(DUMMYOBJ) $(WXLIB) $(OBJECTS) $(EXTRALIBS) $(PROGRAM).res
|
||||
$(link) @<<
|
||||
-out:$(PROGRAM).exe
|
||||
$(LINKFLAGS)
|
||||
$(DUMMYOBJ) $(OBJECTS) $(PROGRAM).res
|
||||
$(LIBS)
|
||||
<<
|
||||
|
||||
|
||||
$(PROGRAM).obj: $(PROGRAM).$(SRCSUFF) cspalette.h doc.h view.h $(DUMMYOBJ)
|
||||
$(cc) @<<
|
||||
$(CPPFLAGS) /c /Tp $*.$(SRCSUFF)
|
||||
<<
|
||||
|
||||
mainfrm.obj: mainfrm.$(SRCSUFF) mainfrm.h
|
||||
$(cc) @<<
|
||||
$(CPPFLAGS) /c /Tp $*.$(SRCSUFF)
|
||||
<<
|
||||
|
||||
cspalette.obj: cspalette.$(SRCSUFF) cspalette.h
|
||||
$(cc) @<<
|
||||
$(CPPFLAGS) /c /Tp $*.$(SRCSUFF)
|
||||
<<
|
||||
|
||||
project.obj: project.$(SRCSUFF) project.h
|
||||
$(cc) @<<
|
||||
$(CPPFLAGS) /c /Tp $*.$(SRCSUFF)
|
||||
<<
|
||||
|
||||
view.obj: view.$(SRCSUFF) view.h
|
||||
$(cc) @<<
|
||||
$(CPPFLAGS) /c /Tp $*.$(SRCSUFF)
|
||||
<<
|
||||
|
||||
doc.obj: doc.$(SRCSUFF) doc.h
|
||||
$(cc) @<<
|
||||
$(CPPFLAGS) /c /Tp $*.$(SRCSUFF)
|
||||
<<
|
||||
|
||||
shapes.obj: shapes.$(SRCSUFF) shapes.h
|
||||
$(cc) @<<
|
||||
$(CPPFLAGS) /c /Tp $*.$(SRCSUFF)
|
||||
<<
|
||||
|
||||
symbols.obj: symbols.$(SRCSUFF) symbols.h
|
||||
$(cc) @<<
|
||||
$(CPPFLAGS) /c /Tp $*.$(SRCSUFF)
|
||||
<<
|
||||
|
||||
dialogs.obj: dialogs.$(SRCSUFF) dialogs.h
|
||||
$(cc) @<<
|
||||
$(CPPFLAGS) /c /Tp $*.$(SRCSUFF)
|
||||
<<
|
||||
|
||||
csprint.obj: csprint.$(SRCSUFF) shapes.h
|
||||
$(cc) @<<
|
||||
$(CPPFLAGS) /c /Tp $*.$(SRCSUFF)
|
||||
<<
|
||||
|
||||
$(OBJECTS): shapes.h doc.h view.h mainfrm.h studio.h cspalette.h project.h symbols.h dialogs.h
|
||||
|
||||
$(PROGRAM).res : $(PROGRAM).rc $(WXDIR)\include\wx\msw\wx.rc
|
||||
$(rc) -r /i$(WXDIR)\include -fo$@ $(PROGRAM).rc
|
||||
|
||||
|
||||
clean:
|
||||
-erase *.obj
|
||||
-erase *.exe
|
||||
-erase *.res
|
||||
-erase *.map
|
||||
-erase *.sbr
|
||||
-erase *.pdb
|
BIN
samples/ogl/studio/manual/alignb.bmp
Normal file
After Width: | Height: | Size: 238 B |
BIN
samples/ogl/studio/manual/alignl.bmp
Normal file
After Width: | Height: | Size: 238 B |
BIN
samples/ogl/studio/manual/alignr.bmp
Normal file
After Width: | Height: | Size: 238 B |
BIN
samples/ogl/studio/manual/alignt.bmp
Normal file
After Width: | Height: | Size: 238 B |
BIN
samples/ogl/studio/manual/arrow.bmp
Normal file
After Width: | Height: | Size: 382 B |
BIN
samples/ogl/studio/manual/back.gif
Normal file
After Width: | Height: | Size: 225 B |
BIN
samples/ogl/studio/manual/bitmap1.bmp
Normal file
After Width: | Height: | Size: 238 B |
BIN
samples/ogl/studio/manual/bitmap2.bmp
Normal file
After Width: | Height: | Size: 238 B |
BIN
samples/ogl/studio/manual/bullet.bmp
Normal file
After Width: | Height: | Size: 138 B |
BIN
samples/ogl/studio/manual/contents.gif
Normal file
After Width: | Height: | Size: 231 B |
BIN
samples/ogl/studio/manual/copy.bmp
Normal file
After Width: | Height: | Size: 238 B |
BIN
samples/ogl/studio/manual/copysize.bmp
Normal file
After Width: | Height: | Size: 238 B |
BIN
samples/ogl/studio/manual/cut.bmp
Normal file
After Width: | Height: | Size: 238 B |
BIN
samples/ogl/studio/manual/cutpoint.bmp
Normal file
After Width: | Height: | Size: 238 B |
BIN
samples/ogl/studio/manual/forward.gif
Normal file
After Width: | Height: | Size: 164 B |
BIN
samples/ogl/studio/manual/help.bmp
Normal file
After Width: | Height: | Size: 238 B |
BIN
samples/ogl/studio/manual/helpcs.bmp
Normal file
After Width: | Height: | Size: 238 B |
BIN
samples/ogl/studio/manual/horiz.bmp
Normal file
After Width: | Height: | Size: 238 B |
BIN
samples/ogl/studio/manual/linearrow.bmp
Normal file
After Width: | Height: | Size: 238 B |