mirror of
http://172.16.200.102/MOISE/Timed-Altarica-To-Fiacre-Translator.git
synced 2025-11-26 05:27:57 +01:00
Initial commit.
This commit is contained in:
85
sdk/wxshapeframework/include/wx/wxsf/ArrowBase.h
Normal file
85
sdk/wxshapeframework/include/wx/wxsf/ArrowBase.h
Normal file
@@ -0,0 +1,85 @@
|
||||
/***************************************************************
|
||||
* Name: ArrowBase.h
|
||||
* Purpose: Defines line arrow base class
|
||||
* Author: Michal Bližňák (michal.bliznak@tiscali.cz)
|
||||
* Created: 2007-07-22
|
||||
* Copyright: Michal Bližňák
|
||||
* License: wxWidgets license (www.wxwidgets.org)
|
||||
* Notes:
|
||||
**************************************************************/
|
||||
|
||||
#ifndef _WXSFARROWBASE_H
|
||||
#define _WXSFARROWBASE_H
|
||||
|
||||
#include <wx/wxsf/ShapeBase.h>
|
||||
|
||||
// default values
|
||||
#define sfdvARROW_FILL wxBrush(*wxWHITE)
|
||||
#define sfdvARROW_BORDER wxPen(*wxBLACK)
|
||||
|
||||
class WXDLLIMPEXP_SF wxSFLineShape;
|
||||
|
||||
/*! \brief Base class for a line arrows */
|
||||
class WXDLLIMPEXP_SF wxSFArrowBase : public xsSerializable
|
||||
{
|
||||
public:
|
||||
friend class wxSFLineShape;
|
||||
|
||||
XS_DECLARE_CLONABLE_CLASS(wxSFArrowBase);
|
||||
/*! \brief Default constructor */
|
||||
wxSFArrowBase(void);
|
||||
/*!
|
||||
* \brief Constructor.
|
||||
* \param parent Pointer to a parent shape
|
||||
*/
|
||||
wxSFArrowBase(wxSFShapeBase* parent);
|
||||
/*!
|
||||
* \brief Copy constructor.
|
||||
* \param obj Source base arrow shape
|
||||
*/
|
||||
wxSFArrowBase(const wxSFArrowBase& obj);
|
||||
/*! \brief Destructor. */
|
||||
~wxSFArrowBase(void);
|
||||
|
||||
// public member data accessors
|
||||
/*!
|
||||
* \brief Set a parent of the arrow shape.
|
||||
* \param parent Pointer to the parent shape
|
||||
*/
|
||||
void SetParentShape(wxSFShapeBase* parent){m_pParentShape = parent;}
|
||||
/*!
|
||||
* \brief Get pointer to a parent shape.
|
||||
* \return Pointer to a parent shape if exists, otherwise NULL
|
||||
*/
|
||||
wxSFShapeBase* GetParentShape(){return m_pParentShape;}
|
||||
|
||||
// public functions
|
||||
|
||||
// public virtual functions
|
||||
/*!
|
||||
* \brief Draw arrow shape at the end of a virtual line.
|
||||
* \param from Start of the virtual line
|
||||
* \param to End of the virtual line
|
||||
* \param dc Device context for drawing
|
||||
*/
|
||||
virtual void Draw(const wxRealPoint& from, const wxRealPoint& to, wxDC& dc);
|
||||
|
||||
protected:
|
||||
|
||||
// protected member data
|
||||
/*! \brief Pointer to a parent shape. */
|
||||
wxSFShapeBase* m_pParentShape;
|
||||
|
||||
// protected functions
|
||||
/*!
|
||||
* \brief Rotate and move arrow's vertices in accordance of virtual line at which end the arrow will be placed.
|
||||
* \param trg Pointer to array where translated vertices will be stored
|
||||
* \param src Pointer to array of source vertices
|
||||
* \param n Number of vertices
|
||||
* \param from Start of the virtual line
|
||||
* \param to End of the virtual line
|
||||
*/
|
||||
void TranslateArrow(wxPoint *trg, const wxRealPoint *src, int n, const wxRealPoint &from, const wxRealPoint& to);
|
||||
};
|
||||
|
||||
#endif //_WXSFARROWBASE_H
|
||||
163
sdk/wxshapeframework/include/wx/wxsf/BitmapShape.h
Normal file
163
sdk/wxshapeframework/include/wx/wxsf/BitmapShape.h
Normal file
@@ -0,0 +1,163 @@
|
||||
/***************************************************************
|
||||
* Name: BitmapShape.h
|
||||
* Purpose: Defines bitmap shape class
|
||||
* Author: Michal Bližňák (michal.bliznak@tiscali.cz)
|
||||
* Created: 2007-07-22
|
||||
* Copyright: Michal Bližňák
|
||||
* License: wxWidgets license (www.wxwidgets.org)
|
||||
* Notes:
|
||||
**************************************************************/
|
||||
|
||||
#ifndef _WXSFBITMAPSHAPE_H
|
||||
#define _WXSFBITMAPSHAPE_H
|
||||
|
||||
#include <wx/wxsf/RectShape.h>
|
||||
|
||||
// default values
|
||||
#define sfdvBITMAPSHAPE_SCALEIMAGE true
|
||||
#define sfdvBITMAPSHAPE_XPMDATA wxT("")
|
||||
|
||||
/*!
|
||||
* \brief Class encapsulating the bitmap shape. The shape can display and control
|
||||
* files stored in formats supported by wxBitmap class loaded from a file or created
|
||||
* from XPM image. */
|
||||
class WXDLLIMPEXP_SF wxSFBitmapShape : public wxSFRectShape
|
||||
{
|
||||
public:
|
||||
|
||||
XS_DECLARE_CLONABLE_CLASS(wxSFBitmapShape);
|
||||
|
||||
/*! \brief Default constructor. */
|
||||
wxSFBitmapShape(void);
|
||||
/*!
|
||||
* \brief User contructor.
|
||||
* \param pos Initial position
|
||||
* \param bitmapPath BMP file name
|
||||
* \param manager Pointer of parent manager
|
||||
*/
|
||||
wxSFBitmapShape(const wxRealPoint& pos, const wxString& bitmapPath, wxSFDiagramManager* manager);
|
||||
/*!
|
||||
* \brief Copy constructor.
|
||||
* \param obj Source shape
|
||||
*/
|
||||
wxSFBitmapShape(const wxSFBitmapShape& obj);
|
||||
/*! \brief Destructor */
|
||||
virtual ~wxSFBitmapShape(void);
|
||||
|
||||
// public member data accessors
|
||||
/*!
|
||||
* \brief Get full name of a source BMP file.
|
||||
* \return String containig full file name
|
||||
*/
|
||||
wxString GetBitmapPath(){return m_sBitmapPath;}
|
||||
/*!
|
||||
* \brief Enable/disable scaling mode of the bitmap.
|
||||
* \param canscale Set TRUE if the bitmap shape could be scaled
|
||||
*/
|
||||
void EnableScale(bool canscale){m_fCanScale = canscale;}
|
||||
/*!
|
||||
* \brief Get information about the possibility of the shape scaling.
|
||||
* \return TRUE if the shape can be scaled, otherwise FALSE
|
||||
*/
|
||||
bool CanScale(){return m_fCanScale;}
|
||||
|
||||
// public functions
|
||||
/*!
|
||||
* \brief Load a bitmap from the file.
|
||||
* \param file File name (absolute or relative)
|
||||
* \param type Bitmap type (see the wxBitmap class reference)
|
||||
* \return TRUE on success, otherwise FALSE
|
||||
*/
|
||||
bool CreateFromFile(const wxString& file, wxBitmapType type = wxBITMAP_TYPE_BMP );
|
||||
/*!
|
||||
* \brief Load a bitmap from the XPM structure.
|
||||
* \param bits Buffer with the image bits
|
||||
* \return TRUE on success, otherwise FALSE
|
||||
*/
|
||||
bool CreateFromXPM(const char* const* bits);
|
||||
|
||||
// public virtual function
|
||||
/*!
|
||||
* \brief Scale the bitmap shape in both directions. The function can be overrided if neccessary.
|
||||
* \param x Scale ratio in the horizontal direction
|
||||
* \param y Scale ratio in the vertical direction
|
||||
* \param children TRUE if the shape's children shoould be scaled as well, otherwise
|
||||
* the shape will be updated after scaling via Update() function.
|
||||
*/
|
||||
virtual void Scale(double x, double y, bool children = sfWITHCHILDREN);
|
||||
/*!
|
||||
* \brief Event handler called when the user started to drag the shape handle. The function can be overrided if neccessary.
|
||||
* \param handle Reference to the dragged shape handle
|
||||
*/
|
||||
virtual void OnBeginHandle(wxSFShapeHandle& handle);
|
||||
/*!
|
||||
* \brief Event handler called during dragging of the shape handle. The function can be overrided if neccessary.
|
||||
* \param handle Reference to the dragged shape handle
|
||||
*/
|
||||
virtual void OnHandle(wxSFShapeHandle& handle);
|
||||
/*!
|
||||
* \brief Event handler called when the user finished dragging of the shape handle. The function can be overrided if neccessary.
|
||||
* \param handle Reference to the dragged shape handle
|
||||
*/
|
||||
virtual void OnEndHandle(wxSFShapeHandle& handle);
|
||||
|
||||
protected:
|
||||
|
||||
// protected data members
|
||||
/*! \brief String containing the full bitmap file name. */
|
||||
wxString m_sBitmapPath;
|
||||
|
||||
/*! \brief Currently processed (modified) bitmap. */
|
||||
wxBitmap m_Bitmap;
|
||||
/*! \brief Original archived bitmap. */
|
||||
wxBitmap m_OriginalBitmap;
|
||||
bool m_fCanScale;
|
||||
bool m_fRescaleInProgress;
|
||||
wxRealPoint m_nPrevPos;
|
||||
|
||||
// protected functions
|
||||
/*!
|
||||
* \brief Rescale the bitmap shape so it will fit the given extent. The
|
||||
* shape position is not involved (the left-top bitmap corner is not moved).
|
||||
* \param size New bitmap size
|
||||
*/
|
||||
void RescaleImage(const wxRealPoint& size);
|
||||
|
||||
// protected virtual functions
|
||||
/*!
|
||||
* \brief Draw the shape in the normal way. The function can be overrided if neccessary.
|
||||
* \param dc Reference to device context where the shape will be drawn to
|
||||
*/
|
||||
virtual void DrawNormal(wxDC& dc);
|
||||
/*!
|
||||
* \brief Draw the shape in the hower mode (the mouse cursor is above the shape). The function can be overrided if neccessary.
|
||||
* \param dc Reference to device context where the shape will be drawn to
|
||||
*/
|
||||
virtual void DrawHover(wxDC& dc);
|
||||
/*!
|
||||
* \brief Draw the shape in the highlighted mode (another shape is dragged over this shape and this shape will accept the dragged one if it will be dropped on it). The function can be overrided if neccessary.
|
||||
* \param dc Reference to device context where the shape will be drawn to
|
||||
*/
|
||||
virtual void DrawHighlighted(wxDC& dc);
|
||||
|
||||
/*!
|
||||
* \brief Serialize shape's properties to the given XML node.
|
||||
* \param node Pointer to XML node where the shape's property nodes will be append to </param>
|
||||
* \sa wxSFShapeBase::Serialize
|
||||
*/
|
||||
virtual wxXmlNode* Serialize(wxXmlNode* node);
|
||||
/*!
|
||||
* \brief Deserialize shape's properties from the given XML node.
|
||||
* \param node Source XML node containig the shape's property nodes
|
||||
* \sa wxSFShapeBase::Deserialize
|
||||
*/
|
||||
virtual void Deserialize(wxXmlNode* node);
|
||||
|
||||
private:
|
||||
// private functions
|
||||
|
||||
/*! \brief Initialize serializable properties. */
|
||||
void MarkSerializableDataMembers();
|
||||
};
|
||||
|
||||
#endif //_WXSFBITMAPSHAPE_H
|
||||
136
sdk/wxshapeframework/include/wx/wxsf/CanvasHistory.h
Normal file
136
sdk/wxshapeframework/include/wx/wxsf/CanvasHistory.h
Normal file
@@ -0,0 +1,136 @@
|
||||
/***************************************************************
|
||||
* Name: CanvasHistory.h
|
||||
* Purpose: Defines manager for stored canvas states
|
||||
* Author: Michal Bližňák (michal.bliznak@tiscali.cz)
|
||||
* Created: 2007-07-22
|
||||
* Copyright: Michal Bližňák
|
||||
* License: wxWidgets license (www.wxwidgets.org)
|
||||
* Notes:
|
||||
**************************************************************/
|
||||
|
||||
#ifndef _WXSFCANVASHISTORY_H
|
||||
#define _WXSFCANVASHISTORY_H
|
||||
|
||||
#include <wx/wxsf/CanvasState.h>
|
||||
|
||||
#define sfDEFAULT_MAX_CANVAS_STATES 25
|
||||
|
||||
class WXDLLIMPEXP_SF wxSFShapeCanvas;
|
||||
|
||||
/*! \brief
|
||||
* Container class that manages stored canvas states (canvas snapshots) and implements
|
||||
* basic Undo/Redo functionality.
|
||||
*
|
||||
* Two different working modes are available: 'histUSE_SERIALIZATION' mode uses basic
|
||||
* serialization functionality encapsulated by a diagram manager for storing
|
||||
* of current canvas content, but in the 'histUSE_CLONING' mode full copy of
|
||||
* diagram manager content is done via its copy constructor. The first mode is
|
||||
* slower than the second one, but do not require implementation of xsSerializable::Clone()
|
||||
* virtual function in all classes derived from xsSerializable like the second
|
||||
* posible working mode.
|
||||
* \sa wxSFCanvasState, wxSFCanvasHistory::MODE, xsSerializable::Clone, wxXmlSerializer::CopyItems
|
||||
*/
|
||||
class WXDLLIMPEXP_SF wxSFCanvasHistory : public wxObject
|
||||
{
|
||||
public:
|
||||
|
||||
enum MODE
|
||||
{
|
||||
/*! \brief Use serialization for storing of a canvas content */
|
||||
histUSE_SERIALIZATION,
|
||||
/*! \brief Use diagram manager's copy constructor for storing of a canvas content */
|
||||
histUSE_CLONING
|
||||
};
|
||||
|
||||
/*!
|
||||
* \brief Default constructor.
|
||||
* \param hmode Working mode (see MODE enumeration for more details)
|
||||
*/
|
||||
wxSFCanvasHistory(MODE hmode = histUSE_SERIALIZATION);
|
||||
/*!
|
||||
* \brief User constructor.
|
||||
* \param canvas Pointer to managed canvas
|
||||
* \param hmode Working mode (see MODE enumeration for more details)
|
||||
* \sa MODE
|
||||
*/
|
||||
wxSFCanvasHistory(wxSFShapeCanvas *canvas, MODE hmode = histUSE_SERIALIZATION);
|
||||
/*! \brief Destructor. */
|
||||
~wxSFCanvasHistory(void);
|
||||
|
||||
// public member data accessors
|
||||
|
||||
/*!
|
||||
* \brief Set history working mode.
|
||||
*
|
||||
* For more details about available working modes see the wxSFCanvasHistory class
|
||||
* description. Note that all stored canvas history will be cleared after
|
||||
* usage of this function.
|
||||
* \param hmode Working mode
|
||||
* \sa MODE
|
||||
*/
|
||||
void SetMode(MODE hmode);
|
||||
/*! \brief
|
||||
* Set total number of stored canvas states.
|
||||
* \param depth Number of stored canvas states
|
||||
* \sa GetHistoryDepth
|
||||
*/
|
||||
void SetHistoryDepth(size_t depth){m_nHistoryDepth = depth;}
|
||||
/*! \brief
|
||||
* Set pointer to the parent shapes canvas. All Undo/Redo operation defined by this class
|
||||
* will be performed on this shape canvas instance.
|
||||
* \param canvas Pointer to parent shape canvas
|
||||
*/
|
||||
void SetParentCanvas(wxSFShapeCanvas* canvas){m_pParentCanvas = canvas;}
|
||||
|
||||
/*! \brief Get currently used working mode */
|
||||
MODE GetMode(){return m_nWorkingMode;}
|
||||
/*! \brief
|
||||
* Get total number of canvas states which can be stored at the same time.
|
||||
* \return Number of allowed concuretly stored canvas states
|
||||
* \sa SetHistoryDepth
|
||||
*/
|
||||
size_t GetHistoryDepth(){return m_nHistoryDepth;}
|
||||
|
||||
// public functions
|
||||
/*! \brief Save current canvas state. */
|
||||
void SaveCanvasState();
|
||||
/*! \brief Perform the 'Undo' operation. */
|
||||
void RestoreOlderState();
|
||||
/*! \brief Perform the 'Redo' operation. */
|
||||
void RestoreNewerState();
|
||||
/*! \brief Clear all canvas history. */
|
||||
void Clear();
|
||||
|
||||
/*! \brief
|
||||
* The function gives information whether the 'Undo' operation is available
|
||||
* (exists any stored canvas state older than the current one.
|
||||
* \return TRUE if the 'Undo' operation can be performed, otherwise FALSE
|
||||
*/
|
||||
bool CanUndo();
|
||||
/*! \brief
|
||||
* The function gives information whether the 'Redo' operation is available
|
||||
* (exists any stored canvas state newer than the current one.
|
||||
* \return TRUE if the 'Undo' operation can be performed, otherwise FALSE
|
||||
*/
|
||||
bool CanRedo();
|
||||
|
||||
protected:
|
||||
|
||||
// protected data members
|
||||
/*! \brief Pointer to the parent canvas. */
|
||||
wxSFShapeCanvas * m_pParentCanvas;
|
||||
/*! \brief
|
||||
* List of stored canvas state instances.
|
||||
* \sa wxSFCanvasState
|
||||
*/
|
||||
StateList m_lstCanvasStates;
|
||||
/*! \brief Auxilary pointer to current canvas state. */
|
||||
wxSFCanvasState *m_pCurrentCanvasState;
|
||||
/*! \brief Canvas history mode */
|
||||
MODE m_nWorkingMode;
|
||||
|
||||
/*! \brief Total allowed amount of stored canvas states. */
|
||||
size_t m_nHistoryDepth;
|
||||
};
|
||||
|
||||
#endif //_WXSFCANVASHISTORY_H
|
||||
62
sdk/wxshapeframework/include/wx/wxsf/CanvasState.h
Normal file
62
sdk/wxshapeframework/include/wx/wxsf/CanvasState.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/***************************************************************
|
||||
* Name: CanvasState.h
|
||||
* Purpose: Defines container for stored canvas state
|
||||
* Author: Michal Bližňák (michal.bliznak@tiscali.cz)
|
||||
* Created: 2007-07-22
|
||||
* Copyright: Michal Bližňák
|
||||
* License: wxWidgets license (www.wxwidgets.org)
|
||||
* Notes:
|
||||
**************************************************************/
|
||||
|
||||
#ifndef _WXSFCANVASSTATE_H
|
||||
#define _WXSFCANVASSTATE_H
|
||||
|
||||
#include <wx/wxprec.h>
|
||||
|
||||
#include <wx/wxsf/Defs.h>
|
||||
#include <wx/wxsf/DiagramManager.h>
|
||||
|
||||
class wxSFShapeCanvas;
|
||||
/*! \brief
|
||||
* Class which stores one saved state of the shape canvas. The instaces of this
|
||||
* class are managed by the wxSFCanvasHistory class which performs all related Undo/Redo
|
||||
* operations.
|
||||
* \sa wxSFShapeCanvas
|
||||
*/
|
||||
class wxSFCanvasState : public wxObject
|
||||
{
|
||||
friend class wxSFCanvasHistory;
|
||||
|
||||
public:
|
||||
/*! \brief
|
||||
* Constructor for 'histUSE_SERIALIZATION' mode.
|
||||
* \param data Pointer to the stream buffer containig serialized content of the shape canvas
|
||||
*/
|
||||
wxSFCanvasState(wxStreamBuffer* data);
|
||||
/*! \brief
|
||||
* Constructor for 'histUSE_CLONING' mode.
|
||||
* \param data Pointer to temporal data manager
|
||||
*/
|
||||
wxSFCanvasState(wxSFDiagramManager *data);
|
||||
/*! \brief Destructor. */
|
||||
~wxSFCanvasState(void);
|
||||
|
||||
protected:
|
||||
|
||||
// protected functions
|
||||
/*! \brief
|
||||
* Restore stored canvas state.
|
||||
* \param canvas Pointer to the shape canvas which content will be replaced by the stored one
|
||||
*/
|
||||
void Restore(wxSFShapeCanvas* canvas);
|
||||
|
||||
// protected data members
|
||||
/*! \brief Memory buffer used during the serialization/deserialization operations. */
|
||||
wxMemoryBuffer m_dataBuffer;
|
||||
/*! \brief Data manager used for storing of temporal canvas state. */
|
||||
wxSFDiagramManager *m_pDataManager;
|
||||
};
|
||||
|
||||
WX_DECLARE_LIST(wxSFCanvasState, StateList);
|
||||
|
||||
#endif //_WXSFCANVASSTATE_H
|
||||
72
sdk/wxshapeframework/include/wx/wxsf/CircleArrow.h
Normal file
72
sdk/wxshapeframework/include/wx/wxsf/CircleArrow.h
Normal file
@@ -0,0 +1,72 @@
|
||||
/***************************************************************
|
||||
* Name: CircleArrow.h
|
||||
* Purpose: Defines circle arrow for line shapes
|
||||
* Author: Michal Bližňák (michal.bliznak@tiscali.cz)
|
||||
* Created: 2009-04-19
|
||||
* Copyright: Michal Bližňák
|
||||
* License: wxWidgets license (www.wxwidgets.org)
|
||||
* Notes:
|
||||
**************************************************************/
|
||||
|
||||
#ifndef _WXSFCIRCLEARROW_H
|
||||
#define _WXSFCIRCLEARROW_H
|
||||
|
||||
#include <wx/wxsf/SolidArrow.h>
|
||||
|
||||
// default values
|
||||
#define sfdvARROW_RADIUS 4
|
||||
|
||||
/*!
|
||||
* \brief Class extends the wxSFSolidBase class and encapsulates
|
||||
* arrow shape consisting of a filled circle located at the end of the
|
||||
* parent line shape.
|
||||
*/
|
||||
class WXDLLIMPEXP_SF wxSFCircleArrow : public wxSFSolidArrow
|
||||
{
|
||||
public:
|
||||
XS_DECLARE_CLONABLE_CLASS(wxSFCircleArrow);
|
||||
|
||||
/*! \brief Default constructor. */
|
||||
wxSFCircleArrow(void);
|
||||
/*!
|
||||
* \brief User constructor.
|
||||
* \param parent Pointer to the parent shape
|
||||
*/
|
||||
wxSFCircleArrow(wxSFShapeBase* parent);
|
||||
/*!
|
||||
* \brief Copy constructor.
|
||||
* \param obj Reference to the source object
|
||||
*/
|
||||
wxSFCircleArrow(const wxSFCircleArrow& obj);
|
||||
/*! \brief Destructor. */
|
||||
virtual ~wxSFCircleArrow(void);
|
||||
|
||||
// public member data accessors
|
||||
/**
|
||||
* \brief Set radius of circle arrow
|
||||
* \param radius Radius of circle arrow
|
||||
*/
|
||||
void SetRadius(int radius) {m_nRadius = radius;}
|
||||
|
||||
/**
|
||||
* \brief Get radius of circle arrow
|
||||
* \return Radius if circle arrow
|
||||
*/
|
||||
int GetRadius() const {return m_nRadius;}
|
||||
|
||||
// public virtual functions
|
||||
/*!
|
||||
* \brief Draw arrow shape at the end of a virtual line.
|
||||
* \param from Start of the virtual line
|
||||
* \param to End of the virtual line
|
||||
* \param dc Device context for drawing
|
||||
*/
|
||||
virtual void Draw(const wxRealPoint& from, const wxRealPoint& to, wxDC& dc);
|
||||
|
||||
protected:
|
||||
// protected data members
|
||||
/*! \brief Circle radius */
|
||||
int m_nRadius;
|
||||
};
|
||||
|
||||
#endif //_WXSFCIRCLEARROW_H
|
||||
84
sdk/wxshapeframework/include/wx/wxsf/CircleShape.h
Normal file
84
sdk/wxshapeframework/include/wx/wxsf/CircleShape.h
Normal file
@@ -0,0 +1,84 @@
|
||||
/***************************************************************
|
||||
* Name: CircleShape.h
|
||||
* Purpose: Defines circle shape class
|
||||
* Author: Michal Bližňák (michal.bliznak@tiscali.cz)
|
||||
* Created: 2007-07-22
|
||||
* Copyright: Michal Bližňák
|
||||
* License: wxWidgets license (www.wxwidgets.org)
|
||||
* Notes:
|
||||
**************************************************************/
|
||||
|
||||
#ifndef _WXSFCIRCLESHAPE_H
|
||||
#define _WXSFCIRCLESHAPE_H
|
||||
|
||||
#include <wx/wxsf/FixedRectShape.h>
|
||||
|
||||
/*! \brief Class encapsulating the circle shape. */
|
||||
class WXDLLIMPEXP_SF wxSFCircleShape : public wxSFSquareShape
|
||||
{
|
||||
public:
|
||||
XS_DECLARE_CLONABLE_CLASS(wxSFCircleShape);
|
||||
|
||||
/*! \brief Default constructor. */
|
||||
wxSFCircleShape(void);
|
||||
/*! \brief
|
||||
* User constructor.
|
||||
* \param pos Initial shape position
|
||||
* \param radius Circle radius
|
||||
* \param manager Pointer to parent manager
|
||||
*/
|
||||
wxSFCircleShape(const wxRealPoint& pos, double radius, wxSFDiagramManager* manager);
|
||||
/*! \brief
|
||||
* Copy constructor.
|
||||
* \param obj Reference to the source object
|
||||
*/
|
||||
wxSFCircleShape(const wxSFCircleShape& obj);
|
||||
/*! \brief Destructor. */
|
||||
virtual ~wxSFCircleShape();
|
||||
|
||||
// public virtual functions
|
||||
/*!
|
||||
* \brief Test whether the given point is inside the shape. The function
|
||||
* can be overrided if neccessary.
|
||||
* \param pos Examined point
|
||||
* \return TRUE if the point is inside the shape area, otherwise FALSE
|
||||
*/
|
||||
virtual bool Contains(const wxPoint& pos);
|
||||
/*!
|
||||
* \brief Get intersection point of the shape border and a line leading from
|
||||
* 'start' point to 'end' point. The function can be overrided if neccessary.
|
||||
* \param start Starting point of the virtual intersection line
|
||||
* \param end Ending point of the virtual intersection line
|
||||
* \return Intersection point
|
||||
*/
|
||||
virtual wxRealPoint GetBorderPoint(const wxRealPoint& start, const wxRealPoint& end);
|
||||
|
||||
protected:
|
||||
|
||||
// protected virtual functions
|
||||
/*!
|
||||
* \brief Draw the shape in the normal way. The function can be overrided if neccessary.
|
||||
* \param dc Reference to device context where the shape will be drawn to
|
||||
*/
|
||||
virtual void DrawNormal(wxDC& dc);
|
||||
/*!
|
||||
* \brief Draw the shape in the hower mode (the mouse cursor is above the shape).
|
||||
* The function can be overrided if neccessary.
|
||||
* \param dc Reference to device context where the shape will be drawn to
|
||||
*/
|
||||
virtual void DrawHover(wxDC& dc);
|
||||
/*!
|
||||
* \brief Draw the shape in the highlighted mode (another shape is dragged over this
|
||||
* shape and this shape will accept the dragged one if it will be dropped on it).
|
||||
* The function can be overrided if neccessary.
|
||||
* \param dc Reference to device context where the shape will be drawn to
|
||||
*/
|
||||
virtual void DrawHighlighted(wxDC& dc);
|
||||
/*!
|
||||
* \brief Draw shadow under the shape. The function can be overrided if neccessary.
|
||||
* \param dc Reference to device context where the shadow will be drawn to
|
||||
*/
|
||||
virtual void DrawShadow(wxDC& dc);
|
||||
};
|
||||
|
||||
#endif //_WXSFCIRCLESHAPE_H
|
||||
45
sdk/wxshapeframework/include/wx/wxsf/CommonFcn.h
Normal file
45
sdk/wxshapeframework/include/wx/wxsf/CommonFcn.h
Normal file
@@ -0,0 +1,45 @@
|
||||
/***************************************************************
|
||||
* Name: CommonFcn.h
|
||||
* Purpose: Defines set of global (auxiliary) functions
|
||||
* Author: Michal Bližňák (michal.bliznak@tiscali.cz)
|
||||
* Created: 2007-07-22
|
||||
* Copyright: Michal Bližňák
|
||||
* License: wxWidgets license (www.wxwidgets.org)
|
||||
* Notes:
|
||||
**************************************************************/
|
||||
|
||||
#ifndef _WXSFCOMMONFCN_H
|
||||
#define _WXSFCOMMONFCN_H
|
||||
|
||||
#include <wx/wxprec.h>
|
||||
#include <wx/xml/xml.h>
|
||||
|
||||
#include <wx/wxsf/Defs.h>
|
||||
|
||||
namespace wxSFCommonFcn
|
||||
{
|
||||
// data conversion functions
|
||||
WXDLLIMPEXP_SF wxPoint Conv2Point(const wxRealPoint& pt);
|
||||
WXDLLIMPEXP_SF wxSize Conv2Size(const wxRealPoint& pt);
|
||||
WXDLLIMPEXP_SF wxRealPoint Conv2RealPoint(const wxPoint& pt);
|
||||
|
||||
// graphics functions
|
||||
WXDLLIMPEXP_SF wxColour GetHybridColour(const wxColour& orig, const wxColour& modificator);
|
||||
WXDLLIMPEXP_SF bool LinesIntersection(const wxRealPoint& from1, const wxRealPoint& to1, const wxRealPoint& from2, const wxRealPoint& to2, wxRealPoint& i);
|
||||
WXDLLIMPEXP_SF double Distance(const wxRealPoint& pt1, const wxRealPoint& pt2);
|
||||
}
|
||||
|
||||
namespace wxSF
|
||||
{
|
||||
enum ERRCODE
|
||||
{
|
||||
errOK = 0,
|
||||
errNOT_CREATED,
|
||||
errNOT_ACCEPTED,
|
||||
errINVALID_INPUT
|
||||
};
|
||||
|
||||
WXDLLIMPEXP_SF extern const double PI;
|
||||
}
|
||||
|
||||
#endif //_WXSFCOMMONFCN_H
|
||||
311
sdk/wxshapeframework/include/wx/wxsf/ControlShape.h
Normal file
311
sdk/wxshapeframework/include/wx/wxsf/ControlShape.h
Normal file
@@ -0,0 +1,311 @@
|
||||
/***************************************************************
|
||||
* Name: ControlShape.h
|
||||
* Purpose: Defines GUI control shape class
|
||||
* Author: Michal Bližňák (michal.bliznak@tiscali.cz)
|
||||
* Created: 2008-04-30
|
||||
* Copyright: Michal Bližňák
|
||||
* License: wxWidgets license (www.wxwidgets.org)
|
||||
* Notes:
|
||||
**************************************************************/
|
||||
|
||||
#ifndef _WXSFCONTROLSHAPE_H
|
||||
#define _WXSFCONTROLSHAPE_H
|
||||
|
||||
#include <wx/wxsf/RectShape.h>
|
||||
|
||||
#define sfFIT_SHAPE_TO_CONTROL true
|
||||
#define sfFIT_CONTROL_TO_SHAPE false
|
||||
|
||||
#define sfdvCONTROLSHAPE_CONTROLOFFSET 0
|
||||
#define sfdvCONTROLSHAPE_PROCESSEVENTS wxSFControlShape::evtKEY2CANVAS | wxSFControlShape::evtMOUSE2CANVAS
|
||||
#define sfdvCONTROLSHAPE_MODFILL wxBrush(*wxBLUE, wxBDIAGONAL_HATCH)
|
||||
#define sfdvCONTROLSHAPE_MODBORDER wxPen(*wxBLUE, 1, wxSOLID)
|
||||
|
||||
class WXDLLIMPEXP_SF wxSFControlShape;
|
||||
|
||||
/*!
|
||||
* \brief Auxiliary class used by wxSFControlShape. All events generated by a GUI control (widget)
|
||||
* managed by parent control shape are redirected to this event sink which invokes a default event handler
|
||||
* or send a copy of the event to shape canvas if requested.
|
||||
*/
|
||||
class EventSink : public wxEvtHandler
|
||||
{
|
||||
public:
|
||||
/*! \brief Default constructor. */
|
||||
EventSink();
|
||||
/*!
|
||||
* \brief User constructor.
|
||||
* \param parent Pointer to parent control shape
|
||||
*/
|
||||
EventSink(wxSFControlShape *parent);
|
||||
/*! \brief Destructor. */
|
||||
virtual ~EventSink();
|
||||
|
||||
// public functions
|
||||
/*!
|
||||
* \brief Event handler used for delayed processing of a mouse button events.
|
||||
* The handler creates new key event instance and sends it to a shape canvas for further processing.
|
||||
* \param event Mouse event
|
||||
*/
|
||||
void _OnMouseButton(wxMouseEvent &event);
|
||||
/*!
|
||||
* \brief Event handler used for delayed processing of a mouse event (mouse movement).
|
||||
* The handler creates new key event instance and sends it to a shape canvas for further processing.
|
||||
* \param event Mouse event
|
||||
*/
|
||||
void _OnMouseMove(wxMouseEvent &event);
|
||||
/*!
|
||||
* \brief Event handler used for delayed processing of a key event.
|
||||
* The handler creates new key event instance and sends it to a shape canvas for further processing.
|
||||
* \param event Keyboard event
|
||||
*/
|
||||
void _OnKeyDown(wxKeyEvent &event);
|
||||
|
||||
/*! \brief Event handler used for adjusting the parent shape's size in accordance to size of managed GUI control. */
|
||||
void _OnSize(wxSizeEvent &event);
|
||||
|
||||
protected:
|
||||
// protected data members
|
||||
/*! \brief Poineter to parent contol shape. */
|
||||
wxSFControlShape *m_pParentShape;
|
||||
|
||||
// protected functions
|
||||
/*!
|
||||
* \brief Send copy of incomming event to a shape canvas.
|
||||
* \param event Event to be send
|
||||
*/
|
||||
void SendEvent(wxEvent &event);
|
||||
/*!
|
||||
* \brief Modify given mouse event (recalculate the event's position in accordance to parent control
|
||||
* shape's position.
|
||||
* \param event Mouse event to be updated;
|
||||
*/
|
||||
void UpdateMouseEvent(wxMouseEvent &event);
|
||||
};
|
||||
|
||||
/*!
|
||||
* \brief Class encapsulates a special shape able to manage assigned GUI controls (widgets). The GUI control's
|
||||
* position and size can by modified via parent control shape. User can also specify how events incoming from the
|
||||
* managed GUI control are processed.
|
||||
*
|
||||
* Note that the managed controls use a shape canvas as their parent window so these shapes cannot be used
|
||||
* without existing and properly initialized shape canvas. Moreover, managed GUI controls are not serialized in any
|
||||
* way internaly so it is completely up to the user to provide this functionality if needed.
|
||||
*/
|
||||
class WXDLLIMPEXP_SF wxSFControlShape : public wxSFRectShape
|
||||
{
|
||||
public:
|
||||
friend class EventSink;
|
||||
|
||||
XS_DECLARE_CLONABLE_CLASS(wxSFControlShape)
|
||||
|
||||
/*! \brief Way of processing of GUI control's events. */
|
||||
enum EVTPROCESSING
|
||||
{
|
||||
/*! \brief Event isn't processed. */
|
||||
evtNONE = 0,
|
||||
/*! \brief Keyboard events are processed by the GUI control. */
|
||||
evtKEY2GUI = 1,
|
||||
/*! \brief Keyboard events are send to a shape canvas. */
|
||||
evtKEY2CANVAS = 2,
|
||||
/*! \brief Mouse events are processed by the GUI control. */
|
||||
evtMOUSE2GUI = 4,
|
||||
/*! \brief Mouse events are send to a shape canvas. */
|
||||
evtMOUSE2CANVAS = 8
|
||||
};
|
||||
|
||||
/*! \brief Default constructor. */
|
||||
wxSFControlShape();
|
||||
/*!
|
||||
* \brief User constructor.
|
||||
* \param ctrl Pointer to managed GUI control
|
||||
* \param pos Initial position
|
||||
* \param size Initial size
|
||||
* \param manager Pointer to parent diagram manager
|
||||
*/
|
||||
wxSFControlShape(wxWindow *ctrl, const wxRealPoint& pos, const wxRealPoint& size, wxSFDiagramManager* manager);
|
||||
/*!
|
||||
* \brief Copy constructor.
|
||||
* \param obj Object to copy from
|
||||
*/
|
||||
wxSFControlShape(const wxSFControlShape& obj);
|
||||
/*! \brief Default destructor. */
|
||||
virtual ~wxSFControlShape();
|
||||
|
||||
// member data accessors
|
||||
/*!
|
||||
* \brief Set managed GUI control.
|
||||
* \param ctrl Pointer to existing manager GUI control
|
||||
* \param fit TRUE if the control shape should be resized in accordance to the given GUI control
|
||||
*/
|
||||
void SetControl(wxWindow * ctrl, bool fit = sfFIT_SHAPE_TO_CONTROL);
|
||||
/*!
|
||||
* \brief Get pointer to managed GUI control.
|
||||
* \return Pointer to the GUI control
|
||||
*/
|
||||
wxWindow * GetControl() { return m_pControl; }
|
||||
/*!
|
||||
* \brief Set a way how GUI control's events are processed.
|
||||
* \param mask Event processing
|
||||
* \sa EVTPROCESSING
|
||||
*/
|
||||
void SetEventProcessing(int mask){m_nProcessEvents = mask;}
|
||||
/*!
|
||||
* \brief Get a way how GUI control's events are processed.
|
||||
* \return Combination of EVTPROCESSING flags
|
||||
* \sa EVTPROCESSING
|
||||
*/
|
||||
int GetEventProcessing(){return m_nProcessEvents;}
|
||||
/*!
|
||||
* \brief Set control shape's background style used during its modification.
|
||||
* \param brush Reference to used brush
|
||||
*/
|
||||
void SetModFill(const wxBrush& brush){m_ModFill = brush;}
|
||||
/*!
|
||||
* \brief Get control shape's background style used during its modification.
|
||||
* \return Used brush
|
||||
*/
|
||||
wxBrush GetModFill(){return m_ModFill;}
|
||||
/*!
|
||||
* \brief Set control shape's border styl used during its modification.
|
||||
* \param pen Reference to used pen
|
||||
*/
|
||||
void SetModBorder(const wxPen& pen){m_ModBorder = pen;}
|
||||
/*!
|
||||
* \brief Get control shape's border styl used during its modification.
|
||||
* \return Used pen
|
||||
*/
|
||||
wxPen GetModBorder(){return m_ModBorder;}
|
||||
/*!
|
||||
* \brief Set control shape's offset (a gap between the shape's border and managed GUI control).
|
||||
* \param offset Offset size
|
||||
*/
|
||||
void SetControlOffset(int offset){m_nControlOffset = offset;}
|
||||
/*!
|
||||
* \brief Get control shape's offset (a gap between the shape's border and managed GUI control).
|
||||
* \return Offset size
|
||||
*/
|
||||
int GetControlOffset(){return m_nControlOffset;}
|
||||
|
||||
// public functions
|
||||
/*! \brief Update size and position of the managed control according to the parent shape. */
|
||||
void UpdateControl();
|
||||
/*! \brief Update size of the shape position according to the managed control. */
|
||||
void UpdateShape();
|
||||
|
||||
// public virtual functions
|
||||
|
||||
/*!
|
||||
* \brief Scale the shape size by in both directions. The function can be overrided if necessary
|
||||
* (new implementation should call default one ore scale shape's children manualy if neccesary).
|
||||
* \param x Horizontal scale factor
|
||||
* \param y Vertical scale factor
|
||||
* \param children TRUE if the shape's children shoould be scaled as well, otherwise the shape will be updated after scaling via Update() function.
|
||||
*/
|
||||
virtual void Scale(double x, double y, bool children = sfWITHCHILDREN);
|
||||
/*!
|
||||
* \brief Move the shape to the given absolute position. The function can be overrided if necessary.
|
||||
* \param x X coordinate
|
||||
* \param y Y coordinate
|
||||
*/
|
||||
virtual void MoveTo(double x, double y);
|
||||
/*!
|
||||
* \brief Move the shape by the given offset. The function can be overrided if neccessary.
|
||||
* \param x X offset
|
||||
* \param y Y offset
|
||||
*/
|
||||
virtual void MoveBy(double x, double y);
|
||||
|
||||
/*! \brief Upate shape (align all child shapes an resize it to fit them) */
|
||||
virtual void Update();
|
||||
|
||||
/*! \brief Resize the shape to bound all child shapes. The function can be overrided if neccessary. */
|
||||
virtual void FitToChildren();
|
||||
|
||||
/*!
|
||||
* \brief Event handler called at the begining of the shape dragging process.
|
||||
* The function can be overrided if necessary.
|
||||
*
|
||||
* The function is called by the framework (by the shape canvas).
|
||||
* Default implementation does nothing.
|
||||
* \sa wxSFShapeCanvas
|
||||
*/
|
||||
virtual void OnBeginDrag(const wxPoint& pos);
|
||||
/*!
|
||||
* \brief Event handler called at the end of the shape dragging process.
|
||||
* The function can be overrided if necessary.
|
||||
*
|
||||
* The function is called by the framework (by the shape canvas).
|
||||
* Default implementation does nothing.
|
||||
* \param pos Current mouse position
|
||||
* \sa wxSFShapeCanvas
|
||||
*/
|
||||
virtual void OnEndDrag(const wxPoint& pos);
|
||||
/*!
|
||||
* \brief Event handler called when the user started to drag the shape handle.
|
||||
* The function can be overrided if necessary.
|
||||
*
|
||||
* The function is called by the framework (by the shape canvas).
|
||||
* Default implementation does nothing.
|
||||
* \param handle Reference to dragged handle
|
||||
*/
|
||||
virtual void OnBeginHandle(wxSFShapeHandle& handle);
|
||||
/*!
|
||||
* \brief Event handler called during dragging of the shape handle.
|
||||
* The function can be overrided if necessary.
|
||||
*
|
||||
* The function is called by the framework (by the shape canvas).
|
||||
* Default implementation does nothing.
|
||||
* \param handle Reference to dragged handle
|
||||
*/
|
||||
virtual void OnHandle(wxSFShapeHandle& handle);
|
||||
/*!
|
||||
* \brief Event handler called when the user finished dragging of the shape handle.
|
||||
* The function can be overrided if necessary.
|
||||
*
|
||||
* The function is called by the framework (by the shape canvas).
|
||||
* Default implementation does nothing.
|
||||
* \param handle Reference to dragged handle
|
||||
*/
|
||||
virtual void OnEndHandle(wxSFShapeHandle& handle);
|
||||
|
||||
protected:
|
||||
|
||||
// protected data members
|
||||
|
||||
/*! \brief Pointer to manager data control. */
|
||||
wxWindow * m_pControl;
|
||||
/*! \brief Events processing mask */
|
||||
int m_nProcessEvents;
|
||||
|
||||
/*! \brief Brush used during the shape's modification. */
|
||||
wxBrush m_ModFill;
|
||||
/*! \brief Pen used during the shape's modification. */
|
||||
wxPen m_ModBorder;
|
||||
/*! \brief Offset between the shape and managed GUI control. */
|
||||
int m_nControlOffset;
|
||||
|
||||
// protected functions
|
||||
|
||||
private:
|
||||
|
||||
// private data members
|
||||
|
||||
/*! \brief Pointer to parent window. */
|
||||
wxWindow * m_pPrevParent;
|
||||
/*! \brief Pointer to event sink.*/
|
||||
EventSink * m_pEventSink;
|
||||
/*! \brief Previous canvas style. */
|
||||
long m_nPrevStyle;
|
||||
/*! \brief Previously used shape's brush. */
|
||||
wxBrush m_PrevFill;
|
||||
/*! \brief Previously used shape's pen. */
|
||||
wxPen m_PrevBorder;
|
||||
|
||||
// private functions
|
||||
/*! \brief Initialize serializable properties. */
|
||||
void MarkSerializableDataMembers();
|
||||
|
||||
};
|
||||
|
||||
#endif //_WXSFCONTROLSHAPE_H
|
||||
82
sdk/wxshapeframework/include/wx/wxsf/CurveShape.h
Normal file
82
sdk/wxshapeframework/include/wx/wxsf/CurveShape.h
Normal file
@@ -0,0 +1,82 @@
|
||||
/***************************************************************
|
||||
* Name: CurveShape.h
|
||||
* Purpose: Defines curve shape class
|
||||
* Author: Michal Bližňák (michal.bliznak@tiscali.cz)
|
||||
* Created: 2007-07-22
|
||||
* Copyright: Michal Bližňák
|
||||
* License: wxWidgets license (www.wxwidgets.org)
|
||||
* Notes:
|
||||
**************************************************************/
|
||||
|
||||
#ifndef _WXSFCURVESHAPE_H
|
||||
#define _WXSFCURVESHAPE_H
|
||||
|
||||
#include <wx/wxsf/LineShape.h>
|
||||
|
||||
/*!
|
||||
* \brief Interpolation line shape. The class extends wxSFLineShape class and allows
|
||||
* user to create curved connection line.
|
||||
*/
|
||||
class WXDLLIMPEXP_SF wxSFCurveShape : public wxSFLineShape
|
||||
{
|
||||
public:
|
||||
XS_DECLARE_CLONABLE_CLASS(wxSFCurveShape);
|
||||
|
||||
/*! \brief Default constructor. */
|
||||
wxSFCurveShape();
|
||||
/*!
|
||||
* \brief User constructor.
|
||||
* \param src ID of the source shape
|
||||
* \param trg ID of the target shape
|
||||
* \param path Array of line's control points
|
||||
* \param manager Parent parent diagram manager
|
||||
*/
|
||||
wxSFCurveShape(long src, long trg, const wxXS::RealPointList& path, wxSFDiagramManager* manager);
|
||||
/*!
|
||||
* \brief Copy constructor.
|
||||
* \param obj Reference to the source object
|
||||
*/
|
||||
wxSFCurveShape(const wxSFCurveShape& obj);
|
||||
/*! \brief Destructor. */
|
||||
virtual ~wxSFCurveShape();
|
||||
|
||||
// public virtual function
|
||||
/*!
|
||||
* \brief Get line's bounding box. The function can be overrided if neccessary.
|
||||
* \return Bounding rectangle
|
||||
*/
|
||||
virtual wxRect GetBoundingBox();
|
||||
|
||||
// public functions
|
||||
/*!
|
||||
* \brief Get a line point laying on the given line segment and shifted
|
||||
* from the beggining of the segment by given offset.
|
||||
* \param segment Zero-based index of the line segment
|
||||
* \param offset Real value in the range from 0 to 1 which determines
|
||||
* the linepoint offset inside the line segment
|
||||
* \return Line point
|
||||
*/
|
||||
wxRealPoint GetPoint(size_t segment, double offset);
|
||||
|
||||
protected:
|
||||
|
||||
// protected virtual functions
|
||||
/*!
|
||||
* \brief Internal function used for drawing of completed line shape.
|
||||
* \param dc Refernce of the device context where the shape will be darwn to
|
||||
*/
|
||||
virtual void DrawCompleteLine(wxDC& dc);
|
||||
|
||||
private:
|
||||
|
||||
// private functions
|
||||
/*! \brief Auxiliary drawing function. */
|
||||
void GetSegmentQuaternion(size_t segment, wxRealPoint& A, wxRealPoint& B, wxRealPoint& C, wxRealPoint& D);
|
||||
/*! \brief Auxiliary drawing function. */
|
||||
void Catmul_Rom_Kubika(const wxRealPoint& A, const wxRealPoint& B, const wxRealPoint& C, const wxRealPoint& D, wxDC& dc);
|
||||
/*! \brief Auxiliary drawing function. */
|
||||
wxRealPoint Coord_Catmul_Rom_Kubika(const wxRealPoint& p1, const wxRealPoint& p2, const wxRealPoint& p3, const wxRealPoint& p4, double t);
|
||||
|
||||
};
|
||||
|
||||
#endif //_WXSFCURVESHAPE_H
|
||||
21
sdk/wxshapeframework/include/wx/wxsf/Defs.h
Normal file
21
sdk/wxshapeframework/include/wx/wxsf/Defs.h
Normal file
@@ -0,0 +1,21 @@
|
||||
#ifndef _WXSFDEFS_H
|
||||
#define _WXSFDEFS_H
|
||||
|
||||
#ifdef USING_SOURCE_SF
|
||||
#define WXDLLIMPEXP_SF
|
||||
#define WXDLLIMPEXP_DATA_SF(type) type
|
||||
#elif defined( LIB_USINGDLL )
|
||||
#define WXDLLIMPEXP_SF
|
||||
#define WXDLLIMPEXP_DATA_SF(type)
|
||||
#elif defined( WXMAKINGDLL_WXSF )
|
||||
#define WXDLLIMPEXP_SF WXEXPORT
|
||||
#define WXDLLIMPEXP_DATA_SF(type) WXEXPORT type
|
||||
#elif defined(WXUSINGDLL)
|
||||
#define WXDLLIMPEXP_SF WXIMPORT
|
||||
#define WXDLLIMPEXP_DATA_SF(type) WXIMPORT type
|
||||
#else // not making nor using DLL
|
||||
#define WXDLLIMPEXP_SF
|
||||
#define WXDLLIMPEXP_DATA_SF(type) type
|
||||
#endif
|
||||
|
||||
#endif//_WXSFDEFS_H
|
||||
345
sdk/wxshapeframework/include/wx/wxsf/DiagramManager.h
Normal file
345
sdk/wxshapeframework/include/wx/wxsf/DiagramManager.h
Normal file
@@ -0,0 +1,345 @@
|
||||
/***************************************************************
|
||||
* Name: DiagramManager.h
|
||||
* Purpose: Defines shape manager class
|
||||
* Author: Michal Bližňák (michal.bliznak@tiscali.cz)
|
||||
* Created: 2007-07-25
|
||||
* Copyright: Michal Bližňák
|
||||
* License: wxWidgets license (www.wxwidgets.org)
|
||||
* Notes:
|
||||
**************************************************************/
|
||||
|
||||
#ifndef _WXSFDIAGRAMMANAGER_H
|
||||
#define _WXSFDIAGRAMMANAGER_H
|
||||
|
||||
#include <wx/wxsf/ShapeBase.h>
|
||||
#include <wx/wxsf/CommonFcn.h>
|
||||
|
||||
#define serINCLUDE_PARENTS true
|
||||
#define serWITHOUT_PARENTS false
|
||||
#define sfINITIALIZE true
|
||||
#define sfDONT_INITIALIZE false
|
||||
|
||||
class wxSFShapeCanvas;
|
||||
class wxSFLineShape;
|
||||
|
||||
/*! \brief Auxiliary class encapsulation two variables suitable for shape IDs. It is
|
||||
* used for storing infomation about various relevant shape IDs */
|
||||
class IDPair : public wxObject
|
||||
{
|
||||
public:
|
||||
/*! \brief Constructor */
|
||||
IDPair(long oldId, long newId){m_nOldID = oldId; m_nNewID = newId;}
|
||||
long m_nNewID;
|
||||
long m_nOldID;
|
||||
};
|
||||
|
||||
WX_DECLARE_LIST(IDPair, IDList);
|
||||
|
||||
/*! \brief Class encapsulating framework's data layer. Its functions are responsible
|
||||
* for managing shape objects and their serialialization/deserialization. Presentation
|
||||
* layer is provided by wxSFShapeCanvas class which tightly cooperates with the shape
|
||||
* manager.
|
||||
*
|
||||
* An application using wxSF must have at least one shape manager object (one for
|
||||
* each diagram) and every shape manager can be assigned as a source to one shape
|
||||
* canvas (and vice versa).
|
||||
*/
|
||||
class WXDLLIMPEXP_SF wxSFDiagramManager : public wxXmlSerializer
|
||||
{
|
||||
public:
|
||||
XS_DECLARE_CLONABLE_CLASS(wxSFDiagramManager);
|
||||
|
||||
/*! \brief Search mode flags for GetShapeAtPosition function */
|
||||
enum SEARCHMODE
|
||||
{
|
||||
/*! \brief Search for selected shapes only */
|
||||
searchSELECTED,
|
||||
/*! \brief Search for unselected shapes only */
|
||||
searchUNSELECTED,
|
||||
/*! \brief Search for both selected and unselected shapes */
|
||||
searchBOTH
|
||||
};
|
||||
|
||||
/*! \brief Constructor */
|
||||
wxSFDiagramManager();
|
||||
/*! \brief Copy constructor */
|
||||
wxSFDiagramManager(const wxSFDiagramManager &obj);
|
||||
/*! \brief Destructor */
|
||||
virtual ~wxSFDiagramManager();
|
||||
|
||||
// public functions
|
||||
/*! \brief Get wxShapeFramework version number */
|
||||
const wxString& GetVersion() const { return m_sSFVersion; }
|
||||
|
||||
/*!
|
||||
* \brief Create new direct connection between two shapes.
|
||||
*
|
||||
* This function creates new simple connection line (without arrows) between gived
|
||||
* shapes.
|
||||
* \param srcId ID of a source shape
|
||||
* \param trgId ID of target shape
|
||||
* \param saveState Set the parameter TRUE if you wish to save canvas state after the operation
|
||||
* \param err Pointer to variable where operation result will be stored. Can be NULL.
|
||||
* \return Pointer to new connection object. The object is added to the shape canvas automaticaly.
|
||||
* \sa StartInteractiveConnection
|
||||
*/
|
||||
wxSFShapeBase* CreateConnection(long srcId, long trgId, bool saveState = true, wxSF::ERRCODE *err = NULL);
|
||||
/*!
|
||||
* \brief Create new direct connection of given type between two shapes.
|
||||
*
|
||||
* This function creates new simple connection line (without arrows) between gived
|
||||
* shapes.
|
||||
* \param srcId ID of a source shape
|
||||
* \param trgId ID of target shape
|
||||
* \param lineInfo Connection type (any class inherited from wxSFLineShape)
|
||||
* \param saveState Set the parameter TRUE if you wish to save canvas state after the operation
|
||||
* \param err Pointer to variable where operation result will be stored. Can be NULL.
|
||||
* \return Pointer to new connection object. The object is added to the shape canvas automaticaly.
|
||||
* \sa StartInteractiveConnection
|
||||
*/
|
||||
wxSFShapeBase* CreateConnection(long srcId, long trgId, wxClassInfo *lineInfo, bool saveState = true, wxSF::ERRCODE *err = NULL);
|
||||
/*!
|
||||
* \brief Create new direct connection of given type between two shapes.
|
||||
*
|
||||
* This function creates new simple connection line (without arrows) between gived
|
||||
* shapes.
|
||||
* \param srcId ID of a source shape
|
||||
* \param trgId ID of target shape
|
||||
* \param line Pointer to line shape
|
||||
* \param saveState Set the parameter TRUE if you wish to save canvas state after the operation
|
||||
* \param err Pointer to variable where operation result will be stored. Can be NULL.
|
||||
* \return Pointer to new connection object. The object is added to the shape canvas automaticaly.
|
||||
* \sa StartInteractiveConnection
|
||||
*/
|
||||
wxSFShapeBase* CreateConnection(long srcId, long trgId, wxSFLineShape *line, bool saveState = true, wxSF::ERRCODE *err = NULL);
|
||||
/*!
|
||||
* \brief Create new shape and add it to the shape canvas.
|
||||
* \param shapeInfo Shape type
|
||||
* \param saveState Set the parameter TRUE if you wish to save canvas state after the operation
|
||||
* \param err Pointer to variable where operation result will be stored. Can be NULL.
|
||||
* \return Pointer to new shape object. The object is added to the shape canvas automaticaly.
|
||||
*/
|
||||
wxSFShapeBase* AddShape(wxClassInfo* shapeInfo, bool saveState = true, wxSF::ERRCODE *err = NULL);
|
||||
/*!
|
||||
* \brief Create new shape and add it to the shape canvas.
|
||||
* \param shapeInfo Shape type
|
||||
* \param pos Shape position
|
||||
* \param saveState Set the parameter TRUE if you wish to save canvas state after the operation
|
||||
* \param err Pointer to variable where operation result will be stored. Can be NULL.
|
||||
* \return Description
|
||||
* \sa Seealso
|
||||
*/
|
||||
wxSFShapeBase* AddShape(wxClassInfo* shapeInfo, const wxPoint& pos, bool saveState = true, wxSF::ERRCODE *err = NULL);
|
||||
/*!
|
||||
* \brief Add an existing shape to the canvas.
|
||||
* \param shape Pointer to the shape
|
||||
* \param parent Pointer to the parent shape
|
||||
* \param pos Position
|
||||
* \param initialize TRUE if the shape should be reinitilialized, otherwise FALSE
|
||||
* \param saveState TRUE if the canvas state should be saved
|
||||
* \param err Pointer to variable where operation result will be stored. Can be NULL.
|
||||
* \return Pointer to the shape
|
||||
*/
|
||||
wxSFShapeBase* AddShape(wxSFShapeBase* shape, xsSerializable* parent, const wxPoint& pos, bool initialize, bool saveState = true, wxSF::ERRCODE *err = NULL);
|
||||
|
||||
/*!
|
||||
* \brief Remove given shape from the shape canvas. The shape object will be deleted as well.
|
||||
* \param shape Pointer to shape object should be deleted
|
||||
* \param refresh Set the paramater to TRUE if you wish to repaint the canvas
|
||||
*/
|
||||
void RemoveShape(wxSFShapeBase* shape, bool refresh = true);
|
||||
/*!
|
||||
* \brief Remove shapes from the shape canvas
|
||||
* \param selection List of shapes which should be removed from the canvas
|
||||
*/
|
||||
void RemoveShapes(const ShapeList& selection);
|
||||
/*! \brief Remove all shapes from canvas */
|
||||
void Clear();
|
||||
|
||||
/*! \brief Move all shapes so none of it will be located in negative position */
|
||||
void MoveShapesFromNegatives();
|
||||
|
||||
/*! \brief Update all shapes in the diagram manager */
|
||||
void UpdateAll();
|
||||
|
||||
/*!
|
||||
* \brief Serialize complete shape canvas to given file
|
||||
* \param file Output file
|
||||
* \param withroot If TRUE then the root item's properties are serialized as well
|
||||
* \return TRUE on success, otherwise FALSE
|
||||
*/
|
||||
virtual bool SerializeToXml(const wxString& file, bool withroot = false);
|
||||
/*!
|
||||
* \brief Deserialize complete shape canvas from given file
|
||||
* \param file Input file
|
||||
* \return TRUE on success, otherwise FALSE
|
||||
*/
|
||||
virtual bool DeserializeFromXml(const wxString& file);
|
||||
/*!
|
||||
* \brief Serialize complete shape canvas to given output stream
|
||||
* \param outstream Output stream
|
||||
* \param withroot If TRUE then the root item's properties are serialized as well
|
||||
* \return TRUE on success, otherwise FALSE
|
||||
*/
|
||||
virtual bool SerializeToXml(wxOutputStream& outstream, bool withroot = false);
|
||||
/*!
|
||||
* \brief Deserialize complete shape canvas from given input stream
|
||||
* \param instream Input stream
|
||||
* \return TRUE on success, otherwise FALSE
|
||||
*/
|
||||
virtual bool DeserializeFromXml(wxInputStream& instream);
|
||||
/*!
|
||||
* \brief Deserialize shapes from XML and assign them to given parent.
|
||||
*
|
||||
* The parent can be NULL (in that case topmost shapes will have no parent assigned).
|
||||
* \param parent Parent shapes
|
||||
* \param node Source XML node
|
||||
*/
|
||||
virtual void DeserializeObjects(xsSerializable* parent, wxXmlNode* node);
|
||||
|
||||
/*!
|
||||
* \brief Add given shape type to an acceptance list. The acceptance list contains class
|
||||
* names of the shapes which can be inserted into this instance of shapes canvas.
|
||||
* Note: Keyword 'All' behaves like any class name.
|
||||
* \param type Class name of accepted shape object
|
||||
* \sa IsShapeAccepted
|
||||
*/
|
||||
void AcceptShape(const wxString& type);
|
||||
/*!
|
||||
* \brief Tells whether the given shape type is accepted by this canvas instance (it means
|
||||
* whether this shape can be inserted into it).
|
||||
*
|
||||
* The function is typically used by the framework for determination whether class type supplied
|
||||
* by AddShape() function can be inserted into shape canvas.
|
||||
* \param type Class name of examined shape object
|
||||
* \return TRUE if the shape type is accepted, otherwise FALSE.
|
||||
*/
|
||||
bool IsShapeAccepted(const wxString& type);
|
||||
/*!
|
||||
* \brief Clear shape object acceptance list
|
||||
* \sa AcceptShape
|
||||
*/
|
||||
inline void ClearAcceptedShapes() { m_arrAcceptedShapes.Clear(); }
|
||||
/*!
|
||||
* \brief Get reference to shape acceptance list
|
||||
*/
|
||||
inline wxArrayString& GetAcceptedShapes() { return m_arrAcceptedShapes; }
|
||||
|
||||
/*!
|
||||
* \brief Find shape with given ID.
|
||||
* \param id Shape's ID
|
||||
* \return Pointer to shape if exists, otherwise NULL
|
||||
*/
|
||||
wxSFShapeBase* FindShape(long id);
|
||||
/*!
|
||||
* \brief Get list of connections assigned to given parent shape.
|
||||
* \param parent Pointer to parent shape
|
||||
* \param shapeInfo Line object type
|
||||
* \param mode Search mode
|
||||
* \param lines Reference to shape list where pointers to all found connections will be stored
|
||||
* \sa wxSFShapeBase::CONNECTMODE
|
||||
*/
|
||||
void GetAssignedConnections(wxSFShapeBase* parent, wxClassInfo* shapeInfo, wxSFShapeBase::CONNECTMODE mode, ShapeList& lines);
|
||||
/*!
|
||||
* \brief Get list of shapes of given type.
|
||||
* \param shapeInfo Shape object type
|
||||
* \param shapes Reference to shape list where pointers to all found shapes will be stored
|
||||
* \param mode Search algorithm
|
||||
* \sa xsSerializable::SEARCHMODE
|
||||
*/
|
||||
void GetShapes(wxClassInfo* shapeInfo, ShapeList& shapes, xsSerializable::SEARCHMODE mode = xsSerializable::searchBFS);
|
||||
/*!
|
||||
* \brief Get shape at given logical position
|
||||
* \param pos Logical position
|
||||
* \param zorder Z-order of searched shape (usefull if several shapes are located at the given position)
|
||||
* \param mode Search mode
|
||||
* \return Pointer to shape if found, otherwise NULL
|
||||
* \sa SEARCHMODE, wxSFShapeCanvas::DP2LP,, wxSFShapeCanvas::GetShapeUnderCursor
|
||||
*/
|
||||
wxSFShapeBase* GetShapeAtPosition(const wxPoint& pos, int zorder = 1, SEARCHMODE mode = searchBOTH);
|
||||
/*!
|
||||
* \brief Get list of all shapes located at given position
|
||||
* \param pos Logical position
|
||||
* \param shapes Reference to shape list where pointers to all found shapes will be stored
|
||||
* \sa wxSFShapeCanvas::DP2LP
|
||||
*/
|
||||
void GetShapesAtPosition(const wxPoint& pos, ShapeList& shapes);
|
||||
/*!
|
||||
* \brief Get list of shapes located inside given rectangle
|
||||
* \param rct Examined rectangle
|
||||
* \param shapes Reference to shape list where pointers to all found shapes will be stored
|
||||
*/
|
||||
void GetShapesInside(const wxRect& rct, ShapeList& shapes);
|
||||
|
||||
/*!
|
||||
* \brief Determines whether the diagram manager contains some shapes.
|
||||
* \return TRUE if there are no shapes in the manager, otherwise FALSE
|
||||
*/
|
||||
inline bool IsEmpty() const { return ! GetRootItem()->HasChildren(); }
|
||||
/*!
|
||||
* \brief Function finds out whether given shape has some children.
|
||||
* \param parent Pointer to potential parent shape
|
||||
* \return TRUE if the parent shape has children, otherwise FALSE
|
||||
*/
|
||||
bool HasChildren(wxSFShapeBase* parent);
|
||||
/*!
|
||||
* \brief Get neighbour shapes connected to given parent shape.
|
||||
* \param parent Pointer to parent shape (can be NULL for all topmost shapes)
|
||||
* \param neighbours List of neighbour shapes
|
||||
* \param shapeInfo Line object type
|
||||
* \param condir Connection direction
|
||||
* \param direct Set this flag to TRUE if only closest shapes should be found,
|
||||
* otherwise also shapes connected by forked lines will be found (also
|
||||
* constants sfDIRECT and sfINDIRECT can be used)
|
||||
* \sa wxSFShapeBase::CONNECTMODE
|
||||
*/
|
||||
void GetNeighbours(wxSFShapeBase* parent, ShapeList& neighbours, wxClassInfo* shapeInfo, wxSFShapeBase::CONNECTMODE condir, bool direct = true);
|
||||
|
||||
|
||||
// public member data accessors
|
||||
/*!
|
||||
* \brief Set associated shape canvas
|
||||
* \param canvas Pointer to shape canvas
|
||||
*/
|
||||
inline void SetShapeCanvas(wxSFShapeCanvas* canvas) { m_pShapeCanvas = canvas; }
|
||||
/*!
|
||||
* \brief Get associated shape canvas
|
||||
* \return Pointer to shape canvas
|
||||
*/
|
||||
inline wxSFShapeCanvas* GetShapeCanvas() { return m_pShapeCanvas; }
|
||||
|
||||
protected:
|
||||
|
||||
// protected data members
|
||||
/*! \brief List of accepted shape types */
|
||||
wxArrayString m_arrAcceptedShapes;
|
||||
|
||||
wxSFShapeCanvas* m_pShapeCanvas;
|
||||
|
||||
private:
|
||||
|
||||
/*! \brief Auxiliary list */
|
||||
IDList m_lstIDPairs;
|
||||
/*! \brief Auxiliary list */
|
||||
ShapeList m_lstLinesForUpdate;
|
||||
/*! \brief Auxiliary list */
|
||||
ShapeList m_lstGridsForUpdate;
|
||||
|
||||
/*! \brief wxSF version number */
|
||||
wxString m_sSFVersion;
|
||||
|
||||
/*! \brief Update connection shapes after importing/dropping of new shapes */
|
||||
void UpdateConnections();
|
||||
/*! \brief Update grid shapes after importing/dropping of new shapes */
|
||||
void UpdateGrids();
|
||||
|
||||
/*!
|
||||
* \brief Deserialize shapes from XML and assign them to given parent.
|
||||
* \param parent Parent shapes
|
||||
* \param node Source XML node
|
||||
*/
|
||||
void _DeserializeObjects(xsSerializable* parent, wxXmlNode* node);
|
||||
|
||||
};
|
||||
|
||||
#endif //_WXSFDIAGRAMMANAGER_H
|
||||
51
sdk/wxshapeframework/include/wx/wxsf/DiamondArrow.h
Normal file
51
sdk/wxshapeframework/include/wx/wxsf/DiamondArrow.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/***************************************************************
|
||||
* Name: DiamondArrow.h
|
||||
* Purpose: Defines diamond arrow for line shapes
|
||||
* Author: Michal Bližňák (michal.bliznak@tiscali.cz)
|
||||
* Created: 2009-04-18
|
||||
* Copyright: Michal Bližňák
|
||||
* License: wxWidgets license (www.wxwidgets.org)
|
||||
* Notes:
|
||||
**************************************************************/
|
||||
|
||||
#ifndef _WXSFDIAMONDARROW_H
|
||||
#define _WXSFDIAMONDARROW_H
|
||||
|
||||
#include <wx/wxsf/SolidArrow.h>
|
||||
|
||||
/*!
|
||||
* \brief Class extends the wxSFSolidArrow class and encapsulates
|
||||
* arrow shape consisting of filled diamond located the end of the
|
||||
* parent line shape.
|
||||
*/
|
||||
class WXDLLIMPEXP_SF wxSFDiamondArrow : public wxSFSolidArrow
|
||||
{
|
||||
public:
|
||||
XS_DECLARE_CLONABLE_CLASS(wxSFDiamondArrow);
|
||||
|
||||
/*! \brief Default constructor. */
|
||||
wxSFDiamondArrow(void);
|
||||
/*!
|
||||
* \brief User constructor.
|
||||
* \param parent"> Pointer to the parent shape
|
||||
*/
|
||||
wxSFDiamondArrow(wxSFShapeBase* parent);
|
||||
/*!
|
||||
* \brief Copy constructor.
|
||||
* \param obj Reference to the source object
|
||||
*/
|
||||
wxSFDiamondArrow(const wxSFDiamondArrow& obj);
|
||||
/*! \brief Destructor. */
|
||||
virtual ~wxSFDiamondArrow(void);
|
||||
|
||||
// public virtual functions
|
||||
/*!
|
||||
* \brief Draw arrow shape at the end of a virtual line.
|
||||
* \param from Start of the virtual line
|
||||
* \param to End of the virtual line
|
||||
* \param dc Device context for drawing
|
||||
*/
|
||||
virtual void Draw(const wxRealPoint& from, const wxRealPoint& to, wxDC& dc);
|
||||
};
|
||||
|
||||
#endif //_WXSFDIAMONDARROW_H
|
||||
51
sdk/wxshapeframework/include/wx/wxsf/DiamondShape.h
Normal file
51
sdk/wxshapeframework/include/wx/wxsf/DiamondShape.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/***************************************************************
|
||||
* Name: DiamondShape.h
|
||||
* Purpose: Defines diamond shape class
|
||||
* Author: Michal Bližňák (michal.bliznak@tiscali.cz)
|
||||
* Created: 2007-07-22
|
||||
* Copyright: Michal Bližňák
|
||||
* License: wxWidgets license (www.wxwidgets.org)
|
||||
* Notes:
|
||||
**************************************************************/
|
||||
|
||||
#ifndef _WXSFDIAMONDSHAPE_H
|
||||
#define _WXSFDIAMONDSHAPE_H
|
||||
|
||||
#include <wx/wxsf/PolygonShape.h>
|
||||
|
||||
/*!
|
||||
* \brief Class encapsulating the diamond shape. It extends the basic polygon shape.
|
||||
* \sa wxSFPolygonShape
|
||||
*/
|
||||
class WXDLLIMPEXP_SF wxSFDiamondShape : public wxSFPolygonShape
|
||||
{
|
||||
public:
|
||||
XS_DECLARE_CLONABLE_CLASS(wxSFDiamondShape);
|
||||
|
||||
/*! \brief Default constructor. */
|
||||
wxSFDiamondShape();
|
||||
/*!
|
||||
* \brief User constructor.
|
||||
* \param pos Initial position
|
||||
* \param manager Pointer to parent diagram manager
|
||||
*/
|
||||
wxSFDiamondShape(const wxRealPoint& pos, wxSFDiagramManager* manager);
|
||||
/*!
|
||||
* \brief Copy constructor.
|
||||
* \param obj Reference to the source object
|
||||
*/
|
||||
wxSFDiamondShape(const wxSFDiamondShape& obj);
|
||||
/*! \brief Destructor. */
|
||||
virtual ~wxSFDiamondShape();
|
||||
|
||||
// public virtual functions
|
||||
/*!
|
||||
* \brief Test whether the given point is inside the shape. The function
|
||||
* can be overrided if neccessary.
|
||||
* \param pos Examined point
|
||||
* \return TRUE if the point is inside the shape area, otherwise FALSE
|
||||
*/
|
||||
virtual bool Contains(const wxPoint& pos);
|
||||
};
|
||||
|
||||
#endif //_WXSFDIAMONDSHAPE_H
|
||||
204
sdk/wxshapeframework/include/wx/wxsf/EditTextShape.h
Normal file
204
sdk/wxshapeframework/include/wx/wxsf/EditTextShape.h
Normal file
@@ -0,0 +1,204 @@
|
||||
/***************************************************************
|
||||
* Name: EditTextShape.h
|
||||
* Purpose: Defines editable text shape class
|
||||
* Author: Michal Bližňák (michal.bliznak@tiscali.cz)
|
||||
* Created: 2007-07-22
|
||||
* Copyright: Michal Bližňák
|
||||
* License: wxWidgets license (www.wxwidgets.org)
|
||||
* Notes:
|
||||
**************************************************************/
|
||||
|
||||
#ifndef _WXSFEDITTEXTSHAPE_H
|
||||
#define _WXSFEDITTEXTSHAPE_H
|
||||
|
||||
#include <wx/wxsf/TextShape.h>
|
||||
|
||||
#define sfCANCEL_TEXT_CHANGES false
|
||||
#define sfAPPLY_TEXT_CHANGES true
|
||||
|
||||
/*! \brief Default value of wxSFEditTextShape::m_fForceMultiline data member */
|
||||
#define sfdvEDITTEXTSHAPE_FORCEMULTILINE false
|
||||
/*! \brief Default value of wxSFEditTextShape::m_nEditType data member */
|
||||
#define sfdvEDITTEXTSHAPE_EDITTYPE wxSFEditTextShape::editINPLACE
|
||||
|
||||
class WXDLLIMPEXP_SF wxSFEditTextShape;
|
||||
|
||||
/*!
|
||||
* \brief Auxiliary class providing neccessary functionality needed for in-place
|
||||
* modification of a content of the text shape. </summary>
|
||||
* \sa wxSFEditTextShape
|
||||
*/
|
||||
class wxSFContentCtrl : public wxTextCtrl
|
||||
{
|
||||
public:
|
||||
/*!
|
||||
* \brief Constructor.
|
||||
* \param parent Pointer to the parent window
|
||||
* \param id ID of the text control window
|
||||
* \param parentShape Pointer to the parent editable text shape
|
||||
* \param content Initial content of the text control
|
||||
* \param pos Initial position
|
||||
* \param size Initial size
|
||||
* \param style Window style
|
||||
*/
|
||||
wxSFContentCtrl(wxWindow* parent, wxWindowID id, wxSFEditTextShape* parentShape, const wxString& content, wxPoint pos, wxSize size, int style);
|
||||
|
||||
/*!
|
||||
* \brief Finish the editing process/
|
||||
* \param apply If TRUE then changes made in eddited text will be applied on text shape, otherwise it will be canceled
|
||||
*/
|
||||
void Quit( bool apply = sfAPPLY_TEXT_CHANGES );
|
||||
|
||||
protected:
|
||||
|
||||
wxWindow* m_pParent;
|
||||
wxSFEditTextShape* m_pParentShape;
|
||||
wxString m_sPrevContent;
|
||||
|
||||
/*!
|
||||
* \brief Event handler called if the text control lost the focus.
|
||||
* \param event Reference to the event class instance
|
||||
*/
|
||||
void OnKillFocus(wxFocusEvent& event);
|
||||
/*!
|
||||
* \brief Event handler called if the key was pressed in the text control.
|
||||
* \param event Reference to the event class instance
|
||||
*/
|
||||
void OnKeyDown(wxKeyEvent& event);
|
||||
|
||||
DECLARE_EVENT_TABLE();
|
||||
};
|
||||
|
||||
/*!
|
||||
* \brief Auxiliary class providing neccessary functionality needed for dialog-based
|
||||
* modification of a content of the text shape. </summary>
|
||||
* \sa wxSFEditTextShape
|
||||
*/
|
||||
class wxSFDetachedContentCtrl : public wxDialog
|
||||
{
|
||||
public:
|
||||
/*!
|
||||
* \brief Constructor.
|
||||
* \param parent Pointer to the parent window
|
||||
* \param id ID of the text control window
|
||||
* \param title Dialog's title
|
||||
* \param pos Initial position
|
||||
* \param size Initial size
|
||||
* \param style Window style
|
||||
*/
|
||||
wxSFDetachedContentCtrl( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Edit content"),
|
||||
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
|
||||
long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
|
||||
|
||||
/*! \brief Destructor. */
|
||||
~wxSFDetachedContentCtrl();
|
||||
|
||||
// public member data accessors
|
||||
/**
|
||||
* \brief Set content of dialog's text edit control.
|
||||
* \param txt Text content
|
||||
*/
|
||||
void SetContent(const wxString& txt){ m_pText->SetValue( txt ); }
|
||||
/**
|
||||
* \brief Get content of dialog's text edit control.
|
||||
* \return Edited text
|
||||
*/
|
||||
wxString GetContent() const { return m_pText->GetValue(); }
|
||||
|
||||
protected:
|
||||
// protected data members
|
||||
wxTextCtrl* m_pText;
|
||||
};
|
||||
|
||||
/*!
|
||||
* \brief Class encapsulating the editable text shape. It extends the basic text shape.
|
||||
* \sa wxSFTextShape
|
||||
*/
|
||||
class WXDLLIMPEXP_SF wxSFEditTextShape : public wxSFTextShape
|
||||
{
|
||||
public:
|
||||
friend class wxSFContentCtrl;
|
||||
|
||||
XS_DECLARE_CLONABLE_CLASS(wxSFEditTextShape);
|
||||
|
||||
enum EDITTYPE
|
||||
{
|
||||
editINPLACE = 0,
|
||||
editDIALOG,
|
||||
editDISABLED
|
||||
};
|
||||
|
||||
/*! \brief Default constructor. */
|
||||
wxSFEditTextShape(void);
|
||||
/*!
|
||||
* \brief User constructor.
|
||||
* \param pos Initial position
|
||||
* \param txt Text content
|
||||
* \param manager Pointer to the parent canvas
|
||||
*/
|
||||
wxSFEditTextShape(const wxRealPoint& pos, const wxString& txt, wxSFDiagramManager* manager);
|
||||
/*!
|
||||
* \brief Copy constructor.
|
||||
* \param obj Reference to the source object
|
||||
*/
|
||||
wxSFEditTextShape(const wxSFEditTextShape& obj);
|
||||
/*! \brief Destructor. */
|
||||
virtual ~wxSFEditTextShape(void);
|
||||
|
||||
// public member data accessors
|
||||
/**
|
||||
* \brief Set way how the text shape's content can be edited.
|
||||
* \param type Edit control type
|
||||
* \sa EDITTYPE
|
||||
*/
|
||||
void SetEditType( EDITTYPE type) { m_nEditType = type; }
|
||||
/**
|
||||
* \brief Get current type of text shape's edit control.
|
||||
* \return Type of edit control
|
||||
* \sa EDITTYPE
|
||||
*/
|
||||
const EDITTYPE& GetEditType() const { return m_nEditType; }
|
||||
/*!
|
||||
* \brief Get pointer to assigned text control allowing user to change the
|
||||
* shape's content directly in the canvas.
|
||||
* \return Pointer to instance of wxSFContentCtrl class
|
||||
*/
|
||||
wxSFContentCtrl* GetTextCtrl() {return m_pTextCtrl;}
|
||||
|
||||
|
||||
// public functions
|
||||
/*! \brief Switch the shape to a label editation mode. */
|
||||
void EditLabel();
|
||||
/*! \brief Force the edit text control to be multiline
|
||||
* \param multiline If TRUE then the associated text control will be allways multiline
|
||||
*/
|
||||
void ForceMultiline(bool multiline){m_fForceMultiline = multiline;}
|
||||
|
||||
// public virtual functions
|
||||
/*!
|
||||
* \brief Event handler called when the shape was double-clicked.
|
||||
* The function can be overrided if neccessary.
|
||||
* \param pos Mouse position.
|
||||
*/
|
||||
virtual void OnLeftDoubleClick(const wxPoint& pos);
|
||||
/*!
|
||||
* \brief Event handler called when any key is pressed (in the shape canvas).
|
||||
* The function can be overrided if necessary.
|
||||
*
|
||||
* The function is called by the framework (by the shape canvas).
|
||||
* \param key The key code
|
||||
* \return The function must return TRUE if the default event routine should be called
|
||||
* as well, otherwise FALSE
|
||||
* \sa wxSFShapeBase::OnKey
|
||||
*/
|
||||
virtual bool OnKey(int key);
|
||||
|
||||
protected:
|
||||
wxSFContentCtrl* m_pTextCtrl;
|
||||
|
||||
long m_nCurrentState;
|
||||
bool m_fForceMultiline;
|
||||
EDITTYPE m_nEditType;
|
||||
};
|
||||
|
||||
#endif //_WXSFEDITTEXTSHAPE_H
|
||||
87
sdk/wxshapeframework/include/wx/wxsf/EllipseShape.h
Normal file
87
sdk/wxshapeframework/include/wx/wxsf/EllipseShape.h
Normal file
@@ -0,0 +1,87 @@
|
||||
/***************************************************************
|
||||
* Name: EllipseShape.h
|
||||
* Purpose: Defines ellipse shape class
|
||||
* Author: Michal Bližňák (michal.bliznak@tiscali.cz)
|
||||
* Created: 2007-07-22
|
||||
* Copyright: Michal Bližňák
|
||||
* License: wxWidgets license (www.wxwidgets.org)
|
||||
* Notes:
|
||||
**************************************************************/
|
||||
|
||||
#ifndef _WXSFELLIPSESHAPE_H
|
||||
#define _WXSFELLIPSESHAPE_H
|
||||
|
||||
#include <wx/wxsf/RectShape.h>
|
||||
|
||||
/*!
|
||||
* \brief Class encapsulating the ellipse shape. It extends the basic rectangular shape.
|
||||
* \sa wxSFRectShape
|
||||
*/
|
||||
class WXDLLIMPEXP_SF wxSFEllipseShape : public wxSFRectShape
|
||||
{
|
||||
public:
|
||||
XS_DECLARE_CLONABLE_CLASS(wxSFEllipseShape);
|
||||
|
||||
/*! \brief Default constructor. */
|
||||
wxSFEllipseShape(void);
|
||||
/*!
|
||||
* \brief User constructor.
|
||||
* \param pos Initial position
|
||||
* \param size Initial size
|
||||
* \param manager Pointer to parent diagram manager
|
||||
*/
|
||||
wxSFEllipseShape(const wxRealPoint& pos, const wxRealPoint& size, wxSFDiagramManager* manager);
|
||||
/*!
|
||||
* \brief Copy constructor.
|
||||
* \param obj Reference to the source shape
|
||||
*/
|
||||
wxSFEllipseShape(const wxSFEllipseShape& obj);
|
||||
/*! \brief Destructor. */
|
||||
virtual ~wxSFEllipseShape();
|
||||
|
||||
// public virtual functions
|
||||
/*!
|
||||
* \brief Test whether the given point is inside the shape. The function
|
||||
* can be overrided if neccessary.
|
||||
* \param pos Examined point
|
||||
* \return TRUE if the point is inside the shape area, otherwise FALSE
|
||||
*/
|
||||
virtual bool Contains(const wxPoint& pos);
|
||||
/*!
|
||||
* \brief Get intersection point of the shape border and a line leading from
|
||||
* 'start' point to 'end' point. The function can be overrided if neccessary.
|
||||
* \param start Starting point of the virtual intersection line
|
||||
* \param end Ending point of the virtual intersection line
|
||||
* \return Intersection point
|
||||
*/
|
||||
virtual wxRealPoint GetBorderPoint(const wxRealPoint& start, const wxRealPoint& end);
|
||||
|
||||
protected:
|
||||
|
||||
// protected virtual functions
|
||||
/*!
|
||||
* \brief Draw the shape in the normal way. The function can be overrided if neccessary.
|
||||
* \param dc Reference to device context where the shape will be drawn to
|
||||
*/
|
||||
virtual void DrawNormal(wxDC& dc);
|
||||
/*!
|
||||
* \brief Draw the shape in the hower mode (the mouse cursor is above the shape).
|
||||
* The function can be overrided if neccessary.
|
||||
* \param dc Reference to device context where the shape will be drawn to
|
||||
*/
|
||||
virtual void DrawHover(wxDC& dc);
|
||||
/*!
|
||||
* \brief Draw the shape in the highlighted mode (another shape is dragged over this
|
||||
* shape and this shape will accept the dragged one if it will be dropped on it).
|
||||
* The function can be overrided if neccessary.
|
||||
* \param dc Reference to device context where the shape will be drawn to
|
||||
*/
|
||||
virtual void DrawHighlighted(wxDC& dc);
|
||||
/*!
|
||||
* \brief Draw shadow under the shape. The function can be overrided if neccessary.
|
||||
* \param dc Reference to device context where the shadow will be drawn to
|
||||
*/
|
||||
virtual void DrawShadow(wxDC& dc);
|
||||
};
|
||||
|
||||
#endif //_WXSFELLIPSESHAPE_H
|
||||
62
sdk/wxshapeframework/include/wx/wxsf/FixedRectShape.h
Normal file
62
sdk/wxshapeframework/include/wx/wxsf/FixedRectShape.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/***************************************************************
|
||||
* Name: FixedRectShape.h
|
||||
* Purpose: Defines square shape class
|
||||
* Author: Michal Bližňák (michal.bliznak@tiscali.cz)
|
||||
* Created: 2007-07-22
|
||||
* Copyright: Michal Bližňák
|
||||
* License: wxWidgets license (www.wxwidgets.org)
|
||||
* Notes:
|
||||
**************************************************************/
|
||||
|
||||
#ifndef _WXSFSQUARESHAPE_H
|
||||
#define _WXSFSQUARESHAPE_H
|
||||
|
||||
#include <wx/wxsf/RectShape.h>
|
||||
|
||||
/*!
|
||||
* \brief Class encapsulating the square shape. It extends the basic rectangular shape.
|
||||
* \sa wxSFRectShape
|
||||
*/
|
||||
class WXDLLIMPEXP_SF wxSFSquareShape : public wxSFRectShape
|
||||
{
|
||||
public:
|
||||
XS_DECLARE_CLONABLE_CLASS(wxSFSquareShape);
|
||||
|
||||
/*! \brief Default constructor. */
|
||||
wxSFSquareShape(void);
|
||||
/*!
|
||||
* \brief User constructor.
|
||||
* \param pos Initial position
|
||||
* \param size Initial size
|
||||
* \param manager Pointer to parent diagram manager
|
||||
*/
|
||||
wxSFSquareShape(const wxRealPoint& pos, double size, wxSFDiagramManager* manager);
|
||||
/*!
|
||||
* \brief Copy constructor.
|
||||
* \param obj Reference to the source object
|
||||
*/
|
||||
wxSFSquareShape(const wxSFSquareShape& obj);
|
||||
/*! \brief Destructor. */
|
||||
virtual ~wxSFSquareShape();
|
||||
|
||||
// public virtual functions
|
||||
/*!
|
||||
* \brief Scale the shape size by in both directions. The function can be overrided if necessary
|
||||
* (new implementation should call default one ore scale shape's children manualy if neccesary).
|
||||
* \param x Horizontal scale factor
|
||||
* \param y Vertical scale factor
|
||||
* \param children TRUE if the shape's children shoould be scaled as well, otherwise the shape will be updated after scaling via Update() function.
|
||||
*/
|
||||
virtual void Scale(double x, double y, bool children = sfWITHCHILDREN);
|
||||
/*!
|
||||
* \brief Event handler called during dragging of the shape handle.
|
||||
* The function can be overrided if necessary.
|
||||
*
|
||||
* The function is called by the framework (by the shape canvas).
|
||||
* Default implementation does nothing.
|
||||
* \param handle Reference to dragged handle
|
||||
*/
|
||||
virtual void OnHandle(wxSFShapeHandle& handle);
|
||||
};
|
||||
|
||||
#endif //_WXSFSQUARESHAPE_H
|
||||
64
sdk/wxshapeframework/include/wx/wxsf/FlexGridShape.h
Normal file
64
sdk/wxshapeframework/include/wx/wxsf/FlexGridShape.h
Normal file
@@ -0,0 +1,64 @@
|
||||
/***************************************************************
|
||||
* Name: FlexGridShape.h
|
||||
* Purpose: Defines flexible grid shape class
|
||||
* Author: Michal Bližňák (michal.bliznak@tiscali.cz)
|
||||
* Created: 2008-09-27
|
||||
* Copyright: Michal Bližňák
|
||||
* License: wxWidgets license (www.wxwidgets.org)
|
||||
* Notes:
|
||||
**************************************************************/
|
||||
|
||||
#ifndef _WXSFFLEXGRIDSHAPE_H
|
||||
#define _WXSFFLEXGRIDSHAPE_H
|
||||
|
||||
#include <wx/wxsf/GridShape.h>
|
||||
|
||||
// default values
|
||||
|
||||
WX_DEFINE_ARRAY(wxSFShapeBase*, ShapePtrArray);
|
||||
|
||||
/*!
|
||||
* \brief Class encapsulates a rectangular shape derived from wxSFGridShape class which acts as a flexible grid-based
|
||||
* container able to manage other assigned child shapes (it can control their position). The managed
|
||||
* shapes are aligned into defined grid with a behaviour similar to classic wxWidget's wxFlexGridSizer class.
|
||||
*/
|
||||
class WXDLLIMPEXP_SF wxSFFlexGridShape : public wxSFGridShape
|
||||
{
|
||||
public:
|
||||
XS_DECLARE_CLONABLE_CLASS(wxSFFlexGridShape);
|
||||
|
||||
/*! \brief Default constructor. */
|
||||
wxSFFlexGridShape();
|
||||
/*!
|
||||
* \brief User constructor.
|
||||
* \param pos Initial position
|
||||
* \param size Initial size
|
||||
* \param rows Number of grid rows
|
||||
* \param cols Number of grid columns
|
||||
* \param cellspace Additional space between managed shapes
|
||||
* \param manager Pointer to parent diagram manager
|
||||
*/
|
||||
wxSFFlexGridShape(const wxRealPoint& pos, const wxRealPoint& size, int rows, int cols, int cellspace, wxSFDiagramManager* manager);
|
||||
/*!
|
||||
* \brief Copy constructor.
|
||||
* \param obj Reference to the source object
|
||||
*/
|
||||
wxSFFlexGridShape(const wxSFFlexGridShape& obj);
|
||||
/*! \brief Destructor. */
|
||||
virtual ~wxSFFlexGridShape();
|
||||
|
||||
// public virtual functions
|
||||
|
||||
/*! \brief Do layout of assigned child shapes */
|
||||
virtual void DoChildrenLayout();
|
||||
|
||||
private:
|
||||
|
||||
// private data members
|
||||
wxXS::IntArray m_arrRowSizes;
|
||||
wxXS::IntArray m_arrColSizes;
|
||||
|
||||
ShapePtrArray m_arrChildShapes;
|
||||
};
|
||||
|
||||
#endif // _WXSFFLEXGRIDSHAPE_H
|
||||
189
sdk/wxshapeframework/include/wx/wxsf/GridShape.h
Normal file
189
sdk/wxshapeframework/include/wx/wxsf/GridShape.h
Normal file
@@ -0,0 +1,189 @@
|
||||
/***************************************************************
|
||||
* Name: GridShape.h
|
||||
* Purpose: Defines grid shape class
|
||||
* Author: Michal Bližňák (michal.bliznak@tiscali.cz)
|
||||
* Created: 2008-08-02
|
||||
* Copyright: Michal Bližňák
|
||||
* License: wxWidgets license (www.wxwidgets.org)
|
||||
* Notes:
|
||||
**************************************************************/
|
||||
|
||||
#ifndef _WXSFGRIDSHAPE_H
|
||||
#define _WXSFGRIDSHAPE_H
|
||||
|
||||
#include <wx/wxsf/RectShape.h>
|
||||
|
||||
// default values
|
||||
/*! \brief Default value of wxSFGridShape::m_nRows data member. */
|
||||
#define sfdvGRIDSHAPE_ROWS 3
|
||||
/*! \brief Default value of wxSFGridShape::m_nCols data member. */
|
||||
#define sfdvGRIDSHAPE_COLS 3
|
||||
/*! \brief Default value of wxSFGridShape::m_nCellSpace data member. */
|
||||
#define sfdvGRIDSHAPE_CELLSPACE 5
|
||||
|
||||
/*!
|
||||
* \brief Class encapsulates a rectangular shape derived from wxSFRectShape class which acts as a grid-based
|
||||
* container able to manage other assigned child shapes (it can control their position). The managed
|
||||
* shapes are aligned into defined grid with a behaviour similar to classic wxWidget's wxGridSizer class.
|
||||
*/
|
||||
class WXDLLIMPEXP_SF wxSFGridShape : public wxSFRectShape
|
||||
{
|
||||
public:
|
||||
XS_DECLARE_CLONABLE_CLASS(wxSFGridShape);
|
||||
|
||||
friend class wxSFDiagramManager;
|
||||
|
||||
/*! \brief Default constructor. */
|
||||
wxSFGridShape();
|
||||
/*!
|
||||
* \brief User constructor.
|
||||
* \param pos Initial position
|
||||
* \param size Initial size
|
||||
* \param rows Number of grid rows
|
||||
* \param cols Number of grid columns
|
||||
* \param cellspace Additional space between managed shapes
|
||||
* \param manager Pointer to parent diagram manager
|
||||
*/
|
||||
wxSFGridShape(const wxRealPoint& pos, const wxRealPoint& size, int rows, int cols, int cellspace, wxSFDiagramManager* manager);
|
||||
/*!
|
||||
* \brief Copy constructor.
|
||||
* \param obj Reference to the source object
|
||||
*/
|
||||
wxSFGridShape(const wxSFGridShape& obj);
|
||||
/*! \brief Destructor. */
|
||||
virtual ~wxSFGridShape();
|
||||
|
||||
// public member data accessors
|
||||
|
||||
/*!
|
||||
* \brief Set grid dimensions.
|
||||
* \param rows Number of rows
|
||||
* \param cols Number of columns
|
||||
*/
|
||||
void SetDimensions(int rows, int cols);
|
||||
/*!
|
||||
* \brief Set space between grid cells (managed shapes).
|
||||
* \param cellspace Cellspace size
|
||||
*/
|
||||
void SetCellSpace(int cellspace){m_nCellSpace = cellspace;}
|
||||
/*!
|
||||
* \brief Get grid dimensions.
|
||||
* \param rows Pointer to variable where number of rows will be stored
|
||||
* \param cols Pointer to variable where number of columns will be stored
|
||||
*/
|
||||
void GetDimensions(int *rows, int *cols);
|
||||
/*!
|
||||
* \brief Get space between grid cells (managed shapes).
|
||||
* \return Cellspace size
|
||||
*/
|
||||
int GetCellSpace(){return m_nCellSpace;}
|
||||
|
||||
/*!
|
||||
* \brief Get managed shape specified by lexicographic cell index.
|
||||
* \param index Lexicographic index of requested shape
|
||||
* \return Pointer to shape object of given cell index if exists, otherwise NULL
|
||||
*/
|
||||
wxSFShapeBase *GetManagedShape(size_t index);
|
||||
/*!
|
||||
* \brief Get managed shape specified by row and column indexes.
|
||||
* \param row Zero-base row index
|
||||
* \param col Zero-based column index
|
||||
* \return Pointer to shape object stored in specified grid cell if exists, otherwise NULL
|
||||
*/
|
||||
wxSFShapeBase *GetManagedShape(int row, int col);
|
||||
|
||||
// public functions
|
||||
|
||||
/*!
|
||||
* \brief Clear information about managed shapes and set number of rows and columns to zero.
|
||||
*
|
||||
* Note that this function doesn't remove managed (child) shapes from the parent grid shape
|
||||
* (they are still its child shapes but aren't managed anymore).
|
||||
*/
|
||||
void ClearGrid();
|
||||
/*!
|
||||
* \brief Append given shape to the grid at the last managed position.
|
||||
* \param shape Pointer to appended shape
|
||||
*/
|
||||
bool AppendToGrid(wxSFShapeBase *shape);
|
||||
/*!
|
||||
* \brief Insert given shape to the grid at the given position.
|
||||
*
|
||||
* Note that the grid can grow in a vertical direction only, so if the user specify desired
|
||||
* horizontal position bigger than the current number of columns is then this function exits with
|
||||
* an error (false) return value. If specified vertical position exceeds the number or grid rows than
|
||||
* the grid is resized. If the given position (grid cell) is already occupied by some shape then the previous
|
||||
* one will be moved to the grid's last lexicographic position.
|
||||
* \param row Vertical position
|
||||
* \param col Horizontal position
|
||||
* \param shape Pointer to inserted shape
|
||||
* \return True on success, otherwise False
|
||||
*/
|
||||
bool InsertToGrid(int row, int col, wxSFShapeBase *shape);
|
||||
/*!
|
||||
* \brief Insert given shape to the grid at the given position.
|
||||
*
|
||||
* Note that the given index is a lexicographic position of inserted shape. The given shape is inserted before
|
||||
* the existing item 'index', thus InsertToGrid(0, something) will insert an item in such way that it will become
|
||||
* the first grid element.
|
||||
* \param index Lexicographic position of inserted shape
|
||||
* \param shape Pointer to inserted shape
|
||||
* \return True on successe, otherwise False
|
||||
*/
|
||||
bool InsertToGrid(int index, wxSFShapeBase *shape);
|
||||
/**
|
||||
* \brief Remove shape with given ID from the grid.
|
||||
* \param id ID of shape which should be removed
|
||||
*/
|
||||
void RemoveFromGrid(long id);
|
||||
|
||||
// public virtual functions
|
||||
/*! \brief Upate shape (align all child shapes an resize it to fit them) */
|
||||
virtual void Update();
|
||||
|
||||
/*! \brief Resize the shape to bound all child shapes. The function can be overrided if neccessary. */
|
||||
virtual void FitToChildren();
|
||||
|
||||
/*! \brief Do layout of assigned child shapes */
|
||||
virtual void DoChildrenLayout();
|
||||
|
||||
/*!
|
||||
* \brief Event handler called when any shape is dropped above this shape (and the dropped
|
||||
* shape is accepted as a child of this shape). The function can be overrided if necessary.
|
||||
*
|
||||
* The function is called by the framework (by the shape canvas).
|
||||
* \param pos Relative position of dropped shape
|
||||
* \param child Pointer to dropped shape
|
||||
*/
|
||||
virtual void OnChildDropped(const wxRealPoint& pos, wxSFShapeBase *child);
|
||||
|
||||
protected:
|
||||
// protected data members
|
||||
/*! \brief Number of grid rows. */
|
||||
int m_nRows;
|
||||
/*! \brief Number of grid columns. */
|
||||
int m_nCols;
|
||||
/*! \brief Space additional space between managed shapes. */
|
||||
int m_nCellSpace;
|
||||
/*! \brief Array containing the IDs of managed shapes. */
|
||||
wxXS::IntArray m_arrCells;
|
||||
|
||||
// protected functions
|
||||
/*!
|
||||
* \brief Move and resize given shape so it will fit the given bounding rectangle.
|
||||
*
|
||||
* The shape is aligned inside the given bounding rectangle in accordance to the shape's
|
||||
* valign and halign flags.
|
||||
* \param shape Pointer to modified shape
|
||||
* \param rct Bounding rectangle
|
||||
* \sa wxSFShapeBase::SetVAlign, wxSFShapeBase::SetHAlign
|
||||
*/
|
||||
void FitShapeToRect( wxSFShapeBase *shape, const wxRect& rct);
|
||||
|
||||
private:
|
||||
// private functions
|
||||
/*! \brief Initialize serializable properties. */
|
||||
void MarkSerializableDataMembers();
|
||||
};
|
||||
|
||||
#endif // _WXSFGRIDSHAPE_H
|
||||
411
sdk/wxshapeframework/include/wx/wxsf/LineShape.h
Normal file
411
sdk/wxshapeframework/include/wx/wxsf/LineShape.h
Normal file
@@ -0,0 +1,411 @@
|
||||
/***************************************************************
|
||||
* Name: LineShape.h
|
||||
* Purpose: Defines line shape class
|
||||
* Author: Michal Bližňák (michal.bliznak@tiscali.cz)
|
||||
* Created: 2007-07-22
|
||||
* Copyright: Michal Bližňák
|
||||
* License: wxWidgets license (www.wxwidgets.org)
|
||||
* Notes:
|
||||
**************************************************************/
|
||||
|
||||
#ifndef _WXSFLINESHAPE_H
|
||||
#define _WXSFLINESHAPE_H
|
||||
|
||||
#include <wx/wxsf/ShapeBase.h>
|
||||
#include <wx/wxsf/ArrowBase.h>
|
||||
#include <limits.h>
|
||||
|
||||
// default values
|
||||
/*! \brief Default value of undefined ID. */
|
||||
#define sfdvLINESHAPE_UNKNOWNID -1
|
||||
/*! \brief Default value of wxSFLineShape::m_Pen data member. */
|
||||
#define sfdvLINESHAPE_PEN wxPen(*wxBLACK)
|
||||
/*! \brief Default value of wxSFLineShape::m_nDockPoint data member. */
|
||||
#define sfdvLINESHAPE_DOCKPOINT 0
|
||||
/*! \brief Default value of wxSFLineShape::m_nDockPoint data member (start line point). */
|
||||
#define sfdvLINESHAPE_DOCKPOINT_START -1
|
||||
/*! \brief Default value of wxSFLineShape::m_nDockPoint data member (end line point). */
|
||||
#define sfdvLINESHAPE_DOCKPOINT_END -2
|
||||
/*! \brief Default value of wxSFLineShape::m_nDockPoint data member (middle dock point). */
|
||||
#define sfdvLINESHAPE_DOCKPOINT_CENTER INT_MAX
|
||||
/*! \brief Default value of wxSFLineShape::m_nSrcOffset and wxSFLineShape::m_nTrgOffset data members. */
|
||||
#define sfdvLINESHAPE_OFFSET wxRealPoint(-1, -1)
|
||||
/*! \brief Default value of wxSFLineShape::m_nSrcPoint and wxSFLineShape::m_nTrgPoint data members. */
|
||||
#define sfdvLINESHAPE_DEFAULTPOINT wxRealPoint(0, 0)
|
||||
/*! \brief Default value of wxSFLineShape::m_fStandAlone data member. */
|
||||
#define sfdvLINESHAPE_STANDALONE false
|
||||
|
||||
/*!
|
||||
* \brief Basic class encapsulating the multiline consisting of several line segments.
|
||||
*/
|
||||
class WXDLLIMPEXP_SF wxSFLineShape : public wxSFShapeBase
|
||||
{
|
||||
public:
|
||||
|
||||
friend class wxSFShapeCanvas;
|
||||
|
||||
XS_DECLARE_CLONABLE_CLASS(wxSFLineShape);
|
||||
|
||||
/*! \brief Default constructor. */
|
||||
wxSFLineShape(void);
|
||||
/*!
|
||||
* \brief User constructor.
|
||||
* \param src ID of the source shape
|
||||
* \param trg ID of the target shape
|
||||
* \param path List of the line control points (can be empty)
|
||||
* \param manager Pointer to parent shape manager
|
||||
*/
|
||||
wxSFLineShape(long src, long trg, const wxXS::RealPointList& path, wxSFDiagramManager* manager);
|
||||
/**
|
||||
* \brief User constructor.
|
||||
* \param src Starting line point
|
||||
* \param trg Ending line point
|
||||
* \param path List of the line control points (can be empty)
|
||||
* \param manager Pointer to parent shape manager
|
||||
*/
|
||||
wxSFLineShape(const wxRealPoint& src, const wxRealPoint& trg, const wxXS::RealPointList& path, wxSFDiagramManager* manager);
|
||||
/*!
|
||||
* \brief Copy constructor.
|
||||
* \param obj Reference to the source object
|
||||
*/
|
||||
wxSFLineShape(const wxSFLineShape& obj);
|
||||
/*! \brief Destructor. */
|
||||
virtual ~wxSFLineShape(void);
|
||||
|
||||
// public member data accessors
|
||||
/*!
|
||||
* \brief Set line source.
|
||||
* \param id ID of the source shape
|
||||
*/
|
||||
inline void SetSrcShapeId(long id) {m_nSrcShapeId = id;}
|
||||
/*!
|
||||
* \brief Get line source.
|
||||
* \return ID of the source shape
|
||||
*/
|
||||
inline long GetSrcShapeId() {return m_nSrcShapeId;}
|
||||
/*!
|
||||
* \brief Set line target.
|
||||
* \param id ID of the target shape
|
||||
*/
|
||||
inline void SetTrgShapeId(long id) {m_nTrgShapeId = id;}
|
||||
/*!
|
||||
* \brief Get line target.
|
||||
* \return ID of the target shape
|
||||
*/
|
||||
inline long GetTrgShapeId() {return m_nTrgShapeId;}
|
||||
/**
|
||||
* \brief Set user-defined starting line point.
|
||||
* \param src Starting point
|
||||
*/
|
||||
inline void SetSrcPoint(const wxRealPoint& src) {m_nSrcPoint = src;}
|
||||
/*!
|
||||
* \brief Get first line point.
|
||||
* \return First line point
|
||||
*/
|
||||
wxRealPoint GetSrcPoint();
|
||||
/**
|
||||
* \brief Set user-defined ending point.
|
||||
* \param trg Ending point
|
||||
*/
|
||||
inline void SetTrgPoint(const wxRealPoint& trg) {m_nTrgPoint = trg;}
|
||||
/*!
|
||||
* \brief Get last line point.
|
||||
* \return Last line point
|
||||
*/
|
||||
wxRealPoint GetTrgPoint();
|
||||
/**
|
||||
* \brief Get starting and ending line points.
|
||||
* \param src Reference to real point value where starting line point will be stored
|
||||
* \param trg Reference to real point value where ending line point will be stored
|
||||
*/
|
||||
void GetDirectLine(wxRealPoint& src, wxRealPoint& trg);
|
||||
/*!
|
||||
* \brief Set source arrow object.
|
||||
* \param arrow Pointer to the arrow object which will be assigned to the begin of the line
|
||||
*/
|
||||
void SetSrcArrow(wxSFArrowBase* arrow);
|
||||
/*!
|
||||
* \brief Set target arrow object.
|
||||
* \param arrow Pointer to the arrow object which will be assigned to the end of the line
|
||||
*/
|
||||
void SetTrgArrow(wxSFArrowBase* arrow);
|
||||
/*!
|
||||
* \brief Set source arrow object created from its class info.
|
||||
* \param arrowInfo Class info of the arrow class
|
||||
* \return New arrow object
|
||||
*/
|
||||
wxSFArrowBase* SetSrcArrow(wxClassInfo* arrowInfo);
|
||||
/*!
|
||||
* \brief Get object of source arrow.
|
||||
* \return Pointer to the arrow object if exists, otherwise NULL
|
||||
*/
|
||||
inline wxSFArrowBase* GetSrcArrow() {return m_pSrcArrow;}
|
||||
/*!
|
||||
* \brief Set target arrow object created from its class info.
|
||||
* \param arrowInfo Class info of the arrow class
|
||||
* \return New arrow object
|
||||
*/
|
||||
wxSFArrowBase* SetTrgArrow(wxClassInfo* arrowInfo);
|
||||
/*!
|
||||
* \brief Get object of target arrow.
|
||||
* \return Pointer to the arrow object if exists, otherwise NULL
|
||||
*/
|
||||
inline wxSFArrowBase* GetTrgArrow() {return m_pTrgArrow;}
|
||||
/*!
|
||||
* \brief Set line style.
|
||||
* \param pen Reference to wxPen object
|
||||
*/
|
||||
inline void SetLinePen(const wxPen& pen) {m_Pen = pen;}
|
||||
/*!
|
||||
* \brief Get line style.
|
||||
* \return wxPen class
|
||||
*/
|
||||
inline wxPen GetLinePen() const {return m_Pen;}
|
||||
/*!
|
||||
* \brief Set the line dock point. It is a zerro based index of the line
|
||||
* control point which will act as the shape position (value returned by GetRelativePosition() function).
|
||||
* \param index Zerro based index of the line control point
|
||||
* \sa sfdvLINESHAPE_DOCKPOINT_START, sfdvLINESHAPE_DOCKPOINT_END, sfdvLINESHAPE_DOCKPOINT_CENTER
|
||||
*/
|
||||
inline void SetDockPoint(int index) {m_nDockPoint = index;}
|
||||
/*!
|
||||
* \brief Get the line dock point. It is a zerro based index of the line
|
||||
* control point which will act as the shape position (value returned by GetRelativePosition() function).
|
||||
* \return Zerro based index of the line control point (-1 means UNDEFINED)
|
||||
*/
|
||||
inline int GetDockPoint() {return m_nDockPoint;}
|
||||
/*!
|
||||
* \brief Get a list of the line's contol points (their positions).
|
||||
* \return List of control points' positions
|
||||
*/
|
||||
inline wxXS::RealPointList& GetControlPoints() {return m_lstPoints;}
|
||||
/*!
|
||||
* \brief Get a position of given line dock point.
|
||||
* \param dp Dock point
|
||||
* \return The dock point's position if exists, otherwise the line center
|
||||
*/
|
||||
wxRealPoint GetDockPointPosition(int dp);
|
||||
|
||||
/*!
|
||||
* \brief Initialize line's starting point with existing fixed connection point.
|
||||
* \param cp Pointer to connection point
|
||||
*/
|
||||
void SetStartingConnectionPoint(const wxSFConnectionPoint *cp);
|
||||
/*!
|
||||
* \brief Initialize line's ending point with existing fixed connection point.
|
||||
* \param cp Pointer to connection point
|
||||
*/
|
||||
void SetEndingConnectionPoint(const wxSFConnectionPoint *cp);
|
||||
|
||||
/*!
|
||||
* \brief Get starting and ending point of line segment defined by its index.
|
||||
* \param index Index of desired line segment
|
||||
* \param src Reference to variable where starting point will be stored
|
||||
* \param trg Reference to variable where ending point will be stored
|
||||
* \return TRUE if a line segment of given index exists, otherwise FALSE
|
||||
*/
|
||||
bool GetLineSegment(size_t index, wxRealPoint& src, wxRealPoint& trg);
|
||||
/*!
|
||||
* \brief Set stand-alone line mode.
|
||||
* \param enab TRUE for stand-alone line, otherwise FALSE
|
||||
*/
|
||||
inline void SetStandAlone(bool enab) { m_fStandAlone = enab; } /*!
|
||||
* \brief Get stand-alone line mode.
|
||||
* \return TRUE, if the line is stand-alone, otherwise FALSE
|
||||
*/
|
||||
inline bool IsStandAlone() { return m_fStandAlone; }
|
||||
|
||||
// public virtual functions
|
||||
/*!
|
||||
* \brief Get line's bounding box. The function can be overrided if neccessary.
|
||||
* \return Bounding rectangle
|
||||
*/
|
||||
virtual wxRect GetBoundingBox();
|
||||
/*!
|
||||
* \brief Get the shape's absolute position in the canvas.
|
||||
* \return Shape's position
|
||||
*/
|
||||
virtual wxRealPoint GetAbsolutePosition();
|
||||
/*!
|
||||
* \brief Get intersection point of the shape border and a line leading from
|
||||
* 'start' point to 'end' point. The function can be overrided if neccessary.
|
||||
* \param start Starting point of the virtual intersection line
|
||||
* \param end Ending point of the virtual intersection line
|
||||
* \return Intersection point
|
||||
*/
|
||||
virtual wxRealPoint GetBorderPoint(const wxRealPoint& start, const wxRealPoint& end);
|
||||
/*!
|
||||
* \brief Test whether the given point is inside the shape. The function
|
||||
* can be overrided if neccessary.
|
||||
* \param pos Examined point
|
||||
* \return TRUE if the point is inside the shape area, otherwise FALSE
|
||||
*/
|
||||
virtual bool Contains(const wxPoint& pos);
|
||||
/*!
|
||||
* \brief Move the shape to the given absolute position. The function
|
||||
* can be overrided if neccessary.
|
||||
* \param x X coordinate
|
||||
* \param y Y coordinate
|
||||
*/
|
||||
virtual void MoveTo(double x, double y);
|
||||
/*!
|
||||
* \brief Move the shape by the given offset. The function
|
||||
* can be overrided if neccessary.
|
||||
* \param x X offset
|
||||
* \param y Y offset
|
||||
*/
|
||||
virtual void MoveBy(double x, double y);
|
||||
|
||||
/*!
|
||||
* \brief Function called by the framework responsible for creation of shape handles
|
||||
* at the creation time. The function can be overrided if neccesary.
|
||||
*/
|
||||
virtual void CreateHandles();
|
||||
/*!
|
||||
* \brief Event handler called during dragging of the shape handle.
|
||||
* The function can be overrided if necessary.
|
||||
*
|
||||
* The function is called by the framework (by the shape canvas).
|
||||
* \param handle Reference to dragged handle
|
||||
*/
|
||||
virtual void OnHandle(wxSFShapeHandle& handle);
|
||||
/*!
|
||||
* \brief Event handler called when the user finished dragging of the shape handle.
|
||||
* The function can be overrided if necessary.
|
||||
*
|
||||
* The function is called by the framework (by the shape canvas).
|
||||
* Default implementation does nothing.
|
||||
* \param handle Reference to dragged handle
|
||||
*/
|
||||
virtual void OnEndHandle(wxSFShapeHandle& handle);
|
||||
/*!
|
||||
* \brief Event handler called at the begining of the shape dragging process.
|
||||
* The function can be overrided if necessary.
|
||||
*
|
||||
* The function is called by the framework (by the shape canvas).
|
||||
* \sa wxSFShapeCanvas
|
||||
*/
|
||||
virtual void OnBeginDrag(const wxPoint& pos);
|
||||
/*!
|
||||
* \brief Event handler called when the shape is double-clicked by
|
||||
* the left mouse button. The function can be overrided if necessary.
|
||||
*
|
||||
* The function is called by the framework (by the shape canvas).
|
||||
* \param pos Current mouse position
|
||||
* \sa wxSFShapeCanvas
|
||||
*/
|
||||
virtual void OnLeftDoubleClick(const wxPoint& pos);
|
||||
/*!
|
||||
* \brief Scale the shape size by in both directions. The function can be overrided if necessary
|
||||
* (new implementation should call default one ore scale shape's children manualy if neccesary).
|
||||
* \param x Horizontal scale factor
|
||||
* \param y Vertical scale factor
|
||||
* \param children TRUE if the shape's children shoould be scaled as well, otherwise the shape will be updated after scaling via Update() function.
|
||||
*/
|
||||
virtual void Scale(double x, double y, bool children = sfWITHCHILDREN);
|
||||
|
||||
protected:
|
||||
|
||||
/*! \brief The modes in which the line shape can stay. */
|
||||
enum LINEMODE
|
||||
{
|
||||
modeREADY,
|
||||
modeUNDERCONSTRUCTION,
|
||||
modeSRCCHANGE,
|
||||
modeTRGCHANGE
|
||||
};
|
||||
|
||||
// protected data members
|
||||
/*! \brief List of the line's control points. */
|
||||
wxXS::RealPointList m_lstPoints;
|
||||
wxRealPoint m_nPrevPosition;
|
||||
wxPoint m_nUnfinishedPoint;
|
||||
LINEMODE m_nMode;
|
||||
/*! \brief Index of the line dock point. */
|
||||
int m_nDockPoint;
|
||||
|
||||
long m_nSrcShapeId;
|
||||
long m_nTrgShapeId;
|
||||
wxSFArrowBase* m_pSrcArrow;
|
||||
wxSFArrowBase* m_pTrgArrow;
|
||||
|
||||
bool m_fStandAlone;
|
||||
/*! \brief Stand alone line's starting point. */
|
||||
wxRealPoint m_nSrcPoint;
|
||||
/*! \brief Stand alone line's ending point. */
|
||||
wxRealPoint m_nTrgPoint;
|
||||
/*! \brief Modification offset for starting line point. */
|
||||
wxRealPoint m_nSrcOffset;
|
||||
/*! \brief Modification offset for ending line point. */
|
||||
wxRealPoint m_nTrgOffset;
|
||||
|
||||
wxPen m_Pen;
|
||||
|
||||
// protected virtual functions
|
||||
/*!
|
||||
* \brief Draw the shape in the normal way. The function can be overrided if neccessary.
|
||||
* \param dc Reference to device context where the shape will be drawn to
|
||||
*/
|
||||
virtual void DrawNormal(wxDC& dc);
|
||||
/*!
|
||||
* \brief Draw the shape in the hower mode (the mouse cursor is above the shape).
|
||||
* The function can be overrided if neccessary.
|
||||
* \param dc Reference to device context where the shape will be drawn to
|
||||
*/
|
||||
virtual void DrawHover(wxDC& dc);
|
||||
/*!
|
||||
* \brief Draw the shape in the highlighted mode (another shape is dragged over this
|
||||
* shape and this shape will accept the dragged one if it will be dropped on it).
|
||||
* The function can be overrided if neccessary.
|
||||
* \param dc Reference to device context where the shape will be drawn to
|
||||
*/
|
||||
virtual void DrawHighlighted(wxDC& dc);
|
||||
|
||||
/*! \brief Draw completed line. */
|
||||
virtual void DrawCompleteLine(wxDC& dc);
|
||||
/*!
|
||||
* \brief Get index of the line segment intersecting the given point.
|
||||
* \param pos Examined point
|
||||
* \return Zero-based index of line segment located under the given point
|
||||
*/
|
||||
virtual int GetHitLinesegment(const wxPoint& pos);
|
||||
|
||||
// protected functions
|
||||
/*!
|
||||
* \brief Set line shape's working mode.
|
||||
* \param mode Working mode
|
||||
* \sa LINEMODE
|
||||
*/
|
||||
void SetLineMode(LINEMODE mode){m_nMode = mode;}
|
||||
/*!
|
||||
* \brief Get current working mode.
|
||||
* \return Current working mode
|
||||
* \sa LINEMODE
|
||||
*/
|
||||
LINEMODE GetLineMode(){return m_nMode;}
|
||||
/*!
|
||||
* \brief Set next potential control point position (usefull in modeUNDERCONSTRUCTION working mode).
|
||||
* \param pos New potential control point position
|
||||
* \sa LINEMODE
|
||||
*/
|
||||
void SetUnfinishedPoint(const wxPoint& pos){m_nUnfinishedPoint = pos;}
|
||||
|
||||
/*!
|
||||
* \brief Get modified starting line point .
|
||||
* \return Modified starting line point
|
||||
*/
|
||||
wxRealPoint GetModSrcPoint();
|
||||
/*!
|
||||
* \brief Get modified ending line point .
|
||||
* \return Modified ending line point
|
||||
*/
|
||||
wxRealPoint GetModTrgPoint();
|
||||
|
||||
private:
|
||||
// private functions
|
||||
/*! \brief Initialize serializable properties. */
|
||||
void MarkSerializableDataMembers();
|
||||
|
||||
};
|
||||
|
||||
#endif //_WXSFLINESHAPE_H
|
||||
87
sdk/wxshapeframework/include/wx/wxsf/MultiSelRect.h
Normal file
87
sdk/wxshapeframework/include/wx/wxsf/MultiSelRect.h
Normal file
@@ -0,0 +1,87 @@
|
||||
/***************************************************************
|
||||
* Name: MultiSelRect.h
|
||||
* Purpose: Defines aux. multiselection shape class
|
||||
* Author: Michal Bližňák (michal.bliznak@tiscali.cz)
|
||||
* Created: 2007-07-22
|
||||
* Copyright: Michal Bližňák
|
||||
* License: wxWidgets license (www.wxwidgets.org)
|
||||
* Notes:
|
||||
**************************************************************/
|
||||
|
||||
#ifndef _WXSFMULTIRECT_H
|
||||
#define _WXSFMULTIRECT_H
|
||||
|
||||
#include <wx/wxsf/RectShape.h>
|
||||
|
||||
/*!
|
||||
* \brief Auxiliary class encapsulating multiselection rectangle used
|
||||
* in the shape canvas. The class shouldn't be used directly.
|
||||
* \sa wxSFShapeCanvas
|
||||
*/
|
||||
class WXDLLIMPEXP_SF wxSFMultiSelRect : public wxSFRectShape
|
||||
{
|
||||
public:
|
||||
/*! \brief Default constructor. */
|
||||
wxSFMultiSelRect(void);
|
||||
/*! \brief Destructor. */
|
||||
virtual ~wxSFMultiSelRect(void);
|
||||
|
||||
// public virtual functions
|
||||
/*!
|
||||
* \brief Event handler called at the begining of the shape handle dragging process.
|
||||
* The function can be overrided if neccessary.
|
||||
* \param handle Reference to dragged shape handle
|
||||
*/
|
||||
virtual void OnBeginHandle(wxSFShapeHandle& handle);
|
||||
/*!
|
||||
* \brief Event handler called during dragging of the shape handle.
|
||||
* The function can be overrided if necessary.
|
||||
*
|
||||
* The function is called by the framework (by the shape canvas).
|
||||
* \param handle Reference to dragged handle
|
||||
*/
|
||||
virtual void OnHandle(wxSFShapeHandle& handle);
|
||||
/*!
|
||||
* \brief Event handler called at the end of the shape handle dragging process.
|
||||
* The function can be overrided if neccessary.
|
||||
* \param handle Reference to dragged shape handle
|
||||
*/
|
||||
virtual void OnEndHandle(wxSFShapeHandle& handle);
|
||||
|
||||
protected:
|
||||
// protected virtual functions
|
||||
/*!
|
||||
* \brief Event handler called during dragging of the right shape handle.
|
||||
* The function can be overrided if neccessary.
|
||||
* \param handle Reference to dragged shape handle
|
||||
*/
|
||||
virtual void OnRightHandle(wxSFShapeHandle& handle);
|
||||
/*!
|
||||
* \brief Event handler called during dragging of the left shape handle.
|
||||
* The function can be overrided if neccessary.
|
||||
* \param handle Reference to dragged shape handle
|
||||
*/
|
||||
virtual void OnLeftHandle(wxSFShapeHandle& handle);
|
||||
/*!
|
||||
* \brief Event handler called during dragging of the top shape handle.
|
||||
* The function can be overrided if neccessary.
|
||||
* \param handle Reference to dragged shape handle
|
||||
*/
|
||||
virtual void OnTopHandle(wxSFShapeHandle& handle);
|
||||
/*!
|
||||
* \brief Event handler called during dragging of the bottom shape handle.
|
||||
* The function can be overrided if neccessary.
|
||||
* \param handle Reference to dragged shape handle
|
||||
*/
|
||||
virtual void OnBottomHandle(wxSFShapeHandle& handle);
|
||||
|
||||
private:
|
||||
|
||||
// private functions
|
||||
/*! \brief Auxiliary function. */
|
||||
bool AnyWidthExceeded(const wxPoint& delta);
|
||||
/*! \brief Auxiliary function. */
|
||||
bool AnyHeightExceeded(const wxPoint& delta);
|
||||
};
|
||||
|
||||
#endif //_WXSFMULTIRECT_H
|
||||
68
sdk/wxshapeframework/include/wx/wxsf/OpenArrow.h
Normal file
68
sdk/wxshapeframework/include/wx/wxsf/OpenArrow.h
Normal file
@@ -0,0 +1,68 @@
|
||||
/***************************************************************
|
||||
* Name: OpenArrow.h
|
||||
* Purpose: Defines open arrow for line shapes
|
||||
* Author: Michal Bližňák (michal.bliznak@tiscali.cz)
|
||||
* Created: 2007-07-22
|
||||
* Copyright: Michal Bližňák
|
||||
* License: wxWidgets license (www.wxwidgets.org)
|
||||
* Notes:
|
||||
**************************************************************/
|
||||
|
||||
#ifndef _WXSFOPENARROW_H
|
||||
#define _WXSFOPENARROW_H
|
||||
|
||||
#include <wx/wxsf/ArrowBase.h>
|
||||
|
||||
/*!
|
||||
* \brief Class extends the wxSFArrowBase class and encapsulates
|
||||
* arrow shape consisting of single two lines leading from the end of the
|
||||
* parent line shape.
|
||||
*/
|
||||
class WXDLLIMPEXP_SF wxSFOpenArrow : public wxSFArrowBase
|
||||
{
|
||||
public:
|
||||
XS_DECLARE_CLONABLE_CLASS(wxSFOpenArrow);
|
||||
|
||||
/*! \brief Default constructor. */
|
||||
wxSFOpenArrow(void);
|
||||
/*!
|
||||
* \brief User constructor.
|
||||
* \param parent"> Pointer to the parent shape
|
||||
*/
|
||||
wxSFOpenArrow(wxSFShapeBase* parent);
|
||||
/*!
|
||||
* \brief Copy constructor.
|
||||
* \param obj Reference to the source object
|
||||
*/
|
||||
wxSFOpenArrow(const wxSFOpenArrow& obj);
|
||||
/*! \brief Destructor. */
|
||||
virtual ~wxSFOpenArrow(void);
|
||||
|
||||
// public member data accessors
|
||||
/**
|
||||
* \brief Set a pen used for drawing of the arrow.
|
||||
* \param pen Reference to the pen
|
||||
*/
|
||||
void SetArrowPen(const wxPen& pen) {m_Pen = pen;}
|
||||
/**
|
||||
* \brief Get current pen used for drawing of the arrow.
|
||||
* \return Constant reference to current pen
|
||||
*/
|
||||
const wxPen& GetArrowPen() const {return m_Pen;}
|
||||
|
||||
// public virtual functions
|
||||
/*!
|
||||
* \brief Draw arrow shape at the end of a virtual line.
|
||||
* \param from Start of the virtual line
|
||||
* \param to End of the virtual line
|
||||
* \param dc Device context for drawing
|
||||
*/
|
||||
virtual void Draw(const wxRealPoint& from, const wxRealPoint& to, wxDC& dc);
|
||||
|
||||
protected:
|
||||
// protected data members
|
||||
/*! \brief Arrow pen */
|
||||
wxPen m_Pen;
|
||||
};
|
||||
|
||||
#endif //_WXSFOPENARROW_H
|
||||
92
sdk/wxshapeframework/include/wx/wxsf/OrthoShape.h
Normal file
92
sdk/wxshapeframework/include/wx/wxsf/OrthoShape.h
Normal file
@@ -0,0 +1,92 @@
|
||||
/***************************************************************
|
||||
* Name: OrthoShape.h
|
||||
* Purpose: Defines orthogonal line shape class
|
||||
* Author: Michal Bližňák (michal.bliznak@gmail.com)
|
||||
* Created: 2009-04-26
|
||||
* Copyright: Michal Bližňák
|
||||
* License: wxWidgets license (www.wxwidgets.org)
|
||||
* Notes:
|
||||
**************************************************************/
|
||||
|
||||
#ifndef _WXSFORTHOSHAPE_H
|
||||
#define _WXSFORTHOSHAPE_H
|
||||
|
||||
#include <wx/wxsf/LineShape.h>
|
||||
|
||||
/*!
|
||||
* \brief Orthogonal line shape. The class extends wxSFLineShape class and allows
|
||||
* user to create connection line orthgonal to base axis.
|
||||
*/
|
||||
class WXDLLIMPEXP_SF wxSFOrthoLineShape : public wxSFLineShape
|
||||
{
|
||||
public:
|
||||
XS_DECLARE_CLONABLE_CLASS(wxSFOrthoLineShape);
|
||||
|
||||
/*! \brief Default constructor. */
|
||||
wxSFOrthoLineShape();
|
||||
/*!
|
||||
* \brief User constructor.
|
||||
* \param src ID of the source shape
|
||||
* \param trg ID of the target shape
|
||||
* \param path Array of line's control points
|
||||
* \param manager Parent parent diagram manager
|
||||
*/
|
||||
wxSFOrthoLineShape(long src, long trg, const wxXS::RealPointList& path, wxSFDiagramManager* manager);
|
||||
/*!
|
||||
* \brief Copy constructor.
|
||||
* \param obj Reference to the source object
|
||||
*/
|
||||
wxSFOrthoLineShape(const wxSFOrthoLineShape& obj);
|
||||
/*! \brief Destructor. */
|
||||
virtual ~wxSFOrthoLineShape();
|
||||
|
||||
protected:
|
||||
|
||||
// protected virtual functions
|
||||
/*!
|
||||
* \brief Internal function used for drawing of completed line shape.
|
||||
* \param dc Refernce of the device context where the shape will be darwn to
|
||||
*/
|
||||
virtual void DrawCompleteLine(wxDC& dc);
|
||||
/*!
|
||||
* \brief Get index of the line segment intersecting the given point.
|
||||
* \param pos Examined point
|
||||
* \return Zero-based index of line segment located under the given point
|
||||
*/
|
||||
virtual int GetHitLinesegment(const wxPoint& pos);
|
||||
/**
|
||||
* \brief Draw one orthogonal line segment.
|
||||
* \param dc Device context
|
||||
* \param src Starting point of the ortho line segment.
|
||||
* \param trg Ending point of the ortho line segment.
|
||||
*/
|
||||
virtual void DrawLineSegment(wxDC& dc, const wxRealPoint& src, const wxRealPoint& trg);
|
||||
|
||||
// protected functions
|
||||
/**
|
||||
* \brief Get first part of orthogonal line segment.
|
||||
* \param src Staring point of the ortho line segment
|
||||
* \param trg Ending point of the ortho line segment
|
||||
* \param subsrc Starting point of the first part of ortho line segment
|
||||
* \param subtrg Ending point of the first part of ortho line segment
|
||||
*/
|
||||
void GetFirstSubsegment( const wxRealPoint& src, const wxRealPoint& trg, wxRealPoint& subsrc, wxRealPoint& subtrg );
|
||||
/**
|
||||
* \brief Get middle part of orthogonal line segment.
|
||||
* \param src Staring point of the ortho line segment
|
||||
* \param trg Ending point of the ortho line segment
|
||||
* \param subsrc Starting point of the second part of ortho line segment
|
||||
* \param subtrg Ending point of the second part of ortho line segment
|
||||
*/
|
||||
void GetMiddleSubsegment( const wxRealPoint& src, const wxRealPoint& trg, wxRealPoint& subsrc, wxRealPoint& subtrg );
|
||||
/**
|
||||
* \brief Get last part of orthogonal line segment.
|
||||
* \param src Staring point of the ortho line segment
|
||||
* \param trg Ending point of the ortho line segment
|
||||
* \param subsrc Starting point of the third part of ortho line segment
|
||||
* \param subtrg Ending point of the third part of ortho line segment
|
||||
*/
|
||||
void GetLastSubsegment( const wxRealPoint& src, const wxRealPoint& trg, wxRealPoint& subsrc, wxRealPoint& subtrg );
|
||||
};
|
||||
|
||||
#endif //_WXSFORTHOSHAPE_H
|
||||
190
sdk/wxshapeframework/include/wx/wxsf/PolygonShape.h
Normal file
190
sdk/wxshapeframework/include/wx/wxsf/PolygonShape.h
Normal file
@@ -0,0 +1,190 @@
|
||||
/***************************************************************
|
||||
* Name: PolygonShape.h
|
||||
* Purpose: Defines polygonial shape class
|
||||
* Author: Michal Bližňák (michal.bliznak@tiscali.cz)
|
||||
* Created: 2007-07-22
|
||||
* Copyright: Michal Bližňák
|
||||
* License: wxWidgets license (www.wxwidgets.org)
|
||||
* Notes:
|
||||
**************************************************************/
|
||||
|
||||
#ifndef _WXSFPOLYGONSHAPE_H
|
||||
#define _WXSFPOLYGONSHAPE_H
|
||||
|
||||
#include <wx/wxsf/RectShape.h>
|
||||
|
||||
// default values
|
||||
/*! \brief Default value of wxSFPolygonShape::m_fConnextToVertex data member. */
|
||||
#define sfdvPOLYGONSHAPE_VERTEXCONNECTIONS true
|
||||
|
||||
/*!
|
||||
* \brief Class extends the wxSFRectShape and encapsulates general polygon shape
|
||||
* defined by a set of its vertices. The class can be used as it is or as a base class
|
||||
* for shapes with more complex form and functionality.
|
||||
* \sa wxSFDiamondShape
|
||||
*/
|
||||
class WXDLLIMPEXP_SF wxSFPolygonShape : public wxSFRectShape
|
||||
{
|
||||
public:
|
||||
XS_DECLARE_CLONABLE_CLASS(wxSFPolygonShape);
|
||||
|
||||
/*! \brief Default constructor. */
|
||||
wxSFPolygonShape(void);
|
||||
/*!
|
||||
* \brief User constructor.
|
||||
* \param n Number of the polygon vertices
|
||||
* \param pts Array of the polygon vertices
|
||||
* \param pos Relative position of the polygon shape
|
||||
* \param manager Pointer of parent diagram manager
|
||||
*/
|
||||
wxSFPolygonShape(int n, const wxRealPoint pts[], const wxRealPoint& pos, wxSFDiagramManager* manager);
|
||||
/*!
|
||||
* \brief Copy constructor.
|
||||
* \param obj Reference to a source object
|
||||
*/
|
||||
wxSFPolygonShape(const wxSFPolygonShape& obj);
|
||||
/*! \brief Destructor. */
|
||||
virtual ~wxSFPolygonShape(void);
|
||||
|
||||
// public data accessors
|
||||
/*!
|
||||
* \brief Set connecting mode.
|
||||
* \param enable Set this parameter to TRUE if you want to connect
|
||||
* line shapes to the polygons's vertices, otherwise the lines will be connected
|
||||
* to the nearest point of the shape's border.
|
||||
*/
|
||||
void SetConnectToVertex(bool enable){m_fConnectToVertex = enable;}
|
||||
/*!
|
||||
* \brief Get status of connecting mode.
|
||||
* \return TRUE if the line shapes will be connected to the polygon's vertices
|
||||
*/
|
||||
bool IsConnectedToVertex(){return m_fConnectToVertex;}
|
||||
|
||||
// public functions
|
||||
/*!
|
||||
* \brief Set the poly vertices which define its form.
|
||||
* \param n Number of the vertices
|
||||
* \param pts Array of the vertices
|
||||
*/
|
||||
void SetVertices(size_t n, const wxRealPoint pts[]);
|
||||
|
||||
// public virtual functions
|
||||
/*!
|
||||
* \brief Resize the rectangle to bound all child shapes. The function can be overrided if neccessary. */
|
||||
virtual void FitToChildren();
|
||||
/*!
|
||||
* \brief Get intersection point of the shape border and a line leading from
|
||||
* 'start' point to 'end' point. The function can be overrided if neccessary.
|
||||
* \param start Starting point of the virtual intersection line
|
||||
* \param end Ending point of the virtual intersection line
|
||||
* \return Intersection point
|
||||
*/
|
||||
virtual wxRealPoint GetBorderPoint(const wxRealPoint& start, const wxRealPoint& end);
|
||||
/*!
|
||||
* \brief Scale the shape size by in both directions. The function can be overrided if necessary
|
||||
* (new implementation should call default one ore scale shape's children manualy if neccesary).
|
||||
* \param x Horizontal scale factor
|
||||
* \param y Vertical scale factor
|
||||
* \param children TRUE if the shape's children shoould be scaled as well, otherwise the shape will be updated after scaling via Update() function.
|
||||
*/
|
||||
virtual void Scale(double x, double y, bool children = sfWITHCHILDREN);
|
||||
/*!
|
||||
* \brief Event handler called during dragging of the shape handle.
|
||||
* The function can be overrided if necessary.
|
||||
*
|
||||
* The function is called by the framework (by the shape canvas).
|
||||
* \param handle Reference to dragged handle
|
||||
*/
|
||||
virtual void OnHandle(wxSFShapeHandle &handle);
|
||||
|
||||
protected:
|
||||
// protected data members
|
||||
bool m_fConnectToVertex;
|
||||
wxXS::RealPointArray m_arrVertices;
|
||||
|
||||
// protected functions
|
||||
/*!
|
||||
* \brief Move all vertices so the polygon's relative bounding box position
|
||||
* will be located in the origin.
|
||||
*/
|
||||
void NormalizeVertices();
|
||||
/*! \brief Scale polygon's vertices to fit into the rectangle bounding the polygon. */
|
||||
void FitVerticesToBoundingBox();
|
||||
/*! \brief Scale the bounding rectangle to fit all polygons vertices. */
|
||||
void FitBoundingBoxToVertices();
|
||||
/*!
|
||||
* \brief Get polygon extents.
|
||||
* \param minx Position of the left side of polygon's bounding box
|
||||
* \param miny Position of the top side of polygon's bounding box
|
||||
* \param maxx Position of the right side of polygon's bounding box
|
||||
* \param maxy Position of the bottom side of polygon's bounding box
|
||||
*/
|
||||
void GetExtents(double *minx, double *miny, double *maxx, double *maxy);
|
||||
/*!
|
||||
* \brief Get absolute positions of the polygon's vertices.
|
||||
* \param pts Array of translated polygon's verices
|
||||
*/
|
||||
void GetTranslatedVerices(wxRealPoint pts[]);
|
||||
/*!
|
||||
* \brief Get absolute positions of the polygon's vertices.
|
||||
* \param pts Array of translated polygon's verices
|
||||
*/
|
||||
void GetTranslatedVerices(wxPoint pts[]);
|
||||
|
||||
/*!
|
||||
* \brief Draw the polygon shape.
|
||||
* \param dc Refernece to the device context where the shape will be drawn to
|
||||
*/
|
||||
void DrawPolygonShape(wxDC& dc);
|
||||
|
||||
// protected virtual functions
|
||||
/*!
|
||||
* \brief Draw the shape in the normal way. The function can be overrided if neccessary.
|
||||
* \param dc Reference to device context where the shape will be drawn to
|
||||
*/
|
||||
virtual void DrawNormal(wxDC& dc);
|
||||
/*!
|
||||
* \brief Draw the shape in the hower mode (the mouse cursor is above the shape).
|
||||
* The function can be overrided if neccessary.
|
||||
* \param dc Reference to device context where the shape will be drawn to
|
||||
*/
|
||||
virtual void DrawHover(wxDC& dc);
|
||||
/*!
|
||||
* \brief Draw the shape in the highlighted mode (another shape is dragged over this
|
||||
* shape and this shape will accept the dragged one if it will be dropped on it).
|
||||
* The function can be overrided if neccessary.
|
||||
* \param dc Reference to device context where the shape will be drawn to
|
||||
*/
|
||||
virtual void DrawHighlighted(wxDC& dc);
|
||||
/*!
|
||||
* \brief Draw shadow under the shape. The function can be overrided if neccessary.
|
||||
* \param dc Reference to device context where the shadow will be drawn to
|
||||
*/
|
||||
virtual void DrawShadow(wxDC& dc);
|
||||
|
||||
/*!
|
||||
* \brief Serialize shape's properties to the given XML node. The serialization
|
||||
* routine is automatically called by the framework and should take care about serialization
|
||||
* of all specific (non-standard) shape's properties.
|
||||
* \param node Pointer to XML node where the shape's property nodes will be appended to
|
||||
* \sa xsSerializable::Serialize
|
||||
*/
|
||||
virtual wxXmlNode* Serialize(wxXmlNode* node);
|
||||
/*!
|
||||
* \brief Deserialize shape's properties from the given XML node. The
|
||||
* routine is automatically called by the framework and should take care about deserialization
|
||||
* of all specific (non-standard) shape's properties.
|
||||
* \param node Pointer to a source XML node containig the shape's property nodes
|
||||
* \sa xsSerializable::Deserialize
|
||||
*/
|
||||
virtual void Deserialize(wxXmlNode* node);
|
||||
|
||||
private:
|
||||
|
||||
// private functions
|
||||
|
||||
/*! \brief Initialize serializable properties. */
|
||||
void MarkSerializableDataMembers();
|
||||
};
|
||||
|
||||
#endif //_WXSFPOLYGONSHAPE_H
|
||||
62
sdk/wxshapeframework/include/wx/wxsf/Printout.h
Normal file
62
sdk/wxshapeframework/include/wx/wxsf/Printout.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/***************************************************************
|
||||
* Name: Printout.h
|
||||
* Purpose: Defines printout class for shape canvas
|
||||
* Author: Michal Bližňák (michal.bliznak@tiscali.cz)
|
||||
* Created: 2008-05-06
|
||||
* Copyright: Michal Bližňák
|
||||
* License: wxWidgets license (www.wxwidgets.org)
|
||||
* Notes:
|
||||
**************************************************************/
|
||||
|
||||
#ifndef _WXSFPRINTOUT_H
|
||||
#define _WXSFPRINTOUT_H
|
||||
|
||||
#include <wx/print.h>
|
||||
#include <wx/printdlg.h>
|
||||
|
||||
#include <wx/wxsf/Defs.h>
|
||||
|
||||
class WXDLLIMPEXP_SF wxSFShapeCanvas;
|
||||
|
||||
/*!
|
||||
* \brief Auxiliary printout class providing all necessary functions needed for canvas printing.
|
||||
* This class is used internally by the wxSFShapeCanvas class. It can be also used as a base class for other modified
|
||||
* printout classes.
|
||||
*/
|
||||
class WXDLLIMPEXP_SF wxSFPrintout : public wxPrintout
|
||||
{
|
||||
public:
|
||||
/*! \brief Default constructor */
|
||||
wxSFPrintout(const wxString& title, wxSFShapeCanvas *canvas);
|
||||
/*! \brief Default destructor */
|
||||
virtual ~wxSFPrintout();
|
||||
|
||||
// public member data accessors
|
||||
/*!
|
||||
* \brief Set shape canvas which content should be printed.
|
||||
* \param canvas Pointer to shape canvas
|
||||
*/
|
||||
void SetPrintedCanvas( wxSFShapeCanvas *canvas ){m_pCanvas = canvas;}
|
||||
|
||||
// public virtual functions
|
||||
|
||||
/*! \brief Called by printing framework. Functions TRUE if a page of given index already exists in printed document.
|
||||
* This function can be overrided if necessary. */
|
||||
virtual bool HasPage(int page);
|
||||
/*! \brief Called by printing framework. Initialize print job. This function can be overrided if necessary. */
|
||||
virtual bool OnBeginDocument(int startPage, int endPage);
|
||||
/*! \brief Called by printing framework. Deinitialize the print job. This function can be overrided if necessary. */
|
||||
virtual void OnEndDocument();
|
||||
/*! \brief Called by printing framework. It does the print job. This function can be overrided if necessary. */
|
||||
virtual bool OnPrintPage(int page);
|
||||
/*! \brief Called by printing framework. Supply information about printed pages. This function can be overrided if necessary. */
|
||||
virtual void GetPageInfo(int *minPage, int *maxPage, int *selPageFrom, int *selPageTo);
|
||||
|
||||
protected:
|
||||
// protected data members
|
||||
|
||||
/*! \brief Pointer to parent shape canvas. */
|
||||
wxSFShapeCanvas *m_pCanvas;
|
||||
};
|
||||
|
||||
#endif // _WXSFPRINTOUT_H
|
||||
211
sdk/wxshapeframework/include/wx/wxsf/RectShape.h
Normal file
211
sdk/wxshapeframework/include/wx/wxsf/RectShape.h
Normal file
@@ -0,0 +1,211 @@
|
||||
/***************************************************************
|
||||
* Name: RectShape.h
|
||||
* Purpose: Defines rectangular shape class
|
||||
* Author: Michal Bližňák (michal.bliznak@tiscali.cz)
|
||||
* Created: 2007-07-22
|
||||
* Copyright: Michal Bližňák
|
||||
* License: wxWidgets license (www.wxwidgets.org)
|
||||
* Notes:
|
||||
**************************************************************/
|
||||
|
||||
#ifndef _WXSFRECTSHAPE_H
|
||||
#define _WXSFRECTSHAPE_H
|
||||
|
||||
#include <wx/wxsf/ShapeBase.h>
|
||||
|
||||
// default values
|
||||
/*! \brief Default value of wxSFRectShape::m_nRectSize data member. */
|
||||
#define sfdvRECTSHAPE_SIZE wxRealPoint(100, 50)
|
||||
/*! \brief Default value of wxSFRectShape::m_Fill data member. */
|
||||
#define sfdvRECTSHAPE_FILL wxBrush(*wxWHITE)
|
||||
/*! \brief Default value of wxSFRectShape::m_Border data member. */
|
||||
#define sfdvRECTSHAPE_BORDER wxPen(*wxBLACK)
|
||||
/*!
|
||||
* \brief Class encapsulates basic rectangle shape which is used as a base class
|
||||
* for many other shapes that can be bounded by a simple rectangle. The class
|
||||
* provides all functionality needed for manipulating the rectangle's (bounding box)
|
||||
* size and position.
|
||||
*/
|
||||
class WXDLLIMPEXP_SF wxSFRectShape : public wxSFShapeBase
|
||||
{
|
||||
public:
|
||||
XS_DECLARE_CLONABLE_CLASS(wxSFRectShape);
|
||||
|
||||
/*! \brief Default constructor. */
|
||||
wxSFRectShape(void);
|
||||
/*!
|
||||
* \brief User constructor.
|
||||
* \param pos Initial position
|
||||
* \param size Initial size
|
||||
* \param manager Pointer to parent diagram manager
|
||||
*/
|
||||
wxSFRectShape(const wxRealPoint& pos, const wxRealPoint& size, wxSFDiagramManager* manager);
|
||||
/*!
|
||||
* \brief Copy constructor.
|
||||
* \param obj Reference to the source object
|
||||
*/
|
||||
wxSFRectShape(const wxSFRectShape& obj);
|
||||
/*! \brief Destructor. */
|
||||
virtual ~wxSFRectShape(void);
|
||||
|
||||
// public virtual functions
|
||||
/*!
|
||||
* \brief Get shapes's bounding box. The function can be overrided if neccessary.
|
||||
* \return Bounding rectangle
|
||||
*/
|
||||
virtual wxRect GetBoundingBox();
|
||||
/*!
|
||||
* \brief Get intersection point of the shape border and a line leading from
|
||||
* 'start' point to 'end' point. The function can be overrided if neccessary.
|
||||
* \param start Starting point of the virtual intersection line
|
||||
* \param end Ending point of the virtual intersection line
|
||||
* \return Intersection point
|
||||
*/
|
||||
virtual wxRealPoint GetBorderPoint(const wxRealPoint& start, const wxRealPoint& end);
|
||||
|
||||
/*!
|
||||
* \brief Function called by the framework responsible for creation of shape handles
|
||||
* at the creation time. The function can be overrided if neccesary.
|
||||
*/
|
||||
virtual void CreateHandles();
|
||||
/*!
|
||||
* \brief Event handler called during dragging of the shape handle.
|
||||
* The function can be overrided if necessary.
|
||||
*
|
||||
* The function is called by the framework (by the shape canvas).
|
||||
* \param handle Reference to dragged handle
|
||||
*/
|
||||
virtual void OnHandle(wxSFShapeHandle& handle);
|
||||
/*!
|
||||
* \brief Event handler called when the user started to drag the shape handle.
|
||||
* The function can be overrided if necessary.
|
||||
*
|
||||
* The function is called by the framework (by the shape canvas).
|
||||
* \param handle Reference to dragged handle
|
||||
*/
|
||||
virtual void OnBeginHandle(wxSFShapeHandle& handle);
|
||||
|
||||
/*! \brief Resize the shape to bound all child shapes. The function can be overrided if neccessary. */
|
||||
virtual void FitToChildren();
|
||||
/*!
|
||||
* \brief Scale the shape size by in both directions. The function can be overrided if necessary
|
||||
* (new implementation should call default one ore scale shape's children manualy if neccesary).
|
||||
* \param x Horizontal scale factor
|
||||
* \param y Vertical scale factor
|
||||
* \param children TRUE if the shape's children shoould be scaled as well, otherwise the shape will be updated after scaling via Update() function.
|
||||
*/
|
||||
virtual void Scale(double x, double y, bool children = sfWITHCHILDREN);
|
||||
|
||||
// public data accessors
|
||||
/*!
|
||||
* \brief Set rectangle's fill style.
|
||||
* \param brush Refernce to a brush object
|
||||
*/
|
||||
void SetFill(const wxBrush& brush){m_Fill = brush;}
|
||||
/*!
|
||||
* \brief Get current fill style.
|
||||
* \return Current brush
|
||||
*/
|
||||
wxBrush GetFill() const {return m_Fill;}
|
||||
/*!
|
||||
* \brief Set rectangle's border style.
|
||||
* \param pen Reference to a pen object
|
||||
*/
|
||||
void SetBorder(const wxPen& pen){m_Border = pen;}
|
||||
/*!
|
||||
* \brief Get current border style.
|
||||
* \return Current pen
|
||||
*/
|
||||
wxPen GetBorder() const {return m_Border;}
|
||||
/*!
|
||||
* \brief Set the rectangle size.
|
||||
* \param size New size
|
||||
*/
|
||||
void SetRectSize(const wxRealPoint& size){m_nRectSize = size;}
|
||||
/*!
|
||||
* \brief Set the rectangle size.
|
||||
* \param x Horizontal size
|
||||
* \param y Verical size
|
||||
*/
|
||||
void SetRectSize(double x, double y){m_nRectSize.x = x; m_nRectSize.y = y;}
|
||||
/*!
|
||||
* \brief Get the rectangle size.
|
||||
* \return Current size
|
||||
*/
|
||||
wxRealPoint GetRectSize() const {return m_nRectSize;}
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// protected data members
|
||||
/*! \brief Pen object used for drawing of the rectangle border. */
|
||||
wxPen m_Border;
|
||||
/*! \brief Brush object used for drawing of the rectangle body. */
|
||||
wxBrush m_Fill;
|
||||
/*! \brief The rectangle size. */
|
||||
wxRealPoint m_nRectSize;
|
||||
|
||||
// protected virtual functions
|
||||
/*!
|
||||
* \brief Draw the shape in the normal way. The function can be overrided if neccessary.
|
||||
* \param dc Reference to device context where the shape will be drawn to
|
||||
*/
|
||||
virtual void DrawNormal(wxDC& dc);
|
||||
/*!
|
||||
* \brief Draw the shape in the hower mode (the mouse cursor is above the shape).
|
||||
* The function can be overrided if neccessary.
|
||||
* \param dc Reference to device context where the shape will be drawn to
|
||||
*/
|
||||
virtual void DrawHover(wxDC& dc);
|
||||
/*!
|
||||
* \brief Draw the shape in the highlighted mode (another shape is dragged over this
|
||||
* shape and this shape will accept the dragged one if it will be dropped on it).
|
||||
* The function can be overrided if neccessary.
|
||||
* \param dc Reference to device context where the shape will be drawn to
|
||||
*/
|
||||
virtual void DrawHighlighted(wxDC& dc);
|
||||
/*!
|
||||
* \brief Draw shadow under the shape. The function can be overrided if neccessary.
|
||||
* \param dc Reference to device context where the shadow will be drawn to
|
||||
*/
|
||||
virtual void DrawShadow(wxDC& dc);
|
||||
|
||||
/*!
|
||||
* \brief Event handler called during dragging of the right shape handle.
|
||||
* The function can be overrided if neccessary.
|
||||
* \param handle Reference to dragged shape handle
|
||||
*/
|
||||
virtual void OnRightHandle(wxSFShapeHandle& handle);
|
||||
/*!
|
||||
* \brief Event handler called during dragging of the left shape handle.
|
||||
* The function can be overrided if neccessary.
|
||||
* \param handle Reference to dragged shape handle
|
||||
*/
|
||||
virtual void OnLeftHandle(wxSFShapeHandle& handle);
|
||||
/*!
|
||||
* \brief Event handler called during dragging of the top shape handle.
|
||||
* The function can be overrided if neccessary.
|
||||
* \param handle Reference to dragged shape handle
|
||||
*/
|
||||
virtual void OnTopHandle(wxSFShapeHandle& handle);
|
||||
/*!
|
||||
* \brief Event handler called during dragging of the bottom shape handle.
|
||||
* The function can be overrided if neccessary.
|
||||
* \param handle Reference to dragged shape handle
|
||||
*/
|
||||
virtual void OnBottomHandle(wxSFShapeHandle& handle);
|
||||
|
||||
private:
|
||||
|
||||
// private functions
|
||||
|
||||
/*! \brief Initialize serializable properties. */
|
||||
void MarkSerializableDataMembers();
|
||||
|
||||
/*! \brief Auxiliary data member. */
|
||||
wxRealPoint m_nPrevSize;
|
||||
/*! \brief Auxiliary data member. */
|
||||
wxRealPoint m_nPrevPosition;
|
||||
};
|
||||
|
||||
#endif //_WXSFRECTSHAPE_H
|
||||
116
sdk/wxshapeframework/include/wx/wxsf/RoundRectShape.h
Normal file
116
sdk/wxshapeframework/include/wx/wxsf/RoundRectShape.h
Normal file
@@ -0,0 +1,116 @@
|
||||
/***************************************************************
|
||||
* Name: RoundRectShape.h
|
||||
* Purpose: Defines rounded rectangular shape class
|
||||
* Author: Michal Bližňák (michal.bliznak@tiscali.cz)
|
||||
* Created: 2007-07-22
|
||||
* Copyright: Michal Bližňák
|
||||
* License: wxWidgets license (www.wxwidgets.org)
|
||||
* Notes:
|
||||
**************************************************************/
|
||||
|
||||
#ifndef _WXSFROUNDRECTSHAPE_H
|
||||
#define _WXSFROUNDRECTSHAPE_H
|
||||
|
||||
#include <wx/wxsf/RectShape.h>
|
||||
|
||||
// default values
|
||||
|
||||
/*! \brief Default value of wxSFRoundRectShape::m_nRadius data member. */
|
||||
#define sfdvROUNDRECTSHAPE_RADIUS 20
|
||||
|
||||
/*!
|
||||
* \brief Class ecapsulating rounded rectangle. It extends the basic rectangular shape.
|
||||
*/
|
||||
class WXDLLIMPEXP_SF wxSFRoundRectShape : public wxSFRectShape
|
||||
{
|
||||
public:
|
||||
XS_DECLARE_CLONABLE_CLASS(wxSFRoundRectShape);
|
||||
|
||||
/*! \brief Default constructor. */
|
||||
wxSFRoundRectShape(void);
|
||||
/*!
|
||||
* \brief User constructor.
|
||||
* \param pos Initial position
|
||||
* \param size Initial size
|
||||
* \param radius Corner radius
|
||||
* \param manager Pointer of parent diagram manager
|
||||
*/
|
||||
wxSFRoundRectShape(const wxRealPoint& pos, const wxRealPoint &size, double radius, wxSFDiagramManager* manager);
|
||||
/*!
|
||||
* \brief Copy constructor.
|
||||
* \param obj Refernce to the source object.
|
||||
*/
|
||||
wxSFRoundRectShape(const wxSFRoundRectShape& obj);
|
||||
/*! \brief Destructor. */
|
||||
virtual ~wxSFRoundRectShape(void);
|
||||
|
||||
// public virtual functions
|
||||
/*!
|
||||
* \brief Test whether the given point is inside the shape. The function
|
||||
* can be overrided if neccessary.
|
||||
* \param pos Examined point
|
||||
* \return TRUE if the point is inside the shape area, otherwise FALSE
|
||||
*/
|
||||
virtual bool Contains(const wxPoint &pos);
|
||||
|
||||
// public member data accessors
|
||||
/*!
|
||||
* \brief Set corner radius.
|
||||
* \param radius New corner radius
|
||||
*/
|
||||
void SetRadius(double radius){m_nRadius = radius;}
|
||||
/*!
|
||||
* \brief Get current corner radius.
|
||||
* \return Current corner radius
|
||||
*/
|
||||
double GetRadius(){return m_nRadius;}
|
||||
|
||||
protected:
|
||||
|
||||
// protected virtual functions
|
||||
/*!
|
||||
* \brief Draw the shape in the normal way. The function can be overrided if neccessary.
|
||||
* \param dc Reference to device context where the shape will be drawn to
|
||||
*/
|
||||
virtual void DrawNormal(wxDC& dc);
|
||||
/*!
|
||||
* \brief Draw the shape in the hower mode (the mouse cursor is above the shape).
|
||||
* The function can be overrided if neccessary.
|
||||
* \param dc Reference to device context where the shape will be drawn to
|
||||
*/
|
||||
virtual void DrawHover(wxDC& dc);
|
||||
/*!
|
||||
* \brief Draw the shape in the highlighted mode (another shape is dragged over this
|
||||
* shape and this shape will accept the dragged one if it will be dropped on it).
|
||||
* The function can be overrided if neccessary.
|
||||
* \param dc Reference to device context where the shape will be drawn to
|
||||
*/
|
||||
virtual void DrawHighlighted(wxDC& dc);
|
||||
/*!
|
||||
* \brief Draw shadow under the shape. The function can be overrided if neccessary.
|
||||
* \param dc Reference to device context where the shadow will be drawn to
|
||||
*/
|
||||
virtual void DrawShadow(wxDC& dc);
|
||||
|
||||
// protected functions
|
||||
/*!
|
||||
* \brief Auxiliary function. Checks whether the point is inside a circle with given center. The circle's radius
|
||||
* is the roundrect corner radius.
|
||||
* \param pos Examined point
|
||||
* \param center Circle center
|
||||
*/
|
||||
bool IsInCircle(const wxPoint& pos, const wxPoint& center);
|
||||
|
||||
// protected data members
|
||||
/*! \brief Corner radius. */
|
||||
double m_nRadius;
|
||||
|
||||
private:
|
||||
|
||||
// private functions
|
||||
|
||||
/*! \brief Initialize serializable properties. */
|
||||
void MarkSerializableDataMembers();
|
||||
};
|
||||
|
||||
#endif //_WXSFROUNDRECTSHAPE_H
|
||||
673
sdk/wxshapeframework/include/wx/wxsf/SFEvents.h
Normal file
673
sdk/wxshapeframework/include/wx/wxsf/SFEvents.h
Normal file
@@ -0,0 +1,673 @@
|
||||
/***************************************************************
|
||||
* Name: SFEvents.h
|
||||
* Purpose: Defines shape events classes
|
||||
* Author: Michal Bližňák (michal.bliznak@tiscali.cz)
|
||||
* Created: 2007-09-11
|
||||
* Copyright: Michal Bližňák
|
||||
* License: wxWidgets license (www.wxwidgets.org)
|
||||
* Notes:
|
||||
**************************************************************/
|
||||
|
||||
#ifndef _WXSFEVENTS_H
|
||||
#define _WXSFEVENTS_H
|
||||
|
||||
#include <wx/event.h>
|
||||
#include <wx/dnd.h>
|
||||
|
||||
#include <wx/wxsf/Defs.h>
|
||||
#include <wx/wxsf/ShapeBase.h>
|
||||
|
||||
class WXDLLIMPEXP_SF wxSFShapeEvent;
|
||||
class WXDLLIMPEXP_SF wxSFShapeTextEvent;
|
||||
class WXDLLIMPEXP_SF wxSFShapeDropEvent;
|
||||
class WXDLLIMPEXP_SF wxSFShapePasteEvent;
|
||||
class WXDLLIMPEXP_SF wxSFShapeHandleEvent;
|
||||
class WXDLLIMPEXP_SF wxSFShapeKeyEvent;
|
||||
class WXDLLIMPEXP_SF wxSFShapeMouseEvent;
|
||||
class WXDLLIMPEXP_SF wxSFShapeChildDropEvent;
|
||||
|
||||
BEGIN_DECLARE_EVENT_TYPES()
|
||||
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_SF, wxEVT_SF_LINE_DONE, 7770)
|
||||
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_SF, wxEVT_SF_TEXT_CHANGE, 7771)
|
||||
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_SF, wxEVT_SF_ON_DROP, 7772)
|
||||
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_SF, wxEVT_SF_ON_PASTE, 7773)
|
||||
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_SF, wxEVT_SF_SHAPE_LEFT_DOWN, 7774)
|
||||
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_SF, wxEVT_SF_SHAPE_LEFT_DCLICK, 7775)
|
||||
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_SF, wxEVT_SF_SHAPE_RIGHT_DOWN, 7776)
|
||||
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_SF, wxEVT_SF_SHAPE_RIGHT_DCLICK, 7777)
|
||||
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_SF, wxEVT_SF_SHAPE_DRAG_BEGIN, 7778)
|
||||
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_SF, wxEVT_SF_SHAPE_DRAG, 7779)
|
||||
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_SF, wxEVT_SF_SHAPE_DRAG_END, 7780)
|
||||
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_SF, wxEVT_SF_SHAPE_HANDLE_BEGIN, 7781)
|
||||
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_SF, wxEVT_SF_SHAPE_HANDLE, 7782)
|
||||
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_SF, wxEVT_SF_SHAPE_HANDLE_END, 7783)
|
||||
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_SF, wxEVT_SF_SHAPE_KEYDOWN, 7784)
|
||||
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_SF, wxEVT_SF_SHAPE_MOUSE_ENTER, 7785)
|
||||
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_SF, wxEVT_SF_SHAPE_MOUSE_OVER, 7786)
|
||||
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_SF, wxEVT_SF_SHAPE_MOUSE_LEAVE, 7787)
|
||||
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_SF, wxEVT_SF_SHAPE_CHILD_DROP, 7788)
|
||||
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_SF, wxEVT_SF_LINE_BEFORE_DONE, 7789)
|
||||
END_DECLARE_EVENT_TYPES()
|
||||
|
||||
typedef void (wxEvtHandler::*wxSFShapeEventFunction)(wxSFShapeEvent&);
|
||||
typedef void (wxEvtHandler::*wxSFShapeTextEventFunction)(wxSFShapeTextEvent&);
|
||||
typedef void (wxEvtHandler::*wxSFShapeDropEventFunction)(wxSFShapeDropEvent&);
|
||||
typedef void (wxEvtHandler::*wxSFShapePasteEventFunction)(wxSFShapePasteEvent&);
|
||||
typedef void (wxEvtHandler::*wxSFShapeHandleEventFunction)(wxSFShapeHandleEvent&);
|
||||
typedef void (wxEvtHandler::*wxSFShapeKeyEventFunction)(wxSFShapeKeyEvent&);
|
||||
typedef void (wxEvtHandler::*wxSFShapeMouseEventFunction)(wxSFShapeMouseEvent&);
|
||||
typedef void (wxEvtHandler::*wxSFShapeChildDropEventFunction)(wxSFShapeChildDropEvent&);
|
||||
|
||||
#define wxSFShapeEventHandler(func) \
|
||||
(wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxSFShapeEventFunction, &func)
|
||||
|
||||
#define wxSFShapeTextEventHandler(func) \
|
||||
(wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxSFShapeTextEventFunction, &func)
|
||||
|
||||
#define wxSFShapeDropEventHandler(func) \
|
||||
(wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxSFShapeDropEventFunction, &func)
|
||||
|
||||
#define wxSFShapePasteEventHandler(func) \
|
||||
(wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxSFShapePasteEventFunction, &func)
|
||||
|
||||
#define wxSFShapeHandleEventHandler(func) \
|
||||
(wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxSFShapeHandleEventFunction, &func)
|
||||
|
||||
#define wxSFShapeKeyEventHandler(func) \
|
||||
(wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxSFShapeKeyEventFunction, &func)
|
||||
|
||||
#define wxSFShapeMouseEventHandler(func) \
|
||||
(wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxSFShapeMouseEventFunction, &func)
|
||||
|
||||
#define wxSFShapeChildDropEventHandler(func) \
|
||||
(wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxSFShapeChildDropEventFunction, &func)
|
||||
|
||||
|
||||
/*! \brief Event table macro mapping event wxEVT_SF_LINE_DONE. This event occures
|
||||
* when the interactive connection creation process is finished. The generated event
|
||||
* object holds a pointer to the new line shape. */
|
||||
#define EVT_SF_LINE_DONE(id, fn) \
|
||||
DECLARE_EVENT_TABLE_ENTRY( \
|
||||
wxEVT_SF_LINE_DONE, id, wxID_ANY, \
|
||||
(wxObjectEventFunction)(wxEventFunction) wxStaticCastEvent( wxSFShapeEventFunction, &fn ), \
|
||||
(wxObject *) NULL \
|
||||
),
|
||||
|
||||
/*! \brief Event table macro mapping event wxEVT_SF_TEXT_CHANGE. This event occures
|
||||
* when the editable text shape's content is changed. */
|
||||
#define EVT_SF_TEXT_CHANGE(id, fn) \
|
||||
DECLARE_EVENT_TABLE_ENTRY( \
|
||||
wxEVT_SF_TEXT_CHANGE, id, wxID_ANY, \
|
||||
(wxObjectEventFunction)(wxEventFunction) wxStaticCastEvent( wxSFShapeTextEventFunction, &fn ), \
|
||||
(wxObject *) NULL \
|
||||
),
|
||||
|
||||
/*! \brief Event table macro mapping event wxEVT_SF_ON_DROP. This event occures
|
||||
* when dragged shapes (via D&D operation) are dropped to a canvas. */
|
||||
#define EVT_SF_ON_DROP(id, fn) \
|
||||
DECLARE_EVENT_TABLE_ENTRY( \
|
||||
wxEVT_SF_ON_DROP, id, wxID_ANY, \
|
||||
(wxObjectEventFunction)(wxEventFunction) wxStaticCastEvent( wxSFShapeDropEventFunction, &fn ), \
|
||||
(wxObject *) NULL \
|
||||
),
|
||||
|
||||
/*! \brief Event table macro mapping event wxEVT_SF_ON_PASTE. This event occures
|
||||
* when shapes stored in the clipboard are pasted to a canvas. */
|
||||
#define EVT_SF_ON_PASTE(id, fn) \
|
||||
DECLARE_EVENT_TABLE_ENTRY( \
|
||||
wxEVT_SF_ON_PASTE, id, wxID_ANY, \
|
||||
(wxObjectEventFunction)(wxEventFunction) wxStaticCastEvent( wxSFShapePasteEventFunction, &fn ), \
|
||||
(wxObject *) NULL \
|
||||
),
|
||||
|
||||
/*! \brief Event table macro mapping event wxEVT_SF_SHAPE_LEFT_DOWN. This event occures
|
||||
* when the shape is clicked by a left mouse button (sfsEMIT_EVENTS shape style must be in use). */
|
||||
#define EVT_SF_SHAPE_LEFT_DOWN(id, fn) \
|
||||
DECLARE_EVENT_TABLE_ENTRY( \
|
||||
wxEVT_SF_SHAPE_LEFT_DOWN, id, wxID_ANY, \
|
||||
(wxObjectEventFunction)(wxEventFunction) wxStaticCastEvent( wxSFShapeMouseEventFunction, &fn ), \
|
||||
(wxObject *) NULL \
|
||||
),
|
||||
|
||||
/*! \brief Event table macro mapping event wxEVT_SF_SHAPE_LEFT_DCLICK. This event occures
|
||||
* when the shape is double-clicked by a left mouse button (sfsEMIT_EVENTS shape style must be in use). */
|
||||
#define EVT_SF_SHAPE_LEFT_DCLICK(id, fn) \
|
||||
DECLARE_EVENT_TABLE_ENTRY( \
|
||||
wxEVT_SF_SHAPE_LEFT_DCLICK, id, wxID_ANY, \
|
||||
(wxObjectEventFunction)(wxEventFunction) wxStaticCastEvent( wxSFShapeMouseEventFunction, &fn ), \
|
||||
(wxObject *) NULL \
|
||||
),
|
||||
|
||||
/*! \brief Event table macro mapping event wxEVT_SF_SHAPE_RIGHT_DOWN. This event occures
|
||||
* when the shape is clicked by a right mouse button (sfsEMIT_EVENTS shape style must be in use). */
|
||||
#define EVT_SF_SHAPE_RIGHT_DOWN(id, fn) \
|
||||
DECLARE_EVENT_TABLE_ENTRY( \
|
||||
wxEVT_SF_SHAPE_RIGHT_DOWN, id, wxID_ANY, \
|
||||
(wxObjectEventFunction)(wxEventFunction) wxStaticCastEvent( wxSFShapeMouseEventFunction, &fn ), \
|
||||
(wxObject *) NULL \
|
||||
),
|
||||
|
||||
/*! \brief Event table macro mapping event wxEVT_SF_SHAPE_RIGHT_DCLICK. This event occures
|
||||
* when the shape is double-clicked by a right mouse button (sfsEMIT_EVENTS shape style must be in use). */
|
||||
#define EVT_SF_SHAPE_RIGHT_DCLICK(id, fn) \
|
||||
DECLARE_EVENT_TABLE_ENTRY( \
|
||||
wxEVT_SF_SHAPE_RIGHT_DCLICK, id, wxID_ANY, \
|
||||
(wxObjectEventFunction)(wxEventFunction) wxStaticCastEvent( wxSFShapeMouseEventFunction, &fn ), \
|
||||
(wxObject *) NULL \
|
||||
),
|
||||
|
||||
/*! \brief Event table macro mapping event wxEVT_SF_SHAPE_DRAG_BEGIN. This event occures
|
||||
* when the shape has started to be dragged. (sfsEMIT_EVENTS shape style must be in use). */
|
||||
#define EVT_SF_SHAPE_DRAG_BEGIN(id, fn) \
|
||||
DECLARE_EVENT_TABLE_ENTRY( \
|
||||
wxEVT_SF_SHAPE_DRAG_BEGIN, id, wxID_ANY, \
|
||||
(wxObjectEventFunction)(wxEventFunction) wxStaticCastEvent( wxSFShapeMouseEventFunction, &fn ), \
|
||||
(wxObject *) NULL \
|
||||
),
|
||||
|
||||
/*! \brief Event table macro mapping event wxEVT_SF_SHAPE_DRAG. This event occures
|
||||
* when the shape is dragging (sfsEMIT_EVENTS shape style must be in use). */
|
||||
#define EVT_SF_SHAPE_DRAG(id, fn) \
|
||||
DECLARE_EVENT_TABLE_ENTRY( \
|
||||
wxEVT_SF_SHAPE_DRAG, id, wxID_ANY, \
|
||||
(wxObjectEventFunction)(wxEventFunction) wxStaticCastEvent( wxSFShapeMouseEventFunction, &fn ), \
|
||||
(wxObject *) NULL \
|
||||
),
|
||||
|
||||
/*! \brief Event table macro mapping event wxEVT_SF_SHAPE_DRAG_END. This event occures
|
||||
* when the shape's dragging was finished (sfsEMIT_EVENTS shape style must be in use). */
|
||||
#define EVT_SF_SHAPE_DRAG_END(id, fn) \
|
||||
DECLARE_EVENT_TABLE_ENTRY( \
|
||||
wxEVT_SF_SHAPE_DRAG_END, id, wxID_ANY, \
|
||||
(wxObjectEventFunction)(wxEventFunction) wxStaticCastEvent( wxSFShapeMouseEventFunction, &fn ), \
|
||||
(wxObject *) NULL \
|
||||
),
|
||||
|
||||
/*! \brief Event table macro mapping event wxEVT_SF_SHAPE_HANDLE_BEGIN. This event occures
|
||||
* when the shape's handle has started to be dragged. (sfsEMIT_EVENTS shape style must be in use). */
|
||||
#define EVT_SF_SHAPE_HANDLE_BEGIN(id, fn) \
|
||||
DECLARE_EVENT_TABLE_ENTRY( \
|
||||
wxEVT_SF_SHAPE_HANDLE_BEGIN, id, wxID_ANY, \
|
||||
(wxObjectEventFunction)(wxEventFunction) wxStaticCastEvent( wxSFShapeHandleEventFunction, &fn ), \
|
||||
(wxObject *) NULL \
|
||||
),
|
||||
|
||||
/*! \brief Event table macro mapping event wxEVT_SF_SHAPE_HANDLE. This event occures
|
||||
* when the shape's handle is dragging (sfsEMIT_EVENTS shape style must be in use). */
|
||||
#define EVT_SF_SHAPE_HANDLE(id, fn) \
|
||||
DECLARE_EVENT_TABLE_ENTRY( \
|
||||
wxEVT_SF_SHAPE_HANDLE, id, wxID_ANY, \
|
||||
(wxObjectEventFunction)(wxEventFunction) wxStaticCastEvent( wxSFShapeHandleEventFunction, &fn ), \
|
||||
(wxObject *) NULL \
|
||||
),
|
||||
|
||||
/*! \brief Event table macro mapping event wxEVT_SF_SHAPE_HANDLE_END. This event occures
|
||||
* when the shape's dragging was finished (sfsEMIT_EVENTS shape style must be in use). */
|
||||
#define EVT_SF_SHAPE_HANDLE_END(id, fn) \
|
||||
DECLARE_EVENT_TABLE_ENTRY( \
|
||||
wxEVT_SF_SHAPE_HANDLE_END, id, wxID_ANY, \
|
||||
(wxObjectEventFunction)(wxEventFunction) wxStaticCastEvent( wxSFShapeHandleEventFunction, &fn ), \
|
||||
(wxObject *) NULL \
|
||||
),
|
||||
|
||||
/*! \brief Event table macro mapping event wxEVT_SF_SHAPE_KEYDOWN. This event occures
|
||||
* when the any key is pressed on selected shape (sfsEMIT_EVENTS shape style must be in use). */
|
||||
#define EVT_SF_SHAPE_KEYDOWN(id, fn) \
|
||||
DECLARE_EVENT_TABLE_ENTRY( \
|
||||
wxEVT_SF_SHAPE_KEYDOWN, id, wxID_ANY, \
|
||||
(wxObjectEventFunction)(wxEventFunction) wxStaticCastEvent( wxSFShapeKeyEventFunction, &fn ), \
|
||||
(wxObject *) NULL \
|
||||
),
|
||||
|
||||
/*! \brief Event table macro mapping event wxEVT_SF_SHAPE_MOUSE_ENTER. This event occures
|
||||
* when the mouse cursor enters the shape's area (sfsEMIT_EVENTS shape style must be in use). */
|
||||
#define EVT_SF_SHAPE_MOUSE_ENTER(id, fn) \
|
||||
DECLARE_EVENT_TABLE_ENTRY( \
|
||||
wxEVT_SF_SHAPE_MOUSE_ENTER, id, wxID_ANY, \
|
||||
(wxObjectEventFunction)(wxEventFunction) wxStaticCastEvent( wxSFShapeMouseEventFunction, &fn ), \
|
||||
(wxObject *) NULL \
|
||||
),
|
||||
|
||||
/*! \brief Event table macro mapping event wxEVT_SF_SHAPE_MOUSE_OVER. This event occures
|
||||
* when the mouse cursor is moving over the shape's area (sfsEMIT_EVENTS shape style must be in use). */
|
||||
#define EVT_SF_SHAPE_MOUSE_OVER(id, fn) \
|
||||
DECLARE_EVENT_TABLE_ENTRY( \
|
||||
wxEVT_SF_SHAPE_MOUSE_OVER, id, wxID_ANY, \
|
||||
(wxObjectEventFunction)(wxEventFunction) wxStaticCastEvent( wxSFShapeMouseEventFunction, &fn ), \
|
||||
(wxObject *) NULL \
|
||||
),
|
||||
|
||||
/*! \brief Event table macro mapping event wxEVT_SF_SHAPE_MOUSE_LEAVE. This event occures
|
||||
* when the mouse cursor leaves the shape's area (sfsEMIT_EVENTS shape style must be in use). */
|
||||
#define EVT_SF_SHAPE_MOUSE_LEAVE(id, fn) \
|
||||
DECLARE_EVENT_TABLE_ENTRY( \
|
||||
wxEVT_SF_SHAPE_MOUSE_LEAVE, id, wxID_ANY, \
|
||||
(wxObjectEventFunction)(wxEventFunction) wxStaticCastEvent( wxSFShapeMouseEventFunction, &fn ), \
|
||||
(wxObject *) NULL \
|
||||
),
|
||||
|
||||
/*! \brief Event table macro mapping event wxEVT_SF_SHAPE_CHILD_DROP. This event occures
|
||||
* when another shape is dropped onto the new parent shape (sfsEMIT_EVENTS shape style must be in use). */
|
||||
#define EVT_SF_SHAPE_CHILD_DROP(id, fn) \
|
||||
DECLARE_EVENT_TABLE_ENTRY( \
|
||||
wxEVT_SF_SHAPE_CHILD_DROP, id, wxID_ANY, \
|
||||
(wxObjectEventFunction)(wxEventFunction) wxStaticCastEvent( wxSFShapeChildDropEventFunction, &fn ), \
|
||||
(wxObject *) NULL \
|
||||
),
|
||||
|
||||
/*! \brief Event table macro mapping event wxEVT_SF_LINE_BEFORE_DONE. This event occures
|
||||
* when the interactive connection creation process is finished but this has been added in
|
||||
* order to allow the developper to cancel the creation if required. The generated event
|
||||
* object holds a pointer to the new line shape. */
|
||||
#define EVT_SF_LINE_BEFORE_DONE(id, fn) \
|
||||
DECLARE_EVENT_TABLE_ENTRY( \
|
||||
wxEVT_SF_LINE_BEFORE_DONE, id, wxID_ANY, \
|
||||
(wxObjectEventFunction)(wxEventFunction) wxStaticCastEvent( wxSFShapeEventFunction, &fn ), \
|
||||
(wxObject *) NULL \
|
||||
),
|
||||
|
||||
/*!
|
||||
* \brief Class encapsulates generic wxSF shape's event.
|
||||
*/
|
||||
class WXDLLIMPEXP_SF wxSFShapeEvent : public wxEvent
|
||||
{
|
||||
public:
|
||||
/*! \brief Constructor */
|
||||
wxSFShapeEvent(wxEventType cmdType = wxEVT_NULL, int id = 0);
|
||||
/*! \brief Copy constructor */
|
||||
wxSFShapeEvent(const wxSFShapeEvent& obj);
|
||||
/*! \brief Destructor */
|
||||
virtual ~wxSFShapeEvent();
|
||||
|
||||
// public member data accessors
|
||||
/*!
|
||||
* \brief Insert a shape object to the event object.
|
||||
* \param shape Pointer to the shape object
|
||||
*/
|
||||
void SetShape(wxSFShapeBase* shape){m_Shape = shape;}
|
||||
/*!
|
||||
* \brief Get a shape object from the event object.
|
||||
* \return Pointer to the shape object.
|
||||
*/
|
||||
wxSFShapeBase* GetShape(){return m_Shape;}
|
||||
|
||||
/*! \brief Clone this event object and return pointer to the new instance. */
|
||||
wxEvent* Clone() const { return new wxSFShapeEvent(*this); }
|
||||
|
||||
/*!
|
||||
* \brief Check if the event has been vetoed or not.
|
||||
* \return TRUE if the event has been vetoed.
|
||||
*/
|
||||
bool IsVetoed() {return m_Vetoed;}
|
||||
|
||||
/*!
|
||||
* \brief Set the veto flag to true.
|
||||
*/
|
||||
void Veto() {m_Vetoed = true;};
|
||||
|
||||
|
||||
private:
|
||||
// private data members
|
||||
/*! \brief Pointer to stored shape object. */
|
||||
wxSFShapeBase* m_Shape;
|
||||
bool m_Vetoed;
|
||||
};
|
||||
|
||||
/*!
|
||||
* \brief Class encapsulates wxEVT_SF_SHAPE_KEYDOWN event.
|
||||
*/
|
||||
class WXDLLIMPEXP_SF wxSFShapeKeyEvent : public wxEvent
|
||||
{
|
||||
public:
|
||||
/*! \brief Constructor */
|
||||
wxSFShapeKeyEvent(wxEventType cmdType = wxEVT_NULL, int id = 0);
|
||||
/*! \brief Copy constructor */
|
||||
wxSFShapeKeyEvent(const wxSFShapeKeyEvent& obj);
|
||||
/*! \brief Destructor */
|
||||
virtual ~wxSFShapeKeyEvent();
|
||||
|
||||
// public member data accessors
|
||||
/*!
|
||||
* \brief Insert a shape object to the event object.
|
||||
* \param shape Pointer to the shape object
|
||||
*/
|
||||
void SetShape(wxSFShapeBase* shape){m_Shape = shape;}
|
||||
/*!
|
||||
* \brief Get a shape object from the event object.
|
||||
* \return Pointer to the shape object.
|
||||
*/
|
||||
wxSFShapeBase* GetShape(){return m_Shape;}
|
||||
/**
|
||||
* \brief Set key code.
|
||||
* \param KeyCode Code of pressed key
|
||||
*/
|
||||
void SetKeyCode(int KeyCode) {this->m_KeyCode = KeyCode;}
|
||||
/**
|
||||
* \brief Get key code.
|
||||
* \return Code of pressed key
|
||||
*/
|
||||
int GetKeyCode() const {return m_KeyCode;}
|
||||
|
||||
|
||||
/*! \brief Clone this event object and return pointer to the new instance. */
|
||||
wxEvent* Clone() const { return new wxSFShapeKeyEvent(*this); }
|
||||
|
||||
|
||||
private:
|
||||
// private data members
|
||||
/*! \brief Pointer to stored shape object. */
|
||||
wxSFShapeBase* m_Shape;
|
||||
/*! \brief Code of pressed key. */
|
||||
int m_KeyCode;
|
||||
};
|
||||
|
||||
/*!
|
||||
* \brief Class encapsulates mouse events generated by a shape.
|
||||
*/
|
||||
class WXDLLIMPEXP_SF wxSFShapeMouseEvent : public wxEvent
|
||||
{
|
||||
public:
|
||||
/*! \brief Constructor */
|
||||
wxSFShapeMouseEvent(wxEventType cmdType = wxEVT_NULL, int id = 0);
|
||||
/*! \brief Copy constructor */
|
||||
wxSFShapeMouseEvent(const wxSFShapeMouseEvent& obj);
|
||||
/*! \brief Destructor */
|
||||
virtual ~wxSFShapeMouseEvent();
|
||||
|
||||
// public member data accessors
|
||||
/*!
|
||||
* \brief Insert a shape object to the event object.
|
||||
* \param shape Pointer to the shape object
|
||||
*/
|
||||
void SetShape(wxSFShapeBase* shape){m_Shape = shape;}
|
||||
/*!
|
||||
* \brief Get a shape object from the event object.
|
||||
* \return Pointer to the shape object.
|
||||
*/
|
||||
wxSFShapeBase* GetShape(){return m_Shape;}
|
||||
/**
|
||||
* \brief Set absolute position of mouse cursor.
|
||||
* \param MousePosition Mouse cursor's absolute position
|
||||
*/
|
||||
void SetMousePosition(const wxPoint& MousePosition) {this->m_MousePosition = MousePosition;}
|
||||
/**
|
||||
* \brief Get absolute position of mouse cursor
|
||||
* \return Mouse cursor's absolute position
|
||||
*/
|
||||
const wxPoint& GetMousePosition() const {return m_MousePosition;}
|
||||
|
||||
/*! \brief Clone this event object and return pointer to the new instance. */
|
||||
wxEvent* Clone() const { return new wxSFShapeMouseEvent(*this); }
|
||||
|
||||
|
||||
private:
|
||||
// private data members
|
||||
/*! \brief Pointer to stored shape object. */
|
||||
wxSFShapeBase* m_Shape;
|
||||
/*! \brief Code of pressed key. */
|
||||
wxPoint m_MousePosition;
|
||||
};
|
||||
|
||||
|
||||
/*!
|
||||
* \brief Class encapsulates wxEVT_SF_TEXT_CHANGE event.
|
||||
*/
|
||||
class WXDLLIMPEXP_SF wxSFShapeTextEvent : public wxEvent
|
||||
{
|
||||
public:
|
||||
/*! \brief Constructor */
|
||||
wxSFShapeTextEvent(wxEventType cmdType = wxEVT_NULL, int id = 0);
|
||||
/*! \brief Copy constructor */
|
||||
wxSFShapeTextEvent(const wxSFShapeTextEvent& obj);
|
||||
/*! \brief Destructor */
|
||||
virtual ~wxSFShapeTextEvent();
|
||||
|
||||
// public member data accessors
|
||||
/*!
|
||||
* \brief Insert a shape object to the event object.
|
||||
* \param shape Pointer to the shape object
|
||||
*/
|
||||
void SetShape(wxSFShapeBase* shape){m_Shape = shape;}
|
||||
/*!
|
||||
* \brief Get a shape object from the event object.
|
||||
* \return Pointer to the shape object.
|
||||
*/
|
||||
wxSFShapeBase* GetShape(){return m_Shape;}
|
||||
/*!
|
||||
* \brief Set new text shape.
|
||||
* \param txt New text content.
|
||||
*/
|
||||
void SetText(const wxString& txt){m_Text = txt;}
|
||||
/*!
|
||||
* \brief Get a shape text.
|
||||
* \return Shape text content.
|
||||
*/
|
||||
wxString GetText(){return m_Text;}
|
||||
|
||||
/*! \brief Clone this event object and return pointer to the new instance. */
|
||||
wxEvent* Clone() const { return new wxSFShapeTextEvent(*this); }
|
||||
|
||||
|
||||
private:
|
||||
// private data members
|
||||
/*! \brief Pointer to stored shape object. */
|
||||
wxSFShapeBase* m_Shape;
|
||||
/*! \brief New shape text. */
|
||||
wxString m_Text;
|
||||
};
|
||||
|
||||
/*!
|
||||
* \brief Class encapsulates handle-related events.
|
||||
*/
|
||||
class WXDLLIMPEXP_SF wxSFShapeHandleEvent : public wxEvent
|
||||
{
|
||||
public:
|
||||
/*! \brief Constructor */
|
||||
wxSFShapeHandleEvent(wxEventType cmdType = wxEVT_NULL, int id = 0);
|
||||
/*! \brief Copy constructor */
|
||||
wxSFShapeHandleEvent(const wxSFShapeHandleEvent& obj);
|
||||
/*! \brief Destructor */
|
||||
virtual ~wxSFShapeHandleEvent();
|
||||
|
||||
// public member data accessors
|
||||
/*!
|
||||
* \brief Insert a shape object to the event object.
|
||||
* \param shape Pointer to the shape object
|
||||
*/
|
||||
void SetShape(wxSFShapeBase* shape){m_Shape = shape;}
|
||||
/*!
|
||||
* \brief Get a shape object from the event object.
|
||||
* \return Pointer to the shape object.
|
||||
*/
|
||||
wxSFShapeBase* GetShape(){return m_Shape;}
|
||||
/**
|
||||
* \brief Set pointer to dragged shape handle.
|
||||
* \param Handle Pointer to shape handle
|
||||
* \sa wxSFShapeHandle
|
||||
*/
|
||||
void SetHandle(wxSFShapeHandle& Handle) {this->m_Handle = &Handle;}
|
||||
/**
|
||||
* \brief Get pointer to dragged shape handle.
|
||||
* \return Pointer to shape handle
|
||||
* \sa wxSFShapeHandle
|
||||
*/
|
||||
wxSFShapeHandle& GetHandle() const {return *m_Handle;}
|
||||
|
||||
/*! \brief Clone this event object and return pointer to the new instance. */
|
||||
wxEvent* Clone() const { return new wxSFShapeHandleEvent(*this); }
|
||||
|
||||
|
||||
private:
|
||||
// private data members
|
||||
/*! \brief Pointer to stored shape object. */
|
||||
wxSFShapeBase* m_Shape;
|
||||
/*! \brief Dragged handle. */
|
||||
wxSFShapeHandle* m_Handle;
|
||||
};
|
||||
|
||||
/*!
|
||||
* \brief Class encapsulates wxEVT_SF_ON_DROP event.
|
||||
*/
|
||||
class WXDLLIMPEXP_SF wxSFShapeDropEvent : public wxEvent
|
||||
{
|
||||
public:
|
||||
/*! \brief Constructor */
|
||||
wxSFShapeDropEvent(wxEventType cmdType = wxEVT_NULL, wxCoord x = 0, wxCoord y = 0, wxSFShapeCanvas* target = NULL, wxDragResult def = wxDragNone, int id = 0);
|
||||
/*! \brief Copy constructor */
|
||||
wxSFShapeDropEvent(const wxSFShapeDropEvent& obj);
|
||||
/*! \brief Destructor */
|
||||
virtual ~wxSFShapeDropEvent();
|
||||
|
||||
// public member data accessors
|
||||
/*!
|
||||
* \brief Copy given shapes to the internal list of dropped shapes.
|
||||
* \param list Reference to a list of copied shapes
|
||||
*/
|
||||
void SetDroppedShapes(const ShapeList& list);
|
||||
/*!
|
||||
* \brief Set a position where the shapes were dropped.
|
||||
* \param pos Position
|
||||
*/
|
||||
void SetDropPosition(const wxPoint& pos){m_nDropPosition = pos;}
|
||||
/*!
|
||||
* \brief Set drag result.
|
||||
* \param def Drag result
|
||||
*/
|
||||
void SetDragResult(wxDragResult def){m_nDragResult = def;}
|
||||
/*!
|
||||
* \brief Set drop target (shape canvas where shapes have been dropped to).
|
||||
* \param target Pointer to drop target (shape canvas)
|
||||
*/
|
||||
void SetDropTarget(wxSFShapeCanvas *target){m_pDropTarget = target;}
|
||||
/*!
|
||||
* \brief Get a shape object from the event object.
|
||||
* \return Pointer to the shape object.
|
||||
*/
|
||||
ShapeList& GetDroppedShapes(){return m_lstDroppedShapes;}
|
||||
/*!
|
||||
* \brief Get drop position.
|
||||
* \return Position.
|
||||
*/
|
||||
wxPoint GetDropPosition(){return m_nDropPosition;}
|
||||
/*!
|
||||
* \brief Get drag result.
|
||||
* \return Drag result.
|
||||
*/
|
||||
wxDragResult GetDragResult(){return m_nDragResult;}
|
||||
/*!
|
||||
* \brief Get drop target (shape canvas where shapes have been dropped to).
|
||||
* \return Pointer to drop target (shape canvas)
|
||||
*/
|
||||
wxSFShapeCanvas* GetDropTarget(){return m_pDropTarget;}
|
||||
|
||||
/*! \brief Clone this event object and return pointer to the new instance. */
|
||||
wxEvent* Clone() const { return new wxSFShapeDropEvent(*this); }
|
||||
|
||||
|
||||
private:
|
||||
// private data members
|
||||
/*! \brief List of dropped shapes. */
|
||||
ShapeList m_lstDroppedShapes;
|
||||
/*! \brief Drop target. */
|
||||
wxSFShapeCanvas *m_pDropTarget;
|
||||
/*! \brief Drop position. */
|
||||
wxPoint m_nDropPosition;
|
||||
/*! \brief Drag result. */
|
||||
wxDragResult m_nDragResult;
|
||||
};
|
||||
|
||||
/*!
|
||||
* \brief Class encapsulates wxEVT_SF_ON_PASTE event.
|
||||
*/
|
||||
class WXDLLIMPEXP_SF wxSFShapePasteEvent : public wxEvent
|
||||
{
|
||||
public:
|
||||
/*! \brief Constructor */
|
||||
wxSFShapePasteEvent(wxEventType cmdType = wxEVT_NULL, wxSFShapeCanvas *target = NULL, int id = 0);
|
||||
/*! \brief Copy constructor */
|
||||
wxSFShapePasteEvent(const wxSFShapePasteEvent& obj);
|
||||
/*! \brief Destructor */
|
||||
virtual ~wxSFShapePasteEvent();
|
||||
|
||||
// public member data accessors
|
||||
/*!
|
||||
* \brief Copy given shapes to the internal list of pasted shapes.
|
||||
* \param list Reference to a list of copied shapes
|
||||
*/
|
||||
void SetPastedShapes(const ShapeList& list);
|
||||
/*!
|
||||
* \brief Set drop target (shape canvas where shapes have been pasted to).
|
||||
* \param target Pointer to drop target (shape canvas)
|
||||
*/
|
||||
void SetDropTarget(wxSFShapeCanvas *target){m_pDropTarget = target;}
|
||||
/*!
|
||||
* \brief Get a shape object from the event object.
|
||||
* \return Pointer to the shape object.
|
||||
*/
|
||||
ShapeList& GetPastedShapes(){return m_lstPastedShapes;}
|
||||
/*!
|
||||
* \brief Get drop target (shape canvas where shapes have been pasted to).
|
||||
* \return Pointer to drop target (shape canvas)
|
||||
*/
|
||||
wxSFShapeCanvas* GetDropTarget(){return m_pDropTarget;}
|
||||
|
||||
/*! \brief Clone this event object and return pointer to the new instance. */
|
||||
wxEvent* Clone() const { return new wxSFShapePasteEvent(*this); }
|
||||
|
||||
|
||||
private:
|
||||
// private data members
|
||||
/*! \brief List of pasted shapes. */
|
||||
ShapeList m_lstPastedShapes;
|
||||
/*! \brief Drop target. */
|
||||
wxSFShapeCanvas *m_pDropTarget;
|
||||
};
|
||||
|
||||
/*!
|
||||
* \brief Class encapsulates wxEVT_SF_SHAPE_CHILD_DROP event.
|
||||
*/
|
||||
class WXDLLIMPEXP_SF wxSFShapeChildDropEvent : public wxEvent
|
||||
{
|
||||
public:
|
||||
/*! \brief Constructor */
|
||||
wxSFShapeChildDropEvent(wxEventType cmdType = wxEVT_NULL, int id = 0);
|
||||
/*! \brief Copy constructor */
|
||||
wxSFShapeChildDropEvent(const wxSFShapeChildDropEvent& obj);
|
||||
/*! \brief Destructor */
|
||||
virtual ~wxSFShapeChildDropEvent();
|
||||
|
||||
// public member data accessors
|
||||
/*!
|
||||
* \brief Insert a shape object to the event object.
|
||||
* \param shape Pointer to the shape object
|
||||
*/
|
||||
void SetShape(wxSFShapeBase* shape){m_Shape = shape;}
|
||||
/*!
|
||||
* \brief Get a shape object from the event object.
|
||||
* \return Pointer to the shape object.
|
||||
*/
|
||||
wxSFShapeBase* GetShape(){return m_Shape;}
|
||||
/**
|
||||
* \brief Set a pointer to dropped child shape.
|
||||
* \param ChildShape Pointer to dropped child shape
|
||||
*/
|
||||
void SetChildShape(wxSFShapeBase* ChildShape) {this->m_ChildShape = ChildShape;}
|
||||
/**
|
||||
* \brief Get a pointer to dropped child shape.
|
||||
* \return Pointer to dropped child shape
|
||||
*/
|
||||
wxSFShapeBase* GetChildShape() {return m_ChildShape;}
|
||||
|
||||
/*! \brief Clone this event object and return pointer to the new instance. */
|
||||
wxEvent* Clone() const { return new wxSFShapeChildDropEvent(*this); }
|
||||
|
||||
|
||||
private:
|
||||
// private data members
|
||||
/*! \brief Pointer to stored shape object. */
|
||||
wxSFShapeBase* m_Shape;
|
||||
/*! \brief Pointer to dropped child object. */
|
||||
wxSFShapeBase* m_ChildShape;
|
||||
};
|
||||
|
||||
#endif // _WXSFEVENTS_H
|
||||
700
sdk/wxshapeframework/include/wx/wxsf/ScaledDC.h
Normal file
700
sdk/wxshapeframework/include/wx/wxsf/ScaledDC.h
Normal file
@@ -0,0 +1,700 @@
|
||||
/***************************************************************
|
||||
* Name: ScaledDC.h
|
||||
* Purpose: Defines scaled DC class
|
||||
* Author: Michal Bližňák (michal.bliznak@tiscali.cz)
|
||||
* Created: 2008-11-7
|
||||
* Copyright: Michal Bližňák
|
||||
* License: wxWidgets license (www.wxwidgets.org)
|
||||
* Notes:
|
||||
**************************************************************/
|
||||
|
||||
#ifndef _WXSFSCALEDDC_H
|
||||
#define _WXSFSCALEDDC_H
|
||||
|
||||
#include <wx/graphics.h>
|
||||
#include <wx/dc.h>
|
||||
#include <math.h>
|
||||
#include <wx/dcclient.h>
|
||||
#include <wx/wxsf/Defs.h>
|
||||
|
||||
#if wxVERSION_NUMBER < 2900
|
||||
|
||||
/*! \brief Class acts as a wrapper for given DC class and provides modified
|
||||
* drawing functions cooperating with the shape canvas able to draw scaled graphics.
|
||||
* All drawing operations performed by the shapes should be done via this class otherwise
|
||||
* the global scalling capabilities provided by the shape canvas wont be available.
|
||||
* \sa wxSFShapeCanvas
|
||||
*/
|
||||
|
||||
|
||||
class WXDLLIMPEXP_SF wxSFScaledDC : public wxDC {
|
||||
|
||||
public:
|
||||
wxSFScaledDC( wxWindowDC* target, double scale );
|
||||
virtual ~wxSFScaledDC();
|
||||
|
||||
// public member data accessors
|
||||
/*!
|
||||
* \brief Set the global graphics scale.
|
||||
* \param scale Scale
|
||||
*/
|
||||
void SetScale(double scale){m_nScale = scale;}
|
||||
|
||||
/**
|
||||
* \brief Prepare wxGraphicsContext similiarly to PrepareDC() function.
|
||||
*/
|
||||
void PrepareGC();
|
||||
/**
|
||||
* \brief Enable/Disable usage of wxGraphicsContext.
|
||||
* \param enab Set to TRUE if the wxGraphicsContext should be used for drawing
|
||||
*/
|
||||
static void EnableGC(bool enab){m_fEnableGC = enab;}
|
||||
|
||||
public:
|
||||
virtual void CalcBoundingBox(wxCoord x, wxCoord y);
|
||||
virtual bool CanDrawBitmap() const;
|
||||
virtual bool CanGetTextExtent() const;
|
||||
virtual void Clear();
|
||||
virtual void ComputeScaleAndOrigin();
|
||||
virtual void DrawObject(wxDrawObject* drawobject);
|
||||
virtual void EndDoc();
|
||||
virtual void EndPage();
|
||||
virtual const wxBrush& GetBackground() const;
|
||||
virtual int GetBackgroundMode() const;
|
||||
virtual const wxBrush& GetBrush() const;
|
||||
virtual wxCoord GetCharHeight() const;
|
||||
virtual wxCoord GetCharWidth() const;
|
||||
virtual int GetDepth() const;
|
||||
virtual const wxFont& GetFont() const;
|
||||
#ifdef __WXGTK__
|
||||
virtual GdkWindow* GetGDKWindow() const;
|
||||
#endif
|
||||
virtual wxLayoutDirection GetLayoutDirection() const;
|
||||
virtual int GetLogicalFunction() const;
|
||||
virtual void GetLogicalScale(double *x, double *y);
|
||||
virtual int GetMapMode() const;
|
||||
virtual void GetMultiLineTextExtent(const wxString& string, wxCoord *width, wxCoord *height, wxCoord *heightLine = NULL, wxFont *font = NULL) const;
|
||||
virtual wxSize GetPPI() const;
|
||||
virtual const wxPen& GetPen() const;
|
||||
virtual wxBitmap GetSelectedBitmap() const;
|
||||
virtual const wxColour& GetTextBackground() const;
|
||||
virtual const wxColour& GetTextForeground() const;
|
||||
virtual void GetUserScale(double *x, double *y) const;
|
||||
virtual bool IsOk() const;
|
||||
virtual bool Ok() const;
|
||||
virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp);
|
||||
virtual void SetBackground(const wxBrush& brush);
|
||||
virtual void SetBackgroundMode(int mode);
|
||||
virtual void SetBrush(const wxBrush& brush);
|
||||
virtual void SetDeviceOrigin(wxCoord x, wxCoord y);
|
||||
virtual void SetFont(const wxFont& font);
|
||||
virtual void SetLayoutDirection(wxLayoutDirection dir);
|
||||
virtual void SetLogicalFunction(int function);
|
||||
virtual void SetLogicalOrigin( wxCoord x, wxCoord y );
|
||||
virtual void SetLogicalScale(double x, double y);
|
||||
virtual void SetMapMode( int mode );
|
||||
virtual void SetPalette(const wxPalette& palette);
|
||||
virtual void SetPen(const wxPen& pen);
|
||||
virtual void SetTextBackground(const wxColour& colour);
|
||||
virtual void SetTextForeground(const wxColour& colour);
|
||||
virtual void SetUserScale( double x, double y );
|
||||
virtual bool StartDoc( const wxString& message );
|
||||
virtual void StartPage();
|
||||
|
||||
protected:
|
||||
// protected data members
|
||||
/*! \brief Global graphics scale. */
|
||||
double m_nScale;
|
||||
/*! \brief wxGraphicsContext usage flag. */
|
||||
static bool m_fEnableGC;
|
||||
/*! \brief Pointer to wrapped device context. */
|
||||
wxWindowDC *m_pTargetDC;
|
||||
|
||||
#if wxUSE_GRAPHICS_CONTEXT
|
||||
/*! \brief Pointer to wxGraphicsContext instance. */
|
||||
wxGraphicsContext *m_pGC;
|
||||
#endif
|
||||
|
||||
// protected function
|
||||
/**
|
||||
* \brief Scale given value.
|
||||
* \param val Value to scale
|
||||
* \return Scaled value
|
||||
*/
|
||||
wxCoord Scale(wxCoord val){return (wxCoord)ceil((double)val*m_nScale);}
|
||||
|
||||
/**
|
||||
* \brief Initialize wxGraphicsContext.
|
||||
*/
|
||||
void InitGC();
|
||||
/**
|
||||
* \brief Uninitialize wxGraphicsContext.
|
||||
*/
|
||||
void UninitGC();
|
||||
|
||||
virtual bool DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, wxDC *source, wxCoord xsrc, wxCoord ysrc, int rop = wxCOPY, bool useMask = false, wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord);
|
||||
virtual void DoCrossHair(wxCoord x, wxCoord y);
|
||||
virtual void DoDrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord xc, wxCoord yc);
|
||||
virtual void DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask = false);
|
||||
virtual void DoDrawCheckMark(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
|
||||
virtual void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
|
||||
virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h, double sa, double ea);
|
||||
virtual void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y);
|
||||
virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2);
|
||||
virtual void DoDrawLines(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset);
|
||||
virtual void DoDrawPoint(wxCoord x, wxCoord y);
|
||||
virtual void DoDrawPolyPolygon(int n, int count[], wxPoint points[], wxCoord xoffset, wxCoord yoffset, int fillStyle);
|
||||
virtual void DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset, int fillStyle = wxODDEVEN_RULE);
|
||||
virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
|
||||
virtual void DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle);
|
||||
virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius);
|
||||
virtual void DoDrawSpline(wxList *points);
|
||||
virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y);
|
||||
virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, int style = wxFLOOD_SURFACE);
|
||||
virtual wxBitmap DoGetAsBitmap(const wxRect *subrect) const;
|
||||
virtual void DoGetClippingBox(wxCoord *x, wxCoord *y, wxCoord *w, wxCoord *h) const;
|
||||
virtual void DoGetClippingRegion(wxCoord *x, wxCoord *y, wxCoord *w, wxCoord *h);
|
||||
virtual void DoGetDeviceOrigin(wxCoord *x, wxCoord *y) const;
|
||||
virtual void DoGetLogicalOrigin(wxCoord *x, wxCoord *y) const;
|
||||
virtual bool DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const;
|
||||
virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const;
|
||||
virtual void DoGetSize(int *width, int *height) const;
|
||||
virtual void DoGetSizeMM(int* width, int* height) const;
|
||||
virtual void DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y, wxCoord *descent = NULL, wxCoord *externalLeading = NULL, wxFont *theFont = NULL) const;
|
||||
virtual void DoGradientFillConcentric(const wxRect& rect, const wxColour& initialColour, const wxColour& destColour, const wxPoint& circleCenter);
|
||||
virtual void DoGradientFillLinear(const wxRect& rect, const wxColour& initialColour, const wxColour& destColour, wxDirection nDirection = wxEAST);
|
||||
virtual void DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
|
||||
virtual void DoSetClippingRegionAsRegion(const wxRegion& region);
|
||||
|
||||
};
|
||||
|
||||
#else // ! wxVERSION_NUMBER < 2900
|
||||
|
||||
#include <wx/dcclient.h>
|
||||
class WXDLLIMPEXP_SF wxSFScaledDC;
|
||||
|
||||
class wxSFDCImplWrapper : public wxDCImpl
|
||||
{
|
||||
public:
|
||||
friend class wxSFScaledDC;
|
||||
|
||||
wxSFDCImplWrapper( wxDCImpl *orig, double scale ) : wxDCImpl( orig->GetOwner() )
|
||||
{
|
||||
m_pOrig = orig;
|
||||
m_nScale = scale;
|
||||
}
|
||||
virtual ~wxSFDCImplWrapper()
|
||||
{
|
||||
}
|
||||
|
||||
wxDC *GetOwner() const { return m_pOrig->GetOwner(); }
|
||||
|
||||
wxWindow* GetWindow() const { return m_pOrig->GetWindow(); }
|
||||
|
||||
virtual bool IsOk() const { return m_pOrig->IsOk(); }
|
||||
|
||||
// query capabilities
|
||||
|
||||
virtual bool CanDrawBitmap() const { return m_pOrig->CanDrawBitmap(); }
|
||||
virtual bool CanGetTextExtent() const { return m_pOrig->CanGetTextExtent(); }
|
||||
|
||||
// get Cairo context
|
||||
virtual void* GetCairoContext() const
|
||||
{
|
||||
return m_pOrig->GetCairoContext();
|
||||
}
|
||||
|
||||
// query dimension, colour deps, resolution
|
||||
|
||||
virtual void DoGetSize(int *width, int *height) const { m_pOrig->DoGetSize( width, height); }
|
||||
void GetSize(int *width, int *height) const
|
||||
{
|
||||
DoGetSize(width, height);
|
||||
return ;
|
||||
}
|
||||
|
||||
wxSize GetSize() const
|
||||
{
|
||||
int w, h;
|
||||
DoGetSize(&w, &h);
|
||||
return wxSize(w, h);
|
||||
}
|
||||
|
||||
virtual void DoGetSizeMM(int* width, int* height) const { m_pOrig->DoGetSizeMM( width, height); }
|
||||
|
||||
virtual int GetDepth() const { return m_pOrig->GetDepth(); }
|
||||
virtual wxSize GetPPI() const { return m_pOrig->GetPPI(); }
|
||||
|
||||
// Right-To-Left (RTL) modes
|
||||
|
||||
virtual void SetLayoutDirection(wxLayoutDirection dir) { m_pOrig->SetLayoutDirection( dir ); }
|
||||
virtual wxLayoutDirection GetLayoutDirection() const { return m_pOrig->GetLayoutDirection(); }
|
||||
|
||||
// page and document
|
||||
|
||||
virtual bool StartDoc(const wxString& message) { return m_pOrig->StartDoc( message ); }
|
||||
virtual void EndDoc() { return m_pOrig->EndDoc(); }
|
||||
|
||||
virtual void StartPage() { m_pOrig->StartPage(); }
|
||||
virtual void EndPage() { m_pOrig->EndPage(); }
|
||||
|
||||
// flushing the content of this dc immediately eg onto screen
|
||||
virtual void Flush() { m_pOrig->Flush(); }
|
||||
|
||||
// bounding box
|
||||
|
||||
virtual void CalcBoundingBox(wxCoord x, wxCoord y) { m_pOrig->CalcBoundingBox( x, y); }
|
||||
|
||||
wxCoord MinX() const { return m_pOrig->MinX(); }
|
||||
wxCoord MaxX() const { return m_pOrig->MaxX(); }
|
||||
wxCoord MinY() const { return m_pOrig->MinY(); }
|
||||
wxCoord MaxY() const { return m_pOrig->MaxY(); }
|
||||
|
||||
// setters and getters
|
||||
|
||||
virtual void SetFont(const wxFont& font) { m_pOrig->SetFont( font ); }
|
||||
virtual const wxFont& GetFont() const { return m_pOrig->GetFont(); }
|
||||
|
||||
virtual void SetPen(const wxPen& pen) { m_pOrig->SetPen( pen ); }
|
||||
virtual const wxPen& GetPen() const { return m_pOrig->GetPen(); }
|
||||
|
||||
virtual void SetBrush(const wxBrush& brush) { m_pOrig->SetBrush( brush ); }
|
||||
virtual const wxBrush& GetBrush() const { return m_pOrig->GetBrush(); }
|
||||
|
||||
virtual void SetBackground(const wxBrush& brush) { m_pOrig->SetBackground( brush ); }
|
||||
virtual const wxBrush& GetBackground() const { return m_pOrig->GetBackground(); }
|
||||
|
||||
virtual void SetBackgroundMode(int mode) { m_pOrig->SetBackgroundMode( mode ); }
|
||||
virtual int GetBackgroundMode() const { return m_pOrig->GetBackgroundMode(); }
|
||||
|
||||
virtual void SetTextForeground(const wxColour& colour) { m_pOrig->SetTextForeground( colour ); }
|
||||
virtual const wxColour& GetTextForeground() const { return m_pOrig->GetTextForeground(); }
|
||||
|
||||
virtual void SetTextBackground(const wxColour& colour) { m_pOrig->SetTextBackground( colour ); }
|
||||
virtual const wxColour& GetTextBackground() const { return m_pOrig->GetTextBackground(); }
|
||||
|
||||
#if wxUSE_PALETTE
|
||||
virtual void SetPalette(const wxPalette& palette) { m_pOrig->SetPalette( palette ); }
|
||||
#endif // wxUSE_PALETTE
|
||||
|
||||
// inherit the DC attributes (font and colours) from the given window
|
||||
//
|
||||
// this is called automatically when a window, client or paint DC is
|
||||
// created
|
||||
virtual void InheritAttributes(wxWindow *win) { m_pOrig->InheritAttributes( win ); }
|
||||
|
||||
|
||||
// logical functions
|
||||
|
||||
virtual void SetLogicalFunction(wxRasterOperationMode function) { m_pOrig->SetLogicalFunction( function ); }
|
||||
virtual wxRasterOperationMode GetLogicalFunction() const { return m_pOrig->GetLogicalFunction(); }
|
||||
|
||||
// text measurement
|
||||
|
||||
virtual wxCoord GetCharHeight() const { return m_pOrig->GetCharHeight(); }
|
||||
virtual wxCoord GetCharWidth() const { return m_pOrig->GetCharWidth(); }
|
||||
virtual void DoGetTextExtent(const wxString& string,
|
||||
wxCoord *x, wxCoord *y,
|
||||
wxCoord *descent = NULL,
|
||||
wxCoord *externalLeading = NULL,
|
||||
const wxFont *theFont = NULL) const { m_pOrig->DoGetTextExtent( string, x, y, descent, externalLeading, theFont ); }
|
||||
virtual void GetMultiLineTextExtent(const wxString& string,
|
||||
wxCoord *width,
|
||||
wxCoord *height,
|
||||
wxCoord *heightLine = NULL,
|
||||
const wxFont *font = NULL) const { m_pOrig->GetMultiLineTextExtent( string, width, height, heightLine, font ); }
|
||||
virtual bool DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const { return m_pOrig->DoGetPartialTextExtents( text, widths); }
|
||||
|
||||
// clearing
|
||||
|
||||
virtual void Clear() { m_pOrig->Clear(); }
|
||||
|
||||
// clipping
|
||||
|
||||
virtual void DoSetClippingRegion(wxCoord x, wxCoord y,
|
||||
wxCoord width, wxCoord height) { m_pOrig->DoSetClippingRegion( x, y, width, height ); }
|
||||
|
||||
// NB: this function works with device coordinates, not the logical ones!
|
||||
virtual void DoSetDeviceClippingRegion(const wxRegion& region) { m_pOrig->DoSetDeviceClippingRegion( region ); }
|
||||
|
||||
virtual void DoGetClippingBox(wxCoord *x, wxCoord *y,
|
||||
wxCoord *w, wxCoord *h) const { m_pOrig->DoGetClippingBox( x, y, w, h ); }
|
||||
|
||||
virtual void DestroyClippingRegion() { m_pOrig->DestroyClippingRegion(); }
|
||||
|
||||
|
||||
// coordinates conversions and transforms
|
||||
|
||||
virtual wxCoord DeviceToLogicalX(wxCoord x) const { return m_pOrig->DeviceToLogicalX(x); }
|
||||
virtual wxCoord DeviceToLogicalY(wxCoord y) const { return m_pOrig->DeviceToLogicalY(y); }
|
||||
virtual wxCoord DeviceToLogicalXRel(wxCoord x) const { return m_pOrig->DeviceToLogicalXRel(x); }
|
||||
virtual wxCoord DeviceToLogicalYRel(wxCoord y) const { return m_pOrig->DeviceToLogicalYRel(y); }
|
||||
virtual wxCoord LogicalToDeviceX(wxCoord x) const { return m_pOrig->LogicalToDeviceX(x); }
|
||||
virtual wxCoord LogicalToDeviceY(wxCoord y) const { return m_pOrig->LogicalToDeviceY(y); }
|
||||
virtual wxCoord LogicalToDeviceXRel(wxCoord x) const { return m_pOrig->LogicalToDeviceXRel(x); }
|
||||
virtual wxCoord LogicalToDeviceYRel(wxCoord y) const { return m_pOrig->LogicalToDeviceYRel(y); }
|
||||
|
||||
virtual void SetMapMode(wxMappingMode mode) { m_pOrig->SetMapMode(mode); }
|
||||
virtual wxMappingMode GetMapMode() const { return m_pOrig->GetMapMode(); }
|
||||
|
||||
virtual void SetUserScale(double x, double y) { m_pOrig->SetUserScale( x, y ); }
|
||||
virtual void GetUserScale(double *x, double *y) const { m_pOrig->GetUserScale( x, y ); }
|
||||
|
||||
virtual void SetLogicalScale(double x, double y) { m_pOrig->SetLogicalScale( x, y ); }
|
||||
virtual void GetLogicalScale(double *x, double *y) { m_pOrig->GetLogicalScale( x, y ); }
|
||||
|
||||
virtual void SetLogicalOrigin(wxCoord x, wxCoord y) { m_pOrig->SetLogicalOrigin( x, y ); }
|
||||
virtual void DoGetLogicalOrigin(wxCoord *x, wxCoord *y) const { m_pOrig->DoGetLogicalOrigin( x, y); }
|
||||
|
||||
virtual void SetDeviceOrigin(wxCoord x, wxCoord y) { m_pOrig->SetDeviceOrigin( x, y ); }
|
||||
virtual void DoGetDeviceOrigin(wxCoord *x, wxCoord *y) const { m_pOrig->DoGetDeviceOrigin( x, y ); }
|
||||
|
||||
virtual void SetDeviceLocalOrigin( wxCoord x, wxCoord y ) { m_pOrig->SetDeviceLocalOrigin( x, y ); }
|
||||
|
||||
virtual void ComputeScaleAndOrigin() { m_pOrig->ComputeScaleAndOrigin(); }
|
||||
|
||||
// this needs to overidden if the axis is inverted
|
||||
virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp) { m_pOrig->SetAxisOrientation( xLeftRight, yBottomUp); }
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// the actual drawing API
|
||||
|
||||
virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col,
|
||||
wxFloodFillStyle style = wxFLOOD_SURFACE)
|
||||
{
|
||||
return m_pOrig->DoFloodFill( ScaleCoord(x), ScaleCoord(y), col, style );
|
||||
}
|
||||
|
||||
virtual void DoGradientFillLinear(const wxRect& rect,
|
||||
const wxColour& initialColour,
|
||||
const wxColour& destColour,
|
||||
wxDirection nDirection = wxEAST)
|
||||
{
|
||||
m_pOrig->DoGradientFillLinear( wxRect( ScaleInt(rect.x), ScaleInt(rect.y), ScaleInt(rect.width), ScaleInt(rect.height)),
|
||||
initialColour, destColour, nDirection );
|
||||
}
|
||||
|
||||
virtual void DoGradientFillConcentric(const wxRect& rect,
|
||||
const wxColour& initialColour,
|
||||
const wxColour& destColour,
|
||||
const wxPoint& circleCenter)
|
||||
{
|
||||
m_pOrig->DoGradientFillConcentric( wxRect( ScaleInt(rect.x), ScaleInt(rect.y), ScaleInt(rect.width), ScaleInt(rect.height)),
|
||||
initialColour, destColour,
|
||||
wxPoint( ScaleInt(circleCenter.x), ScaleInt(circleCenter.y)) );
|
||||
}
|
||||
|
||||
virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const
|
||||
{
|
||||
return m_pOrig->DoGetPixel( (wxCoord)ceil((double)x*m_nScale), (wxCoord)ceil((double)y*m_nScale), col );
|
||||
}
|
||||
|
||||
virtual void DoDrawPoint(wxCoord x, wxCoord y)
|
||||
{
|
||||
m_pOrig->DoDrawPoint( ScaleCoord(x), ScaleCoord(y) );
|
||||
}
|
||||
virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
|
||||
{
|
||||
m_pOrig->DoDrawLine( ScaleCoord(x1), ScaleCoord(y1), ScaleCoord(x2), ScaleCoord(y2) );
|
||||
}
|
||||
|
||||
virtual void DoDrawArc(wxCoord x1, wxCoord y1,
|
||||
wxCoord x2, wxCoord y2,
|
||||
wxCoord xc, wxCoord yc)
|
||||
{
|
||||
m_pOrig->DoDrawArc( ScaleCoord(x1), ScaleCoord(y1),
|
||||
ScaleCoord(x2), ScaleCoord(y2),
|
||||
ScaleCoord(xc), ScaleCoord(yc) );
|
||||
}
|
||||
|
||||
virtual void DoDrawCheckMark(wxCoord x, wxCoord y,
|
||||
wxCoord width, wxCoord height)
|
||||
{
|
||||
m_pOrig->DoDrawCheckMark( ScaleCoord(x), ScaleCoord(y), ScaleCoord(width), ScaleCoord(height) );
|
||||
}
|
||||
|
||||
virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
|
||||
double sa, double ea)
|
||||
{
|
||||
m_pOrig->DoDrawEllipticArc( ScaleCoord(x), ScaleCoord(y), ScaleCoord(w), ScaleCoord(h), sa, ea );
|
||||
}
|
||||
|
||||
virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
|
||||
{
|
||||
m_pOrig->DoDrawRectangle( ScaleCoord(x), ScaleCoord(y), ScaleCoord(width), ScaleCoord(height) );
|
||||
}
|
||||
|
||||
virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y,
|
||||
wxCoord width, wxCoord height,
|
||||
double radius)
|
||||
{
|
||||
m_pOrig->DoDrawRoundedRectangle( ScaleCoord(x), ScaleCoord(y), ScaleCoord(width), ScaleCoord(height), radius*m_nScale );
|
||||
}
|
||||
|
||||
virtual void DoDrawEllipse(wxCoord x, wxCoord y,
|
||||
wxCoord width, wxCoord height)
|
||||
{
|
||||
m_pOrig->DoDrawEllipse( ScaleCoord(x), ScaleCoord(y), ScaleCoord(width), ScaleCoord(height) );
|
||||
}
|
||||
|
||||
virtual void DoCrossHair(wxCoord x, wxCoord y)
|
||||
{
|
||||
m_pOrig->DoCrossHair( ScaleCoord(x), ScaleCoord(y) );
|
||||
}
|
||||
|
||||
virtual void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y)
|
||||
{
|
||||
m_pOrig->DoDrawIcon( icon, ScaleCoord(x), ScaleCoord(y) );
|
||||
}
|
||||
|
||||
virtual void DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y,
|
||||
bool useMask = false)
|
||||
{
|
||||
m_pOrig->DoDrawBitmap( bmp, ScaleCoord(x), ScaleCoord(y), useMask );
|
||||
}
|
||||
|
||||
virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y)
|
||||
{
|
||||
wxFont font = GetFont();
|
||||
wxFont prevfont = font;
|
||||
|
||||
if(font != wxNullFont)
|
||||
{
|
||||
font.SetPointSize(int(font.GetPointSize()*m_nScale));
|
||||
SetFont(font);
|
||||
}
|
||||
|
||||
m_pOrig->DoDrawText( text, ScaleCoord(x), ScaleCoord(y) );
|
||||
|
||||
SetFont(prevfont);
|
||||
}
|
||||
|
||||
virtual void DoDrawRotatedText(const wxString& text,
|
||||
wxCoord x, wxCoord y, double angle)
|
||||
{
|
||||
wxFont font = GetFont();
|
||||
wxFont prevfont = font;
|
||||
|
||||
if(font != wxNullFont)
|
||||
{
|
||||
font.SetPointSize(int(font.GetPointSize()*m_nScale));
|
||||
SetFont(font);
|
||||
}
|
||||
|
||||
m_pOrig->DoDrawRotatedText( text, ScaleCoord(x), ScaleCoord(y), angle );
|
||||
|
||||
SetFont(prevfont);
|
||||
}
|
||||
|
||||
virtual bool DoBlit(wxCoord xdest, wxCoord ydest,
|
||||
wxCoord width, wxCoord height,
|
||||
wxDC *source,
|
||||
wxCoord xsrc, wxCoord ysrc,
|
||||
wxRasterOperationMode rop = wxCOPY,
|
||||
bool useMask = false,
|
||||
wxCoord xsrcMask = wxDefaultCoord,
|
||||
wxCoord ysrcMask = wxDefaultCoord)
|
||||
{
|
||||
return m_pOrig->DoBlit( ScaleCoord(xdest), ScaleCoord(ydest),
|
||||
width, height, source, xsrc, ysrc, rop, useMask, xsrcMask, ysrcMask );
|
||||
}
|
||||
|
||||
virtual bool DoStretchBlit(wxCoord xdest, wxCoord ydest,
|
||||
wxCoord dstWidth, wxCoord dstHeight,
|
||||
wxDC *source,
|
||||
wxCoord xsrc, wxCoord ysrc,
|
||||
wxCoord srcWidth, wxCoord srcHeight,
|
||||
wxRasterOperationMode rop = wxCOPY,
|
||||
bool useMask = false,
|
||||
wxCoord xsrcMask = wxDefaultCoord,
|
||||
wxCoord ysrcMask = wxDefaultCoord)
|
||||
{
|
||||
return m_pOrig->DoStretchBlit( ScaleCoord(xdest), ScaleCoord(ydest), ScaleCoord(dstWidth), ScaleCoord(dstHeight),
|
||||
source, xsrc, ysrc, srcWidth, srcHeight, rop, useMask, xsrcMask, ysrcMask );
|
||||
}
|
||||
|
||||
virtual wxBitmap DoGetAsBitmap(const wxRect *subrect) const
|
||||
{
|
||||
return m_pOrig->DoGetAsBitmap( subrect );
|
||||
}
|
||||
|
||||
#if wxVERSION_NUMBER < 2905
|
||||
virtual void DoDrawLines(int n, wxPoint points[],
|
||||
#else
|
||||
virtual void DoDrawLines(int n, const wxPoint points[],
|
||||
#endif
|
||||
wxCoord xoffset, wxCoord yoffset )
|
||||
{
|
||||
wxPoint *updPoints = new wxPoint[n];
|
||||
|
||||
for(int i = 0; i < n; i++)
|
||||
{
|
||||
(updPoints + i)->x = ScaleInt((points + i)->x);
|
||||
(updPoints + i)->y = ScaleInt((points + i)->y);
|
||||
}
|
||||
|
||||
m_pOrig->DoDrawLines( n, updPoints, ScaleCoord(xoffset), ScaleCoord(yoffset) );
|
||||
|
||||
delete [] updPoints;
|
||||
}
|
||||
|
||||
virtual void DrawLines(const wxPointList *list,
|
||||
wxCoord xoffset, wxCoord yoffset )
|
||||
{
|
||||
int i = 0;
|
||||
wxPoint *pts = new wxPoint[list->GetCount()];
|
||||
|
||||
wxPointList::compatibility_iterator node = list->GetFirst();
|
||||
while( node )
|
||||
{
|
||||
*(pts + i) = *node->GetData();
|
||||
i++;
|
||||
node = node->GetNext();
|
||||
}
|
||||
|
||||
wxSFDCImplWrapper::DoDrawLines( i, pts, xoffset, yoffset );
|
||||
|
||||
delete [] pts;
|
||||
}
|
||||
|
||||
#if wxVERSION_NUMBER < 2905
|
||||
virtual void DoDrawPolygon(int n, wxPoint points[],
|
||||
#else
|
||||
virtual void DoDrawPolygon(int n, const wxPoint points[],
|
||||
#endif
|
||||
wxCoord xoffset, wxCoord yoffset,
|
||||
wxPolygonFillMode fillStyle = wxODDEVEN_RULE)
|
||||
{
|
||||
wxPoint *updPoints = new wxPoint[n];
|
||||
|
||||
for(int i = 0; i < n; i++)
|
||||
{
|
||||
(updPoints + i)->x = ScaleInt((points + i)->x);
|
||||
(updPoints + i)->y = ScaleInt((points + i)->y);
|
||||
}
|
||||
|
||||
m_pOrig->DoDrawPolygon(n, updPoints, ScaleCoord(xoffset), ScaleCoord(yoffset), fillStyle);
|
||||
|
||||
delete [] updPoints;
|
||||
}
|
||||
|
||||
virtual void DoDrawPolyPolygon(int n, int count[], wxPoint points[],
|
||||
wxCoord xoffset, wxCoord yoffset,
|
||||
wxPolygonFillMode fillStyle)
|
||||
{
|
||||
int nTotalPoints = 0;
|
||||
|
||||
for(int i = 0; i < n; i++)nTotalPoints += count[i];
|
||||
|
||||
wxPoint *updPoints = new wxPoint[nTotalPoints];
|
||||
|
||||
for(int i = 0; i < nTotalPoints; i++)
|
||||
{
|
||||
(updPoints + i)->x = ScaleInt((points + i)->x);
|
||||
(updPoints + i)->y = ScaleInt((points + i)->y);
|
||||
}
|
||||
|
||||
m_pOrig->DoDrawPolyPolygon(n, count, updPoints, ScaleCoord(xoffset), ScaleCoord(yoffset), fillStyle);
|
||||
|
||||
delete [] updPoints;
|
||||
}
|
||||
|
||||
void DrawPolygon(const wxPointList *list,
|
||||
wxCoord xoffset, wxCoord yoffset,
|
||||
wxPolygonFillMode fillStyle )
|
||||
{
|
||||
int i = 0;
|
||||
wxPoint *pts = new wxPoint[list->GetCount()];
|
||||
|
||||
wxPointList::compatibility_iterator node = list->GetFirst();
|
||||
while( node )
|
||||
{
|
||||
*(pts + i) = *node->GetData();
|
||||
i++;
|
||||
node = node->GetNext();
|
||||
}
|
||||
|
||||
wxSFDCImplWrapper::DoDrawPolygon( i, pts, xoffset, yoffset, fillStyle );
|
||||
|
||||
delete [] pts;
|
||||
}
|
||||
|
||||
|
||||
#if wxUSE_SPLINES
|
||||
void DrawSpline(wxCoord x1, wxCoord y1,
|
||||
wxCoord x2, wxCoord y2,
|
||||
wxCoord x3, wxCoord y3);
|
||||
void DrawSpline(int n, wxPoint points[]);
|
||||
void DrawSpline(const wxPointList *points) { DoDrawSpline(points); }
|
||||
|
||||
virtual void DoDrawSpline(const wxPointList *points)
|
||||
{
|
||||
wxPoint *pPt;
|
||||
wxPointList updPoints;
|
||||
|
||||
wxPointList::compatibility_iterator node = points->GetFirst();
|
||||
while( node )
|
||||
{
|
||||
pPt = node->GetData();
|
||||
updPoints.Append( new wxPoint( ScaleInt(pPt->x), ScaleInt(pPt->y)) );
|
||||
node = node->GetNext();
|
||||
}
|
||||
|
||||
m_pOrig->DoDrawSpline( &updPoints );
|
||||
|
||||
updPoints.DeleteContents( true );
|
||||
updPoints.Clear();
|
||||
}
|
||||
#endif
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// wxMemoryDC Impl API
|
||||
|
||||
virtual void DoSelect(const wxBitmap& bmp) { m_pOrig->DoSelect( bmp ); }
|
||||
|
||||
virtual const wxBitmap& GetSelectedBitmap() const { return m_pOrig->GetSelectedBitmap(); }
|
||||
virtual wxBitmap& GetSelectedBitmap() { return m_pOrig->GetSelectedBitmap(); }
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// wxPrinterDC Impl API
|
||||
|
||||
virtual wxRect GetPaperRect() const { return m_pOrig->GetPaperRect(); }
|
||||
|
||||
virtual int GetResolution() const { return m_pOrig->GetResolution(); }
|
||||
|
||||
protected:
|
||||
/*! \brief Pointer to original DC implementation. */
|
||||
wxDCImpl *m_pOrig;
|
||||
/*! \brief Global graphics scale. */
|
||||
double m_nScale;
|
||||
|
||||
/**
|
||||
* \brief Scale given value.
|
||||
* \param val Value to scale
|
||||
* \return Scaled value
|
||||
*/
|
||||
wxCoord ScaleCoord(wxCoord val){return (wxCoord)ceil((double)val*m_nScale);}
|
||||
|
||||
/**
|
||||
* \brief Scale given value.
|
||||
* \param val Value to scale
|
||||
* \return Scaled value
|
||||
*/
|
||||
wxCoord ScaleInt(int val){return (int)ceil((double)val*m_nScale);}
|
||||
};
|
||||
|
||||
/*! \brief Class acts as a wrapper for given DC class and provides modified
|
||||
* drawing functions cooperating with the shape canvas able to draw scaled graphics.
|
||||
* All drawing operations performed by the shapes should be done via this class otherwise
|
||||
* the global scalling capabilities provided by the shape canvas wont be available.
|
||||
* \sa wxSFShapeCanvas
|
||||
*/
|
||||
class WXDLLIMPEXP_SF wxSFScaledDC : public wxDC {
|
||||
|
||||
public:
|
||||
wxSFScaledDC( wxWindowDC* target, double scale );
|
||||
virtual ~wxSFScaledDC();
|
||||
};
|
||||
#endif // wxVERSION_NUMBER < 2900
|
||||
|
||||
#endif // _WXSFSCALEDDC_H
|
||||
1099
sdk/wxshapeframework/include/wx/wxsf/ShapeBase.h
Normal file
1099
sdk/wxshapeframework/include/wx/wxsf/ShapeBase.h
Normal file
File diff suppressed because it is too large
Load Diff
1196
sdk/wxshapeframework/include/wx/wxsf/ShapeCanvas.h
Normal file
1196
sdk/wxshapeframework/include/wx/wxsf/ShapeCanvas.h
Normal file
File diff suppressed because it is too large
Load Diff
67
sdk/wxshapeframework/include/wx/wxsf/ShapeDataObject.h
Normal file
67
sdk/wxshapeframework/include/wx/wxsf/ShapeDataObject.h
Normal file
@@ -0,0 +1,67 @@
|
||||
/***************************************************************
|
||||
* Name: ShapeDataObject.h
|
||||
* Purpose: Defines shape data object class
|
||||
* Author: Michal Bližňák (michal.bliznak@tiscali.cz)
|
||||
* Created: 2007-07-22
|
||||
* Copyright: Michal Bližňák
|
||||
* License: wxWidgets license (www.wxwidgets.org)
|
||||
* Notes:
|
||||
**************************************************************/
|
||||
|
||||
#ifndef _WXSFSHAPEDATAOBJECT_H
|
||||
#define _WXSFSHAPEDATAOBJECT_H
|
||||
|
||||
#include <wx/wxsf/DiagramManager.h>
|
||||
|
||||
/*!
|
||||
* \brief Class encapsulating data object used during clipboard operations with shapes.
|
||||
*/
|
||||
class wxSFShapeDataObject : public wxDataObjectSimple
|
||||
{
|
||||
public:
|
||||
/*!
|
||||
* \brief Default constructor
|
||||
* \param format Data format
|
||||
*/
|
||||
wxSFShapeDataObject(const wxDataFormat& format);
|
||||
/*!
|
||||
* \brief User constructor
|
||||
* \param format Data format
|
||||
* \param selection List of shapes which should be stored in the data object
|
||||
* \param manager Pointer to diagram manager which manages stored shapes
|
||||
*/
|
||||
wxSFShapeDataObject(const wxDataFormat& format, const ShapeList& selection, wxSFDiagramManager* manager);
|
||||
/*! \brief Destructor */
|
||||
virtual ~wxSFShapeDataObject(void);
|
||||
|
||||
/*! \brief Function returns sizes of the data object */
|
||||
virtual size_t GetDataSize() const;
|
||||
/*!
|
||||
* \brief Function should export data from data object to given buffer.
|
||||
* \param buf External output data buffer
|
||||
* \return TRUE on success, otherwise FALSE
|
||||
*/
|
||||
virtual bool GetDataHere(void* buf) const;
|
||||
/*!
|
||||
* \brief Function should inport data from data object from given buffer.
|
||||
* \param len Data lenght
|
||||
* \param buf External input data buffer
|
||||
* \return TRUE on success, otherwise FALSE
|
||||
*/
|
||||
virtual bool SetData(size_t len, const void* buf);
|
||||
|
||||
wxTextDataObject m_Data;
|
||||
|
||||
protected:
|
||||
|
||||
/*!
|
||||
* \brief Serialize shapes to data object.
|
||||
* \param selection List of shapes which should be serialized
|
||||
* \param manager Parent diagram manager
|
||||
* \return String containing serialized information
|
||||
*/
|
||||
wxString SerializeSelectedShapes(const ShapeList& selection, wxSFDiagramManager* manager);
|
||||
|
||||
};
|
||||
|
||||
#endif //_WXSFSHAPEDATAOBJECT_H
|
||||
199
sdk/wxshapeframework/include/wx/wxsf/ShapeHandle.h
Normal file
199
sdk/wxshapeframework/include/wx/wxsf/ShapeHandle.h
Normal file
@@ -0,0 +1,199 @@
|
||||
/***************************************************************
|
||||
* Name: ShapeHandle.h
|
||||
* Purpose: Defines shape handle class
|
||||
* Author: Michal Bližňák (michal.bliznak@tiscali.cz)
|
||||
* Created: 2007-07-22
|
||||
* Copyright: Michal Bližňák
|
||||
* License: wxWidgets license (www.wxwidgets.org)
|
||||
* Notes:
|
||||
**************************************************************/
|
||||
|
||||
#ifndef _WXSFSHAPEHANDLE_H
|
||||
#define _WXSFSHAPEHANDLE_H
|
||||
|
||||
#include <wx/list.h>
|
||||
|
||||
#include <wx/wxsf/ScaledDC.h>
|
||||
|
||||
class WXDLLIMPEXP_SF wxSFShapeBase;
|
||||
|
||||
/*! \brief Class encapsulates shape's handle. The class shouldn't be used separately; see
|
||||
* wxSFShapeBase class for more detailed information about functions used for managing of shape
|
||||
* handles and handling their events */
|
||||
class wxSFShapeHandle : public wxObject
|
||||
{
|
||||
public:
|
||||
|
||||
friend class wxSFShapeBase;
|
||||
friend class wxSFShapeCanvas;
|
||||
|
||||
DECLARE_DYNAMIC_CLASS(wxSFShapeHandle);
|
||||
|
||||
/*! \brief Handle type */
|
||||
enum HANDLETYPE
|
||||
{
|
||||
hndLEFTTOP,
|
||||
hndTOP,
|
||||
hndRIGHTTOP,
|
||||
hndRIGHT,
|
||||
hndRIGHTBOTTOM,
|
||||
hndBOTTOM,
|
||||
hndLEFTBOTTOM,
|
||||
hndLEFT,
|
||||
hndLINECTRL,
|
||||
hndLINESTART,
|
||||
hndLINEEND,
|
||||
hndUNDEF
|
||||
};
|
||||
|
||||
/*! \brief Default constructor */
|
||||
wxSFShapeHandle(void);
|
||||
/*!
|
||||
* \brief User constructor
|
||||
* \param parent Parent shape
|
||||
* \param type Handle type
|
||||
* \param id Handle ID (usefull only for line controls handles)
|
||||
*/
|
||||
wxSFShapeHandle(wxSFShapeBase* parent, HANDLETYPE type, long id = -1);
|
||||
/*!
|
||||
* \brief Copy constructor
|
||||
* \param obj Source object
|
||||
*/
|
||||
wxSFShapeHandle(const wxSFShapeHandle& obj);
|
||||
/*! \brief Destructor */
|
||||
virtual ~wxSFShapeHandle(void);
|
||||
|
||||
// public members accessors
|
||||
/*!
|
||||
* \brief Get current handle position.
|
||||
* \return Handle position
|
||||
*/
|
||||
wxPoint GetPosition() const {return m_nCurrPos;}
|
||||
/*!
|
||||
* \brief Get current handle delta (difference between current and previous position).
|
||||
* \return Handle delta
|
||||
*/
|
||||
wxPoint GetDelta() const {return m_nCurrPos - m_nPrevPos;}
|
||||
/*!
|
||||
* \brief Get current total handle delta (difference between current and starting position
|
||||
* stored at the begining of the dragging process).
|
||||
* \return Total handle delta
|
||||
*/
|
||||
wxPoint GetTotalDelta() const {return m_nCurrPos - m_nStartPos;}
|
||||
/*!
|
||||
* \brief Set handle type.
|
||||
* \param type Handle type
|
||||
* \sa HANDLETYPE
|
||||
*/
|
||||
void SetType(HANDLETYPE type){m_nType = type;}
|
||||
/*!
|
||||
* \brief Get handle type.
|
||||
* \return Handle type
|
||||
* \sa HANDLETYPE
|
||||
*/
|
||||
HANDLETYPE GetType(){return m_nType;}
|
||||
/*!
|
||||
* \brief Show/hide handle
|
||||
* \param show TRUE if the handle should be visible (active), otherwise FALSE
|
||||
*/
|
||||
void Show(bool show){m_fVisible = show;}
|
||||
/*! \brief Function returns TRUE if the handle is visible, otherwise FALSE */
|
||||
bool IsVisible(){return m_fVisible;}
|
||||
/*!
|
||||
* \brief Get parent shape.
|
||||
* \return Pointer to parent shape
|
||||
*/
|
||||
wxSFShapeBase* GetParentShape(){return m_pParentShape;}
|
||||
/*!
|
||||
* \brief Set handle's ID.
|
||||
* \param id Handle's ID
|
||||
*/
|
||||
void SetId(long id){m_nId = id;}
|
||||
/*!
|
||||
* \brief Get handle's ID.
|
||||
* \return id Handle's ID
|
||||
*/
|
||||
long GetId(){return m_nId;}
|
||||
|
||||
// public functions
|
||||
/*! \brief Refresh (repaint) the handle */
|
||||
void Refresh();
|
||||
/*!
|
||||
* \brief Find out whether given point is inside the handle.
|
||||
* \param pos Examined point
|
||||
* \return TRUE if the point is inside the handle, otherwise FALSE
|
||||
*/
|
||||
bool Contains(const wxPoint& pos);
|
||||
|
||||
protected:
|
||||
|
||||
// protected data members
|
||||
HANDLETYPE m_nType;
|
||||
wxSFShapeBase *m_pParentShape;
|
||||
|
||||
bool m_fVisible;
|
||||
bool m_fMouseOver;
|
||||
|
||||
// protected functions
|
||||
/*!
|
||||
* \brief Draw handle.
|
||||
* \param dc Device context where the handle will be drawn
|
||||
*/
|
||||
void Draw(wxDC& dc);
|
||||
/*!
|
||||
* \brief Draw handle in the normal way.
|
||||
* \param dc Device context where the handle will be drawn
|
||||
*/
|
||||
void DrawNormal(wxDC& dc);
|
||||
/*!
|
||||
* \brief Draw handle in the "hover" way (the mouse pointer is above the handle area).
|
||||
* \param dc Device context where the handle will be drawn
|
||||
*/
|
||||
void DrawHover(wxDC& dc);
|
||||
|
||||
/*!
|
||||
* \brief Set parent shape.
|
||||
* \param parent Pointer to parent shape
|
||||
*/
|
||||
void SetParentShape(wxSFShapeBase *parent){m_pParentShape = parent;}
|
||||
|
||||
/*!
|
||||
* \brief Get handle rectangle.
|
||||
* \return Handle rectangle
|
||||
*/
|
||||
wxRect GetHandleRect() const;
|
||||
|
||||
private:
|
||||
|
||||
// private data memders
|
||||
wxPoint m_nStartPos;
|
||||
wxPoint m_nPrevPos;
|
||||
wxPoint m_nCurrPos;
|
||||
|
||||
long m_nId;
|
||||
|
||||
/*!
|
||||
* \brief Event handler called when the mouse pointer is moving above shape canvas.
|
||||
* \param pos Current mouse position
|
||||
*/
|
||||
void _OnMouseMove(const wxPoint& pos);
|
||||
/*!
|
||||
* \brief Event handler called when the handle is started to be dragged.
|
||||
* \param pos Current mouse position
|
||||
*/
|
||||
void _OnBeginDrag(const wxPoint& pos);
|
||||
/*!
|
||||
* \brief Event handler called when the handle is dragged.
|
||||
* \param pos Current mouse position
|
||||
*/
|
||||
void _OnDragging(const wxPoint& pos);
|
||||
/*!
|
||||
* \brief Event handler called when the handle is released.
|
||||
* \param pos Current mouse position
|
||||
*/
|
||||
void _OnEndDrag(const wxPoint& pos);
|
||||
};
|
||||
|
||||
WX_DECLARE_LIST(wxSFShapeHandle, HandleList);
|
||||
|
||||
#endif //_WXSFSHAPEHANDLE_H
|
||||
85
sdk/wxshapeframework/include/wx/wxsf/SolidArrow.h
Normal file
85
sdk/wxshapeframework/include/wx/wxsf/SolidArrow.h
Normal file
@@ -0,0 +1,85 @@
|
||||
/***************************************************************
|
||||
* Name: SolidArrow.h
|
||||
* Purpose: Defines solid arrow for line shapes
|
||||
* Author: Michal Bližňák (michal.bliznak@tiscali.cz)
|
||||
* Created: 2007-07-22
|
||||
* Copyright: Michal Bližňák
|
||||
* License: wxWidgets license (www.wxwidgets.org)
|
||||
* Notes:
|
||||
**************************************************************/
|
||||
|
||||
#ifndef _WXSFSOLIDARROW_H
|
||||
#define _WXSFSOLIDARROW_H
|
||||
|
||||
#include <wx/wxsf/ArrowBase.h>
|
||||
|
||||
/*!
|
||||
* \brief Class extends the wxSFArrowBase class and encapsulates
|
||||
* arrow shape consisting of a solid triangle pointing to the end of the
|
||||
* parent line shape.
|
||||
*/
|
||||
class WXDLLIMPEXP_SF wxSFSolidArrow : public wxSFArrowBase
|
||||
{
|
||||
public:
|
||||
XS_DECLARE_CLONABLE_CLASS(wxSFSolidArrow);
|
||||
|
||||
/*! \brief Default constructor. */
|
||||
wxSFSolidArrow(void);
|
||||
/*!
|
||||
* \brief User constructor.
|
||||
* \param parent Pointer to the parent shape
|
||||
*/
|
||||
wxSFSolidArrow(wxSFShapeBase* parent);
|
||||
/*!
|
||||
* \brief Copy constructor.
|
||||
* \param obj Reference to the source object
|
||||
*/
|
||||
wxSFSolidArrow(const wxSFSolidArrow& obj);
|
||||
/*! \brief Destructor. */
|
||||
virtual ~wxSFSolidArrow(void);
|
||||
|
||||
// public functions
|
||||
|
||||
// public member data accessors
|
||||
/*!
|
||||
* \brief Set a brush filling the arrow's body.
|
||||
* \param br Reference to the brush
|
||||
*/
|
||||
void SetArrowFill(const wxBrush& br) {m_Fill = br;}
|
||||
/**
|
||||
* \brief Set a pen used for drawing of the arrow's border.
|
||||
* \param pen Reference to the pen
|
||||
*/
|
||||
void SetArrowPen(const wxPen& pen) {m_Pen = pen;}
|
||||
/*!
|
||||
* \brief Get current brush used for filling of the arrow's body.
|
||||
* \return Constant reference to current brush
|
||||
*/
|
||||
const wxBrush& GetArrowFill() const {return m_Fill;}
|
||||
/**
|
||||
* \brief Get current pen used for drawing of the arrow's border.
|
||||
* \return Constant reference to current pen
|
||||
*/
|
||||
const wxPen& GetArrowPen() const {return m_Pen;}
|
||||
|
||||
// public virtual functions
|
||||
/*!
|
||||
* \brief Draw arrow shape at the end of a virtual line.
|
||||
* \param from Start of the virtual line
|
||||
* \param to End of the virtual line
|
||||
* \param dc Device context for drawing
|
||||
*/
|
||||
virtual void Draw(const wxRealPoint& from, const wxRealPoint& to, wxDC& dc);
|
||||
|
||||
protected:
|
||||
// protected data members
|
||||
/*! \brief Arrows brush. */
|
||||
wxBrush m_Fill;
|
||||
/*! \brief Arrow pen */
|
||||
wxPen m_Pen;
|
||||
|
||||
// protected functions
|
||||
void MarkSerializableDataMembers();
|
||||
};
|
||||
|
||||
#endif //_WXSFSOLIDARROW_H
|
||||
196
sdk/wxshapeframework/include/wx/wxsf/TextShape.h
Normal file
196
sdk/wxshapeframework/include/wx/wxsf/TextShape.h
Normal file
@@ -0,0 +1,196 @@
|
||||
/***************************************************************
|
||||
* Name: TextShape.h
|
||||
* Purpose: Defines static text shape class
|
||||
* Author: Michal Bližňák (michal.bliznak@tiscali.cz)
|
||||
* Created: 2007-07-22
|
||||
* Copyright: Michal Bližňák
|
||||
* License: wxWidgets license (www.wxwidgets.org)
|
||||
* Notes:
|
||||
**************************************************************/
|
||||
|
||||
#ifndef _WXSFTEXTSHAPE_H
|
||||
#define _WXSFTEXTSHAPE_H
|
||||
|
||||
#include <wx/wxsf/RectShape.h>
|
||||
|
||||
// default values
|
||||
/*! \brief Default value of wxSFTextShape::m_Font data member. */
|
||||
#define sfdvTEXTSHAPE_FONT *wxSWISS_FONT
|
||||
/*! \brief Default value of wxSFTextShape::m_TextColor data member. */
|
||||
#define sfdvTEXTSHAPE_TEXTCOLOR *wxBLACK
|
||||
|
||||
/*! \brief Class encapsulates basic non-editable text shape which is suitable for
|
||||
* displaying of various text information in the canvas.
|
||||
* \sa wxSFEditTextShape
|
||||
*/
|
||||
class WXDLLIMPEXP_SF wxSFTextShape : public wxSFRectShape
|
||||
{
|
||||
public:
|
||||
XS_DECLARE_CLONABLE_CLASS(wxSFTextShape);
|
||||
|
||||
/*! \brief Default constructor. */
|
||||
wxSFTextShape(void);
|
||||
/*!
|
||||
* \brief User constructor.
|
||||
* \param pos Initial position
|
||||
* \param txt Text content
|
||||
* \param manager Pointer to parent diagram manager
|
||||
*/
|
||||
wxSFTextShape(const wxRealPoint& pos, const wxString& txt, wxSFDiagramManager* manager);
|
||||
/*!
|
||||
* \brief Copy constructor.
|
||||
* \param obj Source objct
|
||||
*/
|
||||
wxSFTextShape(const wxSFTextShape& obj);
|
||||
/*! \brief Destructor */
|
||||
virtual ~wxSFTextShape();
|
||||
|
||||
// public member data accessors
|
||||
/*!
|
||||
* \brief Set text font.
|
||||
* \param font Font
|
||||
*/
|
||||
void SetFont(const wxFont& font);
|
||||
/*!
|
||||
* \brief Get text font.
|
||||
* \return Font
|
||||
*/
|
||||
wxFont& GetFont(){return m_Font;}
|
||||
/*!
|
||||
* \brief Set text.
|
||||
* \param txt Text content
|
||||
*/
|
||||
void SetText(const wxString& txt);
|
||||
/*!
|
||||
* \brief Get text.
|
||||
* \return Current text content
|
||||
*/
|
||||
wxString GetText() const {return m_sText;}
|
||||
/*!
|
||||
* \brief Set text color.
|
||||
* \param col Text color
|
||||
*/
|
||||
void SetTextColour(const wxColour& col){m_TextColor = col;}
|
||||
/*!
|
||||
* \brief Get text color.
|
||||
* \return Current text color
|
||||
*/
|
||||
wxColour GetTextColour() const {return m_TextColor;}
|
||||
|
||||
// public virtual functions
|
||||
/*!
|
||||
* \brief Scale the shape size by in both directions. The function can be overrided if necessary
|
||||
* (new implementation should call default one ore scale shape's children manualy if neccesary).
|
||||
* \param x Horizontal scale factor
|
||||
* \param y Vertical scale factor
|
||||
* \param children TRUE if the shape's children shoould be scaled as well, otherwise the shape will be updated after scaling via Update() function.
|
||||
*/
|
||||
virtual void Scale(double x, double y, bool children = sfWITHCHILDREN);
|
||||
/*!
|
||||
* \brief Event handler called during dragging of the shape handle.
|
||||
* The function can be overrided if necessary.
|
||||
*
|
||||
* The function is called by the framework (by the shape canvas).
|
||||
* Default implementation does nothing.
|
||||
* \param handle Reference to dragged handle
|
||||
*/
|
||||
virtual void OnHandle(wxSFShapeHandle& handle);
|
||||
/*! \brief Upate shape (align all child shapes an resize it to fit them) */
|
||||
virtual void Update();
|
||||
|
||||
// public functions
|
||||
wxSize GetTextExtent();
|
||||
void UpdateRectSize();
|
||||
|
||||
protected:
|
||||
|
||||
// protected data members
|
||||
wxFont m_Font;
|
||||
wxColour m_TextColor;
|
||||
wxString m_sText;
|
||||
|
||||
// protected virtual functions
|
||||
/*!
|
||||
* \brief Draw the shape in the normal way. The function can be overrided if neccessary.
|
||||
* \param dc Reference to device context where the shape will be drawn to
|
||||
*/
|
||||
virtual void DrawNormal(wxDC& dc);
|
||||
/*!
|
||||
* \brief Draw the shape in the hower mode (the mouse cursor is above the shape).
|
||||
* The function can be overrided if neccessary.
|
||||
* \param dc Reference to device context where the shape will be drawn to
|
||||
*/
|
||||
virtual void DrawHover(wxDC& dc);
|
||||
/*!
|
||||
* \brief Draw the shape in the highlighted mode (another shape is dragged over this
|
||||
* shape and this shape will accept the dragged one if it will be dropped on it).
|
||||
* The function can be overrided if neccessary.
|
||||
* \param dc Reference to device context where the shape will be drawn to
|
||||
*/
|
||||
virtual void DrawHighlighted(wxDC& dc);
|
||||
/*!
|
||||
* \brief Draw shadow under the shape. The function can be overrided if neccessary.
|
||||
* \param dc Reference to device context where the shadow will be drawn to
|
||||
*/
|
||||
virtual void DrawShadow(wxDC& dc);
|
||||
|
||||
/*!
|
||||
* \brief Serialize shape's properties to the given XML node. The serialization
|
||||
* routine is automatically called by the framework and should take care about serialization
|
||||
* of all specific (non-standard) shape's properties.
|
||||
* \param node Pointer to XML node where the shape's property nodes will be appended to
|
||||
* \sa xsSerializable::Serialize
|
||||
*/
|
||||
virtual wxXmlNode* Serialize(wxXmlNode* node);
|
||||
/*!
|
||||
* \brief Deserialize shape's properties from the given XML node. The
|
||||
* routine is automatically called by the framework and should take care about deserialization
|
||||
* of all specific (non-standard) shape's properties.
|
||||
* \param node Pointer to a source XML node containig the shape's property nodes
|
||||
* \sa xsSerializable::Deserialize
|
||||
*/
|
||||
virtual void Deserialize(wxXmlNode* node);
|
||||
|
||||
/*!
|
||||
* \brief Event handler called during dragging of the left shape handle.
|
||||
* The function can be overrided if neccessary.
|
||||
* \param handle Reference to dragged shape handle
|
||||
*/
|
||||
virtual void OnLeftHandle(wxSFShapeHandle& handle);
|
||||
/*!
|
||||
* \brief Event handler called during dragging of the top shape handle.
|
||||
* The function can be overrided if neccessary.
|
||||
* \param handle Reference to dragged shape handle
|
||||
*/
|
||||
virtual void OnTopHandle(wxSFShapeHandle& handle);
|
||||
/*!
|
||||
* \brief Event handler called during dragging of the right shape handle.
|
||||
* The function can be overrided if neccessary.
|
||||
* \param handle Reference to dragged shape handle
|
||||
*/
|
||||
virtual void OnRightHandle(wxSFShapeHandle& handle);
|
||||
/*!
|
||||
* \brief Event handler called during dragging of the bottom shape handle.
|
||||
* The function can be overrided if neccessary.
|
||||
* \param handle Reference to dragged shape handle
|
||||
*/
|
||||
virtual void OnBottomHandle(wxSFShapeHandle& handle);
|
||||
|
||||
// protected functions
|
||||
/*!
|
||||
* \brief Draw text shape.
|
||||
* \param dc Device context where the text shape will be drawn to
|
||||
*/
|
||||
void DrawTextContent(wxDC& dc);
|
||||
|
||||
private:
|
||||
|
||||
// private functions
|
||||
|
||||
/*! \brief Initialize serializable properties. */
|
||||
void MarkSerializableDataMembers();
|
||||
|
||||
wxCoord m_nLineHeight;
|
||||
};
|
||||
|
||||
#endif //_WXSFTEXTSHAPE_H
|
||||
120
sdk/wxshapeframework/include/wx/wxsf/Thumbnail.h
Normal file
120
sdk/wxshapeframework/include/wx/wxsf/Thumbnail.h
Normal file
@@ -0,0 +1,120 @@
|
||||
/***************************************************************
|
||||
* Name: Thumbnail.h
|
||||
* Purpose: Defines canvas thumbnail class
|
||||
* Author: Michal Bližňák (michal.bliznak@tiscali.cz)
|
||||
* Created: 2009-06-09
|
||||
* Copyright: Michal Bližňák
|
||||
* License: wxWidgets license (www.wxwidgets.org)
|
||||
* Notes:
|
||||
**************************************************************/
|
||||
|
||||
#ifndef _WXSFTHUMBNAIL_H
|
||||
#define _WXSFTHUMBNAIL_H
|
||||
|
||||
#include <wx/wxsf/ShapeCanvas.h>
|
||||
|
||||
/**
|
||||
* \brief Class encalpsulating a shape canvas' thumbnail. This GUI control derived from wxPanel can be associated with
|
||||
* one shape canvas and can be used for previewing and manipulating of it.
|
||||
*/
|
||||
class WXDLLIMPEXP_SF wxSFThumbnail : public wxPanel
|
||||
{
|
||||
public:
|
||||
/** \brief Internally used IDs */
|
||||
enum IDS
|
||||
{
|
||||
ID_UPDATETIMER = wxID_HIGHEST + 1,
|
||||
IDM_SHOWELEMENTS,
|
||||
IDM_SHOWCONNECTIONS
|
||||
};
|
||||
/** \brief Thumbnail style */
|
||||
enum THUMBSTYLE
|
||||
{
|
||||
/** \brief Show diagram elements (excluding connections) in the thumbnail. */
|
||||
tsSHOW_ELEMENTS = 1,
|
||||
/** \brief Show diagram connections in the thumbnail. */
|
||||
tsSHOW_CONNECTIONS = 2
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Constructor.
|
||||
* \param parent Pointer to parent window
|
||||
*/
|
||||
wxSFThumbnail(wxWindow *parent);
|
||||
/** \brief Destructor. */
|
||||
virtual ~wxSFThumbnail();
|
||||
|
||||
// public member data accessors
|
||||
/**
|
||||
* \brief Set the thumbnail style.
|
||||
* \param style Style value composed of predefined flags
|
||||
* \sa THUMBSTYLE
|
||||
*/
|
||||
void SetThumbStyle(int style) { m_nThumbStyle = style; }
|
||||
/**
|
||||
* \brief Get current thumbnail style.
|
||||
* \return Style value composed of predefined flags
|
||||
* \sa THUMBSTYLE
|
||||
*/
|
||||
int GetThumbStyle() { return m_nThumbStyle; }
|
||||
|
||||
// public functions
|
||||
/**
|
||||
* \brief Set canvas managed by the thumbnail.
|
||||
* \param canvas Pointer to shape canvas
|
||||
*/
|
||||
void SetCanvas(wxSFShapeCanvas *canvas);
|
||||
|
||||
// public virtual functions
|
||||
/**
|
||||
* \brief Implementation of drawing of the thumbnail's content. This virtual function can be overrided
|
||||
* by the user for customization of the thumbnail appearance.
|
||||
* \param dc Reference to output device context
|
||||
*/
|
||||
virtual void DrawContent(wxDC &dc);
|
||||
|
||||
protected:
|
||||
// protected data members
|
||||
wxSFShapeCanvas *m_pCanvas; /** \brief Pointer to managed shape canvas. */
|
||||
wxTimer m_UpdateTimer; /** \brief Timer user for the thumbnail's update */
|
||||
wxPoint m_nPrevMousePos; /** \brief Auxiliary varialble */
|
||||
double m_nScale; /** \brief Current thumbnail's scale */
|
||||
int m_nThumbStyle; /** \brief Current thumbnail's style */
|
||||
|
||||
// protected event handlers
|
||||
/** \brief Internally used event handler. */
|
||||
void _OnPaint( wxPaintEvent &event );
|
||||
|
||||
// protected functions
|
||||
/**
|
||||
* \brief Get offset (view start) of managed shape canvas defined in pixels.
|
||||
* \return Canvas offset in pixels
|
||||
*/
|
||||
wxSize GetCanvasOffset();
|
||||
|
||||
private:
|
||||
// private event handlers
|
||||
/** \brief Internally used event handler. */
|
||||
void _OnEraseBackground( wxEraseEvent& event );
|
||||
/** \brief Internally used event handler. */
|
||||
void _OnMouseMove( wxMouseEvent &event );
|
||||
/** \brief Internally used event handler. */
|
||||
void _OnLeftDown( wxMouseEvent &event );
|
||||
/** \brief Internally used event handler. */
|
||||
void _OnRightDown( wxMouseEvent &event );
|
||||
/** \brief Internally used event handler. */
|
||||
void _OnTimer( wxTimerEvent &event );
|
||||
|
||||
/** \brief Internally used event handler. */
|
||||
void _OnShowElements( wxCommandEvent &event );
|
||||
/** \brief Internally used event handler. */
|
||||
void _OnShowConnections( wxCommandEvent &event );
|
||||
/** \brief Internally used event handler. */
|
||||
void _OnUpdateShowElements( wxUpdateUIEvent &event );
|
||||
/** \brief Internally used event handler. */
|
||||
void _OnUpdateShowConnections( wxUpdateUIEvent &event );
|
||||
|
||||
DECLARE_EVENT_TABLE();
|
||||
};
|
||||
|
||||
#endif //_WXSFTHUMBNAIL_H
|
||||
59
sdk/wxshapeframework/include/wx/wxsf/wxShapeFramework.h
Normal file
59
sdk/wxshapeframework/include/wx/wxsf/wxShapeFramework.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/***************************************************************
|
||||
* Name: wxShapeFramework.h
|
||||
* Purpose: Main header file
|
||||
* Author: Michal Bližňák (michal.bliznak@tiscali.cz)
|
||||
* Created: 2007-07-22
|
||||
* Copyright: Michal Bližňák
|
||||
* License: wxWidgets license (www.wxwidgets.org)
|
||||
* Notes:
|
||||
**************************************************************/
|
||||
|
||||
#ifndef _WXSF_H_
|
||||
#define _WXSF_H_
|
||||
|
||||
// main library classes
|
||||
#include <wx/wxsf/DiagramManager.h>
|
||||
#include <wx/wxsf/ShapeCanvas.h>
|
||||
#include <wx/wxsf/Thumbnail.h>
|
||||
#include <wx/wxsf/AutoLayout.h>
|
||||
|
||||
// shapes' declarations
|
||||
#include <wx/wxsf/RectShape.h>
|
||||
#include <wx/wxsf/RoundRectShape.h>
|
||||
#include <wx/wxsf/FixedRectShape.h>
|
||||
#include <wx/wxsf/EllipseShape.h>
|
||||
#include <wx/wxsf/CircleShape.h>
|
||||
#include <wx/wxsf/DiamondShape.h>
|
||||
#include <wx/wxsf/TextShape.h>
|
||||
#include <wx/wxsf/EditTextShape.h>
|
||||
#include <wx/wxsf/BitmapShape.h>
|
||||
#include <wx/wxsf/PolygonShape.h>
|
||||
#include <wx/wxsf/ControlShape.h>
|
||||
#include <wx/wxsf/GridShape.h>
|
||||
#include <wx/wxsf/FlexGridShape.h>
|
||||
|
||||
// arrows' declarations
|
||||
#include <wx/wxsf/OpenArrow.h>
|
||||
#include <wx/wxsf/SolidArrow.h>
|
||||
#include <wx/wxsf/DiamondArrow.h>
|
||||
#include <wx/wxsf/CircleArrow.h>
|
||||
|
||||
// connection lines' declarations
|
||||
#include <wx/wxsf/LineShape.h>
|
||||
#include <wx/wxsf/CurveShape.h>
|
||||
#include <wx/wxsf/OrthoShape.h>
|
||||
#include <wx/wxsf/RoundOrthoShape.h>
|
||||
|
||||
// library events
|
||||
#include <wx/wxsf/SFEvents.h>
|
||||
|
||||
// printing support
|
||||
#include <wx/wxsf/Printout.h>
|
||||
|
||||
// common functions
|
||||
#include <wx/wxsf/CommonFcn.h>
|
||||
|
||||
// serialize/deserialize functionality
|
||||
#include <wx/wxxmlserializer/XmlSerializer.h>
|
||||
|
||||
#endif //_WXSF_H_
|
||||
Reference in New Issue
Block a user